Commit ca38255e authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

thermal/drivers/exynos: Use generic thermal_zone_get_trip() function

The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-8-daniel.lezcano@linaro.org
parent 5c4855d7
...@@ -260,16 +260,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ...@@ -260,16 +260,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
{ {
struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tzd = data->tzd; struct thermal_zone_device *tzd = data->tzd;
const struct thermal_trip * const trips =
of_thermal_get_trip_points(tzd);
unsigned int status; unsigned int status;
int ret = 0, temp, hyst; int ret = 0, temp;
if (!trips) {
dev_err(&pdev->dev,
"Cannot get trip points from device tree!\n");
return -ENODEV;
}
if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */ if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
ret = tzd->ops->get_crit_temp(tzd, &temp); ret = tzd->ops->get_crit_temp(tzd, &temp);
...@@ -303,19 +295,16 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ...@@ -303,19 +295,16 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
/* Write temperature code for rising and falling threshold */ /* Write temperature code for rising and falling threshold */
for (i = 0; i < ntrips; i++) { for (i = 0; i < ntrips; i++) {
/* Write temperature code for rising threshold */
ret = tzd->ops->get_trip_temp(tzd, i, &temp);
if (ret)
goto err;
temp /= MCELSIUS;
data->tmu_set_trip_temp(data, i, temp);
/* Write temperature code for falling threshold */ struct thermal_trip trip;
ret = tzd->ops->get_trip_hyst(tzd, i, &hyst);
ret = thermal_zone_get_trip(tzd, i, &trip);
if (ret) if (ret)
goto err; goto err;
hyst /= MCELSIUS;
data->tmu_set_trip_hyst(data, i, temp, hyst); data->tmu_set_trip_temp(data, i, trip.temperature / MCELSIUS);
data->tmu_set_trip_hyst(data, i, trip.temperature / MCELSIUS,
trip.hysteresis / MCELSIUS);
} }
data->tmu_clear_irqs(data); data->tmu_clear_irqs(data);
...@@ -360,21 +349,23 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) ...@@ -360,21 +349,23 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
} }
static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data, static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data,
int trip, u8 temp) int trip_id, u8 temp)
{ {
const struct thermal_trip * const trips = struct thermal_trip trip;
of_thermal_get_trip_points(data->tzd);
u8 ref, th_code; u8 ref, th_code;
ref = trips[0].temperature / MCELSIUS; if (thermal_zone_get_trip(data->tzd, 0, &trip))
return;
ref = trip.temperature / MCELSIUS;
if (trip == 0) { if (trip_id == 0) {
th_code = temp_to_code(data, ref); th_code = temp_to_code(data, ref);
writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
} }
temp -= ref; temp -= ref;
writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip * 4); writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip_id * 4);
} }
/* failing thresholds are not supported on Exynos4210 */ /* failing thresholds are not supported on Exynos4210 */
......
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