This patch adds the support for Loongson-2 thermal sensor controller,
which can support maximum 4 sensors.
It's based on thermal of framework:
- Trip points defined in device tree.
- Cpufreq as cooling device registered in Loongson-2 cpufreq driver.
- Pwm fan as cooling device registered in hwmon pwm-fan driver.
Signed-off-by: zhanghongchen <zhanghongchen-cXZgJK919ebM1kAEIRd3EQ@xxxxxxxxxxxxxxxx>
Signed-off-by: Yinbo Zhu <zhuyinbo-cXZgJK919ebM1kAEIRd3EQ@xxxxxxxxxxxxxxxx>
---
+static int loongson2_thermal_set(struct loongson2_thermal_data *data,
+ int low, int high, bool enable)
+{
+ u64 reg_ctrl = 0;
+ int reg_off = data->id * 2;
+
+ if (low > high)
+ return -EINVAL;
+
+ low = min(low, -100);
+ high = max(high, 155);
+
+ low += 100;
+ high += 100;
+
+ reg_ctrl |= low;
+ reg_ctrl |= enable ? 0x100 : 0;
+ writew(reg_ctrl, data->regs + LOONGSON2_TSENSOR_CTRL_LO + reg_off);
+
+ reg_ctrl = 0;
+ reg_ctrl |= high;
+ reg_ctrl |= enable ? 0x100 : 0;
+ writew(reg_ctrl, data->regs + LOONGSON2_TSENSOR_CTRL_HI + reg_off);
+
+ return 0;
+}