blob: d4292ebc5c8b0e06ca64e7497d07a0579d17fb2f [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
Viresh Kumar4d753aa2017-04-25 15:57:14 +053031struct cpufreq_policy;
32
Javi Merinoc36cf072015-02-26 19:00:29 +000033typedef int (*get_static_t)(cpumask_t *cpumask, int interval,
34 unsigned long voltage, u32 *power);
35
Zhang Ruibbf7fc82013-03-26 23:57:01 +080036#ifdef CONFIG_CPU_THERMAL
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053037/**
38 * cpufreq_cooling_register - function to create cpufreq cooling device.
Viresh Kumar4d753aa2017-04-25 15:57:14 +053039 * @policy: cpufreq policy.
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053040 */
Eduardo Valentind44ada52013-04-17 17:12:23 +000041struct thermal_cooling_device *
Viresh Kumar4d753aa2017-04-25 15:57:14 +053042cpufreq_cooling_register(struct cpufreq_policy *policy);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053043
Javi Merinoc36cf072015-02-26 19:00:29 +000044struct thermal_cooling_device *
Viresh Kumar4d753aa2017-04-25 15:57:14 +053045cpufreq_power_cooling_register(struct cpufreq_policy *policy,
Javi Merinoc36cf072015-02-26 19:00:29 +000046 u32 capacitance, get_static_t plat_static_func);
47
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053048/**
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040049 * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
50 * @np: a valid struct device_node to the cooling device device tree node.
Viresh Kumar4d753aa2017-04-25 15:57:14 +053051 * @policy: cpufreq policy.
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040052 */
53#ifdef CONFIG_THERMAL_OF
54struct thermal_cooling_device *
55of_cpufreq_cooling_register(struct device_node *np,
Viresh Kumar4d753aa2017-04-25 15:57:14 +053056 struct cpufreq_policy *policy);
Javi Merinoc36cf072015-02-26 19:00:29 +000057
58struct thermal_cooling_device *
59of_cpufreq_power_cooling_register(struct device_node *np,
Viresh Kumar4d753aa2017-04-25 15:57:14 +053060 struct cpufreq_policy *policy,
Javi Merinoc36cf072015-02-26 19:00:29 +000061 u32 capacitance,
62 get_static_t plat_static_func);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040063#else
64static inline struct thermal_cooling_device *
65of_cpufreq_cooling_register(struct device_node *np,
Viresh Kumar4d753aa2017-04-25 15:57:14 +053066 struct cpufreq_policy *policy)
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040067{
Javi Merino503ccc32014-12-17 11:11:24 +000068 return ERR_PTR(-ENOSYS);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040069}
Javi Merinoc36cf072015-02-26 19:00:29 +000070
71static inline struct thermal_cooling_device *
72of_cpufreq_power_cooling_register(struct device_node *np,
Viresh Kumar4d753aa2017-04-25 15:57:14 +053073 struct cpufreq_policy *policy,
Javi Merinoc36cf072015-02-26 19:00:29 +000074 u32 capacitance,
75 get_static_t plat_static_func)
76{
77 return NULL;
78}
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040079#endif
80
81/**
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053082 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
83 * @cdev: thermal cooling device pointer.
84 */
85void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
Zhang Rui57df8102013-02-08 14:52:06 +080086
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053087#else /* !CONFIG_CPU_THERMAL */
Eduardo Valentind44ada52013-04-17 17:12:23 +000088static inline struct thermal_cooling_device *
Viresh Kumar4d753aa2017-04-25 15:57:14 +053089cpufreq_cooling_register(struct cpufreq_policy *policy)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053090{
Javi Merino503ccc32014-12-17 11:11:24 +000091 return ERR_PTR(-ENOSYS);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053092}
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040093static inline struct thermal_cooling_device *
Viresh Kumar4d753aa2017-04-25 15:57:14 +053094cpufreq_power_cooling_register(struct cpufreq_policy *policy,
Javi Merinoc36cf072015-02-26 19:00:29 +000095 u32 capacitance, get_static_t plat_static_func)
96{
97 return NULL;
98}
99
100static inline struct thermal_cooling_device *
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400101of_cpufreq_cooling_register(struct device_node *np,
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530102 struct cpufreq_policy *policy)
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400103{
Javi Merino503ccc32014-12-17 11:11:24 +0000104 return ERR_PTR(-ENOSYS);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -0400105}
Javi Merinoc36cf072015-02-26 19:00:29 +0000106
107static inline struct thermal_cooling_device *
108of_cpufreq_power_cooling_register(struct device_node *np,
Viresh Kumar4d753aa2017-04-25 15:57:14 +0530109 struct cpufreq_policy *policy,
Javi Merinoc36cf072015-02-26 19:00:29 +0000110 u32 capacitance,
111 get_static_t plat_static_func)
112{
113 return NULL;
114}
115
Eduardo Valentind44ada52013-04-17 17:12:23 +0000116static inline
117void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530118{
119 return;
120}
Amit Daniel Kachhap02361412012-08-16 17:11:40 +0530121#endif /* CONFIG_CPU_THERMAL */
122
123#endif /* __CPU_COOLING_H__ */