Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 2 | /* |
| 3 | * consumer.h -- SoC Regulator consumer support. |
| 4 | * |
| 5 | * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. |
| 6 | * |
Liam Girdwood | 1dd68f0 | 2009-02-02 21:43:31 +0000 | [diff] [blame] | 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 8 | * |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 9 | * Regulator Consumer Interface. |
| 10 | * |
| 11 | * A Power Management Regulator framework for SoC based devices. |
| 12 | * Features:- |
| 13 | * o Voltage and current level control. |
| 14 | * o Operating mode control. |
| 15 | * o Regulator status. |
| 16 | * o sysfs entries for showing client devices and status |
| 17 | * |
| 18 | * EXPERIMENTAL FEATURES: |
| 19 | * Dynamic Regulator operating Mode Switching (DRMS) - allows regulators |
| 20 | * to use most efficient operating mode depending upon voltage and load and |
| 21 | * is transparent to client drivers. |
| 22 | * |
| 23 | * e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during |
| 24 | * IO and 1mA at idle. Device z draws 100mA when under load and 5mA when |
| 25 | * idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA |
| 26 | * but this drops rapidly to 60% when below 100mA. Regulator r has > 90% |
| 27 | * efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate |
| 28 | * in normal mode for loads > 10mA and in IDLE mode for load <= 10mA. |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 29 | */ |
| 30 | |
| 31 | #ifndef __LINUX_REGULATOR_CONSUMER_H_ |
| 32 | #define __LINUX_REGULATOR_CONSUMER_H_ |
| 33 | |
Guenter Roeck | 174e964 | 2014-10-09 12:43:27 -0700 | [diff] [blame] | 34 | #include <linux/err.h> |
| 35 | |
Paul Gortmaker | 313162d | 2012-01-30 11:46:54 -0500 | [diff] [blame] | 36 | struct device; |
| 37 | struct notifier_block; |
Tuomas Tynkkynen | 04eca28 | 2014-07-21 18:38:48 +0300 | [diff] [blame] | 38 | struct regmap; |
Liam Girdwood | b56daf1 | 2009-11-11 14:16:10 +0000 | [diff] [blame] | 39 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 40 | /* |
| 41 | * Regulator operating modes. |
| 42 | * |
| 43 | * Regulators can run in a variety of different operating modes depending on |
| 44 | * output load. This allows further system power savings by selecting the |
| 45 | * best (and most efficient) regulator mode for a desired load. |
| 46 | * |
| 47 | * Most drivers will only care about NORMAL. The modes below are generic and |
| 48 | * will probably not match the naming convention of your regulator data sheet |
| 49 | * but should match the use cases in the datasheet. |
| 50 | * |
| 51 | * In order of power efficiency (least efficient at top). |
| 52 | * |
| 53 | * Mode Description |
| 54 | * FAST Regulator can handle fast changes in it's load. |
| 55 | * e.g. useful in CPU voltage & frequency scaling where |
| 56 | * load can quickly increase with CPU frequency increases. |
| 57 | * |
| 58 | * NORMAL Normal regulator power supply mode. Most drivers will |
| 59 | * use this mode. |
| 60 | * |
| 61 | * IDLE Regulator runs in a more efficient mode for light |
| 62 | * loads. Can be used for devices that have a low power |
| 63 | * requirement during periods of inactivity. This mode |
| 64 | * may be more noisy than NORMAL and may not be able |
| 65 | * to handle fast load switching. |
| 66 | * |
| 67 | * STANDBY Regulator runs in the most efficient mode for very |
| 68 | * light loads. Can be used by devices when they are |
| 69 | * in a sleep/standby state. This mode is likely to be |
| 70 | * the most noisy and may not be able to handle fast load |
| 71 | * switching. |
| 72 | * |
| 73 | * NOTE: Most regulators will only support a subset of these modes. Some |
| 74 | * will only just support NORMAL. |
| 75 | * |
| 76 | * These modes can be OR'ed together to make up a mask of valid register modes. |
| 77 | */ |
| 78 | |
Douglas Anderson | 02f3703 | 2018-04-18 08:54:18 -0700 | [diff] [blame] | 79 | #define REGULATOR_MODE_INVALID 0x0 |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 80 | #define REGULATOR_MODE_FAST 0x1 |
| 81 | #define REGULATOR_MODE_NORMAL 0x2 |
| 82 | #define REGULATOR_MODE_IDLE 0x4 |
| 83 | #define REGULATOR_MODE_STANDBY 0x8 |
| 84 | |
| 85 | /* |
| 86 | * Regulator notifier events. |
| 87 | * |
| 88 | * UNDER_VOLTAGE Regulator output is under voltage. |
| 89 | * OVER_CURRENT Regulator output current is too high. |
| 90 | * REGULATION_OUT Regulator output is out of regulation. |
| 91 | * FAIL Regulator output has failed. |
| 92 | * OVER_TEMP Regulator over temp. |
Mark Brown | 84b6826 | 2009-12-01 21:12:27 +0000 | [diff] [blame] | 93 | * FORCE_DISABLE Regulator forcibly shut down by software. |
Jonathan Cameron | b136fb4 | 2009-01-19 18:20:58 +0000 | [diff] [blame] | 94 | * VOLTAGE_CHANGE Regulator voltage changed. |
Heiko Stübner | 7179569 | 2014-08-28 12:36:04 -0700 | [diff] [blame] | 95 | * Data passed is old voltage cast to (void *). |
Mark Brown | 84b6826 | 2009-12-01 21:12:27 +0000 | [diff] [blame] | 96 | * DISABLE Regulator was disabled. |
Heiko Stübner | 7179569 | 2014-08-28 12:36:04 -0700 | [diff] [blame] | 97 | * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed. |
| 98 | * Data passed is "struct pre_voltage_change_data" |
| 99 | * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason. |
| 100 | * Data passed is old voltage cast to (void *). |
Richard Fitzgerald | a1c8a55 | 2014-11-24 14:10:52 +0000 | [diff] [blame] | 101 | * PRE_DISABLE Regulator is about to be disabled |
| 102 | * ABORT_DISABLE Regulator disable failed for some reason |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 103 | * |
| 104 | * NOTE: These events can be OR'ed together when passed into handler. |
| 105 | */ |
| 106 | |
| 107 | #define REGULATOR_EVENT_UNDER_VOLTAGE 0x01 |
| 108 | #define REGULATOR_EVENT_OVER_CURRENT 0x02 |
| 109 | #define REGULATOR_EVENT_REGULATION_OUT 0x04 |
| 110 | #define REGULATOR_EVENT_FAIL 0x08 |
| 111 | #define REGULATOR_EVENT_OVER_TEMP 0x10 |
| 112 | #define REGULATOR_EVENT_FORCE_DISABLE 0x20 |
Jonathan Cameron | b136fb4 | 2009-01-19 18:20:58 +0000 | [diff] [blame] | 113 | #define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40 |
Geert Uytterhoeven | 5c9e719 | 2015-02-23 17:10:03 +0100 | [diff] [blame] | 114 | #define REGULATOR_EVENT_DISABLE 0x80 |
Heiko Stübner | 7179569 | 2014-08-28 12:36:04 -0700 | [diff] [blame] | 115 | #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100 |
| 116 | #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200 |
Richard Fitzgerald | a1c8a55 | 2014-11-24 14:10:52 +0000 | [diff] [blame] | 117 | #define REGULATOR_EVENT_PRE_DISABLE 0x400 |
| 118 | #define REGULATOR_EVENT_ABORT_DISABLE 0x800 |
Harald Geyer | 264b88c | 2017-02-23 17:06:52 +0000 | [diff] [blame] | 119 | #define REGULATOR_EVENT_ENABLE 0x1000 |
Heiko Stübner | 7179569 | 2014-08-28 12:36:04 -0700 | [diff] [blame] | 120 | |
Axel Haslam | 1b5b422 | 2016-11-03 12:11:42 +0100 | [diff] [blame] | 121 | /* |
| 122 | * Regulator errors that can be queried using regulator_get_error_flags |
| 123 | * |
| 124 | * UNDER_VOLTAGE Regulator output is under voltage. |
| 125 | * OVER_CURRENT Regulator output current is too high. |
| 126 | * REGULATION_OUT Regulator output is out of regulation. |
| 127 | * FAIL Regulator output has failed. |
| 128 | * OVER_TEMP Regulator over temp. |
| 129 | * |
| 130 | * NOTE: These errors can be OR'ed together. |
| 131 | */ |
| 132 | |
| 133 | #define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1) |
| 134 | #define REGULATOR_ERROR_OVER_CURRENT BIT(2) |
| 135 | #define REGULATOR_ERROR_REGULATION_OUT BIT(3) |
| 136 | #define REGULATOR_ERROR_FAIL BIT(4) |
| 137 | #define REGULATOR_ERROR_OVER_TEMP BIT(5) |
| 138 | |
| 139 | |
Heiko Stübner | 7179569 | 2014-08-28 12:36:04 -0700 | [diff] [blame] | 140 | /** |
| 141 | * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event |
| 142 | * |
| 143 | * @old_uV: Current voltage before change. |
| 144 | * @min_uV: Min voltage we'll change to. |
| 145 | * @max_uV: Max voltage we'll change to. |
| 146 | */ |
| 147 | struct pre_voltage_change_data { |
| 148 | unsigned long old_uV; |
| 149 | unsigned long min_uV; |
| 150 | unsigned long max_uV; |
| 151 | }; |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 152 | |
| 153 | struct regulator; |
| 154 | |
| 155 | /** |
| 156 | * struct regulator_bulk_data - Data used for bulk regulator operations. |
| 157 | * |
Mark Brown | 69279fb | 2008-12-31 12:52:41 +0000 | [diff] [blame] | 158 | * @supply: The name of the supply. Initialised by the user before |
| 159 | * using the bulk regulator APIs. |
| 160 | * @consumer: The regulator consumer for the supply. This will be managed |
| 161 | * by the bulk API. |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 162 | * |
| 163 | * The regulator APIs provide a series of regulator_bulk_() API calls as |
| 164 | * a convenience to consumers which require multiple supplies. This |
| 165 | * structure is used to manage data for these calls. |
| 166 | */ |
| 167 | struct regulator_bulk_data { |
| 168 | const char *supply; |
| 169 | struct regulator *consumer; |
Mark Brown | f21e0e8 | 2011-05-24 08:12:40 +0800 | [diff] [blame] | 170 | |
Randy Dunlap | bff747c | 2011-09-08 10:16:47 -0700 | [diff] [blame] | 171 | /* private: Internal use */ |
Mark Brown | f21e0e8 | 2011-05-24 08:12:40 +0800 | [diff] [blame] | 172 | int ret; |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 173 | }; |
| 174 | |
| 175 | #if defined(CONFIG_REGULATOR) |
| 176 | |
| 177 | /* regulator get and put */ |
| 178 | struct regulator *__must_check regulator_get(struct device *dev, |
| 179 | const char *id); |
Stephen Boyd | 070b907 | 2012-01-16 19:39:58 -0800 | [diff] [blame] | 180 | struct regulator *__must_check devm_regulator_get(struct device *dev, |
| 181 | const char *id); |
Mark Brown | 5ffbd13 | 2009-07-21 16:00:23 +0100 | [diff] [blame] | 182 | struct regulator *__must_check regulator_get_exclusive(struct device *dev, |
| 183 | const char *id); |
Matthias Kaehlcke | 9efdd27 | 2013-08-25 17:54:13 +0200 | [diff] [blame] | 184 | struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev, |
| 185 | const char *id); |
Mark Brown | de1dd9f | 2013-07-29 21:42:42 +0100 | [diff] [blame] | 186 | struct regulator *__must_check regulator_get_optional(struct device *dev, |
| 187 | const char *id); |
| 188 | struct regulator *__must_check devm_regulator_get_optional(struct device *dev, |
| 189 | const char *id); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 190 | void regulator_put(struct regulator *regulator); |
Axel Lin | 2950c4b | 2012-01-29 17:52:37 +0800 | [diff] [blame] | 191 | void devm_regulator_put(struct regulator *regulator); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 192 | |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 193 | int regulator_register_supply_alias(struct device *dev, const char *id, |
| 194 | struct device *alias_dev, |
| 195 | const char *alias_id); |
| 196 | void regulator_unregister_supply_alias(struct device *dev, const char *id); |
| 197 | |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 198 | int regulator_bulk_register_supply_alias(struct device *dev, |
| 199 | const char *const *id, |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 200 | struct device *alias_dev, |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 201 | const char *const *alias_id, |
| 202 | int num_id); |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 203 | void regulator_bulk_unregister_supply_alias(struct device *dev, |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 204 | const char * const *id, int num_id); |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 205 | |
| 206 | int devm_regulator_register_supply_alias(struct device *dev, const char *id, |
| 207 | struct device *alias_dev, |
| 208 | const char *alias_id); |
| 209 | void devm_regulator_unregister_supply_alias(struct device *dev, |
| 210 | const char *id); |
| 211 | |
| 212 | int devm_regulator_bulk_register_supply_alias(struct device *dev, |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 213 | const char *const *id, |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 214 | struct device *alias_dev, |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 215 | const char *const *alias_id, |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 216 | int num_id); |
| 217 | void devm_regulator_bulk_unregister_supply_alias(struct device *dev, |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 218 | const char *const *id, |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 219 | int num_id); |
| 220 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 221 | /* regulator output control and status */ |
Mark Brown | c8801a8 | 2012-03-19 16:35:48 +0000 | [diff] [blame] | 222 | int __must_check regulator_enable(struct regulator *regulator); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 223 | int regulator_disable(struct regulator *regulator); |
| 224 | int regulator_force_disable(struct regulator *regulator); |
| 225 | int regulator_is_enabled(struct regulator *regulator); |
Mark Brown | da07ecd | 2011-09-11 09:53:50 +0100 | [diff] [blame] | 226 | int regulator_disable_deferred(struct regulator *regulator, int ms); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 227 | |
Mark Brown | c8801a8 | 2012-03-19 16:35:48 +0000 | [diff] [blame] | 228 | int __must_check regulator_bulk_get(struct device *dev, int num_consumers, |
| 229 | struct regulator_bulk_data *consumers); |
| 230 | int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, |
| 231 | struct regulator_bulk_data *consumers); |
| 232 | int __must_check regulator_bulk_enable(int num_consumers, |
| 233 | struct regulator_bulk_data *consumers); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 234 | int regulator_bulk_disable(int num_consumers, |
| 235 | struct regulator_bulk_data *consumers); |
Donggeun Kim | e1de2f4 | 2012-01-03 16:22:03 +0900 | [diff] [blame] | 236 | int regulator_bulk_force_disable(int num_consumers, |
| 237 | struct regulator_bulk_data *consumers); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 238 | void regulator_bulk_free(int num_consumers, |
| 239 | struct regulator_bulk_data *consumers); |
| 240 | |
David Brownell | 4367cfd | 2009-02-26 11:48:36 -0800 | [diff] [blame] | 241 | int regulator_count_voltages(struct regulator *regulator); |
| 242 | int regulator_list_voltage(struct regulator *regulator, unsigned selector); |
Mark Brown | a7a1ad90 | 2009-07-21 16:00:24 +0100 | [diff] [blame] | 243 | int regulator_is_supported_voltage(struct regulator *regulator, |
| 244 | int min_uV, int max_uV); |
Paul Walmsley | 2a668a8 | 2013-06-07 08:06:56 +0000 | [diff] [blame] | 245 | unsigned int regulator_get_linear_step(struct regulator *regulator); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 246 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); |
Linus Walleij | 88cd222b | 2011-03-17 13:24:52 +0100 | [diff] [blame] | 247 | int regulator_set_voltage_time(struct regulator *regulator, |
| 248 | int old_uV, int new_uV); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 249 | int regulator_get_voltage(struct regulator *regulator); |
Mark Brown | 606a256 | 2010-12-16 15:49:36 +0000 | [diff] [blame] | 250 | int regulator_sync_voltage(struct regulator *regulator); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 251 | int regulator_set_current_limit(struct regulator *regulator, |
| 252 | int min_uA, int max_uA); |
| 253 | int regulator_get_current_limit(struct regulator *regulator); |
| 254 | |
| 255 | int regulator_set_mode(struct regulator *regulator, unsigned int mode); |
| 256 | unsigned int regulator_get_mode(struct regulator *regulator); |
Axel Haslam | 1b5b422 | 2016-11-03 12:11:42 +0100 | [diff] [blame] | 257 | int regulator_get_error_flags(struct regulator *regulator, |
| 258 | unsigned int *flags); |
Bjorn Andersson | e39ce48 | 2015-02-11 19:35:27 -0800 | [diff] [blame] | 259 | int regulator_set_load(struct regulator *regulator, int load_uA); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 260 | |
Mark Brown | f59c8f9 | 2012-08-31 10:36:37 -0700 | [diff] [blame] | 261 | int regulator_allow_bypass(struct regulator *regulator, bool allow); |
| 262 | |
Tuomas Tynkkynen | 04eca28 | 2014-07-21 18:38:48 +0300 | [diff] [blame] | 263 | struct regmap *regulator_get_regmap(struct regulator *regulator); |
| 264 | int regulator_get_hardware_vsel_register(struct regulator *regulator, |
| 265 | unsigned *vsel_reg, |
| 266 | unsigned *vsel_mask); |
| 267 | int regulator_list_hardware_vsel(struct regulator *regulator, |
| 268 | unsigned selector); |
| 269 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 270 | /* regulator notifier block */ |
| 271 | int regulator_register_notifier(struct regulator *regulator, |
| 272 | struct notifier_block *nb); |
Charles Keepax | 046db76 | 2015-03-05 15:39:20 +0000 | [diff] [blame] | 273 | int devm_regulator_register_notifier(struct regulator *regulator, |
| 274 | struct notifier_block *nb); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 275 | int regulator_unregister_notifier(struct regulator *regulator, |
| 276 | struct notifier_block *nb); |
Charles Keepax | 046db76 | 2015-03-05 15:39:20 +0000 | [diff] [blame] | 277 | void devm_regulator_unregister_notifier(struct regulator *regulator, |
| 278 | struct notifier_block *nb); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 279 | |
| 280 | /* driver data - core doesn't touch */ |
| 281 | void *regulator_get_drvdata(struct regulator *regulator); |
| 282 | void regulator_set_drvdata(struct regulator *regulator, void *data); |
| 283 | |
| 284 | #else |
| 285 | |
| 286 | /* |
| 287 | * Make sure client drivers will still build on systems with no software |
| 288 | * controllable voltage or current regulators. |
| 289 | */ |
| 290 | static inline struct regulator *__must_check regulator_get(struct device *dev, |
| 291 | const char *id) |
| 292 | { |
| 293 | /* Nothing except the stubbed out regulator API should be |
| 294 | * looking at the value except to check if it is an error |
Jean Delvare | be1a50d | 2010-04-03 17:37:45 +0200 | [diff] [blame] | 295 | * value. Drivers are free to handle NULL specifically by |
| 296 | * skipping all regulator API calls, but they don't have to. |
| 297 | * Drivers which don't, should make sure they properly handle |
| 298 | * corner cases of the API, such as regulator_get_voltage() |
| 299 | * returning 0. |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 300 | */ |
Jean Delvare | be1a50d | 2010-04-03 17:37:45 +0200 | [diff] [blame] | 301 | return NULL; |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 302 | } |
Stephen Boyd | 070b907 | 2012-01-16 19:39:58 -0800 | [diff] [blame] | 303 | |
| 304 | static inline struct regulator *__must_check |
| 305 | devm_regulator_get(struct device *dev, const char *id) |
| 306 | { |
| 307 | return NULL; |
| 308 | } |
| 309 | |
Mark Brown | de1dd9f | 2013-07-29 21:42:42 +0100 | [diff] [blame] | 310 | static inline struct regulator *__must_check |
Mark Brown | 4bdfb27 | 2013-07-29 21:00:53 +0100 | [diff] [blame] | 311 | regulator_get_exclusive(struct device *dev, const char *id) |
| 312 | { |
Mark Brown | 70b946f | 2014-10-24 21:56:58 +0100 | [diff] [blame] | 313 | return ERR_PTR(-ENODEV); |
Mark Brown | 4bdfb27 | 2013-07-29 21:00:53 +0100 | [diff] [blame] | 314 | } |
| 315 | |
Mark Brown | de1dd9f | 2013-07-29 21:42:42 +0100 | [diff] [blame] | 316 | static inline struct regulator *__must_check |
| 317 | regulator_get_optional(struct device *dev, const char *id) |
| 318 | { |
Tim Kryger | df7926f | 2014-04-17 11:55:24 -0700 | [diff] [blame] | 319 | return ERR_PTR(-ENODEV); |
Mark Brown | de1dd9f | 2013-07-29 21:42:42 +0100 | [diff] [blame] | 320 | } |
| 321 | |
Mark Brown | 4bdfb27 | 2013-07-29 21:00:53 +0100 | [diff] [blame] | 322 | |
| 323 | static inline struct regulator *__must_check |
Mark Brown | de1dd9f | 2013-07-29 21:42:42 +0100 | [diff] [blame] | 324 | devm_regulator_get_optional(struct device *dev, const char *id) |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 325 | { |
Tim Kryger | df7926f | 2014-04-17 11:55:24 -0700 | [diff] [blame] | 326 | return ERR_PTR(-ENODEV); |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | static inline void regulator_put(struct regulator *regulator) |
| 330 | { |
| 331 | } |
| 332 | |
Axel Lin | 2950c4b | 2012-01-29 17:52:37 +0800 | [diff] [blame] | 333 | static inline void devm_regulator_put(struct regulator *regulator) |
| 334 | { |
| 335 | } |
| 336 | |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 337 | static inline int regulator_register_supply_alias(struct device *dev, |
| 338 | const char *id, |
| 339 | struct device *alias_dev, |
| 340 | const char *alias_id) |
| 341 | { |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | static inline void regulator_unregister_supply_alias(struct device *dev, |
| 346 | const char *id) |
| 347 | { |
| 348 | } |
| 349 | |
| 350 | static inline int regulator_bulk_register_supply_alias(struct device *dev, |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 351 | const char *const *id, |
| 352 | struct device *alias_dev, |
| 353 | const char * const *alias_id, |
| 354 | int num_id) |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 355 | { |
| 356 | return 0; |
| 357 | } |
| 358 | |
| 359 | static inline void regulator_bulk_unregister_supply_alias(struct device *dev, |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 360 | const char * const *id, |
| 361 | int num_id) |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 362 | { |
| 363 | } |
| 364 | |
| 365 | static inline int devm_regulator_register_supply_alias(struct device *dev, |
| 366 | const char *id, |
| 367 | struct device *alias_dev, |
| 368 | const char *alias_id) |
| 369 | { |
| 370 | return 0; |
| 371 | } |
| 372 | |
| 373 | static inline void devm_regulator_unregister_supply_alias(struct device *dev, |
| 374 | const char *id) |
| 375 | { |
| 376 | } |
| 377 | |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 378 | static inline int devm_regulator_bulk_register_supply_alias(struct device *dev, |
| 379 | const char *const *id, |
| 380 | struct device *alias_dev, |
| 381 | const char *const *alias_id, |
| 382 | int num_id) |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 383 | { |
| 384 | return 0; |
| 385 | } |
| 386 | |
| 387 | static inline void devm_regulator_bulk_unregister_supply_alias( |
Lee Jones | 9f8c0fe | 2014-05-23 16:44:10 +0100 | [diff] [blame] | 388 | struct device *dev, const char *const *id, int num_id) |
Charles Keepax | a06ccd9 | 2013-10-15 20:14:20 +0100 | [diff] [blame] | 389 | { |
| 390 | } |
| 391 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 392 | static inline int regulator_enable(struct regulator *regulator) |
| 393 | { |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | static inline int regulator_disable(struct regulator *regulator) |
| 398 | { |
| 399 | return 0; |
| 400 | } |
| 401 | |
MyungJoo Ham | 935a5210 | 2012-01-02 18:49:32 +0900 | [diff] [blame] | 402 | static inline int regulator_force_disable(struct regulator *regulator) |
| 403 | { |
| 404 | return 0; |
| 405 | } |
| 406 | |
Mark Brown | da07ecd | 2011-09-11 09:53:50 +0100 | [diff] [blame] | 407 | static inline int regulator_disable_deferred(struct regulator *regulator, |
| 408 | int ms) |
| 409 | { |
| 410 | return 0; |
| 411 | } |
| 412 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 413 | static inline int regulator_is_enabled(struct regulator *regulator) |
| 414 | { |
| 415 | return 1; |
| 416 | } |
| 417 | |
| 418 | static inline int regulator_bulk_get(struct device *dev, |
| 419 | int num_consumers, |
| 420 | struct regulator_bulk_data *consumers) |
| 421 | { |
| 422 | return 0; |
| 423 | } |
| 424 | |
Axel Lin | e24abd6 | 2012-01-27 12:55:28 +0800 | [diff] [blame] | 425 | static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers, |
| 426 | struct regulator_bulk_data *consumers) |
| 427 | { |
| 428 | return 0; |
| 429 | } |
| 430 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 431 | static inline int regulator_bulk_enable(int num_consumers, |
| 432 | struct regulator_bulk_data *consumers) |
| 433 | { |
| 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | static inline int regulator_bulk_disable(int num_consumers, |
| 438 | struct regulator_bulk_data *consumers) |
| 439 | { |
| 440 | return 0; |
| 441 | } |
| 442 | |
Donggeun Kim | e1de2f4 | 2012-01-03 16:22:03 +0900 | [diff] [blame] | 443 | static inline int regulator_bulk_force_disable(int num_consumers, |
| 444 | struct regulator_bulk_data *consumers) |
| 445 | { |
| 446 | return 0; |
| 447 | } |
| 448 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 449 | static inline void regulator_bulk_free(int num_consumers, |
| 450 | struct regulator_bulk_data *consumers) |
| 451 | { |
| 452 | } |
| 453 | |
| 454 | static inline int regulator_set_voltage(struct regulator *regulator, |
| 455 | int min_uV, int max_uV) |
| 456 | { |
| 457 | return 0; |
| 458 | } |
| 459 | |
Viresh Kumar | d660e92 | 2014-05-27 17:37:29 +0530 | [diff] [blame] | 460 | static inline int regulator_set_voltage_time(struct regulator *regulator, |
| 461 | int old_uV, int new_uV) |
| 462 | { |
| 463 | return 0; |
| 464 | } |
| 465 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 466 | static inline int regulator_get_voltage(struct regulator *regulator) |
| 467 | { |
Mark Brown | 08aed2f | 2012-06-11 20:14:24 +0800 | [diff] [blame] | 468 | return -EINVAL; |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 469 | } |
| 470 | |
Philip Rakity | 4fe2379 | 2012-06-30 16:05:36 -0700 | [diff] [blame] | 471 | static inline int regulator_is_supported_voltage(struct regulator *regulator, |
| 472 | int min_uV, int max_uV) |
| 473 | { |
| 474 | return 0; |
| 475 | } |
| 476 | |
Arnd Bergmann | 7287275 | 2019-03-04 20:38:29 +0100 | [diff] [blame] | 477 | static inline unsigned int regulator_get_linear_step(struct regulator *regulator) |
| 478 | { |
| 479 | return 0; |
| 480 | } |
| 481 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 482 | static inline int regulator_set_current_limit(struct regulator *regulator, |
| 483 | int min_uA, int max_uA) |
| 484 | { |
| 485 | return 0; |
| 486 | } |
| 487 | |
| 488 | static inline int regulator_get_current_limit(struct regulator *regulator) |
| 489 | { |
| 490 | return 0; |
| 491 | } |
| 492 | |
| 493 | static inline int regulator_set_mode(struct regulator *regulator, |
| 494 | unsigned int mode) |
| 495 | { |
| 496 | return 0; |
| 497 | } |
| 498 | |
| 499 | static inline unsigned int regulator_get_mode(struct regulator *regulator) |
| 500 | { |
| 501 | return REGULATOR_MODE_NORMAL; |
| 502 | } |
| 503 | |
David Lechner | 30103b5 | 2016-12-04 16:52:31 -0600 | [diff] [blame] | 504 | static inline int regulator_get_error_flags(struct regulator *regulator, |
| 505 | unsigned int *flags) |
Axel Haslam | 1b5b422 | 2016-11-03 12:11:42 +0100 | [diff] [blame] | 506 | { |
| 507 | return -EINVAL; |
| 508 | } |
| 509 | |
Bjorn Andersson | e39ce48 | 2015-02-11 19:35:27 -0800 | [diff] [blame] | 510 | static inline int regulator_set_load(struct regulator *regulator, int load_uA) |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 511 | { |
Mark Brown | f1abf67 | 2018-11-16 19:19:30 -0800 | [diff] [blame] | 512 | return 0; |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Mark Brown | f59c8f9 | 2012-08-31 10:36:37 -0700 | [diff] [blame] | 515 | static inline int regulator_allow_bypass(struct regulator *regulator, |
| 516 | bool allow) |
| 517 | { |
| 518 | return 0; |
| 519 | } |
| 520 | |
Mark Brown | 3bc0312 | 2014-07-25 19:07:11 +0100 | [diff] [blame] | 521 | static inline struct regmap *regulator_get_regmap(struct regulator *regulator) |
Tuomas Tynkkynen | 04eca28 | 2014-07-21 18:38:48 +0300 | [diff] [blame] | 522 | { |
| 523 | return ERR_PTR(-EOPNOTSUPP); |
| 524 | } |
| 525 | |
Mark Brown | 3bc0312 | 2014-07-25 19:07:11 +0100 | [diff] [blame] | 526 | static inline int regulator_get_hardware_vsel_register(struct regulator *regulator, |
| 527 | unsigned *vsel_reg, |
| 528 | unsigned *vsel_mask) |
Tuomas Tynkkynen | 04eca28 | 2014-07-21 18:38:48 +0300 | [diff] [blame] | 529 | { |
| 530 | return -EOPNOTSUPP; |
| 531 | } |
| 532 | |
Mark Brown | 3bc0312 | 2014-07-25 19:07:11 +0100 | [diff] [blame] | 533 | static inline int regulator_list_hardware_vsel(struct regulator *regulator, |
| 534 | unsigned selector) |
Tuomas Tynkkynen | 04eca28 | 2014-07-21 18:38:48 +0300 | [diff] [blame] | 535 | { |
| 536 | return -EOPNOTSUPP; |
| 537 | } |
| 538 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 539 | static inline int regulator_register_notifier(struct regulator *regulator, |
| 540 | struct notifier_block *nb) |
| 541 | { |
| 542 | return 0; |
| 543 | } |
| 544 | |
Charles Keepax | 046db76 | 2015-03-05 15:39:20 +0000 | [diff] [blame] | 545 | static inline int devm_regulator_register_notifier(struct regulator *regulator, |
| 546 | struct notifier_block *nb) |
| 547 | { |
| 548 | return 0; |
| 549 | } |
| 550 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 551 | static inline int regulator_unregister_notifier(struct regulator *regulator, |
| 552 | struct notifier_block *nb) |
| 553 | { |
| 554 | return 0; |
| 555 | } |
| 556 | |
Charles Keepax | 046db76 | 2015-03-05 15:39:20 +0000 | [diff] [blame] | 557 | static inline int devm_regulator_unregister_notifier(struct regulator *regulator, |
| 558 | struct notifier_block *nb) |
| 559 | { |
| 560 | return 0; |
| 561 | } |
| 562 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 563 | static inline void *regulator_get_drvdata(struct regulator *regulator) |
| 564 | { |
| 565 | return NULL; |
| 566 | } |
| 567 | |
| 568 | static inline void regulator_set_drvdata(struct regulator *regulator, |
| 569 | void *data) |
| 570 | { |
| 571 | } |
| 572 | |
Philip Rakity | 1a8f85d | 2012-11-20 18:07:41 +0100 | [diff] [blame] | 573 | static inline int regulator_count_voltages(struct regulator *regulator) |
| 574 | { |
| 575 | return 0; |
| 576 | } |
Suzuki K. Poulose | 5127e31 | 2015-07-10 16:26:38 +0100 | [diff] [blame] | 577 | |
| 578 | static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector) |
| 579 | { |
| 580 | return -EINVAL; |
| 581 | } |
| 582 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 583 | #endif |
| 584 | |
Viresh Kumar | 30f93ca | 2015-08-17 08:16:51 +0530 | [diff] [blame] | 585 | static inline int regulator_set_voltage_triplet(struct regulator *regulator, |
| 586 | int min_uV, int target_uV, |
| 587 | int max_uV) |
| 588 | { |
| 589 | if (regulator_set_voltage(regulator, target_uV, max_uV) == 0) |
| 590 | return 0; |
| 591 | |
| 592 | return regulator_set_voltage(regulator, min_uV, max_uV); |
| 593 | } |
| 594 | |
Shawn Guo | 3f19657 | 2012-08-05 23:05:20 +0800 | [diff] [blame] | 595 | static inline int regulator_set_voltage_tol(struct regulator *regulator, |
| 596 | int new_uV, int tol_uV) |
| 597 | { |
Mark Brown | dc9ceed | 2013-07-04 17:27:14 +0100 | [diff] [blame] | 598 | if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0) |
| 599 | return 0; |
| 600 | else |
| 601 | return regulator_set_voltage(regulator, |
| 602 | new_uV - tol_uV, new_uV + tol_uV); |
Shawn Guo | 3f19657 | 2012-08-05 23:05:20 +0800 | [diff] [blame] | 603 | } |
| 604 | |
Mark Brown | fe1e43f | 2012-11-14 16:47:10 +0900 | [diff] [blame] | 605 | static inline int regulator_is_supported_voltage_tol(struct regulator *regulator, |
| 606 | int target_uV, int tol_uV) |
| 607 | { |
| 608 | return regulator_is_supported_voltage(regulator, |
| 609 | target_uV - tol_uV, |
| 610 | target_uV + tol_uV); |
| 611 | } |
| 612 | |
Liam Girdwood | e2ce4eaa | 2008-04-30 15:10:07 +0100 | [diff] [blame] | 613 | #endif |