summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/qcom/tsens-common.c
diff options
context:
space:
mode:
authorAmit Kucheria <amit.kucheria@linaro.org>2019-03-20 18:47:53 +0530
committerEduardo Valentin <edubezval@gmail.com>2019-05-14 06:59:17 -0700
commit3e6a8fb3308419129c7a52de6eb42feef5a919a0 (patch)
treeaa022b085fb0a5de3c5cdf87eae9eaeb3bed8937 /drivers/thermal/qcom/tsens-common.c
parentfc7d18cf6a923cde7f5e7ba2c1105bb106d3e29a (diff)
downloadlinux-3e6a8fb3308419129c7a52de6eb42feef5a919a0.tar.bz2
drivers: thermal: tsens: Add new operation to check if a sensor is enabled
is_sensor_enabled() checks if the sensors are enabled on this platform. It is possible that the SoC might choose not to enable all the sensors that the IP block is capable of supporting. Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal/qcom/tsens-common.c')
-rw-r--r--drivers/thermal/qcom/tsens-common.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
index 9d7a6c328ae0..c76f8cfb25a2 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -69,6 +69,20 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1,
}
}
+bool is_sensor_enabled(struct tsens_priv *priv, u32 hw_id)
+{
+ u32 val;
+ int ret;
+
+ if ((hw_id > (priv->num_sensors - 1)) || (hw_id < 0))
+ return -EINVAL;
+ ret = regmap_field_read(priv->rf[SENSOR_EN], &val);
+ if (ret)
+ return ret;
+
+ return val & (1 << hw_id);
+}
+
static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)
{
int degc, num, den;