xref: /linux/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c (revision bc537a9cc47eec7f4e32b8164c494ddc35dca8ac)
1 /*
2  * OMAP5 thermal driver.
3  *
4  * Copyright (C) 2011-2012 Texas Instruments Inc.
5  * Contact:
6  *	Eduardo Valentin <eduardo.valentin@ti.com>
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  */
18 
19 #include "ti-thermal.h"
20 #include "ti-bandgap.h"
21 #include "omap5xxx-bandgap.h"
22 
23 /*
24  * OMAP5430 has three instances of thermal sensor for MPU, GPU & CORE,
25  * need to describe the individual registers and bit fields.
26  */
27 
28 /*
29  * OMAP5430 MPU thermal sensor register offset and bit-fields
30  */
31 static struct temp_sensor_registers
32 omap5430_mpu_temp_sensor_registers = {
33 	.temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_MPU_OFFSET,
34 	.bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
35 	.bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
36 	.bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
37 
38 	.bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
39 	.mask_hot_mask = OMAP5430_MASK_HOT_MPU_MASK,
40 	.mask_cold_mask = OMAP5430_MASK_COLD_MPU_MASK,
41 	.mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
42 	.mask_freeze_mask = OMAP5430_MASK_FREEZE_MPU_MASK,
43 
44 	.bgap_counter = OMAP5430_BGAP_CTRL_OFFSET,
45 	.counter_mask = OMAP5430_COUNTER_MASK,
46 
47 	.bgap_threshold = OMAP5430_BGAP_THRESHOLD_MPU_OFFSET,
48 	.threshold_thot_mask = OMAP5430_T_HOT_MASK,
49 	.threshold_tcold_mask = OMAP5430_T_COLD_MASK,
50 
51 	.tshut_threshold = OMAP5430_BGAP_TSHUT_MPU_OFFSET,
52 	.tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
53 	.tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
54 
55 	.bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
56 	.status_hot_mask = OMAP5430_HOT_MPU_FLAG_MASK,
57 	.status_cold_mask = OMAP5430_COLD_MPU_FLAG_MASK,
58 
59 	.ctrl_dtemp_1 = OMAP5430_BGAP_DTEMP_MPU_1_OFFSET,
60 	.ctrl_dtemp_2 = OMAP5430_BGAP_DTEMP_MPU_2_OFFSET,
61 	.bgap_efuse = OMAP5430_FUSE_OPP_BGAP_MPU,
62 };
63 
64 /*
65  * OMAP5430 GPU thermal sensor register offset and bit-fields
66  */
67 static struct temp_sensor_registers
68 omap5430_gpu_temp_sensor_registers = {
69 	.temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_GPU_OFFSET,
70 	.bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
71 	.bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
72 	.bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
73 
74 	.bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
75 	.mask_hot_mask = OMAP5430_MASK_HOT_GPU_MASK,
76 	.mask_cold_mask = OMAP5430_MASK_COLD_GPU_MASK,
77 	.mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
78 	.mask_freeze_mask = OMAP5430_MASK_FREEZE_GPU_MASK,
79 
80 	.bgap_counter = OMAP5430_BGAP_CTRL_OFFSET,
81 	.counter_mask = OMAP5430_COUNTER_MASK,
82 
83 	.bgap_threshold = OMAP5430_BGAP_THRESHOLD_GPU_OFFSET,
84 	.threshold_thot_mask = OMAP5430_T_HOT_MASK,
85 	.threshold_tcold_mask = OMAP5430_T_COLD_MASK,
86 
87 	.tshut_threshold = OMAP5430_BGAP_TSHUT_GPU_OFFSET,
88 	.tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
89 	.tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
90 
91 	.bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
92 	.status_hot_mask = OMAP5430_HOT_GPU_FLAG_MASK,
93 	.status_cold_mask = OMAP5430_COLD_GPU_FLAG_MASK,
94 
95 	.ctrl_dtemp_1 = OMAP5430_BGAP_DTEMP_GPU_1_OFFSET,
96 	.ctrl_dtemp_2 = OMAP5430_BGAP_DTEMP_GPU_2_OFFSET,
97 
98 	.bgap_efuse = OMAP5430_FUSE_OPP_BGAP_GPU,
99 };
100 
101 /*
102  * OMAP5430 CORE thermal sensor register offset and bit-fields
103  */
104 static struct temp_sensor_registers
105 omap5430_core_temp_sensor_registers = {
106 	.temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_CORE_OFFSET,
107 	.bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
108 	.bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
109 	.bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
110 
111 	.bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
112 	.mask_hot_mask = OMAP5430_MASK_HOT_CORE_MASK,
113 	.mask_cold_mask = OMAP5430_MASK_COLD_CORE_MASK,
114 	.mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
115 	.mask_freeze_mask = OMAP5430_MASK_FREEZE_CORE_MASK,
116 
117 	.bgap_counter = OMAP5430_BGAP_CTRL_OFFSET,
118 	.counter_mask = OMAP5430_COUNTER_MASK,
119 
120 	.bgap_threshold = OMAP5430_BGAP_THRESHOLD_CORE_OFFSET,
121 	.threshold_thot_mask = OMAP5430_T_HOT_MASK,
122 	.threshold_tcold_mask = OMAP5430_T_COLD_MASK,
123 
124 	.tshut_threshold = OMAP5430_BGAP_TSHUT_CORE_OFFSET,
125 	.tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
126 	.tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
127 
128 	.bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
129 	.status_hot_mask = OMAP5430_HOT_CORE_FLAG_MASK,
130 	.status_cold_mask = OMAP5430_COLD_CORE_FLAG_MASK,
131 
132 	.ctrl_dtemp_1 = OMAP5430_BGAP_DTEMP_CORE_1_OFFSET,
133 	.ctrl_dtemp_2 = OMAP5430_BGAP_DTEMP_CORE_2_OFFSET,
134 
135 	.bgap_efuse = OMAP5430_FUSE_OPP_BGAP_CORE,
136 };
137 
138 /* Thresholds and limits for OMAP5430 MPU temperature sensor */
139 static struct temp_sensor_data omap5430_mpu_temp_sensor_data = {
140 	.tshut_hot = OMAP5430_MPU_TSHUT_HOT,
141 	.tshut_cold = OMAP5430_MPU_TSHUT_COLD,
142 	.t_hot = OMAP5430_MPU_T_HOT,
143 	.t_cold = OMAP5430_MPU_T_COLD,
144 	.min_freq = OMAP5430_MPU_MIN_FREQ,
145 	.max_freq = OMAP5430_MPU_MAX_FREQ,
146 };
147 
148 /* Thresholds and limits for OMAP5430 GPU temperature sensor */
149 static struct temp_sensor_data omap5430_gpu_temp_sensor_data = {
150 	.tshut_hot = OMAP5430_GPU_TSHUT_HOT,
151 	.tshut_cold = OMAP5430_GPU_TSHUT_COLD,
152 	.t_hot = OMAP5430_GPU_T_HOT,
153 	.t_cold = OMAP5430_GPU_T_COLD,
154 	.min_freq = OMAP5430_GPU_MIN_FREQ,
155 	.max_freq = OMAP5430_GPU_MAX_FREQ,
156 };
157 
158 /* Thresholds and limits for OMAP5430 CORE temperature sensor */
159 static struct temp_sensor_data omap5430_core_temp_sensor_data = {
160 	.tshut_hot = OMAP5430_CORE_TSHUT_HOT,
161 	.tshut_cold = OMAP5430_CORE_TSHUT_COLD,
162 	.t_hot = OMAP5430_CORE_T_HOT,
163 	.t_cold = OMAP5430_CORE_T_COLD,
164 	.min_freq = OMAP5430_CORE_MIN_FREQ,
165 	.max_freq = OMAP5430_CORE_MAX_FREQ,
166 };
167 
168 /*
169  * OMAP54xx ES2.0 : Temperature values in milli degree celsius
170  * ADC code values from 540 to 945
171  */
172 static int
173 omap5430_adc_to_temp[
174 	OMAP5430_ADC_END_VALUE - OMAP5430_ADC_START_VALUE + 1] = {
175 	/* Index 540 - 549 */
176 	-40000, -40000, -40000, -40000, -39800, -39400, -39000, -38600, -38200,
177 	-37800,
178 	/* Index 550 - 559 */
179 	-37400, -37000, -36600, -36200, -35800, -35300, -34700, -34200, -33800,
180 	-33400,
181 	/* Index 560 - 569 */
182 	-33000, -32600, -32200, -31800, -31400, -31000, -30600, -30200, -29800,
183 	-29400,
184 	/* Index 570 - 579 */
185 	-29000, -28600, -28200, -27700, -27100, -26600, -26200, -25800, -25400,
186 	-25000,
187 	/* Index 580 - 589 */
188 	-24600, -24200, -23800, -23400, -23000, -22600, -22200, -21600, -21400,
189 	-21000,
190 	/* Index 590 - 599 */
191 	-20500, -19900, -19400, -19000, -18600, -18200, -17800, -17400, -17000,
192 	-16600,
193 	/* Index 600 - 609 */
194 	-16200, -15800, -15400, -15000, -14600, -14200, -13800,	-13400, -13000,
195 	-12500,
196 	/* Index 610 - 619 */
197 	-11900, -11400, -11000, -10600, -10200, -9800, -9400, -9000, -8600,
198 	-8200,
199 	/* Index 620 - 629 */
200 	-7800, -7400, -7000, -6600, -6200, -5800, -5400, -5000, -4500, -3900,
201 	/* Index 630 - 639 */
202 	-3400, -3000, -2600, -2200, -1800, -1400, -1000, -600, -200, 200,
203 	/* Index 640 - 649 */
204 	600, 1000, 1400, 1800, 2200, 2600, 3000, 3400, 3900, 4500,
205 	/* Index 650 - 659 */
206 	5000, 5400, 5800, 6200, 6600, 7000, 7400, 7800, 8200, 8600,
207 	/* Index 660 - 669 */
208 	9000, 9400, 9800, 10200, 10600, 11000, 11400, 11800, 12200, 12700,
209 	/* Index 670 - 679 */
210 	13300, 13800, 14200, 14600, 15000, 15400, 15800, 16200, 16600, 17000,
211 	/* Index 680 - 689 */
212 	17400, 17800, 18200, 18600, 19000, 19400, 19800, 20200, 20600, 21100,
213 	/* Index 690 - 699 */
214 	21400, 21900, 22500, 23000, 23400, 23800, 24200, 24600, 25000, 25400,
215 	/* Index 700 - 709 */
216 	25800, 26200, 26600, 27000, 27400, 27800, 28200, 28600, 29000, 29400,
217 	/* Index 710 - 719 */
218 	29800, 30200, 30600, 31000, 31400, 31900, 32500, 33000, 33400, 33800,
219 	/* Index 720 - 729 */
220 	34200, 34600, 35000, 35400, 35800, 36200, 36600, 37000, 37400, 37800,
221 	/* Index 730 - 739 */
222 	38200, 38600, 39000, 39400, 39800, 40200, 40600, 41000, 41400, 41800,
223 	/* Index 740 - 749 */
224 	42200, 42600, 43100, 43700, 44200, 44600, 45000, 45400, 45800, 46200,
225 	/* Index 750 - 759 */
226 	46600, 47000, 47400, 47800, 48200, 48600, 49000, 49400, 49800, 50200,
227 	/* Index 760 - 769 */
228 	50600, 51000, 51400, 51800, 52200, 52600, 53000, 53400, 53800, 54200,
229 	/* Index 770 - 779 */
230 	54600, 55000, 55400, 55900, 56500, 57000, 57400, 57800, 58200, 58600,
231 	/* Index 780 - 789 */
232 	59000, 59400, 59800, 60200, 60600, 61000, 61400, 61800, 62200, 62600,
233 	/* Index 790 - 799 */
234 	63000, 63400, 63800, 64200, 64600, 65000, 65400, 65800, 66200, 66600,
235 	/* Index 800 - 809 */
236 	67000, 67400, 67800, 68200, 68600, 69000, 69400, 69800, 70200, 70600,
237 	/* Index 810 - 819 */
238 	71000, 71500, 72100, 72600, 73000, 73400, 73800, 74200, 74600, 75000,
239 	/* Index 820 - 829 */
240 	75400, 75800, 76200, 76600, 77000, 77400, 77800, 78200, 78600, 79000,
241 	/* Index 830 - 839 */
242 	79400, 79800, 80200, 80600, 81000, 81400, 81800, 82200, 82600, 83000,
243 	/* Index 840 - 849 */
244 	83400, 83800, 84200, 84600, 85000, 85400, 85800, 86200, 86600, 87000,
245 	/* Index 850 - 859 */
246 	87400, 87800, 88200, 88600, 89000, 89400, 89800, 90200, 90600, 91000,
247 	/* Index 860 - 869 */
248 	91400, 91800, 92200, 92600, 93000, 93400, 93800, 94200, 94600, 95000,
249 	/* Index 870 - 879 */
250 	95400, 95800, 96200, 96600, 97000, 97500, 98100, 98600, 99000, 99400,
251 	/* Index 880 - 889 */
252 	99800, 100200, 100600, 101000, 101400, 101800, 102200, 102600, 103000,
253 	103400,
254 	/* Index 890 - 899 */
255 	103800, 104200, 104600, 105000, 105400, 105800, 106200, 106600, 107000,
256 	107400,
257 	/* Index 900 - 909 */
258 	107800, 108200, 108600, 109000, 109400, 109800, 110200, 110600, 111000,
259 	111400,
260 	/* Index 910 - 919 */
261 	111800, 112200, 112600, 113000, 113400, 113800, 114200, 114600, 115000,
262 	115400,
263 	/* Index 920 - 929 */
264 	115800, 116200, 116600, 117000, 117400, 117800, 118200, 118600, 119000,
265 	119400,
266 	/* Index 930 - 939 */
267 	119800, 120200, 120600, 121000, 121400, 121800, 122400, 122600, 123000,
268 	123400,
269 	/* Index 940 - 945 */
270 	123800, 124200, 124600, 124900, 125000, 125000,
271 };
272 
273 /* OMAP54xx ES2.0 data */
274 const struct ti_bandgap_data omap5430_data = {
275 	.features = TI_BANDGAP_FEATURE_TSHUT_CONFIG |
276 			TI_BANDGAP_FEATURE_FREEZE_BIT |
277 			TI_BANDGAP_FEATURE_TALERT |
278 			TI_BANDGAP_FEATURE_COUNTER_DELAY |
279 			TI_BANDGAP_FEATURE_HISTORY_BUFFER,
280 	.fclock_name = "l3instr_ts_gclk_div",
281 	.div_ck_name = "l3instr_ts_gclk_div",
282 	.conv_table = omap5430_adc_to_temp,
283 	.adc_start_val = OMAP5430_ADC_START_VALUE,
284 	.adc_end_val = OMAP5430_ADC_END_VALUE,
285 	.expose_sensor = ti_thermal_expose_sensor,
286 	.remove_sensor = ti_thermal_remove_sensor,
287 	.report_temperature = ti_thermal_report_sensor_temperature,
288 	.sensors = {
289 		{
290 		.registers = &omap5430_mpu_temp_sensor_registers,
291 		.ts_data = &omap5430_mpu_temp_sensor_data,
292 		.domain = "cpu",
293 		.register_cooling = ti_thermal_register_cpu_cooling,
294 		.unregister_cooling = ti_thermal_unregister_cpu_cooling,
295 		.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_CPU,
296 		.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_CPU,
297 		},
298 		{
299 		.registers = &omap5430_gpu_temp_sensor_registers,
300 		.ts_data = &omap5430_gpu_temp_sensor_data,
301 		.domain = "gpu",
302 		.slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU,
303 		.constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_GPU,
304 		},
305 		{
306 		.registers = &omap5430_core_temp_sensor_registers,
307 		.ts_data = &omap5430_core_temp_sensor_data,
308 		.domain = "core",
309 		},
310 	},
311 	.sensor_count = 3,
312 };
313