1 From a1d874ef3376295ee8ed89b3b5315f4c840ff00b Mon Sep 17 00:00:00 2001
2 From: Balsam CHIHI <bchihi@baylibre.com>
3 Date: Tue, 17 Oct 2023 21:05:42 +0200
4 Subject: [PATCH 40/42] thermal/drivers/mediatek/lvts_thermal: Add suspend and
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Add suspend and resume support to LVTS driver.
12 Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
13 [bero@baylibre.com: suspend/resume in noirq phase]
14 Co-developed-by: Bernhard Rosenkränzer <bero@baylibre.com>
15 Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com>
16 Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
17 Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
18 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
19 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
20 Link: https://lore.kernel.org/r/20231017190545.157282-3-bero@baylibre.com
22 drivers/thermal/mediatek/lvts_thermal.c | 37 +++++++++++++++++++++++++
23 1 file changed, 37 insertions(+)
25 --- a/drivers/thermal/mediatek/lvts_thermal.c
26 +++ b/drivers/thermal/mediatek/lvts_thermal.c
27 @@ -1297,6 +1297,38 @@ static const struct lvts_ctrl_data mt798
31 +static int lvts_suspend(struct device *dev)
33 + struct lvts_domain *lvts_td;
36 + lvts_td = dev_get_drvdata(dev);
38 + for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
39 + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
41 + clk_disable_unprepare(lvts_td->clk);
46 +static int lvts_resume(struct device *dev)
48 + struct lvts_domain *lvts_td;
51 + lvts_td = dev_get_drvdata(dev);
53 + ret = clk_prepare_enable(lvts_td->clk);
57 + for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
58 + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true);
63 static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
65 .cal_offset = { 0x04, 0x07 },
66 @@ -1405,12 +1437,17 @@ static const struct of_device_id lvts_of
68 MODULE_DEVICE_TABLE(of, lvts_of_match);
70 +static const struct dev_pm_ops lvts_pm_ops = {
71 + NOIRQ_SYSTEM_SLEEP_PM_OPS(lvts_suspend, lvts_resume)
74 static struct platform_driver lvts_driver = {
76 .remove_new = lvts_remove,
78 .name = "mtk-lvts-thermal",
79 .of_match_table = lvts_of_match,
83 module_platform_driver(lvts_driver);