Commit e1ff6fc2 authored by Florian Fainelli's avatar Florian Fainelli Committed by Daniel Lezcano

thermal: brcmstb_thermal: Do not use DT coefficients

At the time the brcmstb_thermal driver and its binding were merged, the
DT binding did not make the coefficients properties a mandatory one,
therefore all users of the brcmstb_thermal driver out there have a non
functional implementation with zero coefficients. Even if these
properties were provided, the formula used for computation is incorrect.

The coefficients are entirely process specific (right now, only 28nm is
supported) and not board or SoC specific, it is therefore appropriate to
hard code them in the driver given the compatibility string we are
probed with which has to be updated whenever a new process is
introduced.

We remove the existing coefficients definition since subsequent patches
are going to add support for a new process and will introduce new
coefficients as well.

Fixes: 9e03cf1b ("thermal: add brcmstb AVS TMON driver")
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200114190607.29339-2-f.fainelli@gmail.com
parent 263c8c4c
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#define AVS_TMON_TP_TEST_ENABLE 0x20 #define AVS_TMON_TP_TEST_ENABLE 0x20
/* Default coefficients */ /* Default coefficients */
#define AVS_TMON_TEMP_SLOPE -487 #define AVS_TMON_TEMP_SLOPE 487
#define AVS_TMON_TEMP_OFFSET 410040 #define AVS_TMON_TEMP_OFFSET 410040
/* HW related temperature constants */ /* HW related temperature constants */
...@@ -108,23 +108,12 @@ struct brcmstb_thermal_priv { ...@@ -108,23 +108,12 @@ struct brcmstb_thermal_priv {
struct thermal_zone_device *thermal; struct thermal_zone_device *thermal;
}; };
static void avs_tmon_get_coeffs(struct thermal_zone_device *tz, int *slope,
int *offset)
{
*slope = thermal_zone_get_slope(tz);
*offset = thermal_zone_get_offset(tz);
}
/* Convert a HW code to a temperature reading (millidegree celsius) */ /* Convert a HW code to a temperature reading (millidegree celsius) */
static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz, static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz,
u32 code) u32 code)
{ {
const int val = code & AVS_TMON_TEMP_MASK; return (AVS_TMON_TEMP_OFFSET -
int slope, offset; (int)((code & AVS_TMON_TEMP_MAX) * AVS_TMON_TEMP_SLOPE));
avs_tmon_get_coeffs(tz, &slope, &offset);
return slope * val + offset;
} }
/* /*
...@@ -136,20 +125,18 @@ static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz, ...@@ -136,20 +125,18 @@ static inline int avs_tmon_code_to_temp(struct thermal_zone_device *tz,
static inline u32 avs_tmon_temp_to_code(struct thermal_zone_device *tz, static inline u32 avs_tmon_temp_to_code(struct thermal_zone_device *tz,
int temp, bool low) int temp, bool low)
{ {
int slope, offset;
if (temp < AVS_TMON_TEMP_MIN) if (temp < AVS_TMON_TEMP_MIN)
return AVS_TMON_TEMP_MAX; /* Maximum code value */ return AVS_TMON_TEMP_MAX; /* Maximum code value */
avs_tmon_get_coeffs(tz, &slope, &offset);
if (temp >= offset) if (temp >= AVS_TMON_TEMP_OFFSET)
return 0; /* Minimum code value */ return 0; /* Minimum code value */
if (low) if (low)
return (u32)(DIV_ROUND_UP(offset - temp, abs(slope))); return (u32)(DIV_ROUND_UP(AVS_TMON_TEMP_OFFSET - temp,
AVS_TMON_TEMP_SLOPE));
else else
return (u32)((offset - temp) / abs(slope)); return (u32)((AVS_TMON_TEMP_OFFSET - temp) /
AVS_TMON_TEMP_SLOPE);
} }
static int brcmstb_get_temp(void *data, int *temp) static int brcmstb_get_temp(void *data, int *temp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment