• Home
  • Raw
  • Download

Lines Matching +full:cooling +full:- +full:device

24 #include <linux/device.h>
34 * struct clock_cooling_device - data for cooling device with clock
37 * @dev: struct device pointer to the device being used to cool off using
40 * registered cooling device.
45 * cooling devices.
57 struct device *dev;
70 /* Below code defines functions to be used for clock as cooling device */
79 * clock_cooling_get_property - fetch a property of interest for a give cpu.
80 * @ccdev: clock cooling device reference
86 * 1. get maximum clock cooling states
87 * 2. translate frequency to cooling state
88 * 3. translate cooling state to frequency
93 * cooling states and frequencies.
95 * Return: 0 on success, -EINVAL when invalid parameters are passed.
105 int descend = -1; in clock_cooling_get_property()
106 struct cpufreq_frequency_table *pos, *table = ccdev->freq_table; in clock_cooling_get_property()
109 return -EINVAL; in clock_cooling_get_property()
112 return -EINVAL; in clock_cooling_get_property()
116 if (freq == pos->frequency) in clock_cooling_get_property()
120 if (freq != CPUFREQ_ENTRY_INVALID && descend == -1) in clock_cooling_get_property()
121 descend = freq > pos->frequency; in clock_cooling_get_property()
123 freq = pos->frequency; in clock_cooling_get_property()
129 return -EINVAL; in clock_cooling_get_property()
132 max_level--; in clock_cooling_get_property()
141 level = descend ? input : (max_level - input); in clock_cooling_get_property()
146 if (freq == pos->frequency) in clock_cooling_get_property()
150 freq = pos->frequency; in clock_cooling_get_property()
154 *output = descend ? i : (max_level - i); in clock_cooling_get_property()
165 return -EINVAL; in clock_cooling_get_property()
169 * clock_cooling_get_level - return the cooling level of given clock cooling.
170 * @cdev: reference of a thermal cooling device of used as clock cooling device
173 * This function will match the cooling level corresponding to the
176 * Return: The matched cooling level on success or THERMAL_CSTATE_INVALID
182 struct clock_cooling_device *ccdev = cdev->devdata; in clock_cooling_get_level()
194 * clock_cooling_get_frequency - get the absolute value of frequency from level.
195 * @ccdev: clock cooling device reference
196 * @level: cooling level
198 * This function matches cooling level with frequency. Based on a cooling level
199 * of frequency, equals cooling state of cpu cooling device, it will return
201 * e.g level=0 --> 1st MAX FREQ, level=1 ---> 2nd MAX FREQ, .... etc
220 * clock_cooling_apply - function to apply frequency clipping.
222 * @cooling_state: value of the cooling state.
228 * Return: 0 on success, an error code otherwise (-EINVAL in case wrong
229 * cooling state).
238 /* Check if the old cooling action is same as new cooling action */ in clock_cooling_apply()
239 if (ccdev->clock_state == cooling_state) in clock_cooling_apply()
244 return -EINVAL; in clock_cooling_apply()
246 cur_freq = clk_get_rate(ccdev->clk); in clock_cooling_apply()
248 mutex_lock(&ccdev->lock); in clock_cooling_apply()
249 ccdev->clock_state = cooling_state; in clock_cooling_apply()
250 ccdev->clock_val = clip_freq; in clock_cooling_apply()
253 ret = clk_set_rate(ccdev->clk, clip_freq); in clock_cooling_apply()
254 mutex_unlock(&ccdev->lock); in clock_cooling_apply()
260 * clock_cooling_clock_notifier - notifier callback on clock rate changes.
263 * @data: callback-specific data
285 if (ndata->new_rate > ccdev->clock_val) in clock_cooling_clock_notifier()
295 /* clock cooling device thermal callback functions are defined below */
298 * clock_cooling_get_max_state - callback function to get the max cooling state.
299 * @cdev: thermal cooling device pointer.
300 * @state: fill this variable with the max cooling state.
302 * Callback for the thermal cooling device to return the clock
303 * max cooling state.
310 struct clock_cooling_device *ccdev = cdev->devdata; in clock_cooling_get_max_state()
322 * clock_cooling_get_cur_state - function to get the current cooling state.
323 * @cdev: thermal cooling device pointer.
324 * @state: fill this variable with the current cooling state.
326 * Callback for the thermal cooling device to return the clock
327 * current cooling state.
334 struct clock_cooling_device *ccdev = cdev->devdata; in clock_cooling_get_cur_state()
336 *state = ccdev->clock_state; in clock_cooling_get_cur_state()
342 * clock_cooling_set_cur_state - function to set the current cooling state.
343 * @cdev: thermal cooling device pointer.
344 * @state: set this variable to the current cooling state.
346 * Callback for the thermal cooling device to change the clock cooling
347 * current cooling state.
354 struct clock_cooling_device *clock_device = cdev->devdata; in clock_cooling_set_cur_state()
359 /* Bind clock callbacks to thermal cooling device ops */
367 * clock_cooling_register - function to create clock cooling device.
368 * @dev: struct device pointer to the device used as clock cooling device.
369 * @clock_name: string containing the clock used as cooling mechanism.
371 * This interface function registers the clock cooling device with the name
372 * "thermal-clock-%x". The cooling device is based on clock frequencies.
373 * The struct device is assumed to be capable of DVFS transitions.
375 * the referred device. The ordered frequency table is used to control
376 * the clock cooling device cooling states and to limit clock transitions
377 * based on the cooling state requested by the thermal framework.
383 clock_cooling_register(struct device *dev, const char *clock_name) in clock_cooling_register()
392 return ERR_PTR(-ENOMEM); in clock_cooling_register()
394 mutex_init(&ccdev->lock); in clock_cooling_register()
395 ccdev->dev = dev; in clock_cooling_register()
396 ccdev->clk = devm_clk_get(dev, clock_name); in clock_cooling_register()
397 if (IS_ERR(ccdev->clk)) in clock_cooling_register()
398 return ERR_CAST(ccdev->clk); in clock_cooling_register()
403 ccdev->id = ret; in clock_cooling_register()
405 snprintf(dev_name, sizeof(dev_name), "thermal-clock-%d", ccdev->id); in clock_cooling_register()
410 ida_simple_remove(&clock_ida, ccdev->id); in clock_cooling_register()
411 return ERR_PTR(-EINVAL); in clock_cooling_register()
413 ccdev->cdev = cdev; in clock_cooling_register()
414 ccdev->clk_rate_change_nb.notifier_call = clock_cooling_clock_notifier; in clock_cooling_register()
416 /* Assuming someone has already filled the opp table for this device */ in clock_cooling_register()
417 ret = dev_pm_opp_init_cpufreq_table(dev, &ccdev->freq_table); in clock_cooling_register()
419 ida_simple_remove(&clock_ida, ccdev->id); in clock_cooling_register()
422 ccdev->clock_state = 0; in clock_cooling_register()
423 ccdev->clock_val = clock_cooling_get_frequency(ccdev, 0); in clock_cooling_register()
425 clk_notifier_register(ccdev->clk, &ccdev->clk_rate_change_nb); in clock_cooling_register()
432 * clock_cooling_unregister - function to remove clock cooling device.
433 * @cdev: thermal cooling device pointer.
435 * This interface function unregisters the "thermal-clock-%x" cooling device.
444 ccdev = cdev->devdata; in clock_cooling_unregister()
446 clk_notifier_unregister(ccdev->clk, &ccdev->clk_rate_change_nb); in clock_cooling_unregister()
447 dev_pm_opp_free_cpufreq_table(ccdev->dev, &ccdev->freq_table); in clock_cooling_unregister()
449 thermal_cooling_device_unregister(ccdev->cdev); in clock_cooling_unregister()
450 ida_simple_remove(&clock_ida, ccdev->id); in clock_cooling_unregister()