blob: 1d88bbff99f6af31104bd802f1c87d8aad52b893 [file] [log] [blame]
Ørjan Eidea76caf52015-09-10 18:09:30 +01001/*
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
Ørjan Eidea76caf52015-09-10 18:09:30 +010023/**
24 * struct devfreq_cooling_power - Devfreq cooling power ops
25 * @get_static_power: Take voltage, in mV, and return the static power
26 * in mW. If NULL, the static power is assumed
27 * to be 0.
28 * @get_dynamic_power: Take voltage, in mV, and frequency, in HZ, and
29 * return the dynamic power draw in mW. If NULL,
30 * a simple power model is used.
31 * @dyn_power_coeff: Coefficient for the simple dynamic power model in
32 * mW/(MHz mV mV).
33 * If get_dynamic_power() is NULL, then the
34 * dynamic power is calculated as
35 * @dyn_power_coeff * frequency * voltage^2
36 */
37struct devfreq_cooling_power {
38 unsigned long (*get_static_power)(unsigned long voltage);
39 unsigned long (*get_dynamic_power)(unsigned long freq,
40 unsigned long voltage);
41 unsigned long dyn_power_coeff;
42};
43
Ram Chandrasekar5f7c0082016-11-22 15:46:31 -070044#ifdef CONFIG_DEVFREQ_THERMAL
45
Javi Merino3c99c2c2015-11-02 19:03:03 +000046struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010047of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
48 struct devfreq_cooling_power *dfc_power);
Javi Merino3c99c2c2015-11-02 19:03:03 +000049struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010050of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
Javi Merino3c99c2c2015-11-02 19:03:03 +000051struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
52void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
Ørjan Eidea76caf52015-09-10 18:09:30 +010053
54#else /* !CONFIG_DEVFREQ_THERMAL */
55
Martin Blumenstinglacca1bd2020-04-03 22:51:33 +020056static inline struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010057of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
58 struct devfreq_cooling_power *dfc_power)
59{
60 return ERR_PTR(-EINVAL);
61}
62
Javi Merino3c99c2c2015-11-02 19:03:03 +000063static inline struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010064of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
65{
66 return ERR_PTR(-EINVAL);
67}
68
Javi Merino3c99c2c2015-11-02 19:03:03 +000069static inline struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010070devfreq_cooling_register(struct devfreq *df)
71{
72 return ERR_PTR(-EINVAL);
73}
74
75static inline void
Javi Merino3c99c2c2015-11-02 19:03:03 +000076devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
Ørjan Eidea76caf52015-09-10 18:09:30 +010077{
78}
79
80#endif /* CONFIG_DEVFREQ_THERMAL */
81#endif /* __DEVFREQ_COOLING_H__ */