[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220515064126.1424-7-linux.amoon@gmail.com>
Date: Sun, 15 May 2022 06:41:23 +0000
From: Anand Moon <linux.amoon@...il.com>
To: Bartlomiej Zolnierkiewicz <bzolnier@...il.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Alim Akhtar <alim.akhtar@...sung.com>,
linux-pm@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: Anand Moon <linux.amoon@...il.com>
Subject: [PATCHv2 6/6] thermal: exynos: Add runtime power management for tmu
Add runtime power management for exynos thermal driver.
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...il.com>
Signed-off-by: Anand Moon <linux.amoon@...il.com>
---
v1: new patch in this series.
---
drivers/thermal/samsung/exynos_tmu.c | 29 ++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index f8a527f19383..be9b98caf2ba 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -20,6 +20,7 @@
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
+#include <linux/pm_runtime.h>
#include <dt-bindings/thermal/thermal_exynos.h>
@@ -1106,6 +1107,15 @@ static int exynos_tmu_probe(struct platform_device *pdev)
goto err_thermal;
}
+ pm_runtime_set_active(&pdev->dev);
+ pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
+ pm_runtime_use_autosuspend(&pdev->dev);
+ pm_runtime_enable(&pdev->dev);
+
+ ret = pm_runtime_resume_and_get(&pdev->dev);
+ if (ret < 0)
+ goto disable_runtime_pm;
+
ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
if (ret) {
@@ -1113,11 +1123,16 @@ static int exynos_tmu_probe(struct platform_device *pdev)
goto err_thermal;
}
+ pm_runtime_put(&pdev->dev);
+
exynos_tmu_control(pdev, true);
return 0;
err_thermal:
thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
+disable_runtime_pm:
+ pm_runtime_put_noidle(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
err_clk_sec:
clk_disable_unprepare(data->clk_sec);
err_sclk:
@@ -1143,6 +1158,9 @@ static int exynos_tmu_remove(struct platform_device *pdev)
clk_disable_unprepare(data->clk);
clk_disable_unprepare(data->clk_sec);
+ pm_runtime_put_noidle(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
+
if (!IS_ERR(data->regulator))
regulator_disable(data->regulator);
@@ -1151,18 +1169,25 @@ static int exynos_tmu_remove(struct platform_device *pdev)
static int __maybe_unused exynos_tmu_suspend(struct device *dev)
{
- exynos_tmu_control(to_platform_device(dev), false);
+ struct platform_device *pdev = to_platform_device(dev);
- return 0;
+ exynos_tmu_control(pdev, false);
+
+ return pm_runtime_force_suspend(&pdev->dev);
}
static int __maybe_unused exynos_tmu_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
+ int ret;
exynos_tmu_initialize(pdev);
exynos_tmu_control(pdev, true);
+ ret = pm_runtime_force_resume(&pdev->dev);
+ if (ret)
+ return ret;
+
return 0;
}
--
2.36.1
Powered by blists - more mailing lists