Skip to content

Commit

Permalink
thermal: armada: Allow to specify an 'inverted readout' sensor
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ezequiel Garcia authored and Zhang Rui committed May 15, 2014
1 parent 04bf3d7 commit fd2c94d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/thermal/armada_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit fd2c94d

Please sign in to comment.