Lines Matching refs:tsc
92 struct rcar_gen3_thermal_tsc *tsc);
96 static inline u32 rcar_gen3_thermal_read(struct rcar_gen3_thermal_tsc *tsc, in rcar_gen3_thermal_read() argument
99 return ioread32(tsc->base + reg); in rcar_gen3_thermal_read()
102 static inline void rcar_gen3_thermal_write(struct rcar_gen3_thermal_tsc *tsc, in rcar_gen3_thermal_write() argument
105 iowrite32(data, tsc->base + reg); in rcar_gen3_thermal_write()
137 struct rcar_gen3_thermal_tsc *tsc, in rcar_gen3_thermal_calc_coefs() argument
146 tsc->tj_t = (FIXPT_INT((priv->ptat[1] - priv->ptat[2]) * (ths_tj_1 - TJ_3)) in rcar_gen3_thermal_calc_coefs()
149 tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(tsc->thcode[1] - tsc->thcode[2]), in rcar_gen3_thermal_calc_coefs()
150 tsc->tj_t - FIXPT_INT(TJ_3)); in rcar_gen3_thermal_calc_coefs()
151 tsc->coef.b1 = FIXPT_INT(tsc->thcode[2]) - tsc->coef.a1 * TJ_3; in rcar_gen3_thermal_calc_coefs()
153 tsc->coef.a2 = FIXPT_DIV(FIXPT_INT(tsc->thcode[1] - tsc->thcode[0]), in rcar_gen3_thermal_calc_coefs()
154 tsc->tj_t - FIXPT_INT(ths_tj_1)); in rcar_gen3_thermal_calc_coefs()
155 tsc->coef.b2 = FIXPT_INT(tsc->thcode[0]) - tsc->coef.a2 * ths_tj_1; in rcar_gen3_thermal_calc_coefs()
170 struct rcar_gen3_thermal_tsc *tsc = tz->devdata; in rcar_gen3_thermal_get_temp() local
175 reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK; in rcar_gen3_thermal_get_temp()
177 if (reg <= tsc->thcode[1]) in rcar_gen3_thermal_get_temp()
178 val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1, in rcar_gen3_thermal_get_temp()
179 tsc->coef.a1); in rcar_gen3_thermal_get_temp()
181 val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2, in rcar_gen3_thermal_get_temp()
182 tsc->coef.a2); in rcar_gen3_thermal_get_temp()
193 static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc, in rcar_gen3_thermal_mcelsius_to_temp() argument
199 if (celsius <= INT_FIXPT(tsc->tj_t)) in rcar_gen3_thermal_mcelsius_to_temp()
200 val = celsius * tsc->coef.a1 + tsc->coef.b1; in rcar_gen3_thermal_mcelsius_to_temp()
202 val = celsius * tsc->coef.a2 + tsc->coef.b2; in rcar_gen3_thermal_mcelsius_to_temp()
209 struct rcar_gen3_thermal_tsc *tsc = tz->devdata; in rcar_gen3_thermal_set_trips() local
214 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP1, in rcar_gen3_thermal_set_trips()
215 rcar_gen3_thermal_mcelsius_to_temp(tsc, low)); in rcar_gen3_thermal_set_trips()
220 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP2, in rcar_gen3_thermal_set_trips()
221 rcar_gen3_thermal_mcelsius_to_temp(tsc, high)); in rcar_gen3_thermal_set_trips()
224 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, irqmsk); in rcar_gen3_thermal_set_trips()
278 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_read_fuses() local
280 tsc->thcode[0] = thcodes[i][0]; in rcar_gen3_thermal_read_fuses()
281 tsc->thcode[1] = thcodes[i][1]; in rcar_gen3_thermal_read_fuses()
282 tsc->thcode[2] = thcodes[i][2]; in rcar_gen3_thermal_read_fuses()
301 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_read_fuses() local
303 tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE1) & in rcar_gen3_thermal_read_fuses()
305 tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE2) & in rcar_gen3_thermal_read_fuses()
307 tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE3) & in rcar_gen3_thermal_read_fuses()
315 struct rcar_gen3_thermal_tsc *tsc) in rcar_gen3_thermal_init_r8a7795es1() argument
317 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR); in rcar_gen3_thermal_init_r8a7795es1()
318 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0); in rcar_gen3_thermal_init_r8a7795es1()
322 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_PONM); in rcar_gen3_thermal_init_r8a7795es1()
324 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F); in rcar_gen3_thermal_init_r8a7795es1()
325 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); in rcar_gen3_thermal_init_r8a7795es1()
327 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, in rcar_gen3_thermal_init_r8a7795es1()
330 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, in rcar_gen3_thermal_init_r8a7795es1()
335 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, in rcar_gen3_thermal_init_r8a7795es1()
343 struct rcar_gen3_thermal_tsc *tsc) in rcar_gen3_thermal_init() argument
347 reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR); in rcar_gen3_thermal_init()
349 rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val); in rcar_gen3_thermal_init()
353 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0); in rcar_gen3_thermal_init()
354 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); in rcar_gen3_thermal_init()
356 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, in rcar_gen3_thermal_init()
359 reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR); in rcar_gen3_thermal_init()
361 rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val); in rcar_gen3_thermal_init()
490 struct rcar_gen3_thermal_tsc *tsc; in rcar_gen3_thermal_probe() local
496 tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); in rcar_gen3_thermal_probe()
497 if (!tsc) { in rcar_gen3_thermal_probe()
502 tsc->base = devm_ioremap_resource(dev, res); in rcar_gen3_thermal_probe()
503 if (IS_ERR(tsc->base)) { in rcar_gen3_thermal_probe()
504 ret = PTR_ERR(tsc->base); in rcar_gen3_thermal_probe()
508 priv->tscs[i] = tsc; in rcar_gen3_thermal_probe()
517 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_probe() local
519 priv->thermal_init(priv, tsc); in rcar_gen3_thermal_probe()
520 rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1); in rcar_gen3_thermal_probe()
522 zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops); in rcar_gen3_thermal_probe()
528 tsc->zone = zone; in rcar_gen3_thermal_probe()
530 tsc->zone->tzp->no_hwmon = false; in rcar_gen3_thermal_probe()
531 ret = thermal_add_hwmon_sysfs(tsc->zone); in rcar_gen3_thermal_probe()
539 ret = thermal_zone_get_num_trips(tsc->zone); in rcar_gen3_thermal_probe()
565 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_resume() local
567 priv->thermal_init(priv, tsc); in rcar_gen3_thermal_resume()