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