h3-dth
This commit is contained in:
parent
41260ac309
commit
55d16b3d26
@ -0,0 +1,65 @@
|
||||
diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c
|
||||
--- a/drivers/thermal/sun8i_thermal.c
|
||||
+++ b/drivers/thermal/sun8i_thermal.c
|
||||
+++ sun8i_thermal.c.new 2023-04-15 13:35:22.362606946 +0200
|
||||
@@ -81,7 +81,8 @@
|
||||
};
|
||||
|
||||
struct ths_device {
|
||||
- const struct ths_thermal_chip *chip;
|
||||
+// const struct ths_thermal_chip *chip;
|
||||
+ struct ths_thermal_chip *chip;
|
||||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
struct reset_control *reset;
|
||||
@@ -229,6 +230,32 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int sun8i_h3only_ths_calibrate(struct ths_device *tmdev,
|
||||
+ u16 *caldata, int callen)
|
||||
+{
|
||||
+ // 12.4.2023 radoslavv: meaningless code for H3 chip in sun8i_h3_ths_calibrate()
|
||||
+ // 1) no need to iterate 1 sensor on h3 chip (however still another family chips needs this) => separate function for h3 chip only
|
||||
+ // 2) register SUN8I_THS_TEMP_CALIB is rather to be read, than trying to "FIX" factory written value with regmap_update_bits
|
||||
+ // 3) we need to read it to update .offset value => main reason for change
|
||||
+ // 4) per each chip could be value slightly different, can't be predefined const in code
|
||||
+
|
||||
+ int val = 0;
|
||||
+
|
||||
+ dev_warn(tmdev->dev, "DEBUG: h3 caldata=0x%04x=%u, callen=%i\n", (*caldata), (*caldata), callen );
|
||||
+
|
||||
+ if (callen != 4)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ regmap_read(tmdev->regmap, SUN8I_THS_TEMP_CALIB, &val);
|
||||
+ val &= 0xFFF; //only 12bits to use
|
||||
+ caldata[0] = val;
|
||||
+
|
||||
+ tmdev->chip->scale = 10000/14.882; //according datasheet (= 672)
|
||||
+ tmdev->chip->offset = val * tmdev->chip->scale / 10;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int sun50i_h6_ths_calibrate(struct ths_device *tmdev,
|
||||
u16 *caldata, int callen)
|
||||
{
|
||||
@@ -751,14 +778,15 @@
|
||||
.calc_temp = sun8i_ths_calc_temp,
|
||||
};
|
||||
|
||||
-static const struct ths_thermal_chip sun8i_h3_ths = {
|
||||
+//static const struct ths_thermal_chip sun8i_h3_ths = {
|
||||
+static struct ths_thermal_chip sun8i_h3_ths = {
|
||||
.sensor_num = 1,
|
||||
.scale = 1211,
|
||||
.offset = 217000,
|
||||
.has_mod_clk = true,
|
||||
.has_bus_clk_reset = true,
|
||||
.temp_data_base = SUN8I_THS_TEMP_DATA,
|
||||
- .calibrate = sun8i_h3_ths_calibrate,
|
||||
+ .calibrate = sun8i_h3only_ths_calibrate,
|
||||
.init = sun8i_h3_thermal_init,
|
||||
.irq_ack = sun8i_h3_irq_ack,
|
||||
.calc_temp = sun8i_ths_calc_temp,
|
||||
Loading…
Reference in New Issue
Block a user