Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/drivers/qcom/tsens: Add support for tsens v1 without RPM

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. SoCs can have support for more sensors than those which will
actually be enabled. As such, init will only enable those explicitly
added to the hw_ids array.

Co-developed-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Signed-off-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
Signed-off-by: George Moussalem <george.moussalem@outlook.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/DS7PR19MB8883C5D7974C7735E23923769DCC2@DS7PR19MB8883.namprd19.prod.outlook.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

George Moussalem and committed by
Daniel Lezcano
19f9b02e e3f90f16

+59 -4
+48
drivers/thermal/qcom/tsens-v1.c
··· 79 79 .trip_max_temp = 120000, 80 80 }; 81 81 82 + static struct tsens_features tsens_v1_no_rpm_feat = { 83 + .ver_major = VER_1_X_NO_RPM, 84 + .crit_int = 0, 85 + .combo_int = 0, 86 + .adc = 1, 87 + .srot_split = 1, 88 + .max_sensors = 11, 89 + .trip_min_temp = -40000, 90 + .trip_max_temp = 120000, 91 + }; 92 + 82 93 static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = { 83 94 /* ----- SROT ------ */ 84 95 /* VERSION */ ··· 159 148 priv->sensor[10].slope = 3286; 160 149 161 150 return init_common(priv); 151 + } 152 + 153 + static int __init init_tsens_v1_no_rpm(struct tsens_priv *priv) 154 + { 155 + int i, ret; 156 + u32 mask = 0; 157 + 158 + ret = init_common(priv); 159 + if (ret < 0) { 160 + dev_err(priv->dev, "Init common failed %d\n", ret); 161 + return ret; 162 + } 163 + 164 + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 1); 165 + if (ret) { 166 + dev_err(priv->dev, "Reset failed\n"); 167 + return ret; 168 + } 169 + 170 + for (i = 0; i < priv->num_sensors; i++) 171 + mask |= BIT(priv->sensor[i].hw_id); 172 + 173 + ret = regmap_field_update_bits(priv->rf[SENSOR_EN], mask, mask); 174 + if (ret) { 175 + dev_err(priv->dev, "Sensor Enable failed\n"); 176 + return ret; 177 + } 178 + 179 + ret = regmap_field_write(priv->rf[TSENS_EN], 1); 180 + if (ret) { 181 + dev_err(priv->dev, "Enable failed\n"); 182 + return ret; 183 + } 184 + 185 + ret = regmap_field_write(priv->rf[TSENS_SW_RST], 0); 186 + 187 + return ret; 162 188 } 163 189 164 190 static const struct tsens_ops ops_generic_v1 = {
+10 -4
drivers/thermal/qcom/tsens.c
··· 975 975 ret = regmap_field_read(priv->rf[TSENS_EN], &enabled); 976 976 if (ret) 977 977 goto err_put_device; 978 - if (!enabled && (tsens_version(priv) != VER_2_X_NO_RPM)) { 979 - dev_err(dev, "%s: device not enabled\n", __func__); 980 - ret = -ENODEV; 981 - goto err_put_device; 978 + if (!enabled) { 979 + switch (tsens_version(priv)) { 980 + case VER_1_X_NO_RPM: 981 + case VER_2_X_NO_RPM: 982 + break; 983 + default: 984 + dev_err(dev, "%s: device not enabled\n", __func__); 985 + ret = -ENODEV; 986 + goto err_put_device; 987 + } 982 988 } 983 989 984 990 priv->rf[SENSOR_EN] = devm_regmap_field_alloc(dev, priv->srot_map,
+1
drivers/thermal/qcom/tsens.h
··· 34 34 VER_0 = 0, 35 35 VER_0_1, 36 36 VER_1_X, 37 + VER_1_X_NO_RPM, 37 38 VER_2_X, 38 39 VER_2_X_NO_RPM, 39 40 };