Linux Audio

Check our new training course

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