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

thermal/drivers/rcar_gen3: Add support for per-SoC default trim values

The Working Sample R-Car SoCs may not yet have thermal sensor trimming
values programmed into fuses, those fuses are blank instead. For such
SoCs, the driver includes fallback trimming values. Those values are
currently applied to all SoCs which use this driver.

Introduce support for per-SoC fallback trimming values in preparation
for SoCs which do not use these current trimming values. No functional
change is intended here.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20250625181739.28391-1-marek.vasut+renesas@mailbox.org

authored by

Marek Vasut and committed by
Daniel Lezcano
84fd9e4a 4ae50c82

+27 -14
+27 -14
drivers/thermal/renesas/rcar_gen3_thermal.c
··· 73 73 u32 mask; 74 74 }; 75 75 76 + struct rcar_gen3_thermal_fuse_default { 77 + u32 ptat[3]; 78 + u32 thcodes[TSC_MAX_NUM][3]; 79 + }; 80 + 76 81 struct rcar_thermal_info { 77 82 int scale; 78 83 int adj_below; 79 84 int adj_above; 80 85 const struct rcar_gen3_thermal_fuse_info *fuses; 86 + const struct rcar_gen3_thermal_fuse_default *fuse_defaults; 81 87 }; 82 88 83 89 struct equation_set_coef { ··· 295 289 296 290 static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) 297 291 { 292 + const struct rcar_gen3_thermal_fuse_default *fuse_defaults = priv->info->fuse_defaults; 298 293 unsigned int i; 299 294 u32 thscp; 300 295 ··· 304 297 if (!priv->info->fuses || 305 298 (thscp & THSCP_COR_PARA_VLD) != THSCP_COR_PARA_VLD) { 306 299 /* Default THCODE values in case FUSEs are not set. */ 307 - static const int thcodes[TSC_MAX_NUM][3] = { 308 - { 3397, 2800, 2221 }, 309 - { 3393, 2795, 2216 }, 310 - { 3389, 2805, 2237 }, 311 - { 3415, 2694, 2195 }, 312 - { 3356, 2724, 2244 }, 313 - }; 314 - 315 - priv->ptat[0] = 2631; 316 - priv->ptat[1] = 1509; 317 - priv->ptat[2] = 435; 300 + priv->ptat[0] = fuse_defaults->ptat[0]; 301 + priv->ptat[1] = fuse_defaults->ptat[1]; 302 + priv->ptat[2] = fuse_defaults->ptat[2]; 318 303 319 304 for (i = 0; i < priv->num_tscs; i++) { 320 305 struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; 321 306 322 - tsc->thcode[0] = thcodes[i][0]; 323 - tsc->thcode[1] = thcodes[i][1]; 324 - tsc->thcode[2] = thcodes[i][2]; 307 + tsc->thcode[0] = fuse_defaults->thcodes[i][0]; 308 + tsc->thcode[1] = fuse_defaults->thcodes[i][1]; 309 + tsc->thcode[2] = fuse_defaults->thcodes[i][2]; 325 310 } 326 311 327 312 return false; ··· 360 361 .mask = GEN4_FUSE_MASK, 361 362 }; 362 363 364 + static const struct rcar_gen3_thermal_fuse_default rcar_gen3_thermal_fuse_default_info_gen3 = { 365 + .ptat = { 2631, 1509, 435 }, 366 + .thcodes = { 367 + { 3397, 2800, 2221 }, 368 + { 3393, 2795, 2216 }, 369 + { 3389, 2805, 2237 }, 370 + { 3415, 2694, 2195 }, 371 + { 3356, 2724, 2244 }, 372 + }, 373 + }; 374 + 363 375 static const struct rcar_thermal_info rcar_m3w_thermal_info = { 364 376 .scale = 157, 365 377 .adj_below = -41, 366 378 .adj_above = 116, 367 379 .fuses = &rcar_gen3_thermal_fuse_info_gen3, 380 + .fuse_defaults = &rcar_gen3_thermal_fuse_default_info_gen3, 368 381 }; 369 382 370 383 static const struct rcar_thermal_info rcar_gen3_thermal_info = { ··· 384 373 .adj_below = -41, 385 374 .adj_above = 126, 386 375 .fuses = &rcar_gen3_thermal_fuse_info_gen3, 376 + .fuse_defaults = &rcar_gen3_thermal_fuse_default_info_gen3, 387 377 }; 388 378 389 379 static const struct rcar_thermal_info rcar_gen4_thermal_info = { ··· 392 380 .adj_below = -41, 393 381 .adj_above = 126, 394 382 .fuses = &rcar_gen3_thermal_fuse_info_gen4, 383 + .fuse_defaults = &rcar_gen3_thermal_fuse_default_info_gen3, 395 384 }; 396 385 397 386 static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {