Message ID | DS7PR19MB8883A75912761EB89C9A1B409DC72@DS7PR19MB8883.namprd19.prod.outlook.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add support for IPQ5018 tsens | expand |
On Fri, Feb 21, 2025 at 10:52:18AM +0400, George Moussalem wrote: > From: Sricharan Ramabadhran <quic_srichara@quicinc.com> > > IPQ5018 has tsens IP V1.0, 4 sensors and 1 interrupt. > The soc does not have a RPM, hence tsens has to be reset and > enabled in the driver init. Adding the driver support for same. > > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Signed-off-by: Sricharan Ramabadhran <quic_srichara@quicinc.com> > Signed-off-by: George Moussalem <george.moussalem@outlook.com> > --- > [v4] Added Dmitry's Reviewed-by tag > Fixed modpost warning: added __init to init_common > > drivers/thermal/qcom/tsens-v1.c | 60 +++++++++++++++++++++++++++++++++ > drivers/thermal/qcom/tsens.c | 3 ++ > drivers/thermal/qcom/tsens.h | 2 +- > 3 files changed, 64 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c > index 1a7874676f68..1f955acbc2cf 100644 > --- a/drivers/thermal/qcom/tsens-v1.c > +++ b/drivers/thermal/qcom/tsens-v1.c > @@ -79,6 +79,18 @@ static struct tsens_features tsens_v1_feat = { > .trip_max_temp = 120000, > }; > > +static struct tsens_features tsens_v1_ipq5018_feat = { > + .ver_major = VER_1_X, > + .crit_int = 0, > + .combo_int = 0, > + .adc = 1, > + .srot_split = 1, > + .max_sensors = 11, > + .trip_min_temp = -40000, > + .trip_max_temp = 120000, > + .ignore_enable = 1, > +}; > + > static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = { > /* ----- SROT ------ */ > /* VERSION */ > @@ -150,6 +162,41 @@ static int __init init_8956(struct tsens_priv *priv) { > return init_common(priv); > } > > +static int __init init_ipq5018(struct tsens_priv *priv) > +{ > + int ret; > + u32 mask; > + > + ret = init_common(priv); > + if (ret < 0) { > + dev_err(priv->dev, "Init common failed %d\n", ret); > + return ret; > + } > + > + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 1); > + if (ret) { > + dev_err(priv->dev, "Reset failed\n"); > + return ret; > + } > + > + mask = GENMASK(priv->num_sensors, 0); > + ret = regmap_field_update_bits(priv->rf[SENSOR_EN], mask, mask); > + if (ret) { > + dev_err(priv->dev, "Sensor Enable failed\n"); > + return ret; > + } > + > + ret = regmap_field_write(priv->rf[TSENS_EN], 1); > + if (ret) { > + dev_err(priv->dev, "Enable failed\n"); > + return ret; > + } > + > + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 0); > + > + return ret; > +} > + > static const struct tsens_ops ops_generic_v1 = { > .init = init_common, > .calibrate = calibrate_v1, > @@ -194,3 +241,16 @@ struct tsens_plat_data data_8976 = { > .feat = &tsens_v1_feat, > .fields = tsens_v1_regfields, > }; > + > +const struct tsens_ops ops_ipq5018 = { > + .init = init_ipq5018, > + .calibrate = tsens_calibrate_common, > + .get_temp = get_temp_tsens_valid, > +}; > + > +struct tsens_plat_data data_ipq5018 = { > + .num_sensors = 5, Commit message suggests that this should be '4'. > + .ops = &ops_ipq5018, > + .feat = &tsens_v1_ipq5018_feat, > + .fields = tsens_v1_regfields, > +};
Good catch, thanks! Will fix and send a v5 after a quick test. Also found that the addresses in the tsens and qfprom nodes in patch 5 need padding.
On Fri, Feb 21, 2025 at 06:13:12PM +0400, George Moussalem wrote: > Good catch, thanks! Will fix and send a v5 after a quick test. > Also found that the addresses in the tsens and qfprom nodes in patch 5 need > padding. Well... DT suggests that there are 5 sensors. So maybe the code is correct, but the commit message isn't.
I've just checked the downstream dts and driver, it contains 5 sensors, but only 4 are used. So I propose we leave the number of sensors to 5 and adjust the commit message. Thoughts? Best regards, George
On Fri, Feb 21, 2025 at 06:41:44PM +0400, George Moussalem wrote: > I've just checked the downstream dts and driver, it contains 5 sensors, > but only 4 are used. So I propose we leave the number of sensors to 5 and > adjust the commit message. Thoughts? SGTM
diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c index 1a7874676f68..1f955acbc2cf 100644 --- a/drivers/thermal/qcom/tsens-v1.c +++ b/drivers/thermal/qcom/tsens-v1.c @@ -79,6 +79,18 @@ static struct tsens_features tsens_v1_feat = { .trip_max_temp = 120000, }; +static struct tsens_features tsens_v1_ipq5018_feat = { + .ver_major = VER_1_X, + .crit_int = 0, + .combo_int = 0, + .adc = 1, + .srot_split = 1, + .max_sensors = 11, + .trip_min_temp = -40000, + .trip_max_temp = 120000, + .ignore_enable = 1, +}; + static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = { /* ----- SROT ------ */ /* VERSION */ @@ -150,6 +162,41 @@ static int __init init_8956(struct tsens_priv *priv) { return init_common(priv); } +static int __init init_ipq5018(struct tsens_priv *priv) +{ + int ret; + u32 mask; + + ret = init_common(priv); + if (ret < 0) { + dev_err(priv->dev, "Init common failed %d\n", ret); + return ret; + } + + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 1); + if (ret) { + dev_err(priv->dev, "Reset failed\n"); + return ret; + } + + mask = GENMASK(priv->num_sensors, 0); + ret = regmap_field_update_bits(priv->rf[SENSOR_EN], mask, mask); + if (ret) { + dev_err(priv->dev, "Sensor Enable failed\n"); + return ret; + } + + ret = regmap_field_write(priv->rf[TSENS_EN], 1); + if (ret) { + dev_err(priv->dev, "Enable failed\n"); + return ret; + } + + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 0); + + return ret; +} + static const struct tsens_ops ops_generic_v1 = { .init = init_common, .calibrate = calibrate_v1, @@ -194,3 +241,16 @@ struct tsens_plat_data data_8976 = { .feat = &tsens_v1_feat, .fields = tsens_v1_regfields, }; + +const struct tsens_ops ops_ipq5018 = { + .init = init_ipq5018, + .calibrate = tsens_calibrate_common, + .get_temp = get_temp_tsens_valid, +}; + +struct tsens_plat_data data_ipq5018 = { + .num_sensors = 5, + .ops = &ops_ipq5018, + .feat = &tsens_v1_ipq5018_feat, + .fields = tsens_v1_regfields, +}; diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index a25ca17adf1a..5ccaa297d16d 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1102,6 +1102,9 @@ static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume); static const struct of_device_id tsens_table[] = { { + .compatible = "qcom,ipq5018-tsens", + .data = &data_ipq5018, + }, { .compatible = "qcom,ipq8064-tsens", .data = &data_8960, }, { diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 90bf11fba563..f5c87facb552 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -650,7 +650,7 @@ extern struct tsens_plat_data data_8960; extern struct tsens_plat_data data_8226, data_8909, data_8916, data_8939, data_8974, data_9607; /* TSENS v1 targets */ -extern struct tsens_plat_data data_tsens_v1, data_8937, data_8976, data_8956; +extern struct tsens_plat_data data_tsens_v1, data_8937, data_8976, data_8956, data_ipq5018; /* TSENS v2 targets */ extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2;