blob: cc6b84e4140499df4098457faa7d00087e826b96 [file] [log] [blame]
Daniel Lezcano0fac9e2f2019-04-28 11:51:04 +02001// SPDX-License-Identifier: GPL-2.0
Amit Daniel Kachhap02361412012-08-16 17:11:40 +05302/*
3 * linux/drivers/thermal/cpu_cooling.c
4 *
5 * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +05306 *
Daniel Lezcano42cd9b02019-04-28 11:51:03 +02007 * Copyright (C) 2012-2018 Linaro Limited.
8 *
9 * Authors: Amit Daniel <amit.kachhap@linaro.org>
10 * Viresh Kumar <viresh.kumar@linaro.org>
Viresh Kumar73904cb2014-12-04 09:42:08 +053011 *
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053012 */
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053013#include <linux/module.h>
14#include <linux/thermal.h>
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053015#include <linux/cpufreq.h>
16#include <linux/err.h>
Matthew Wilcoxae606082016-12-21 09:47:05 -080017#include <linux/idr.h>
Javi Merinoc36cf072015-02-26 19:00:29 +000018#include <linux/pm_opp.h>
Viresh Kumar51308022019-07-23 11:44:02 +053019#include <linux/pm_qos.h>
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053020#include <linux/slab.h>
21#include <linux/cpu.h>
22#include <linux/cpu_cooling.h>
23
Javi Merino6828a472015-03-02 17:17:20 +000024#include <trace/events/thermal.h>
25
Viresh Kumar07d888d2014-12-04 09:41:49 +053026/*
27 * Cooling state <-> CPUFreq frequency
28 *
29 * Cooling states are translated to frequencies throughout this driver and this
30 * is the relation between them.
31 *
32 * Highest cooling state corresponds to lowest possible frequency.
33 *
34 * i.e.
35 * level 0 --> 1st Max Freq
36 * level 1 --> 2nd Max Freq
37 * ...
38 */
39
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053040/**
Viresh Kumar349d39d2017-04-25 15:57:19 +053041 * struct freq_table - frequency table along with power entries
Javi Merinoc36cf072015-02-26 19:00:29 +000042 * @frequency: frequency in KHz
43 * @power: power in mW
44 *
45 * This structure is built when the cooling device registers and helps
Viresh Kumar349d39d2017-04-25 15:57:19 +053046 * in translating frequency to power and vice versa.
Javi Merinoc36cf072015-02-26 19:00:29 +000047 */
Viresh Kumar349d39d2017-04-25 15:57:19 +053048struct freq_table {
Javi Merinoc36cf072015-02-26 19:00:29 +000049 u32 frequency;
Quentin Perret5a4e5b72019-10-30 15:14:50 +000050#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
Javi Merinoc36cf072015-02-26 19:00:29 +000051 u32 power;
Quentin Perret5a4e5b72019-10-30 15:14:50 +000052#endif
Javi Merinoc36cf072015-02-26 19:00:29 +000053};
54
55/**
Viresh Kumar81ee14d2017-04-25 15:57:20 +053056 * struct time_in_idle - Idle time stats
57 * @time: previous reading of the absolute time that this cpu was idle
58 * @timestamp: wall time of the last invocation of get_cpu_idle_time_us()
59 */
60struct time_in_idle {
61 u64 time;
62 u64 timestamp;
63};
64
65/**
Eduardo Valentin3b3c0742013-04-17 17:11:56 +000066 * struct cpufreq_cooling_device - data for cooling device with cpufreq
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053067 * @id: unique integer value corresponding to each cpufreq_cooling_device
68 * registered.
Viresh Kumard72b4012017-04-25 15:57:24 +053069 * @last_load: load measured by the latest call to cpufreq_get_requested_power()
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053070 * @cpufreq_state: integer value representing the current state of cpufreq
71 * cooling devices.
Viresh Kumardcc6c7f2014-12-04 09:42:02 +053072 * @max_level: maximum cooling level. One less than total number of valid
73 * cpufreq frequencies.
Viresh Kumard72b4012017-04-25 15:57:24 +053074 * @freq_table: Freq table in descending order of frequencies
75 * @cdev: thermal_cooling_device pointer to keep track of the
76 * registered cooling device.
77 * @policy: cpufreq policy.
Javi Merinofc4de352014-12-15 16:55:52 +000078 * @node: list_head to link all cpufreq_cooling_device together.
Viresh Kumar81ee14d2017-04-25 15:57:20 +053079 * @idle_time: idle time stats
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053080 *
Viresh Kumarbeca6052014-12-04 09:41:48 +053081 * This structure is required for keeping information of each registered
82 * cpufreq_cooling_device.
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053083 */
84struct cpufreq_cooling_device {
85 int id;
Viresh Kumard72b4012017-04-25 15:57:24 +053086 u32 last_load;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053087 unsigned int cpufreq_state;
Viresh Kumardcc6c7f2014-12-04 09:42:02 +053088 unsigned int max_level;
Viresh Kumar349d39d2017-04-25 15:57:19 +053089 struct freq_table *freq_table; /* In descending order */
Viresh Kumard72b4012017-04-25 15:57:24 +053090 struct cpufreq_policy *policy;
Yadwinder Singh Brar2dcd8512014-11-07 19:12:29 +053091 struct list_head node;
Viresh Kumar81ee14d2017-04-25 15:57:20 +053092 struct time_in_idle *idle_time;
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +020093 struct freq_qos_request qos_req;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053094};
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053095
Viresh Kumarfb8ea302017-04-25 15:57:09 +053096static DEFINE_IDA(cpufreq_ida);
Russell King02373d72015-08-12 15:22:16 +053097static DEFINE_MUTEX(cooling_list_lock);
Viresh Kumar1dea4322017-04-25 15:57:10 +053098static LIST_HEAD(cpufreq_cdev_list);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053099
Quentin Perret5a4e5b72019-10-30 15:14:50 +0000100#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530101/**
Viresh Kumar4843c4a2014-12-04 09:42:07 +0530102 * get_level: Find the level for a particular frequency
Viresh Kumar1dea4322017-04-25 15:57:10 +0530103 * @cpufreq_cdev: cpufreq_cdev for which the property is required
Viresh Kumar4843c4a2014-12-04 09:42:07 +0530104 * @freq: Frequency
Eduardo Valentin82b9ee42013-04-17 17:12:00 +0000105 *
Viresh Kumarda27f692017-04-25 15:57:21 +0530106 * Return: level corresponding to the frequency.
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530107 */
Viresh Kumar1dea4322017-04-25 15:57:10 +0530108static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev,
Viresh Kumar4843c4a2014-12-04 09:42:07 +0530109 unsigned int freq)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530110{
Viresh Kumarda27f692017-04-25 15:57:21 +0530111 struct freq_table *freq_table = cpufreq_cdev->freq_table;
Viresh Kumar4843c4a2014-12-04 09:42:07 +0530112 unsigned long level;
Eduardo Valentin79491e52013-04-17 17:11:59 +0000113
Viresh Kumarda27f692017-04-25 15:57:21 +0530114 for (level = 1; level <= cpufreq_cdev->max_level; level++)
115 if (freq > freq_table[level].frequency)
Viresh Kumar4843c4a2014-12-04 09:42:07 +0530116 break;
Zhang Ruia1167762014-01-02 11:57:48 +0800117
Viresh Kumarda27f692017-04-25 15:57:21 +0530118 return level - 1;
Zhang Ruifc35b352013-02-08 13:09:32 +0800119}
120
Eduardo Valentin44952d32013-04-17 17:12:05 +0000121/**
Viresh Kumar349d39d2017-04-25 15:57:19 +0530122 * update_freq_table() - Update the freq table with power numbers
123 * @cpufreq_cdev: the cpufreq cooling device in which to update the table
Javi Merinoc36cf072015-02-26 19:00:29 +0000124 * @capacitance: dynamic power coefficient for these cpus
125 *
Viresh Kumar349d39d2017-04-25 15:57:19 +0530126 * Update the freq table with power numbers. This table will be used in
127 * cpu_power_to_freq() and cpu_freq_to_power() to convert between power and
128 * frequency efficiently. Power is stored in mW, frequency in KHz. The
129 * resulting table is in descending order.
Javi Merinoc36cf072015-02-26 19:00:29 +0000130 *
Javi Merino459ac372015-08-17 19:21:42 +0100131 * Return: 0 on success, -EINVAL if there are no OPPs for any CPUs,
Viresh Kumar349d39d2017-04-25 15:57:19 +0530132 * or -ENOMEM if we run out of memory.
Javi Merinoc36cf072015-02-26 19:00:29 +0000133 */
Viresh Kumar349d39d2017-04-25 15:57:19 +0530134static int update_freq_table(struct cpufreq_cooling_device *cpufreq_cdev,
135 u32 capacitance)
Javi Merinoc36cf072015-02-26 19:00:29 +0000136{
Viresh Kumar349d39d2017-04-25 15:57:19 +0530137 struct freq_table *freq_table = cpufreq_cdev->freq_table;
Javi Merinoc36cf072015-02-26 19:00:29 +0000138 struct dev_pm_opp *opp;
139 struct device *dev = NULL;
Viresh Kumar349d39d2017-04-25 15:57:19 +0530140 int num_opps = 0, cpu = cpufreq_cdev->policy->cpu, i;
Javi Merinoc36cf072015-02-26 19:00:29 +0000141
Viresh Kumar02bacb22017-04-25 15:57:17 +0530142 dev = get_cpu_device(cpu);
143 if (unlikely(!dev)) {
Daniel Lezcano72554a72019-04-28 11:51:05 +0200144 pr_warn("No cpu device for cpu %d\n", cpu);
Viresh Kumar02bacb22017-04-25 15:57:17 +0530145 return -ENODEV;
Javi Merinoc36cf072015-02-26 19:00:29 +0000146 }
147
Viresh Kumar02bacb22017-04-25 15:57:17 +0530148 num_opps = dev_pm_opp_get_opp_count(dev);
149 if (num_opps < 0)
150 return num_opps;
151
Viresh Kumar349d39d2017-04-25 15:57:19 +0530152 /*
153 * The cpufreq table is also built from the OPP table and so the count
154 * should match.
155 */
156 if (num_opps != cpufreq_cdev->max_level + 1) {
157 dev_warn(dev, "Number of OPPs not matching with max_levels\n");
Javi Merino459ac372015-08-17 19:21:42 +0100158 return -EINVAL;
Viresh Kumar349d39d2017-04-25 15:57:19 +0530159 }
Javi Merinoc36cf072015-02-26 19:00:29 +0000160
Viresh Kumar349d39d2017-04-25 15:57:19 +0530161 for (i = 0; i <= cpufreq_cdev->max_level; i++) {
162 unsigned long freq = freq_table[i].frequency * 1000;
163 u32 freq_mhz = freq_table[i].frequency / 1000;
Javi Merinoc36cf072015-02-26 19:00:29 +0000164 u64 power;
Viresh Kumar349d39d2017-04-25 15:57:19 +0530165 u32 voltage_mv;
Javi Merinoc36cf072015-02-26 19:00:29 +0000166
Viresh Kumar349d39d2017-04-25 15:57:19 +0530167 /*
168 * Find ceil frequency as 'freq' may be slightly lower than OPP
169 * freq due to truncation while converting to kHz.
170 */
171 opp = dev_pm_opp_find_freq_ceil(dev, &freq);
172 if (IS_ERR(opp)) {
173 dev_err(dev, "failed to get opp for %lu frequency\n",
174 freq);
175 return -EINVAL;
Javi Merino459ac372015-08-17 19:21:42 +0100176 }
177
Javi Merinoc36cf072015-02-26 19:00:29 +0000178 voltage_mv = dev_pm_opp_get_voltage(opp) / 1000;
Viresh Kumar8a31d9d92017-01-23 10:11:47 +0530179 dev_pm_opp_put(opp);
Javi Merinoc36cf072015-02-26 19:00:29 +0000180
181 /*
182 * Do the multiplication with MHz and millivolt so as
183 * to not overflow.
184 */
185 power = (u64)capacitance * freq_mhz * voltage_mv * voltage_mv;
186 do_div(power, 1000000000);
187
Javi Merinoc36cf072015-02-26 19:00:29 +0000188 /* power is stored in mW */
Viresh Kumar349d39d2017-04-25 15:57:19 +0530189 freq_table[i].power = power;
Javi Merinoeba4f882015-08-17 19:21:43 +0100190 }
Javi Merinoc36cf072015-02-26 19:00:29 +0000191
Javi Merino459ac372015-08-17 19:21:42 +0100192 return 0;
Javi Merinoc36cf072015-02-26 19:00:29 +0000193}
194
Viresh Kumar1dea4322017-04-25 15:57:10 +0530195static u32 cpu_freq_to_power(struct cpufreq_cooling_device *cpufreq_cdev,
Javi Merinoc36cf072015-02-26 19:00:29 +0000196 u32 freq)
197{
198 int i;
Viresh Kumar349d39d2017-04-25 15:57:19 +0530199 struct freq_table *freq_table = cpufreq_cdev->freq_table;
Javi Merinoc36cf072015-02-26 19:00:29 +0000200
Viresh Kumar349d39d2017-04-25 15:57:19 +0530201 for (i = 1; i <= cpufreq_cdev->max_level; i++)
202 if (freq > freq_table[i].frequency)
Javi Merinoc36cf072015-02-26 19:00:29 +0000203 break;
204
Viresh Kumar349d39d2017-04-25 15:57:19 +0530205 return freq_table[i - 1].power;
Javi Merinoc36cf072015-02-26 19:00:29 +0000206}
207
Viresh Kumar1dea4322017-04-25 15:57:10 +0530208static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev,
Javi Merinoc36cf072015-02-26 19:00:29 +0000209 u32 power)
210{
211 int i;
Viresh Kumar349d39d2017-04-25 15:57:19 +0530212 struct freq_table *freq_table = cpufreq_cdev->freq_table;
Javi Merinoc36cf072015-02-26 19:00:29 +0000213
Viresh Kumar349d39d2017-04-25 15:57:19 +0530214 for (i = 1; i <= cpufreq_cdev->max_level; i++)
215 if (power > freq_table[i].power)
Javi Merinoc36cf072015-02-26 19:00:29 +0000216 break;
217
Viresh Kumar349d39d2017-04-25 15:57:19 +0530218 return freq_table[i - 1].frequency;
Javi Merinoc36cf072015-02-26 19:00:29 +0000219}
220
221/**
222 * get_load() - get load for a cpu since last updated
Viresh Kumar1dea4322017-04-25 15:57:10 +0530223 * @cpufreq_cdev: &struct cpufreq_cooling_device for this cpu
Javi Merinoc36cf072015-02-26 19:00:29 +0000224 * @cpu: cpu number
Viresh Kumarba76dd92017-04-25 15:57:18 +0530225 * @cpu_idx: index of the cpu in time_in_idle*
Javi Merinoc36cf072015-02-26 19:00:29 +0000226 *
227 * Return: The average load of cpu @cpu in percentage since this
228 * function was last called.
229 */
Viresh Kumar1dea4322017-04-25 15:57:10 +0530230static u32 get_load(struct cpufreq_cooling_device *cpufreq_cdev, int cpu,
Javi Merinoa53b8392016-02-11 12:00:51 +0000231 int cpu_idx)
Javi Merinoc36cf072015-02-26 19:00:29 +0000232{
233 u32 load;
234 u64 now, now_idle, delta_time, delta_idle;
Viresh Kumar81ee14d2017-04-25 15:57:20 +0530235 struct time_in_idle *idle_time = &cpufreq_cdev->idle_time[cpu_idx];
Javi Merinoc36cf072015-02-26 19:00:29 +0000236
237 now_idle = get_cpu_idle_time(cpu, &now, 0);
Viresh Kumar81ee14d2017-04-25 15:57:20 +0530238 delta_idle = now_idle - idle_time->time;
239 delta_time = now - idle_time->timestamp;
Javi Merinoc36cf072015-02-26 19:00:29 +0000240
241 if (delta_time <= delta_idle)
242 load = 0;
243 else
244 load = div64_u64(100 * (delta_time - delta_idle), delta_time);
245
Viresh Kumar81ee14d2017-04-25 15:57:20 +0530246 idle_time->time = now_idle;
247 idle_time->timestamp = now;
Javi Merinoc36cf072015-02-26 19:00:29 +0000248
249 return load;
250}
251
252/**
Javi Merinoc36cf072015-02-26 19:00:29 +0000253 * get_dynamic_power() - calculate the dynamic power
Viresh Kumar1dea4322017-04-25 15:57:10 +0530254 * @cpufreq_cdev: &cpufreq_cooling_device for this cdev
Javi Merinoc36cf072015-02-26 19:00:29 +0000255 * @freq: current frequency
256 *
257 * Return: the dynamic power consumed by the cpus described by
Viresh Kumar1dea4322017-04-25 15:57:10 +0530258 * @cpufreq_cdev.
Javi Merinoc36cf072015-02-26 19:00:29 +0000259 */
Viresh Kumar1dea4322017-04-25 15:57:10 +0530260static u32 get_dynamic_power(struct cpufreq_cooling_device *cpufreq_cdev,
Javi Merinoc36cf072015-02-26 19:00:29 +0000261 unsigned long freq)
262{
263 u32 raw_cpu_power;
264
Viresh Kumar1dea4322017-04-25 15:57:10 +0530265 raw_cpu_power = cpu_freq_to_power(cpufreq_cdev, freq);
266 return (raw_cpu_power * cpufreq_cdev->last_load) / 100;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530267}
268
Javi Merinoc36cf072015-02-26 19:00:29 +0000269/**
270 * cpufreq_get_requested_power() - get the current power
271 * @cdev: &thermal_cooling_device pointer
272 * @tz: a valid thermal zone device pointer
273 * @power: pointer in which to store the resulting power
274 *
275 * Calculate the current power consumption of the cpus in milliwatts
276 * and store it in @power. This function should actually calculate
277 * the requested power, but it's hard to get the frequency that
278 * cpufreq would have assigned if there were no thermal limits.
279 * Instead, we calculate the current power on the assumption that the
280 * immediate future will look like the immediate past.
281 *
282 * We use the current frequency and the average load since this
283 * function was last called. In reality, there could have been
284 * multiple opps since this function was last called and that affects
285 * the load calculation. While it's not perfectly accurate, this
286 * simplification is good enough and works. REVISIT this, as more
287 * complex code may be needed if experiments show that it's not
288 * accurate enough.
289 *
290 * Return: 0 on success, -E* if getting the static power failed.
291 */
292static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
293 struct thermal_zone_device *tz,
294 u32 *power)
295{
296 unsigned long freq;
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530297 int i = 0, cpu;
298 u32 total_load = 0;
Viresh Kumar1dea4322017-04-25 15:57:10 +0530299 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
Viresh Kumarba76dd92017-04-25 15:57:18 +0530300 struct cpufreq_policy *policy = cpufreq_cdev->policy;
Javi Merino6828a472015-03-02 17:17:20 +0000301 u32 *load_cpu = NULL;
Javi Merinoc36cf072015-02-26 19:00:29 +0000302
Viresh Kumarba76dd92017-04-25 15:57:18 +0530303 freq = cpufreq_quick_get(policy->cpu);
Javi Merinoc36cf072015-02-26 19:00:29 +0000304
Javi Merino6828a472015-03-02 17:17:20 +0000305 if (trace_thermal_power_cpu_get_power_enabled()) {
Viresh Kumarba76dd92017-04-25 15:57:18 +0530306 u32 ncpus = cpumask_weight(policy->related_cpus);
Javi Merino6828a472015-03-02 17:17:20 +0000307
Vaishali Thakkara71544c2015-08-19 11:52:19 +0530308 load_cpu = kcalloc(ncpus, sizeof(*load_cpu), GFP_KERNEL);
Javi Merino6828a472015-03-02 17:17:20 +0000309 }
310
Viresh Kumarba76dd92017-04-25 15:57:18 +0530311 for_each_cpu(cpu, policy->related_cpus) {
Javi Merinoc36cf072015-02-26 19:00:29 +0000312 u32 load;
313
314 if (cpu_online(cpu))
Viresh Kumar1dea4322017-04-25 15:57:10 +0530315 load = get_load(cpufreq_cdev, cpu, i);
Javi Merinoc36cf072015-02-26 19:00:29 +0000316 else
317 load = 0;
318
319 total_load += load;
Matthias Kaehlckebf45ac12019-05-02 11:32:38 -0700320 if (load_cpu)
Javi Merino6828a472015-03-02 17:17:20 +0000321 load_cpu[i] = load;
322
323 i++;
Javi Merinoc36cf072015-02-26 19:00:29 +0000324 }
325
Viresh Kumar1dea4322017-04-25 15:57:10 +0530326 cpufreq_cdev->last_load = total_load;
Javi Merinoc36cf072015-02-26 19:00:29 +0000327
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530328 *power = get_dynamic_power(cpufreq_cdev, freq);
Javi Merino6828a472015-03-02 17:17:20 +0000329
330 if (load_cpu) {
Viresh Kumarba76dd92017-04-25 15:57:18 +0530331 trace_thermal_power_cpu_get_power(policy->related_cpus, freq,
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530332 load_cpu, i, *power);
Javi Merino6828a472015-03-02 17:17:20 +0000333
Vaishali Thakkara71544c2015-08-19 11:52:19 +0530334 kfree(load_cpu);
Javi Merino6828a472015-03-02 17:17:20 +0000335 }
Javi Merinoc36cf072015-02-26 19:00:29 +0000336
Javi Merinoc36cf072015-02-26 19:00:29 +0000337 return 0;
338}
339
340/**
341 * cpufreq_state2power() - convert a cpu cdev state to power consumed
342 * @cdev: &thermal_cooling_device pointer
343 * @tz: a valid thermal zone device pointer
344 * @state: cooling device state to be converted
345 * @power: pointer in which to store the resulting power
346 *
347 * Convert cooling device state @state into power consumption in
348 * milliwatts assuming 100% load. Store the calculated power in
349 * @power.
350 *
351 * Return: 0 on success, -EINVAL if the cooling device state could not
352 * be converted into a frequency or other -E* if there was an error
353 * when calculating the static power.
354 */
355static int cpufreq_state2power(struct thermal_cooling_device *cdev,
356 struct thermal_zone_device *tz,
357 unsigned long state, u32 *power)
358{
359 unsigned int freq, num_cpus;
Viresh Kumar1dea4322017-04-25 15:57:10 +0530360 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
Javi Merinoc36cf072015-02-26 19:00:29 +0000361
Viresh Kumarcb1b6312017-04-25 15:57:23 +0530362 /* Request state should be less than max_level */
363 if (WARN_ON(state > cpufreq_cdev->max_level))
364 return -EINVAL;
365
Viresh Kumarba76dd92017-04-25 15:57:18 +0530366 num_cpus = cpumask_weight(cpufreq_cdev->policy->cpus);
Javi Merinoc36cf072015-02-26 19:00:29 +0000367
Viresh Kumar349d39d2017-04-25 15:57:19 +0530368 freq = cpufreq_cdev->freq_table[state].frequency;
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530369 *power = cpu_freq_to_power(cpufreq_cdev, freq) * num_cpus;
Javi Merinoc36cf072015-02-26 19:00:29 +0000370
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530371 return 0;
Javi Merinoc36cf072015-02-26 19:00:29 +0000372}
373
374/**
375 * cpufreq_power2state() - convert power to a cooling device state
376 * @cdev: &thermal_cooling_device pointer
377 * @tz: a valid thermal zone device pointer
378 * @power: power in milliwatts to be converted
379 * @state: pointer in which to store the resulting state
380 *
381 * Calculate a cooling device state for the cpus described by @cdev
382 * that would allow them to consume at most @power mW and store it in
383 * @state. Note that this calculation depends on external factors
384 * such as the cpu load or the current static power. Calling this
385 * function with the same power as input can yield different cooling
386 * device states depending on those external factors.
387 *
388 * Return: 0 on success, -ENODEV if no cpus are online or -EINVAL if
389 * the calculated frequency could not be converted to a valid state.
390 * The latter should not happen unless the frequencies available to
391 * cpufreq have changed since the initialization of the cpu cooling
392 * device.
393 */
394static int cpufreq_power2state(struct thermal_cooling_device *cdev,
395 struct thermal_zone_device *tz, u32 power,
396 unsigned long *state)
397{
Shaokun Zhange0fda732019-02-18 14:22:30 +0800398 unsigned int target_freq;
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530399 u32 last_load, normalised_power;
Viresh Kumar1dea4322017-04-25 15:57:10 +0530400 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
Viresh Kumarba76dd92017-04-25 15:57:18 +0530401 struct cpufreq_policy *policy = cpufreq_cdev->policy;
Javi Merinoc36cf072015-02-26 19:00:29 +0000402
Viresh Kumar1dea4322017-04-25 15:57:10 +0530403 last_load = cpufreq_cdev->last_load ?: 1;
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530404 normalised_power = (power * 100) / last_load;
Viresh Kumar1dea4322017-04-25 15:57:10 +0530405 target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power);
Javi Merinoc36cf072015-02-26 19:00:29 +0000406
Viresh Kumar3e08b2d2017-04-25 15:57:12 +0530407 *state = get_level(cpufreq_cdev, target_freq);
Viresh Kumarba76dd92017-04-25 15:57:18 +0530408 trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state,
409 power);
Javi Merinoc36cf072015-02-26 19:00:29 +0000410 return 0;
411}
Quentin Perret5a4e5b72019-10-30 15:14:50 +0000412#endif /* CONFIG_THERMAL_GOV_POWER_ALLOCATOR */
413
414/* cpufreq cooling device callback functions are defined below */
415
416/**
417 * cpufreq_get_max_state - callback function to get the max cooling state.
418 * @cdev: thermal cooling device pointer.
419 * @state: fill this variable with the max cooling state.
420 *
421 * Callback for the thermal cooling device to return the cpufreq
422 * max cooling state.
423 *
424 * Return: 0 on success, an error code otherwise.
425 */
426static int cpufreq_get_max_state(struct thermal_cooling_device *cdev,
427 unsigned long *state)
428{
429 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
430
431 *state = cpufreq_cdev->max_level;
432 return 0;
433}
434
435/**
436 * cpufreq_get_cur_state - callback function to get the current cooling state.
437 * @cdev: thermal cooling device pointer.
438 * @state: fill this variable with the current cooling state.
439 *
440 * Callback for the thermal cooling device to return the cpufreq
441 * current cooling state.
442 *
443 * Return: 0 on success, an error code otherwise.
444 */
445static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev,
446 unsigned long *state)
447{
448 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
449
450 *state = cpufreq_cdev->cpufreq_state;
451
452 return 0;
453}
454
455/**
456 * cpufreq_set_cur_state - callback function to set the current cooling state.
457 * @cdev: thermal cooling device pointer.
458 * @state: set this variable to the current cooling state.
459 *
460 * Callback for the thermal cooling device to change the cpufreq
461 * current cooling state.
462 *
463 * Return: 0 on success, an error code otherwise.
464 */
465static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
466 unsigned long state)
467{
468 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
469
470 /* Request state should be less than max_level */
471 if (WARN_ON(state > cpufreq_cdev->max_level))
472 return -EINVAL;
473
474 /* Check if the old cooling action is same as new cooling action */
475 if (cpufreq_cdev->cpufreq_state == state)
476 return 0;
477
478 cpufreq_cdev->cpufreq_state = state;
479
480 return freq_qos_update_request(&cpufreq_cdev->qos_req,
481 cpufreq_cdev->freq_table[state].frequency);
482}
Javi Merinoc36cf072015-02-26 19:00:29 +0000483
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530484/* Bind cpufreq callbacks to thermal cooling device ops */
Brendan Jackmana305a432016-08-17 16:14:59 +0100485
Javi Merinoc36cf072015-02-26 19:00:29 +0000486static struct thermal_cooling_device_ops cpufreq_cooling_ops = {
Brendan Jackmana305a432016-08-17 16:14:59 +0100487 .get_max_state = cpufreq_get_max_state,
488 .get_cur_state = cpufreq_get_cur_state,
489 .set_cur_state = cpufreq_set_cur_state,
Brendan Jackmana305a432016-08-17 16:14:59 +0100490};
491
Viresh Kumarf6859012014-12-04 09:42:06 +0530492static unsigned int find_next_max(struct cpufreq_frequency_table *table,
493 unsigned int prev_max)
494{
495 struct cpufreq_frequency_table *pos;
496 unsigned int max = 0;
497
498 cpufreq_for_each_valid_entry(pos, table) {
499 if (pos->frequency > max && pos->frequency < prev_max)
500 max = pos->frequency;
501 }
502
503 return max;
504}
505
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530506/**
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400507 * __cpufreq_cooling_register - helper function to create cpufreq cooling device
508 * @np: a valid struct device_node to the cooling device device tree node
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530509 * @policy: cpufreq policy
Viresh Kumar405fb822014-12-04 09:41:55 +0530510 * Normally this should be same as cpufreq policy->related_cpus.
Javi Merinoc36cf072015-02-26 19:00:29 +0000511 * @capacitance: dynamic power coefficient for these cpus
Eduardo Valentin12cb08b2013-04-17 17:12:15 +0000512 *
513 * This interface function registers the cpufreq cooling device with the name
514 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400515 * cooling devices. It also gives the opportunity to link the cooling device
516 * with a device tree node, in order to bind it via the thermal DT code.
Eduardo Valentin12cb08b2013-04-17 17:12:15 +0000517 *
518 * Return: a valid struct thermal_cooling_device pointer on success,
519 * on failure, it returns a corresponding ERR_PTR().
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530520 */
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400521static struct thermal_cooling_device *
522__cpufreq_cooling_register(struct device_node *np,
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530523 struct cpufreq_policy *policy, u32 capacitance)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530524{
Viresh Kumar04bdbdf2017-04-25 15:57:11 +0530525 struct thermal_cooling_device *cdev;
Viresh Kumar1dea4322017-04-25 15:57:10 +0530526 struct cpufreq_cooling_device *cpufreq_cdev;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530527 char dev_name[THERMAL_NAME_LENGTH];
Javi Merinoc36cf072015-02-26 19:00:29 +0000528 unsigned int freq, i, num_cpus;
Viresh Kumar51308022019-07-23 11:44:02 +0530529 struct device *dev;
Viresh Kumar405fb822014-12-04 09:41:55 +0530530 int ret;
Brendan Jackmana305a432016-08-17 16:14:59 +0100531 struct thermal_cooling_device_ops *cooling_ops;
Viresh Kumar51308022019-07-23 11:44:02 +0530532
533 dev = get_cpu_device(policy->cpu);
534 if (unlikely(!dev)) {
535 pr_warn("No cpu device for cpu %d\n", policy->cpu);
536 return ERR_PTR(-ENODEV);
537 }
538
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530539
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530540 if (IS_ERR_OR_NULL(policy)) {
Arvind Yadavb2fd7082017-10-24 13:20:39 +0530541 pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530542 return ERR_PTR(-EINVAL);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530543 }
Eduardo Valentin0f1be512014-12-04 09:41:43 +0530544
Viresh Kumar55d85292017-04-25 15:57:15 +0530545 i = cpufreq_table_count_valid_entries(policy);
546 if (!i) {
547 pr_debug("%s: CPUFreq table not found or has no valid entries\n",
548 __func__);
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530549 return ERR_PTR(-ENODEV);
Viresh Kumarf8bfc112016-06-03 10:58:47 +0530550 }
551
Viresh Kumar1dea4322017-04-25 15:57:10 +0530552 cpufreq_cdev = kzalloc(sizeof(*cpufreq_cdev), GFP_KERNEL);
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530553 if (!cpufreq_cdev)
554 return ERR_PTR(-ENOMEM);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530555
Viresh Kumarb12b6512017-04-25 15:57:16 +0530556 cpufreq_cdev->policy = policy;
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530557 num_cpus = cpumask_weight(policy->related_cpus);
Viresh Kumar81ee14d2017-04-25 15:57:20 +0530558 cpufreq_cdev->idle_time = kcalloc(num_cpus,
559 sizeof(*cpufreq_cdev->idle_time),
560 GFP_KERNEL);
561 if (!cpufreq_cdev->idle_time) {
Viresh Kumar04bdbdf2017-04-25 15:57:11 +0530562 cdev = ERR_PTR(-ENOMEM);
Javi Merinoc36cf072015-02-26 19:00:29 +0000563 goto free_cdev;
564 }
565
Viresh Kumar55d85292017-04-25 15:57:15 +0530566 /* max_level is an index, not a counter */
567 cpufreq_cdev->max_level = i - 1;
Viresh Kumardcc6c7f2014-12-04 09:42:02 +0530568
Viresh Kumarf19b1a12017-05-23 12:33:06 +0530569 cpufreq_cdev->freq_table = kmalloc_array(i,
570 sizeof(*cpufreq_cdev->freq_table),
571 GFP_KERNEL);
Viresh Kumar1dea4322017-04-25 15:57:10 +0530572 if (!cpufreq_cdev->freq_table) {
Viresh Kumar04bdbdf2017-04-25 15:57:11 +0530573 cdev = ERR_PTR(-ENOMEM);
Viresh Kumar81ee14d2017-04-25 15:57:20 +0530574 goto free_idle_time;
Viresh Kumarf6859012014-12-04 09:42:06 +0530575 }
576
Matthew Wilcoxae606082016-12-21 09:47:05 -0800577 ret = ida_simple_get(&cpufreq_ida, 0, 0, GFP_KERNEL);
578 if (ret < 0) {
Viresh Kumar04bdbdf2017-04-25 15:57:11 +0530579 cdev = ERR_PTR(ret);
Viresh Kumar349d39d2017-04-25 15:57:19 +0530580 goto free_table;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530581 }
Viresh Kumar1dea4322017-04-25 15:57:10 +0530582 cpufreq_cdev->id = ret;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530583
Viresh Kumar349d39d2017-04-25 15:57:19 +0530584 snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
585 cpufreq_cdev->id);
586
Viresh Kumarf6859012014-12-04 09:42:06 +0530587 /* Fill freq-table in descending order of frequencies */
Viresh Kumar1dea4322017-04-25 15:57:10 +0530588 for (i = 0, freq = -1; i <= cpufreq_cdev->max_level; i++) {
Viresh Kumar55d85292017-04-25 15:57:15 +0530589 freq = find_next_max(policy->freq_table, freq);
Viresh Kumar349d39d2017-04-25 15:57:19 +0530590 cpufreq_cdev->freq_table[i].frequency = freq;
Viresh Kumarf6859012014-12-04 09:42:06 +0530591
592 /* Warn for duplicate entries */
593 if (!freq)
594 pr_warn("%s: table has duplicate entries\n", __func__);
595 else
596 pr_debug("%s: freq:%u KHz\n", __func__, freq);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530597 }
Viresh Kumarf6859012014-12-04 09:42:06 +0530598
Quentin Perret5a4e5b72019-10-30 15:14:50 +0000599 cooling_ops = &cpufreq_cooling_ops;
600
601#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR
Viresh Kumar349d39d2017-04-25 15:57:19 +0530602 if (capacitance) {
Viresh Kumar349d39d2017-04-25 15:57:19 +0530603 ret = update_freq_table(cpufreq_cdev, capacitance);
604 if (ret) {
605 cdev = ERR_PTR(ret);
606 goto remove_ida;
607 }
Quentin Perret5a4e5b72019-10-30 15:14:50 +0000608 cooling_ops->get_requested_power = cpufreq_get_requested_power;
609 cooling_ops->state2power = cpufreq_state2power;
610 cooling_ops->power2state = cpufreq_power2state;
Viresh Kumar349d39d2017-04-25 15:57:19 +0530611 }
Quentin Perret5a4e5b72019-10-30 15:14:50 +0000612#endif
Lukasz Lubaf840ab12016-05-31 11:32:02 +0100613
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +0200614 ret = freq_qos_add_request(&policy->constraints,
615 &cpufreq_cdev->qos_req, FREQ_QOS_MAX,
616 cpufreq_cdev->freq_table[0].frequency);
Viresh Kumar51308022019-07-23 11:44:02 +0530617 if (ret < 0) {
618 pr_err("%s: Failed to add freq constraint (%d)\n", __func__,
619 ret);
620 cdev = ERR_PTR(ret);
621 goto remove_ida;
622 }
623
Viresh Kumar04bdbdf2017-04-25 15:57:11 +0530624 cdev = thermal_of_cooling_device_register(np, dev_name, cpufreq_cdev,
625 cooling_ops);
626 if (IS_ERR(cdev))
Viresh Kumar51308022019-07-23 11:44:02 +0530627 goto remove_qos_req;
Viresh Kumar92e615e2014-12-04 09:41:51 +0530628
Russell King02373d72015-08-12 15:22:16 +0530629 mutex_lock(&cooling_list_lock);
Viresh Kumar1dea4322017-04-25 15:57:10 +0530630 list_add(&cpufreq_cdev->node, &cpufreq_cdev_list);
Matthew Wilcox088db932017-03-10 18:33:28 +0000631 mutex_unlock(&cooling_list_lock);
632
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530633 return cdev;
Viresh Kumar730abe02014-12-04 09:41:58 +0530634
Viresh Kumar51308022019-07-23 11:44:02 +0530635remove_qos_req:
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +0200636 freq_qos_remove_request(&cpufreq_cdev->qos_req);
Matthew Wilcoxae606082016-12-21 09:47:05 -0800637remove_ida:
Viresh Kumar1dea4322017-04-25 15:57:10 +0530638 ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id);
Viresh Kumarf6859012014-12-04 09:42:06 +0530639free_table:
Viresh Kumar1dea4322017-04-25 15:57:10 +0530640 kfree(cpufreq_cdev->freq_table);
Viresh Kumar81ee14d2017-04-25 15:57:20 +0530641free_idle_time:
642 kfree(cpufreq_cdev->idle_time);
Viresh Kumar730abe02014-12-04 09:41:58 +0530643free_cdev:
Viresh Kumar1dea4322017-04-25 15:57:10 +0530644 kfree(cpufreq_cdev);
Viresh Kumar04bdbdf2017-04-25 15:57:11 +0530645 return cdev;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530646}
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400647
648/**
649 * cpufreq_cooling_register - function to create cpufreq cooling device.
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530650 * @policy: cpufreq policy
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400651 *
652 * This interface function registers the cpufreq cooling device with the name
653 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
654 * cooling devices.
655 *
656 * Return: a valid struct thermal_cooling_device pointer on success,
657 * on failure, it returns a corresponding ERR_PTR().
658 */
659struct thermal_cooling_device *
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530660cpufreq_cooling_register(struct cpufreq_policy *policy)
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400661{
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530662 return __cpufreq_cooling_register(NULL, policy, 0);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400663}
Eduardo Valentin243dbd92013-04-17 17:11:57 +0000664EXPORT_SYMBOL_GPL(cpufreq_cooling_register);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530665
666/**
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400667 * of_cpufreq_cooling_register - function to create cpufreq cooling device.
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530668 * @policy: cpufreq policy
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400669 *
670 * This interface function registers the cpufreq cooling device with the name
671 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
672 * cooling devices. Using this API, the cpufreq cooling device will be
673 * linked to the device tree node provided.
674 *
Javi Merinoc36cf072015-02-26 19:00:29 +0000675 * Using this function, the cooling device will implement the power
676 * extensions by using a simple cpu power model. The cpus must have
677 * registered their OPPs using the OPP library.
678 *
Viresh Kumarf5f263f2017-12-05 11:02:43 +0530679 * It also takes into account, if property present in policy CPU node, the
680 * static power consumed by the cpu.
Javi Merinoc36cf072015-02-26 19:00:29 +0000681 *
682 * Return: a valid struct thermal_cooling_device pointer on success,
Viresh Kumarf5f263f2017-12-05 11:02:43 +0530683 * and NULL on failure.
Javi Merinoc36cf072015-02-26 19:00:29 +0000684 */
685struct thermal_cooling_device *
Viresh Kumar3ebb62f2017-12-05 11:02:45 +0530686of_cpufreq_cooling_register(struct cpufreq_policy *policy)
Javi Merinoc36cf072015-02-26 19:00:29 +0000687{
Viresh Kumarf5f263f2017-12-05 11:02:43 +0530688 struct device_node *np = of_get_cpu_node(policy->cpu, NULL);
689 struct thermal_cooling_device *cdev = NULL;
690 u32 capacitance = 0;
Javi Merinoc36cf072015-02-26 19:00:29 +0000691
Viresh Kumarf5f263f2017-12-05 11:02:43 +0530692 if (!np) {
693 pr_err("cpu_cooling: OF node not available for cpu%d\n",
694 policy->cpu);
695 return NULL;
696 }
697
698 if (of_find_property(np, "#cooling-cells", NULL)) {
699 of_property_read_u32(np, "dynamic-power-coefficient",
700 &capacitance);
701
Viresh Kumar84fe2ca2017-12-05 11:02:46 +0530702 cdev = __cpufreq_cooling_register(np, policy, capacitance);
Viresh Kumarf5f263f2017-12-05 11:02:43 +0530703 if (IS_ERR(cdev)) {
Amit Kucheriabf78f132019-01-21 15:12:23 +0530704 pr_err("cpu_cooling: cpu%d failed to register as cooling device: %ld\n",
Viresh Kumarf5f263f2017-12-05 11:02:43 +0530705 policy->cpu, PTR_ERR(cdev));
706 cdev = NULL;
707 }
708 }
709
710 of_node_put(np);
711 return cdev;
Javi Merinoc36cf072015-02-26 19:00:29 +0000712}
Viresh Kumar3ebb62f2017-12-05 11:02:45 +0530713EXPORT_SYMBOL_GPL(of_cpufreq_cooling_register);
Javi Merinoc36cf072015-02-26 19:00:29 +0000714
715/**
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530716 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
717 * @cdev: thermal cooling device pointer.
Eduardo Valentin135266b2013-04-17 17:12:16 +0000718 *
719 * This interface function unregisters the "thermal-cpufreq-%x" cooling device.
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530720 */
721void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
722{
Viresh Kumar1dea4322017-04-25 15:57:10 +0530723 struct cpufreq_cooling_device *cpufreq_cdev;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530724
Eduardo Valentin50e66c72013-08-15 10:54:46 -0400725 if (!cdev)
726 return;
727
Viresh Kumar1dea4322017-04-25 15:57:10 +0530728 cpufreq_cdev = cdev->devdata;
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530729
Matthew Wilcoxae606082016-12-21 09:47:05 -0800730 mutex_lock(&cooling_list_lock);
Viresh Kumar1dea4322017-04-25 15:57:10 +0530731 list_del(&cpufreq_cdev->node);
Matthew Wilcox088db932017-03-10 18:33:28 +0000732 mutex_unlock(&cooling_list_lock);
733
Daniel Lezcano72554a72019-04-28 11:51:05 +0200734 thermal_cooling_device_unregister(cdev);
Rafael J. Wysocki3000ce32019-10-16 12:47:06 +0200735 freq_qos_remove_request(&cpufreq_cdev->qos_req);
Viresh Kumar1dea4322017-04-25 15:57:10 +0530736 ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id);
Viresh Kumar81ee14d2017-04-25 15:57:20 +0530737 kfree(cpufreq_cdev->idle_time);
Viresh Kumar1dea4322017-04-25 15:57:10 +0530738 kfree(cpufreq_cdev->freq_table);
739 kfree(cpufreq_cdev);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530740}
Eduardo Valentin243dbd92013-04-17 17:11:57 +0000741EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister);