Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/drivers/qoriq: Support version 2.1

i.MX93 use TMU version 2.1, which supports:
- TRITSR_TP5(When this field is 1, you must add 0.5 K to the temperature
that TEMP reports. For example, if TEMP is 300 K and TP5=1, then the
final temperature is 300.5 K.)
- Has 16 TTRCR register: Temperature Range Control (TTRCR0 - TTRCR15)

This patch is to add this support.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230516083746.63436-4-peng.fan@oss.nxp.com

authored by

Peng Fan and committed by
Daniel Lezcano
f12d60c8 9301575d

+10 -4
+10 -4
drivers/thermal/qoriq_thermal.c
··· 50 50 * Site Register 51 51 */ 52 52 #define TRITSR_V BIT(31) 53 + #define TRITSR_TP5 BIT(9) 53 54 #define REGS_V2_TMSAR(n) (0x304 + 16 * (n)) /* TMU monitoring 54 55 * site adjustment register 55 56 */ ··· 118 117 10 * USEC_PER_MSEC)) 119 118 return -ENODATA; 120 119 121 - if (qdata->ver == TMU_VER1) 120 + if (qdata->ver == TMU_VER1) { 122 121 *temp = (val & GENMASK(7, 0)) * MILLIDEGREE_PER_DEGREE; 123 - else 124 - *temp = kelvin_to_millicelsius(val & GENMASK(8, 0)); 122 + } else { 123 + if (val & TRITSR_TP5) 124 + *temp = milli_kelvin_to_millicelsius((val & GENMASK(8, 0)) * 125 + MILLIDEGREE_PER_DEGREE + 500); 126 + else 127 + *temp = kelvin_to_millicelsius(val & GENMASK(8, 0)); 128 + } 125 129 126 130 return 0; 127 131 } ··· 240 234 241 235 static const struct regmap_range qoriq_yes_ranges[] = { 242 236 regmap_reg_range(REGS_TMR, REGS_TSCFGR), 243 - regmap_reg_range(REGS_TTRnCR(0), REGS_TTRnCR(3)), 237 + regmap_reg_range(REGS_TTRnCR(0), REGS_TTRnCR(15)), 244 238 regmap_reg_range(REGS_V2_TEUMR(0), REGS_V2_TEUMR(2)), 245 239 regmap_reg_range(REGS_V2_TMSAR(0), REGS_V2_TMSAR(15)), 246 240 regmap_reg_range(REGS_IPBRR(0), REGS_IPBRR(1)),