The hardware-tracked trips will set the alarm interrupt value for
registers. Then when the thermal zone has no trips to be set,
That make the thermal trips callback a over range value.
The root cause is the rk_tsadcv2_temp_to_code() function to handle the
invalid temperature range is indeed incorrect, let's fix it on now.
Otherwise, the thermal alarm interrupt will be triggered all the time
on some SoCs.
Fox example:
localhost tmp # grep thermal /proc/interrupts; sleep 5;
grep thermal /proc/interrupts
23: 994830 .. GICv3 129 Level rockchip_thermal
23:
1003423 .. GICv3 129 Level rockchip_thermal
Change-Id: I0ddbd0b2dd9c03e785e588f5f339f1eeed4e1c5c
Reported-by: Rocky Hao <rocky.hao@rock-chips.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: linux-pm@vger.kernel.org
(am from https://patchwork.kernel.org/patch/
9192357/)
int temp)
{
int high, low, mid;
int temp)
{
int high, low, mid;
+ u32 error = table.data_mask;
low = 0;
high = table.length - 1;
mid = (high + low) / 2;
low = 0;
high = table.length - 1;
mid = (high + low) / 2;
+ /* Return mask code data when the temp is over table range */
if (temp < table.id[low].temp || temp > table.id[high].temp)
if (temp < table.id[low].temp || temp > table.id[high].temp)
while (low <= high) {
if (temp == table.id[mid].temp)
while (low <= high) {
if (temp == table.id[mid].temp)
mid = (low + high) / 2;
}
mid = (low + high) / 2;
}
+exit:
+ pr_err("%s: Invalid conversion table: code=%d, temperature=%d\n",
+ __func__, error, temp);
+
+ return error;
}
static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
}
static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code,
- pr_err("Invalid the conversion table\n");
+ pr_err("%s: Invalid the conversion table mode=%d\n",
+ __func__, table.mode);
{
u32 alarm_value, int_en;
{
u32 alarm_value, int_en;
+ /* Make sure the value is valid */
alarm_value = rk_tsadcv2_temp_to_code(table, temp);
alarm_value = rk_tsadcv2_temp_to_code(table, temp);
+ if (alarm_value == table.data_mask)
+ return;
+
writel_relaxed(alarm_value & table.data_mask,
regs + TSADCV2_COMP_INT(chn));
writel_relaxed(alarm_value & table.data_mask,
regs + TSADCV2_COMP_INT(chn));
+ /* Make sure the value is valid */
tshut_value = rk_tsadcv2_temp_to_code(table, temp);
tshut_value = rk_tsadcv2_temp_to_code(table, temp);
+ if (tshut_value == table.data_mask)
+ return;
+
writel_relaxed(tshut_value, regs + TSADCV2_COMP_SHUT(chn));
/* TSHUT will be valid */
writel_relaxed(tshut_value, regs + TSADCV2_COMP_SHUT(chn));
/* TSHUT will be valid */