diff options
-rw-r--r-- | drivers/thermal/armada_thermal.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index 4de6e56a0515..2fecccf71e9a 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c | |||
@@ -24,10 +24,7 @@ | |||
24 | #include <linux/of_device.h> | 24 | #include <linux/of_device.h> |
25 | #include <linux/thermal.h> | 25 | #include <linux/thermal.h> |
26 | 26 | ||
27 | #define THERMAL_VALID_OFFSET 9 | ||
28 | #define THERMAL_VALID_MASK 0x1 | 27 | #define THERMAL_VALID_MASK 0x1 |
29 | #define THERMAL_TEMP_OFFSET 10 | ||
30 | #define THERMAL_TEMP_MASK 0x1ff | ||
31 | 28 | ||
32 | /* Thermal Manager Control and Status Register */ | 29 | /* Thermal Manager Control and Status Register */ |
33 | #define PMU_TDC0_SW_RST_MASK (0x1 << 1) | 30 | #define PMU_TDC0_SW_RST_MASK (0x1 << 1) |
@@ -58,6 +55,11 @@ struct armada_thermal_data { | |||
58 | unsigned long coef_b; | 55 | unsigned long coef_b; |
59 | unsigned long coef_m; | 56 | unsigned long coef_m; |
60 | unsigned long coef_div; | 57 | unsigned long coef_div; |
58 | |||
59 | /* Register shift and mask to access the sensor temperature */ | ||
60 | unsigned int temp_shift; | ||
61 | unsigned int temp_mask; | ||
62 | unsigned int is_valid_shift; | ||
61 | }; | 63 | }; |
62 | 64 | ||
63 | static void armadaxp_init_sensor(struct armada_thermal_priv *priv) | 65 | static void armadaxp_init_sensor(struct armada_thermal_priv *priv) |
@@ -108,7 +110,7 @@ static bool armada_is_valid(struct armada_thermal_priv *priv) | |||
108 | { | 110 | { |
109 | unsigned long reg = readl_relaxed(priv->sensor); | 111 | unsigned long reg = readl_relaxed(priv->sensor); |
110 | 112 | ||
111 | return (reg >> THERMAL_VALID_OFFSET) & THERMAL_VALID_MASK; | 113 | return (reg >> priv->data->is_valid_shift) & THERMAL_VALID_MASK; |
112 | } | 114 | } |
113 | 115 | ||
114 | static int armada_get_temp(struct thermal_zone_device *thermal, | 116 | static int armada_get_temp(struct thermal_zone_device *thermal, |
@@ -126,7 +128,7 @@ static int armada_get_temp(struct thermal_zone_device *thermal, | |||
126 | } | 128 | } |
127 | 129 | ||
128 | reg = readl_relaxed(priv->sensor); | 130 | reg = readl_relaxed(priv->sensor); |
129 | reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK; | 131 | reg = (reg >> priv->data->temp_shift) & priv->data->temp_mask; |
130 | 132 | ||
131 | /* Get formula coeficients */ | 133 | /* Get formula coeficients */ |
132 | b = priv->data->coef_b; | 134 | b = priv->data->coef_b; |
@@ -143,6 +145,8 @@ static struct thermal_zone_device_ops ops = { | |||
143 | 145 | ||
144 | static const struct armada_thermal_data armadaxp_data = { | 146 | static const struct armada_thermal_data armadaxp_data = { |
145 | .init_sensor = armadaxp_init_sensor, | 147 | .init_sensor = armadaxp_init_sensor, |
148 | .temp_shift = 10, | ||
149 | .temp_mask = 0x1ff, | ||
146 | .coef_b = 3153000000UL, | 150 | .coef_b = 3153000000UL, |
147 | .coef_m = 10000000UL, | 151 | .coef_m = 10000000UL, |
148 | .coef_div = 13825, | 152 | .coef_div = 13825, |
@@ -151,6 +155,9 @@ static const struct armada_thermal_data armadaxp_data = { | |||
151 | static const struct armada_thermal_data armada370_data = { | 155 | static const struct armada_thermal_data armada370_data = { |
152 | .is_valid = armada_is_valid, | 156 | .is_valid = armada_is_valid, |
153 | .init_sensor = armada370_init_sensor, | 157 | .init_sensor = armada370_init_sensor, |
158 | .is_valid_shift = 9, | ||
159 | .temp_shift = 10, | ||
160 | .temp_mask = 0x1ff, | ||
154 | .coef_b = 3153000000UL, | 161 | .coef_b = 3153000000UL, |
155 | .coef_m = 10000000UL, | 162 | .coef_m = 10000000UL, |
156 | .coef_div = 13825, | 163 | .coef_div = 13825, |