830-v6.4-15-thermal-drivers-mediatek-Control-buffer-enablement-t.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From f6658c1c4ae98477d6be00495226c0617354fe76 Mon Sep 17 00:00:00 2001
  2. From: Markus Schneider-Pargmann <[email protected]>
  3. Date: Fri, 27 Jan 2023 16:44:43 +0100
  4. Subject: [PATCH 11/42] thermal/drivers/mediatek: Control buffer enablement
  5. tweaks
  6. Add logic in order to be able to turn on the control buffer on MT8365.
  7. This change now allows to have control buffer support for MTK_THERMAL_V1,
  8. and it allows to define the register offset, and mask used to enable it.
  9. Signed-off-by: Markus Schneider-Pargmann <[email protected]>
  10. Signed-off-by: Fabien Parent <[email protected]>
  11. Signed-off-by: Amjad Ouled-Ameur <[email protected]>
  12. Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
  13. Link: https://lore.kernel.org/r/[email protected]
  14. Signed-off-by: Daniel Lezcano <[email protected]>
  15. ---
  16. drivers/thermal/mediatek/auxadc_thermal.c | 28 +++++++++++++++--------
  17. 1 file changed, 19 insertions(+), 9 deletions(-)
  18. --- a/drivers/thermal/mediatek/auxadc_thermal.c
  19. +++ b/drivers/thermal/mediatek/auxadc_thermal.c
  20. @@ -307,6 +307,9 @@ struct mtk_thermal_data {
  21. bool need_switch_bank;
  22. struct thermal_bank_cfg bank_data[MAX_NUM_ZONES];
  23. enum mtk_thermal_version version;
  24. + u32 apmixed_buffer_ctl_reg;
  25. + u32 apmixed_buffer_ctl_mask;
  26. + u32 apmixed_buffer_ctl_set;
  27. };
  28. struct mtk_thermal {
  29. @@ -560,6 +563,9 @@ static const struct mtk_thermal_data mt7
  30. .adcpnp = mt7622_adcpnp,
  31. .sensor_mux_values = mt7622_mux_values,
  32. .version = MTK_THERMAL_V2,
  33. + .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1,
  34. + .apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3),
  35. + .apmixed_buffer_ctl_set = BIT(0),
  36. };
  37. /*
  38. @@ -1079,14 +1085,18 @@ static const struct of_device_id mtk_the
  39. };
  40. MODULE_DEVICE_TABLE(of, mtk_thermal_of_match);
  41. -static void mtk_thermal_turn_on_buffer(void __iomem *apmixed_base)
  42. +static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt,
  43. + void __iomem *apmixed_base)
  44. {
  45. - int tmp;
  46. + u32 tmp;
  47. +
  48. + if (!mt->conf->apmixed_buffer_ctl_reg)
  49. + return;
  50. - tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1);
  51. - tmp &= ~(0x37);
  52. - tmp |= 0x1;
  53. - writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1);
  54. + tmp = readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
  55. + tmp &= mt->conf->apmixed_buffer_ctl_mask;
  56. + tmp |= mt->conf->apmixed_buffer_ctl_set;
  57. + writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
  58. udelay(200);
  59. }
  60. @@ -1184,10 +1194,10 @@ static int mtk_thermal_probe(struct plat
  61. goto err_disable_clk_auxadc;
  62. }
  63. - if (mt->conf->version != MTK_THERMAL_V1) {
  64. - mtk_thermal_turn_on_buffer(apmixed_base);
  65. + mtk_thermal_turn_on_buffer(mt, apmixed_base);
  66. +
  67. + if (mt->conf->version != MTK_THERMAL_V2)
  68. mtk_thermal_release_periodic_ts(mt, auxadc_base);
  69. - }
  70. if (mt->conf->version == MTK_THERMAL_V1)
  71. mt->raw_to_mcelsius = raw_to_mcelsius_v1;