2 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <linux/module.h>
16 #include <linux/platform_device.h>
18 #include <dt-bindings/thermal/tegra124-soctherm.h>
22 #define TEGRA124_THERMTRIP_ANY_EN_MASK (0x1 << 28)
23 #define TEGRA124_THERMTRIP_MEM_EN_MASK (0x1 << 27)
24 #define TEGRA124_THERMTRIP_GPU_EN_MASK (0x1 << 26)
25 #define TEGRA124_THERMTRIP_CPU_EN_MASK (0x1 << 25)
26 #define TEGRA124_THERMTRIP_TSENSE_EN_MASK (0x1 << 24)
27 #define TEGRA124_THERMTRIP_GPUMEM_THRESH_MASK (0xff << 16)
28 #define TEGRA124_THERMTRIP_CPU_THRESH_MASK (0xff << 8)
29 #define TEGRA124_THERMTRIP_TSENSE_THRESH_MASK 0xff
31 #define TEGRA124_THRESH_GRAIN 1000
33 static const struct tegra_tsensor_configuration tegra124_tsensor_config
= {
41 static const struct tegra_tsensor_group tegra124_tsensor_group_cpu
= {
42 .id
= TEGRA124_SOCTHERM_SENSOR_CPU
,
44 .sensor_temp_offset
= SENSOR_TEMP1
,
45 .sensor_temp_mask
= SENSOR_TEMP1_CPU_TEMP_MASK
,
48 .pdiv_mask
= SENSOR_PDIV_CPU_MASK
,
49 .pllx_hotspot_diff
= 10,
50 .pllx_hotspot_mask
= SENSOR_HOTSPOT_CPU_MASK
,
51 .thermtrip_any_en_mask
= TEGRA124_THERMTRIP_ANY_EN_MASK
,
52 .thermtrip_enable_mask
= TEGRA124_THERMTRIP_CPU_EN_MASK
,
53 .thermtrip_threshold_mask
= TEGRA124_THERMTRIP_CPU_THRESH_MASK
,
56 static const struct tegra_tsensor_group tegra124_tsensor_group_gpu
= {
57 .id
= TEGRA124_SOCTHERM_SENSOR_GPU
,
59 .sensor_temp_offset
= SENSOR_TEMP1
,
60 .sensor_temp_mask
= SENSOR_TEMP1_GPU_TEMP_MASK
,
63 .pdiv_mask
= SENSOR_PDIV_GPU_MASK
,
64 .pllx_hotspot_diff
= 5,
65 .pllx_hotspot_mask
= SENSOR_HOTSPOT_GPU_MASK
,
66 .thermtrip_any_en_mask
= TEGRA124_THERMTRIP_ANY_EN_MASK
,
67 .thermtrip_enable_mask
= TEGRA124_THERMTRIP_GPU_EN_MASK
,
68 .thermtrip_threshold_mask
= TEGRA124_THERMTRIP_GPUMEM_THRESH_MASK
,
71 static const struct tegra_tsensor_group tegra124_tsensor_group_pll
= {
72 .id
= TEGRA124_SOCTHERM_SENSOR_PLLX
,
74 .sensor_temp_offset
= SENSOR_TEMP2
,
75 .sensor_temp_mask
= SENSOR_TEMP2_PLLX_TEMP_MASK
,
78 .pdiv_mask
= SENSOR_PDIV_PLLX_MASK
,
79 .thermtrip_any_en_mask
= TEGRA124_THERMTRIP_ANY_EN_MASK
,
80 .thermtrip_enable_mask
= TEGRA124_THERMTRIP_TSENSE_EN_MASK
,
81 .thermtrip_threshold_mask
= TEGRA124_THERMTRIP_TSENSE_THRESH_MASK
,
84 static const struct tegra_tsensor_group tegra124_tsensor_group_mem
= {
85 .id
= TEGRA124_SOCTHERM_SENSOR_MEM
,
87 .sensor_temp_offset
= SENSOR_TEMP2
,
88 .sensor_temp_mask
= SENSOR_TEMP2_MEM_TEMP_MASK
,
91 .pdiv_mask
= SENSOR_PDIV_MEM_MASK
,
92 .pllx_hotspot_diff
= 0,
93 .pllx_hotspot_mask
= SENSOR_HOTSPOT_MEM_MASK
,
94 .thermtrip_any_en_mask
= TEGRA124_THERMTRIP_ANY_EN_MASK
,
95 .thermtrip_enable_mask
= TEGRA124_THERMTRIP_MEM_EN_MASK
,
96 .thermtrip_threshold_mask
= TEGRA124_THERMTRIP_GPUMEM_THRESH_MASK
,
99 static const struct tegra_tsensor_group
*tegra124_tsensor_groups
[] = {
100 &tegra124_tsensor_group_cpu
,
101 &tegra124_tsensor_group_gpu
,
102 &tegra124_tsensor_group_pll
,
103 &tegra124_tsensor_group_mem
,
106 static const struct tegra_tsensor tegra124_tsensors
[] = {
110 .config
= &tegra124_tsensor_config
,
111 .calib_fuse_offset
= 0x098,
112 .fuse_corr_alpha
= 1135400,
113 .fuse_corr_beta
= -6266900,
114 .group
= &tegra124_tsensor_group_cpu
,
118 .config
= &tegra124_tsensor_config
,
119 .calib_fuse_offset
= 0x084,
120 .fuse_corr_alpha
= 1122220,
121 .fuse_corr_beta
= -5700700,
122 .group
= &tegra124_tsensor_group_cpu
,
126 .config
= &tegra124_tsensor_config
,
127 .calib_fuse_offset
= 0x088,
128 .fuse_corr_alpha
= 1127000,
129 .fuse_corr_beta
= -6768200,
130 .group
= &tegra124_tsensor_group_cpu
,
134 .config
= &tegra124_tsensor_config
,
135 .calib_fuse_offset
= 0x12c,
136 .fuse_corr_alpha
= 1110900,
137 .fuse_corr_beta
= -6232000,
138 .group
= &tegra124_tsensor_group_cpu
,
142 .config
= &tegra124_tsensor_config
,
143 .calib_fuse_offset
= 0x158,
144 .fuse_corr_alpha
= 1122300,
145 .fuse_corr_beta
= -5936400,
146 .group
= &tegra124_tsensor_group_mem
,
150 .config
= &tegra124_tsensor_config
,
151 .calib_fuse_offset
= 0x15c,
152 .fuse_corr_alpha
= 1145700,
153 .fuse_corr_beta
= -7124600,
154 .group
= &tegra124_tsensor_group_mem
,
158 .config
= &tegra124_tsensor_config
,
159 .calib_fuse_offset
= 0x154,
160 .fuse_corr_alpha
= 1120100,
161 .fuse_corr_beta
= -6000500,
162 .group
= &tegra124_tsensor_group_gpu
,
166 .config
= &tegra124_tsensor_config
,
167 .calib_fuse_offset
= 0x160,
168 .fuse_corr_alpha
= 1106500,
169 .fuse_corr_beta
= -6729300,
170 .group
= &tegra124_tsensor_group_pll
,
175 * Mask/shift bits in FUSE_TSENSOR_COMMON and
176 * FUSE_TSENSOR_COMMON, which are described in
177 * tegra_soctherm_fuse.c
179 static const struct tegra_soctherm_fuse tegra124_soctherm_fuse
= {
180 .fuse_base_cp_mask
= 0x3ff,
181 .fuse_base_cp_shift
= 0,
182 .fuse_base_ft_mask
= 0x7ff << 10,
183 .fuse_base_ft_shift
= 10,
184 .fuse_shift_ft_mask
= 0x1f << 21,
185 .fuse_shift_ft_shift
= 21,
186 .fuse_spare_realignment
= 0x1fc,
189 const struct tegra_soctherm_soc tegra124_soctherm
= {
190 .tsensors
= tegra124_tsensors
,
191 .num_tsensors
= ARRAY_SIZE(tegra124_tsensors
),
192 .ttgs
= tegra124_tsensor_groups
,
193 .num_ttgs
= ARRAY_SIZE(tegra124_tsensor_groups
),
194 .tfuse
= &tegra124_soctherm_fuse
,
195 .thresh_grain
= TEGRA124_THRESH_GRAIN
,