diff options
author | Amit Daniel Kachhap <amit.daniel@samsung.com> | 2013-06-24 06:50:29 -0400 |
---|---|---|
committer | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-08-13 09:52:00 -0400 |
commit | d0a0ce3e77c795258d47f9163e92d5031d0c5221 (patch) | |
tree | 415a737777e8e99850f8f683200aa340d10ddfd8 /drivers/thermal/samsung | |
parent | e6b7991ed50fea9bf8b36e8a4794ee36d35e1651 (diff) |
thermal: exynos: Add missing definations and code cleanup
This patch adds some extra register bitfield definations and cleans
up the code to prepare for moving register macros and definations inside
the TMU data section. In this code cleanup the TMU enable bit is correctly used
as bit0 and bit1 is taken care which is reserve bit.
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Acked-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Diffstat (limited to 'drivers/thermal/samsung')
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 5df04a1294ec..fa33a485ee5b 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -43,9 +43,12 @@ | |||
43 | 43 | ||
44 | #define EXYNOS_TMU_TRIM_TEMP_MASK 0xff | 44 | #define EXYNOS_TMU_TRIM_TEMP_MASK 0xff |
45 | #define EXYNOS_TMU_GAIN_SHIFT 8 | 45 | #define EXYNOS_TMU_GAIN_SHIFT 8 |
46 | #define EXYNOS_TMU_GAIN_MASK 0xf | ||
46 | #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 | 47 | #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 |
47 | #define EXYNOS_TMU_CORE_ON 3 | 48 | #define EXYNOS_TMU_REF_VOLTAGE_MASK 0x1f |
48 | #define EXYNOS_TMU_CORE_OFF 2 | 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 | ||
49 | #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 | 52 | #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 |
50 | 53 | ||
51 | /* Exynos4210 specific registers */ | 54 | /* Exynos4210 specific registers */ |
@@ -63,6 +66,7 @@ | |||
63 | #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10 | 66 | #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10 |
64 | #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100 | 67 | #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100 |
65 | #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000 | 68 | #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000 |
69 | #define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x1111 | ||
66 | #define EXYNOS4210_TMU_INTCLEAR_VAL 0x1111 | 70 | #define EXYNOS4210_TMU_INTCLEAR_VAL 0x1111 |
67 | 71 | ||
68 | /* Exynos5250 and Exynos4412 specific registers */ | 72 | /* Exynos5250 and Exynos4412 specific registers */ |
@@ -72,17 +76,30 @@ | |||
72 | #define EXYNOS_EMUL_CON 0x80 | 76 | #define EXYNOS_EMUL_CON 0x80 |
73 | 77 | ||
74 | #define EXYNOS_TRIMINFO_RELOAD 0x1 | 78 | #define EXYNOS_TRIMINFO_RELOAD 0x1 |
79 | #define EXYNOS_TRIMINFO_SHIFT 0x0 | ||
80 | #define EXYNOS_TMU_RISE_INT_MASK 0x111 | ||
81 | #define EXYNOS_TMU_RISE_INT_SHIFT 0 | ||
82 | #define EXYNOS_TMU_FALL_INT_MASK 0x111 | ||
83 | #define EXYNOS_TMU_FALL_INT_SHIFT 12 | ||
75 | #define EXYNOS_TMU_CLEAR_RISE_INT 0x111 | 84 | #define EXYNOS_TMU_CLEAR_RISE_INT 0x111 |
76 | #define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) | 85 | #define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) |
77 | #define EXYNOS_MUX_ADDR_VALUE 6 | ||
78 | #define EXYNOS_MUX_ADDR_SHIFT 20 | ||
79 | #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 | 86 | #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 |
87 | #define EXYNOS_TMU_TRIP_MODE_MASK 0x7 | ||
88 | |||
89 | #define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 | ||
90 | #define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 | ||
91 | #define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 | ||
92 | #define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 | ||
93 | #define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 | ||
94 | #define EXYNOS_TMU_INTEN_FALL1_SHIFT 20 | ||
95 | #define EXYNOS_TMU_INTEN_FALL2_SHIFT 24 | ||
80 | 96 | ||
81 | #define EFUSE_MIN_VALUE 40 | 97 | #define EFUSE_MIN_VALUE 40 |
82 | #define EFUSE_MAX_VALUE 100 | 98 | #define EFUSE_MAX_VALUE 100 |
83 | 99 | ||
84 | #ifdef CONFIG_THERMAL_EMULATION | 100 | #ifdef CONFIG_THERMAL_EMULATION |
85 | #define EXYNOS_EMUL_TIME 0x57F0 | 101 | #define EXYNOS_EMUL_TIME 0x57F0 |
102 | #define EXYNOS_EMUL_TIME_MASK 0xffff | ||
86 | #define EXYNOS_EMUL_TIME_SHIFT 16 | 103 | #define EXYNOS_EMUL_TIME_SHIFT 16 |
87 | #define EXYNOS_EMUL_DATA_SHIFT 8 | 104 | #define EXYNOS_EMUL_DATA_SHIFT 8 |
88 | #define EXYNOS_EMUL_DATA_MASK 0xFF | 105 | #define EXYNOS_EMUL_DATA_MASK 0xFF |
@@ -261,24 +278,37 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) | |||
261 | mutex_lock(&data->lock); | 278 | mutex_lock(&data->lock); |
262 | clk_enable(data->clk); | 279 | clk_enable(data->clk); |
263 | 280 | ||
264 | con = pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT | | 281 | con = readl(data->base + EXYNOS_TMU_REG_CONTROL); |
265 | pdata->gain << EXYNOS_TMU_GAIN_SHIFT; | ||
266 | 282 | ||
267 | if (data->soc == SOC_ARCH_EXYNOS) { | 283 | if (pdata->reference_voltage) { |
268 | con |= pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT; | 284 | con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << |
269 | con |= (EXYNOS_MUX_ADDR_VALUE << EXYNOS_MUX_ADDR_SHIFT); | 285 | EXYNOS_TMU_REF_VOLTAGE_SHIFT); |
286 | con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT; | ||
287 | } | ||
288 | |||
289 | if (pdata->gain) { | ||
290 | con &= ~(EXYNOS_TMU_GAIN_MASK << EXYNOS_TMU_GAIN_SHIFT); | ||
291 | con |= (pdata->gain << EXYNOS_TMU_GAIN_SHIFT); | ||
292 | } | ||
293 | |||
294 | if (pdata->noise_cancel_mode) { | ||
295 | con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << | ||
296 | EXYNOS_TMU_TRIP_MODE_SHIFT); | ||
297 | con |= (pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT); | ||
270 | } | 298 | } |
271 | 299 | ||
272 | if (on) { | 300 | if (on) { |
273 | con |= EXYNOS_TMU_CORE_ON; | 301 | con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); |
274 | interrupt_en = pdata->trigger_level3_en << 12 | | 302 | interrupt_en = |
275 | pdata->trigger_level2_en << 8 | | 303 | pdata->trigger_level3_en << EXYNOS_TMU_INTEN_RISE3_SHIFT | |
276 | pdata->trigger_level1_en << 4 | | 304 | pdata->trigger_level2_en << EXYNOS_TMU_INTEN_RISE2_SHIFT | |
277 | pdata->trigger_level0_en; | 305 | pdata->trigger_level1_en << EXYNOS_TMU_INTEN_RISE1_SHIFT | |
306 | pdata->trigger_level0_en << EXYNOS_TMU_INTEN_RISE0_SHIFT; | ||
278 | if (pdata->threshold_falling) | 307 | if (pdata->threshold_falling) |
279 | interrupt_en |= interrupt_en << 16; | 308 | interrupt_en |= |
309 | interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; | ||
280 | } else { | 310 | } else { |
281 | con |= EXYNOS_TMU_CORE_OFF; | 311 | con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT); |
282 | interrupt_en = 0; /* Disable all interrupts */ | 312 | interrupt_en = 0; /* Disable all interrupts */ |
283 | } | 313 | } |
284 | writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN); | 314 | writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN); |