From f6ec026aa9916b08981b574416f555e2cdab6c66 Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Tue, 4 Dec 2018 16:06:23 +0800 Subject: thermal: power_allocator: Add support to get PID constant from dt Change-Id: Ibabdad4ba2df6df26d75483dd35b6c51572befe8 Signed-off-by: Finley Xiao --- drivers/thermal/of-thermal.c | 12 ++++++++++++ drivers/thermal/power_allocator.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'drivers/thermal') diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index ef6101b8b5de..2f7e814be930 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -1009,6 +1009,18 @@ int __init of_parse_thermal_zones(void) if (!of_property_read_u32(child, "sustainable-power", &prop)) tzp->sustainable_power = prop; + if (!of_property_read_u32(child, "k_pu", &prop)) { + tzp->k_pu = prop; + tzp->is_k_pu_available = true; + } + if (!of_property_read_u32(child, "k_po", &prop)) { + tzp->k_po = prop; + tzp->is_k_po_available = true; + } + if (!of_property_read_u32(child, "k_i", &prop)) { + tzp->k_i = prop; + tzp->is_k_i_available = true; + } for (i = 0; i < tz->ntrips; i++) mask |= 1 << i; diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c index d86450a142e9..ee475f5458c3 100644 --- a/drivers/thermal/power_allocator.c +++ b/drivers/thermal/power_allocator.c @@ -155,15 +155,15 @@ static void estimate_pid_constants(struct thermal_zone_device *tz, if (!temperature_threshold) return; - if (!tz->tzp->k_po || force) + if (!tz->tzp->is_k_po_available || force) tz->tzp->k_po = int_to_frac(sustainable_power) / temperature_threshold; - if (!tz->tzp->k_pu || force) + if (!tz->tzp->is_k_pu_available || force) tz->tzp->k_pu = int_to_frac(2 * sustainable_power) / temperature_threshold; - if (!tz->tzp->k_i || force) + if (!tz->tzp->is_k_i_available || force) tz->tzp->k_i = int_to_frac(10) / 1000; /* * The default for k_d and integral_cutoff is 0, so we can -- cgit v1.2.3