aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorAmit Daniel Kachhap <amit.daniel@samsung.com>2013-06-24 06:50:31 -0400
committerEduardo Valentin <eduardo.valentin@ti.com>2013-08-13 09:52:00 -0400
commitb8d582b9405c75506f4adff9abd4afbe7b698b61 (patch)
tree4c45b7aea583b04ab7d72ed309831125f565211d /drivers/thermal
parentbb34b4c8cfd8538376666f574ed90b03ea2b0446 (diff)
thermal: exynos: Move register definitions from driver to data file
This patch migrates the TMU register definition/bitfields to data file. This is needed to support SoC's which use the same TMU controller but register validity, offsets or bitfield may slightly vary across SOC's. Acked-by: Kukjin Kim <kgene.kim@samsung.com> Acked-by: Jonghwa Lee <jonghwa3.lee@samsung.com> Acked-by: Eduardo Valentin <eduardo.valentin@ti.com> Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c172
-rw-r--r--drivers/thermal/samsung/exynos_tmu.h133
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.c59
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.h68
4 files changed, 315 insertions, 117 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 401ec980c592..6fd776f41ebc 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -32,76 +32,6 @@
32#include "exynos_tmu.h" 32#include "exynos_tmu.h"
33#include "exynos_tmu_data.h" 33#include "exynos_tmu_data.h"
34 34
35/* Exynos generic registers */
36#define EXYNOS_TMU_REG_TRIMINFO 0x0
37#define EXYNOS_TMU_REG_CONTROL 0x20
38#define EXYNOS_TMU_REG_STATUS 0x28
39#define EXYNOS_TMU_REG_CURRENT_TEMP 0x40
40#define EXYNOS_TMU_REG_INTEN 0x70
41#define EXYNOS_TMU_REG_INTSTAT 0x74
42#define EXYNOS_TMU_REG_INTCLEAR 0x78
43
44#define EXYNOS_TMU_TRIM_TEMP_MASK 0xff
45#define EXYNOS_TMU_GAIN_SHIFT 8
46#define EXYNOS_TMU_GAIN_MASK 0xf
47#define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24
48#define EXYNOS_TMU_REF_VOLTAGE_MASK 0x1f
49#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf
50#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8
51#define EXYNOS_TMU_CORE_EN_SHIFT 0
52
53/* Exynos4210 specific registers */
54#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44
55#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50
56#define EXYNOS4210_TMU_REG_TRIG_LEVEL1 0x54
57#define EXYNOS4210_TMU_REG_TRIG_LEVEL2 0x58
58#define EXYNOS4210_TMU_REG_TRIG_LEVEL3 0x5C
59#define EXYNOS4210_TMU_REG_PAST_TEMP0 0x60
60#define EXYNOS4210_TMU_REG_PAST_TEMP1 0x64
61#define EXYNOS4210_TMU_REG_PAST_TEMP2 0x68
62#define EXYNOS4210_TMU_REG_PAST_TEMP3 0x6C
63
64#define EXYNOS4210_TMU_TRIG_LEVEL0_MASK 0x1
65#define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10
66#define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100
67#define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000
68#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x1111
69#define EXYNOS4210_TMU_INTCLEAR_VAL 0x1111
70
71/* Exynos5250 and Exynos4412 specific registers */
72#define EXYNOS_TMU_TRIMINFO_CON 0x14
73#define EXYNOS_THD_TEMP_RISE 0x50
74#define EXYNOS_THD_TEMP_FALL 0x54
75#define EXYNOS_EMUL_CON 0x80
76
77#define EXYNOS_TRIMINFO_RELOAD 0x1
78#define EXYNOS_TRIMINFO_SHIFT 0x0
79#define EXYNOS_TMU_RISE_INT_MASK 0x111
80#define EXYNOS_TMU_RISE_INT_SHIFT 0
81#define EXYNOS_TMU_FALL_INT_MASK 0x111
82#define EXYNOS_TMU_FALL_INT_SHIFT 12
83#define EXYNOS_TMU_CLEAR_RISE_INT 0x111
84#define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12)
85#define EXYNOS_TMU_TRIP_MODE_SHIFT 13
86#define EXYNOS_TMU_TRIP_MODE_MASK 0x7
87
88#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0
89#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4
90#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8
91#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12
92#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16
93#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20
94#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24
95
96#ifdef CONFIG_THERMAL_EMULATION
97#define EXYNOS_EMUL_TIME 0x57F0
98#define EXYNOS_EMUL_TIME_MASK 0xffff
99#define EXYNOS_EMUL_TIME_SHIFT 16
100#define EXYNOS_EMUL_DATA_SHIFT 8
101#define EXYNOS_EMUL_DATA_MASK 0xFF
102#define EXYNOS_EMUL_ENABLE 0x1
103#endif /* CONFIG_THERMAL_EMULATION */
104
105struct exynos_tmu_data { 35struct exynos_tmu_data {
106 struct exynos_tmu_platform_data *pdata; 36 struct exynos_tmu_platform_data *pdata;
107 struct resource *mem; 37 struct resource *mem;
@@ -186,6 +116,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
186{ 116{
187 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 117 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
188 struct exynos_tmu_platform_data *pdata = data->pdata; 118 struct exynos_tmu_platform_data *pdata = data->pdata;
119 const struct exynos_tmu_registers *reg = pdata->registers;
189 unsigned int status, trim_info; 120 unsigned int status, trim_info;
190 unsigned int rising_threshold = 0, falling_threshold = 0; 121 unsigned int rising_threshold = 0, falling_threshold = 0;
191 int ret = 0, threshold_code, i, trigger_levs = 0; 122 int ret = 0, threshold_code, i, trigger_levs = 0;
@@ -193,20 +124,20 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
193 mutex_lock(&data->lock); 124 mutex_lock(&data->lock);
194 clk_enable(data->clk); 125 clk_enable(data->clk);
195 126
196 status = readb(data->base + EXYNOS_TMU_REG_STATUS); 127 status = readb(data->base + reg->tmu_status);
197 if (!status) { 128 if (!status) {
198 ret = -EBUSY; 129 ret = -EBUSY;
199 goto out; 130 goto out;
200 } 131 }
201 132
202 if (data->soc == SOC_ARCH_EXYNOS) { 133 if (data->soc == SOC_ARCH_EXYNOS)
203 __raw_writel(EXYNOS_TRIMINFO_RELOAD, 134 __raw_writel(1, data->base + reg->triminfo_ctrl);
204 data->base + EXYNOS_TMU_TRIMINFO_CON); 135
205 }
206 /* Save trimming info in order to perform calibration */ 136 /* Save trimming info in order to perform calibration */
207 trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); 137 trim_info = readl(data->base + reg->triminfo_data);
208 data->temp_error1 = trim_info & EXYNOS_TMU_TRIM_TEMP_MASK; 138 data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
209 data->temp_error2 = ((trim_info >> 8) & EXYNOS_TMU_TRIM_TEMP_MASK); 139 data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) &
140 EXYNOS_TMU_TEMP_MASK);
210 141
211 if ((pdata->min_efuse_value > data->temp_error1) || 142 if ((pdata->min_efuse_value > data->temp_error1) ||
212 (data->temp_error1 > pdata->max_efuse_value) || 143 (data->temp_error1 > pdata->max_efuse_value) ||
@@ -226,13 +157,12 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
226 goto out; 157 goto out;
227 } 158 }
228 writeb(threshold_code, 159 writeb(threshold_code,
229 data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 160 data->base + reg->threshold_temp);
230 for (i = 0; i < trigger_levs; i++) 161 for (i = 0; i < trigger_levs; i++)
231 writeb(pdata->trigger_levels[i], 162 writeb(pdata->trigger_levels[i], data->base +
232 data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4); 163 reg->threshold_th0 + i * sizeof(reg->threshold_th0));
233 164
234 writel(EXYNOS4210_TMU_INTCLEAR_VAL, 165 writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
235 data->base + EXYNOS_TMU_REG_INTCLEAR);
236 } else if (data->soc == SOC_ARCH_EXYNOS) { 166 } else if (data->soc == SOC_ARCH_EXYNOS) {
237 /* Write temperature code for rising and falling threshold */ 167 /* Write temperature code for rising and falling threshold */
238 for (i = 0; i < trigger_levs; i++) { 168 for (i = 0; i < trigger_levs; i++) {
@@ -254,12 +184,13 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
254 } 184 }
255 185
256 writel(rising_threshold, 186 writel(rising_threshold,
257 data->base + EXYNOS_THD_TEMP_RISE); 187 data->base + reg->threshold_th0);
258 writel(falling_threshold, 188 writel(falling_threshold,
259 data->base + EXYNOS_THD_TEMP_FALL); 189 data->base + reg->threshold_th1);
260 190
261 writel(EXYNOS_TMU_CLEAR_RISE_INT | EXYNOS_TMU_CLEAR_FALL_INT, 191 writel((reg->inten_rise_mask << reg->inten_rise_shift) |
262 data->base + EXYNOS_TMU_REG_INTCLEAR); 192 (reg->inten_fall_mask << reg->inten_fall_shift),
193 data->base + reg->tmu_intclear);
263 } 194 }
264out: 195out:
265 clk_disable(data->clk); 196 clk_disable(data->clk);
@@ -272,46 +203,46 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
272{ 203{
273 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 204 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
274 struct exynos_tmu_platform_data *pdata = data->pdata; 205 struct exynos_tmu_platform_data *pdata = data->pdata;
206 const struct exynos_tmu_registers *reg = pdata->registers;
275 unsigned int con, interrupt_en; 207 unsigned int con, interrupt_en;
276 208
277 mutex_lock(&data->lock); 209 mutex_lock(&data->lock);
278 clk_enable(data->clk); 210 clk_enable(data->clk);
279 211
280 con = readl(data->base + EXYNOS_TMU_REG_CONTROL); 212 con = readl(data->base + reg->tmu_ctrl);
281 213
282 if (pdata->reference_voltage) { 214 if (pdata->reference_voltage) {
283 con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << 215 con &= ~(reg->buf_vref_sel_mask << reg->buf_vref_sel_shift);
284 EXYNOS_TMU_REF_VOLTAGE_SHIFT); 216 con |= pdata->reference_voltage << reg->buf_vref_sel_shift;
285 con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT;
286 } 217 }
287 218
288 if (pdata->gain) { 219 if (pdata->gain) {
289 con &= ~(EXYNOS_TMU_GAIN_MASK << EXYNOS_TMU_GAIN_SHIFT); 220 con &= ~(reg->buf_slope_sel_mask << reg->buf_slope_sel_shift);
290 con |= (pdata->gain << EXYNOS_TMU_GAIN_SHIFT); 221 con |= (pdata->gain << reg->buf_slope_sel_shift);
291 } 222 }
292 223
293 if (pdata->noise_cancel_mode) { 224 if (pdata->noise_cancel_mode) {
294 con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << 225 con &= ~(reg->therm_trip_mode_mask <<
295 EXYNOS_TMU_TRIP_MODE_SHIFT); 226 reg->therm_trip_mode_shift);
296 con |= (pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT); 227 con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift);
297 } 228 }
298 229
299 if (on) { 230 if (on) {
300 con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); 231 con |= (1 << reg->core_en_shift);
301 interrupt_en = 232 interrupt_en =
302 pdata->trigger_enable[3] << EXYNOS_TMU_INTEN_RISE3_SHIFT | 233 pdata->trigger_enable[3] << reg->inten_rise3_shift |
303 pdata->trigger_enable[2] << EXYNOS_TMU_INTEN_RISE2_SHIFT | 234 pdata->trigger_enable[2] << reg->inten_rise2_shift |
304 pdata->trigger_enable[1] << EXYNOS_TMU_INTEN_RISE1_SHIFT | 235 pdata->trigger_enable[1] << reg->inten_rise1_shift |
305 pdata->trigger_enable[0] << EXYNOS_TMU_INTEN_RISE0_SHIFT; 236 pdata->trigger_enable[0] << reg->inten_rise0_shift;
306 if (pdata->threshold_falling) 237 if (pdata->threshold_falling)
307 interrupt_en |= 238 interrupt_en |=
308 interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; 239 interrupt_en << reg->inten_fall0_shift;
309 } else { 240 } else {
310 con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT); 241 con &= ~(1 << reg->core_en_shift);
311 interrupt_en = 0; /* Disable all interrupts */ 242 interrupt_en = 0; /* Disable all interrupts */
312 } 243 }
313 writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN); 244 writel(interrupt_en, data->base + reg->tmu_inten);
314 writel(con, data->base + EXYNOS_TMU_REG_CONTROL); 245 writel(con, data->base + reg->tmu_ctrl);
315 246
316 clk_disable(data->clk); 247 clk_disable(data->clk);
317 mutex_unlock(&data->lock); 248 mutex_unlock(&data->lock);
@@ -319,13 +250,15 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
319 250
320static int exynos_tmu_read(struct exynos_tmu_data *data) 251static int exynos_tmu_read(struct exynos_tmu_data *data)
321{ 252{
253 struct exynos_tmu_platform_data *pdata = data->pdata;
254 const struct exynos_tmu_registers *reg = pdata->registers;
322 u8 temp_code; 255 u8 temp_code;
323 int temp; 256 int temp;
324 257
325 mutex_lock(&data->lock); 258 mutex_lock(&data->lock);
326 clk_enable(data->clk); 259 clk_enable(data->clk);
327 260
328 temp_code = readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP); 261 temp_code = readb(data->base + reg->tmu_cur_temp);
329 temp = code_to_temp(data, temp_code); 262 temp = code_to_temp(data, temp_code);
330 263
331 clk_disable(data->clk); 264 clk_disable(data->clk);
@@ -338,7 +271,9 @@ static int exynos_tmu_read(struct exynos_tmu_data *data)
338static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) 271static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
339{ 272{
340 struct exynos_tmu_data *data = drv_data; 273 struct exynos_tmu_data *data = drv_data;
341 unsigned int reg; 274 struct exynos_tmu_platform_data *pdata = data->pdata;
275 const struct exynos_tmu_registers *reg = pdata->registers;
276 unsigned int val;
342 int ret = -EINVAL; 277 int ret = -EINVAL;
343 278
344 if (data->soc == SOC_ARCH_EXYNOS4210) 279 if (data->soc == SOC_ARCH_EXYNOS4210)
@@ -350,19 +285,19 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
350 mutex_lock(&data->lock); 285 mutex_lock(&data->lock);
351 clk_enable(data->clk); 286 clk_enable(data->clk);
352 287
353 reg = readl(data->base + EXYNOS_EMUL_CON); 288 val = readl(data->base + reg->emul_con);
354 289
355 if (temp) { 290 if (temp) {
356 temp /= MCELSIUS; 291 temp /= MCELSIUS;
357 292
358 reg = (EXYNOS_EMUL_TIME << EXYNOS_EMUL_TIME_SHIFT) | 293 val = (EXYNOS_EMUL_TIME << reg->emul_time_shift) |
359 (temp_to_code(data, temp) 294 (temp_to_code(data, temp)
360 << EXYNOS_EMUL_DATA_SHIFT) | EXYNOS_EMUL_ENABLE; 295 << reg->emul_temp_shift) | EXYNOS_EMUL_ENABLE;
361 } else { 296 } else {
362 reg &= ~EXYNOS_EMUL_ENABLE; 297 val &= ~EXYNOS_EMUL_ENABLE;
363 } 298 }
364 299
365 writel(reg, data->base + EXYNOS_EMUL_CON); 300 writel(val, data->base + reg->emul_con);
366 301
367 clk_disable(data->clk); 302 clk_disable(data->clk);
368 mutex_unlock(&data->lock); 303 mutex_unlock(&data->lock);
@@ -379,17 +314,20 @@ static void exynos_tmu_work(struct work_struct *work)
379{ 314{
380 struct exynos_tmu_data *data = container_of(work, 315 struct exynos_tmu_data *data = container_of(work,
381 struct exynos_tmu_data, irq_work); 316 struct exynos_tmu_data, irq_work);
317 struct exynos_tmu_platform_data *pdata = data->pdata;
318 const struct exynos_tmu_registers *reg = pdata->registers;
382 319
383 exynos_report_trigger(); 320 exynos_report_trigger();
384 mutex_lock(&data->lock); 321 mutex_lock(&data->lock);
385 clk_enable(data->clk); 322 clk_enable(data->clk);
323
386 if (data->soc == SOC_ARCH_EXYNOS) 324 if (data->soc == SOC_ARCH_EXYNOS)
387 writel(EXYNOS_TMU_CLEAR_RISE_INT | 325 writel((reg->inten_rise_mask << reg->inten_rise_shift) |
388 EXYNOS_TMU_CLEAR_FALL_INT, 326 (reg->inten_fall_mask << reg->inten_fall_shift),
389 data->base + EXYNOS_TMU_REG_INTCLEAR); 327 data->base + reg->tmu_intclear);
390 else 328 else
391 writel(EXYNOS4210_TMU_INTCLEAR_VAL, 329 writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
392 data->base + EXYNOS_TMU_REG_INTCLEAR); 330
393 clk_disable(data->clk); 331 clk_disable(data->clk);
394 mutex_unlock(&data->lock); 332 mutex_unlock(&data->lock);
395 333
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 473acae04f82..ef5dc0ebff75 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -43,6 +43,136 @@ enum soc_type {
43}; 43};
44 44
45/** 45/**
46 * struct exynos_tmu_register - register descriptors to access registers and
47 * bitfields. The register validity, offsets and bitfield values may vary
48 * slightly across different exynos SOC's.
49 * @triminfo_data: register containing 2 pont trimming data
50 * @triminfo_25_shift: shift bit of the 25 C trim value in triminfo_data reg.
51 * @triminfo_85_shift: shift bit of the 85 C trim value in triminfo_data reg.
52 * @triminfo_ctrl: trim info controller register.
53 * @triminfo_reload_shift: shift of triminfo reload enable bit in triminfo_ctrl
54 reg.
55 * @tmu_ctrl: TMU main controller register.
56 * @buf_vref_sel_shift: shift bits of reference voltage in tmu_ctrl register.
57 * @buf_vref_sel_mask: mask bits of reference voltage in tmu_ctrl register.
58 * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
59 * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
60 * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
61 * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
62 register.
63 * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
64 * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
65 tmu_ctrl register.
66 * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
67 * @tmu_status: register drescribing the TMU status.
68 * @tmu_cur_temp: register containing the current temperature of the TMU.
69 * @tmu_cur_temp_shift: shift bits of current temp value in tmu_cur_temp
70 register.
71 * @threshold_temp: register containing the base threshold level.
72 * @threshold_th0: Register containing first set of rising levels.
73 * @threshold_th0_l0_shift: shift bits of level0 threshold temperature.
74 * @threshold_th0_l1_shift: shift bits of level1 threshold temperature.
75 * @threshold_th0_l2_shift: shift bits of level2 threshold temperature.
76 * @threshold_th0_l3_shift: shift bits of level3 threshold temperature.
77 * @threshold_th1: Register containing second set of rising levels.
78 * @threshold_th1_l0_shift: shift bits of level0 threshold temperature.
79 * @threshold_th1_l1_shift: shift bits of level1 threshold temperature.
80 * @threshold_th1_l2_shift: shift bits of level2 threshold temperature.
81 * @threshold_th1_l3_shift: shift bits of level3 threshold temperature.
82 * @threshold_th2: Register containing third set of rising levels.
83 * @threshold_th2_l0_shift: shift bits of level0 threshold temperature.
84 * @threshold_th3: Register containing fourth set of rising levels.
85 * @threshold_th3_l0_shift: shift bits of level0 threshold temperature.
86 * @tmu_inten: register containing the different threshold interrupt
87 enable bits.
88 * @inten_rise_shift: shift bits of all rising interrupt bits.
89 * @inten_rise_mask: mask bits of all rising interrupt bits.
90 * @inten_fall_shift: shift bits of all rising interrupt bits.
91 * @inten_fall_mask: mask bits of all rising interrupt bits.
92 * @inten_rise0_shift: shift bits of rising 0 interrupt bits.
93 * @inten_rise1_shift: shift bits of rising 1 interrupt bits.
94 * @inten_rise2_shift: shift bits of rising 2 interrupt bits.
95 * @inten_rise3_shift: shift bits of rising 3 interrupt bits.
96 * @inten_fall0_shift: shift bits of falling 0 interrupt bits.
97 * @inten_fall1_shift: shift bits of falling 1 interrupt bits.
98 * @inten_fall2_shift: shift bits of falling 2 interrupt bits.
99 * @inten_fall3_shift: shift bits of falling 3 interrupt bits.
100 * @tmu_intstat: Register containing the interrupt status values.
101 * @tmu_intclear: Register for clearing the raised interrupt status.
102 * @emul_con: TMU emulation controller register.
103 * @emul_temp_shift: shift bits of emulation temperature.
104 * @emul_time_shift: shift bits of emulation time.
105 * @emul_time_mask: mask bits of emulation time.
106 */
107struct exynos_tmu_registers {
108 u32 triminfo_data;
109 u32 triminfo_25_shift;
110 u32 triminfo_85_shift;
111
112 u32 triminfo_ctrl;
113 u32 triminfo_reload_shift;
114
115 u32 tmu_ctrl;
116 u32 buf_vref_sel_shift;
117 u32 buf_vref_sel_mask;
118 u32 therm_trip_mode_shift;
119 u32 therm_trip_mode_mask;
120 u32 therm_trip_en_shift;
121 u32 buf_slope_sel_shift;
122 u32 buf_slope_sel_mask;
123 u32 therm_trip_tq_en_shift;
124 u32 core_en_shift;
125
126 u32 tmu_status;
127
128 u32 tmu_cur_temp;
129 u32 tmu_cur_temp_shift;
130
131 u32 threshold_temp;
132
133 u32 threshold_th0;
134 u32 threshold_th0_l0_shift;
135 u32 threshold_th0_l1_shift;
136 u32 threshold_th0_l2_shift;
137 u32 threshold_th0_l3_shift;
138
139 u32 threshold_th1;
140 u32 threshold_th1_l0_shift;
141 u32 threshold_th1_l1_shift;
142 u32 threshold_th1_l2_shift;
143 u32 threshold_th1_l3_shift;
144
145 u32 threshold_th2;
146 u32 threshold_th2_l0_shift;
147
148 u32 threshold_th3;
149 u32 threshold_th3_l0_shift;
150
151 u32 tmu_inten;
152 u32 inten_rise_shift;
153 u32 inten_rise_mask;
154 u32 inten_fall_shift;
155 u32 inten_fall_mask;
156 u32 inten_rise0_shift;
157 u32 inten_rise1_shift;
158 u32 inten_rise2_shift;
159 u32 inten_rise3_shift;
160 u32 inten_fall0_shift;
161 u32 inten_fall1_shift;
162 u32 inten_fall2_shift;
163 u32 inten_fall3_shift;
164
165 u32 tmu_intstat;
166
167 u32 tmu_intclear;
168
169 u32 emul_con;
170 u32 emul_temp_shift;
171 u32 emul_time_shift;
172 u32 emul_time_mask;
173};
174
175/**
46 * struct exynos_tmu_platform_data 176 * struct exynos_tmu_platform_data
47 * @threshold: basic temperature for generating interrupt 177 * @threshold: basic temperature for generating interrupt
48 * 25 <= threshold <= 125 [unit: degree Celsius] 178 * 25 <= threshold <= 125 [unit: degree Celsius]
@@ -90,6 +220,8 @@ enum soc_type {
90 * @freq_clip_table: Table representing frequency reduction percentage. 220 * @freq_clip_table: Table representing frequency reduction percentage.
91 * @freq_tab_count: Count of the above table as frequency reduction may 221 * @freq_tab_count: Count of the above table as frequency reduction may
92 * applicable to only some of the trigger levels. 222 * applicable to only some of the trigger levels.
223 * @registers: Pointer to structure containing all the TMU controller registers
224 * and bitfields shifts and masks.
93 * 225 *
94 * This structure is required for configuration of exynos_tmu driver. 226 * This structure is required for configuration of exynos_tmu driver.
95 */ 227 */
@@ -116,5 +248,6 @@ struct exynos_tmu_platform_data {
116 enum soc_type type; 248 enum soc_type type;
117 struct freq_clip_table freq_tab[4]; 249 struct freq_clip_table freq_tab[4];
118 unsigned int freq_tab_count; 250 unsigned int freq_tab_count;
251 const struct exynos_tmu_registers *registers;
119}; 252};
120#endif /* _EXYNOS_TMU_H */ 253#endif /* _EXYNOS_TMU_H */
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index 24934d7c7f05..896aa2ac0bb4 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -25,6 +25,28 @@
25#include "exynos_tmu_data.h" 25#include "exynos_tmu_data.h"
26 26
27#if defined(CONFIG_CPU_EXYNOS4210) 27#if defined(CONFIG_CPU_EXYNOS4210)
28static const struct exynos_tmu_registers exynos4210_tmu_registers = {
29 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
30 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
31 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
32 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
33 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
34 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
35 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
36 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
37 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
38 .tmu_status = EXYNOS_TMU_REG_STATUS,
39 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
40 .threshold_temp = EXYNOS4210_TMU_REG_THRESHOLD_TEMP,
41 .threshold_th0 = EXYNOS4210_TMU_REG_TRIG_LEVEL0,
42 .tmu_inten = EXYNOS_TMU_REG_INTEN,
43 .inten_rise_mask = EXYNOS4210_TMU_TRIG_LEVEL_MASK,
44 .inten_rise0_shift = EXYNOS_TMU_INTEN_RISE0_SHIFT,
45 .inten_rise1_shift = EXYNOS_TMU_INTEN_RISE1_SHIFT,
46 .inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT,
47 .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT,
48 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
49};
28struct exynos_tmu_platform_data const exynos4210_default_tmu_data = { 50struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
29 .threshold = 80, 51 .threshold = 80,
30 .trigger_levels[0] = 5, 52 .trigger_levels[0] = 5,
@@ -56,10 +78,46 @@ struct exynos_tmu_platform_data const exynos4210_default_tmu_data = {
56 }, 78 },
57 .freq_tab_count = 2, 79 .freq_tab_count = 2,
58 .type = SOC_ARCH_EXYNOS4210, 80 .type = SOC_ARCH_EXYNOS4210,
81 .registers = &exynos4210_tmu_registers,
59}; 82};
60#endif 83#endif
61 84
62#if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412) 85#if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412)
86static const struct exynos_tmu_registers exynos5250_tmu_registers = {
87 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
88 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
89 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
90 .triminfo_ctrl = EXYNOS_TMU_TRIMINFO_CON,
91 .triminfo_reload_shift = EXYNOS_TRIMINFO_RELOAD_SHIFT,
92 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
93 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
94 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
95 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
96 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
97 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
98 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
99 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
100 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
101 .tmu_status = EXYNOS_TMU_REG_STATUS,
102 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
103 .threshold_th0 = EXYNOS_THD_TEMP_RISE,
104 .threshold_th1 = EXYNOS_THD_TEMP_FALL,
105 .tmu_inten = EXYNOS_TMU_REG_INTEN,
106 .inten_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
107 .inten_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
108 .inten_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
109 .inten_fall_shift = EXYNOS_TMU_FALL_INT_SHIFT,
110 .inten_rise0_shift = EXYNOS_TMU_INTEN_RISE0_SHIFT,
111 .inten_rise1_shift = EXYNOS_TMU_INTEN_RISE1_SHIFT,
112 .inten_rise2_shift = EXYNOS_TMU_INTEN_RISE2_SHIFT,
113 .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT,
114 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
115 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
116 .emul_con = EXYNOS_EMUL_CON,
117 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
118 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
119 .emul_time_mask = EXYNOS_EMUL_TIME_MASK,
120};
63struct exynos_tmu_platform_data const exynos5250_default_tmu_data = { 121struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
64 .threshold_falling = 10, 122 .threshold_falling = 10,
65 .trigger_levels[0] = 85, 123 .trigger_levels[0] = 85,
@@ -93,5 +151,6 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
93 }, 151 },
94 .freq_tab_count = 2, 152 .freq_tab_count = 2,
95 .type = SOC_ARCH_EXYNOS, 153 .type = SOC_ARCH_EXYNOS,
154 .registers = &exynos5250_tmu_registers,
96}; 155};
97#endif 156#endif
diff --git a/drivers/thermal/samsung/exynos_tmu_data.h b/drivers/thermal/samsung/exynos_tmu_data.h
index b7835fee6bef..0e2244fb8bd1 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.h
+++ b/drivers/thermal/samsung/exynos_tmu_data.h
@@ -23,6 +23,74 @@
23#ifndef _EXYNOS_TMU_DATA_H 23#ifndef _EXYNOS_TMU_DATA_H
24#define _EXYNOS_TMU_DATA_H 24#define _EXYNOS_TMU_DATA_H
25 25
26/* Exynos generic registers */
27#define EXYNOS_TMU_REG_TRIMINFO 0x0
28#define EXYNOS_TMU_REG_CONTROL 0x20
29#define EXYNOS_TMU_REG_STATUS 0x28
30#define EXYNOS_TMU_REG_CURRENT_TEMP 0x40
31#define EXYNOS_TMU_REG_INTEN 0x70
32#define EXYNOS_TMU_REG_INTSTAT 0x74
33#define EXYNOS_TMU_REG_INTCLEAR 0x78
34
35#define EXYNOS_TMU_TEMP_MASK 0xff
36#define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24
37#define EXYNOS_TMU_REF_VOLTAGE_MASK 0x1f
38#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf
39#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8
40#define EXYNOS_TMU_CORE_EN_SHIFT 0
41
42/* Exynos4210 specific registers */
43#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44
44#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50
45#define EXYNOS4210_TMU_REG_TRIG_LEVEL1 0x54
46#define EXYNOS4210_TMU_REG_TRIG_LEVEL2 0x58
47#define EXYNOS4210_TMU_REG_TRIG_LEVEL3 0x5C
48#define EXYNOS4210_TMU_REG_PAST_TEMP0 0x60
49#define EXYNOS4210_TMU_REG_PAST_TEMP1 0x64
50#define EXYNOS4210_TMU_REG_PAST_TEMP2 0x68
51#define EXYNOS4210_TMU_REG_PAST_TEMP3 0x6C
52
53#define EXYNOS4210_TMU_TRIG_LEVEL0_MASK 0x1
54#define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10
55#define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100
56#define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000
57#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x1111
58#define EXYNOS4210_TMU_INTCLEAR_VAL 0x1111
59
60/* Exynos5250 and Exynos4412 specific registers */
61#define EXYNOS_TMU_TRIMINFO_CON 0x14
62#define EXYNOS_THD_TEMP_RISE 0x50
63#define EXYNOS_THD_TEMP_FALL 0x54
64#define EXYNOS_EMUL_CON 0x80
65
66#define EXYNOS_TRIMINFO_RELOAD_SHIFT 1
67#define EXYNOS_TRIMINFO_25_SHIFT 0
68#define EXYNOS_TRIMINFO_85_SHIFT 8
69#define EXYNOS_TMU_RISE_INT_MASK 0x111
70#define EXYNOS_TMU_RISE_INT_SHIFT 0
71#define EXYNOS_TMU_FALL_INT_MASK 0x111
72#define EXYNOS_TMU_FALL_INT_SHIFT 12
73#define EXYNOS_TMU_CLEAR_RISE_INT 0x111
74#define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12)
75#define EXYNOS_TMU_TRIP_MODE_SHIFT 13
76#define EXYNOS_TMU_TRIP_MODE_MASK 0x7
77#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12
78
79#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0
80#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4
81#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8
82#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12
83#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16
84#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20
85#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24
86
87#define EXYNOS_EMUL_TIME 0x57F0
88#define EXYNOS_EMUL_TIME_MASK 0xffff
89#define EXYNOS_EMUL_TIME_SHIFT 16
90#define EXYNOS_EMUL_DATA_SHIFT 8
91#define EXYNOS_EMUL_DATA_MASK 0xFF
92#define EXYNOS_EMUL_ENABLE 0x1
93
26#if defined(CONFIG_CPU_EXYNOS4210) 94#if defined(CONFIG_CPU_EXYNOS4210)
27extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data; 95extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
28#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data) 96#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)