diff options
author | Finley Xiao <finley.xiao@rock-chips.com> | 2018-12-04 16:06:23 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2018-12-25 17:58:26 +0800 |
commit | f6ec026aa9916b08981b574416f555e2cdab6c66 (patch) | |
tree | 9676d1486ff91f6b2592d947f3d01cb173da117a | |
parent | d2f238a541a2f72c1bfed9f20cdcff84dcd5edcb (diff) |
thermal: power_allocator: Add support to get PID constant from dt
Change-Id: Ibabdad4ba2df6df26d75483dd35b6c51572befe8
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
-rw-r--r-- | drivers/thermal/of-thermal.c | 12 | ||||
-rw-r--r-- | drivers/thermal/power_allocator.c | 6 | ||||
-rw-r--r-- | include/linux/thermal.h | 6 |
3 files changed, 21 insertions, 3 deletions
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 diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 5b0718c850ce..e132714398c7 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -300,15 +300,21 @@ struct thermal_zone_params { */ s32 k_po; + bool is_k_po_available; + /* * Proportional parameter of the PID controller when * undershooting */ s32 k_pu; + bool is_k_pu_available; + /* Integral parameter of the PID controller */ s32 k_i; + bool is_k_i_available; + /* Derivative parameter of the PID controller */ s32 k_d; |