提交 fe87789c 编写于 作者: B Bartlomiej Zolnierkiewicz 提交者: Eduardo Valentin

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: NBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: NKyungmin Park <kyungmin.park@samsung.com>
Tested-by: NLukasz Majewski <l.majewski@samsung.com>
Signed-off-by: NEduardo Valentin <edubezval@gmail.com>
上级 8328a4b1
...@@ -158,6 +158,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) ...@@ -158,6 +158,25 @@ static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
EXYNOS_TMU_TEMP_MASK; EXYNOS_TMU_TEMP_MASK;
} }
static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
{
struct exynos_tmu_platform_data *pdata = data->pdata;
int i;
for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
u8 temp = pdata->trigger_levels[i];
if (falling)
temp -= pdata->threshold_falling;
else
threshold &= ~(0xff << 8 * i);
threshold |= temp_to_code(data, temp) << 8 * i;
}
return threshold;
}
static int exynos_tmu_initialize(struct platform_device *pdev) static int exynos_tmu_initialize(struct platform_device *pdev)
{ {
struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_data *data = platform_get_drvdata(pdev);
...@@ -221,8 +240,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ...@@ -221,8 +240,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
} }
sanitize_temp_error(data, trim_info); sanitize_temp_error(data, trim_info);
rising_threshold = readl(data->base + reg->threshold_th0);
if (data->soc == SOC_ARCH_EXYNOS4210) { if (data->soc == SOC_ARCH_EXYNOS4210) {
/* Write temperature code for threshold */ /* Write temperature code for threshold */
threshold_code = temp_to_code(data, pdata->threshold); threshold_code = temp_to_code(data, pdata->threshold);
...@@ -235,18 +252,10 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ...@@ -235,18 +252,10 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
exynos_tmu_clear_irqs(data); exynos_tmu_clear_irqs(data);
} else { } else {
/* Write temperature code for rising and falling threshold */ /* Write temperature code for rising and falling threshold */
for (i = 0; i < pdata->non_hw_trigger_levels; i++) { rising_threshold = readl(data->base + reg->threshold_th0);
threshold_code = temp_to_code(data, rising_threshold = get_th_reg(data, rising_threshold, false);
pdata->trigger_levels[i]); if (data->soc != SOC_ARCH_EXYNOS5440)
rising_threshold &= ~(0xff << 8 * i); falling_threshold = get_th_reg(data, 0, true);
rising_threshold |= threshold_code << 8 * i;
if (data->soc != SOC_ARCH_EXYNOS5440) {
threshold_code = temp_to_code(data,
pdata->trigger_levels[i] -
pdata->threshold_falling);
falling_threshold |= threshold_code << 8 * i;
}
}
writel(rising_threshold, writel(rising_threshold,
data->base + reg->threshold_th0); data->base + reg->threshold_th0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册