From 2fa7e1c4ed754fa5b35437b76430fb85ca5ccfcb Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Mon, 1 Apr 2019 21:27:52 +0800 Subject: [PATCH] thermal: power_allocator: Add support to change state by system monitor Change-Id: Ib0ed0c5df3fbae078be7ec88e93ba69cee894286 Signed-off-by: Finley Xiao --- drivers/thermal/power_allocator.c | 8 ++++++++ drivers/thermal/thermal_core.c | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c index 3055f9a12a17..478862b4d258 100644 --- a/drivers/thermal/power_allocator.c +++ b/drivers/thermal/power_allocator.c @@ -19,6 +19,9 @@ #include #include +#ifdef CONFIG_ARCH_ROCKCHIP +#include +#endif #define CREATE_TRACE_POINTS #include @@ -530,6 +533,11 @@ static void allow_maximum_power(struct thermal_zone_device *tz) continue; instance->target = 0; +#ifdef CONFIG_ARCH_ROCKCHIP + rockchip_system_monitor_adjust_cdev_state(instance->cdev, + tz->temperature, + &instance->target); +#endif mutex_lock(&instance->cdev->lock); instance->cdev->updated = false; mutex_unlock(&instance->cdev->lock); diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 441778100887..cc83ac4ea98c 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -22,6 +22,9 @@ #include #include #include +#ifdef CONFIG_ARCH_ROCKCHIP +#include +#endif #define CREATE_TRACE_POINTS #include @@ -587,6 +590,15 @@ int power_actor_set_power(struct thermal_cooling_device *cdev, return -EINVAL; ret = cdev->ops->power2state(cdev, instance->tz, power, &state); +#ifdef CONFIG_ARCH_ROCKCHIP + if (ret) + state = THERMAL_CSTATE_INVALID; + rockchip_system_monitor_adjust_cdev_state(cdev, + instance->tz->temperature, + &state); + if (state == THERMAL_CSTATE_INVALID) + ret = -EINVAL; +#endif if (ret) return ret;