Commit ac951af5 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Eduardo Valentin

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: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: default avatarAmit Daniel Kachhap <amit.daniel@samsung.com>
Tested-by: default avatarAmit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent ddb31d43
...@@ -129,7 +129,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ...@@ -129,7 +129,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
const struct exynos_tmu_registers *reg = pdata->registers; const struct exynos_tmu_registers *reg = pdata->registers;
unsigned int status, trim_info = 0, con; unsigned int status, trim_info = 0, con;
unsigned int rising_threshold = 0, falling_threshold = 0; unsigned int rising_threshold = 0, falling_threshold = 0;
int ret = 0, threshold_code, i, trigger_levs = 0; int ret = 0, threshold_code, i;
mutex_lock(&data->lock); mutex_lock(&data->lock);
clk_enable(data->clk); clk_enable(data->clk);
...@@ -187,15 +187,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ...@@ -187,15 +187,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
(pdata->efuse_value >> reg->triminfo_85_shift) & (pdata->efuse_value >> reg->triminfo_85_shift) &
EXYNOS_TMU_TEMP_MASK; EXYNOS_TMU_TEMP_MASK;
for (i = 0; i < pdata->max_trigger_level; i++) {
if (!pdata->trigger_levels[i])
continue;
/* Count trigger levels except the HW trip*/
if (!(pdata->trigger_type[i] == HW_TRIP))
trigger_levs++;
}
rising_threshold = readl(data->base + reg->threshold_th0); rising_threshold = readl(data->base + reg->threshold_th0);
if (data->soc == SOC_ARCH_EXYNOS4210) { if (data->soc == SOC_ARCH_EXYNOS4210) {
...@@ -203,15 +194,14 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ...@@ -203,15 +194,14 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
threshold_code = temp_to_code(data, pdata->threshold); threshold_code = temp_to_code(data, pdata->threshold);
writeb(threshold_code, writeb(threshold_code,
data->base + reg->threshold_temp); data->base + reg->threshold_temp);
for (i = 0; i < trigger_levs; i++) for (i = 0; i < pdata->non_hw_trigger_levels; i++)
writeb(pdata->trigger_levels[i], data->base + writeb(pdata->trigger_levels[i], data->base +
reg->threshold_th0 + i * sizeof(reg->threshold_th0)); reg->threshold_th0 + i * sizeof(reg->threshold_th0));
writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear); writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear);
} else { } else {
/* Write temperature code for rising and falling threshold */ /* Write temperature code for rising and falling threshold */
for (i = 0; for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
threshold_code = temp_to_code(data, threshold_code = temp_to_code(data,
pdata->trigger_levels[i]); pdata->trigger_levels[i]);
rising_threshold &= ~(0xff << 8 * i); rising_threshold &= ~(0xff << 8 * i);
......
...@@ -199,6 +199,7 @@ struct exynos_tmu_registers { ...@@ -199,6 +199,7 @@ struct exynos_tmu_registers {
* 1 = enable trigger_level[] interrupt, * 1 = enable trigger_level[] interrupt,
* 0 = disable trigger_level[] interrupt * 0 = disable trigger_level[] interrupt
* @max_trigger_level: max trigger level supported by the TMU * @max_trigger_level: max trigger level supported by the TMU
* @non_hw_trigger_levels: number of defined non-hardware trigger levels
* @gain: gain of amplifier in the positive-TC generator block * @gain: gain of amplifier in the positive-TC generator block
* 0 <= gain <= 15 * 0 <= gain <= 15
* @reference_voltage: reference voltage of amplifier * @reference_voltage: reference voltage of amplifier
...@@ -232,6 +233,7 @@ struct exynos_tmu_platform_data { ...@@ -232,6 +233,7 @@ struct exynos_tmu_platform_data {
enum trigger_type trigger_type[MAX_TRIP_COUNT]; enum trigger_type trigger_type[MAX_TRIP_COUNT];
bool trigger_enable[MAX_TRIP_COUNT]; bool trigger_enable[MAX_TRIP_COUNT];
u8 max_trigger_level; u8 max_trigger_level;
u8 non_hw_trigger_levels;
u8 gain; u8 gain;
u8 reference_voltage; u8 reference_voltage;
u8 noise_cancel_mode; u8 noise_cancel_mode;
......
...@@ -64,6 +64,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = { ...@@ -64,6 +64,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
.trigger_type[1] = THROTTLE_ACTIVE, .trigger_type[1] = THROTTLE_ACTIVE,
.trigger_type[2] = SW_TRIP, .trigger_type[2] = SW_TRIP,
.max_trigger_level = 4, .max_trigger_level = 4,
.non_hw_trigger_levels = 3,
.gain = 15, .gain = 15,
.reference_voltage = 7, .reference_voltage = 7,
.cal_type = TYPE_ONE_POINT_TRIMMING, .cal_type = TYPE_ONE_POINT_TRIMMING,
...@@ -140,6 +141,7 @@ static const struct exynos_tmu_registers exynos3250_tmu_registers = { ...@@ -140,6 +141,7 @@ static const struct exynos_tmu_registers exynos3250_tmu_registers = {
.trigger_type[2] = SW_TRIP, \ .trigger_type[2] = SW_TRIP, \
.trigger_type[3] = HW_TRIP, \ .trigger_type[3] = HW_TRIP, \
.max_trigger_level = 4, \ .max_trigger_level = 4, \
.non_hw_trigger_levels = 3, \
.gain = 8, \ .gain = 8, \
.reference_voltage = 16, \ .reference_voltage = 16, \
.noise_cancel_mode = 4, \ .noise_cancel_mode = 4, \
...@@ -230,6 +232,7 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = { ...@@ -230,6 +232,7 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = {
.trigger_type[2] = SW_TRIP, \ .trigger_type[2] = SW_TRIP, \
.trigger_type[3] = HW_TRIP, \ .trigger_type[3] = HW_TRIP, \
.max_trigger_level = 4, \ .max_trigger_level = 4, \
.non_hw_trigger_levels = 3, \
.gain = 8, \ .gain = 8, \
.reference_voltage = 16, \ .reference_voltage = 16, \
.noise_cancel_mode = 4, \ .noise_cancel_mode = 4, \
...@@ -331,6 +334,7 @@ static const struct exynos_tmu_registers exynos5260_tmu_registers = { ...@@ -331,6 +334,7 @@ static const struct exynos_tmu_registers exynos5260_tmu_registers = {
.trigger_type[2] = SW_TRIP, \ .trigger_type[2] = SW_TRIP, \
.trigger_type[3] = HW_TRIP, \ .trigger_type[3] = HW_TRIP, \
.max_trigger_level = 4, \ .max_trigger_level = 4, \
.non_hw_trigger_levels = 3, \
.gain = 8, \ .gain = 8, \
.reference_voltage = 16, \ .reference_voltage = 16, \
.noise_cancel_mode = 4, \ .noise_cancel_mode = 4, \
...@@ -422,6 +426,7 @@ static const struct exynos_tmu_registers exynos5420_tmu_registers = { ...@@ -422,6 +426,7 @@ static const struct exynos_tmu_registers exynos5420_tmu_registers = {
.trigger_type[2] = SW_TRIP, \ .trigger_type[2] = SW_TRIP, \
.trigger_type[3] = HW_TRIP, \ .trigger_type[3] = HW_TRIP, \
.max_trigger_level = 4, \ .max_trigger_level = 4, \
.non_hw_trigger_levels = 3, \
.gain = 8, \ .gain = 8, \
.reference_voltage = 16, \ .reference_voltage = 16, \
.noise_cancel_mode = 4, \ .noise_cancel_mode = 4, \
...@@ -514,6 +519,7 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = { ...@@ -514,6 +519,7 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
.trigger_type[0] = SW_TRIP, \ .trigger_type[0] = SW_TRIP, \
.trigger_type[4] = HW_TRIP, \ .trigger_type[4] = HW_TRIP, \
.max_trigger_level = 5, \ .max_trigger_level = 5, \
.non_hw_trigger_levels = 1, \
.gain = 5, \ .gain = 5, \
.reference_voltage = 16, \ .reference_voltage = 16, \
.noise_cancel_mode = 4, \ .noise_cancel_mode = 4, \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment