diff options
author | Anson Huang <Anson.Huang@nxp.com> | 2016-11-08 20:33:16 +0800 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:25:14 +0800 |
commit | 543bc9d13f6bf3ba331db5e7fbbd8b6a4a467586 (patch) | |
tree | e93b5528c1b8d5cb5fb9df46a4b78ac72e6a7138 /drivers/mmc | |
parent | a0fd474b31b4d9ada8eacfb824d58648b040ffb5 (diff) |
MLK-13441-16 mmc: host: imx: add pm_qos to interact with cpuidle
On some SoCs such as i.MX7ULP, there is no busfreq
driver, but cpuidle has some levels which may disable
system/bus clocks, so need to add pm_qos to prevent
cpuidle from entering low level idles and make sure
system/bus clocks are enabled when usdhc is active.
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/sdhci-esdhc-imx.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 4c45573d854d..c1e89f91c55e 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -18,6 +18,7 @@ #include <linux/clk.h> #include <linux/gpio.h> #include <linux/module.h> +#include <linux/pm_qos.h> #include <linux/slab.h> #include <linux/mmc/host.h> #include <linux/mmc/mmc.h> @@ -150,6 +151,8 @@ #define ESDHC_FLAG_ERR010450 BIT(11) /* need request bus freq during low power */ #define ESDHC_FLAG_BUSFREQ BIT(12) +/* need request pmqos during low power */ +#define ESDHC_FLAG_PMQOS BIT(13) /* A clock frequency higher than this rate requires strobe dll control */ #define ESDHC_STROBE_DLL_CLK_FREQ 100000000 @@ -219,6 +222,13 @@ static struct esdhc_soc_data usdhc_imx7d_data = { | ESDHC_FLAG_BUSFREQ, }; +static struct esdhc_soc_data usdhc_imx7ulp_data = { + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING + | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 + | ESDHC_FLAG_STATE_LOST_IN_LPMODE + | ESDHC_FLAG_PMQOS, +}; + struct pltfm_imx_data { u32 scratchpad; struct pinctrl *pinctrl; @@ -236,6 +246,7 @@ struct pltfm_imx_data { WAIT_FOR_INT, /* sent CMD12, waiting for response INT */ } multiblock_status; u32 is_ddr; + struct pm_qos_request pm_qos_req; }; static const struct platform_device_id imx_esdhc_devtype[] = { @@ -264,6 +275,7 @@ static const struct of_device_id imx_esdhc_dt_ids[] = { { .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, }, { .compatible = "fsl,imx6ull-usdhc", .data = &usdhc_imx6ull_data, }, { .compatible = "fsl,imx7d-usdhc", .data = &usdhc_imx7d_data, }, + { .compatible = "fsl,imx7ulp-usdhc", .data = &usdhc_imx7ulp_data, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids); @@ -1335,6 +1347,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (imx_data->socdata->flags & ESDHC_FLAG_BUSFREQ) request_bus_freq(BUS_FREQ_HIGH); + if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) + pm_qos_add_request(&imx_data->pm_qos_req, + PM_QOS_CPU_DMA_LATENCY, 0); + err = clk_prepare_enable(imx_data->clk_per); if (err) goto free_sdhci; @@ -1411,6 +1427,8 @@ disable_per_clk: if (imx_data->socdata->flags & ESDHC_FLAG_BUSFREQ) release_bus_freq(BUS_FREQ_HIGH); + if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) + pm_qos_remove_request(&imx_data->pm_qos_req); free_sdhci: sdhci_pltfm_free(pdev); return err; @@ -1423,6 +1441,9 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev) struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); + if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) + pm_qos_remove_request(&imx_data->pm_qos_req); + pm_runtime_get_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); @@ -1504,6 +1525,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev) if (imx_data->socdata->flags & ESDHC_FLAG_BUSFREQ) release_bus_freq(BUS_FREQ_HIGH); + if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) + pm_qos_remove_request(&imx_data->pm_qos_req); + return ret; } @@ -1517,6 +1541,10 @@ static int sdhci_esdhc_runtime_resume(struct device *dev) if (imx_data->socdata->flags & ESDHC_FLAG_BUSFREQ) request_bus_freq(BUS_FREQ_HIGH); + if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) + pm_qos_add_request(&imx_data->pm_qos_req, + PM_QOS_CPU_DMA_LATENCY, 0); + if (!sdhci_sdio_irq_enabled(host)) { err = clk_prepare_enable(imx_data->clk_per); if (err) |