Message ID | 20230529164605.3552619-3-bero@baylibre.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | Add LVTS support for mt8192 | expand |
On 29/05/2023 18:46, Bernhard Rosenkränzer wrote: > From: Balsam CHIHI <bchihi@baylibre.com> > > Add suspend and resume support to LVTS driver. > > Signed-off-by: Balsam CHIHI <bchihi@baylibre.com> > Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> > --- > drivers/thermal/mediatek/lvts_thermal.c | 34 +++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c > index d0a3f95b7884b..5ea8a9d569ea6 100644 > --- a/drivers/thermal/mediatek/lvts_thermal.c > +++ b/drivers/thermal/mediatek/lvts_thermal.c > @@ -1169,6 +1169,38 @@ static int lvts_remove(struct platform_device *pdev) > return 0; > } > > +static int lvts_suspend(struct platform_device *pdev, pm_message_t state) > +{ > + struct lvts_domain *lvts_td; > + int i; > + > + lvts_td = platform_get_drvdata(pdev); > + > + for (i = 0; i < lvts_td->num_lvts_ctrl; i++) > + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false); > + > + clk_disable_unprepare(lvts_td->clk); > + > + return 0; > +} > + > +static int lvts_resume(struct platform_device *pdev) > +{ > + struct lvts_domain *lvts_td; > + int i, ret; > + > + lvts_td = platform_get_drvdata(pdev); > + > + ret = clk_prepare_enable(lvts_td->clk); > + if (ret) > + return ret; > + > + for (i = 0; i < lvts_td->num_lvts_ctrl; i++) > + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true); > + > + return 0; > +} > + > static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = { > { > .cal_offset = { 0x04, 0x07 }, > @@ -1268,6 +1300,8 @@ MODULE_DEVICE_TABLE(of, lvts_of_match); > static struct platform_driver lvts_driver = { > .probe = lvts_probe, > .remove = lvts_remove, > + .suspend = lvts_suspend, > + .resume = lvts_resume, > .driver = { > .name = "mtk-lvts-thermal", > .of_match_table = lvts_of_match,
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c index d0a3f95b7884b..5ea8a9d569ea6 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -1169,6 +1169,38 @@ static int lvts_remove(struct platform_device *pdev) return 0; } +static int lvts_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct lvts_domain *lvts_td; + int i; + + lvts_td = platform_get_drvdata(pdev); + + for (i = 0; i < lvts_td->num_lvts_ctrl; i++) + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false); + + clk_disable_unprepare(lvts_td->clk); + + return 0; +} + +static int lvts_resume(struct platform_device *pdev) +{ + struct lvts_domain *lvts_td; + int i, ret; + + lvts_td = platform_get_drvdata(pdev); + + ret = clk_prepare_enable(lvts_td->clk); + if (ret) + return ret; + + for (i = 0; i < lvts_td->num_lvts_ctrl; i++) + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true); + + return 0; +} + static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = { { .cal_offset = { 0x04, 0x07 }, @@ -1268,6 +1300,8 @@ MODULE_DEVICE_TABLE(of, lvts_of_match); static struct platform_driver lvts_driver = { .probe = lvts_probe, .remove = lvts_remove, + .suspend = lvts_suspend, + .resume = lvts_resume, .driver = { .name = "mtk-lvts-thermal", .of_match_table = lvts_of_match,