Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: dw_mmc-rockchip: add runtime PM support

This patch adds runtime PM support for dw_mmc-rockchip.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Shawn Lin and committed by
Ulf Hansson
f9014268 e9ed8835

+38 -3
+38 -3
drivers/mmc/host/dw_mmc-rockchip.c
··· 13 13 #include <linux/mmc/host.h> 14 14 #include <linux/mmc/dw_mmc.h> 15 15 #include <linux/of_address.h> 16 + #include <linux/pm_runtime.h> 16 17 #include <linux/slab.h> 17 18 18 19 #include "dw_mmc.h" ··· 326 325 { 327 326 const struct dw_mci_drv_data *drv_data; 328 327 const struct of_device_id *match; 328 + int ret; 329 329 330 330 if (!pdev->dev.of_node) 331 331 return -ENODEV; ··· 334 332 match = of_match_node(dw_mci_rockchip_match, pdev->dev.of_node); 335 333 drv_data = match->data; 336 334 337 - return dw_mci_pltfm_register(pdev, drv_data); 335 + pm_runtime_get_noresume(&pdev->dev); 336 + pm_runtime_set_active(&pdev->dev); 337 + pm_runtime_enable(&pdev->dev); 338 + pm_runtime_set_autosuspend_delay(&pdev->dev, 50); 339 + pm_runtime_use_autosuspend(&pdev->dev); 340 + 341 + ret = dw_mci_pltfm_register(pdev, drv_data); 342 + if (ret) { 343 + pm_runtime_disable(&pdev->dev); 344 + pm_runtime_set_suspended(&pdev->dev); 345 + pm_runtime_put_noidle(&pdev->dev); 346 + return ret; 347 + } 348 + 349 + pm_runtime_put_autosuspend(&pdev->dev); 350 + 351 + return 0; 338 352 } 353 + 354 + static int dw_mci_rockchip_remove(struct platform_device *pdev) 355 + { 356 + pm_runtime_get_sync(&pdev->dev); 357 + pm_runtime_disable(&pdev->dev); 358 + pm_runtime_put_noidle(&pdev->dev); 359 + 360 + return dw_mci_pltfm_remove(pdev); 361 + } 362 + 363 + static const struct dev_pm_ops dw_mci_rockchip_dev_pm_ops = { 364 + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 365 + pm_runtime_force_resume) 366 + SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, 367 + dw_mci_runtime_resume, 368 + NULL) 369 + }; 339 370 340 371 static struct platform_driver dw_mci_rockchip_pltfm_driver = { 341 372 .probe = dw_mci_rockchip_probe, 342 - .remove = dw_mci_pltfm_remove, 373 + .remove = dw_mci_rockchip_remove, 343 374 .driver = { 344 375 .name = "dwmmc_rockchip", 345 376 .of_match_table = dw_mci_rockchip_match, 346 - .pm = &dw_mci_pltfm_pmops, 377 + .pm = &dw_mci_rockchip_dev_pm_ops, 347 378 }, 348 379 }; 349 380