From ef7890463ae9bec8fab7d16448681923736706e3 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Mon, 21 Jan 2019 15:31:57 +0100 Subject: [PATCH] wlcore/sdio/mmc: Debug for runtime PM and power on/off of SDIO Signed-off-by: Ulf Hansson --- drivers/mmc/core/pwrseq_simple.c | 2 ++ drivers/mmc/core/sdio.c | 19 +++++++++++++++++-- drivers/mmc/core/sdio_bus.c | 26 +++++++++++++++++++++++--- drivers/net/wireless/ti/wlcore/sdio.c | 27 ++++++++++++++++++++++++++- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c index ece34c734693..b9b1fc73a5a0 100644 --- a/drivers/mmc/core/pwrseq_simple.c +++ b/drivers/mmc/core/pwrseq_simple.c @@ -66,6 +66,7 @@ static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host) if (!IS_ERR(pwrseq->ext_clk) && !pwrseq->clk_enabled) { clk_prepare_enable(pwrseq->ext_clk); pwrseq->clk_enabled = true; + dev_info(mmc_dev(host), "%s clk_prepare_enable()\n", __func__); } mmc_pwrseq_simple_set_gpios_value(pwrseq, 1); @@ -94,6 +95,7 @@ static void mmc_pwrseq_simple_power_off(struct mmc_host *host) if (!IS_ERR(pwrseq->ext_clk) && pwrseq->clk_enabled) { clk_disable_unprepare(pwrseq->ext_clk); pwrseq->clk_enabled = false; + dev_info(mmc_dev(host), "%s clk_disable_unprepare()\n", __func__); } } diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index d8e17ea6126d..ce7d29ad2651 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1029,11 +1029,13 @@ static int mmc_sdio_power_restore(struct mmc_host *host) static int mmc_sdio_runtime_suspend(struct mmc_host *host) { + dev_info(&host->card->dev, "%s\n", __func__); /* No references to the card, cut the power to it. */ mmc_claim_host(host); mmc_power_off(host); mmc_release_host(host); + dev_info(&host->card->dev, "%s - DONE\n", __func__); return 0; } @@ -1041,19 +1043,27 @@ static int mmc_sdio_runtime_resume(struct mmc_host *host) { int ret; + dev_info(&host->card->dev, "%s\n", __func__); /* Restore power and re-initialize. */ mmc_claim_host(host); mmc_power_up(host, host->card->ocr); ret = mmc_sdio_power_restore(host); mmc_release_host(host); + dev_info(&host->card->dev, "%s - ret=%d DONE\n", __func__, ret); return ret; } static int mmc_sdio_hw_reset(struct mmc_host *host) { + int ret; + + dev_info(&host->card->dev, "%s\n", __func__); mmc_power_cycle(host, host->card->ocr); - return mmc_sdio_power_restore(host); + ret = mmc_sdio_power_restore(host); + + dev_info(&host->card->dev, "%s - ret=%d DONE\n", __func__, ret); + return ret; } static int mmc_sdio_sw_reset(struct mmc_host *host) @@ -1142,6 +1152,8 @@ int mmc_attach_sdio(struct mmc_host *host) * Enable runtime PM for this card */ pm_runtime_enable(&card->dev); + + dev_info(&card->dev, "%s Enabled runtime PM()\n", __func__); } /* @@ -1183,8 +1195,11 @@ int mmc_attach_sdio(struct mmc_host *host) goto remove_added; } - if (host->caps & MMC_CAP_POWER_OFF_CARD) + + if (host->caps & MMC_CAP_POWER_OFF_CARD) { + dev_info(&card->dev, "%s pm_runtime_put()\n", __func__); pm_runtime_put(&card->dev); + } mmc_claim_host(host); return 0; diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index b6d8203e46eb..e4357ce188ef 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c @@ -134,6 +134,8 @@ static int sdio_bus_probe(struct device *dev) const struct sdio_device_id *id; int ret; + dev_info(dev, "%s\n", __func__); + id = sdio_match_device(func, drv); if (!id) return -ENODEV; @@ -149,6 +151,7 @@ static int sdio_bus_probe(struct device *dev) * pm_runtime_get_noresume() in its remove routine. */ if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) { + dev_info(dev, "%s - pm_runtime_get_sync()\n", __func__); ret = pm_runtime_get_sync(dev); if (ret < 0) goto disable_runtimepm; @@ -166,11 +169,14 @@ static int sdio_bus_probe(struct device *dev) if (ret) goto disable_runtimepm; + dev_info(dev, "%s - probe OK\n", __func__); return 0; disable_runtimepm: - if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) + if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) { + dev_info(dev, "%s - ERR call pm_runtime_put_noidle()\n", __func__); pm_runtime_put_noidle(dev); + } dev_pm_domain_detach(dev, false); return ret; } @@ -208,11 +214,25 @@ static int sdio_bus_remove(struct device *dev) return ret; } +#ifdef CONFIG_PM +static int sdio_bus_runtime_suspend(struct device *dev) +{ + dev_info(dev, "%s\n", __func__); + return pm_generic_runtime_suspend(dev); +} + +static int sdio_bus_runtime_resume(struct device *dev) +{ + dev_info(dev, "%s\n", __func__); + return pm_generic_runtime_resume(dev); +} +#endif + static const struct dev_pm_ops sdio_bus_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume) SET_RUNTIME_PM_OPS( - pm_generic_runtime_suspend, - pm_generic_runtime_resume, + sdio_bus_runtime_suspend, + sdio_bus_runtime_resume, NULL ) }; diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c index 4d4b07701149..0a82a11cae97 100644 --- a/drivers/net/wireless/ti/wlcore/sdio.c +++ b/drivers/net/wireless/ti/wlcore/sdio.c @@ -154,6 +154,8 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) struct sdio_func *func = dev_to_sdio_func(glue->dev); struct mmc_card *card = func->card; + dev_info(glue->dev, "%s: STEP1\n", __func__); + ret = pm_runtime_get_sync(&card->dev); if (ret < 0) { pm_runtime_put_noidle(&card->dev); @@ -163,7 +165,12 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) return ret; } + dev_info(glue->dev, "%s: STEP2\n", __func__); + sdio_claim_host(func); + + dev_info(glue->dev, "%s: STEP3\n", __func__); + /* * To guarantee that the SDIO card is power cycled, as required to make * the FW programming to succeed, let's do a brute force HW reset. @@ -171,8 +178,12 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) mmc_hw_reset(card->host); sdio_enable_func(func); + + dev_info(glue->dev, "%s: STEP4\n", __func__); + sdio_release_host(func); + dev_info(glue->dev, "%s: STEP5\n", __func__); return 0; } @@ -181,12 +192,20 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) struct sdio_func *func = dev_to_sdio_func(glue->dev); struct mmc_card *card = func->card; + dev_info(glue->dev, "%s: STEP1\n", __func__); + sdio_claim_host(func); sdio_disable_func(func); + + dev_info(glue->dev, "%s: STEP2\n", __func__); sdio_release_host(func); + + dev_info(glue->dev, "%s: STEP3\n", __func__); /* Let runtime PM know the card is powered off */ pm_runtime_put(&card->dev); + + dev_info(glue->dev, "%s: STEP4\n", __func__); return 0; } @@ -315,7 +334,7 @@ static int wl1271_probe(struct sdio_func *func, /* if sdio can keep power while host is suspended, enable wow */ mmcflags = sdio_get_host_pm_caps(func); - dev_dbg(glue->dev, "sdio PM caps = 0x%x\n", mmcflags); + dev_info(glue->dev, "sdio PM caps = 0x%x\n", mmcflags); if (mmcflags & MMC_PM_KEEP_POWER) pdev_data->pwr_in_suspend = true; @@ -336,6 +355,8 @@ static int wl1271_probe(struct sdio_func *func, else chip_family = "wl12xx"; + dev_info(glue->dev, "chip_family is %s\n", chip_family); + glue->core = platform_device_alloc(chip_family, PLATFORM_DEVID_AUTO); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device"); @@ -375,11 +396,15 @@ static int wl1271_probe(struct sdio_func *func, goto out_dev_put; } + dev_info(glue->dev, "About to add core dev (child)...\n"); + ret = platform_device_add(glue->core); if (ret) { dev_err(glue->dev, "can't add platform device\n"); goto out_dev_put; } + + dev_info(glue->dev, "...added core dev (child) - probe complete!\n"); return 0; out_dev_put: -- 2.17.1