Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 1 | /* |
| 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 Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 27 | #include <linux/of.h> |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 28 | #include <linux/thermal.h> |
Eduardo Valentin | 198f38f | 2013-04-24 23:10:28 +0800 | [diff] [blame] | 29 | #include <linux/cpumask.h> |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 30 | |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 31 | struct cpufreq_policy; |
| 32 | |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 33 | typedef int (*get_static_t)(cpumask_t *cpumask, int interval, |
| 34 | unsigned long voltage, u32 *power); |
| 35 | |
Zhang Rui | bbf7fc8 | 2013-03-26 23:57:01 +0800 | [diff] [blame] | 36 | #ifdef CONFIG_CPU_THERMAL |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 37 | /** |
| 38 | * cpufreq_cooling_register - function to create cpufreq cooling device. |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 39 | * @policy: cpufreq policy. |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 40 | */ |
Eduardo Valentin | d44ada5 | 2013-04-17 17:12:23 +0000 | [diff] [blame] | 41 | struct thermal_cooling_device * |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 42 | cpufreq_cooling_register(struct cpufreq_policy *policy); |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 43 | |
| 44 | /** |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 45 | * of_cpufreq_cooling_register - create cpufreq cooling device based on DT. |
| 46 | * @np: a valid struct device_node to the cooling device device tree node. |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 47 | * @policy: cpufreq policy. |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 48 | */ |
| 49 | #ifdef CONFIG_THERMAL_OF |
| 50 | struct thermal_cooling_device * |
| 51 | of_cpufreq_cooling_register(struct device_node *np, |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 52 | struct cpufreq_policy *policy); |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 53 | |
| 54 | struct thermal_cooling_device * |
Viresh Kumar | f5f263f | 2017-12-05 11:02:43 +0530 | [diff] [blame] | 55 | of_cpufreq_power_cooling_register(struct cpufreq_policy *policy); |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 56 | #else |
| 57 | static inline struct thermal_cooling_device * |
| 58 | of_cpufreq_cooling_register(struct device_node *np, |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 59 | struct cpufreq_policy *policy) |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 60 | { |
Javi Merino | 503ccc3f | 2014-12-17 11:11:24 +0000 | [diff] [blame] | 61 | return ERR_PTR(-ENOSYS); |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 62 | } |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 63 | |
| 64 | static inline struct thermal_cooling_device * |
Viresh Kumar | f5f263f | 2017-12-05 11:02:43 +0530 | [diff] [blame] | 65 | of_cpufreq_power_cooling_register(struct cpufreq_policy *policy) |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 66 | { |
| 67 | return NULL; |
| 68 | } |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 69 | #endif |
| 70 | |
| 71 | /** |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 72 | * cpufreq_cooling_unregister - function to remove cpufreq cooling device. |
| 73 | * @cdev: thermal cooling device pointer. |
| 74 | */ |
| 75 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); |
Zhang Rui | 57df810 | 2013-02-08 14:52:06 +0800 | [diff] [blame] | 76 | |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 77 | #else /* !CONFIG_CPU_THERMAL */ |
Eduardo Valentin | d44ada5 | 2013-04-17 17:12:23 +0000 | [diff] [blame] | 78 | static inline struct thermal_cooling_device * |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 79 | cpufreq_cooling_register(struct cpufreq_policy *policy) |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 80 | { |
Javi Merino | 503ccc3f | 2014-12-17 11:11:24 +0000 | [diff] [blame] | 81 | return ERR_PTR(-ENOSYS); |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 82 | } |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 83 | |
| 84 | static inline struct thermal_cooling_device * |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 85 | of_cpufreq_cooling_register(struct device_node *np, |
Viresh Kumar | 4d753aa | 2017-04-25 15:57:14 +0530 | [diff] [blame] | 86 | struct cpufreq_policy *policy) |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 87 | { |
Javi Merino | 503ccc3f | 2014-12-17 11:11:24 +0000 | [diff] [blame] | 88 | return ERR_PTR(-ENOSYS); |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 89 | } |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 90 | |
| 91 | static inline struct thermal_cooling_device * |
Viresh Kumar | f5f263f | 2017-12-05 11:02:43 +0530 | [diff] [blame] | 92 | of_cpufreq_power_cooling_register(struct cpufreq_policy *policy) |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 93 | { |
| 94 | return NULL; |
| 95 | } |
| 96 | |
Eduardo Valentin | d44ada5 | 2013-04-17 17:12:23 +0000 | [diff] [blame] | 97 | static inline |
| 98 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 99 | { |
| 100 | return; |
| 101 | } |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 102 | #endif /* CONFIG_CPU_THERMAL */ |
| 103 | |
| 104 | #endif /* __CPU_COOLING_H__ */ |