blob: 65501d8f97788c8fd51791a662781d6af36e7351 [file] [log] [blame]
Thomas Gleixner873e65b2019-05-27 08:55:15 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Amit Daniel Kachhap02361412012-08-16 17:11:40 +05302/*
3 * linux/include/linux/cpu_cooling.h
4 *
5 * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com)
6 * Copyright (C) 2012 Amit Daniel <amit.kachhap@linaro.org>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Amit Daniel Kachhap02361412012-08-16 17:11:40 +05309 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 */
12
13#ifndef __CPU_COOLING_H__
14#define __CPU_COOLING_H__
15
Eduardo Valentin39d99cf2013-09-12 19:26:45 -040016#include <linux/of.h>
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053017#include <linux/thermal.h>
Eduardo Valentin198f38f2013-04-24 23:10:28 +080018#include <linux/cpumask.h>
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053019
Viresh Kumar4d753aa2017-04-25 15:57:14 +053020struct cpufreq_policy;
21
Daniel Lezcano2b586fe2019-12-04 16:39:27 +010022#ifdef CONFIG_CPU_FREQ_THERMAL
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053023/**
24 * cpufreq_cooling_register - function to create cpufreq cooling device.
Viresh Kumar4d753aa2017-04-25 15:57:14 +053025 * @policy: cpufreq policy.
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053026 */
Eduardo Valentind44ada52013-04-17 17:12:23 +000027struct thermal_cooling_device *
Viresh Kumar4d753aa2017-04-25 15:57:14 +053028cpufreq_cooling_register(struct cpufreq_policy *policy);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053029
30/**
31 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
32 * @cdev: thermal cooling device pointer.
33 */
34void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
Zhang Rui57df8102013-02-08 14:52:06 +080035
Daniel Lezcano0cac7552019-10-30 10:10:37 +010036/**
37 * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
38 * @policy: cpufreq policy.
39 */
40struct thermal_cooling_device *
41of_cpufreq_cooling_register(struct cpufreq_policy *policy);
42
Daniel Lezcano2b586fe2019-12-04 16:39:27 +010043#else /* !CONFIG_CPU_FREQ_THERMAL */
Eduardo Valentind44ada52013-04-17 17:12:23 +000044static inline struct thermal_cooling_device *
Viresh Kumar4d753aa2017-04-25 15:57:14 +053045cpufreq_cooling_register(struct cpufreq_policy *policy)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053046{
Javi Merino503ccc3f2014-12-17 11:11:24 +000047 return ERR_PTR(-ENOSYS);
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053048}
Javi Merinoc36cf072015-02-26 19:00:29 +000049
Eduardo Valentind44ada52013-04-17 17:12:23 +000050static inline
51void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053052{
53 return;
54}
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053055
Viresh Kumar3ebb62f2017-12-05 11:02:45 +053056static inline struct thermal_cooling_device *
57of_cpufreq_cooling_register(struct cpufreq_policy *policy)
58{
59 return NULL;
60}
Daniel Lezcano2b586fe2019-12-04 16:39:27 +010061#endif /* CONFIG_CPU_FREQ_THERMAL */
Viresh Kumar3ebb62f2017-12-05 11:02:45 +053062
Daniel Lezcanoa4c428e2019-12-19 23:53:16 +010063struct cpuidle_driver;
64
65#ifdef CONFIG_CPU_IDLE_THERMAL
66int cpuidle_cooling_register(struct cpuidle_driver *drv);
67int cpuidle_of_cooling_register(struct device_node *np,
68 struct cpuidle_driver *drv);
69#else /* CONFIG_CPU_IDLE_THERMAL */
70static inline int cpuidle_cooling_register(struct cpuidle_driver *drv)
71{
72 return 0;
73}
74static inline int cpuidle_of_cooling_register(struct device_node *np,
75 struct cpuidle_driver *drv)
76{
77 return 0;
78}
79#endif /* CONFIG_CPU_IDLE_THERMAL */
80
Amit Daniel Kachhap02361412012-08-16 17:11:40 +053081#endif /* __CPU_COOLING_H__ */