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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal

Pull thermal SoC fixes from Eduardo Valentin:

- revert pinctrl settings on rockchip which causes boot failure on
rk3288. The proper follow-up patch is being discussed, meanwhile
the revert gets those booting again.

- minor fixes on rcar and tegra

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal:
thermal: rcar_gen3_thermal: Update temperature conversion method
thermal: rcar_gen3_thermal: Update calculation formula of IRQTEMP
thermal: rcar_gen3_thermal: Update value of Tj_1
thermal: tegra: Make tegra210_tsensor_thermtrips static
Revert "thermal: rockchip: fix up the tsadc pinctrl setting error"

+64 -66
+60 -32
drivers/thermal/rcar_gen3_thermal.c
··· 62 62 63 63 #define TSC_MAX_NUM 3 64 64 65 + /* default THCODE values if FUSEs are missing */ 66 + static const int thcode[TSC_MAX_NUM][3] = { 67 + { 3397, 2800, 2221 }, 68 + { 3393, 2795, 2216 }, 69 + { 3389, 2805, 2237 }, 70 + }; 71 + 65 72 /* Structure for thermal temperature calculation */ 66 73 struct equation_coefs { 67 74 int a1; ··· 83 76 struct equation_coefs coef; 84 77 int low; 85 78 int high; 79 + int tj_t; 80 + int id; /* thermal channel id */ 86 81 }; 87 82 88 83 struct rcar_gen3_thermal_priv { ··· 131 122 #define RCAR3_THERMAL_GRAN 500 /* mili Celsius */ 132 123 133 124 /* no idea where these constants come from */ 134 - #define TJ_1 116 135 125 #define TJ_3 -41 136 126 137 - static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef, 138 - int *ptat, int *thcode) 127 + static void rcar_gen3_thermal_calc_coefs(struct rcar_gen3_thermal_tsc *tsc, 128 + int *ptat, const int *thcode, 129 + int ths_tj_1) 139 130 { 140 - int tj_2; 141 - 142 131 /* TODO: Find documentation and document constant calculation formula */ 143 132 144 133 /* 145 134 * Division is not scaled in BSP and if scaled it might overflow 146 135 * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled 147 136 */ 148 - tj_2 = (FIXPT_INT((ptat[1] - ptat[2]) * 157) 149 - / (ptat[0] - ptat[2])) - FIXPT_INT(41); 137 + tsc->tj_t = (FIXPT_INT((ptat[1] - ptat[2]) * 157) 138 + / (ptat[0] - ptat[2])) + FIXPT_INT(TJ_3); 150 139 151 - coef->a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]), 152 - tj_2 - FIXPT_INT(TJ_3)); 153 - coef->b1 = FIXPT_INT(thcode[2]) - coef->a1 * TJ_3; 140 + tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]), 141 + tsc->tj_t - FIXPT_INT(TJ_3)); 142 + tsc->coef.b1 = FIXPT_INT(thcode[2]) - tsc->coef.a1 * TJ_3; 154 143 155 - coef->a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]), 156 - tj_2 - FIXPT_INT(TJ_1)); 157 - coef->b2 = FIXPT_INT(thcode[0]) - coef->a2 * TJ_1; 144 + tsc->coef.a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]), 145 + tsc->tj_t - FIXPT_INT(ths_tj_1)); 146 + tsc->coef.b2 = FIXPT_INT(thcode[0]) - tsc->coef.a2 * ths_tj_1; 158 147 } 159 148 160 149 static int rcar_gen3_thermal_round(int temp) ··· 168 161 static int rcar_gen3_thermal_get_temp(void *devdata, int *temp) 169 162 { 170 163 struct rcar_gen3_thermal_tsc *tsc = devdata; 171 - int mcelsius, val1, val2; 164 + int mcelsius, val; 172 165 u32 reg; 173 166 174 167 /* Read register and convert to mili Celsius */ 175 168 reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK; 176 169 177 - val1 = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1, tsc->coef.a1); 178 - val2 = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2, tsc->coef.a2); 179 - mcelsius = FIXPT_TO_MCELSIUS((val1 + val2) / 2); 170 + if (reg <= thcode[tsc->id][1]) 171 + val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1, 172 + tsc->coef.a1); 173 + else 174 + val = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2, 175 + tsc->coef.a2); 176 + mcelsius = FIXPT_TO_MCELSIUS(val); 180 177 181 178 /* Make sure we are inside specifications */ 182 179 if ((mcelsius < MCELSIUS(-40)) || (mcelsius > MCELSIUS(125))) ··· 195 184 static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc, 196 185 int mcelsius) 197 186 { 198 - int celsius, val1, val2; 187 + int celsius, val; 199 188 200 189 celsius = DIV_ROUND_CLOSEST(mcelsius, 1000); 201 - val1 = celsius * tsc->coef.a1 + tsc->coef.b1; 202 - val2 = celsius * tsc->coef.a2 + tsc->coef.b2; 190 + if (celsius <= INT_FIXPT(tsc->tj_t)) 191 + val = celsius * tsc->coef.a1 + tsc->coef.b1; 192 + else 193 + val = celsius * tsc->coef.a2 + tsc->coef.b2; 203 194 204 - return INT_FIXPT((val1 + val2) / 2); 195 + return INT_FIXPT(val); 205 196 } 206 197 207 198 static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high) ··· 307 294 usleep_range(1000, 2000); 308 295 } 309 296 297 + static const int rcar_gen3_ths_tj_1 = 126; 298 + static const int rcar_gen3_ths_tj_1_m3_w = 116; 310 299 static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { 311 - { .compatible = "renesas,r8a774a1-thermal", }, 312 - { .compatible = "renesas,r8a7795-thermal", }, 313 - { .compatible = "renesas,r8a7796-thermal", }, 314 - { .compatible = "renesas,r8a77965-thermal", }, 315 - { .compatible = "renesas,r8a77980-thermal", }, 300 + { 301 + .compatible = "renesas,r8a774a1-thermal", 302 + .data = &rcar_gen3_ths_tj_1_m3_w, 303 + }, 304 + { 305 + .compatible = "renesas,r8a7795-thermal", 306 + .data = &rcar_gen3_ths_tj_1, 307 + }, 308 + { 309 + .compatible = "renesas,r8a7796-thermal", 310 + .data = &rcar_gen3_ths_tj_1_m3_w, 311 + }, 312 + { 313 + .compatible = "renesas,r8a77965-thermal", 314 + .data = &rcar_gen3_ths_tj_1, 315 + }, 316 + { 317 + .compatible = "renesas,r8a77980-thermal", 318 + .data = &rcar_gen3_ths_tj_1, 319 + }, 316 320 {}, 317 321 }; 318 322 MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids); ··· 358 328 { 359 329 struct rcar_gen3_thermal_priv *priv; 360 330 struct device *dev = &pdev->dev; 331 + const int *rcar_gen3_ths_tj_1 = of_device_get_match_data(dev); 361 332 struct resource *res; 362 333 struct thermal_zone_device *zone; 363 334 int ret, irq, i; ··· 367 336 /* default values if FUSEs are missing */ 368 337 /* TODO: Read values from hardware on supported platforms */ 369 338 int ptat[3] = { 2631, 1509, 435 }; 370 - int thcode[TSC_MAX_NUM][3] = { 371 - { 3397, 2800, 2221 }, 372 - { 3393, 2795, 2216 }, 373 - { 3389, 2805, 2237 }, 374 - }; 375 339 376 340 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 377 341 if (!priv) ··· 421 395 ret = PTR_ERR(tsc->base); 422 396 goto error_unregister; 423 397 } 398 + tsc->id = i; 424 399 425 400 priv->tscs[i] = tsc; 426 401 427 402 priv->thermal_init(tsc); 428 - rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]); 403 + rcar_gen3_thermal_calc_coefs(tsc, ptat, thcode[i], 404 + *rcar_gen3_ths_tj_1); 429 405 430 406 zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, 431 407 &rcar_gen3_tz_of_ops);
+3 -33
drivers/thermal/rockchip_thermal.c
··· 172 172 int tshut_temp; 173 173 enum tshut_mode tshut_mode; 174 174 enum tshut_polarity tshut_polarity; 175 - struct pinctrl *pinctrl; 176 - struct pinctrl_state *gpio_state; 177 - struct pinctrl_state *otp_state; 178 175 }; 179 176 180 177 /** ··· 1280 1283 return error; 1281 1284 } 1282 1285 1283 - thermal->chip->control(thermal->regs, false); 1284 - 1285 1286 error = clk_prepare_enable(thermal->clk); 1286 1287 if (error) { 1287 1288 dev_err(&pdev->dev, "failed to enable converter clock: %d\n", ··· 1304 1309 1305 1310 thermal->chip->initialize(thermal->grf, thermal->regs, 1306 1311 thermal->tshut_polarity); 1307 - 1308 - if (thermal->tshut_mode == TSHUT_MODE_GPIO) { 1309 - thermal->pinctrl = devm_pinctrl_get(&pdev->dev); 1310 - if (IS_ERR(thermal->pinctrl)) { 1311 - dev_err(&pdev->dev, "failed to find thermal pinctrl\n"); 1312 - return PTR_ERR(thermal->pinctrl); 1313 - } 1314 - 1315 - thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl, 1316 - "gpio"); 1317 - if (IS_ERR_OR_NULL(thermal->gpio_state)) { 1318 - dev_err(&pdev->dev, "failed to find thermal gpio state\n"); 1319 - return -EINVAL; 1320 - } 1321 - 1322 - thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl, 1323 - "otpout"); 1324 - if (IS_ERR_OR_NULL(thermal->otp_state)) { 1325 - dev_err(&pdev->dev, "failed to find thermal otpout state\n"); 1326 - return -EINVAL; 1327 - } 1328 - 1329 - pinctrl_select_state(thermal->pinctrl, thermal->otp_state); 1330 - } 1331 1312 1332 1313 for (i = 0; i < thermal->chip->chn_num; i++) { 1333 1314 error = rockchip_thermal_register_sensor(pdev, thermal, ··· 1375 1404 1376 1405 clk_disable(thermal->pclk); 1377 1406 clk_disable(thermal->clk); 1378 - if (thermal->tshut_mode == TSHUT_MODE_GPIO) 1379 - pinctrl_select_state(thermal->pinctrl, thermal->gpio_state); 1407 + 1408 + pinctrl_pm_select_sleep_state(dev); 1380 1409 1381 1410 return 0; 1382 1411 } ··· 1421 1450 for (i = 0; i < thermal->chip->chn_num; i++) 1422 1451 rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); 1423 1452 1424 - if (thermal->tshut_mode == TSHUT_MODE_GPIO) 1425 - pinctrl_select_state(thermal->pinctrl, thermal->otp_state); 1453 + pinctrl_pm_select_default_state(dev); 1426 1454 1427 1455 return 0; 1428 1456 }
+1 -1
drivers/thermal/tegra/tegra210-soctherm.c
··· 208 208 .fuse_spare_realignment = 0, 209 209 }; 210 210 211 - struct tsensor_group_thermtrips tegra210_tsensor_thermtrips[] = { 211 + static struct tsensor_group_thermtrips tegra210_tsensor_thermtrips[] = { 212 212 {.id = TEGRA124_SOCTHERM_SENSOR_NUM}, 213 213 {.id = TEGRA124_SOCTHERM_SENSOR_NUM}, 214 214 {.id = TEGRA124_SOCTHERM_SENSOR_NUM},