| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ | 
|---|
| 2 | /* | 
|---|
| 3 | * consumer.h -- SoC Regulator consumer support. | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. | 
|---|
| 6 | * | 
|---|
| 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> | 
|---|
| 8 | * | 
|---|
| 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. | 
|---|
| 29 | */ | 
|---|
| 30 |  | 
|---|
| 31 | #ifndef __LINUX_REGULATOR_CONSUMER_H_ | 
|---|
| 32 | #define __LINUX_REGULATOR_CONSUMER_H_ | 
|---|
| 33 |  | 
|---|
| 34 | #include <linux/err.h> | 
|---|
| 35 | #include <linux/suspend.h> | 
|---|
| 36 | #include <regulator/regulator.h> | 
|---|
| 37 |  | 
|---|
| 38 | struct device; | 
|---|
| 39 | struct notifier_block; | 
|---|
| 40 | struct regmap; | 
|---|
| 41 | struct regulator_dev; | 
|---|
| 42 |  | 
|---|
| 43 | /* | 
|---|
| 44 | * Regulator operating modes. | 
|---|
| 45 | * | 
|---|
| 46 | * Regulators can run in a variety of different operating modes depending on | 
|---|
| 47 | * output load. This allows further system power savings by selecting the | 
|---|
| 48 | * best (and most efficient) regulator mode for a desired load. | 
|---|
| 49 | * | 
|---|
| 50 | * Most drivers will only care about NORMAL. The modes below are generic and | 
|---|
| 51 | * will probably not match the naming convention of your regulator data sheet | 
|---|
| 52 | * but should match the use cases in the datasheet. | 
|---|
| 53 | * | 
|---|
| 54 | * In order of power efficiency (least efficient at top). | 
|---|
| 55 | * | 
|---|
| 56 | *  Mode       Description | 
|---|
| 57 | *  FAST       Regulator can handle fast changes in it's load. | 
|---|
| 58 | *             e.g. useful in CPU voltage & frequency scaling where | 
|---|
| 59 | *             load can quickly increase with CPU frequency increases. | 
|---|
| 60 | * | 
|---|
| 61 | *  NORMAL     Normal regulator power supply mode. Most drivers will | 
|---|
| 62 | *             use this mode. | 
|---|
| 63 | * | 
|---|
| 64 | *  IDLE       Regulator runs in a more efficient mode for light | 
|---|
| 65 | *             loads. Can be used for devices that have a low power | 
|---|
| 66 | *             requirement during periods of inactivity. This mode | 
|---|
| 67 | *             may be more noisy than NORMAL and may not be able | 
|---|
| 68 | *             to handle fast load switching. | 
|---|
| 69 | * | 
|---|
| 70 | *  STANDBY    Regulator runs in the most efficient mode for very | 
|---|
| 71 | *             light loads. Can be used by devices when they are | 
|---|
| 72 | *             in a sleep/standby state. This mode is likely to be | 
|---|
| 73 | *             the most noisy and may not be able to handle fast load | 
|---|
| 74 | *             switching. | 
|---|
| 75 | * | 
|---|
| 76 | * NOTE: Most regulators will only support a subset of these modes. Some | 
|---|
| 77 | * will only just support NORMAL. | 
|---|
| 78 | * | 
|---|
| 79 | * These modes can be OR'ed together to make up a mask of valid register modes. | 
|---|
| 80 | */ | 
|---|
| 81 |  | 
|---|
| 82 | #define REGULATOR_MODE_INVALID			0x0 | 
|---|
| 83 | #define REGULATOR_MODE_FAST			0x1 | 
|---|
| 84 | #define REGULATOR_MODE_NORMAL			0x2 | 
|---|
| 85 | #define REGULATOR_MODE_IDLE			0x4 | 
|---|
| 86 | #define REGULATOR_MODE_STANDBY			0x8 | 
|---|
| 87 |  | 
|---|
| 88 | /* | 
|---|
| 89 | * Regulator errors that can be queried using regulator_get_error_flags | 
|---|
| 90 | * | 
|---|
| 91 | * UNDER_VOLTAGE  Regulator output is under voltage. | 
|---|
| 92 | * OVER_CURRENT   Regulator output current is too high. | 
|---|
| 93 | * REGULATION_OUT Regulator output is out of regulation. | 
|---|
| 94 | * FAIL           Regulator output has failed. | 
|---|
| 95 | * OVER_TEMP      Regulator over temp. | 
|---|
| 96 | * | 
|---|
| 97 | * NOTE: These errors can be OR'ed together. | 
|---|
| 98 | */ | 
|---|
| 99 |  | 
|---|
| 100 | #define REGULATOR_ERROR_UNDER_VOLTAGE		BIT(1) | 
|---|
| 101 | #define REGULATOR_ERROR_OVER_CURRENT		BIT(2) | 
|---|
| 102 | #define REGULATOR_ERROR_REGULATION_OUT		BIT(3) | 
|---|
| 103 | #define REGULATOR_ERROR_FAIL			BIT(4) | 
|---|
| 104 | #define REGULATOR_ERROR_OVER_TEMP		BIT(5) | 
|---|
| 105 |  | 
|---|
| 106 | #define REGULATOR_ERROR_UNDER_VOLTAGE_WARN	BIT(6) | 
|---|
| 107 | #define REGULATOR_ERROR_OVER_CURRENT_WARN	BIT(7) | 
|---|
| 108 | #define REGULATOR_ERROR_OVER_VOLTAGE_WARN	BIT(8) | 
|---|
| 109 | #define REGULATOR_ERROR_OVER_TEMP_WARN		BIT(9) | 
|---|
| 110 |  | 
|---|
| 111 | /** | 
|---|
| 112 | * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event | 
|---|
| 113 | * | 
|---|
| 114 | * @old_uV: Current voltage before change. | 
|---|
| 115 | * @min_uV: Min voltage we'll change to. | 
|---|
| 116 | * @max_uV: Max voltage we'll change to. | 
|---|
| 117 | */ | 
|---|
| 118 | struct pre_voltage_change_data { | 
|---|
| 119 | unsigned long old_uV; | 
|---|
| 120 | unsigned long min_uV; | 
|---|
| 121 | unsigned long max_uV; | 
|---|
| 122 | }; | 
|---|
| 123 |  | 
|---|
| 124 | struct regulator; | 
|---|
| 125 |  | 
|---|
| 126 | /** | 
|---|
| 127 | * struct regulator_bulk_data - Data used for bulk regulator operations. | 
|---|
| 128 | * | 
|---|
| 129 | * @supply:       The name of the supply.  Initialised by the user before | 
|---|
| 130 | *                using the bulk regulator APIs. | 
|---|
| 131 | * @consumer:     The regulator consumer for the supply.  This will be managed | 
|---|
| 132 | *                by the bulk API. | 
|---|
| 133 | * @init_load_uA: After getting the regulator, regulator_set_load() will be | 
|---|
| 134 | *                called with this load.  Initialised by the user before | 
|---|
| 135 | *                using the bulk regulator APIs. | 
|---|
| 136 | * | 
|---|
| 137 | * The regulator APIs provide a series of regulator_bulk_() API calls as | 
|---|
| 138 | * a convenience to consumers which require multiple supplies.  This | 
|---|
| 139 | * structure is used to manage data for these calls. | 
|---|
| 140 | */ | 
|---|
| 141 | struct regulator_bulk_data { | 
|---|
| 142 | const char *supply; | 
|---|
| 143 | struct regulator *consumer; | 
|---|
| 144 | int init_load_uA; | 
|---|
| 145 |  | 
|---|
| 146 | /* private: Internal use */ | 
|---|
| 147 | int ret; | 
|---|
| 148 | }; | 
|---|
| 149 |  | 
|---|
| 150 | #if defined(CONFIG_REGULATOR) | 
|---|
| 151 |  | 
|---|
| 152 | /* regulator get and put */ | 
|---|
| 153 | struct regulator *__must_check regulator_get(struct device *dev, | 
|---|
| 154 | const char *id); | 
|---|
| 155 | struct regulator *__must_check devm_regulator_get(struct device *dev, | 
|---|
| 156 | const char *id); | 
|---|
| 157 | struct regulator *__must_check regulator_get_exclusive(struct device *dev, | 
|---|
| 158 | const char *id); | 
|---|
| 159 | struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev, | 
|---|
| 160 | const char *id); | 
|---|
| 161 | struct regulator *__must_check regulator_get_optional(struct device *dev, | 
|---|
| 162 | const char *id); | 
|---|
| 163 | struct regulator *__must_check devm_regulator_get_optional(struct device *dev, | 
|---|
| 164 | const char *id); | 
|---|
| 165 | int devm_regulator_get_enable(struct device *dev, const char *id); | 
|---|
| 166 | int devm_regulator_get_enable_optional(struct device *dev, const char *id); | 
|---|
| 167 | int devm_regulator_get_enable_read_voltage(struct device *dev, const char *id); | 
|---|
| 168 | void regulator_put(struct regulator *regulator); | 
|---|
| 169 | void devm_regulator_put(struct regulator *regulator); | 
|---|
| 170 |  | 
|---|
| 171 | int regulator_register_supply_alias(struct device *dev, const char *id, | 
|---|
| 172 | struct device *alias_dev, | 
|---|
| 173 | const char *alias_id); | 
|---|
| 174 | void regulator_unregister_supply_alias(struct device *dev, const char *id); | 
|---|
| 175 |  | 
|---|
| 176 | int regulator_bulk_register_supply_alias(struct device *dev, | 
|---|
| 177 | const char *const *id, | 
|---|
| 178 | struct device *alias_dev, | 
|---|
| 179 | const char *const *alias_id, | 
|---|
| 180 | int num_id); | 
|---|
| 181 | void regulator_bulk_unregister_supply_alias(struct device *dev, | 
|---|
| 182 | const char * const *id, int num_id); | 
|---|
| 183 |  | 
|---|
| 184 | int devm_regulator_register_supply_alias(struct device *dev, const char *id, | 
|---|
| 185 | struct device *alias_dev, | 
|---|
| 186 | const char *alias_id); | 
|---|
| 187 |  | 
|---|
| 188 | int devm_regulator_bulk_register_supply_alias(struct device *dev, | 
|---|
| 189 | const char *const *id, | 
|---|
| 190 | struct device *alias_dev, | 
|---|
| 191 | const char *const *alias_id, | 
|---|
| 192 | int num_id); | 
|---|
| 193 |  | 
|---|
| 194 | /* regulator output control and status */ | 
|---|
| 195 | int __must_check regulator_enable(struct regulator *regulator); | 
|---|
| 196 | int regulator_disable(struct regulator *regulator); | 
|---|
| 197 | int regulator_force_disable(struct regulator *regulator); | 
|---|
| 198 | int regulator_is_enabled(struct regulator *regulator); | 
|---|
| 199 | int regulator_disable_deferred(struct regulator *regulator, int ms); | 
|---|
| 200 |  | 
|---|
| 201 | int __must_check regulator_bulk_get(struct device *dev, int num_consumers, | 
|---|
| 202 | struct regulator_bulk_data *consumers); | 
|---|
| 203 | int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, | 
|---|
| 204 | struct regulator_bulk_data *consumers); | 
|---|
| 205 | void devm_regulator_bulk_put(struct regulator_bulk_data *consumers); | 
|---|
| 206 | int __must_check devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers, | 
|---|
| 207 | struct regulator_bulk_data *consumers); | 
|---|
| 208 | int __must_check devm_regulator_bulk_get_const( | 
|---|
| 209 | struct device *dev, int num_consumers, | 
|---|
| 210 | const struct regulator_bulk_data *in_consumers, | 
|---|
| 211 | struct regulator_bulk_data **out_consumers); | 
|---|
| 212 | int __must_check regulator_bulk_enable(int num_consumers, | 
|---|
| 213 | struct regulator_bulk_data *consumers); | 
|---|
| 214 | int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, | 
|---|
| 215 | const char * const *id); | 
|---|
| 216 | int regulator_bulk_disable(int num_consumers, | 
|---|
| 217 | struct regulator_bulk_data *consumers); | 
|---|
| 218 | int regulator_bulk_force_disable(int num_consumers, | 
|---|
| 219 | struct regulator_bulk_data *consumers); | 
|---|
| 220 | void regulator_bulk_free(int num_consumers, | 
|---|
| 221 | struct regulator_bulk_data *consumers); | 
|---|
| 222 |  | 
|---|
| 223 | int regulator_count_voltages(struct regulator *regulator); | 
|---|
| 224 | int regulator_list_voltage(struct regulator *regulator, unsigned selector); | 
|---|
| 225 | int regulator_is_supported_voltage(struct regulator *regulator, | 
|---|
| 226 | int min_uV, int max_uV); | 
|---|
| 227 | unsigned int regulator_get_linear_step(struct regulator *regulator); | 
|---|
| 228 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); | 
|---|
| 229 | int regulator_set_voltage_time(struct regulator *regulator, | 
|---|
| 230 | int old_uV, int new_uV); | 
|---|
| 231 | int regulator_get_voltage(struct regulator *regulator); | 
|---|
| 232 | int regulator_sync_voltage(struct regulator *regulator); | 
|---|
| 233 | int regulator_set_current_limit(struct regulator *regulator, | 
|---|
| 234 | int min_uA, int max_uA); | 
|---|
| 235 | int regulator_get_current_limit(struct regulator *regulator); | 
|---|
| 236 | int regulator_get_unclaimed_power_budget(struct regulator *regulator); | 
|---|
| 237 | int regulator_request_power_budget(struct regulator *regulator, | 
|---|
| 238 | unsigned int pw_req); | 
|---|
| 239 | void regulator_free_power_budget(struct regulator *regulator, | 
|---|
| 240 | unsigned int pw); | 
|---|
| 241 |  | 
|---|
| 242 | int regulator_set_mode(struct regulator *regulator, unsigned int mode); | 
|---|
| 243 | unsigned int regulator_get_mode(struct regulator *regulator); | 
|---|
| 244 | int regulator_get_error_flags(struct regulator *regulator, | 
|---|
| 245 | unsigned int *flags); | 
|---|
| 246 | int regulator_set_load(struct regulator *regulator, int load_uA); | 
|---|
| 247 |  | 
|---|
| 248 | int regulator_allow_bypass(struct regulator *regulator, bool allow); | 
|---|
| 249 |  | 
|---|
| 250 | struct regmap *regulator_get_regmap(struct regulator *regulator); | 
|---|
| 251 | int regulator_get_hardware_vsel_register(struct regulator *regulator, | 
|---|
| 252 | unsigned *vsel_reg, | 
|---|
| 253 | unsigned *vsel_mask); | 
|---|
| 254 | int regulator_list_hardware_vsel(struct regulator *regulator, | 
|---|
| 255 | unsigned selector); | 
|---|
| 256 | int regulator_hardware_enable(struct regulator *regulator, bool enable); | 
|---|
| 257 |  | 
|---|
| 258 | /* regulator notifier block */ | 
|---|
| 259 | int regulator_register_notifier(struct regulator *regulator, | 
|---|
| 260 | struct notifier_block *nb); | 
|---|
| 261 | int devm_regulator_register_notifier(struct regulator *regulator, | 
|---|
| 262 | struct notifier_block *nb); | 
|---|
| 263 | int regulator_unregister_notifier(struct regulator *regulator, | 
|---|
| 264 | struct notifier_block *nb); | 
|---|
| 265 | void devm_regulator_unregister_notifier(struct regulator *regulator, | 
|---|
| 266 | struct notifier_block *nb); | 
|---|
| 267 |  | 
|---|
| 268 | /* regulator suspend */ | 
|---|
| 269 | int regulator_suspend_enable(struct regulator_dev *rdev, | 
|---|
| 270 | suspend_state_t state); | 
|---|
| 271 | int regulator_suspend_disable(struct regulator_dev *rdev, | 
|---|
| 272 | suspend_state_t state); | 
|---|
| 273 | int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV, | 
|---|
| 274 | int max_uV, suspend_state_t state); | 
|---|
| 275 |  | 
|---|
| 276 | /* driver data - core doesn't touch */ | 
|---|
| 277 | void *regulator_get_drvdata(struct regulator *regulator); | 
|---|
| 278 | void regulator_set_drvdata(struct regulator *regulator, void *data); | 
|---|
| 279 |  | 
|---|
| 280 | /* misc helpers */ | 
|---|
| 281 |  | 
|---|
| 282 | void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | 
|---|
| 283 | const char *const *supply_names, | 
|---|
| 284 | unsigned int num_supplies); | 
|---|
| 285 |  | 
|---|
| 286 | bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2); | 
|---|
| 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 | 
|---|
| 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. | 
|---|
| 304 | */ | 
|---|
| 305 | return NULL; | 
|---|
| 306 | } | 
|---|
| 307 |  | 
|---|
| 308 | static inline struct regulator *__must_check | 
|---|
| 309 | devm_regulator_get(struct device *dev, const char *id) | 
|---|
| 310 | { | 
|---|
| 311 | return NULL; | 
|---|
| 312 | } | 
|---|
| 313 |  | 
|---|
| 314 | static inline struct regulator *__must_check | 
|---|
| 315 | regulator_get_exclusive(struct device *dev, const char *id) | 
|---|
| 316 | { | 
|---|
| 317 | return ERR_PTR(error: -ENODEV); | 
|---|
| 318 | } | 
|---|
| 319 |  | 
|---|
| 320 | static inline struct regulator *__must_check | 
|---|
| 321 | devm_regulator_get_exclusive(struct device *dev, const char *id) | 
|---|
| 322 | { | 
|---|
| 323 | return ERR_PTR(error: -ENODEV); | 
|---|
| 324 | } | 
|---|
| 325 |  | 
|---|
| 326 | static inline int devm_regulator_get_enable(struct device *dev, const char *id) | 
|---|
| 327 | { | 
|---|
| 328 | return 0; | 
|---|
| 329 | } | 
|---|
| 330 |  | 
|---|
| 331 | static inline int devm_regulator_get_enable_optional(struct device *dev, | 
|---|
| 332 | const char *id) | 
|---|
| 333 | { | 
|---|
| 334 | return 0; | 
|---|
| 335 | } | 
|---|
| 336 |  | 
|---|
| 337 | static inline int devm_regulator_get_enable_read_voltage(struct device *dev, | 
|---|
| 338 | const char *id) | 
|---|
| 339 | { | 
|---|
| 340 | return -ENODEV; | 
|---|
| 341 | } | 
|---|
| 342 |  | 
|---|
| 343 | static inline struct regulator *__must_check | 
|---|
| 344 | regulator_get_optional(struct device *dev, const char *id) | 
|---|
| 345 | { | 
|---|
| 346 | return ERR_PTR(error: -ENODEV); | 
|---|
| 347 | } | 
|---|
| 348 |  | 
|---|
| 349 |  | 
|---|
| 350 | static inline struct regulator *__must_check | 
|---|
| 351 | devm_regulator_get_optional(struct device *dev, const char *id) | 
|---|
| 352 | { | 
|---|
| 353 | return ERR_PTR(error: -ENODEV); | 
|---|
| 354 | } | 
|---|
| 355 |  | 
|---|
| 356 | static inline void regulator_put(struct regulator *regulator) | 
|---|
| 357 | { | 
|---|
| 358 | } | 
|---|
| 359 |  | 
|---|
| 360 | static inline void devm_regulator_put(struct regulator *regulator) | 
|---|
| 361 | { | 
|---|
| 362 | } | 
|---|
| 363 |  | 
|---|
| 364 | static inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers) | 
|---|
| 365 | { | 
|---|
| 366 | } | 
|---|
| 367 |  | 
|---|
| 368 | static inline int regulator_register_supply_alias(struct device *dev, | 
|---|
| 369 | const char *id, | 
|---|
| 370 | struct device *alias_dev, | 
|---|
| 371 | const char *alias_id) | 
|---|
| 372 | { | 
|---|
| 373 | return 0; | 
|---|
| 374 | } | 
|---|
| 375 |  | 
|---|
| 376 | static inline void regulator_unregister_supply_alias(struct device *dev, | 
|---|
| 377 | const char *id) | 
|---|
| 378 | { | 
|---|
| 379 | } | 
|---|
| 380 |  | 
|---|
| 381 | static inline int regulator_bulk_register_supply_alias(struct device *dev, | 
|---|
| 382 | const char *const *id, | 
|---|
| 383 | struct device *alias_dev, | 
|---|
| 384 | const char * const *alias_id, | 
|---|
| 385 | int num_id) | 
|---|
| 386 | { | 
|---|
| 387 | return 0; | 
|---|
| 388 | } | 
|---|
| 389 |  | 
|---|
| 390 | static inline void regulator_bulk_unregister_supply_alias(struct device *dev, | 
|---|
| 391 | const char * const *id, | 
|---|
| 392 | int num_id) | 
|---|
| 393 | { | 
|---|
| 394 | } | 
|---|
| 395 |  | 
|---|
| 396 | static inline int devm_regulator_register_supply_alias(struct device *dev, | 
|---|
| 397 | const char *id, | 
|---|
| 398 | struct device *alias_dev, | 
|---|
| 399 | const char *alias_id) | 
|---|
| 400 | { | 
|---|
| 401 | return 0; | 
|---|
| 402 | } | 
|---|
| 403 |  | 
|---|
| 404 | static inline int devm_regulator_bulk_register_supply_alias(struct device *dev, | 
|---|
| 405 | const char *const *id, | 
|---|
| 406 | struct device *alias_dev, | 
|---|
| 407 | const char *const *alias_id, | 
|---|
| 408 | int num_id) | 
|---|
| 409 | { | 
|---|
| 410 | return 0; | 
|---|
| 411 | } | 
|---|
| 412 |  | 
|---|
| 413 | static inline int regulator_enable(struct regulator *regulator) | 
|---|
| 414 | { | 
|---|
| 415 | return 0; | 
|---|
| 416 | } | 
|---|
| 417 |  | 
|---|
| 418 | static inline int regulator_disable(struct regulator *regulator) | 
|---|
| 419 | { | 
|---|
| 420 | return 0; | 
|---|
| 421 | } | 
|---|
| 422 |  | 
|---|
| 423 | static inline int regulator_force_disable(struct regulator *regulator) | 
|---|
| 424 | { | 
|---|
| 425 | return 0; | 
|---|
| 426 | } | 
|---|
| 427 |  | 
|---|
| 428 | static inline int regulator_disable_deferred(struct regulator *regulator, | 
|---|
| 429 | int ms) | 
|---|
| 430 | { | 
|---|
| 431 | return 0; | 
|---|
| 432 | } | 
|---|
| 433 |  | 
|---|
| 434 | static inline int regulator_is_enabled(struct regulator *regulator) | 
|---|
| 435 | { | 
|---|
| 436 | return 1; | 
|---|
| 437 | } | 
|---|
| 438 |  | 
|---|
| 439 | static inline int regulator_bulk_get(struct device *dev, | 
|---|
| 440 | int num_consumers, | 
|---|
| 441 | struct regulator_bulk_data *consumers) | 
|---|
| 442 | { | 
|---|
| 443 | return 0; | 
|---|
| 444 | } | 
|---|
| 445 |  | 
|---|
| 446 | static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers, | 
|---|
| 447 | struct regulator_bulk_data *consumers) | 
|---|
| 448 | { | 
|---|
| 449 | return 0; | 
|---|
| 450 | } | 
|---|
| 451 |  | 
|---|
| 452 | static inline int devm_regulator_bulk_get_const( | 
|---|
| 453 | struct device *dev, int num_consumers, | 
|---|
| 454 | const struct regulator_bulk_data *in_consumers, | 
|---|
| 455 | struct regulator_bulk_data **out_consumers) | 
|---|
| 456 | { | 
|---|
| 457 | return 0; | 
|---|
| 458 | } | 
|---|
| 459 |  | 
|---|
| 460 | static inline int regulator_bulk_enable(int num_consumers, | 
|---|
| 461 | struct regulator_bulk_data *consumers) | 
|---|
| 462 | { | 
|---|
| 463 | return 0; | 
|---|
| 464 | } | 
|---|
| 465 |  | 
|---|
| 466 | static inline int devm_regulator_bulk_get_enable(struct device *dev, | 
|---|
| 467 | int num_consumers, | 
|---|
| 468 | const char * const *id) | 
|---|
| 469 | { | 
|---|
| 470 | return 0; | 
|---|
| 471 | } | 
|---|
| 472 |  | 
|---|
| 473 | static inline int regulator_bulk_disable(int num_consumers, | 
|---|
| 474 | struct regulator_bulk_data *consumers) | 
|---|
| 475 | { | 
|---|
| 476 | return 0; | 
|---|
| 477 | } | 
|---|
| 478 |  | 
|---|
| 479 | static inline int regulator_bulk_force_disable(int num_consumers, | 
|---|
| 480 | struct regulator_bulk_data *consumers) | 
|---|
| 481 | { | 
|---|
| 482 | return 0; | 
|---|
| 483 | } | 
|---|
| 484 |  | 
|---|
| 485 | static inline void regulator_bulk_free(int num_consumers, | 
|---|
| 486 | struct regulator_bulk_data *consumers) | 
|---|
| 487 | { | 
|---|
| 488 | } | 
|---|
| 489 |  | 
|---|
| 490 | static inline int regulator_set_voltage(struct regulator *regulator, | 
|---|
| 491 | int min_uV, int max_uV) | 
|---|
| 492 | { | 
|---|
| 493 | return 0; | 
|---|
| 494 | } | 
|---|
| 495 |  | 
|---|
| 496 | static inline int regulator_set_voltage_time(struct regulator *regulator, | 
|---|
| 497 | int old_uV, int new_uV) | 
|---|
| 498 | { | 
|---|
| 499 | return 0; | 
|---|
| 500 | } | 
|---|
| 501 |  | 
|---|
| 502 | static inline int regulator_get_voltage(struct regulator *regulator) | 
|---|
| 503 | { | 
|---|
| 504 | return -EINVAL; | 
|---|
| 505 | } | 
|---|
| 506 |  | 
|---|
| 507 | static inline int regulator_sync_voltage(struct regulator *regulator) | 
|---|
| 508 | { | 
|---|
| 509 | return -EINVAL; | 
|---|
| 510 | } | 
|---|
| 511 |  | 
|---|
| 512 | static inline int regulator_is_supported_voltage(struct regulator *regulator, | 
|---|
| 513 | int min_uV, int max_uV) | 
|---|
| 514 | { | 
|---|
| 515 | return 0; | 
|---|
| 516 | } | 
|---|
| 517 |  | 
|---|
| 518 | static inline unsigned int regulator_get_linear_step(struct regulator *regulator) | 
|---|
| 519 | { | 
|---|
| 520 | return 0; | 
|---|
| 521 | } | 
|---|
| 522 |  | 
|---|
| 523 | static inline int regulator_set_current_limit(struct regulator *regulator, | 
|---|
| 524 | int min_uA, int max_uA) | 
|---|
| 525 | { | 
|---|
| 526 | return 0; | 
|---|
| 527 | } | 
|---|
| 528 |  | 
|---|
| 529 | static inline int regulator_get_current_limit(struct regulator *regulator) | 
|---|
| 530 | { | 
|---|
| 531 | return 0; | 
|---|
| 532 | } | 
|---|
| 533 |  | 
|---|
| 534 | static inline int regulator_get_unclaimed_power_budget(struct regulator *regulator) | 
|---|
| 535 | { | 
|---|
| 536 | return INT_MAX; | 
|---|
| 537 | } | 
|---|
| 538 |  | 
|---|
| 539 | static inline int regulator_request_power_budget(struct regulator *regulator, | 
|---|
| 540 | unsigned int pw_req) | 
|---|
| 541 | { | 
|---|
| 542 | return -EOPNOTSUPP; | 
|---|
| 543 | } | 
|---|
| 544 |  | 
|---|
| 545 | static inline void regulator_free_power_budget(struct regulator *regulator, | 
|---|
| 546 | unsigned int pw) | 
|---|
| 547 | { | 
|---|
| 548 | } | 
|---|
| 549 |  | 
|---|
| 550 | static inline int regulator_set_mode(struct regulator *regulator, | 
|---|
| 551 | unsigned int mode) | 
|---|
| 552 | { | 
|---|
| 553 | return 0; | 
|---|
| 554 | } | 
|---|
| 555 |  | 
|---|
| 556 | static inline unsigned int regulator_get_mode(struct regulator *regulator) | 
|---|
| 557 | { | 
|---|
| 558 | return REGULATOR_MODE_NORMAL; | 
|---|
| 559 | } | 
|---|
| 560 |  | 
|---|
| 561 | static inline int regulator_get_error_flags(struct regulator *regulator, | 
|---|
| 562 | unsigned int *flags) | 
|---|
| 563 | { | 
|---|
| 564 | return -EINVAL; | 
|---|
| 565 | } | 
|---|
| 566 |  | 
|---|
| 567 | static inline int regulator_set_load(struct regulator *regulator, int load_uA) | 
|---|
| 568 | { | 
|---|
| 569 | return 0; | 
|---|
| 570 | } | 
|---|
| 571 |  | 
|---|
| 572 | static inline int regulator_allow_bypass(struct regulator *regulator, | 
|---|
| 573 | bool allow) | 
|---|
| 574 | { | 
|---|
| 575 | return 0; | 
|---|
| 576 | } | 
|---|
| 577 |  | 
|---|
| 578 | static inline struct regmap *regulator_get_regmap(struct regulator *regulator) | 
|---|
| 579 | { | 
|---|
| 580 | return ERR_PTR(error: -EOPNOTSUPP); | 
|---|
| 581 | } | 
|---|
| 582 |  | 
|---|
| 583 | static inline int regulator_get_hardware_vsel_register(struct regulator *regulator, | 
|---|
| 584 | unsigned *vsel_reg, | 
|---|
| 585 | unsigned *vsel_mask) | 
|---|
| 586 | { | 
|---|
| 587 | return -EOPNOTSUPP; | 
|---|
| 588 | } | 
|---|
| 589 |  | 
|---|
| 590 | static inline int regulator_list_hardware_vsel(struct regulator *regulator, | 
|---|
| 591 | unsigned selector) | 
|---|
| 592 | { | 
|---|
| 593 | return -EOPNOTSUPP; | 
|---|
| 594 | } | 
|---|
| 595 |  | 
|---|
| 596 | static inline int regulator_hardware_enable(struct regulator *regulator, | 
|---|
| 597 | bool enable) | 
|---|
| 598 | { | 
|---|
| 599 | return -EOPNOTSUPP; | 
|---|
| 600 | } | 
|---|
| 601 |  | 
|---|
| 602 | static inline int regulator_register_notifier(struct regulator *regulator, | 
|---|
| 603 | struct notifier_block *nb) | 
|---|
| 604 | { | 
|---|
| 605 | return 0; | 
|---|
| 606 | } | 
|---|
| 607 |  | 
|---|
| 608 | static inline int devm_regulator_register_notifier(struct regulator *regulator, | 
|---|
| 609 | struct notifier_block *nb) | 
|---|
| 610 | { | 
|---|
| 611 | return 0; | 
|---|
| 612 | } | 
|---|
| 613 |  | 
|---|
| 614 | static inline int regulator_unregister_notifier(struct regulator *regulator, | 
|---|
| 615 | struct notifier_block *nb) | 
|---|
| 616 | { | 
|---|
| 617 | return 0; | 
|---|
| 618 | } | 
|---|
| 619 |  | 
|---|
| 620 | static inline int devm_regulator_unregister_notifier(struct regulator *regulator, | 
|---|
| 621 | struct notifier_block *nb) | 
|---|
| 622 | { | 
|---|
| 623 | return 0; | 
|---|
| 624 | } | 
|---|
| 625 |  | 
|---|
| 626 | static inline int regulator_suspend_enable(struct regulator_dev *rdev, | 
|---|
| 627 | suspend_state_t state) | 
|---|
| 628 | { | 
|---|
| 629 | return -EINVAL; | 
|---|
| 630 | } | 
|---|
| 631 |  | 
|---|
| 632 | static inline int regulator_suspend_disable(struct regulator_dev *rdev, | 
|---|
| 633 | suspend_state_t state) | 
|---|
| 634 | { | 
|---|
| 635 | return -EINVAL; | 
|---|
| 636 | } | 
|---|
| 637 |  | 
|---|
| 638 | static inline int regulator_set_suspend_voltage(struct regulator *regulator, | 
|---|
| 639 | int min_uV, int max_uV, | 
|---|
| 640 | suspend_state_t state) | 
|---|
| 641 | { | 
|---|
| 642 | return -EINVAL; | 
|---|
| 643 | } | 
|---|
| 644 |  | 
|---|
| 645 | static inline void *regulator_get_drvdata(struct regulator *regulator) | 
|---|
| 646 | { | 
|---|
| 647 | return NULL; | 
|---|
| 648 | } | 
|---|
| 649 |  | 
|---|
| 650 | static inline void regulator_set_drvdata(struct regulator *regulator, | 
|---|
| 651 | void *data) | 
|---|
| 652 | { | 
|---|
| 653 | } | 
|---|
| 654 |  | 
|---|
| 655 | static inline int regulator_count_voltages(struct regulator *regulator) | 
|---|
| 656 | { | 
|---|
| 657 | return 0; | 
|---|
| 658 | } | 
|---|
| 659 |  | 
|---|
| 660 | static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector) | 
|---|
| 661 | { | 
|---|
| 662 | return -EINVAL; | 
|---|
| 663 | } | 
|---|
| 664 |  | 
|---|
| 665 | static inline void | 
|---|
| 666 | regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | 
|---|
| 667 | const char *const *supply_names, | 
|---|
| 668 | unsigned int num_supplies) | 
|---|
| 669 | { | 
|---|
| 670 | } | 
|---|
| 671 |  | 
|---|
| 672 | static inline bool | 
|---|
| 673 | regulator_is_equal(struct regulator *reg1, struct regulator *reg2) | 
|---|
| 674 | { | 
|---|
| 675 | return false; | 
|---|
| 676 | } | 
|---|
| 677 | #endif | 
|---|
| 678 |  | 
|---|
| 679 | #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_REGULATOR) | 
|---|
| 680 | struct regulator *__must_check of_regulator_get(struct device *dev, | 
|---|
| 681 | struct device_node *node, | 
|---|
| 682 | const char *id); | 
|---|
| 683 | struct regulator *__must_check devm_of_regulator_get(struct device *dev, | 
|---|
| 684 | struct device_node *node, | 
|---|
| 685 | const char *id); | 
|---|
| 686 | struct regulator *__must_check of_regulator_get_optional(struct device *dev, | 
|---|
| 687 | struct device_node *node, | 
|---|
| 688 | const char *id); | 
|---|
| 689 | struct regulator *__must_check devm_of_regulator_get_optional(struct device *dev, | 
|---|
| 690 | struct device_node *node, | 
|---|
| 691 | const char *id); | 
|---|
| 692 | int __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np, | 
|---|
| 693 | struct regulator_bulk_data **consumers); | 
|---|
| 694 | #else | 
|---|
| 695 | static inline struct regulator *__must_check of_regulator_get_optional(struct device *dev, | 
|---|
| 696 | struct device_node *node, | 
|---|
| 697 | const char *id) | 
|---|
| 698 | { | 
|---|
| 699 | return ERR_PTR(error: -ENODEV); | 
|---|
| 700 | } | 
|---|
| 701 |  | 
|---|
| 702 | static inline struct regulator *__must_check devm_of_regulator_get_optional(struct device *dev, | 
|---|
| 703 | struct device_node *node, | 
|---|
| 704 | const char *id) | 
|---|
| 705 | { | 
|---|
| 706 | return ERR_PTR(error: -ENODEV); | 
|---|
| 707 | } | 
|---|
| 708 |  | 
|---|
| 709 | static inline int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, | 
|---|
| 710 | struct regulator_bulk_data **consumers) | 
|---|
| 711 | { | 
|---|
| 712 | return 0; | 
|---|
| 713 | } | 
|---|
| 714 |  | 
|---|
| 715 | #endif | 
|---|
| 716 |  | 
|---|
| 717 | static inline int regulator_set_voltage_triplet(struct regulator *regulator, | 
|---|
| 718 | int min_uV, int target_uV, | 
|---|
| 719 | int max_uV) | 
|---|
| 720 | { | 
|---|
| 721 | if (regulator_set_voltage(regulator, min_uV: target_uV, max_uV) == 0) | 
|---|
| 722 | return 0; | 
|---|
| 723 |  | 
|---|
| 724 | return regulator_set_voltage(regulator, min_uV, max_uV); | 
|---|
| 725 | } | 
|---|
| 726 |  | 
|---|
| 727 | static inline int regulator_set_voltage_tol(struct regulator *regulator, | 
|---|
| 728 | int new_uV, int tol_uV) | 
|---|
| 729 | { | 
|---|
| 730 | if (regulator_set_voltage(regulator, min_uV: new_uV, max_uV: new_uV + tol_uV) == 0) | 
|---|
| 731 | return 0; | 
|---|
| 732 | else | 
|---|
| 733 | return regulator_set_voltage(regulator, | 
|---|
| 734 | min_uV: new_uV - tol_uV, max_uV: new_uV + tol_uV); | 
|---|
| 735 | } | 
|---|
| 736 |  | 
|---|
| 737 | static inline int regulator_is_supported_voltage_tol(struct regulator *regulator, | 
|---|
| 738 | int target_uV, int tol_uV) | 
|---|
| 739 | { | 
|---|
| 740 | return regulator_is_supported_voltage(regulator, | 
|---|
| 741 | min_uV: target_uV - tol_uV, | 
|---|
| 742 | max_uV: target_uV + tol_uV); | 
|---|
| 743 | } | 
|---|
| 744 |  | 
|---|
| 745 | #endif | 
|---|
| 746 |  | 
|---|