Lines Matching refs:tsc

99 static inline u32 rcar_gen3_thermal_read(struct rcar_gen3_thermal_tsc *tsc,  in rcar_gen3_thermal_read()  argument
102 return ioread32(tsc->base + reg); in rcar_gen3_thermal_read()
105 static inline void rcar_gen3_thermal_write(struct rcar_gen3_thermal_tsc *tsc, in rcar_gen3_thermal_write() argument
108 iowrite32(data, tsc->base + reg); in rcar_gen3_thermal_write()
140 struct rcar_gen3_thermal_tsc *tsc, in rcar_gen3_thermal_calc_coefs() argument
149 tsc->tj_t = (FIXPT_INT((priv->ptat[1] - priv->ptat[2]) * (ths_tj_1 - TJ_3)) in rcar_gen3_thermal_calc_coefs()
152 tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(tsc->thcode[1] - tsc->thcode[2]), in rcar_gen3_thermal_calc_coefs()
153 tsc->tj_t - FIXPT_INT(TJ_3)); in rcar_gen3_thermal_calc_coefs()
154 tsc->coef.b1 = FIXPT_INT(tsc->thcode[2]) - tsc->coef.a1 * TJ_3; in rcar_gen3_thermal_calc_coefs()
156 tsc->coef.a2 = FIXPT_DIV(FIXPT_INT(tsc->thcode[1] - tsc->thcode[0]), in rcar_gen3_thermal_calc_coefs()
157 tsc->tj_t - FIXPT_INT(ths_tj_1)); in rcar_gen3_thermal_calc_coefs()
158 tsc->coef.b2 = FIXPT_INT(tsc->thcode[0]) - tsc->coef.a2 * ths_tj_1; in rcar_gen3_thermal_calc_coefs()
173 struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_priv(tz); in rcar_gen3_thermal_get_temp() local
178 reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK; in rcar_gen3_thermal_get_temp()
180 if (reg <= tsc->thcode[1]) in rcar_gen3_thermal_get_temp()
181 val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1, in rcar_gen3_thermal_get_temp()
182 tsc->coef.a1); in rcar_gen3_thermal_get_temp()
184 val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2, in rcar_gen3_thermal_get_temp()
185 tsc->coef.a2); in rcar_gen3_thermal_get_temp()
196 static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc, in rcar_gen3_thermal_mcelsius_to_temp() argument
202 if (celsius <= INT_FIXPT(tsc->tj_t)) in rcar_gen3_thermal_mcelsius_to_temp()
203 val = celsius * tsc->coef.a1 + tsc->coef.b1; in rcar_gen3_thermal_mcelsius_to_temp()
205 val = celsius * tsc->coef.a2 + tsc->coef.b2; in rcar_gen3_thermal_mcelsius_to_temp()
212 struct rcar_gen3_thermal_tsc *tsc = thermal_zone_device_priv(tz); in rcar_gen3_thermal_set_trips() local
217 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP1, in rcar_gen3_thermal_set_trips()
218 rcar_gen3_thermal_mcelsius_to_temp(tsc, low)); in rcar_gen3_thermal_set_trips()
223 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP2, in rcar_gen3_thermal_set_trips()
224 rcar_gen3_thermal_mcelsius_to_temp(tsc, high)); in rcar_gen3_thermal_set_trips()
227 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, irqmsk); in rcar_gen3_thermal_set_trips()
271 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_read_fuses_gen3() local
273 tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE1) & in rcar_gen3_thermal_read_fuses_gen3()
275 tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE2) & in rcar_gen3_thermal_read_fuses_gen3()
277 tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE3) & in rcar_gen3_thermal_read_fuses_gen3()
299 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_read_fuses_gen4() local
301 tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON01) & in rcar_gen3_thermal_read_fuses_gen4()
303 tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON02) & in rcar_gen3_thermal_read_fuses_gen4()
305 tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON00) & in rcar_gen3_thermal_read_fuses_gen4()
333 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_read_fuses() local
335 tsc->thcode[0] = thcodes[i][0]; in rcar_gen3_thermal_read_fuses()
336 tsc->thcode[1] = thcodes[i][1]; in rcar_gen3_thermal_read_fuses()
337 tsc->thcode[2] = thcodes[i][2]; in rcar_gen3_thermal_read_fuses()
348 struct rcar_gen3_thermal_tsc *tsc) in rcar_gen3_thermal_init() argument
352 reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR); in rcar_gen3_thermal_init()
354 rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val); in rcar_gen3_thermal_init()
358 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0); in rcar_gen3_thermal_init()
359 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); in rcar_gen3_thermal_init()
361 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, in rcar_gen3_thermal_init()
364 reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR); in rcar_gen3_thermal_init()
366 rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val); in rcar_gen3_thermal_init()
505 struct rcar_gen3_thermal_tsc *tsc; in rcar_gen3_thermal_probe() local
511 tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL); in rcar_gen3_thermal_probe()
512 if (!tsc) { in rcar_gen3_thermal_probe()
517 tsc->base = devm_ioremap_resource(dev, res); in rcar_gen3_thermal_probe()
518 if (IS_ERR(tsc->base)) { in rcar_gen3_thermal_probe()
519 ret = PTR_ERR(tsc->base); in rcar_gen3_thermal_probe()
523 priv->tscs[i] = tsc; in rcar_gen3_thermal_probe()
532 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_probe() local
534 rcar_gen3_thermal_init(priv, tsc); in rcar_gen3_thermal_probe()
535 rcar_gen3_thermal_calc_coefs(priv, tsc, priv->info->ths_tj_1); in rcar_gen3_thermal_probe()
537 zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops); in rcar_gen3_thermal_probe()
543 tsc->zone = zone; in rcar_gen3_thermal_probe()
545 ret = thermal_add_hwmon_sysfs(tsc->zone); in rcar_gen3_thermal_probe()
553 ret = thermal_zone_get_num_trips(tsc->zone); in rcar_gen3_thermal_probe()
579 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; in rcar_gen3_thermal_resume() local
581 rcar_gen3_thermal_init(priv, tsc); in rcar_gen3_thermal_resume()