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

thermal/drivers/tegra/soctherm-fuse: Prepare calibration for Tegra114 support

The Tegra114 has a different fuse calibration register layout and address
compared to other Tegra SoCs, requiring SOCTHERM shift, mask, register
address, and nominal tf calibration value to be configurable.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Link: https://lore.kernel.org/r/20250828055104.8073-4-clamor95@gmail.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Svyatoslav Ryhel and committed by
Daniel Lezcano
48fc33b9 aa002515

+30 -7
+12 -6
drivers/thermal/tegra/soctherm-fuse.c
··· 9 9 10 10 #include "soctherm.h" 11 11 12 - #define NOMINAL_CALIB_FT 105 13 12 #define NOMINAL_CALIB_CP 25 14 13 15 14 #define FUSE_TSENSOR_CALIB_CP_TS_BASE_MASK 0x1fff 16 15 #define FUSE_TSENSOR_CALIB_FT_TS_BASE_MASK (0x1fff << 13) 17 16 #define FUSE_TSENSOR_CALIB_FT_TS_BASE_SHIFT 13 18 - 19 - #define FUSE_TSENSOR_COMMON 0x180 20 17 21 18 /* 22 19 * Tegra210: Layout of bits in FUSE_TSENSOR_COMMON: ··· 23 26 * | BASE_FT | BASE_CP | SHFT_FT | SHIFT_CP | 24 27 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 28 * 26 - * Tegra12x, etc: 29 + * Tegra124: 27 30 * In chips prior to Tegra210, this fuse was incorrectly sized as 26 bits, 28 31 * and didn't hold SHIFT_CP in [31:26]. Therefore these missing six bits 29 32 * were obtained via the FUSE_SPARE_REALIGNMENT_REG register [5:0]. ··· 40 43 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 41 44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 45 * |---------------------------------------------------| SHIFT_CP | 46 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + * 48 + * Tegra114: Layout of bits in FUSE_TSENSOR_COMMON aka FUSE_VSENSOR_CALIB: 49 + * 3 2 1 0 50 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 51 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 52 + * | SHFT_FT | BASE_FT | SHIFT_CP | BASE_CP | 43 53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 54 */ 45 55 ··· 81 77 s32 shifted_cp, shifted_ft; 82 78 int err; 83 79 84 - err = tegra_fuse_readl(FUSE_TSENSOR_COMMON, &val); 80 + err = tegra_fuse_readl(tfuse->fuse_common_reg, &val); 85 81 if (err) 86 82 return err; 87 83 ··· 100 96 return err; 101 97 } 102 98 99 + shifted_cp = (val & tfuse->fuse_shift_cp_mask) >> 100 + tfuse->fuse_shift_cp_shift; 103 101 shifted_cp = sign_extend32(val, 5); 104 102 105 103 shared->actual_temp_cp = 2 * NOMINAL_CALIB_CP + shifted_cp; 106 - shared->actual_temp_ft = 2 * NOMINAL_CALIB_FT + shifted_ft; 104 + shared->actual_temp_ft = 2 * tfuse->nominal_calib_ft + shifted_ft; 107 105 108 106 return 0; 109 107 }
+6 -1
drivers/thermal/tegra/soctherm.h
··· 56 56 #define SENSOR_TEMP2_MEM_TEMP_MASK (0xffff << 16) 57 57 #define SENSOR_TEMP2_PLLX_TEMP_MASK 0xffff 58 58 59 + #define FUSE_VSENSOR_CALIB 0x08c 60 + #define FUSE_TSENSOR_COMMON 0x180 61 + 59 62 /** 60 63 * struct tegra_tsensor_group - SOC_THERM sensor group data 61 64 * @name: short name of the temperature sensor group ··· 112 109 113 110 struct tegra_soctherm_fuse { 114 111 u32 fuse_base_cp_mask, fuse_base_cp_shift; 112 + u32 fuse_shift_cp_mask, fuse_shift_cp_shift; 115 113 u32 fuse_base_ft_mask, fuse_base_ft_shift; 116 114 u32 fuse_shift_ft_mask, fuse_shift_ft_shift; 117 - u32 fuse_spare_realignment; 115 + u32 fuse_common_reg, fuse_spare_realignment; 116 + u32 nominal_calib_ft; 118 117 }; 119 118 120 119 struct tsensor_shared_calib {
+4
drivers/thermal/tegra/tegra124-soctherm.c
··· 200 200 static const struct tegra_soctherm_fuse tegra124_soctherm_fuse = { 201 201 .fuse_base_cp_mask = 0x3ff, 202 202 .fuse_base_cp_shift = 0, 203 + .fuse_shift_cp_mask = 0x3f, 204 + .fuse_shift_cp_shift = 0, 203 205 .fuse_base_ft_mask = 0x7ff << 10, 204 206 .fuse_base_ft_shift = 10, 205 207 .fuse_shift_ft_mask = 0x1f << 21, 206 208 .fuse_shift_ft_shift = 21, 209 + .fuse_common_reg = FUSE_TSENSOR_COMMON, 207 210 .fuse_spare_realignment = 0x1fc, 211 + .nominal_calib_ft = 105, 208 212 }; 209 213 210 214 const struct tegra_soctherm_soc tegra124_soctherm = {
+4
drivers/thermal/tegra/tegra132-soctherm.c
··· 200 200 static const struct tegra_soctherm_fuse tegra132_soctherm_fuse = { 201 201 .fuse_base_cp_mask = 0x3ff, 202 202 .fuse_base_cp_shift = 0, 203 + .fuse_shift_cp_mask = 0x3f, 204 + .fuse_shift_cp_shift = 0, 203 205 .fuse_base_ft_mask = 0x7ff << 10, 204 206 .fuse_base_ft_shift = 10, 205 207 .fuse_shift_ft_mask = 0x1f << 21, 206 208 .fuse_shift_ft_shift = 21, 209 + .fuse_common_reg = FUSE_TSENSOR_COMMON, 207 210 .fuse_spare_realignment = 0x1fc, 211 + .nominal_calib_ft = 105, 208 212 }; 209 213 210 214 const struct tegra_soctherm_soc tegra132_soctherm = {
+4
drivers/thermal/tegra/tegra210-soctherm.c
··· 201 201 static const struct tegra_soctherm_fuse tegra210_soctherm_fuse = { 202 202 .fuse_base_cp_mask = 0x3ff << 11, 203 203 .fuse_base_cp_shift = 11, 204 + .fuse_shift_cp_mask = 0x3f, 205 + .fuse_shift_cp_shift = 0, 204 206 .fuse_base_ft_mask = 0x7ff << 21, 205 207 .fuse_base_ft_shift = 21, 206 208 .fuse_shift_ft_mask = 0x1f << 6, 207 209 .fuse_shift_ft_shift = 6, 210 + .fuse_common_reg = FUSE_TSENSOR_COMMON, 208 211 .fuse_spare_realignment = 0, 212 + .nominal_calib_ft = 105, 209 213 }; 210 214 211 215 static struct tsensor_group_thermtrips tegra210_tsensor_thermtrips[] = {