blob: c35d0c0e0ada7a4e99363d217a86fc4cad8dafaf [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/**
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 {
Javi Merino3aa53742016-09-15 15:44:23 +010039 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,
Ørjan Eidea76caf52015-09-10 18:09:30 +010043 unsigned long voltage);
44 unsigned long dyn_power_coeff;
45};
46
Lukasz Luba1cea4e72016-09-15 15:44:22 +010047#ifdef CONFIG_DEVFREQ_THERMAL
48
Javi Merino3c99c2c2015-11-02 19:03:03 +000049struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010050of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
51 struct devfreq_cooling_power *dfc_power);
Javi Merino3c99c2c2015-11-02 19:03:03 +000052struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010053of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
Javi Merino3c99c2c2015-11-02 19:03:03 +000054struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
55void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
Ørjan Eidea76caf52015-09-10 18:09:30 +010056
57#else /* !CONFIG_DEVFREQ_THERMAL */
58
Javi Merino3c99c2c2015-11-02 19:03:03 +000059struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010060of_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
Javi Merino3c99c2c2015-11-02 19:03:03 +000066static inline struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010067of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
68{
69 return ERR_PTR(-EINVAL);
70}
71
Javi Merino3c99c2c2015-11-02 19:03:03 +000072static inline struct thermal_cooling_device *
Ørjan Eidea76caf52015-09-10 18:09:30 +010073devfreq_cooling_register(struct devfreq *df)
74{
75 return ERR_PTR(-EINVAL);
76}
77
78static inline void
Javi Merino3c99c2c2015-11-02 19:03:03 +000079devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
Ørjan Eidea76caf52015-09-10 18:09:30 +010080{
81}
82
83#endif /* CONFIG_DEVFREQ_THERMAL */
84#endif /* __DEVFREQ_COOLING_H__ */