Skip to content

Commit

Permalink
wlcore/wl12xx: add plt_init op and move the code to wl12xx
Browse files Browse the repository at this point in the history
PLT mode needs to be initialized differently for each chip.  This
patch adds an operation to init PLT and moves the existing PLT
initialization into the wl12xx driver.

Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
  • Loading branch information
Luciano Coelho committed Jun 5, 2012
1 parent 05057c0 commit c331b34
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 58 deletions.
57 changes: 57 additions & 0 deletions drivers/net/wireless/ti/wl12xx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,10 +1302,67 @@ static void wl12xx_set_tx_desc_csum(struct wl1271 *wl,
desc->wl12xx_reserved = 0;
}

static int wl12xx_plt_init(struct wl1271 *wl)
{
int ret;

ret = wl->ops->boot(wl);
if (ret < 0)
goto out;

ret = wl->ops->hw_init(wl);
if (ret < 0)
goto out_irq_disable;

ret = wl1271_acx_init_mem_config(wl);
if (ret < 0)
goto out_irq_disable;

ret = wl12xx_acx_mem_cfg(wl);
if (ret < 0)
goto out_free_memmap;

/* Enable data path */
ret = wl1271_cmd_data_path(wl, 1);
if (ret < 0)
goto out_free_memmap;

/* Configure for CAM power saving (ie. always active) */
ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
if (ret < 0)
goto out_free_memmap;

/* configure PM */
ret = wl1271_acx_pm_config(wl);
if (ret < 0)
goto out_free_memmap;

goto out;

out_free_memmap:
kfree(wl->target_mem_map);
wl->target_mem_map = NULL;

out_irq_disable:
mutex_unlock(&wl->mutex);
/* Unlocking the mutex in the middle of handling is
inherently unsafe. In this case we deem it safe to do,
because we need to let any possibly pending IRQ out of
the system (and while we are WL1271_STATE_OFF the IRQ
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. */
wlcore_disable_interrupts(wl);
mutex_lock(&wl->mutex);
out:
return ret;
}

static struct wlcore_ops wl12xx_ops = {
.identify_chip = wl12xx_identify_chip,
.identify_fw = wl12xx_identify_fw,
.boot = wl12xx_boot,
.plt_init = wl12xx_plt_init,
.trigger_cmd = wl12xx_trigger_cmd,
.ack_event = wl12xx_ack_event,
.calc_tx_blocks = wl12xx_calc_tx_blocks,
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/wireless/ti/wlcore/acx.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth)
kfree(auth);
return ret;
}
EXPORT_SYMBOL_GPL(wl1271_acx_sleep_auth);

int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif,
int power)
Expand Down Expand Up @@ -997,6 +998,7 @@ int wl12xx_acx_mem_cfg(struct wl1271 *wl)
kfree(mem_conf);
return ret;
}
EXPORT_SYMBOL_GPL(wl12xx_acx_mem_cfg);

int wl1271_acx_init_mem_config(struct wl1271 *wl)
{
Expand Down Expand Up @@ -1027,6 +1029,7 @@ int wl1271_acx_init_mem_config(struct wl1271 *wl)

return 0;
}
EXPORT_SYMBOL_GPL(wl1271_acx_init_mem_config);

int wl1271_acx_init_rx_interrupt(struct wl1271 *wl)
{
Expand Down Expand Up @@ -1150,6 +1153,7 @@ int wl1271_acx_pm_config(struct wl1271 *wl)
kfree(acx);
return ret;
}
EXPORT_SYMBOL_GPL(wl1271_acx_pm_config);

int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif,
bool enable)
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/ti/wlcore/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ int wl1271_cmd_data_path(struct wl1271 *wl, bool enable)
kfree(cmd);
return ret;
}
EXPORT_SYMBOL_GPL(wl1271_cmd_data_path);

int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif,
u8 ps_mode, u16 auto_ps_timeout)
Expand Down
59 changes: 1 addition & 58 deletions drivers/net/wireless/ti/wlcore/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,46 +320,6 @@ static void wlcore_adjust_conf(struct wl1271 *wl)
}
}

static int wl1271_plt_init(struct wl1271 *wl)
{
int ret;

ret = wl->ops->hw_init(wl);
if (ret < 0)
return ret;

ret = wl1271_acx_init_mem_config(wl);
if (ret < 0)
return ret;

ret = wl12xx_acx_mem_cfg(wl);
if (ret < 0)
goto out_free_memmap;

/* Enable data path */
ret = wl1271_cmd_data_path(wl, 1);
if (ret < 0)
goto out_free_memmap;

/* Configure for CAM power saving (ie. always active) */
ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
if (ret < 0)
goto out_free_memmap;

/* configure PM */
ret = wl1271_acx_pm_config(wl);
if (ret < 0)
goto out_free_memmap;

return 0;

out_free_memmap:
kfree(wl->target_mem_map);
wl->target_mem_map = NULL;

return ret;
}

static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl,
struct wl12xx_vif *wlvif,
u8 hlid, u8 tx_pkts)
Expand Down Expand Up @@ -1042,14 +1002,10 @@ int wl1271_plt_start(struct wl1271 *wl)
if (ret < 0)
goto power_off;

ret = wl->ops->boot(wl);
ret = wl->ops->plt_init(wl);
if (ret < 0)
goto power_off;

ret = wl1271_plt_init(wl);
if (ret < 0)
goto irq_disable;

wl->plt = true;
wl->state = WL1271_STATE_ON;
wl1271_notice("firmware booted in PLT mode (%s)",
Expand All @@ -1062,19 +1018,6 @@ int wl1271_plt_start(struct wl1271 *wl)

goto out;

irq_disable:
mutex_unlock(&wl->mutex);
/* Unlocking the mutex in the middle of handling is
inherently unsafe. In this case we deem it safe to do,
because we need to let any possibly pending IRQ out of
the system (and while we are WL1271_STATE_OFF the IRQ
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. */
wlcore_disable_interrupts(wl);
wl1271_flush_deferred_work(wl);
cancel_work_sync(&wl->netstack_work);
mutex_lock(&wl->mutex);
power_off:
wl1271_power_off(wl);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/ti/wlcore/wlcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct wlcore_ops {
int (*identify_chip)(struct wl1271 *wl);
int (*identify_fw)(struct wl1271 *wl);
int (*boot)(struct wl1271 *wl);
int (*plt_init)(struct wl1271 *wl);
void (*trigger_cmd)(struct wl1271 *wl, int cmd_box_addr,
void *buf, size_t len);
void (*ack_event)(struct wl1271 *wl);
Expand Down

0 comments on commit c331b34

Please sign in to comment.