aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2014-07-31 13:11:04 -0400
committerEduardo Valentin <edubezval@gmail.com>2014-11-02 22:02:48 -0500
commitac951af51f417f71bb6830a5d8018755f55715f4 (patch)
tree9c46d5b6f027e68c9286047d1c721e334d00e576 /drivers/thermal
parentddb31d43cb20222f929b0d242bdb516de51b6c23 (diff)
thermal: exynos: cache non_hw_trigger_levels in pdata
Cache number of non-hardware trigger levels in a new pdata field (non_hw_trigger_levels) and convert code in exynos_tmu_initialize() accordingly. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Tested-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c16
-rw-r--r--drivers/thermal/samsung/exynos_tmu.h2
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.c6
3 files changed, 11 insertions, 13 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index aa4d4fd2b3f9..6bc8a2019613 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -129,7 +129,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
129 const struct exynos_tmu_registers *reg = pdata->registers; 129 const struct exynos_tmu_registers *reg = pdata->registers;
130 unsigned int status, trim_info = 0, con; 130 unsigned int status, trim_info = 0, con;
131 unsigned int rising_threshold = 0, falling_threshold = 0; 131 unsigned int rising_threshold = 0, falling_threshold = 0;
132 int ret = 0, threshold_code, i, trigger_levs = 0; 132 int ret = 0, threshold_code, i;
133 133
134 mutex_lock(&data->lock); 134 mutex_lock(&data->lock);
135 clk_enable(data->clk); 135 clk_enable(data->clk);
@@ -187,15 +187,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
187 (pdata->efuse_value >> reg->triminfo_85_shift) & 187 (pdata->efuse_value >> reg->triminfo_85_shift) &
188 EXYNOS_TMU_TEMP_MASK; 188 EXYNOS_TMU_TEMP_MASK;
189 189
190 for (i = 0; i < pdata->max_trigger_level; i++) {
191 if (!pdata->trigger_levels[i])
192 continue;
193
194 /* Count trigger levels except the HW trip*/
195 if (!(pdata->trigger_type[i] == HW_TRIP))
196 trigger_levs++;
197 }
198
199 rising_threshold = readl(data->base + reg->threshold_th0); 190 rising_threshold = readl(data->base + reg->threshold_th0);
200 191
201 if (data->soc == SOC_ARCH_EXYNOS4210) { 192 if (data->soc == SOC_ARCH_EXYNOS4210) {
@@ -203,15 +194,14 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
203 threshold_code = temp_to_code(data, pdata->threshold); 194 threshold_code = temp_to_code(data, pdata->threshold);
204 writeb(threshold_code, 195 writeb(threshold_code,
205 data->base + reg->threshold_temp); 196 data->base + reg->threshold_temp);
206 for (i = 0; i < trigger_levs; i++) 197 for (i = 0; i < pdata->non_hw_trigger_levels; i++)
207 writeb(pdata->trigger_levels[i], data->base + 198 writeb(pdata->trigger_levels[i], data->base +
208 reg->threshold_th0 + i * sizeof(reg->threshold_th0)); 199 reg->threshold_th0 + i * sizeof(reg->threshold_th0));
209 200
210 writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear); 201 writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear);
211 } else { 202 } else {
212 /* Write temperature code for rising and falling threshold */ 203 /* Write temperature code for rising and falling threshold */
213 for (i = 0; 204 for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
214 i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
215 threshold_code = temp_to_code(data, 205 threshold_code = temp_to_code(data,
216 pdata->trigger_levels[i]); 206 pdata->trigger_levels[i]);
217 rising_threshold &= ~(0xff << 8 * i); 207 rising_threshold &= ~(0xff << 8 * i);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 789a8f70f45c..5514d689624b 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -199,6 +199,7 @@ struct exynos_tmu_registers {
199 * 1 = enable trigger_level[] interrupt, 199 * 1 = enable trigger_level[] interrupt,
200 * 0 = disable trigger_level[] interrupt 200 * 0 = disable trigger_level[] interrupt
201 * @max_trigger_level: max trigger level supported by the TMU 201 * @max_trigger_level: max trigger level supported by the TMU
202 * @non_hw_trigger_levels: number of defined non-hardware trigger levels
202 * @gain: gain of amplifier in the positive-TC generator block 203 * @gain: gain of amplifier in the positive-TC generator block
203 * 0 <= gain <= 15 204 * 0 <= gain <= 15
204 * @reference_voltage: reference voltage of amplifier 205 * @reference_voltage: reference voltage of amplifier
@@ -232,6 +233,7 @@ struct exynos_tmu_platform_data {
232 enum trigger_type trigger_type[MAX_TRIP_COUNT]; 233 enum trigger_type trigger_type[MAX_TRIP_COUNT];
233 bool trigger_enable[MAX_TRIP_COUNT]; 234 bool trigger_enable[MAX_TRIP_COUNT];
234 u8 max_trigger_level; 235 u8 max_trigger_level;
236 u8 non_hw_trigger_levels;
235 u8 gain; 237 u8 gain;
236 u8 reference_voltage; 238 u8 reference_voltage;
237 u8 noise_cancel_mode; 239 u8 noise_cancel_mode;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index 1d05bf8235aa..9c81515e74a9 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -64,6 +64,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
64 .trigger_type[1] = THROTTLE_ACTIVE, 64 .trigger_type[1] = THROTTLE_ACTIVE,
65 .trigger_type[2] = SW_TRIP, 65 .trigger_type[2] = SW_TRIP,
66 .max_trigger_level = 4, 66 .max_trigger_level = 4,
67 .non_hw_trigger_levels = 3,
67 .gain = 15, 68 .gain = 15,
68 .reference_voltage = 7, 69 .reference_voltage = 7,
69 .cal_type = TYPE_ONE_POINT_TRIMMING, 70 .cal_type = TYPE_ONE_POINT_TRIMMING,
@@ -140,6 +141,7 @@ static const struct exynos_tmu_registers exynos3250_tmu_registers = {
140 .trigger_type[2] = SW_TRIP, \ 141 .trigger_type[2] = SW_TRIP, \
141 .trigger_type[3] = HW_TRIP, \ 142 .trigger_type[3] = HW_TRIP, \
142 .max_trigger_level = 4, \ 143 .max_trigger_level = 4, \
144 .non_hw_trigger_levels = 3, \
143 .gain = 8, \ 145 .gain = 8, \
144 .reference_voltage = 16, \ 146 .reference_voltage = 16, \
145 .noise_cancel_mode = 4, \ 147 .noise_cancel_mode = 4, \
@@ -230,6 +232,7 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = {
230 .trigger_type[2] = SW_TRIP, \ 232 .trigger_type[2] = SW_TRIP, \
231 .trigger_type[3] = HW_TRIP, \ 233 .trigger_type[3] = HW_TRIP, \
232 .max_trigger_level = 4, \ 234 .max_trigger_level = 4, \
235 .non_hw_trigger_levels = 3, \
233 .gain = 8, \ 236 .gain = 8, \
234 .reference_voltage = 16, \ 237 .reference_voltage = 16, \
235 .noise_cancel_mode = 4, \ 238 .noise_cancel_mode = 4, \
@@ -331,6 +334,7 @@ static const struct exynos_tmu_registers exynos5260_tmu_registers = {
331 .trigger_type[2] = SW_TRIP, \ 334 .trigger_type[2] = SW_TRIP, \
332 .trigger_type[3] = HW_TRIP, \ 335 .trigger_type[3] = HW_TRIP, \
333 .max_trigger_level = 4, \ 336 .max_trigger_level = 4, \
337 .non_hw_trigger_levels = 3, \
334 .gain = 8, \ 338 .gain = 8, \
335 .reference_voltage = 16, \ 339 .reference_voltage = 16, \
336 .noise_cancel_mode = 4, \ 340 .noise_cancel_mode = 4, \
@@ -422,6 +426,7 @@ static const struct exynos_tmu_registers exynos5420_tmu_registers = {
422 .trigger_type[2] = SW_TRIP, \ 426 .trigger_type[2] = SW_TRIP, \
423 .trigger_type[3] = HW_TRIP, \ 427 .trigger_type[3] = HW_TRIP, \
424 .max_trigger_level = 4, \ 428 .max_trigger_level = 4, \
429 .non_hw_trigger_levels = 3, \
425 .gain = 8, \ 430 .gain = 8, \
426 .reference_voltage = 16, \ 431 .reference_voltage = 16, \
427 .noise_cancel_mode = 4, \ 432 .noise_cancel_mode = 4, \
@@ -514,6 +519,7 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
514 .trigger_type[0] = SW_TRIP, \ 519 .trigger_type[0] = SW_TRIP, \
515 .trigger_type[4] = HW_TRIP, \ 520 .trigger_type[4] = HW_TRIP, \
516 .max_trigger_level = 5, \ 521 .max_trigger_level = 5, \
522 .non_hw_trigger_levels = 1, \
517 .gain = 5, \ 523 .gain = 5, \
518 .reference_voltage = 16, \ 524 .reference_voltage = 16, \
519 .noise_cancel_mode = 4, \ 525 .noise_cancel_mode = 4, \