diff options
author | Amit Kucheria <amit.kucheria@linaro.org> | 2019-03-20 18:47:58 +0530 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2019-05-14 06:59:22 -0700 |
commit | 14bbe98811209f3fb3f8143285ddcf1f6108aae4 (patch) | |
tree | c34c95e063155ce72b39b5450859fe75a658576a /drivers/thermal | |
parent | c8b6169093f66e9bae6eb5157ccc4ad426402caf (diff) | |
download | blackbird-op-linux-14bbe98811209f3fb3f8143285ddcf1f6108aae4.tar.gz blackbird-op-linux-14bbe98811209f3fb3f8143285ddcf1f6108aae4.zip |
drivers: thermal: tsens: Common get_temp() learns to do ADC conversion
get_temp() learns to return temperature regardless of whether it is
returned as ADC code or direct temperature.
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/qcom/tsens-common.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 5adbf1a2e0fb..92747ccb2850 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -129,10 +129,15 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) if (ret) return ret; - mask = GENMASK(priv->fields[LAST_TEMP_0].msb, - priv->fields[LAST_TEMP_0].lsb); - /* Convert temperature from deciCelsius to milliCelsius */ - *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; + if (priv->feat->adc) { + /* Convert temperature from ADC code to milliCelsius */ + *temp = code_to_degc(last_temp, s) * 1000; + } else { + mask = GENMASK(priv->fields[LAST_TEMP_0].msb, + priv->fields[LAST_TEMP_0].lsb); + /* Convert temperature from deciCelsius to milliCelsius */ + *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; + } return 0; } |