Lines Matching +full:anatop +full:- +full:reg +full:- +full:offset

6  * SPDX-License-Identifier:	GPL-2.0+
24 #define TEMPERATURE_HOT_DELTA 5 /* CPU maxT - 5C */
28 #define OFFSET 3580661 macro
30 #define TEMPERATURE_MIN -40
53 unsigned int reg, n_meas; in read_cpu_temperature() local
55 struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; in read_cpu_temperature() local
57 u32 fuse = priv->fuse; in read_cpu_temperature()
65 * [31:20] - sensor value @ 25C in read_cpu_temperature()
67 * slope = 0.4445388 - (0.0016549 * 25C fuse) in read_cpu_temperature()
74 * slope = 0.4445388 - (0.0016549 * 25C fuse) in read_cpu_temperature()
75 * slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0 in read_cpu_temperature()
76 * offset = 3.580661 in read_cpu_temperature()
77 * offset = OFFSET / 1000000 in read_cpu_temperature()
78 * (Nmeas - n1) / (Tmeas - t1 - offset) = slope in read_cpu_temperature()
82 * Tmeas = (Nmeas - n1) / slope + t1 + offset in read_cpu_temperature()
83 * milli_Tmeas = 1000000 * (Nmeas - n1) / slope + 1000000 * t1 + OFFSET in read_cpu_temperature()
84 * milli_Tmeas = -1000000 * (n1 - Nmeas) / slope + 1000000 * t1 + OFFSET in read_cpu_temperature()
85 * Let constant c1 = (-1000000 / slope) in read_cpu_temperature()
86 * milli_Tmeas = (n1 - Nmeas) * c1 + 1000000 * t1 + OFFSET in read_cpu_temperature()
88 * milli_Tmeas = (c2 - Nmeas * c1) + OFFSET in read_cpu_temperature()
89 * Tmeas = ((c2 - Nmeas * c1) + OFFSET) / 1000000 in read_cpu_temperature()
93 temp64 = div_s64_rem(temp64, FACTOR1 * n1 - FACTOR2, &rem); in read_cpu_temperature()
102 writel(TEMPSENSE0_POWER_DOWN, &anatop->tempsense0_clr); in read_cpu_temperature()
103 writel(MISC0_REFTOP_SELBIASOFF, &anatop->ana_misc0_set); in read_cpu_temperature()
106 reg = readl(&anatop->tempsense1); in read_cpu_temperature()
107 reg &= ~TEMPSENSE1_MEASURE_FREQ; in read_cpu_temperature()
108 reg |= MEASURE_FREQ; in read_cpu_temperature()
109 writel(reg, &anatop->tempsense1); in read_cpu_temperature()
112 writel(TEMPSENSE0_MEASURE_TEMP, &anatop->tempsense0_clr); in read_cpu_temperature()
113 writel(TEMPSENSE0_FINISHED, &anatop->tempsense0_clr); in read_cpu_temperature()
114 writel(TEMPSENSE0_MEASURE_TEMP, &anatop->tempsense0_set); in read_cpu_temperature()
117 while ((readl(&anatop->tempsense0) & in read_cpu_temperature()
122 reg = readl(&anatop->tempsense0); in read_cpu_temperature()
123 n_meas = (reg & TEMPSENSE0_TEMP_CNT_MASK) in read_cpu_temperature()
125 writel(TEMPSENSE0_FINISHED, &anatop->tempsense0_clr); in read_cpu_temperature()
127 /* Tmeas = (c2 - Nmeas * c1 + OFFSET) / 1000000 */ in read_cpu_temperature()
128 temperature = div_s64_rem(c2 - n_meas * c1 + OFFSET, 1000000, &rem); in read_cpu_temperature()
130 /* power down anatop thermal sensor */ in read_cpu_temperature()
131 writel(TEMPSENSE0_POWER_DOWN, &anatop->tempsense0_set); in read_cpu_temperature()
132 writel(MISC0_REFTOP_SELBIASOFF, &anatop->ana_misc0_clr); in read_cpu_temperature()
139 unsigned int reg, tmp; in read_cpu_temperature() local
165 writel(TEMPMON_HW_ANADIG_TEMPSENSE1_POWER_DOWN_MASK, &ccm_anatop->tempsense1_clr); in read_cpu_temperature()
166 writel(PMU_REF_REFTOP_SELFBIASOFF_MASK, &ccm_anatop->ref_set); in read_cpu_temperature()
169 reg = readl(&ccm_anatop->tempsense1); in read_cpu_temperature()
170 reg &= ~TEMPMON_HW_ANADIG_TEMPSENSE1_MEASURE_FREQ_MASK; in read_cpu_temperature()
171 reg |= TEMPMON_HW_ANADIG_TEMPSENSE1_MEASURE_FREQ(MEASURE_FREQ); in read_cpu_temperature()
172 writel(reg, &ccm_anatop->tempsense1); in read_cpu_temperature()
174 writel(TEMPMON_HW_ANADIG_TEMPSENSE1_MEASURE_TEMP_MASK, &ccm_anatop->tempsense1_clr); in read_cpu_temperature()
175 writel(TEMPMON_HW_ANADIG_TEMPSENSE1_FINISHED_MASK, &ccm_anatop->tempsense1_clr); in read_cpu_temperature()
176 writel(TEMPMON_HW_ANADIG_TEMPSENSE1_MEASURE_TEMP_MASK, &ccm_anatop->tempsense1_set); in read_cpu_temperature()
179 while ((readl(&ccm_anatop->tempsense1) & in read_cpu_temperature()
182 reg = readl(&ccm_anatop->tempsense1); in read_cpu_temperature()
183 tmp = (reg & TEMPMON_HW_ANADIG_TEMPSENSE1_TEMP_VALUE_MASK) in read_cpu_temperature()
193 reg = readl(&ccm_anatop->tempsense1); in read_cpu_temperature()
194 tmp = (reg & TEMPMON_HW_ANADIG_TEMPSENSE1_TEMP_VALUE_MASK) in read_cpu_temperature()
198 writel(TEMPMON_HW_ANADIG_TEMPSENSE1_FINISHED_MASK, &ccm_anatop->tempsense1_clr); in read_cpu_temperature()
200 /* power down anatop thermal sensor */ in read_cpu_temperature()
201 writel(TEMPMON_HW_ANADIG_TEMPSENSE1_POWER_DOWN_MASK, &ccm_anatop->tempsense1_set); in read_cpu_temperature()
202 writel(PMU_REF_REFTOP_SELFBIASOFF_MASK, &ccm_anatop->ref_clr); in read_cpu_temperature()
205 temperature = tmp - (te1 - raw_25c); in read_cpu_temperature()
218 while (cpu_tmp >= priv->critical) { in imx_thermal_get_temp()
220 cpu_tmp, priv->maxc); in imx_thermal_get_temp()
243 fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse); in imx_thermal_probe()
250 return -EPERM; in imx_thermal_probe()
255 return -EPERM; in imx_thermal_probe()
258 return -EPERM; in imx_thermal_probe()
262 get_cpu_temp_grade(&priv->minc, &priv->maxc); in imx_thermal_probe()
263 priv->critical = priv->maxc - TEMPERATURE_HOT_DELTA; in imx_thermal_probe()
264 priv->fuse = fuse; in imx_thermal_probe()