7b4b124b561fcc7d0b95b099a1b98af3dae3b55c
[openwrt/staging/mans0n.git] /
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
5 resume
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Add suspend and resume support to LVTS driver.
11
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
21 ---
22 drivers/thermal/mediatek/lvts_thermal.c | 37 +++++++++++++++++++++++++
23 1 file changed, 37 insertions(+)
24
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
28 }
29 };
30
31 +static int lvts_suspend(struct device *dev)
32 +{
33 + struct lvts_domain *lvts_td;
34 + int i;
35 +
36 + lvts_td = dev_get_drvdata(dev);
37 +
38 + for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
39 + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
40 +
41 + clk_disable_unprepare(lvts_td->clk);
42 +
43 + return 0;
44 +}
45 +
46 +static int lvts_resume(struct device *dev)
47 +{
48 + struct lvts_domain *lvts_td;
49 + int i, ret;
50 +
51 + lvts_td = dev_get_drvdata(dev);
52 +
53 + ret = clk_prepare_enable(lvts_td->clk);
54 + if (ret)
55 + return ret;
56 +
57 + for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
58 + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true);
59 +
60 + return 0;
61 +}
62 +
63 static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
64 {
65 .cal_offset = { 0x04, 0x07 },
66 @@ -1405,12 +1437,17 @@ static const struct of_device_id lvts_of
67 };
68 MODULE_DEVICE_TABLE(of, lvts_of_match);
69
70 +static const struct dev_pm_ops lvts_pm_ops = {
71 + NOIRQ_SYSTEM_SLEEP_PM_OPS(lvts_suspend, lvts_resume)
72 +};
73 +
74 static struct platform_driver lvts_driver = {
75 .probe = lvts_probe,
76 .remove_new = lvts_remove,
77 .driver = {
78 .name = "mtk-lvts-thermal",
79 .of_match_table = lvts_of_match,
80 + .pm = &lvts_pm_ops,
81 },
82 };
83 module_platform_driver(lvts_driver);