aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/thermal/armada_thermal.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index c5db07104354..4de6e56a0515 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -53,6 +53,11 @@ struct armada_thermal_data {
53 53
54 /* Test for a valid sensor value (optional) */ 54 /* Test for a valid sensor value (optional) */
55 bool (*is_valid)(struct armada_thermal_priv *); 55 bool (*is_valid)(struct armada_thermal_priv *);
56
57 /* Formula coeficients: temp = (b + m * reg) / div */
58 unsigned long coef_b;
59 unsigned long coef_m;
60 unsigned long coef_div;
56}; 61};
57 62
58static void armadaxp_init_sensor(struct armada_thermal_priv *priv) 63static void armadaxp_init_sensor(struct armada_thermal_priv *priv)
@@ -111,6 +116,7 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
111{ 116{
112 struct armada_thermal_priv *priv = thermal->devdata; 117 struct armada_thermal_priv *priv = thermal->devdata;
113 unsigned long reg; 118 unsigned long reg;
119 unsigned long m, b, div;
114 120
115 /* Valid check */ 121 /* Valid check */
116 if (priv->data->is_valid && !priv->data->is_valid(priv)) { 122 if (priv->data->is_valid && !priv->data->is_valid(priv)) {
@@ -121,7 +127,13 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
121 127
122 reg = readl_relaxed(priv->sensor); 128 reg = readl_relaxed(priv->sensor);
123 reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK; 129 reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK;
124 *temp = (3153000000UL - (10000000UL*reg)) / 13825; 130
131 /* Get formula coeficients */
132 b = priv->data->coef_b;
133 m = priv->data->coef_m;
134 div = priv->data->coef_div;
135
136 *temp = (b - (m * reg)) / div;
125 return 0; 137 return 0;
126} 138}
127 139
@@ -131,11 +143,17 @@ static struct thermal_zone_device_ops ops = {
131 143
132static const struct armada_thermal_data armadaxp_data = { 144static const struct armada_thermal_data armadaxp_data = {
133 .init_sensor = armadaxp_init_sensor, 145 .init_sensor = armadaxp_init_sensor,
146 .coef_b = 3153000000UL,
147 .coef_m = 10000000UL,
148 .coef_div = 13825,
134}; 149};
135 150
136static const struct armada_thermal_data armada370_data = { 151static const struct armada_thermal_data armada370_data = {
137 .is_valid = armada_is_valid, 152 .is_valid = armada_is_valid,
138 .init_sensor = armada370_init_sensor, 153 .init_sensor = armada370_init_sensor,
154 .coef_b = 3153000000UL,
155 .coef_m = 10000000UL,
156 .coef_div = 13825,
139}; 157};
140 158
141static const struct of_device_id armada_thermal_id_table[] = { 159static const struct of_device_id armada_thermal_id_table[] = {