b/drivers/thermal/uniphier_thermal.c
@@ -94,16 +94,16 @@ struct uniphier_tm_soc_data {
struct uniphier_tm_dev {
struct regmap *regmap;
bool alert_en[ALERT_CH_NUM];
- u32 tmod_calib0;
- u32 tmod_calib1;
struct thermal_zone_device *tz_dev;
const struct uniphier_tm_soc_data *data;
};
-static int uniphier_tm_initialize_sensor(struct uniphier_tm_dev *tdev)
+static int uniphier_tm_initialize_sensor(struct uniphier_tm_dev *tdev,
+ struct device *dev)
{
struct regmap *map = tdev->regmap;
u32 val;
+ u32 tmod_val[2];
int ret;
/* stop PVT */
@@ -123,10 +123,22 @@ static int uniphier_tm_initialize_sensor(struct
uniphier_tm_dev *tdev)
ret = regmap_read(map, tdev->data->map_base + TMODCOEF, &val);
if (ret)
return ret;
- if (!val)
+ if (!val) {
+ /*
+ * No preset value found in the register.
+ * Look for the fall-back values in DT.
+ */
+ ret = of_property_read_u32_array(dev->of_node,
+ "socionext,tmod-calibration",
+ tmod_val,
ARRAY_SIZE(tmod_val));
+ if (ret) {
+ dev_err(dev, "neither register nor DT has
calibrated values.\n");
+ return ret;
+ }
regmap_write(map, tdev->data->tmod_setup_addr,
- TMODSETUP0_EN | TMODSETUP0_VAL(tdev->tmod_calib0) |
- TMODSETUP1_EN | TMODSETUP1_VAL(tdev->tmod_calib1));
+ TMODSETUP0_EN | TMODSETUP0_VAL(tmod_val[0]) |
+ TMODSETUP1_EN | TMODSETUP1_VAL(tmod_val[1]));
+ }