Skip to content

Commit 62e79e3

Browse files
Fabio Estevamdlezcano
authored andcommitted
thermal/thermal_of: Allow rebooting after critical temp
Currently, the default mechanism is to trigger a shutdown after the critical temperature is reached. In some embedded cases, such behavior does not suit well, as the board may be unattended in the field and rebooting may be a better approach. The bootloader may also check the temperature and only allow the boot to proceed when the temperature is below a certain threshold. Introduce support for allowing a reboot to be triggered after the critical temperature is reached. If the "critical-action" devicetree property is not found, fall back to the shutdown action to preserve the existing default behavior. If a custom ops->critical exists, then it takes preference over critical-actions. Tested on a i.MX8MM board with the following devicetree changes: thermal-zones { cpu-thermal { critical-action = "reboot"; }; }; Signed-off-by: Fabio Estevam <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 79fa723 commit 62e79e3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/thermal/thermal_of.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
475475
struct thermal_zone_params tzp = {};
476476
struct thermal_zone_device_ops *of_ops;
477477
struct device_node *np;
478+
const char *action;
478479
int delay, pdelay;
479480
int ntrips, mask;
480481
int ret;
@@ -511,6 +512,11 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
511512

512513
mask = GENMASK_ULL((ntrips) - 1, 0);
513514

515+
ret = of_property_read_string(np, "critical-action", &action);
516+
if (!ret)
517+
if (!of_ops->critical && !strcasecmp(action, "reboot"))
518+
of_ops->critical = thermal_zone_device_critical_reboot;
519+
514520
tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
515521
mask, data, of_ops, &tzp,
516522
pdelay, delay);

0 commit comments

Comments
 (0)