diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2014-05-06 13:59:46 -0300 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2014-05-15 17:12:34 +0800 |
commit | 9484bc62cadd919f072ed1232f25ccc156d8bacf (patch) | |
tree | 49fe0c96542c23eb8196aa88412cd92d46c30f35 /drivers/thermal | |
parent | 66fdb7b63513d92c0ca9ff3a34e5f29b2e018e47 (diff) | |
download | op-kernel-dev-9484bc62cadd919f072ed1232f25ccc156d8bacf.zip op-kernel-dev-9484bc62cadd919f072ed1232f25ccc156d8bacf.tar.gz |
thermal: armada: Add infrastructure to support generic formulas
In order to support other similar SoC, with different sensor
coefficients, this commit adds the coeficients to the per-variant
structure, instead of having the formula hardcoded.
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')
-rw-r--r-- | drivers/thermal/armada_thermal.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index c5db071..4de6e56a 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -53,6 +53,11 @@ struct armada_thermal_data { /* Test for a valid sensor value (optional) */ bool (*is_valid)(struct armada_thermal_priv *); + + /* Formula coeficients: temp = (b + m * reg) / div */ + unsigned long coef_b; + unsigned long coef_m; + unsigned long coef_div; }; static void armadaxp_init_sensor(struct armada_thermal_priv *priv) @@ -111,6 +116,7 @@ static int armada_get_temp(struct thermal_zone_device *thermal, { struct armada_thermal_priv *priv = thermal->devdata; unsigned long reg; + unsigned long m, b, div; /* Valid check */ if (priv->data->is_valid && !priv->data->is_valid(priv)) { @@ -121,7 +127,13 @@ static int armada_get_temp(struct thermal_zone_device *thermal, reg = readl_relaxed(priv->sensor); reg = (reg >> THERMAL_TEMP_OFFSET) & THERMAL_TEMP_MASK; - *temp = (3153000000UL - (10000000UL*reg)) / 13825; + + /* Get formula coeficients */ + b = priv->data->coef_b; + m = priv->data->coef_m; + div = priv->data->coef_div; + + *temp = (b - (m * reg)) / div; return 0; } @@ -131,11 +143,17 @@ static struct thermal_zone_device_ops ops = { static const struct armada_thermal_data armadaxp_data = { .init_sensor = armadaxp_init_sensor, + .coef_b = 3153000000UL, + .coef_m = 10000000UL, + .coef_div = 13825, }; static const struct armada_thermal_data armada370_data = { .is_valid = armada_is_valid, .init_sensor = armada370_init_sensor, + .coef_b = 3153000000UL, + .coef_m = 10000000UL, + .coef_div = 13825, }; static const struct of_device_id armada_thermal_id_table[] = { |