* [PATCH v3 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function
[not found] <20220906164720.330701-1-daniel.lezcano@linaro.org>
@ 2022-09-06 16:46 ` Daniel Lezcano
2022-09-07 11:06 ` Krzysztof Kozlowski
2022-09-06 16:46 ` [PATCH v3 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Daniel Lezcano
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2022-09-06 16:46 UTC (permalink / raw)
To: daniel.lezcano, rafael
Cc: linux-kernel, linux-pm, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Amit Kucheria, Zhang Rui, Alim Akhtar,
open list:SAMSUNG THERMAL DRIVER, moderated list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES
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: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/thermal/samsung/exynos_tmu.c | 41 +++++++++++-----------------
1 file changed, 16 insertions(+), 25 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 51874d0a284c..0e33d32a9d2e 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -260,16 +260,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tzd = data->tzd;
- const struct thermal_trip * const trips =
- of_thermal_get_trip_points(tzd);
unsigned int status;
- int ret = 0, temp, hyst;
-
- if (!trips) {
- dev_err(&pdev->dev,
- "Cannot get trip points from device tree!\n");
- return -ENODEV;
- }
+ int ret = 0, temp;
if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
ret = tzd->ops->get_crit_temp(tzd, &temp);
@@ -303,19 +295,16 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
/* Write temperature code for rising and falling threshold */
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 */
- ret = tzd->ops->get_trip_hyst(tzd, i, &hyst);
+ struct thermal_trip trip;
+
+ ret = thermal_zone_get_trip(tzd, i, &trip);
if (ret)
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);
@@ -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,
- int trip, u8 temp)
+ int trip_id, u8 temp)
{
- const struct thermal_trip * const trips =
- of_thermal_get_trip_points(data->tzd);
+ struct thermal_trip trip;
u8 ref, th_code;
- ref = trips[0].temperature / MCELSIUS;
+ if (thermal_zone_get_trip(data->tzd, 0, &trip))
+ return;
- if (trip == 0) {
+ ref = trip.temperature / MCELSIUS;
+
+ if (trip_id == 0) {
th_code = temp_to_code(data, ref);
writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
}
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 */
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 09/30] thermal/drivers/exynos: of_thermal_get_ntrips()
[not found] <20220906164720.330701-1-daniel.lezcano@linaro.org>
2022-09-06 16:46 ` [PATCH v3 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Daniel Lezcano
@ 2022-09-06 16:46 ` Daniel Lezcano
2022-09-06 16:47 ` [PATCH v3 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Daniel Lezcano
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2022-09-06 16:46 UTC (permalink / raw)
To: daniel.lezcano, rafael
Cc: linux-kernel, linux-pm, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz, Amit Kucheria, Zhang Rui, Alim Akhtar,
open list:SAMSUNG THERMAL DRIVER, moderated list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES
The thermal core framework allows to get the number of thermal trips,
use it instead of visiting the thermal core structure internals.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/thermal/samsung/exynos_tmu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 0e33d32a9d2e..91e6860b5ec4 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -260,6 +260,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tzd = data->tzd;
+ int num_trips = thermal_zone_get_num_trips(tzd);
unsigned int status;
int ret = 0, temp;
@@ -271,12 +272,12 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
goto out;
}
- if (of_thermal_get_ntrips(tzd) > data->ntrip) {
+ if (num_trips > data->ntrip) {
dev_info(&pdev->dev,
"More trip points than supported by this TMU.\n");
dev_info(&pdev->dev,
"%d trip points should be configured in polling mode.\n",
- (of_thermal_get_ntrips(tzd) - data->ntrip));
+ num_trips - data->ntrip);
}
mutex_lock(&data->lock);
@@ -289,7 +290,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
ret = -EBUSY;
} else {
int i, ntrips =
- min_t(int, of_thermal_get_ntrips(tzd), data->ntrip);
+ min_t(int, num_trips, data->ntrip);
data->tmu_initialize(pdev);
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip()
[not found] <20220906164720.330701-1-daniel.lezcano@linaro.org>
2022-09-06 16:46 ` [PATCH v3 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-06 16:46 ` [PATCH v3 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Daniel Lezcano
@ 2022-09-06 16:47 ` Daniel Lezcano
2022-09-07 11:07 ` Krzysztof Kozlowski
2022-09-06 16:47 ` [PATCH v3 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Daniel Lezcano
` (2 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2022-09-06 16:47 UTC (permalink / raw)
To: daniel.lezcano, rafael
Cc: linux-kernel, linux-pm, Bartlomiej Zolnierkiewicz,
Krzysztof Kozlowski, Amit Kucheria, Zhang Rui, Alim Akhtar,
open list:SAMSUNG THERMAL DRIVER, moderated list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES
The thermal_zone_get_trip() does the same check as
of_thermal_is_trip_valid(). Replace the call to
of_thermal_is_trip_valid() by thermal_zone_get_trip().
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/thermal/samsung/exynos_tmu.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 91e6860b5ec4..5e6bb74c67f0 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -554,13 +554,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
+ struct thermal_trip trip;
unsigned int con, interrupt_en = 0, i;
con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
if (on) {
for (i = 0; i < data->ntrip; i++) {
- if (!of_thermal_is_trip_valid(tz, i))
+
+ if (thermal_zone_get_trip(tz, i, &trip))
continue;
interrupt_en |=
@@ -584,13 +586,15 @@ static void exynos5433_tmu_control(struct platform_device *pdev, bool on)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
+ struct thermal_trip trip;
unsigned int con, interrupt_en = 0, pd_det_en, i;
con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
if (on) {
for (i = 0; i < data->ntrip; i++) {
- if (!of_thermal_is_trip_valid(tz, i))
+
+ if (thermal_zone_get_trip(tz, i, &trip))
continue;
interrupt_en |=
@@ -615,13 +619,15 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
+ struct thermal_trip trip;
unsigned int con, interrupt_en = 0, i;
con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
if (on) {
for (i = 0; i < data->ntrip; i++) {
- if (!of_thermal_is_trip_valid(tz, i))
+
+ if (thermal_zone_get_trip(tz, i, &trip))
continue;
interrupt_en |=
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function
[not found] <20220906164720.330701-1-daniel.lezcano@linaro.org>
` (2 preceding siblings ...)
2022-09-06 16:47 ` [PATCH v3 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Daniel Lezcano
@ 2022-09-06 16:47 ` Daniel Lezcano
2022-09-06 16:47 ` [PATCH v3 22/30] thermal/drivers/imx: " Daniel Lezcano
2022-09-06 16:47 ` [PATCH v3 24/30] thermal/drivers/broadcom: " Daniel Lezcano
5 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2022-09-06 16:47 UTC (permalink / raw)
To: daniel.lezcano, rafael
Cc: linux-kernel, linux-pm, Kunihiko Hayashi, Amit Kucheria,
Zhang Rui, Masami Hiramatsu,
moderated list:ARM/UNIPHIER ARCHITECTURE
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: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
drivers/thermal/uniphier_thermal.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_thermal.c
index 4111d99ef50e..277ae300c5b1 100644
--- a/drivers/thermal/uniphier_thermal.c
+++ b/drivers/thermal/uniphier_thermal.c
@@ -248,8 +248,7 @@ static int uniphier_tm_probe(struct platform_device *pdev)
struct regmap *regmap;
struct device_node *parent;
struct uniphier_tm_dev *tdev;
- const struct thermal_trip *trips;
- int i, ret, irq, ntrips, crit_temp = INT_MAX;
+ int i, ret, irq, crit_temp = INT_MAX;
tdev = devm_kzalloc(dev, sizeof(*tdev), GFP_KERNEL);
if (!tdev)
@@ -296,20 +295,18 @@ static int uniphier_tm_probe(struct platform_device *pdev)
return PTR_ERR(tdev->tz_dev);
}
- /* get trip points */
- trips = of_thermal_get_trip_points(tdev->tz_dev);
- ntrips = of_thermal_get_ntrips(tdev->tz_dev);
- if (ntrips > ALERT_CH_NUM) {
- dev_err(dev, "thermal zone has too many trips\n");
- return -E2BIG;
- }
-
/* set alert temperatures */
- for (i = 0; i < ntrips; i++) {
- if (trips[i].type == THERMAL_TRIP_CRITICAL &&
- trips[i].temperature < crit_temp)
- crit_temp = trips[i].temperature;
- uniphier_tm_set_alert(tdev, i, trips[i].temperature);
+ for (i = 0; i < thermal_zone_get_num_trips(tdev->tz_dev); i++) {
+ struct thermal_trip trip;
+
+ ret = thermal_zone_get_trip(tdev->tz_dev, i, &trip);
+ if (ret)
+ return ret;
+
+ if (trip.type == THERMAL_TRIP_CRITICAL &&
+ trip.temperature < crit_temp)
+ crit_temp = trip.temperature;
+ uniphier_tm_set_alert(tdev, i, trip.temperature);
tdev->alert_en[i] = true;
}
if (crit_temp > CRITICAL_TEMP_LIMIT) {
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 22/30] thermal/drivers/imx: Use generic thermal_zone_get_trip() function
[not found] <20220906164720.330701-1-daniel.lezcano@linaro.org>
` (3 preceding siblings ...)
2022-09-06 16:47 ` [PATCH v3 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Daniel Lezcano
@ 2022-09-06 16:47 ` Daniel Lezcano
2022-09-16 17:02 ` Daniel Lezcano
2022-09-06 16:47 ` [PATCH v3 24/30] thermal/drivers/broadcom: " Daniel Lezcano
5 siblings, 1 reply; 9+ messages in thread
From: Daniel Lezcano @ 2022-09-06 16:47 UTC (permalink / raw)
To: daniel.lezcano, rafael
Cc: linux-kernel, linux-pm, Amit Kucheria, Zhang Rui, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
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: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/thermal/imx_thermal.c | 72 +++++++++++++----------------------
1 file changed, 27 insertions(+), 45 deletions(-)
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 16663373b682..fb0d5cab70af 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -76,7 +76,6 @@
enum imx_thermal_trip {
IMX_TRIP_PASSIVE,
IMX_TRIP_CRITICAL,
- IMX_TRIP_NUM,
};
#define IMX_POLLING_DELAY 2000 /* millisecond */
@@ -115,6 +114,11 @@ struct thermal_soc_data {
u32 low_alarm_shift;
};
+static struct thermal_trip trips[] = {
+ [IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE },
+ [IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL },
+};
+
static struct thermal_soc_data thermal_imx6q_data = {
.version = TEMPMON_IMX6Q,
@@ -201,8 +205,6 @@ struct imx_thermal_data {
struct thermal_cooling_device *cdev;
struct regmap *tempmon;
u32 c1, c2; /* See formula in imx_init_calib() */
- int temp_passive;
- int temp_critical;
int temp_max;
int alarm_temp;
int last_temp;
@@ -279,12 +281,12 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
/* Update alarm value to next higher trip point for TEMPMON_IMX6Q */
if (data->socdata->version == TEMPMON_IMX6Q) {
- if (data->alarm_temp == data->temp_passive &&
- *temp >= data->temp_passive)
- imx_set_alarm_temp(data, data->temp_critical);
- if (data->alarm_temp == data->temp_critical &&
- *temp < data->temp_passive) {
- imx_set_alarm_temp(data, data->temp_passive);
+ if (data->alarm_temp == trips[IMX_TRIP_PASSIVE].temperature &&
+ *temp >= trips[IMX_TRIP_PASSIVE].temperature)
+ imx_set_alarm_temp(data, trips[IMX_TRIP_CRITICAL].temperature);
+ if (data->alarm_temp == trips[IMX_TRIP_CRITICAL].temperature &&
+ *temp < trips[IMX_TRIP_PASSIVE].temperature) {
+ imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature);
dev_dbg(&tz->device, "thermal alarm off: T < %d\n",
data->alarm_temp / 1000);
}
@@ -330,29 +332,10 @@ static int imx_change_mode(struct thermal_zone_device *tz,
return 0;
}
-static int imx_get_trip_type(struct thermal_zone_device *tz, int trip,
- enum thermal_trip_type *type)
-{
- *type = (trip == IMX_TRIP_PASSIVE) ? THERMAL_TRIP_PASSIVE :
- THERMAL_TRIP_CRITICAL;
- return 0;
-}
-
static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp)
{
- struct imx_thermal_data *data = tz->devdata;
-
- *temp = data->temp_critical;
- return 0;
-}
-
-static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip,
- int *temp)
-{
- struct imx_thermal_data *data = tz->devdata;
+ *temp = trips[IMX_TRIP_CRITICAL].temperature;
- *temp = (trip == IMX_TRIP_PASSIVE) ? data->temp_passive :
- data->temp_critical;
return 0;
}
@@ -371,10 +354,10 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
return -EPERM;
/* do not allow passive to be set higher than critical */
- if (temp < 0 || temp > data->temp_critical)
+ if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
return -EINVAL;
- data->temp_passive = temp;
+ trips[IMX_TRIP_PASSIVE].temperature = temp;
imx_set_alarm_temp(data, temp);
@@ -423,8 +406,6 @@ static struct thermal_zone_device_ops imx_tz_ops = {
.unbind = imx_unbind,
.get_temp = imx_get_temp,
.change_mode = imx_change_mode,
- .get_trip_type = imx_get_trip_type,
- .get_trip_temp = imx_get_trip_temp,
.get_crit_temp = imx_get_crit_temp,
.set_trip_temp = imx_set_trip_temp,
};
@@ -507,8 +488,8 @@ static void imx_init_temp_grade(struct platform_device *pdev, u32 ocotp_mem0)
* Set the critical trip point at 5 °C under max
* Set the passive trip point at 10 °C under max (changeable via sysfs)
*/
- data->temp_critical = data->temp_max - (1000 * 5);
- data->temp_passive = data->temp_max - (1000 * 10);
+ trips[IMX_TRIP_PASSIVE].temperature = data->temp_max - (1000 * 10);
+ trips[IMX_TRIP_CRITICAL].temperature = data->temp_max - (1000 * 5);
}
static int imx_init_from_tempmon_data(struct platform_device *pdev)
@@ -743,12 +724,13 @@ static int imx_thermal_probe(struct platform_device *pdev)
goto legacy_cleanup;
}
- data->tz = thermal_zone_device_register("imx_thermal_zone",
- IMX_TRIP_NUM,
- BIT(IMX_TRIP_PASSIVE), data,
- &imx_tz_ops, NULL,
- IMX_PASSIVE_DELAY,
- IMX_POLLING_DELAY);
+ data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone",
+ trips,
+ ARRAY_SIZE(trips),
+ BIT(IMX_TRIP_PASSIVE), data,
+ &imx_tz_ops, NULL,
+ IMX_PASSIVE_DELAY,
+ IMX_POLLING_DELAY);
if (IS_ERR(data->tz)) {
ret = PTR_ERR(data->tz);
dev_err(&pdev->dev,
@@ -758,8 +740,8 @@ static int imx_thermal_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
" critical:%dC passive:%dC\n", data->temp_grade,
- data->temp_max / 1000, data->temp_critical / 1000,
- data->temp_passive / 1000);
+ data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000,
+ trips[IMX_TRIP_PASSIVE].temperature / 1000);
/* Enable measurements at ~ 10 Hz */
regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR,
@@ -767,10 +749,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
regmap_write(map, data->socdata->measure_freq_ctrl + REG_SET,
measure_freq << data->socdata->measure_freq_shift);
- imx_set_alarm_temp(data, data->temp_passive);
+ imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature);
if (data->socdata->version == TEMPMON_IMX6SX)
- imx_set_panic_temp(data, data->temp_critical);
+ imx_set_panic_temp(data, trips[IMX_TRIP_CRITICAL].temperature);
regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
data->socdata->power_down_mask);
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v3 24/30] thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function
[not found] <20220906164720.330701-1-daniel.lezcano@linaro.org>
` (4 preceding siblings ...)
2022-09-06 16:47 ` [PATCH v3 22/30] thermal/drivers/imx: " Daniel Lezcano
@ 2022-09-06 16:47 ` Daniel Lezcano
5 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2022-09-06 16:47 UTC (permalink / raw)
To: daniel.lezcano, rafael
Cc: linux-kernel, linux-pm, Amit Kucheria, Zhang Rui,
Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE
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: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/thermal/broadcom/bcm2835_thermal.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c
index 2c67841a1115..5485e59d03a9 100644
--- a/drivers/thermal/broadcom/bcm2835_thermal.c
+++ b/drivers/thermal/broadcom/bcm2835_thermal.c
@@ -18,6 +18,7 @@
#include <linux/platform_device.h>
#include <linux/thermal.h>
+#include "../thermal_core.h"
#include "../thermal_hwmon.h"
#define BCM2835_TS_TSENSCTL 0x00
@@ -224,7 +225,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
*/
val = readl(data->regs + BCM2835_TS_TSENSCTL);
if (!(val & BCM2835_TS_TSENSCTL_RSTB)) {
- int trip_temp, offset, slope;
+ struct thermal_trip trip;
+ int offset, slope;
slope = thermal_zone_get_slope(tz);
offset = thermal_zone_get_offset(tz);
@@ -232,7 +234,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
* For now we deal only with critical, otherwise
* would need to iterate
*/
- err = tz->ops->get_trip_temp(tz, 0, &trip_temp);
+ err = thermal_zone_get_trip(tz, 0, &trip);
if (err < 0) {
dev_err(&pdev->dev,
"Not able to read trip_temp: %d\n",
@@ -249,7 +251,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
val |= (0xFE << BCM2835_TS_TSENSCTL_RSTDELAY_SHIFT);
/* trip_adc value from info */
- val |= bcm2835_thermal_temp2adc(trip_temp,
+ val |= bcm2835_thermal_temp2adc(trip.temperature,
offset,
slope)
<< BCM2835_TS_TSENSCTL_THOLD_SHIFT;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function
2022-09-06 16:46 ` [PATCH v3 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Daniel Lezcano
@ 2022-09-07 11:06 ` Krzysztof Kozlowski
0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-07 11:06 UTC (permalink / raw)
To: Daniel Lezcano, rafael
Cc: linux-kernel, linux-pm, Bartlomiej Zolnierkiewicz, Amit Kucheria,
Zhang Rui, Alim Akhtar, open list:SAMSUNG THERMAL DRIVER,
moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES
On 06/09/2022 18:46, Daniel Lezcano wrote:
> 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: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip()
2022-09-06 16:47 ` [PATCH v3 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Daniel Lezcano
@ 2022-09-07 11:07 ` Krzysztof Kozlowski
0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-07 11:07 UTC (permalink / raw)
To: Daniel Lezcano, rafael
Cc: linux-kernel, linux-pm, Bartlomiej Zolnierkiewicz, Amit Kucheria,
Zhang Rui, Alim Akhtar, open list:SAMSUNG THERMAL DRIVER,
moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES
On 06/09/2022 18:47, Daniel Lezcano wrote:
> The thermal_zone_get_trip() does the same check as
> of_thermal_is_trip_valid(). Replace the call to
> of_thermal_is_trip_valid() by thermal_zone_get_trip().
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
> drivers/thermal/samsung/exynos_tmu.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 91e6860b5ec4..5e6bb74c67f0 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -554,13 +554,15 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
> {
> struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> struct thermal_zone_device *tz = data->tzd;
> + struct thermal_trip trip;
> unsigned int con, interrupt_en = 0, i;
>
> con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
>
> if (on) {
> for (i = 0; i < data->ntrip; i++) {
> - if (!of_thermal_is_trip_valid(tz, i))
> +
> + if (thermal_zone_get_trip(tz, i, &trip))
No need for empty line before. Ditto in other places.
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 22/30] thermal/drivers/imx: Use generic thermal_zone_get_trip() function
2022-09-06 16:47 ` [PATCH v3 22/30] thermal/drivers/imx: " Daniel Lezcano
@ 2022-09-16 17:02 ` Daniel Lezcano
0 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2022-09-16 17:02 UTC (permalink / raw)
To: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
NXP Linux Team,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
Cc: rafael, linux-kernel, linux-pm, Amit Kucheria, Zhang Rui
Hi,
On 06/09/2022 18:47, Daniel Lezcano wrote:
> 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.
Any comment on this patch?
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
> drivers/thermal/imx_thermal.c | 72 +++++++++++++----------------------
> 1 file changed, 27 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index 16663373b682..fb0d5cab70af 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -76,7 +76,6 @@
> enum imx_thermal_trip {
> IMX_TRIP_PASSIVE,
> IMX_TRIP_CRITICAL,
> - IMX_TRIP_NUM,
> };
>
> #define IMX_POLLING_DELAY 2000 /* millisecond */
> @@ -115,6 +114,11 @@ struct thermal_soc_data {
> u32 low_alarm_shift;
> };
>
> +static struct thermal_trip trips[] = {
> + [IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE },
> + [IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL },
> +};
> +
> static struct thermal_soc_data thermal_imx6q_data = {
> .version = TEMPMON_IMX6Q,
>
> @@ -201,8 +205,6 @@ struct imx_thermal_data {
> struct thermal_cooling_device *cdev;
> struct regmap *tempmon;
> u32 c1, c2; /* See formula in imx_init_calib() */
> - int temp_passive;
> - int temp_critical;
> int temp_max;
> int alarm_temp;
> int last_temp;
> @@ -279,12 +281,12 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
>
> /* Update alarm value to next higher trip point for TEMPMON_IMX6Q */
> if (data->socdata->version == TEMPMON_IMX6Q) {
> - if (data->alarm_temp == data->temp_passive &&
> - *temp >= data->temp_passive)
> - imx_set_alarm_temp(data, data->temp_critical);
> - if (data->alarm_temp == data->temp_critical &&
> - *temp < data->temp_passive) {
> - imx_set_alarm_temp(data, data->temp_passive);
> + if (data->alarm_temp == trips[IMX_TRIP_PASSIVE].temperature &&
> + *temp >= trips[IMX_TRIP_PASSIVE].temperature)
> + imx_set_alarm_temp(data, trips[IMX_TRIP_CRITICAL].temperature);
> + if (data->alarm_temp == trips[IMX_TRIP_CRITICAL].temperature &&
> + *temp < trips[IMX_TRIP_PASSIVE].temperature) {
> + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature);
> dev_dbg(&tz->device, "thermal alarm off: T < %d\n",
> data->alarm_temp / 1000);
> }
> @@ -330,29 +332,10 @@ static int imx_change_mode(struct thermal_zone_device *tz,
> return 0;
> }
>
> -static int imx_get_trip_type(struct thermal_zone_device *tz, int trip,
> - enum thermal_trip_type *type)
> -{
> - *type = (trip == IMX_TRIP_PASSIVE) ? THERMAL_TRIP_PASSIVE :
> - THERMAL_TRIP_CRITICAL;
> - return 0;
> -}
> -
> static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp)
> {
> - struct imx_thermal_data *data = tz->devdata;
> -
> - *temp = data->temp_critical;
> - return 0;
> -}
> -
> -static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip,
> - int *temp)
> -{
> - struct imx_thermal_data *data = tz->devdata;
> + *temp = trips[IMX_TRIP_CRITICAL].temperature;
>
> - *temp = (trip == IMX_TRIP_PASSIVE) ? data->temp_passive :
> - data->temp_critical;
> return 0;
> }
>
> @@ -371,10 +354,10 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
> return -EPERM;
>
> /* do not allow passive to be set higher than critical */
> - if (temp < 0 || temp > data->temp_critical)
> + if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
> return -EINVAL;
>
> - data->temp_passive = temp;
> + trips[IMX_TRIP_PASSIVE].temperature = temp;
>
> imx_set_alarm_temp(data, temp);
>
> @@ -423,8 +406,6 @@ static struct thermal_zone_device_ops imx_tz_ops = {
> .unbind = imx_unbind,
> .get_temp = imx_get_temp,
> .change_mode = imx_change_mode,
> - .get_trip_type = imx_get_trip_type,
> - .get_trip_temp = imx_get_trip_temp,
> .get_crit_temp = imx_get_crit_temp,
> .set_trip_temp = imx_set_trip_temp,
> };
> @@ -507,8 +488,8 @@ static void imx_init_temp_grade(struct platform_device *pdev, u32 ocotp_mem0)
> * Set the critical trip point at 5 °C under max
> * Set the passive trip point at 10 °C under max (changeable via sysfs)
> */
> - data->temp_critical = data->temp_max - (1000 * 5);
> - data->temp_passive = data->temp_max - (1000 * 10);
> + trips[IMX_TRIP_PASSIVE].temperature = data->temp_max - (1000 * 10);
> + trips[IMX_TRIP_CRITICAL].temperature = data->temp_max - (1000 * 5);
> }
>
> static int imx_init_from_tempmon_data(struct platform_device *pdev)
> @@ -743,12 +724,13 @@ static int imx_thermal_probe(struct platform_device *pdev)
> goto legacy_cleanup;
> }
>
> - data->tz = thermal_zone_device_register("imx_thermal_zone",
> - IMX_TRIP_NUM,
> - BIT(IMX_TRIP_PASSIVE), data,
> - &imx_tz_ops, NULL,
> - IMX_PASSIVE_DELAY,
> - IMX_POLLING_DELAY);
> + data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone",
> + trips,
> + ARRAY_SIZE(trips),
> + BIT(IMX_TRIP_PASSIVE), data,
> + &imx_tz_ops, NULL,
> + IMX_PASSIVE_DELAY,
> + IMX_POLLING_DELAY);
> if (IS_ERR(data->tz)) {
> ret = PTR_ERR(data->tz);
> dev_err(&pdev->dev,
> @@ -758,8 +740,8 @@ static int imx_thermal_probe(struct platform_device *pdev)
>
> dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC"
> " critical:%dC passive:%dC\n", data->temp_grade,
> - data->temp_max / 1000, data->temp_critical / 1000,
> - data->temp_passive / 1000);
> + data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000,
> + trips[IMX_TRIP_PASSIVE].temperature / 1000);
>
> /* Enable measurements at ~ 10 Hz */
> regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR,
> @@ -767,10 +749,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
> measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
> regmap_write(map, data->socdata->measure_freq_ctrl + REG_SET,
> measure_freq << data->socdata->measure_freq_shift);
> - imx_set_alarm_temp(data, data->temp_passive);
> + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature);
>
> if (data->socdata->version == TEMPMON_IMX6SX)
> - imx_set_panic_temp(data, data->temp_critical);
> + imx_set_panic_temp(data, trips[IMX_TRIP_CRITICAL].temperature);
>
> regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
> data->socdata->power_down_mask);
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-16 17:05 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20220906164720.330701-1-daniel.lezcano@linaro.org>
2022-09-06 16:46 ` [PATCH v3 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-07 11:06 ` Krzysztof Kozlowski
2022-09-06 16:46 ` [PATCH v3 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Daniel Lezcano
2022-09-06 16:47 ` [PATCH v3 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Daniel Lezcano
2022-09-07 11:07 ` Krzysztof Kozlowski
2022-09-06 16:47 ` [PATCH v3 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-06 16:47 ` [PATCH v3 22/30] thermal/drivers/imx: " Daniel Lezcano
2022-09-16 17:02 ` Daniel Lezcano
2022-09-06 16:47 ` [PATCH v3 24/30] thermal/drivers/broadcom: " Daniel Lezcano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).