From 7ee882d39ef6f1ae77e70c2636b5578aa8df5895 Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Thu, 1 Jul 2021 11:27:37 +0800 Subject: [PATCH] Revert "soc: rockchip: system_monitor: change cdev state according to temperature" This reverts commit 72dc50cd924965988dd0593281ea801b669348dd. As the system monitor support changing thermal governor and managing cooling devices, there's no need to export system monitor devices to thermal framework. Change-Id: I2ee0314d6f3b342f2c7f41f7fafbb0074555759d Signed-off-by: Finley Xiao --- .../soc/rockchip/rockchip_system_monitor.c | 118 ++---------------- .../soc/rockchip/rockchip_system_monitor.h | 17 --- 2 files changed, 7 insertions(+), 128 deletions(-) diff --git a/drivers/soc/rockchip/rockchip_system_monitor.c b/drivers/soc/rockchip/rockchip_system_monitor.c index e2b0fabae09f..39fc7fc0915a 100644 --- a/drivers/soc/rockchip/rockchip_system_monitor.c +++ b/drivers/soc/rockchip/rockchip_system_monitor.c @@ -585,9 +585,12 @@ static int monitor_device_parse_wide_temp_config(struct device_node *np, else info->high_temp_max_volt = value; rockchip_init_temp_opp_table(info); - if (rockchip_get_temp_freq_table(np, "rockchip,high-temp-limit-table", - &info->high_limit_table)) { - info->high_limit_table = NULL; + rockchip_get_temp_freq_table(np, "rockchip,temp-freq-table", + &info->high_limit_table); + if (!info->high_limit_table) + rockchip_get_temp_freq_table(np, "rockchip,high-temp-limit-table", + &info->high_limit_table); + if (!info->high_limit_table) { if (!of_property_read_u32(np, "rockchip,high-temp-max-freq", &value)) { high_temp_max_freq = value * 1000; @@ -656,7 +659,6 @@ static int monitor_device_parse_dt(struct device *dev, int ret = 0; bool is_wide_temp_en = false; bool is_status_limit_en = false; - bool is_temp_freq_en = false; np = of_parse_phandle(dev->of_node, "operating-points-v2", 0); if (!np) @@ -666,10 +668,7 @@ static int monitor_device_parse_dt(struct device *dev, is_wide_temp_en = true; if (!monitor_device_parse_status_config(np, info)) is_status_limit_en = true; - if (!rockchip_get_temp_freq_table(np, "rockchip,temp-freq-table", - &info->temp_freq_table)) - is_temp_freq_en = true; - if (is_wide_temp_en || is_status_limit_en || is_temp_freq_en) + if (is_wide_temp_en || is_status_limit_en) ret = 0; else ret = -EINVAL; @@ -999,105 +998,6 @@ rockchip_system_monitor_freq_qos_requset(struct monitor_dev_info *info) return 0; } -static int monitor_set_freq_table(struct device *dev, - struct monitor_dev_info *info) -{ - struct dev_pm_opp *opp; - unsigned long *freq_table; - unsigned long rate; - int i, max_opps; - - max_opps = dev_pm_opp_get_opp_count(dev); - if (max_opps <= 0) - return -EINVAL; - - freq_table = kcalloc(max_opps, sizeof(*info->freq_table), GFP_KERNEL); - if (!freq_table) - return -ENOMEM; - - for (i = 0, rate = 0; i < max_opps; i++, rate++) { - opp = dev_pm_opp_find_freq_ceil(dev, &rate); - if (IS_ERR(opp)) { - kfree(freq_table); - return PTR_ERR(opp); - } - freq_table[i] = rate / 1000; - dev_pm_opp_put(opp); - } - - info->max_state = max_opps; - info->freq_table = freq_table; - - return 0; -} - -static unsigned long monitor_freq_to_state(struct monitor_dev_info *info, - unsigned long freq) -{ - unsigned long i = 0; - - if (!info->freq_table) { - dev_info(info->dev, "failed to get freq_table"); - return 0; - } - - for (i = 0; i < info->max_state; i++) { - if (freq >= info->freq_table[i]) - return i; - } - - return info->max_state - 1; -} - -static int monitor_temp_to_state(struct monitor_dev_info *info, - int temp, unsigned long *state) -{ - unsigned long target_state, target_freq = 0; - int i; - - if (temp == THERMAL_TEMP_INVALID) - return 0; - if (info->temp_freq_table) { - for (i = 0; info->temp_freq_table[i].freq != UINT_MAX; i++) { - if (temp > info->temp_freq_table[i].temp) - target_freq = info->temp_freq_table[i].freq; - } - if (target_freq) - *state = monitor_freq_to_state(info, - target_freq * 1000); - else - *state = 0; - } - - if (info->status_min_limit) { - target_freq = info->status_min_limit * 1000; - target_state = monitor_freq_to_state(info, target_freq); - if (*state > target_state) - *state = target_state; - } - - return 0; -} - -int -rockchip_system_monitor_adjust_cdev_state(struct thermal_cooling_device *cdev, - int temp, unsigned long *state) -{ - struct monitor_dev_info *info; - - down_read(&mdev_list_sem); - list_for_each_entry(info, &monitor_dev_list, node) { - if (cdev->np != info->dev->of_node) - continue; - monitor_temp_to_state(info, temp, state); - break; - } - up_read(&mdev_list_sem); - - return 0; -} -EXPORT_SYMBOL(rockchip_system_monitor_adjust_cdev_state); - static int rockchip_system_monitor_parse_supplies(struct device *dev, struct monitor_dev_info *info) { @@ -1221,9 +1121,6 @@ rockchip_system_monitor_register(struct device *dev, if (monitor_device_parse_dt(dev, info)) goto free_info; - if (monitor_set_freq_table(dev, info)) - goto free_info; - rockchip_system_monitor_wide_temp_init(info); if (rockchip_system_monitor_freq_qos_requset(info)) goto free_info; @@ -1259,7 +1156,6 @@ void rockchip_system_monitor_unregister(struct monitor_dev_info *info) kfree(info->low_temp_adjust_table); kfree(info->opp_table); - kfree(info->freq_table); kfree(info); } EXPORT_SYMBOL(rockchip_system_monitor_unregister); diff --git a/include/soc/rockchip/rockchip_system_monitor.h b/include/soc/rockchip/rockchip_system_monitor.h index 05d16a23f8d1..21d046e67709 100644 --- a/include/soc/rockchip/rockchip_system_monitor.h +++ b/include/soc/rockchip/rockchip_system_monitor.h @@ -44,8 +44,6 @@ struct temp_opp_table { * @opp_table: Frequency and voltage information of device * @devp: Device-specific system monitor profile * @node: Node in monitor_dev_list - * @temp_freq_table: Maximum frequency at different temperature and the - * frequency will not be changed by thermal framework. * @high_limit_table: Limit maximum frequency at different temperature, * but the frequency is also changed by thermal framework. * @volt_adjust_mutex: A mutex to protect changing voltage. @@ -69,8 +67,6 @@ struct temp_opp_table { * @reboot_freq: Limit maximum and minimum frequency when reboot, in KHz * @status_min_limit: Minimum frequency of some status frequency, in KHz * @status_max_limit: Minimum frequency of all status frequency, in KHz - * @freq_table: Optional list of frequencies in descending order - * @max_state: The size of freq_table * @low_temp: Low temperature trip point, in millicelsius * @high_temp: High temperature trip point, in millicelsius * @temp_hysteresis: A low hysteresis value on low_temp, in millicelsius @@ -86,7 +82,6 @@ struct monitor_dev_info { struct temp_opp_table *opp_table; struct monitor_dev_profile *devp; struct list_head node; - struct temp_freq_table *temp_freq_table; struct temp_freq_table *high_limit_table; struct mutex volt_adjust_mutex; struct freq_qos_request max_temp_freq_req; @@ -104,8 +99,6 @@ struct monitor_dev_info { unsigned int reboot_freq; unsigned int status_min_limit; unsigned int status_max_limit; - unsigned long *freq_table; - unsigned int max_state; int low_temp; int high_temp; int temp_hysteresis; @@ -140,9 +133,6 @@ int rockchip_monitor_dev_low_temp_adjust(struct monitor_dev_info *info, int rockchip_monitor_dev_high_temp_adjust(struct monitor_dev_info *info, bool is_high); int rockchip_monitor_suspend_low_temp_adjust(int cpu); -int -rockchip_system_monitor_adjust_cdev_state(struct thermal_cooling_device *cdev, - int temp, unsigned long *state); #else static inline struct monitor_dev_info * rockchip_system_monitor_register(struct device *dev, @@ -203,13 +193,6 @@ static inline int rockchip_monitor_suspend_low_temp_adjust(int cpu) return 0; }; -static inline int -rockchip_system_monitor_adjust_cdev_state(struct thermal_cooling_device *cdev, - int temp, unsigned long *state) -{ - return 0; -} - #endif /* CONFIG_ROCKCHIP_SYSTEM_MONITOR */ #endif