Linux Audio

Check our new training course

Loading...
v5.9
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/*
 3 * devfreq_cooling: Thermal cooling device implementation for devices using
 4 *                  devfreq
 5 *
 6 * Copyright (C) 2014-2015 ARM Limited
 7 *
 
 
 
 
 
 
 
 
 8 */
 9
10#ifndef __DEVFREQ_COOLING_H__
11#define __DEVFREQ_COOLING_H__
12
13#include <linux/devfreq.h>
14#include <linux/thermal.h>
15
16
17/**
18 * struct devfreq_cooling_power - Devfreq cooling power ops
19 * @get_static_power:	Take voltage, in mV, and return the static power
20 *			in mW.  If NULL, the static power is assumed
21 *			to be 0.
22 * @get_dynamic_power:	Take voltage, in mV, and frequency, in HZ, and
23 *			return the dynamic power draw in mW.  If NULL,
24 *			a simple power model is used.
25 * @dyn_power_coeff:	Coefficient for the simple dynamic power model in
26 *			mW/(MHz mV mV).
27 *			If get_dynamic_power() is NULL, then the
28 *			dynamic power is calculated as
29 *			@dyn_power_coeff * frequency * voltage^2
30 * @get_real_power:	When this is set, the framework uses it to ask the
31 *			device driver for the actual power.
32 *			Some devices have more sophisticated methods
33 *			(like power counters) to approximate the actual power
34 *			that they use.
35 *			This function provides more accurate data to the
36 *			thermal governor. When the driver does not provide
37 *			such function, framework just uses pre-calculated
38 *			table and scale the power by 'utilization'
39 *			(based on 'busy_time' and 'total_time' taken from
40 *			devfreq 'last_status').
41 *			The value returned by this function must be lower
42 *			or equal than the maximum power value
43 *			for the current	state
44 *			(which can be found in power_table[state]).
45 *			When this interface is used, the power_table holds
46 *			max total (static + dynamic) power value for each OPP.
47 */
48struct devfreq_cooling_power {
49	unsigned long (*get_static_power)(struct devfreq *devfreq,
50					  unsigned long voltage);
51	unsigned long (*get_dynamic_power)(struct devfreq *devfreq,
52					   unsigned long freq,
53					   unsigned long voltage);
54	int (*get_real_power)(struct devfreq *df, u32 *power,
55			      unsigned long freq, unsigned long voltage);
56	unsigned long dyn_power_coeff;
57};
58
59#ifdef CONFIG_DEVFREQ_THERMAL
60
61struct thermal_cooling_device *
62of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
63				  struct devfreq_cooling_power *dfc_power);
64struct thermal_cooling_device *
65of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
66struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
67void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
68
69#else /* !CONFIG_DEVFREQ_THERMAL */
70
71static inline struct thermal_cooling_device *
72of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
73				  struct devfreq_cooling_power *dfc_power)
74{
75	return ERR_PTR(-EINVAL);
76}
77
78static inline struct thermal_cooling_device *
79of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
80{
81	return ERR_PTR(-EINVAL);
82}
83
84static inline struct thermal_cooling_device *
85devfreq_cooling_register(struct devfreq *df)
86{
87	return ERR_PTR(-EINVAL);
88}
89
90static inline void
91devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
92{
93}
94
95#endif /* CONFIG_DEVFREQ_THERMAL */
96#endif /* __DEVFREQ_COOLING_H__ */
v4.10.11
 
 1/*
 2 * devfreq_cooling: Thermal cooling device implementation for devices using
 3 *                  devfreq
 4 *
 5 * Copyright (C) 2014-2015 ARM Limited
 6 *
 7 * This program is free software; you can redistribute it and/or modify
 8 * it under the terms of the GNU General Public License version 2 as
 9 * published by the Free Software Foundation.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef __DEVFREQ_COOLING_H__
18#define __DEVFREQ_COOLING_H__
19
20#include <linux/devfreq.h>
21#include <linux/thermal.h>
22
23
24/**
25 * struct devfreq_cooling_power - Devfreq cooling power ops
26 * @get_static_power:	Take voltage, in mV, and return the static power
27 *			in mW.  If NULL, the static power is assumed
28 *			to be 0.
29 * @get_dynamic_power:	Take voltage, in mV, and frequency, in HZ, and
30 *			return the dynamic power draw in mW.  If NULL,
31 *			a simple power model is used.
32 * @dyn_power_coeff:	Coefficient for the simple dynamic power model in
33 *			mW/(MHz mV mV).
34 *			If get_dynamic_power() is NULL, then the
35 *			dynamic power is calculated as
36 *			@dyn_power_coeff * frequency * voltage^2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37 */
38struct devfreq_cooling_power {
39	unsigned long (*get_static_power)(struct devfreq *devfreq,
40					  unsigned long voltage);
41	unsigned long (*get_dynamic_power)(struct devfreq *devfreq,
42					   unsigned long freq,
43					   unsigned long voltage);
 
 
44	unsigned long dyn_power_coeff;
45};
46
47#ifdef CONFIG_DEVFREQ_THERMAL
48
49struct thermal_cooling_device *
50of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
51				  struct devfreq_cooling_power *dfc_power);
52struct thermal_cooling_device *
53of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
54struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
55void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
56
57#else /* !CONFIG_DEVFREQ_THERMAL */
58
59struct thermal_cooling_device *
60of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
61				  struct devfreq_cooling_power *dfc_power)
62{
63	return ERR_PTR(-EINVAL);
64}
65
66static inline struct thermal_cooling_device *
67of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
68{
69	return ERR_PTR(-EINVAL);
70}
71
72static inline struct thermal_cooling_device *
73devfreq_cooling_register(struct devfreq *df)
74{
75	return ERR_PTR(-EINVAL);
76}
77
78static inline void
79devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
80{
81}
82
83#endif /* CONFIG_DEVFREQ_THERMAL */
84#endif /* __DEVFREQ_COOLING_H__ */