From a03fec2ff60895cc9bfebf265499f9ee43eb8a10 Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Wed, 9 Oct 2019 11:10:01 +0800 Subject: [PATCH] mmc: dw_mmc: bypass RPM for native CD Otherwise now the RPM core will gate the clk and power domain, so that the hotplug will be broken. Change-Id: I9104ff1beb2db5ef2752179eb91730f48f3089d7 Signed-off-by: Shawn Lin --- drivers/mmc/host/dw_mmc-rockchip.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c index e7dfafa91164..53134509d1bb 100644 --- a/drivers/mmc/host/dw_mmc-rockchip.c +++ b/drivers/mmc/host/dw_mmc-rockchip.c @@ -338,28 +338,43 @@ static int dw_mci_rockchip_probe(struct platform_device *pdev) const struct dw_mci_drv_data *drv_data; const struct of_device_id *match; int ret; + bool use_rpm = true; if (!pdev->dev.of_node) return -ENODEV; + if (!device_property_read_bool(&pdev->dev, "non-removable") && + !device_property_read_bool(&pdev->dev, "cd-gpios")) + use_rpm = false; + match = of_match_node(dw_mci_rockchip_match, pdev->dev.of_node); drv_data = match->data; + /* + * increase rpm usage count in order to make + * pm_runtime_force_resume calls rpm resume callback + */ pm_runtime_get_noresume(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - pm_runtime_set_autosuspend_delay(&pdev->dev, 50); - pm_runtime_use_autosuspend(&pdev->dev); + + if (use_rpm) { + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 50); + pm_runtime_use_autosuspend(&pdev->dev); + } ret = dw_mci_pltfm_register(pdev, drv_data); if (ret) { - pm_runtime_disable(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); + if (use_rpm) { + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + } pm_runtime_put_noidle(&pdev->dev); return ret; } - pm_runtime_put_autosuspend(&pdev->dev); + if (use_rpm) + pm_runtime_put_autosuspend(&pdev->dev); return 0; }