aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2014-10-03 12:17:17 -0400
committerEduardo Valentin <edubezval@gmail.com>2014-11-02 22:02:49 -0500
commitb835ced1fd05c43bd4a706050963678bc6e95bc7 (patch)
tree1933e4f19ff68cea859b097193a69c02607f00f0 /drivers/thermal
parentc2aad93c7edd5e1bc26cc1d80c1c00a954f01946 (diff)
thermal: exynos: fix IRQ clearing on TMU initialization
* Factor out code for clearing raised IRQs from exynos_tmu_work() to exynos_tmu_clear_irqs(). * Add a comment about documentation bugs to exynos_tmu_clear_irqs(). [ The documentation for Exynos3250, Exynos4412, Exynos5250 and Exynos5260 incorrectly states that INTCLEAR register has a different placing of bits responsible for FALL IRQs than INTSTAT register. Exynos5420 and Exynos5440 documentation is correct (Exynos4210 doesn't support FALL IRQs at all). ] * Use exynos_tmu_clear_irqs() in exynos_tmu_initialize() instead of open-coded code trying to clear IRQs according to predefined masks. After this change exynos_tmu_initialize() just clears IRQs that are raised like it is already done in exynos_tmu_work(). As a nice side-effect the code now uses the correct offset (16 instead of 12) for bits responsible for clearing FALL IRQs in INTCLEAR register on Exynos3250, Exynos4412 and Exynos5250. * Remove no longer needed intclr_rise_[mask,shift] and intclr_fall_[mask,shift] fields from struct exynos_tmu_registers. * Remove no longer needed defines. This patch has been tested on Exynos4412 and Exynos5420 SoCs. Cc: Amit Daniel Kachhap <amit.daniel@samsung.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c29
-rw-r--r--drivers/thermal/samsung/exynos_tmu.h8
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.c21
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.h15
4 files changed, 21 insertions, 52 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 092ab69d6282..49c09243fd38 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -122,6 +122,23 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
122 return temp; 122 return temp;
123} 123}
124 124
125static void exynos_tmu_clear_irqs(struct exynos_tmu_data *data)
126{
127 const struct exynos_tmu_registers *reg = data->pdata->registers;
128 unsigned int val_irq;
129
130 val_irq = readl(data->base + reg->tmu_intstat);
131 /*
132 * Clear the interrupts. Please note that the documentation for
133 * Exynos3250, Exynos4412, Exynos5250 and Exynos5260 incorrectly
134 * states that INTCLEAR register has a different placing of bits
135 * responsible for FALL IRQs than INTSTAT register. Exynos5420
136 * and Exynos5440 documentation is correct (Exynos4210 doesn't
137 * support FALL IRQs at all).
138 */
139 writel(val_irq, data->base + reg->tmu_intclear);
140}
141
125static int exynos_tmu_initialize(struct platform_device *pdev) 142static int exynos_tmu_initialize(struct platform_device *pdev)
126{ 143{
127 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 144 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
@@ -207,7 +224,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
207 writeb(pdata->trigger_levels[i], data->base + 224 writeb(pdata->trigger_levels[i], data->base +
208 reg->threshold_th0 + i * sizeof(reg->threshold_th0)); 225 reg->threshold_th0 + i * sizeof(reg->threshold_th0));
209 226
210 writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear); 227 exynos_tmu_clear_irqs(data);
211 } else { 228 } else {
212 /* Write temperature code for rising and falling threshold */ 229 /* Write temperature code for rising and falling threshold */
213 for (i = 0; i < pdata->non_hw_trigger_levels; i++) { 230 for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
@@ -228,9 +245,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
228 writel(falling_threshold, 245 writel(falling_threshold,
229 data->base + reg->threshold_th1); 246 data->base + reg->threshold_th1);
230 247
231 writel((reg->intclr_rise_mask << reg->intclr_rise_shift) | 248 exynos_tmu_clear_irqs(data);
232 (reg->intclr_fall_mask << reg->intclr_fall_shift),
233 data->base + reg->tmu_intclear);
234 249
235 /* if last threshold limit is also present */ 250 /* if last threshold limit is also present */
236 i = pdata->max_trigger_level - 1; 251 i = pdata->max_trigger_level - 1;
@@ -396,7 +411,7 @@ static void exynos_tmu_work(struct work_struct *work)
396 struct exynos_tmu_data, irq_work); 411 struct exynos_tmu_data, irq_work);
397 struct exynos_tmu_platform_data *pdata = data->pdata; 412 struct exynos_tmu_platform_data *pdata = data->pdata;
398 const struct exynos_tmu_registers *reg = pdata->registers; 413 const struct exynos_tmu_registers *reg = pdata->registers;
399 unsigned int val_irq, val_type; 414 unsigned int val_type;
400 415
401 if (!IS_ERR(data->clk_sec)) 416 if (!IS_ERR(data->clk_sec))
402 clk_enable(data->clk_sec); 417 clk_enable(data->clk_sec);
@@ -414,9 +429,7 @@ static void exynos_tmu_work(struct work_struct *work)
414 clk_enable(data->clk); 429 clk_enable(data->clk);
415 430
416 /* TODO: take action based on particular interrupt */ 431 /* TODO: take action based on particular interrupt */
417 val_irq = readl(data->base + reg->tmu_intstat); 432 exynos_tmu_clear_irqs(data);
418 /* clear the interrupts */
419 writel(val_irq, data->base + reg->tmu_intclear);
420 433
421 clk_disable(data->clk); 434 clk_disable(data->clk);
422 mutex_unlock(&data->lock); 435 mutex_unlock(&data->lock);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index f67203bfd83c..c58c7663a3fe 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -100,10 +100,6 @@ enum soc_type {
100 * @inten_fall0_shift: shift bits of falling 0 interrupt bits. 100 * @inten_fall0_shift: shift bits of falling 0 interrupt bits.
101 * @tmu_intstat: Register containing the interrupt status values. 101 * @tmu_intstat: Register containing the interrupt status values.
102 * @tmu_intclear: Register for clearing the raised interrupt status. 102 * @tmu_intclear: Register for clearing the raised interrupt status.
103 * @intclr_fall_shift: shift bits for interrupt clear fall 0
104 * @intclr_rise_shift: shift bits of all rising interrupt bits.
105 * @intclr_rise_mask: mask bits of all rising interrupt bits.
106 * @intclr_fall_mask: mask bits of all rising interrupt bits.
107 * @emul_con: TMU emulation controller register. 103 * @emul_con: TMU emulation controller register.
108 * @emul_temp_shift: shift bits of emulation temperature. 104 * @emul_temp_shift: shift bits of emulation temperature.
109 * @emul_time_shift: shift bits of emulation time. 105 * @emul_time_shift: shift bits of emulation time.
@@ -143,10 +139,6 @@ struct exynos_tmu_registers {
143 u32 tmu_intstat; 139 u32 tmu_intstat;
144 140
145 u32 tmu_intclear; 141 u32 tmu_intclear;
146 u32 intclr_fall_shift;
147 u32 intclr_rise_shift;
148 u32 intclr_fall_mask;
149 u32 intclr_rise_mask;
150 142
151 u32 emul_con; 143 u32 emul_con;
152 u32 emul_temp_shift; 144 u32 emul_temp_shift;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index 8bae1704b9bd..2683d2897e90 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -39,7 +39,6 @@ static const struct exynos_tmu_registers exynos4210_tmu_registers = {
39 .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT, 39 .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT,
40 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 40 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
41 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 41 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
42 .intclr_rise_mask = EXYNOS4210_TMU_TRIG_LEVEL_MASK,
43}; 42};
44 43
45struct exynos_tmu_init_data const exynos4210_default_tmu_data = { 44struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
@@ -106,10 +105,6 @@ static const struct exynos_tmu_registers exynos3250_tmu_registers = {
106 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 105 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
107 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 106 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
108 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 107 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
109 .intclr_fall_shift = EXYNOS_TMU_CLEAR_FALL_INT_SHIFT,
110 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
111 .intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
112 .intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
113 .emul_con = EXYNOS_EMUL_CON, 108 .emul_con = EXYNOS_EMUL_CON,
114 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 109 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
115 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 110 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
@@ -193,10 +188,6 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = {
193 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 188 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
194 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 189 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
195 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 190 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
196 .intclr_fall_shift = EXYNOS_TMU_CLEAR_FALL_INT_SHIFT,
197 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
198 .intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
199 .intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
200 .emul_con = EXYNOS_EMUL_CON, 191 .emul_con = EXYNOS_EMUL_CON,
201 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 192 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
202 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 193 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
@@ -289,10 +280,6 @@ static const struct exynos_tmu_registers exynos5260_tmu_registers = {
289 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 280 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
290 .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT, 281 .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT,
291 .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR, 282 .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR,
292 .intclr_fall_shift = EXYNOS5420_TMU_CLEAR_FALL_INT_SHIFT,
293 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
294 .intclr_rise_mask = EXYNOS5260_TMU_RISE_INT_MASK,
295 .intclr_fall_mask = EXYNOS5260_TMU_FALL_INT_MASK,
296 .emul_con = EXYNOS5260_EMUL_CON, 283 .emul_con = EXYNOS5260_EMUL_CON,
297 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 284 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
298 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 285 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
@@ -373,10 +360,6 @@ static const struct exynos_tmu_registers exynos5420_tmu_registers = {
373 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 360 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
374 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 361 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
375 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 362 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
376 .intclr_fall_shift = EXYNOS5420_TMU_CLEAR_FALL_INT_SHIFT,
377 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
378 .intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
379 .intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
380 .emul_con = EXYNOS_EMUL_CON, 363 .emul_con = EXYNOS_EMUL_CON,
381 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 364 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
382 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 365 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
@@ -465,10 +448,6 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
465 .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT, 448 .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT,
466 .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, 449 .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ,
467 .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, 450 .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ,
468 .intclr_fall_shift = EXYNOS5440_TMU_CLEAR_FALL_INT_SHIFT,
469 .intclr_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT,
470 .intclr_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK,
471 .intclr_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
472 .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS, 451 .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS,
473 .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, 452 .emul_con = EXYNOS5440_TMU_S0_7_DEBUG,
474 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 453 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
diff --git a/drivers/thermal/samsung/exynos_tmu_data.h b/drivers/thermal/samsung/exynos_tmu_data.h
index 4b8f33c85b35..65e2ea6a9579 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.h
+++ b/drivers/thermal/samsung/exynos_tmu_data.h
@@ -46,8 +46,6 @@
46#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 46#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44
47#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50 47#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50
48 48
49#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x1111
50
51/* Exynos5250, Exynos4412, Exynos3250 specific registers */ 49/* Exynos5250, Exynos4412, Exynos3250 specific registers */
52#define EXYNOS_TMU_TRIMINFO_CON2 0x14 50#define EXYNOS_TMU_TRIMINFO_CON2 0x14
53#define EXYNOS_THD_TEMP_RISE 0x50 51#define EXYNOS_THD_TEMP_RISE 0x50
@@ -57,12 +55,6 @@
57#define EXYNOS_TRIMINFO_RELOAD_ENABLE 1 55#define EXYNOS_TRIMINFO_RELOAD_ENABLE 1
58#define EXYNOS_TRIMINFO_25_SHIFT 0 56#define EXYNOS_TRIMINFO_25_SHIFT 0
59#define EXYNOS_TRIMINFO_85_SHIFT 8 57#define EXYNOS_TRIMINFO_85_SHIFT 8
60#define EXYNOS_TMU_RISE_INT_MASK 0x111
61#define EXYNOS_TMU_RISE_INT_SHIFT 0
62#define EXYNOS_TMU_FALL_INT_MASK 0x111
63#define EXYNOS_TMU_CLEAR_FALL_INT_SHIFT 12
64#define EXYNOS5420_TMU_CLEAR_FALL_INT_SHIFT 16
65#define EXYNOS5440_TMU_CLEAR_FALL_INT_SHIFT 4
66#define EXYNOS_TMU_TRIP_MODE_SHIFT 13 58#define EXYNOS_TMU_TRIP_MODE_SHIFT 13
67#define EXYNOS_TMU_TRIP_MODE_MASK 0x7 59#define EXYNOS_TMU_TRIP_MODE_MASK 0x7
68#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12 60#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12
@@ -87,10 +79,6 @@
87#define EXYNOS5260_TMU_REG_INTEN 0xC0 79#define EXYNOS5260_TMU_REG_INTEN 0xC0
88#define EXYNOS5260_TMU_REG_INTSTAT 0xC4 80#define EXYNOS5260_TMU_REG_INTSTAT 0xC4
89#define EXYNOS5260_TMU_REG_INTCLEAR 0xC8 81#define EXYNOS5260_TMU_REG_INTCLEAR 0xC8
90#define EXYNOS5260_TMU_CLEAR_RISE_INT 0x1111
91#define EXYNOS5260_TMU_CLEAR_FALL_INT (0x1111 << 16)
92#define EXYNOS5260_TMU_RISE_INT_MASK 0x1111
93#define EXYNOS5260_TMU_FALL_INT_MASK 0x1111
94#define EXYNOS5260_EMUL_CON 0x100 82#define EXYNOS5260_EMUL_CON 0x100
95 83
96/* Exynos4412 specific */ 84/* Exynos4412 specific */
@@ -112,9 +100,6 @@
112#define EXYNOS5440_TMU_IRQ_STATUS 0x000 100#define EXYNOS5440_TMU_IRQ_STATUS 0x000
113#define EXYNOS5440_TMU_PMIN 0x004 101#define EXYNOS5440_TMU_PMIN 0x004
114 102
115#define EXYNOS5440_TMU_RISE_INT_MASK 0xf
116#define EXYNOS5440_TMU_RISE_INT_SHIFT 0
117#define EXYNOS5440_TMU_FALL_INT_MASK 0xf
118#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT 0 103#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT 0
119#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT 1 104#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT 1
120#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT 2 105#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT 2