Skip to content

Commit

Permalink
ath6kl: move power control from sdio to core
Browse files Browse the repository at this point in the history
In preparation for cutting down power from the chip on the fly.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  • Loading branch information
Kalle Valo committed Nov 11, 2011
1 parent c89c591 commit b2e7569
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
15 changes: 15 additions & 0 deletions drivers/net/wireless/ath/ath6kl/hif-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,19 @@ static inline int ath6kl_hif_resume(struct ath6kl *ar)

return ar->hif_ops->resume(ar);
}

static inline int ath6kl_hif_power_on(struct ath6kl *ar)
{
ath6kl_dbg(ATH6KL_DBG_HIF, "hif power on\n");

return ar->hif_ops->power_on(ar);
}

static inline int ath6kl_hif_power_off(struct ath6kl *ar)
{
ath6kl_dbg(ATH6KL_DBG_HIF, "hif power off\n");

return ar->hif_ops->power_off(ar);
}

#endif
2 changes: 2 additions & 0 deletions drivers/net/wireless/ath/ath6kl/hif.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ struct ath6kl_hif_ops {
void (*cleanup_scatter)(struct ath6kl *ar);
int (*suspend)(struct ath6kl *ar);
int (*resume)(struct ath6kl *ar);
int (*power_on)(struct ath6kl *ar);
int (*power_off)(struct ath6kl *ar);
};

int ath6kl_hif_setup(struct ath6kl_device *dev);
Expand Down
16 changes: 12 additions & 4 deletions drivers/net/wireless/ath/ath6kl/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ void ath6kl_core_free(struct ath6kl *ar)

void ath6kl_core_cleanup(struct ath6kl *ar)
{
ath6kl_hif_power_off(ar);

destroy_workqueue(ar->ath6kl_wq);

if (ar->htc_target)
Expand Down Expand Up @@ -1602,27 +1604,31 @@ int ath6kl_core_init(struct ath6kl *ar)
if (ret)
goto err_wq;

ret = ath6kl_bmi_get_target_info(ar, &targ_info);
ret = ath6kl_hif_power_on(ar);
if (ret)
goto err_bmi_cleanup;

ret = ath6kl_bmi_get_target_info(ar, &targ_info);
if (ret)
goto err_power_off;

ar->version.target_ver = le32_to_cpu(targ_info.version);
ar->target_type = le32_to_cpu(targ_info.type);
ar->wiphy->hw_version = le32_to_cpu(targ_info.version);

ret = ath6kl_init_hw_params(ar);
if (ret)
goto err_bmi_cleanup;
goto err_power_off;

ret = ath6kl_configure_target(ar);
if (ret)
goto err_bmi_cleanup;
goto err_power_off;

ar->htc_target = ath6kl_htc_create(ar);

if (!ar->htc_target) {
ret = -ENOMEM;
goto err_bmi_cleanup;
goto err_power_off;
}

ret = ath6kl_fetch_firmwares(ar);
Expand All @@ -1641,6 +1647,8 @@ int ath6kl_core_init(struct ath6kl *ar)

err_htc_cleanup:
ath6kl_htc_cleanup(ar->htc_target);
err_power_off:
ath6kl_hif_power_off(ar);
err_bmi_cleanup:
ath6kl_bmi_cleanup(ar);
err_wq:
Expand Down
20 changes: 8 additions & 12 deletions drivers/net/wireless/ath/ath6kl/sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,9 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func)
WARN_ON(status && status != -ECANCELED);
}

static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio)
static int ath6kl_sdio_power_on(struct ath6kl *ar)
{
struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
struct sdio_func *func = ar_sdio->func;
int ret = 0;

Expand Down Expand Up @@ -495,8 +496,9 @@ static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio)
return ret;
}

static int ath6kl_sdio_power_off(struct ath6kl_sdio *ar_sdio)
static int ath6kl_sdio_power_off(struct ath6kl *ar)
{
struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
int ret;

if (ar_sdio->is_disabled)
Expand Down Expand Up @@ -772,6 +774,8 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = {
.cleanup_scatter = ath6kl_sdio_cleanup_scatter,
.suspend = ath6kl_sdio_suspend,
.resume = ath6kl_sdio_resume,
.power_on = ath6kl_sdio_power_on,
.power_off = ath6kl_sdio_power_off,
};

static int ath6kl_sdio_probe(struct sdio_func *func,
Expand Down Expand Up @@ -852,32 +856,26 @@ static int ath6kl_sdio_probe(struct sdio_func *func,

sdio_release_host(func);

ret = ath6kl_sdio_power_on(ar_sdio);
if (ret)
goto err_core_alloc;

sdio_claim_host(func);

ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE);
if (ret) {
ath6kl_err("Set sdio block size %d failed: %d)\n",
HIF_MBOX_BLOCK_SIZE, ret);
sdio_release_host(func);
goto err_off;
goto err_hif;
}

sdio_release_host(func);

ret = ath6kl_core_init(ar);
if (ret) {
ath6kl_err("Failed to init ath6kl core\n");
goto err_off;
goto err_hif;
}

return ret;

err_off:
ath6kl_sdio_power_off(ar_sdio);
err_core_alloc:
ath6kl_core_free(ar_sdio->ar);
err_dma:
Expand All @@ -903,8 +901,6 @@ static void ath6kl_sdio_remove(struct sdio_func *func)

ath6kl_core_cleanup(ar_sdio->ar);

ath6kl_sdio_power_off(ar_sdio);

kfree(ar_sdio->dma_buffer);
kfree(ar_sdio);
}
Expand Down

0 comments on commit b2e7569

Please sign in to comment.