Commit dd5512eb authored by Luciano Coelho's avatar Luciano Coelho

wlcore/wl12xx: move top initialization to wl12xx

The top registers initialization is very specific to the actual
hardware used, even the way in which we read from and write to the top
registers varies from chip to chip.  This patch moves all top
registers initialization to wl12xx.  Also add a boot op for the wlcore
module to call at the right time and a few callbacks with the common
called to be called from the lower drivers boot operations.
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 4ded91ce
This diff is collapsed.
......@@ -428,16 +428,6 @@ b12-b0 - Supported Rate indicator bits as defined below.
#define OCP_REG_CLK_POLARITY 0x0cb2
#define OCP_REG_CLK_PULL 0x0cb4
#define WL127X_REG_FUSE_DATA_2_1 0x050a
#define WL128X_REG_FUSE_DATA_2_1 0x2152
#define PG_VER_MASK 0x3c
#define PG_VER_OFFSET 2
#define PG_MAJOR_VER_MASK 0x3
#define PG_MAJOR_VER_OFFSET 0x0
#define PG_MINOR_VER_MASK 0xc
#define PG_MINOR_VER_OFFSET 0x2
#define POLARITY_LOW BIT(1)
#define NO_PULL (BIT(14) | BIT(15))
......
This diff is collapsed.
......@@ -26,8 +26,9 @@
#include "wlcore.h"
int wl1271_boot(struct wl1271 *wl);
int wl1271_load_firmware(struct wl1271 *wl);
int wlcore_boot_upload_firmware(struct wl1271 *wl);
int wlcore_boot_upload_nvs(struct wl1271 *wl);
int wlcore_boot_run_firmware(struct wl1271 *wl);
#define WL1271_NO_SUBBANDS 8
#define WL1271_NO_POWER_LEVELS 4
......
......@@ -32,12 +32,6 @@
#include "io.h"
#include "tx.h"
/*
* TODO: this is here just for now, it will be removed when we move
* the top_reg stuff to wl12xx
*/
#include "../wl12xx/reg.h"
bool wl1271_set_block_size(struct wl1271 *wl)
{
if (wl->if_ops->set_block_size) {
......@@ -48,15 +42,17 @@ bool wl1271_set_block_size(struct wl1271 *wl)
return false;
}
void wl1271_disable_interrupts(struct wl1271 *wl)
void wlcore_disable_interrupts(struct wl1271 *wl)
{
disable_irq(wl->irq);
}
EXPORT_SYMBOL_GPL(wlcore_disable_interrupts);
void wl1271_enable_interrupts(struct wl1271 *wl)
void wlcore_enable_interrupts(struct wl1271 *wl)
{
enable_irq(wl->irq);
}
EXPORT_SYMBOL_GPL(wlcore_enable_interrupts);
int wlcore_translate_addr(struct wl1271 *wl, int addr)
{
......@@ -175,48 +171,3 @@ void wl1271_io_init(struct wl1271 *wl)
if (wl->if_ops->init)
wl->if_ops->init(wl->dev);
}
void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val)
{
/* write address >> 1 + 0x30000 to OCP_POR_CTR */
addr = (addr >> 1) + 0x30000;
wl1271_write32(wl, WL12XX_OCP_POR_CTR, addr);
/* write value to OCP_POR_WDATA */
wl1271_write32(wl, WL12XX_OCP_DATA_WRITE, val);
/* write 1 to OCP_CMD */
wl1271_write32(wl, WL12XX_OCP_CMD, OCP_CMD_WRITE);
}
u16 wl1271_top_reg_read(struct wl1271 *wl, int addr)
{
u32 val;
int timeout = OCP_CMD_LOOP;
/* write address >> 1 + 0x30000 to OCP_POR_CTR */
addr = (addr >> 1) + 0x30000;
wl1271_write32(wl, WL12XX_OCP_POR_CTR, addr);
/* write 2 to OCP_CMD */
wl1271_write32(wl, WL12XX_OCP_CMD, OCP_CMD_READ);
/* poll for data ready */
do {
val = wl1271_read32(wl, WL12XX_OCP_DATA_READ);
} while (!(val & OCP_READY_MASK) && --timeout);
if (!timeout) {
wl1271_warning("Top register access timed out.");
return 0xffff;
}
/* check data status and return if OK */
if ((val & OCP_STATUS_MASK) == OCP_STATUS_OK)
return val & 0xffff;
else {
wl1271_warning("Top register access returned error.");
return 0xffff;
}
}
EXPORT_SYMBOL_GPL(wl1271_top_reg_read);
......@@ -44,8 +44,8 @@
struct wl1271;
void wl1271_disable_interrupts(struct wl1271 *wl);
void wl1271_enable_interrupts(struct wl1271 *wl);
void wlcore_disable_interrupts(struct wl1271 *wl);
void wlcore_enable_interrupts(struct wl1271 *wl);
void wl1271_io_reset(struct wl1271 *wl);
void wl1271_io_init(struct wl1271 *wl);
......@@ -173,11 +173,6 @@ static inline int wl1271_power_on(struct wl1271 *wl)
return ret;
}
/* Top Register IO */
void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val);
u16 wl1271_top_reg_read(struct wl1271 *wl, int addr);
void wlcore_set_partition(struct wl1271 *wl,
const struct wlcore_partition_set *p);
......
......@@ -1397,7 +1397,7 @@ int wl1271_plt_start(struct wl1271 *wl)
if (ret < 0)
goto power_off;
ret = wl1271_boot(wl);
ret = wl->ops->boot(wl);
if (ret < 0)
goto power_off;
......@@ -1426,7 +1426,7 @@ int wl1271_plt_start(struct wl1271 *wl)
work function will not do anything.) Also, any other
possible concurrent operations will fail due to the
current state, hence the wl1271 struct should be safe. */
wl1271_disable_interrupts(wl);
wlcore_disable_interrupts(wl);
wl1271_flush_deferred_work(wl);
cancel_work_sync(&wl->netstack_work);
mutex_lock(&wl->mutex);
......@@ -1453,7 +1453,7 @@ int wl1271_plt_stop(struct wl1271 *wl)
* Otherwise, the interrupt handler might be called and exit without
* reading the interrupt status.
*/
wl1271_disable_interrupts(wl);
wlcore_disable_interrupts(wl);
mutex_lock(&wl->mutex);
if (!wl->plt) {
mutex_unlock(&wl->mutex);
......@@ -1463,7 +1463,7 @@ int wl1271_plt_stop(struct wl1271 *wl)
* may have been disabled when op_stop was called. It will,
* however, balance the above call to disable_interrupts().
*/
wl1271_enable_interrupts(wl);
wlcore_enable_interrupts(wl);
wl1271_error("cannot power down because not in PLT "
"state: %d", wl->state);
......@@ -1734,7 +1734,7 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
* disable and re-enable interrupts in order to flush
* the threaded_irq
*/
wl1271_disable_interrupts(wl);
wlcore_disable_interrupts(wl);
/*
* set suspended flag to avoid triggering a new threaded_irq
......@@ -1742,7 +1742,7 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw,
*/
set_bit(WL1271_FLAG_SUSPENDED, &wl->flags);
wl1271_enable_interrupts(wl);
wlcore_enable_interrupts(wl);
flush_work(&wl->tx_work);
flush_delayed_work(&wl->elp_work);
......@@ -1774,7 +1774,7 @@ static int wl1271_op_resume(struct ieee80211_hw *hw)
wl1271_debug(DEBUG_MAC80211,
"run postponed irq_work directly");
wl1271_irq(0, wl);
wl1271_enable_interrupts(wl);
wlcore_enable_interrupts(wl);
}
mutex_lock(&wl->mutex);
......@@ -1818,7 +1818,7 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
* Otherwise, the interrupt handler might be called and exit without
* reading the interrupt status.
*/
wl1271_disable_interrupts(wl);
wlcore_disable_interrupts(wl);
mutex_lock(&wl->mutex);
if (wl->state == WL1271_STATE_OFF) {
mutex_unlock(&wl->mutex);
......@@ -1828,7 +1828,7 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
* may have been disabled when op_stop was called. It will,
* however, balance the above call to disable_interrupts().
*/
wl1271_enable_interrupts(wl);
wlcore_enable_interrupts(wl);
return;
}
......@@ -2034,7 +2034,7 @@ static bool wl12xx_init_fw(struct wl1271 *wl)
if (ret < 0)
goto power_off;
ret = wl1271_boot(wl);
ret = wl->ops->boot(wl);
if (ret < 0)
goto power_off;
......@@ -2054,7 +2054,7 @@ static bool wl12xx_init_fw(struct wl1271 *wl)
work function will not do anything.) Also, any other
possible concurrent operations will fail due to the
current state, hence the wl1271 struct should be safe. */
wl1271_disable_interrupts(wl);
wlcore_disable_interrupts(wl);
wl1271_flush_deferred_work(wl);
cancel_work_sync(&wl->netstack_work);
mutex_lock(&wl->mutex);
......
......@@ -29,6 +29,7 @@
struct wlcore_ops {
int (*identify_chip)(struct wl1271 *wl);
int (*boot)(struct wl1271 *wl);
s8 (*get_pg_ver)(struct wl1271 *wl);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment