summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/armada_thermal.c
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2014-05-06 13:59:49 -0300
committerZhang Rui <rui.zhang@intel.com>2014-05-15 17:12:48 +0800
commitfd2c94d5a32297c63b025b54b71aa24ccc0596ed (patch)
tree62fb40a3d929a24e18aa4272ec7a24df39405df6 /drivers/thermal/armada_thermal.c
parent04bf3d7e5ba862214f1c761778c414be95e2dfb9 (diff)
downloadlinux-fd2c94d5a32297c63b025b54b71aa24ccc0596ed.tar.gz
linux-fd2c94d5a32297c63b025b54b71aa24ccc0596ed.tar.bz2
linux-fd2c94d5a32297c63b025b54b71aa24ccc0596ed.zip
thermal: armada: Allow to specify an 'inverted readout' sensor
In order to support inverted-formula thermal sensor readout, this commit introduces an 'inverted' field in the SoC-specific structure which allows to specify an inversion of the temperature formula. Acked-by: Jason Cooper <jason@lakedaemon.net> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/armada_thermal.c')
-rw-r--r--drivers/thermal/armada_thermal.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 6fd648337e63..f84d9f077fe2 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -56,6 +56,7 @@ struct armada_thermal_data {
unsigned long coef_b;
unsigned long coef_m;
unsigned long coef_div;
+ bool inverted;
/* Register shift and mask to access the sensor temperature */
unsigned int temp_shift;
@@ -138,7 +139,10 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
m = priv->data->coef_m;
div = priv->data->coef_div;
- *temp = (b - (m * reg)) / div;
+ if (priv->data->inverted)
+ *temp = ((m * reg) - b) / div;
+ else
+ *temp = (b - (m * reg)) / div;
return 0;
}