830-v6.7-45-thermal-drivers-mediatek-lvts_thermal-Add-suspend-an.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. From a1d874ef3376295ee8ed89b3b5315f4c840ff00b Mon Sep 17 00:00:00 2001
  2. From: Balsam CHIHI <[email protected]>
  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. Add suspend and resume support to LVTS driver.
  10. Signed-off-by: Balsam CHIHI <[email protected]>
  11. [[email protected]: suspend/resume in noirq phase]
  12. Co-developed-by: Bernhard Rosenkränzer <[email protected]>
  13. Signed-off-by: Bernhard Rosenkränzer <[email protected]>
  14. Reviewed-by: Matthias Brugger <[email protected]>
  15. Reviewed-by: Alexandre Mergnat <[email protected]>
  16. Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
  17. Signed-off-by: Daniel Lezcano <[email protected]>
  18. Link: https://lore.kernel.org/r/[email protected]
  19. ---
  20. drivers/thermal/mediatek/lvts_thermal.c | 37 +++++++++++++++++++++++++
  21. 1 file changed, 37 insertions(+)
  22. --- a/drivers/thermal/mediatek/lvts_thermal.c
  23. +++ b/drivers/thermal/mediatek/lvts_thermal.c
  24. @@ -1297,6 +1297,38 @@ static const struct lvts_ctrl_data mt798
  25. }
  26. };
  27. +static int lvts_suspend(struct device *dev)
  28. +{
  29. + struct lvts_domain *lvts_td;
  30. + int i;
  31. +
  32. + lvts_td = dev_get_drvdata(dev);
  33. +
  34. + for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
  35. + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
  36. +
  37. + clk_disable_unprepare(lvts_td->clk);
  38. +
  39. + return 0;
  40. +}
  41. +
  42. +static int lvts_resume(struct device *dev)
  43. +{
  44. + struct lvts_domain *lvts_td;
  45. + int i, ret;
  46. +
  47. + lvts_td = dev_get_drvdata(dev);
  48. +
  49. + ret = clk_prepare_enable(lvts_td->clk);
  50. + if (ret)
  51. + return ret;
  52. +
  53. + for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
  54. + lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true);
  55. +
  56. + return 0;
  57. +}
  58. +
  59. static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
  60. {
  61. .cal_offset = { 0x04, 0x07 },
  62. @@ -1405,12 +1437,17 @@ static const struct of_device_id lvts_of
  63. };
  64. MODULE_DEVICE_TABLE(of, lvts_of_match);
  65. +static const struct dev_pm_ops lvts_pm_ops = {
  66. + NOIRQ_SYSTEM_SLEEP_PM_OPS(lvts_suspend, lvts_resume)
  67. +};
  68. +
  69. static struct platform_driver lvts_driver = {
  70. .probe = lvts_probe,
  71. .remove_new = lvts_remove,
  72. .driver = {
  73. .name = "mtk-lvts-thermal",
  74. .of_match_table = lvts_of_match,
  75. + .pm = &lvts_pm_ops,
  76. },
  77. };
  78. module_platform_driver(lvts_driver);