Skip to content

Commit 48fc33b

Browse files
clamor-sdlezcano
authored andcommitted
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>
1 parent aa00251 commit 48fc33b

5 files changed

Lines changed: 30 additions & 7 deletions

File tree

drivers/thermal/tegra/soctherm-fuse.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99

1010
#include "soctherm.h"
1111

12-
#define NOMINAL_CALIB_FT 105
1312
#define NOMINAL_CALIB_CP 25
1413

1514
#define FUSE_TSENSOR_CALIB_CP_TS_BASE_MASK 0x1fff
1615
#define FUSE_TSENSOR_CALIB_FT_TS_BASE_MASK (0x1fff << 13)
1716
#define FUSE_TSENSOR_CALIB_FT_TS_BASE_SHIFT 13
1817

19-
#define FUSE_TSENSOR_COMMON 0x180
20-
2118
/*
2219
* Tegra210: Layout of bits in FUSE_TSENSOR_COMMON:
2320
* 3 2 1 0
@@ -26,7 +23,7 @@
2623
* | BASE_FT | BASE_CP | SHFT_FT | SHIFT_CP |
2724
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2825
*
29-
* Tegra12x, etc:
26+
* Tegra124:
3027
* In chips prior to Tegra210, this fuse was incorrectly sized as 26 bits,
3128
* and didn't hold SHIFT_CP in [31:26]. Therefore these missing six bits
3229
* were obtained via the FUSE_SPARE_REALIGNMENT_REG register [5:0].
@@ -44,6 +41,13 @@
4441
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4542
* |---------------------------------------------------| SHIFT_CP |
4643
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44+
*
45+
* Tegra114: Layout of bits in FUSE_TSENSOR_COMMON aka FUSE_VSENSOR_CALIB:
46+
* 3 2 1 0
47+
* 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
48+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49+
* | SHFT_FT | BASE_FT | SHIFT_CP | BASE_CP |
50+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4751
*/
4852

4953
#define CALIB_COEFFICIENT 1000000LL
@@ -77,7 +81,7 @@ int tegra_calc_shared_calib(const struct tegra_soctherm_fuse *tfuse,
7781
s32 shifted_cp, shifted_ft;
7882
int err;
7983

80-
err = tegra_fuse_readl(FUSE_TSENSOR_COMMON, &val);
84+
err = tegra_fuse_readl(tfuse->fuse_common_reg, &val);
8185
if (err)
8286
return err;
8387

@@ -96,10 +100,12 @@ int tegra_calc_shared_calib(const struct tegra_soctherm_fuse *tfuse,
96100
return err;
97101
}
98102

103+
shifted_cp = (val & tfuse->fuse_shift_cp_mask) >>
104+
tfuse->fuse_shift_cp_shift;
99105
shifted_cp = sign_extend32(val, 5);
100106

101107
shared->actual_temp_cp = 2 * NOMINAL_CALIB_CP + shifted_cp;
102-
shared->actual_temp_ft = 2 * NOMINAL_CALIB_FT + shifted_ft;
108+
shared->actual_temp_ft = 2 * tfuse->nominal_calib_ft + shifted_ft;
103109

104110
return 0;
105111
}

drivers/thermal/tegra/soctherm.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
#define SENSOR_TEMP2_MEM_TEMP_MASK (0xffff << 16)
5757
#define SENSOR_TEMP2_PLLX_TEMP_MASK 0xffff
5858

59+
#define FUSE_VSENSOR_CALIB 0x08c
60+
#define FUSE_TSENSOR_COMMON 0x180
61+
5962
/**
6063
* struct tegra_tsensor_group - SOC_THERM sensor group data
6164
* @name: short name of the temperature sensor group
@@ -109,9 +112,11 @@ struct tsensor_group_thermtrips {
109112

110113
struct tegra_soctherm_fuse {
111114
u32 fuse_base_cp_mask, fuse_base_cp_shift;
115+
u32 fuse_shift_cp_mask, fuse_shift_cp_shift;
112116
u32 fuse_base_ft_mask, fuse_base_ft_shift;
113117
u32 fuse_shift_ft_mask, fuse_shift_ft_shift;
114-
u32 fuse_spare_realignment;
118+
u32 fuse_common_reg, fuse_spare_realignment;
119+
u32 nominal_calib_ft;
115120
};
116121

117122
struct tsensor_shared_calib {

drivers/thermal/tegra/tegra124-soctherm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,15 @@ static const struct tegra_tsensor tegra124_tsensors[] = {
200200
static const struct tegra_soctherm_fuse tegra124_soctherm_fuse = {
201201
.fuse_base_cp_mask = 0x3ff,
202202
.fuse_base_cp_shift = 0,
203+
.fuse_shift_cp_mask = 0x3f,
204+
.fuse_shift_cp_shift = 0,
203205
.fuse_base_ft_mask = 0x7ff << 10,
204206
.fuse_base_ft_shift = 10,
205207
.fuse_shift_ft_mask = 0x1f << 21,
206208
.fuse_shift_ft_shift = 21,
209+
.fuse_common_reg = FUSE_TSENSOR_COMMON,
207210
.fuse_spare_realignment = 0x1fc,
211+
.nominal_calib_ft = 105,
208212
};
209213

210214
const struct tegra_soctherm_soc tegra124_soctherm = {

drivers/thermal/tegra/tegra132-soctherm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,15 @@ static struct tegra_tsensor tegra132_tsensors[] = {
200200
static const struct tegra_soctherm_fuse tegra132_soctherm_fuse = {
201201
.fuse_base_cp_mask = 0x3ff,
202202
.fuse_base_cp_shift = 0,
203+
.fuse_shift_cp_mask = 0x3f,
204+
.fuse_shift_cp_shift = 0,
203205
.fuse_base_ft_mask = 0x7ff << 10,
204206
.fuse_base_ft_shift = 10,
205207
.fuse_shift_ft_mask = 0x1f << 21,
206208
.fuse_shift_ft_shift = 21,
209+
.fuse_common_reg = FUSE_TSENSOR_COMMON,
207210
.fuse_spare_realignment = 0x1fc,
211+
.nominal_calib_ft = 105,
208212
};
209213

210214
const struct tegra_soctherm_soc tegra132_soctherm = {

drivers/thermal/tegra/tegra210-soctherm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,15 @@ static const struct tegra_tsensor tegra210_tsensors[] = {
201201
static const struct tegra_soctherm_fuse tegra210_soctherm_fuse = {
202202
.fuse_base_cp_mask = 0x3ff << 11,
203203
.fuse_base_cp_shift = 11,
204+
.fuse_shift_cp_mask = 0x3f,
205+
.fuse_shift_cp_shift = 0,
204206
.fuse_base_ft_mask = 0x7ff << 21,
205207
.fuse_base_ft_shift = 21,
206208
.fuse_shift_ft_mask = 0x1f << 6,
207209
.fuse_shift_ft_shift = 6,
210+
.fuse_common_reg = FUSE_TSENSOR_COMMON,
208211
.fuse_spare_realignment = 0,
212+
.nominal_calib_ft = 105,
209213
};
210214

211215
static struct tsensor_group_thermtrips tegra210_tsensor_thermtrips[] = {

0 commit comments

Comments
 (0)