MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 1 | /* |
| 2 | * devfreq: Generic Dynamic Voltage and Frequency Scaling (DVFS) Framework |
| 3 | * for Non-CPU Devices. |
| 4 | * |
| 5 | * Copyright (C) 2011 Samsung Electronics |
| 6 | * MyungJoo Ham <myungjoo.ham@samsung.com> |
| 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 version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #ifndef __LINUX_DEVFREQ_H__ |
| 14 | #define __LINUX_DEVFREQ_H__ |
| 15 | |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/notifier.h> |
Nishanth Menon | e4db1c7 | 2013-09-19 16:03:52 -0500 | [diff] [blame] | 18 | #include <linux/pm_opp.h> |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 19 | |
| 20 | #define DEVFREQ_NAME_LEN 16 |
| 21 | |
Chanwoo Choi | aa7c352 | 2017-10-23 10:32:12 +0900 | [diff] [blame] | 22 | /* DEVFREQ governor name */ |
| 23 | #define DEVFREQ_GOV_SIMPLE_ONDEMAND "simple_ondemand" |
| 24 | #define DEVFREQ_GOV_PERFORMANCE "performance" |
| 25 | #define DEVFREQ_GOV_POWERSAVE "powersave" |
| 26 | #define DEVFREQ_GOV_USERSPACE "userspace" |
| 27 | #define DEVFREQ_GOV_PASSIVE "passive" |
| 28 | |
Chanwoo Choi | 0fe3a66 | 2016-01-26 13:21:26 +0900 | [diff] [blame] | 29 | /* DEVFREQ notifier interface */ |
| 30 | #define DEVFREQ_TRANSITION_NOTIFIER (0) |
| 31 | |
| 32 | /* Transition notifiers of DEVFREQ_TRANSITION_NOTIFIER */ |
| 33 | #define DEVFREQ_PRECHANGE (0) |
| 34 | #define DEVFREQ_POSTCHANGE (1) |
| 35 | |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 36 | struct devfreq; |
Chanwoo Choi | 3ea6b70 | 2017-04-06 13:19:35 +0900 | [diff] [blame] | 37 | struct devfreq_governor; |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * struct devfreq_dev_status - Data given from devfreq user device to |
| 41 | * governors. Represents the performance |
| 42 | * statistics. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 43 | * @total_time: The total time represented by this instance of |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 44 | * devfreq_dev_status |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 45 | * @busy_time: The time that the device was working among the |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 46 | * total_time. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 47 | * @current_frequency: The operating frequency. |
| 48 | * @private_data: An entry not specified by the devfreq framework. |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 49 | * A device and a specific governor may have their |
| 50 | * own protocol with private_data. However, because |
| 51 | * this is governor-specific, a governor using this |
| 52 | * will be only compatible with devices aware of it. |
| 53 | */ |
| 54 | struct devfreq_dev_status { |
| 55 | /* both since the last measure */ |
| 56 | unsigned long total_time; |
| 57 | unsigned long busy_time; |
| 58 | unsigned long current_frequency; |
Jonathan Corbet | 1a51cfd | 2011-11-07 23:54:53 +0100 | [diff] [blame] | 59 | void *private_data; |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 60 | }; |
| 61 | |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 62 | /* |
| 63 | * The resulting frequency should be at most this. (this bound is the |
| 64 | * least upper bound; thus, the resulting freq should be lower or same) |
| 65 | * If the flag is not set, the resulting frequency should be at most the |
| 66 | * bound (greatest lower bound) |
| 67 | */ |
| 68 | #define DEVFREQ_FLAG_LEAST_UPPER_BOUND 0x1 |
| 69 | |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 70 | /** |
| 71 | * struct devfreq_dev_profile - Devfreq's user device profile |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 72 | * @initial_freq: The operating frequency when devfreq_add_device() is |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 73 | * called. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 74 | * @polling_ms: The polling interval in ms. 0 disables polling. |
| 75 | * @target: The device should set its operating frequency at |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 76 | * freq or lowest-upper-than-freq value. If freq is |
| 77 | * higher than any operable frequency, set maximum. |
| 78 | * Before returning, target function should set |
| 79 | * freq at the current frequency. |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 80 | * The "flags" parameter's possible values are |
| 81 | * explained above with "DEVFREQ_FLAG_*" macros. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 82 | * @get_dev_status: The device should provide the current performance |
MyungJoo Ham | d54cdf3 | 2015-08-18 13:45:49 +0900 | [diff] [blame] | 83 | * status to devfreq. Governors are recommended not to |
| 84 | * use this directly. Instead, governors are recommended |
| 85 | * to use devfreq_update_stats() along with |
| 86 | * devfreq.last_status. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 87 | * @get_cur_freq: The device should provide the current frequency |
Rajagopal Venkat | 7f98a90 | 2012-10-26 01:50:26 +0200 | [diff] [blame] | 88 | * at which it is operating. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 89 | * @exit: An optional callback that is called when devfreq |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 90 | * is removing the devfreq object due to error or |
| 91 | * from devfreq_remove_device() call. If the user |
| 92 | * has registered devfreq->nb at a notifier-head, |
| 93 | * this is the time to unregister it. |
Chanwoo Choi | 416b46a | 2017-10-23 10:32:10 +0900 | [diff] [blame] | 94 | * @freq_table: Optional list of frequencies to support statistics |
| 95 | * and freq_table must be generated in ascending order. |
| 96 | * @max_state: The size of freq_table. |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 97 | */ |
| 98 | struct devfreq_dev_profile { |
| 99 | unsigned long initial_freq; |
| 100 | unsigned int polling_ms; |
| 101 | |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 102 | int (*target)(struct device *dev, unsigned long *freq, u32 flags); |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 103 | int (*get_dev_status)(struct device *dev, |
| 104 | struct devfreq_dev_status *stat); |
Rajagopal Venkat | 7f98a90 | 2012-10-26 01:50:26 +0200 | [diff] [blame] | 105 | int (*get_cur_freq)(struct device *dev, unsigned long *freq); |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 106 | void (*exit)(struct device *dev); |
Jonghwa Lee | e552bba | 2012-08-23 20:00:46 +0900 | [diff] [blame] | 107 | |
Chanwoo Choi | 0ec09ac | 2015-11-18 14:49:02 +0900 | [diff] [blame] | 108 | unsigned long *freq_table; |
Jonghwa Lee | e552bba | 2012-08-23 20:00:46 +0900 | [diff] [blame] | 109 | unsigned int max_state; |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | /** |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 113 | * struct devfreq - Device devfreq structure |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 114 | * @node: list node - contains the devices with devfreq that have been |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 115 | * registered. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 116 | * @lock: a mutex to protect accessing devfreq. |
| 117 | * @dev: device registered by devfreq class. dev.parent is the device |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 118 | * using devfreq. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 119 | * @profile: device-specific devfreq profile |
| 120 | * @governor: method how to choose frequency based on the usage. |
Nishanth Menon | 1b5c1be | 2012-10-29 15:01:45 -0500 | [diff] [blame] | 121 | * @governor_name: devfreq governor name for use with this devfreq |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 122 | * @nb: notifier block used to notify devfreq object that it should |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 123 | * reevaluate operable frequencies. Devfreq users may use |
| 124 | * devfreq.nb to the corresponding register notifier call chain. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 125 | * @work: delayed work for load monitoring. |
| 126 | * @previous_freq: previously configured frequency value. |
| 127 | * @data: Private data of the governor. The devfreq framework does not |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 128 | * touch this. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 129 | * @min_freq: Limit minimum frequency requested by user (0: none) |
| 130 | * @max_freq: Limit maximum frequency requested by user (0: none) |
Chanwoo Choi | f1d981e | 2017-10-23 10:32:08 +0900 | [diff] [blame] | 131 | * @scaling_min_freq: Limit minimum frequency requested by OPP interface |
| 132 | * @scaling_max_freq: Limit maximum frequency requested by OPP interface |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 133 | * @stop_polling: devfreq polling status of a device. |
Jonghwa Lee | e552bba | 2012-08-23 20:00:46 +0900 | [diff] [blame] | 134 | * @total_trans: Number of devfreq transitions |
| 135 | * @trans_table: Statistics of devfreq transitions |
| 136 | * @time_in_state: Statistics of devfreq states |
| 137 | * @last_stat_updated: The last time stat updated |
Chanwoo Choi | 0fe3a66 | 2016-01-26 13:21:26 +0900 | [diff] [blame] | 138 | * @transition_notifier_list: list head of DEVFREQ_TRANSITION_NOTIFIER notifier |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 139 | * |
| 140 | * This structure stores the devfreq information for a give device. |
| 141 | * |
| 142 | * Note that when a governor accesses entries in struct devfreq in its |
| 143 | * functions except for the context of callbacks defined in struct |
| 144 | * devfreq_governor, the governor should protect its access with the |
| 145 | * struct mutex lock in struct devfreq. A governor may use this mutex |
| 146 | * to protect its own private data in void *data as well. |
| 147 | */ |
| 148 | struct devfreq { |
| 149 | struct list_head node; |
| 150 | |
| 151 | struct mutex lock; |
| 152 | struct device dev; |
| 153 | struct devfreq_dev_profile *profile; |
| 154 | const struct devfreq_governor *governor; |
Nishanth Menon | 1b5c1be | 2012-10-29 15:01:45 -0500 | [diff] [blame] | 155 | char governor_name[DEVFREQ_NAME_LEN]; |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 156 | struct notifier_block nb; |
Rajagopal Venkat | 7e6fdd4 | 2012-10-26 01:50:09 +0200 | [diff] [blame] | 157 | struct delayed_work work; |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 158 | |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 159 | unsigned long previous_freq; |
Javi Merino | 08e75e7 | 2015-08-14 18:56:56 +0100 | [diff] [blame] | 160 | struct devfreq_dev_status last_status; |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 161 | |
| 162 | void *data; /* private data for governors */ |
| 163 | |
MyungJoo Ham | 6530b9de | 2011-12-09 16:42:19 +0900 | [diff] [blame] | 164 | unsigned long min_freq; |
| 165 | unsigned long max_freq; |
Chanwoo Choi | f1d981e | 2017-10-23 10:32:08 +0900 | [diff] [blame] | 166 | unsigned long scaling_min_freq; |
| 167 | unsigned long scaling_max_freq; |
Rajagopal Venkat | 7e6fdd4 | 2012-10-26 01:50:09 +0200 | [diff] [blame] | 168 | bool stop_polling; |
Jonghwa Lee | e552bba | 2012-08-23 20:00:46 +0900 | [diff] [blame] | 169 | |
LABBE Corentin | 0585123 | 2013-09-26 16:50:21 +0200 | [diff] [blame] | 170 | /* information for device frequency transition */ |
Jonghwa Lee | e552bba | 2012-08-23 20:00:46 +0900 | [diff] [blame] | 171 | unsigned int total_trans; |
| 172 | unsigned int *trans_table; |
| 173 | unsigned long *time_in_state; |
| 174 | unsigned long last_stat_updated; |
Chanwoo Choi | 0fe3a66 | 2016-01-26 13:21:26 +0900 | [diff] [blame] | 175 | |
| 176 | struct srcu_notifier_head transition_notifier_list; |
| 177 | }; |
| 178 | |
| 179 | struct devfreq_freqs { |
| 180 | unsigned long old; |
| 181 | unsigned long new; |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | #if defined(CONFIG_PM_DEVFREQ) |
| 185 | extern struct devfreq *devfreq_add_device(struct device *dev, |
| 186 | struct devfreq_dev_profile *profile, |
Nishanth Menon | 1b5c1be | 2012-10-29 15:01:45 -0500 | [diff] [blame] | 187 | const char *governor_name, |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 188 | void *data); |
| 189 | extern int devfreq_remove_device(struct devfreq *devfreq); |
Chanwoo Choi | 8cd8409 | 2014-05-09 16:43:08 +0900 | [diff] [blame] | 190 | extern struct devfreq *devm_devfreq_add_device(struct device *dev, |
| 191 | struct devfreq_dev_profile *profile, |
| 192 | const char *governor_name, |
| 193 | void *data); |
| 194 | extern void devm_devfreq_remove_device(struct device *dev, |
| 195 | struct devfreq *devfreq); |
MyungJoo Ham | de9c739 | 2013-02-05 18:40:17 +0900 | [diff] [blame] | 196 | |
Rafael J. Wysocki | 464ed18 | 2014-12-19 15:37:54 +0100 | [diff] [blame] | 197 | /* Supposed to be called by PM callbacks */ |
Rajagopal Venkat | 206c30c | 2012-10-26 01:50:18 +0200 | [diff] [blame] | 198 | extern int devfreq_suspend_device(struct devfreq *devfreq); |
| 199 | extern int devfreq_resume_device(struct devfreq *devfreq); |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 200 | |
| 201 | /* Helper functions for devfreq user device driver with OPP. */ |
Nishanth Menon | 47d43ba | 2013-09-19 16:03:51 -0500 | [diff] [blame] | 202 | extern struct dev_pm_opp *devfreq_recommended_opp(struct device *dev, |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 203 | unsigned long *freq, u32 flags); |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 204 | extern int devfreq_register_opp_notifier(struct device *dev, |
| 205 | struct devfreq *devfreq); |
| 206 | extern int devfreq_unregister_opp_notifier(struct device *dev, |
| 207 | struct devfreq *devfreq); |
Chanwoo Choi | d5b040d | 2014-05-09 16:43:09 +0900 | [diff] [blame] | 208 | extern int devm_devfreq_register_opp_notifier(struct device *dev, |
| 209 | struct devfreq *devfreq); |
| 210 | extern void devm_devfreq_unregister_opp_notifier(struct device *dev, |
| 211 | struct devfreq *devfreq); |
Chanwoo Choi | 0fe3a66 | 2016-01-26 13:21:26 +0900 | [diff] [blame] | 212 | extern int devfreq_register_notifier(struct devfreq *devfreq, |
| 213 | struct notifier_block *nb, |
| 214 | unsigned int list); |
| 215 | extern int devfreq_unregister_notifier(struct devfreq *devfreq, |
| 216 | struct notifier_block *nb, |
| 217 | unsigned int list); |
| 218 | extern int devm_devfreq_register_notifier(struct device *dev, |
| 219 | struct devfreq *devfreq, |
| 220 | struct notifier_block *nb, |
| 221 | unsigned int list); |
| 222 | extern void devm_devfreq_unregister_notifier(struct device *dev, |
| 223 | struct devfreq *devfreq, |
| 224 | struct notifier_block *nb, |
| 225 | unsigned int list); |
Chanwoo Choi | 8f510ae | 2015-11-10 20:31:07 +0900 | [diff] [blame] | 226 | extern struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, |
| 227 | int index); |
| 228 | |
MyungJoo Ham | 883d588 | 2012-11-21 17:17:11 +0900 | [diff] [blame] | 229 | #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 230 | /** |
| 231 | * struct devfreq_simple_ondemand_data - void *data fed to struct devfreq |
| 232 | * and devfreq_add_device |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 233 | * @upthreshold: If the load is over this value, the frequency jumps. |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 234 | * Specify 0 to use the default. Valid value = 0 to 100. |
Nishanth Menon | e09651f | 2012-10-29 08:02:23 -0500 | [diff] [blame] | 235 | * @downdifferential: If the load is under upthreshold - downdifferential, |
MyungJoo Ham | ce26c5b | 2011-10-02 00:19:34 +0200 | [diff] [blame] | 236 | * the governor may consider slowing the frequency down. |
| 237 | * Specify 0 to use the default. Valid value = 0 to 100. |
| 238 | * downdifferential < upthreshold must hold. |
| 239 | * |
| 240 | * If the fed devfreq_simple_ondemand_data pointer is NULL to the governor, |
| 241 | * the governor uses the default values. |
| 242 | */ |
| 243 | struct devfreq_simple_ondemand_data { |
| 244 | unsigned int upthreshold; |
| 245 | unsigned int downdifferential; |
| 246 | }; |
| 247 | #endif |
| 248 | |
Chanwoo Choi | 9961331 | 2016-03-22 13:44:03 +0900 | [diff] [blame] | 249 | #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) |
| 250 | /** |
| 251 | * struct devfreq_passive_data - void *data fed to struct devfreq |
| 252 | * and devfreq_add_device |
| 253 | * @parent: the devfreq instance of parent device. |
| 254 | * @get_target_freq: Optional callback, Returns desired operating frequency |
| 255 | * for the device using passive governor. That is called |
| 256 | * when passive governor should decide the next frequency |
| 257 | * by using the new frequency of parent devfreq device |
| 258 | * using governors except for passive governor. |
| 259 | * If the devfreq device has the specific method to decide |
| 260 | * the next frequency, should use this callback. |
| 261 | * @this: the devfreq instance of own device. |
| 262 | * @nb: the notifier block for DEVFREQ_TRANSITION_NOTIFIER list |
| 263 | * |
| 264 | * The devfreq_passive_data have to set the devfreq instance of parent |
| 265 | * device with governors except for the passive governor. But, don't need to |
| 266 | * initialize the 'this' and 'nb' field because the devfreq core will handle |
| 267 | * them. |
| 268 | */ |
| 269 | struct devfreq_passive_data { |
| 270 | /* Should set the devfreq instance of parent device */ |
| 271 | struct devfreq *parent; |
| 272 | |
| 273 | /* Optional callback to decide the next frequency of passvice device */ |
| 274 | int (*get_target_freq)(struct devfreq *this, unsigned long *freq); |
| 275 | |
| 276 | /* For passive governor's internal use. Don't need to set them */ |
| 277 | struct devfreq *this; |
| 278 | struct notifier_block nb; |
| 279 | }; |
| 280 | #endif |
| 281 | |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 282 | #else /* !CONFIG_PM_DEVFREQ */ |
Rajagopal Venkat | 5faaa03 | 2013-03-21 13:28:25 +0000 | [diff] [blame] | 283 | static inline struct devfreq *devfreq_add_device(struct device *dev, |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 284 | struct devfreq_dev_profile *profile, |
Nishanth Menon | 1b5c1be | 2012-10-29 15:01:45 -0500 | [diff] [blame] | 285 | const char *governor_name, |
MyungJoo Ham | a95e1f5 | 2012-01-11 17:44:28 +0900 | [diff] [blame] | 286 | void *data) |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 287 | { |
Chanwoo Choi | 8cd8409 | 2014-05-09 16:43:08 +0900 | [diff] [blame] | 288 | return ERR_PTR(-ENOSYS); |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Rajagopal Venkat | 5faaa03 | 2013-03-21 13:28:25 +0000 | [diff] [blame] | 291 | static inline int devfreq_remove_device(struct devfreq *devfreq) |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 292 | { |
| 293 | return 0; |
| 294 | } |
| 295 | |
Chanwoo Choi | 8cd8409 | 2014-05-09 16:43:08 +0900 | [diff] [blame] | 296 | static inline struct devfreq *devm_devfreq_add_device(struct device *dev, |
| 297 | struct devfreq_dev_profile *profile, |
| 298 | const char *governor_name, |
| 299 | void *data) |
| 300 | { |
| 301 | return ERR_PTR(-ENOSYS); |
| 302 | } |
| 303 | |
| 304 | static inline void devm_devfreq_remove_device(struct device *dev, |
| 305 | struct devfreq *devfreq) |
| 306 | { |
| 307 | } |
| 308 | |
Rajagopal Venkat | 5faaa03 | 2013-03-21 13:28:25 +0000 | [diff] [blame] | 309 | static inline int devfreq_suspend_device(struct devfreq *devfreq) |
Rajagopal Venkat | 206c30c | 2012-10-26 01:50:18 +0200 | [diff] [blame] | 310 | { |
| 311 | return 0; |
| 312 | } |
| 313 | |
Rajagopal Venkat | 5faaa03 | 2013-03-21 13:28:25 +0000 | [diff] [blame] | 314 | static inline int devfreq_resume_device(struct devfreq *devfreq) |
Rajagopal Venkat | 206c30c | 2012-10-26 01:50:18 +0200 | [diff] [blame] | 315 | { |
| 316 | return 0; |
| 317 | } |
| 318 | |
Nishanth Menon | 47d43ba | 2013-09-19 16:03:51 -0500 | [diff] [blame] | 319 | static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev, |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 320 | unsigned long *freq, u32 flags) |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 321 | { |
Rajagopal Venkat | 5faaa03 | 2013-03-21 13:28:25 +0000 | [diff] [blame] | 322 | return ERR_PTR(-EINVAL); |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 323 | } |
| 324 | |
Rajagopal Venkat | 5faaa03 | 2013-03-21 13:28:25 +0000 | [diff] [blame] | 325 | static inline int devfreq_register_opp_notifier(struct device *dev, |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 326 | struct devfreq *devfreq) |
| 327 | { |
| 328 | return -EINVAL; |
| 329 | } |
| 330 | |
Rajagopal Venkat | 5faaa03 | 2013-03-21 13:28:25 +0000 | [diff] [blame] | 331 | static inline int devfreq_unregister_opp_notifier(struct device *dev, |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 332 | struct devfreq *devfreq) |
| 333 | { |
| 334 | return -EINVAL; |
| 335 | } |
| 336 | |
Chanwoo Choi | d5b040d | 2014-05-09 16:43:09 +0900 | [diff] [blame] | 337 | static inline int devm_devfreq_register_opp_notifier(struct device *dev, |
| 338 | struct devfreq *devfreq) |
| 339 | { |
| 340 | return -EINVAL; |
| 341 | } |
| 342 | |
| 343 | static inline void devm_devfreq_unregister_opp_notifier(struct device *dev, |
| 344 | struct devfreq *devfreq) |
| 345 | { |
| 346 | } |
Javi Merino | 08e75e7 | 2015-08-14 18:56:56 +0100 | [diff] [blame] | 347 | |
Chanwoo Choi | 0fe3a66 | 2016-01-26 13:21:26 +0900 | [diff] [blame] | 348 | static inline int devfreq_register_notifier(struct devfreq *devfreq, |
| 349 | struct notifier_block *nb, |
| 350 | unsigned int list) |
| 351 | { |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | static inline int devfreq_unregister_notifier(struct devfreq *devfreq, |
| 356 | struct notifier_block *nb, |
| 357 | unsigned int list) |
| 358 | { |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | static inline int devm_devfreq_register_notifier(struct device *dev, |
| 363 | struct devfreq *devfreq, |
| 364 | struct notifier_block *nb, |
| 365 | unsigned int list) |
| 366 | { |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | static inline void devm_devfreq_unregister_notifier(struct device *dev, |
| 371 | struct devfreq *devfreq, |
| 372 | struct notifier_block *nb, |
| 373 | unsigned int list) |
| 374 | { |
| 375 | } |
| 376 | |
Chanwoo Choi | 8f510ae | 2015-11-10 20:31:07 +0900 | [diff] [blame] | 377 | static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, |
| 378 | int index) |
| 379 | { |
| 380 | return ERR_PTR(-ENODEV); |
| 381 | } |
| 382 | |
Javi Merino | 08e75e7 | 2015-08-14 18:56:56 +0100 | [diff] [blame] | 383 | static inline int devfreq_update_stats(struct devfreq *df) |
| 384 | { |
| 385 | return -EINVAL; |
| 386 | } |
MyungJoo Ham | a3c98b8 | 2011-10-02 00:19:15 +0200 | [diff] [blame] | 387 | #endif /* CONFIG_PM_DEVFREQ */ |
| 388 | |
| 389 | #endif /* __LINUX_DEVFREQ_H__ */ |