Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd2c94d5 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Zhang Rui
Browse files

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: default avatarJason Cooper <jason@lakedaemon.net>
Signed-off-by: default avatarEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
parent 04bf3d7e
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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,6 +139,9 @@ static int armada_get_temp(struct thermal_zone_device *thermal,
	m = priv->data->coef_m;
	div = priv->data->coef_div;

	if (priv->data->inverted)
		*temp = ((m * reg) - b) / div;
	else
		*temp = (b - (m * reg)) / div;
	return 0;
}