soc: rockchip_system_monitor: Add a dummy thermal governor

Add support to change thermal governor to dummy, and the system
monitor will manage cooling devices.

This also fixes the following build errors when build as a module.
ERROR: modpost: "__governor_thermal_table_end" [drivers/soc/rockchip/rockchip_system_monitor.ko] undefined!
ERROR: modpost: "__governor_thermal_table" [drivers/soc/rockchip/rockchip_system_monitor.ko] undefined!

Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Change-Id: Ia68b5bf2b6d94cb13fafc5cde74bc80b32dfac0a
This commit is contained in:
Finley Xiao
2021-07-13 11:20:43 +08:00
committed by Tao Huang
parent 888b10e41e
commit da2cde8541
2 changed files with 18 additions and 14 deletions

View File

@@ -17,6 +17,9 @@ Optional properties:
property (above).
- rockchip,temp-offline-cpus: A string containing cpus which will be killed
when temperature is high.
- rockchip,thermal-governor-dummy: This property allows system monitor to
change thermal governor to dummy, and the system
monitor will manage cooling devices.
Example:

View File

@@ -1160,12 +1160,20 @@ void rockchip_system_monitor_unregister(struct monitor_dev_info *info)
}
EXPORT_SYMBOL(rockchip_system_monitor_unregister);
static int notify_dummy(struct thermal_zone_device *tz, int trip)
{
return 0;
}
static struct thermal_governor thermal_gov_dummy = {
.name = "dummy",
.throttle = notify_dummy,
};
static int rockchip_system_monitor_parse_dt(struct system_monitor *monitor)
{
struct device_node *np = monitor->dev->of_node;
struct thermal_governor **governor;
const char *tz_name, *buf = NULL;
const char *gov_name;
if (of_property_read_string(np, "rockchip,video-4k-offline-cpus", &buf))
cpumask_clear(&system_monitor->video_4k_offline_cpus);
@@ -1195,19 +1203,12 @@ static int rockchip_system_monitor_parse_dt(struct system_monitor *monitor)
of_property_read_u32(np, "rockchip,temp-hysteresis",
&system_monitor->temp_hysteresis);
if (of_property_read_string(np, "rockchip,thermal-governor", &gov_name))
goto out;
for_each_governor_table(governor) {
if (!strncasecmp((*governor)->name, gov_name,
THERMAL_NAME_LENGTH)) {
if (monitor->tz->governor->unbind_from_tz)
monitor->tz->governor->unbind_from_tz(monitor->tz);
if ((*governor)->bind_to_tz)
(*governor)->bind_to_tz(monitor->tz);
monitor->tz->governor = (*governor);
break;
}
if (of_find_property(np, "rockchip,thermal-governor-dummy", NULL)) {
if (monitor->tz->governor->unbind_from_tz)
monitor->tz->governor->unbind_from_tz(monitor->tz);
monitor->tz->governor = &thermal_gov_dummy;
}
out:
return 0;
}