• Home
  • Raw
  • Download

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

2  * devfreq_cooling: Thermal cooling device implementation for devices using
5 * Copyright (C) 2014-2015 ARM Limited
17 * - If OPPs are added or removed after devfreq cooling has
18 * registered, the devfreq cooling won't react to it.
36 * struct devfreq_cooling_device - Devfreq cooling device
39 * @cdev: Pointer to associated thermal cooling device.
40 * @devfreq: Pointer to associated devfreq device.
41 * @cooling_state: Current cooling state.
43 * cooling state. State is the index into the table, and
46 * order. You can index the table by cooling device state
71 * partition_enable_opps() - disable all opps above a given state
73 * @cdev_state: cooling device state we're setting
75 * Go through the OPPs of the device, enabling all OPPs until
82 struct device *dev = dfc->devfreq->dev.parent; in partition_enable_opps()
84 for (i = 0; i < dfc->freq_table_size; i++) { in partition_enable_opps()
87 unsigned int freq = dfc->freq_table[i]; in partition_enable_opps()
92 if (PTR_ERR(opp) == -ERANGE) in partition_enable_opps()
114 struct devfreq_cooling_device *dfc = cdev->devdata; in devfreq_cooling_get_max_state()
116 *state = dfc->freq_table_size - 1; in devfreq_cooling_get_max_state()
124 struct devfreq_cooling_device *dfc = cdev->devdata; in devfreq_cooling_get_cur_state()
126 *state = dfc->cooling_state; in devfreq_cooling_get_cur_state()
134 struct devfreq_cooling_device *dfc = cdev->devdata; in devfreq_cooling_set_cur_state()
135 struct devfreq *df = dfc->devfreq; in devfreq_cooling_set_cur_state()
136 struct device *dev = df->dev.parent; in devfreq_cooling_set_cur_state()
139 if (state == dfc->cooling_state) in devfreq_cooling_set_cur_state()
142 dev_dbg(dev, "Setting cooling state %lu\n", state); in devfreq_cooling_set_cur_state()
144 if (state >= dfc->freq_table_size) in devfreq_cooling_set_cur_state()
145 return -EINVAL; in devfreq_cooling_set_cur_state()
151 dfc->cooling_state = state; in devfreq_cooling_set_cur_state()
157 * freq_get_state() - get the cooling state corresponding to a frequency
158 * @dfc: Pointer to devfreq cooling device
161 * Return: the cooling state associated with the @freq, or
169 for (i = 0; i < dfc->freq_table_size; i++) { in freq_get_state()
170 if (dfc->freq_table[i] == freq) in freq_get_state()
179 struct device *dev = df->dev.parent; in get_voltage()
184 if (PTR_ERR(opp) == -ERANGE) in get_voltage()
206 * get_static_power() - calculate the static power
207 * @dfc: Pointer to devfreq cooling device
218 struct devfreq *df = dfc->devfreq; in get_static_power()
221 if (!dfc->power_ops->get_static_power) in get_static_power()
229 return dfc->power_ops->get_static_power(df, voltage); in get_static_power()
233 * get_dynamic_power - calculate the dynamic power
234 * @dfc: Pointer to devfreq cooling device
238 * Calculate the dynamic power in milliwatts consumed by the device at
250 struct devfreq_cooling_power *dfc_power = dfc->power_ops; in get_dynamic_power()
252 if (dfc_power->get_dynamic_power) in get_dynamic_power()
253 return dfc_power->get_dynamic_power(dfc->devfreq, freq, in get_dynamic_power()
257 power = (u64)dfc_power->dyn_power_coeff * freq_mhz * voltage * voltage; in get_dynamic_power()
277 struct devfreq_cooling_device *dfc = cdev->devdata; in devfreq_cooling_get_requested_power()
278 struct devfreq *df = dfc->devfreq; in devfreq_cooling_get_requested_power()
279 struct devfreq_dev_status *status = &df->last_status; in devfreq_cooling_get_requested_power()
281 unsigned long freq = status->current_frequency; in devfreq_cooling_get_requested_power()
289 res = -EAGAIN; in devfreq_cooling_get_requested_power()
293 if (dfc->power_ops->get_real_power) { in devfreq_cooling_get_requested_power()
296 res = -EINVAL; in devfreq_cooling_get_requested_power()
300 res = dfc->power_ops->get_real_power(df, power, freq, voltage); in devfreq_cooling_get_requested_power()
302 state = dfc->capped_state; in devfreq_cooling_get_requested_power()
303 dfc->res_util = dfc->power_table[state]; in devfreq_cooling_get_requested_power()
304 dfc->res_util *= SCALE_ERROR_MITIGATION; in devfreq_cooling_get_requested_power()
307 dfc->res_util /= *power; in devfreq_cooling_get_requested_power()
312 dyn_power = dfc->power_table[state]; in devfreq_cooling_get_requested_power()
315 dyn_power *= status->busy_time; in devfreq_cooling_get_requested_power()
316 dyn_power /= status->total_time; in devfreq_cooling_get_requested_power()
329 dfc->res_util = SCALE_ERROR_MITIGATION; in devfreq_cooling_get_requested_power()
338 struct devfreq_cooling_device *dfc = cdev->devdata; in devfreq_cooling_state2power()
342 if (state >= dfc->freq_table_size) in devfreq_cooling_state2power()
343 return -EINVAL; in devfreq_cooling_state2power()
345 freq = dfc->freq_table[state]; in devfreq_cooling_state2power()
348 *power = dfc->power_table[state] + static_power; in devfreq_cooling_state2power()
356 struct devfreq_cooling_device *dfc = cdev->devdata; in devfreq_cooling_power2state()
357 struct devfreq *df = dfc->devfreq; in devfreq_cooling_power2state()
358 struct devfreq_dev_status *status = &df->last_status; in devfreq_cooling_power2state()
359 unsigned long freq = status->current_frequency; in devfreq_cooling_power2state()
366 if (dfc->power_ops->get_real_power) { in devfreq_cooling_power2state()
368 est_power = power * dfc->res_util; in devfreq_cooling_power2state()
373 dyn_power = power - static_power; in devfreq_cooling_power2state()
377 busy_time = status->busy_time ?: 1; in devfreq_cooling_power2state()
378 est_power = (dyn_power * status->total_time) / busy_time; in devfreq_cooling_power2state()
382 * Find the first cooling state that is within the power in devfreq_cooling_power2state()
385 for (i = 0; i < dfc->freq_table_size - 1; i++) in devfreq_cooling_power2state()
386 if (est_power >= dfc->power_table[i]) in devfreq_cooling_power2state()
390 dfc->capped_state = i; in devfreq_cooling_power2state()
402 * devfreq_cooling_gen_tables() - Generate power and freq tables.
403 * @dfc: Pointer to devfreq cooling device.
406 * device's maximum power usage at each cooling state (OPP). The
412 * That way its indexed by cooling device state.
415 * freed when unregistering the devfreq cooling device.
421 struct devfreq *df = dfc->devfreq; in devfreq_cooling_gen_tables()
422 struct device *dev = df->dev.parent; in devfreq_cooling_gen_tables()
431 if (dfc->power_ops) { in devfreq_cooling_gen_tables()
435 return -ENOMEM; in devfreq_cooling_gen_tables()
441 ret = -ENOMEM; in devfreq_cooling_gen_tables()
445 for (i = 0, freq = ULONG_MAX; i < num_opps; i++, freq--) { in devfreq_cooling_gen_tables()
458 if (dfc->power_ops) { in devfreq_cooling_gen_tables()
459 if (dfc->power_ops->get_real_power) in devfreq_cooling_gen_tables()
473 if (dfc->power_ops) in devfreq_cooling_gen_tables()
474 dfc->power_table = power_table; in devfreq_cooling_gen_tables()
476 dfc->freq_table = freq_table; in devfreq_cooling_gen_tables()
477 dfc->freq_table_size = num_opps; in devfreq_cooling_gen_tables()
490 * of_devfreq_cooling_register_power() - Register devfreq cooling device,
493 * @df: Pointer to devfreq device.
496 * Register a devfreq cooling device. The available OPPs must be
497 * registered on the device.
499 * If @dfc_power is provided, the cooling device is registered with the
515 return ERR_PTR(-ENOMEM); in of_devfreq_cooling_register_power()
517 dfc->devfreq = df; in of_devfreq_cooling_register_power()
520 dfc->power_ops = dfc_power; in of_devfreq_cooling_register_power()
535 dfc->id = err; in of_devfreq_cooling_register_power()
537 snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id); in of_devfreq_cooling_register_power()
543 dev_err(df->dev.parent, in of_devfreq_cooling_register_power()
544 "Failed to register devfreq cooling device (%d)\n", in of_devfreq_cooling_register_power()
549 dfc->cdev = cdev; in of_devfreq_cooling_register_power()
554 ida_simple_remove(&devfreq_ida, dfc->id); in of_devfreq_cooling_register_power()
556 kfree(dfc->power_table); in of_devfreq_cooling_register_power()
557 kfree(dfc->freq_table); in of_devfreq_cooling_register_power()
566 * of_devfreq_cooling_register() - Register devfreq cooling device,
569 * @df: Pointer to devfreq device.
579 * devfreq_cooling_register() - Register devfreq cooling device.
580 * @df: Pointer to devfreq device.
589 * devfreq_cooling_unregister() - Unregister devfreq cooling device.
590 * @dfc: Pointer to devfreq cooling device to unregister.
599 dfc = cdev->devdata; in devfreq_cooling_unregister()
601 thermal_cooling_device_unregister(dfc->cdev); in devfreq_cooling_unregister()
602 ida_simple_remove(&devfreq_ida, dfc->id); in devfreq_cooling_unregister()
603 kfree(dfc->power_table); in devfreq_cooling_unregister()
604 kfree(dfc->freq_table); in devfreq_cooling_unregister()