diff options
author | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | 2014-11-13 10:01:12 -0500 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2014-11-20 09:53:24 -0500 |
commit | fe87789cd437378e7cf72c43b753703b2a835fc3 (patch) | |
tree | 120cc4d98e1f583bdf1277104f11d894f7b04b67 /drivers/thermal | |
parent | 8328a4b1d67fa6a4e0c51c27ddb7cb61b562f33e (diff) |
thermal: exynos: add get_th_reg() helper
Factor out code for preparing threshold register value from
exynos_tmu_initialize() into get_th_reg().
This is a preparation for introducing per-SoC type tmu_initialize
method.
There should be no functional changes caused by this patch.
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>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index b0c07151e2eb..6e82fdd860b0 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -158,6 +158,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) | |||
158 | EXYNOS_TMU_TEMP_MASK; | 158 | EXYNOS_TMU_TEMP_MASK; |
159 | } | 159 | } |
160 | 160 | ||
161 | static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling) | ||
162 | { | ||
163 | struct exynos_tmu_platform_data *pdata = data->pdata; | ||
164 | int i; | ||
165 | |||
166 | for (i = 0; i < pdata->non_hw_trigger_levels; i++) { | ||
167 | u8 temp = pdata->trigger_levels[i]; | ||
168 | |||
169 | if (falling) | ||
170 | temp -= pdata->threshold_falling; | ||
171 | else | ||
172 | threshold &= ~(0xff << 8 * i); | ||
173 | |||
174 | threshold |= temp_to_code(data, temp) << 8 * i; | ||
175 | } | ||
176 | |||
177 | return threshold; | ||
178 | } | ||
179 | |||
161 | static int exynos_tmu_initialize(struct platform_device *pdev) | 180 | static int exynos_tmu_initialize(struct platform_device *pdev) |
162 | { | 181 | { |
163 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); | 182 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
@@ -221,8 +240,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev) | |||
221 | } | 240 | } |
222 | sanitize_temp_error(data, trim_info); | 241 | sanitize_temp_error(data, trim_info); |
223 | 242 | ||
224 | rising_threshold = readl(data->base + reg->threshold_th0); | ||
225 | |||
226 | if (data->soc == SOC_ARCH_EXYNOS4210) { | 243 | if (data->soc == SOC_ARCH_EXYNOS4210) { |
227 | /* Write temperature code for threshold */ | 244 | /* Write temperature code for threshold */ |
228 | threshold_code = temp_to_code(data, pdata->threshold); | 245 | threshold_code = temp_to_code(data, pdata->threshold); |
@@ -235,18 +252,10 @@ static int exynos_tmu_initialize(struct platform_device *pdev) | |||
235 | exynos_tmu_clear_irqs(data); | 252 | exynos_tmu_clear_irqs(data); |
236 | } else { | 253 | } else { |
237 | /* Write temperature code for rising and falling threshold */ | 254 | /* Write temperature code for rising and falling threshold */ |
238 | for (i = 0; i < pdata->non_hw_trigger_levels; i++) { | 255 | rising_threshold = readl(data->base + reg->threshold_th0); |
239 | threshold_code = temp_to_code(data, | 256 | rising_threshold = get_th_reg(data, rising_threshold, false); |
240 | pdata->trigger_levels[i]); | 257 | if (data->soc != SOC_ARCH_EXYNOS5440) |
241 | rising_threshold &= ~(0xff << 8 * i); | 258 | falling_threshold = get_th_reg(data, 0, true); |
242 | rising_threshold |= threshold_code << 8 * i; | ||
243 | if (data->soc != SOC_ARCH_EXYNOS5440) { | ||
244 | threshold_code = temp_to_code(data, | ||
245 | pdata->trigger_levels[i] - | ||
246 | pdata->threshold_falling); | ||
247 | falling_threshold |= threshold_code << 8 * i; | ||
248 | } | ||
249 | } | ||
250 | 259 | ||
251 | writel(rising_threshold, | 260 | writel(rising_threshold, |
252 | data->base + reg->threshold_th0); | 261 | data->base + reg->threshold_th0); |