Skip to content

Commit

Permalink
wl1251: fix ELP_CTRL register accesses when using SDIO
Browse files Browse the repository at this point in the history
For some unknown reason ELP_CTRL can't be accesed using
sdio_memcpy_* functions (any attemts to do so result in timeouts):

 wl1251: ERROR sdio write failed (-110)
 wl1251: ERROR sdio read failed (-110)
 wl1251: WARNING WLAN not ready

To fix this, add special IO functions for ELP_CTRL access that are
using sdio_readb/sdio_writeb. Similar handling is done in TI
reference driver from Android code drop.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Cc: Bob Copeland <me@bobcopeland.com>
Acked-by: Kalle Valo <kalle.valo@iki.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Grazvydas Ignotas authored and John W. Linville committed Mar 15, 2010
1 parent 3c9cb9c commit 3f9e750
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 6 deletions.
2 changes: 2 additions & 0 deletions drivers/net/wireless/wl12xx/wl1251.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ struct wl1251_debugfs {
struct wl1251_if_operations {
void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
void (*read_elp)(struct wl1251 *wl, int addr, u32 *val);
void (*write_elp)(struct wl1251 *wl, int addr, u32 val);
void (*reset)(struct wl1251 *wl);
void (*enable_irq)(struct wl1251 *wl);
void (*disable_irq)(struct wl1251 *wl);
Expand Down
20 changes: 20 additions & 0 deletions drivers/net/wireless/wl12xx/wl1251_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
wl->if_ops->write(wl, addr, &val, sizeof(u32));
}

static inline u32 wl1251_read_elp(struct wl1251 *wl, int addr)
{
u32 response;

if (wl->if_ops->read_elp)
wl->if_ops->read_elp(wl, addr, &response);
else
wl->if_ops->read(wl, addr, &response, sizeof(u32));

return response;
}

static inline void wl1251_write_elp(struct wl1251 *wl, int addr, u32 val)
{
if (wl->if_ops->write_elp)
wl->if_ops->write_elp(wl, addr, val);
else
wl->if_ops->write(wl, addr, &val, sizeof(u32));
}

/* Memory target IO, address is translated to partition 0 */
void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len);
void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/wl12xx/wl1251_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ static void wl1251_fw_wakeup(struct wl1251 *wl)
u32 elp_reg;

elp_reg = ELPCTRL_WAKE_UP;
wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);

if (!(elp_reg & ELPCTRL_WLAN_READY))
wl1251_warning("WLAN not ready");
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/wl12xx/wl1251_ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void wl1251_elp_work(struct work_struct *work)
goto out;

wl1251_debug(DEBUG_PSM, "chip to elp");
wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP);
wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP);
wl->elp = true;

out:
Expand Down Expand Up @@ -79,9 +79,9 @@ int wl1251_ps_elp_wakeup(struct wl1251 *wl)
start = jiffies;
timeout = jiffies + msecs_to_jiffies(WL1251_WAKEUP_TIMEOUT);

wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP);
wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP);

elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);

/*
* FIXME: we should wait for irq from chip but, as a temporary
Expand All @@ -93,7 +93,7 @@ int wl1251_ps_elp_wakeup(struct wl1251 *wl)
return -ETIMEDOUT;
}
msleep(1);
elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
}

wl1251_debug(DEBUG_PSM, "wakeup time: %u ms",
Expand Down
28 changes: 28 additions & 0 deletions drivers/net/wireless/wl12xx/wl1251_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,32 @@ static void wl1251_sdio_write(struct wl1251 *wl, int addr,
sdio_release_host(func);
}

static void wl1251_sdio_read_elp(struct wl1251 *wl, int addr, u32 *val)
{
int ret = 0;
struct sdio_func *func = wl_to_func(wl);

sdio_claim_host(func);
*val = sdio_readb(func, addr, &ret);
sdio_release_host(func);

if (ret)
wl1251_error("sdio_readb failed (%d)", ret);
}

static void wl1251_sdio_write_elp(struct wl1251 *wl, int addr, u32 val)
{
int ret = 0;
struct sdio_func *func = wl_to_func(wl);

sdio_claim_host(func);
sdio_writeb(func, val, addr, &ret);
sdio_release_host(func);

if (ret)
wl1251_error("sdio_writeb failed (%d)", ret);
}

static void wl1251_sdio_reset(struct wl1251 *wl)
{
}
Expand Down Expand Up @@ -111,6 +137,8 @@ static void wl1251_sdio_set_power(bool enable)
static const struct wl1251_if_operations wl1251_sdio_ops = {
.read = wl1251_sdio_read,
.write = wl1251_sdio_write,
.write_elp = wl1251_sdio_write_elp,
.read_elp = wl1251_sdio_read_elp,
.reset = wl1251_sdio_reset,
.enable_irq = wl1251_sdio_enable_irq,
.disable_irq = wl1251_sdio_disable_irq,
Expand Down

0 comments on commit 3f9e750

Please sign in to comment.