From 67e5f56812e7e7c1485d7f0eee7f8ba95780ea04 Mon Sep 17 00:00:00 2001 From: Bing Song Date: Wed, 15 Apr 2020 13:10:06 +0800 Subject: [PATCH] MLK-23791 XUVI/PPM: MU: enable runtime PM for MU3 Need request and free MU3 in runtime. So MU3 will be in non-active when it isn't in use. Signed-off-by: Bing Song Reviewed-by: Jian Li Reviewed-by: Zhou Peng Reviewed-by: Anson Huang --- drivers/mxc/xuvi/ppm.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/mxc/xuvi/ppm.c b/drivers/mxc/xuvi/ppm.c index 82963b3b8f3c..f2c06ab9d867 100644 --- a/drivers/mxc/xuvi/ppm.c +++ b/drivers/mxc/xuvi/ppm.c @@ -884,16 +884,11 @@ static int ppm_probe(struct platform_device *pdev) return -ENOMEM; dev->plat_dev = pdev; - dev->generic_dev = get_device(&pdev->dev); ret = xuvi_attach_pm_domains(dev); if (ret) goto err_pm; - ret = xuvi_mu_request(dev); - if (ret) - goto err_mu; - ret = parse_dt_info(dev, np); if (ret) { dprintk(LVL_ERR, "parse device tree fail\n"); @@ -949,12 +944,12 @@ static int ppm_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); + dev->generic_dev = get_device(&pdev->dev); pm_runtime_put_sync(&pdev->dev); return 0; err_put_dev: -err_mu: xuvi_detach_pm_domains(dev); err_pm: if (&dev->msg_fifo) @@ -1037,8 +1032,11 @@ static int ppm_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); - xuvi_mu_free(dev); xuvi_detach_pm_domains(dev); + if (dev->generic_dev) { + put_device(dev->generic_dev); + dev->generic_dev = NULL; + } devm_kfree(&pdev->dev, dev); return 0; @@ -1046,12 +1044,25 @@ static int ppm_remove(struct platform_device *pdev) static int ppm_runtime_suspend(struct device *dev) { + struct ppm_dev *ppmdev = (struct ppm_dev *)dev_get_drvdata(dev); + + dprintk(LVL_DEBUG, "ppm_runtime_suspend\n"); + if (ppmdev->generic_dev) + xuvi_mu_free(ppmdev); + return 0; } static int ppm_runtime_resume(struct device *dev) { - return 0; + int ret = 0; + struct ppm_dev *ppmdev = (struct ppm_dev *)dev_get_drvdata(dev); + + dprintk(LVL_DEBUG, "ppm_runtime_resume\n"); + if (ppmdev->generic_dev) + ret = xuvi_mu_request(ppmdev); + + return ret; } static int find_first_available_instance(struct ppm_dev *dev) @@ -1132,6 +1143,7 @@ static int __maybe_unused ppm_suspend(struct device *dev) int ret = 0; dprintk(LVL_INFO, "suspend\n"); + pm_runtime_get_sync(ppmdev->generic_dev); if (ppmdev->fw_is_ready) { ppm_send_snapshot(ppmdev); reinit_completion(&ppmdev->snap_done_comp); @@ -1147,6 +1159,7 @@ static int __maybe_unused ppm_suspend(struct device *dev) ppm_dec_cancel_work(ppmdev); ppmdev->suspend = false; dprintk(LVL_INFO, "suspend done\n"); + pm_runtime_put_sync(ppmdev->generic_dev); return ret; }