This change adds pm suspend callbacks in order to trigger a gpio line to push the CHIP_PWD_L reset/power line low on suspend. This puts the chip into the lowest power state on suspend. On resume, it releases the line, allowing the chip to boot. Slower, but provides a clean reset of the chip and recovery from standby. Signed-off-by: Steve deRosier <steve.derosier@xxxxxxxxxxxxx> --- drivers/net/wireless/ath/ath6kl/sdio.c | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 7a732f3..b296809 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1290,9 +1290,54 @@ static int ath6kl_sdio_pm_resume(struct device *device) return 0; } +#ifdef CONFIG_GPIOLIB +/* Below handlers leverage the PM system to make sure we turn on and off + * the power gpio at the right time. If we do it in the earlier power on + * and off handlers for the sdio, we get errors from the mmc subsystem. + */ +static int ath6kl_sdio_pm_suspend_late(struct device *device) +{ + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm ath6kl_sdio_pm_suspend_late\n"); + + if (gpio_is_valid(reset_pwd_gpio)) + gpio_set_value(reset_pwd_gpio, 0); + + return 0; +} + +static int ath6kl_sdio_pm_resume_early(struct device *device) +{ + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm ath6kl_sdio_pm_resume_early\n"); + + if (gpio_is_valid(reset_pwd_gpio)) + gpio_set_value(reset_pwd_gpio, 1); + + usleep_range(1000, 5000); /* wait for power up */ + + return 0; +} + +/* The GPIO version requires the more complex dev_pm_ops setup */ +const struct dev_pm_ops ath6kl_sdio_pm_ops = { + .suspend = ath6kl_sdio_pm_suspend, + .suspend_late = ath6kl_sdio_pm_suspend_late, + .resume_early = ath6kl_sdio_pm_resume_early, + .resume = ath6kl_sdio_pm_resume, + .freeze = ath6kl_sdio_pm_suspend, + .thaw = ath6kl_sdio_pm_resume, + .poweroff = ath6kl_sdio_pm_suspend, + .poweroff_late = ath6kl_sdio_pm_suspend_late, + .restore_early = ath6kl_sdio_pm_resume_early, + .restore = ath6kl_sdio_pm_resume, +}; + +#else + static SIMPLE_DEV_PM_OPS(ath6kl_sdio_pm_ops, ath6kl_sdio_pm_suspend, ath6kl_sdio_pm_resume); +#endif /* CONFIG_GPIOLIB */ + #define ATH6KL_SDIO_PM_OPS (&ath6kl_sdio_pm_ops) #else -- 1.9.1 _______________________________________________ ath6kl mailing list ath6kl@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/ath6kl