blob: ff8844f3b99bd1881f82f5bc1fa32b167325f590 [file] [log] [blame]
Donggeun Kim9d97e5c2011-09-07 18:49:08 +09001/*
Amit Daniel Kachhap0c1836a2013-06-24 16:20:27 +05302 * exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit)
Donggeun Kim9d97e5c2011-09-07 18:49:08 +09003 *
4 * Copyright (C) 2011 Samsung Electronics
5 * Donggeun Kim <dg77.kim@samsung.com>
Amit Daniel Kachhap0c1836a2013-06-24 16:20:27 +05306 * Amit Daniel Kachhap <amit.daniel@samsung.com>
Donggeun Kim9d97e5c2011-09-07 18:49:08 +09007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
Amit Daniel Kachhap0c1836a2013-06-24 16:20:27 +053023#ifndef _EXYNOS_TMU_H
24#define _EXYNOS_TMU_H
Amit Daniel Kachhap7e0b55e2012-08-16 17:11:43 +053025#include <linux/cpu_cooling.h>
Donggeun Kim9d97e5c2011-09-07 18:49:08 +090026
Amit Daniel Kachhap0c1836a2013-06-24 16:20:27 +053027#include "exynos_thermal_common.h"
28
Donggeun Kim9d97e5c2011-09-07 18:49:08 +090029enum calibration_type {
30 TYPE_ONE_POINT_TRIMMING,
31 TYPE_TWO_POINT_TRIMMING,
32 TYPE_NONE,
33};
34
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +053035enum calibration_mode {
36 SW_MODE,
37 HW_MODE,
38};
39
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +053040enum soc_type {
41 SOC_ARCH_EXYNOS4210 = 1,
42 SOC_ARCH_EXYNOS,
43};
Amit Daniel Kachhap7e0b55e2012-08-16 17:11:43 +053044
45/**
Amit Daniel Kachhapf4dae752013-06-24 16:20:40 +053046 * EXYNOS TMU supported features.
47 * TMU_SUPPORT_EMULATION - This features is used to set user defined
48 * temperature to the TMU controller.
49 * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
50 * has many instances of TMU.
51 * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can
52 * be reloaded.
53 * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
54 * be registered for falling trips also.
55 * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current
56 * state(active/idle) can be checked.
57 * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
58 * sample time.
59 * TMU_SUPPORT_SHARED_MEMORY - This feature tells that the different TMU
60 * sensors shares some common registers.
61 * TMU_SUPPORT - macro to compare the above features with the supplied.
62 */
63#define TMU_SUPPORT_EMULATION BIT(0)
64#define TMU_SUPPORT_MULTI_INST BIT(1)
65#define TMU_SUPPORT_TRIM_RELOAD BIT(2)
66#define TMU_SUPPORT_FALLING_TRIP BIT(3)
67#define TMU_SUPPORT_READY_STATUS BIT(4)
68#define TMU_SUPPORT_EMUL_TIME BIT(5)
69#define TMU_SUPPORT_SHARED_MEMORY BIT(6)
70
71#define TMU_SUPPORTS(a, b) (a->features & TMU_SUPPORT_ ## b)
72
73/**
Amit Daniel Kachhapb8d582b2013-06-24 16:20:31 +053074 * struct exynos_tmu_register - register descriptors to access registers and
75 * bitfields. The register validity, offsets and bitfield values may vary
76 * slightly across different exynos SOC's.
77 * @triminfo_data: register containing 2 pont trimming data
78 * @triminfo_25_shift: shift bit of the 25 C trim value in triminfo_data reg.
79 * @triminfo_85_shift: shift bit of the 85 C trim value in triminfo_data reg.
80 * @triminfo_ctrl: trim info controller register.
81 * @triminfo_reload_shift: shift of triminfo reload enable bit in triminfo_ctrl
82 reg.
83 * @tmu_ctrl: TMU main controller register.
84 * @buf_vref_sel_shift: shift bits of reference voltage in tmu_ctrl register.
85 * @buf_vref_sel_mask: mask bits of reference voltage in tmu_ctrl register.
86 * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
87 * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
88 * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
89 * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
90 register.
91 * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
92 * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
93 tmu_ctrl register.
94 * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
95 * @tmu_status: register drescribing the TMU status.
96 * @tmu_cur_temp: register containing the current temperature of the TMU.
97 * @tmu_cur_temp_shift: shift bits of current temp value in tmu_cur_temp
98 register.
99 * @threshold_temp: register containing the base threshold level.
100 * @threshold_th0: Register containing first set of rising levels.
101 * @threshold_th0_l0_shift: shift bits of level0 threshold temperature.
102 * @threshold_th0_l1_shift: shift bits of level1 threshold temperature.
103 * @threshold_th0_l2_shift: shift bits of level2 threshold temperature.
104 * @threshold_th0_l3_shift: shift bits of level3 threshold temperature.
105 * @threshold_th1: Register containing second set of rising levels.
106 * @threshold_th1_l0_shift: shift bits of level0 threshold temperature.
107 * @threshold_th1_l1_shift: shift bits of level1 threshold temperature.
108 * @threshold_th1_l2_shift: shift bits of level2 threshold temperature.
109 * @threshold_th1_l3_shift: shift bits of level3 threshold temperature.
110 * @threshold_th2: Register containing third set of rising levels.
111 * @threshold_th2_l0_shift: shift bits of level0 threshold temperature.
112 * @threshold_th3: Register containing fourth set of rising levels.
113 * @threshold_th3_l0_shift: shift bits of level0 threshold temperature.
114 * @tmu_inten: register containing the different threshold interrupt
115 enable bits.
116 * @inten_rise_shift: shift bits of all rising interrupt bits.
117 * @inten_rise_mask: mask bits of all rising interrupt bits.
118 * @inten_fall_shift: shift bits of all rising interrupt bits.
119 * @inten_fall_mask: mask bits of all rising interrupt bits.
120 * @inten_rise0_shift: shift bits of rising 0 interrupt bits.
121 * @inten_rise1_shift: shift bits of rising 1 interrupt bits.
122 * @inten_rise2_shift: shift bits of rising 2 interrupt bits.
123 * @inten_rise3_shift: shift bits of rising 3 interrupt bits.
124 * @inten_fall0_shift: shift bits of falling 0 interrupt bits.
125 * @inten_fall1_shift: shift bits of falling 1 interrupt bits.
126 * @inten_fall2_shift: shift bits of falling 2 interrupt bits.
127 * @inten_fall3_shift: shift bits of falling 3 interrupt bits.
128 * @tmu_intstat: Register containing the interrupt status values.
129 * @tmu_intclear: Register for clearing the raised interrupt status.
130 * @emul_con: TMU emulation controller register.
131 * @emul_temp_shift: shift bits of emulation temperature.
132 * @emul_time_shift: shift bits of emulation time.
133 * @emul_time_mask: mask bits of emulation time.
134 */
135struct exynos_tmu_registers {
136 u32 triminfo_data;
137 u32 triminfo_25_shift;
138 u32 triminfo_85_shift;
139
140 u32 triminfo_ctrl;
141 u32 triminfo_reload_shift;
142
143 u32 tmu_ctrl;
144 u32 buf_vref_sel_shift;
145 u32 buf_vref_sel_mask;
146 u32 therm_trip_mode_shift;
147 u32 therm_trip_mode_mask;
148 u32 therm_trip_en_shift;
149 u32 buf_slope_sel_shift;
150 u32 buf_slope_sel_mask;
151 u32 therm_trip_tq_en_shift;
152 u32 core_en_shift;
153
154 u32 tmu_status;
155
156 u32 tmu_cur_temp;
157 u32 tmu_cur_temp_shift;
158
159 u32 threshold_temp;
160
161 u32 threshold_th0;
162 u32 threshold_th0_l0_shift;
163 u32 threshold_th0_l1_shift;
164 u32 threshold_th0_l2_shift;
165 u32 threshold_th0_l3_shift;
166
167 u32 threshold_th1;
168 u32 threshold_th1_l0_shift;
169 u32 threshold_th1_l1_shift;
170 u32 threshold_th1_l2_shift;
171 u32 threshold_th1_l3_shift;
172
173 u32 threshold_th2;
174 u32 threshold_th2_l0_shift;
175
176 u32 threshold_th3;
177 u32 threshold_th3_l0_shift;
178
179 u32 tmu_inten;
180 u32 inten_rise_shift;
181 u32 inten_rise_mask;
182 u32 inten_fall_shift;
183 u32 inten_fall_mask;
184 u32 inten_rise0_shift;
185 u32 inten_rise1_shift;
186 u32 inten_rise2_shift;
187 u32 inten_rise3_shift;
188 u32 inten_fall0_shift;
189 u32 inten_fall1_shift;
190 u32 inten_fall2_shift;
191 u32 inten_fall3_shift;
192
193 u32 tmu_intstat;
194
195 u32 tmu_intclear;
196
197 u32 emul_con;
198 u32 emul_temp_shift;
199 u32 emul_time_shift;
200 u32 emul_time_mask;
201};
202
203/**
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +0530204 * struct exynos_tmu_platform_data
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900205 * @threshold: basic temperature for generating interrupt
206 * 25 <= threshold <= 125 [unit: degree Celsius]
Jonghwa Lee4f0a6842013-02-08 01:13:06 +0000207 * @threshold_falling: differntial value for setting threshold
208 * of temperature falling interrupt.
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900209 * @trigger_levels: array for each interrupt levels
210 * [unit: degree Celsius]
211 * 0: temperature for trigger_level0 interrupt
212 * condition for trigger_level0 interrupt:
213 * current temperature > threshold + trigger_levels[0]
214 * 1: temperature for trigger_level1 interrupt
215 * condition for trigger_level1 interrupt:
216 * current temperature > threshold + trigger_levels[1]
217 * 2: temperature for trigger_level2 interrupt
218 * condition for trigger_level2 interrupt:
219 * current temperature > threshold + trigger_levels[2]
220 * 3: temperature for trigger_level3 interrupt
221 * condition for trigger_level3 interrupt:
222 * current temperature > threshold + trigger_levels[3]
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +0530223 * @trigger_type: defines the type of trigger. Possible values are,
224 * THROTTLE_ACTIVE trigger type
225 * THROTTLE_PASSIVE trigger type
226 * SW_TRIP trigger type
227 * HW_TRIP
228 * @trigger_enable[]: array to denote which trigger levels are enabled.
229 * 1 = enable trigger_level[] interrupt,
230 * 0 = disable trigger_level[] interrupt
231 * @max_trigger_level: max trigger level supported by the TMU
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900232 * @gain: gain of amplifier in the positive-TC generator block
233 * 0 <= gain <= 15
234 * @reference_voltage: reference voltage of amplifier
235 * in the positive-TC generator block
236 * 0 <= reference_voltage <= 31
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +0530237 * @noise_cancel_mode: noise cancellation mode
238 * 000, 100, 101, 110 and 111 can be different modes
239 * @type: determines the type of SOC
240 * @efuse_value: platform defined fuse value
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +0530241 * @min_efuse_value: minimum valid trimming data
242 * @max_efuse_value: maximum valid trimming data
243 * @first_point_trim: temp value of the first point trimming
244 * @second_point_trim: temp value of the second point trimming
245 * @default_temp_offset: default temperature offset in case of no trimming
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900246 * @cal_type: calibration type for temperature
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +0530247 * @cal_mode: calibration mode for temperature
Amit Daniel Kachhap7e0b55e2012-08-16 17:11:43 +0530248 * @freq_clip_table: Table representing frequency reduction percentage.
249 * @freq_tab_count: Count of the above table as frequency reduction may
250 * applicable to only some of the trigger levels.
Amit Daniel Kachhapb8d582b2013-06-24 16:20:31 +0530251 * @registers: Pointer to structure containing all the TMU controller registers
252 * and bitfields shifts and masks.
Amit Daniel Kachhapf4dae752013-06-24 16:20:40 +0530253 * @features: a bitfield value indicating the features supported in SOC like
254 * emulation, multi instance etc
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900255 *
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +0530256 * This structure is required for configuration of exynos_tmu driver.
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900257 */
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +0530258struct exynos_tmu_platform_data {
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900259 u8 threshold;
Jonghwa Lee4f0a6842013-02-08 01:13:06 +0000260 u8 threshold_falling;
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +0530261 u8 trigger_levels[MAX_TRIP_COUNT];
262 enum trigger_type trigger_type[MAX_TRIP_COUNT];
263 bool trigger_enable[MAX_TRIP_COUNT];
264 u8 max_trigger_level;
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900265 u8 gain;
266 u8 reference_voltage;
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +0530267 u8 noise_cancel_mode;
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +0530268
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +0530269 u32 efuse_value;
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +0530270 u32 min_efuse_value;
271 u32 max_efuse_value;
272 u8 first_point_trim;
273 u8 second_point_trim;
274 u8 default_temp_offset;
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900275
276 enum calibration_type cal_type;
Amit Daniel Kachhapbb34b4c2013-06-24 16:20:30 +0530277 enum calibration_mode cal_mode;
Amit Daniel Kachhapf22d9c02012-08-16 17:11:42 +0530278 enum soc_type type;
Amit Daniel Kachhap7e0b55e2012-08-16 17:11:43 +0530279 struct freq_clip_table freq_tab[4];
280 unsigned int freq_tab_count;
Amit Daniel Kachhapb8d582b2013-06-24 16:20:31 +0530281 const struct exynos_tmu_registers *registers;
Amit Daniel Kachhapf4dae752013-06-24 16:20:40 +0530282 unsigned int features;
Donggeun Kim9d97e5c2011-09-07 18:49:08 +0900283};
Amit Daniel Kachhapcebe7372013-06-24 16:20:39 +0530284
285/**
286 * struct exynos_tmu_init_data
287 * @tmu_count: number of TMU instances.
288 * @tmu_data: platform data of all TMU instances.
289 * This structure is required to store data for multi-instance exynos tmu
290 * driver.
291 */
292struct exynos_tmu_init_data {
293 int tmu_count;
294 struct exynos_tmu_platform_data tmu_data[];
295};
296
Amit Daniel Kachhap0c1836a2013-06-24 16:20:27 +0530297#endif /* _EXYNOS_TMU_H */