Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
omap5-thermal.c
Go to the documentation of this file.
1 /*
2  * OMAP5 thermal driver.
3  *
4  * Copyright (C) 2011-2012 Texas Instruments Inc.
5  * Contact:
6  * Eduardo Valentin <[email protected]>
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 "omap-bandgap.h"
20 #include "omap-thermal.h"
21 
22 /*
23  * omap5430 has one instance of thermal sensor for MPU
24  * need to describe the individual bit fields
25  */
26 static struct temp_sensor_registers
27 omap5430_mpu_temp_sensor_registers = {
28  .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_MPU_OFFSET,
29  .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
30  .bgap_soc_mask = OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK,
31  .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
32  .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
33 
34  .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
35  .mask_hot_mask = OMAP5430_MASK_HOT_MPU_MASK,
36  .mask_cold_mask = OMAP5430_MASK_COLD_MPU_MASK,
37 
38  .bgap_mode_ctrl = OMAP5430_BGAP_COUNTER_MPU_OFFSET,
39  .mode_ctrl_mask = OMAP5430_REPEAT_MODE_MASK,
40 
41  .bgap_counter = OMAP5430_BGAP_COUNTER_MPU_OFFSET,
42  .counter_mask = OMAP5430_COUNTER_MASK,
43 
44  .bgap_threshold = OMAP5430_BGAP_THRESHOLD_MPU_OFFSET,
45  .threshold_thot_mask = OMAP5430_T_HOT_MASK,
46  .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
47 
48  .tshut_threshold = OMAP5430_BGAP_TSHUT_MPU_OFFSET,
49  .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
50  .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
51 
52  .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
53  .status_clean_stop_mask = 0x0,
54  .status_bgap_alert_mask = OMAP5430_BGAP_ALERT_MASK,
55  .status_hot_mask = OMAP5430_HOT_MPU_FLAG_MASK,
56  .status_cold_mask = OMAP5430_COLD_MPU_FLAG_MASK,
57 
58  .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_MPU,
59 };
60 
61 /*
62  * omap5430 has one instance of thermal sensor for GPU
63  * need to describe the individual bit fields
64  */
65 static struct temp_sensor_registers
66 omap5430_gpu_temp_sensor_registers = {
67  .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_GPU_OFFSET,
68  .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
69  .bgap_soc_mask = OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK,
70  .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
71  .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
72 
73  .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
74  .mask_hot_mask = OMAP5430_MASK_HOT_MM_MASK,
75  .mask_cold_mask = OMAP5430_MASK_COLD_MM_MASK,
76 
77  .bgap_mode_ctrl = OMAP5430_BGAP_COUNTER_GPU_OFFSET,
78  .mode_ctrl_mask = OMAP5430_REPEAT_MODE_MASK,
79 
80  .bgap_counter = OMAP5430_BGAP_COUNTER_GPU_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_clean_stop_mask = 0x0,
93  .status_bgap_alert_mask = OMAP5430_BGAP_ALERT_MASK,
94  .status_hot_mask = OMAP5430_HOT_MM_FLAG_MASK,
95  .status_cold_mask = OMAP5430_COLD_MM_FLAG_MASK,
96 
97  .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_GPU,
98 };
99 
100 /*
101  * omap5430 has one instance of thermal sensor for CORE
102  * need to describe the individual 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_soc_mask = OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK,
109  .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
110  .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
111 
112  .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
113  .mask_hot_mask = OMAP5430_MASK_HOT_CORE_MASK,
114  .mask_cold_mask = OMAP5430_MASK_COLD_CORE_MASK,
115 
116  .bgap_mode_ctrl = OMAP5430_BGAP_COUNTER_CORE_OFFSET,
117  .mode_ctrl_mask = OMAP5430_REPEAT_MODE_MASK,
118 
119  .bgap_counter = OMAP5430_BGAP_COUNTER_CORE_OFFSET,
120  .counter_mask = OMAP5430_COUNTER_MASK,
121 
122  .bgap_threshold = OMAP5430_BGAP_THRESHOLD_CORE_OFFSET,
123  .threshold_thot_mask = OMAP5430_T_HOT_MASK,
124  .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
125 
126  .tshut_threshold = OMAP5430_BGAP_TSHUT_CORE_OFFSET,
127  .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
128  .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
129 
130  .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
131  .status_clean_stop_mask = 0x0,
132  .status_bgap_alert_mask = OMAP5430_BGAP_ALERT_MASK,
133  .status_hot_mask = OMAP5430_HOT_CORE_FLAG_MASK,
134  .status_cold_mask = OMAP5430_COLD_CORE_FLAG_MASK,
135 
136  .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_CORE,
137 };
138 
139 /* Thresholds and limits for OMAP5430 MPU temperature sensor */
140 static struct temp_sensor_data omap5430_mpu_temp_sensor_data = {
141  .tshut_hot = OMAP5430_MPU_TSHUT_HOT,
142  .tshut_cold = OMAP5430_MPU_TSHUT_COLD,
143  .t_hot = OMAP5430_MPU_T_HOT,
144  .t_cold = OMAP5430_MPU_T_COLD,
145  .min_freq = OMAP5430_MPU_MIN_FREQ,
146  .max_freq = OMAP5430_MPU_MAX_FREQ,
147  .max_temp = OMAP5430_MPU_MAX_TEMP,
148  .min_temp = OMAP5430_MPU_MIN_TEMP,
149  .hyst_val = OMAP5430_MPU_HYST_VAL,
150  .adc_start_val = OMAP5430_ADC_START_VALUE,
151  .adc_end_val = OMAP5430_ADC_END_VALUE,
152  .update_int1 = 1000,
153  .update_int2 = 2000,
154 };
155 
156 /* Thresholds and limits for OMAP5430 GPU temperature sensor */
157 static struct temp_sensor_data omap5430_gpu_temp_sensor_data = {
158  .tshut_hot = OMAP5430_GPU_TSHUT_HOT,
159  .tshut_cold = OMAP5430_GPU_TSHUT_COLD,
160  .t_hot = OMAP5430_GPU_T_HOT,
161  .t_cold = OMAP5430_GPU_T_COLD,
162  .min_freq = OMAP5430_GPU_MIN_FREQ,
163  .max_freq = OMAP5430_GPU_MAX_FREQ,
164  .max_temp = OMAP5430_GPU_MAX_TEMP,
165  .min_temp = OMAP5430_GPU_MIN_TEMP,
166  .hyst_val = OMAP5430_GPU_HYST_VAL,
167  .adc_start_val = OMAP5430_ADC_START_VALUE,
168  .adc_end_val = OMAP5430_ADC_END_VALUE,
169  .update_int1 = 1000,
170  .update_int2 = 2000,
171 };
172 
173 /* Thresholds and limits for OMAP5430 CORE temperature sensor */
174 static struct temp_sensor_data omap5430_core_temp_sensor_data = {
175  .tshut_hot = OMAP5430_CORE_TSHUT_HOT,
176  .tshut_cold = OMAP5430_CORE_TSHUT_COLD,
177  .t_hot = OMAP5430_CORE_T_HOT,
178  .t_cold = OMAP5430_CORE_T_COLD,
179  .min_freq = OMAP5430_CORE_MIN_FREQ,
180  .max_freq = OMAP5430_CORE_MAX_FREQ,
181  .max_temp = OMAP5430_CORE_MAX_TEMP,
182  .min_temp = OMAP5430_CORE_MIN_TEMP,
183  .hyst_val = OMAP5430_CORE_HYST_VAL,
184  .adc_start_val = OMAP5430_ADC_START_VALUE,
185  .adc_end_val = OMAP5430_ADC_END_VALUE,
186  .update_int1 = 1000,
187  .update_int2 = 2000,
188 };
189 
190 static const int
191 omap5430_adc_to_temp[OMAP5430_ADC_END_VALUE - OMAP5430_ADC_START_VALUE + 1] = {
192  -40000, -40000, -40000, -40000, -39800, -39400, -39000, -38600,
193  -38200, -37800, -37300, -36800,
194  -36400, -36000, -35600, -35200, -34800, -34300, -33800, -33400, -33000,
195  -32600,
196  -32200, -31800, -31300, -30800, -30400, -30000, -29600, -29200, -28700,
197  -28200, -27800, -27400, -27000, -26600, -26200, -25700, -25200, -24800,
198  -24400, -24000, -23600, -23200, -22700, -22200, -21800, -21400, -21000,
199  -20600, -20200, -19700, -19200, -9300, -18400, -18000, -17600, -17200,
200  -16700, -16200, -15800, -15400, -15000, -14600, -14200, -13700, -13200,
201  -12800, -12400, -12000, -11600, -11200, -10700, -10200, -9800, -9400,
202  -9000,
203  -8600, -8200, -7700, -7200, -6800, -6400, -6000, -5600, -5200, -4800,
204  -4300,
205  -3800, -3400, -3000, -2600, -2200, -1800, -1300, -800, -400, 0, 400,
206  800,
207  1200, 1600, 2100, 2600, 3000, 3400, 3800, 4200, 4600, 5100, 5600, 6000,
208  6400, 6800, 7200, 7600, 8000, 8500, 9000, 9400, 9800, 10200, 10800,
209  11100,
210  11400, 11900, 12400, 12800, 13200, 13600, 14000, 14400, 14800, 15300,
211  15800,
212  16200, 16600, 17000, 17400, 17800, 18200, 18700, 19200, 19600, 20000,
213  20400,
214  20800, 21200, 21600, 22100, 22600, 23000, 23400, 23800, 24200, 24600,
215  25000,
216  25400, 25900, 26400, 26800, 27200, 27600, 28000, 28400, 28800, 29300,
217  29800,
218  30200, 30600, 31000, 31400, 31800, 32200, 32600, 33100, 33600, 34000,
219  34400,
220  34800, 35200, 35600, 36000, 36400, 36800, 37300, 37800, 38200, 38600,
221  39000,
222  39400, 39800, 40200, 40600, 41100, 41600, 42000, 42400, 42800, 43200,
223  43600,
224  44000, 44400, 44800, 45300, 45800, 46200, 46600, 47000, 47400, 47800,
225  48200,
226  48600, 49000, 49500, 50000, 50400, 50800, 51200, 51600, 52000, 52400,
227  52800,
228  53200, 53700, 54200, 54600, 55000, 55400, 55800, 56200, 56600, 57000,
229  57400,
230  57800, 58200, 58700, 59200, 59600, 60000, 60400, 60800, 61200, 61600,
231  62000,
232  62400, 62800, 63300, 63800, 64200, 64600, 65000, 65400, 65800, 66200,
233  66600,
234  67000, 67400, 67800, 68200, 68700, 69200, 69600, 70000, 70400, 70800,
235  71200,
236  71600, 72000, 72400, 72800, 73200, 73600, 74100, 74600, 75000, 75400,
237  75800,
238  76200, 76600, 77000, 77400, 77800, 78200, 78600, 79000, 79400, 79800,
239  80300,
240  80800, 81200, 81600, 82000, 82400, 82800, 83200, 83600, 84000, 84400,
241  84800,
242  85200, 85600, 86000, 86400, 86800, 87300, 87800, 88200, 88600, 89000,
243  89400,
244  89800, 90200, 90600, 91000, 91400, 91800, 92200, 92600, 93000, 93400,
245  93800,
246  94200, 94600, 95000, 95500, 96000, 96400, 96800, 97200, 97600, 98000,
247  98400,
248  98800, 99200, 99600, 100000, 100400, 100800, 101200, 101600, 102000,
249  102400,
250  102800, 103200, 103600, 104000, 104400, 104800, 105200, 105600, 106100,
251  106600, 107000, 107400, 107800, 108200, 108600, 109000, 109400, 109800,
252  110200, 110600, 111000, 111400, 111800, 112200, 112600, 113000, 113400,
253  113800, 114200, 114600, 115000, 115400, 115800, 116200, 116600, 117000,
254  117400, 117800, 118200, 118600, 119000, 119400, 119800, 120200, 120600,
255  121000, 121400, 121800, 122200, 122600, 123000, 123400, 123800, 124200,
256  124600, 124900, 125000, 125000, 125000, 125000,
257 };
258 
264  .fclock_name = "ts_clk_div_ck",
265  .div_ck_name = "ts_clk_div_ck",
266  .conv_table = omap5430_adc_to_temp,
267  .expose_sensor = omap_thermal_expose_sensor,
268  .remove_sensor = omap_thermal_remove_sensor,
269  .sensors = {
270  {
271  .registers = &omap5430_mpu_temp_sensor_registers,
272  .ts_data = &omap5430_mpu_temp_sensor_data,
273  .domain = "cpu",
274  .register_cooling = omap_thermal_register_cpu_cooling,
275  .unregister_cooling = omap_thermal_unregister_cpu_cooling,
277  .constant = OMAP_GRADIENT_CONST_5430_CPU,
279  .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_CPU,
280  },
281  {
282  .registers = &omap5430_gpu_temp_sensor_registers,
283  .ts_data = &omap5430_gpu_temp_sensor_data,
284  .domain = "gpu",
286  .constant = OMAP_GRADIENT_CONST_5430_GPU,
288  .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_GPU,
289  },
290  {
291  .registers = &omap5430_core_temp_sensor_registers,
292  .ts_data = &omap5430_core_temp_sensor_data,
293  .domain = "core",
294  },
295  },
296  .sensor_count = 3,
297 };