On 2/27/25 23:02, Dmitry Baryshkov wrote: > On Thu, Feb 27, 2025 at 09:25:05PM +0400, George Moussalem wrote: >> On 2/27/25 18:59, Dmitry Baryshkov wrote: >> >>> On Thu, Feb 27, 2025 at 02:56:41PM +0400, George Moussalem wrote: >>>> Adding generic support for SoCs with tsens v1.0 IP with no RPM. >>>> Due to lack of RPM, tsens has to be reset and enabled in the driver >>>> init. >>>> >>>> Co-developed-by: Sricharan Ramabadhran <quic_srichara@xxxxxxxxxxx> >>>> Signed-off-by: Sricharan Ramabadhran <quic_srichara@xxxxxxxxxxx> >>>> Signed-off-by: George Moussalem <george.moussalem@xxxxxxxxxxx> >>>> --- >>>> drivers/thermal/qcom/tsens-v1.c | 48 +++++++++++++++++++++++++++++++++ >>>> drivers/thermal/qcom/tsens.c | 24 ++++++++++------- >>>> drivers/thermal/qcom/tsens.h | 1 + >>>> 3 files changed, 64 insertions(+), 9 deletions(-) >>>> >>>> diff --git a/drivers/thermal/qcom/tsens-v1.c b/drivers/thermal/qcom/tsens-v1.c >>>> index 1a7874676f68..877b27274fd2 100644 >>>> --- a/drivers/thermal/qcom/tsens-v1.c >>>> +++ b/drivers/thermal/qcom/tsens-v1.c >>>> @@ -79,6 +79,17 @@ static struct tsens_features tsens_v1_feat = { >>>> .trip_max_temp = 120000, >>>> }; >>>> >>>> +static struct tsens_features tsens_v1_no_rpm_feat = { >>>> + .ver_major = VER_1_X_NO_RPM, >>>> + .crit_int = 0, >>>> + .combo_int = 0, >>>> + .adc = 1, >>>> + .srot_split = 1, >>>> + .max_sensors = 11, >>>> + .trip_min_temp = -40000, >>>> + .trip_max_temp = 120000, >>>> +}; >>>> + >>>> static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = { >>>> /* ----- SROT ------ */ >>>> /* VERSION */ >>>> @@ -150,6 +161,43 @@ static int __init init_8956(struct tsens_priv *priv) { >>>> return init_common(priv); >>>> } >>>> >>>> +static int __init init_tsens_v1_no_rpm(struct tsens_priv *priv) >>>> +{ >>>> + int i, ret; >>>> + u32 mask = 0; >>>> + >>>> + 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; >>>> + } >>>> + >>>> + for (i = 0; i < priv->num_sensors; i++) >>>> + mask |= BIT(priv->sensor[i].hw_id); >>>> + >>>> + 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, >>>> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c >>>> index 1f5d4de017d9..f860ea86d130 100644 >>>> --- a/drivers/thermal/qcom/tsens.c >>>> +++ b/drivers/thermal/qcom/tsens.c >>>> @@ -447,7 +447,7 @@ static void tsens_set_interrupt(struct tsens_priv *priv, u32 hw_id, >>>> dev_dbg(priv->dev, "[%u] %s: %s -> %s\n", hw_id, __func__, >>>> irq_type ? ((irq_type == 1) ? "UP" : "CRITICAL") : "LOW", >>>> enable ? "en" : "dis"); >>>> - if (tsens_version(priv) > VER_1_X) >>>> + if (tsens_version(priv) > VER_1_X_NO_RPM) >>> I'd suggest to replace these checks with >= VER_2_X. This saves us from >>> all the troubles if there is another 1.x 'modification' later on. >> makes sense, will change to >= VER_2_X. Thanks for the feedback. > THanks! It also makes sense to split this into two patches then: one > which changes the condition all over the place and the other one which > adds VER_1_X_NO_RPM. Sounds good, will split into two. Will send v9 shortly.. Kind regards, George >>>> tsens_set_interrupt_v2(priv, hw_id, irq_type, enable); >>>> else >>>> tsens_set_interrupt_v1(priv, hw_id, irq_type, enable);