blob: bd955270d5aae60f77cc8f936a5820d9690ac6ac [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
Zhang Ruibbf7fc82013-03-26 23:57:01 +080031#ifdef CONFIG_CPU_THERMAL
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053032/**
33 * cpufreq_cooling_register - function to create cpufreq cooling device.
34 * @clip_cpus: cpumask of cpus where the frequency constraints will happen
35 */
Eduardo Valentind44ada52013-04-17 17:12:23 +000036struct thermal_cooling_device *
37cpufreq_cooling_register(const struct cpumask *clip_cpus);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053038
39/**
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040040 * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
41 * @np: a valid struct device_node to the cooling device device tree node.
42 * @clip_cpus: cpumask of cpus where the frequency constraints will happen
43 */
44#ifdef CONFIG_THERMAL_OF
45struct thermal_cooling_device *
46of_cpufreq_cooling_register(struct device_node *np,
47 const struct cpumask *clip_cpus);
48#else
49static inline struct thermal_cooling_device *
50of_cpufreq_cooling_register(struct device_node *np,
51 const struct cpumask *clip_cpus)
52{
Javi Merino503ccc32014-12-17 11:11:24 +000053 return ERR_PTR(-ENOSYS);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040054}
55#endif
56
57/**
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053058 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
59 * @cdev: thermal cooling device pointer.
60 */
61void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
Zhang Rui57df8102013-02-08 14:52:06 +080062
Arnd Bergmanne8d39242013-07-05 17:40:13 +020063unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053064#else /* !CONFIG_CPU_THERMAL */
Eduardo Valentind44ada52013-04-17 17:12:23 +000065static inline struct thermal_cooling_device *
66cpufreq_cooling_register(const struct cpumask *clip_cpus)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053067{
Javi Merino503ccc32014-12-17 11:11:24 +000068 return ERR_PTR(-ENOSYS);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053069}
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040070static inline struct thermal_cooling_device *
71of_cpufreq_cooling_register(struct device_node *np,
72 const struct cpumask *clip_cpus)
73{
Javi Merino503ccc32014-12-17 11:11:24 +000074 return ERR_PTR(-ENOSYS);
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040075}
Eduardo Valentind44ada52013-04-17 17:12:23 +000076static inline
77void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053078{
79 return;
80}
Eduardo Valentind44ada52013-04-17 17:12:23 +000081static inline
Arnd Bergmanne8d39242013-07-05 17:40:13 +020082unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
Zhang Rui57df8102013-02-08 14:52:06 +080083{
84 return THERMAL_CSTATE_INVALID;
85}
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053086#endif /* CONFIG_CPU_THERMAL */
87
88#endif /* __CPU_COOLING_H__ */