blob: c156f50827589c9547d48aac0072a30bf97672a5 [file] [log] [blame]
Amit Daniel Kachhap02361412012-08-16 17:11:40 +05301/*
2 * linux/include/linux/cpu_cooling.h
3 *
4 * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com)
5 * Copyright (C) 2012 Amit Daniel <amit.kachhap@linaro.org>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 *
21 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 */
23
24#ifndef __CPU_COOLING_H__
25#define __CPU_COOLING_H__
26
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040027#include <linux/of.h>
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053028#include <linux/thermal.h>
Eduardo Valentin198f38f2013-04-24 23:10:28 +080029#include <linux/cpumask.h>
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053030
Javi Merinoc36cf072015-02-26 19:00:29 +000031typedef int (*get_static_t)(cpumask_t *cpumask, int interval,
32 unsigned long voltage, u32 *power);
33
Zhang Ruibbf7fc82013-03-26 23:57:01 +080034#ifdef CONFIG_CPU_THERMAL
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053035/**
36 * cpufreq_cooling_register - function to create cpufreq cooling device.
37 * @clip_cpus: cpumask of cpus where the frequency constraints will happen
38 */
Eduardo Valentind44ada52013-04-17 17:12:23 +000039struct thermal_cooling_device *
40cpufreq_cooling_register(const struct cpumask *clip_cpus);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053041
Javi Merinoc36cf072015-02-26 19:00:29 +000042struct thermal_cooling_device *
43cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
44 u32 capacitance, get_static_t plat_static_func);
45
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053046/**
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040047 * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
48 * @np: a valid struct device_node to the cooling device device tree node.
49 * @clip_cpus: cpumask of cpus where the frequency constraints will happen
50 */
51#ifdef CONFIG_THERMAL_OF
52struct thermal_cooling_device *
53of_cpufreq_cooling_register(struct device_node *np,
54 const struct cpumask *clip_cpus);
Javi Merinoc36cf072015-02-26 19:00:29 +000055
56struct thermal_cooling_device *
57of_cpufreq_power_cooling_register(struct device_node *np,
58 const struct cpumask *clip_cpus,
59 u32 capacitance,
60 get_static_t plat_static_func);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040061#else
62static inline struct thermal_cooling_device *
63of_cpufreq_cooling_register(struct device_node *np,
64 const struct cpumask *clip_cpus)
65{
Javi Merino503ccc32014-12-17 11:11:24 +000066 return ERR_PTR(-ENOSYS);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040067}
Javi Merinoc36cf072015-02-26 19:00:29 +000068
69static inline struct thermal_cooling_device *
70of_cpufreq_power_cooling_register(struct device_node *np,
71 const struct cpumask *clip_cpus,
72 u32 capacitance,
73 get_static_t plat_static_func)
74{
75 return NULL;
76}
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040077#endif
78
79/**
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053080 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
81 * @cdev: thermal cooling device pointer.
82 */
83void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
Zhang Rui57df8102013-02-08 14:52:06 +080084
Arnd Bergmanne8d39242013-07-05 17:40:13 +020085unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053086#else /* !CONFIG_CPU_THERMAL */
Eduardo Valentind44ada52013-04-17 17:12:23 +000087static inline struct thermal_cooling_device *
88cpufreq_cooling_register(const struct cpumask *clip_cpus)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053089{
Javi Merino503ccc32014-12-17 11:11:24 +000090 return ERR_PTR(-ENOSYS);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053091}
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040092static inline struct thermal_cooling_device *
Javi Merinoc36cf072015-02-26 19:00:29 +000093cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
94 u32 capacitance, get_static_t plat_static_func)
95{
96 return NULL;
97}
98
99static inline struct thermal_cooling_device *
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400100of_cpufreq_cooling_register(struct device_node *np,
101 const struct cpumask *clip_cpus)
102{
Javi Merino503ccc32014-12-17 11:11:24 +0000103 return ERR_PTR(-ENOSYS);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400104}
Javi Merinoc36cf072015-02-26 19:00:29 +0000105
106static inline struct thermal_cooling_device *
107of_cpufreq_power_cooling_register(struct device_node *np,
108 const struct cpumask *clip_cpus,
109 u32 capacitance,
110 get_static_t plat_static_func)
111{
112 return NULL;
113}
114
Eduardo Valentind44ada52013-04-17 17:12:23 +0000115static inline
116void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530117{
118 return;
119}
Eduardo Valentind44ada52013-04-17 17:12:23 +0000120static inline
Arnd Bergmanne8d39242013-07-05 17:40:13 +0200121unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
Zhang Rui57df8102013-02-08 14:52:06 +0800122{
123 return THERMAL_CSTATE_INVALID;
124}
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530125#endif /* CONFIG_CPU_THERMAL */
126
127#endif /* __CPU_COOLING_H__ */