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 | |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 31 | typedef int (*get_static_t)(cpumask_t *cpumask, int interval, |
| 32 | unsigned long voltage, u32 *power); |
Lina Iyer | 986fde1 | 2016-02-23 13:08:31 -0700 | [diff] [blame] | 33 | typedef int (*plat_mitig_t)(int cpu, u32 clip_freq); |
| 34 | |
| 35 | struct cpu_cooling_ops { |
| 36 | plat_mitig_t ceil_limit, floor_limit; |
| 37 | }; |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 38 | |
Zhang Rui | bbf7fc8 | 2013-03-26 23:57:01 +0800 | [diff] [blame] | 39 | #ifdef CONFIG_CPU_THERMAL |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 40 | /** |
| 41 | * cpufreq_cooling_register - function to create cpufreq cooling device. |
| 42 | * @clip_cpus: cpumask of cpus where the frequency constraints will happen |
| 43 | */ |
Eduardo Valentin | d44ada5 | 2013-04-17 17:12:23 +0000 | [diff] [blame] | 44 | struct thermal_cooling_device * |
| 45 | cpufreq_cooling_register(const struct cpumask *clip_cpus); |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 46 | |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 47 | struct thermal_cooling_device * |
| 48 | cpufreq_power_cooling_register(const struct cpumask *clip_cpus, |
| 49 | u32 capacitance, get_static_t plat_static_func); |
| 50 | |
Lina Iyer | 986fde1 | 2016-02-23 13:08:31 -0700 | [diff] [blame] | 51 | struct thermal_cooling_device * |
| 52 | cpufreq_platform_cooling_register(const struct cpumask *clip_cpus, |
| 53 | struct cpu_cooling_ops *ops); |
| 54 | |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 55 | /** |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 56 | * of_cpufreq_cooling_register - create cpufreq cooling device based on DT. |
| 57 | * @np: a valid struct device_node to the cooling device device tree node. |
| 58 | * @clip_cpus: cpumask of cpus where the frequency constraints will happen |
| 59 | */ |
| 60 | #ifdef CONFIG_THERMAL_OF |
| 61 | struct thermal_cooling_device * |
| 62 | of_cpufreq_cooling_register(struct device_node *np, |
| 63 | const struct cpumask *clip_cpus); |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 64 | |
| 65 | struct thermal_cooling_device * |
| 66 | of_cpufreq_power_cooling_register(struct device_node *np, |
| 67 | const struct cpumask *clip_cpus, |
| 68 | u32 capacitance, |
| 69 | get_static_t plat_static_func); |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 70 | #else |
| 71 | static inline struct thermal_cooling_device * |
| 72 | of_cpufreq_cooling_register(struct device_node *np, |
| 73 | const struct cpumask *clip_cpus) |
| 74 | { |
Javi Merino | 503ccc3 | 2014-12-17 11:11:24 +0000 | [diff] [blame] | 75 | return ERR_PTR(-ENOSYS); |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 76 | } |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 77 | |
| 78 | static inline struct thermal_cooling_device * |
| 79 | of_cpufreq_power_cooling_register(struct device_node *np, |
| 80 | const struct cpumask *clip_cpus, |
| 81 | u32 capacitance, |
| 82 | get_static_t plat_static_func) |
| 83 | { |
| 84 | return NULL; |
| 85 | } |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 86 | #endif |
| 87 | |
| 88 | /** |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 89 | * cpufreq_cooling_unregister - function to remove cpufreq cooling device. |
| 90 | * @cdev: thermal cooling device pointer. |
| 91 | */ |
| 92 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); |
Zhang Rui | 57df810 | 2013-02-08 14:52:06 +0800 | [diff] [blame] | 93 | |
Arnd Bergmann | e8d3924 | 2013-07-05 17:40:13 +0200 | [diff] [blame] | 94 | unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq); |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 95 | #else /* !CONFIG_CPU_THERMAL */ |
Eduardo Valentin | d44ada5 | 2013-04-17 17:12:23 +0000 | [diff] [blame] | 96 | static inline struct thermal_cooling_device * |
| 97 | cpufreq_cooling_register(const struct cpumask *clip_cpus) |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 98 | { |
Javi Merino | 503ccc3 | 2014-12-17 11:11:24 +0000 | [diff] [blame] | 99 | return ERR_PTR(-ENOSYS); |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 100 | } |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 101 | static inline struct thermal_cooling_device * |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 102 | cpufreq_power_cooling_register(const struct cpumask *clip_cpus, |
| 103 | u32 capacitance, get_static_t plat_static_func) |
| 104 | { |
| 105 | return NULL; |
| 106 | } |
| 107 | |
| 108 | static inline struct thermal_cooling_device * |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 109 | of_cpufreq_cooling_register(struct device_node *np, |
| 110 | const struct cpumask *clip_cpus) |
| 111 | { |
Javi Merino | 503ccc3 | 2014-12-17 11:11:24 +0000 | [diff] [blame] | 112 | return ERR_PTR(-ENOSYS); |
Eduardo Valentin | 39d99cf | 2013-09-12 19:26:45 -0400 | [diff] [blame] | 113 | } |
Javi Merino | c36cf07 | 2015-02-26 19:00:29 +0000 | [diff] [blame] | 114 | |
| 115 | static inline struct thermal_cooling_device * |
| 116 | of_cpufreq_power_cooling_register(struct device_node *np, |
| 117 | const struct cpumask *clip_cpus, |
| 118 | u32 capacitance, |
| 119 | get_static_t plat_static_func) |
| 120 | { |
| 121 | return NULL; |
| 122 | } |
| 123 | |
Lina Iyer | 986fde1 | 2016-02-23 13:08:31 -0700 | [diff] [blame] | 124 | static inline struct thermal_cooling_device * |
| 125 | cpufreq_platform_cooling_register(const struct cpumask *clip_cpus, |
| 126 | struct cpu_cooling_ops *ops) |
| 127 | { |
| 128 | return NULL; |
| 129 | } |
| 130 | |
Eduardo Valentin | d44ada5 | 2013-04-17 17:12:23 +0000 | [diff] [blame] | 131 | static inline |
| 132 | void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 133 | { |
| 134 | return; |
| 135 | } |
Eduardo Valentin | d44ada5 | 2013-04-17 17:12:23 +0000 | [diff] [blame] | 136 | static inline |
Arnd Bergmann | e8d3924 | 2013-07-05 17:40:13 +0200 | [diff] [blame] | 137 | unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) |
Zhang Rui | 57df810 | 2013-02-08 14:52:06 +0800 | [diff] [blame] | 138 | { |
| 139 | return THERMAL_CSTATE_INVALID; |
| 140 | } |
Amit Daniel Kachhap | 0236141 | 2012-08-16 17:11:40 +0530 | [diff] [blame] | 141 | #endif /* CONFIG_CPU_THERMAL */ |
| 142 | |
| 143 | #endif /* __CPU_COOLING_H__ */ |