Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
e2ce4eaa LG |
2 | /* |
3 | * consumer.h -- SoC Regulator consumer support. | |
4 | * | |
5 | * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. | |
6 | * | |
1dd68f01 | 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
e2ce4eaa | 8 | * |
e2ce4eaa LG |
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. | |
e2ce4eaa LG |
29 | */ |
30 | ||
31 | #ifndef __LINUX_REGULATOR_CONSUMER_H_ | |
32 | #define __LINUX_REGULATOR_CONSUMER_H_ | |
33 | ||
174e964e | 34 | #include <linux/err.h> |
da669076 | 35 | #include <linux/suspend.h> |
174e964e | 36 | |
313162d0 PG |
37 | struct device; |
38 | struct notifier_block; | |
04eca28c | 39 | struct regmap; |
da669076 | 40 | struct regulator_dev; |
b56daf13 | 41 | |
e2ce4eaa LG |
42 | /* |
43 | * Regulator operating modes. | |
44 | * | |
45 | * Regulators can run in a variety of different operating modes depending on | |
46 | * output load. This allows further system power savings by selecting the | |
47 | * best (and most efficient) regulator mode for a desired load. | |
48 | * | |
49 | * Most drivers will only care about NORMAL. The modes below are generic and | |
50 | * will probably not match the naming convention of your regulator data sheet | |
51 | * but should match the use cases in the datasheet. | |
52 | * | |
53 | * In order of power efficiency (least efficient at top). | |
54 | * | |
55 | * Mode Description | |
56 | * FAST Regulator can handle fast changes in it's load. | |
57 | * e.g. useful in CPU voltage & frequency scaling where | |
58 | * load can quickly increase with CPU frequency increases. | |
59 | * | |
60 | * NORMAL Normal regulator power supply mode. Most drivers will | |
61 | * use this mode. | |
62 | * | |
63 | * IDLE Regulator runs in a more efficient mode for light | |
64 | * loads. Can be used for devices that have a low power | |
65 | * requirement during periods of inactivity. This mode | |
66 | * may be more noisy than NORMAL and may not be able | |
67 | * to handle fast load switching. | |
68 | * | |
69 | * STANDBY Regulator runs in the most efficient mode for very | |
70 | * light loads. Can be used by devices when they are | |
71 | * in a sleep/standby state. This mode is likely to be | |
72 | * the most noisy and may not be able to handle fast load | |
73 | * switching. | |
74 | * | |
75 | * NOTE: Most regulators will only support a subset of these modes. Some | |
76 | * will only just support NORMAL. | |
77 | * | |
78 | * These modes can be OR'ed together to make up a mask of valid register modes. | |
79 | */ | |
80 | ||
02f37039 | 81 | #define REGULATOR_MODE_INVALID 0x0 |
e2ce4eaa LG |
82 | #define REGULATOR_MODE_FAST 0x1 |
83 | #define REGULATOR_MODE_NORMAL 0x2 | |
84 | #define REGULATOR_MODE_IDLE 0x4 | |
85 | #define REGULATOR_MODE_STANDBY 0x8 | |
86 | ||
87 | /* | |
88 | * Regulator notifier events. | |
89 | * | |
90 | * UNDER_VOLTAGE Regulator output is under voltage. | |
91 | * OVER_CURRENT Regulator output current is too high. | |
92 | * REGULATION_OUT Regulator output is out of regulation. | |
93 | * FAIL Regulator output has failed. | |
94 | * OVER_TEMP Regulator over temp. | |
84b68263 | 95 | * FORCE_DISABLE Regulator forcibly shut down by software. |
b136fb44 | 96 | * VOLTAGE_CHANGE Regulator voltage changed. |
7179569a | 97 | * Data passed is old voltage cast to (void *). |
84b68263 | 98 | * DISABLE Regulator was disabled. |
7179569a HS |
99 | * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed. |
100 | * Data passed is "struct pre_voltage_change_data" | |
101 | * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason. | |
102 | * Data passed is old voltage cast to (void *). | |
a1c8a551 RF |
103 | * PRE_DISABLE Regulator is about to be disabled |
104 | * ABORT_DISABLE Regulator disable failed for some reason | |
e2ce4eaa LG |
105 | * |
106 | * NOTE: These events can be OR'ed together when passed into handler. | |
107 | */ | |
108 | ||
109 | #define REGULATOR_EVENT_UNDER_VOLTAGE 0x01 | |
110 | #define REGULATOR_EVENT_OVER_CURRENT 0x02 | |
111 | #define REGULATOR_EVENT_REGULATION_OUT 0x04 | |
112 | #define REGULATOR_EVENT_FAIL 0x08 | |
113 | #define REGULATOR_EVENT_OVER_TEMP 0x10 | |
114 | #define REGULATOR_EVENT_FORCE_DISABLE 0x20 | |
b136fb44 | 115 | #define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40 |
5c9e7196 | 116 | #define REGULATOR_EVENT_DISABLE 0x80 |
7179569a HS |
117 | #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100 |
118 | #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200 | |
a1c8a551 RF |
119 | #define REGULATOR_EVENT_PRE_DISABLE 0x400 |
120 | #define REGULATOR_EVENT_ABORT_DISABLE 0x800 | |
264b88c9 | 121 | #define REGULATOR_EVENT_ENABLE 0x1000 |
e6c3092d MV |
122 | /* |
123 | * Following notifications should be emitted only if detected condition | |
124 | * is such that the HW is likely to still be working but consumers should | |
125 | * take a recovery action to prevent problems esacalating into errors. | |
126 | */ | |
127 | #define REGULATOR_EVENT_UNDER_VOLTAGE_WARN 0x2000 | |
128 | #define REGULATOR_EVENT_OVER_CURRENT_WARN 0x4000 | |
129 | #define REGULATOR_EVENT_OVER_VOLTAGE_WARN 0x8000 | |
130 | #define REGULATOR_EVENT_OVER_TEMP_WARN 0x10000 | |
131 | #define REGULATOR_EVENT_WARN_MASK 0x1E000 | |
7179569a | 132 | |
1b5b4221 AH |
133 | /* |
134 | * Regulator errors that can be queried using regulator_get_error_flags | |
135 | * | |
136 | * UNDER_VOLTAGE Regulator output is under voltage. | |
137 | * OVER_CURRENT Regulator output current is too high. | |
138 | * REGULATION_OUT Regulator output is out of regulation. | |
139 | * FAIL Regulator output has failed. | |
140 | * OVER_TEMP Regulator over temp. | |
141 | * | |
142 | * NOTE: These errors can be OR'ed together. | |
143 | */ | |
144 | ||
145 | #define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1) | |
146 | #define REGULATOR_ERROR_OVER_CURRENT BIT(2) | |
147 | #define REGULATOR_ERROR_REGULATION_OUT BIT(3) | |
148 | #define REGULATOR_ERROR_FAIL BIT(4) | |
149 | #define REGULATOR_ERROR_OVER_TEMP BIT(5) | |
150 | ||
e6c3092d MV |
151 | #define REGULATOR_ERROR_UNDER_VOLTAGE_WARN BIT(6) |
152 | #define REGULATOR_ERROR_OVER_CURRENT_WARN BIT(7) | |
153 | #define REGULATOR_ERROR_OVER_VOLTAGE_WARN BIT(8) | |
154 | #define REGULATOR_ERROR_OVER_TEMP_WARN BIT(9) | |
1b5b4221 | 155 | |
7179569a HS |
156 | /** |
157 | * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event | |
158 | * | |
159 | * @old_uV: Current voltage before change. | |
160 | * @min_uV: Min voltage we'll change to. | |
161 | * @max_uV: Max voltage we'll change to. | |
162 | */ | |
163 | struct pre_voltage_change_data { | |
164 | unsigned long old_uV; | |
165 | unsigned long min_uV; | |
166 | unsigned long max_uV; | |
167 | }; | |
e2ce4eaa LG |
168 | |
169 | struct regulator; | |
170 | ||
171 | /** | |
172 | * struct regulator_bulk_data - Data used for bulk regulator operations. | |
173 | * | |
6eabfc01 DA |
174 | * @supply: The name of the supply. Initialised by the user before |
175 | * using the bulk regulator APIs. | |
176 | * @init_load_uA: After getting the regulator, regulator_set_load() will be | |
177 | * called with this load. Initialised by the user before | |
178 | * using the bulk regulator APIs. | |
179 | * @consumer: The regulator consumer for the supply. This will be managed | |
180 | * by the bulk API. | |
e2ce4eaa LG |
181 | * |
182 | * The regulator APIs provide a series of regulator_bulk_() API calls as | |
183 | * a convenience to consumers which require multiple supplies. This | |
184 | * structure is used to manage data for these calls. | |
185 | */ | |
186 | struct regulator_bulk_data { | |
187 | const char *supply; | |
6eabfc01 | 188 | int init_load_uA; |
e2ce4eaa | 189 | struct regulator *consumer; |
f21e0e81 | 190 | |
bff747c5 | 191 | /* private: Internal use */ |
f21e0e81 | 192 | int ret; |
e2ce4eaa LG |
193 | }; |
194 | ||
195 | #if defined(CONFIG_REGULATOR) | |
196 | ||
197 | /* regulator get and put */ | |
198 | struct regulator *__must_check regulator_get(struct device *dev, | |
199 | const char *id); | |
070b9079 SB |
200 | struct regulator *__must_check devm_regulator_get(struct device *dev, |
201 | const char *id); | |
5ffbd136 MB |
202 | struct regulator *__must_check regulator_get_exclusive(struct device *dev, |
203 | const char *id); | |
9efdd276 MK |
204 | struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev, |
205 | const char *id); | |
de1dd9fd MB |
206 | struct regulator *__must_check regulator_get_optional(struct device *dev, |
207 | const char *id); | |
208 | struct regulator *__must_check devm_regulator_get_optional(struct device *dev, | |
209 | const char *id); | |
da279e69 MV |
210 | int devm_regulator_get_enable(struct device *dev, const char *id); |
211 | int devm_regulator_get_enable_optional(struct device *dev, const char *id); | |
e2ce4eaa | 212 | void regulator_put(struct regulator *regulator); |
2950c4bb | 213 | void devm_regulator_put(struct regulator *regulator); |
e2ce4eaa | 214 | |
a06ccd9c CK |
215 | int regulator_register_supply_alias(struct device *dev, const char *id, |
216 | struct device *alias_dev, | |
217 | const char *alias_id); | |
218 | void regulator_unregister_supply_alias(struct device *dev, const char *id); | |
219 | ||
9f8c0fe9 LJ |
220 | int regulator_bulk_register_supply_alias(struct device *dev, |
221 | const char *const *id, | |
a06ccd9c | 222 | struct device *alias_dev, |
9f8c0fe9 LJ |
223 | const char *const *alias_id, |
224 | int num_id); | |
a06ccd9c | 225 | void regulator_bulk_unregister_supply_alias(struct device *dev, |
9f8c0fe9 | 226 | const char * const *id, int num_id); |
a06ccd9c CK |
227 | |
228 | int devm_regulator_register_supply_alias(struct device *dev, const char *id, | |
229 | struct device *alias_dev, | |
230 | const char *alias_id); | |
a06ccd9c CK |
231 | |
232 | int devm_regulator_bulk_register_supply_alias(struct device *dev, | |
9f8c0fe9 | 233 | const char *const *id, |
a06ccd9c | 234 | struct device *alias_dev, |
9f8c0fe9 | 235 | const char *const *alias_id, |
a06ccd9c | 236 | int num_id); |
a06ccd9c | 237 | |
e2ce4eaa | 238 | /* regulator output control and status */ |
c8801a8e | 239 | int __must_check regulator_enable(struct regulator *regulator); |
e2ce4eaa LG |
240 | int regulator_disable(struct regulator *regulator); |
241 | int regulator_force_disable(struct regulator *regulator); | |
242 | int regulator_is_enabled(struct regulator *regulator); | |
da07ecd9 | 243 | int regulator_disable_deferred(struct regulator *regulator, int ms); |
e2ce4eaa | 244 | |
c8801a8e MB |
245 | int __must_check regulator_bulk_get(struct device *dev, int num_consumers, |
246 | struct regulator_bulk_data *consumers); | |
27b9ecc7 CL |
247 | int __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np, |
248 | struct regulator_bulk_data **consumers); | |
c8801a8e MB |
249 | int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, |
250 | struct regulator_bulk_data *consumers); | |
da279e69 | 251 | void devm_regulator_bulk_put(struct regulator_bulk_data *consumers); |
fd184506 ZW |
252 | int __must_check devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers, |
253 | struct regulator_bulk_data *consumers); | |
1de452a0 DA |
254 | int __must_check devm_regulator_bulk_get_const( |
255 | struct device *dev, int num_consumers, | |
256 | const struct regulator_bulk_data *in_consumers, | |
257 | struct regulator_bulk_data **out_consumers); | |
c8801a8e MB |
258 | int __must_check regulator_bulk_enable(int num_consumers, |
259 | struct regulator_bulk_data *consumers); | |
da279e69 MV |
260 | int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, |
261 | const char * const *id); | |
e2ce4eaa LG |
262 | int regulator_bulk_disable(int num_consumers, |
263 | struct regulator_bulk_data *consumers); | |
e1de2f42 DK |
264 | int regulator_bulk_force_disable(int num_consumers, |
265 | struct regulator_bulk_data *consumers); | |
e2ce4eaa LG |
266 | void regulator_bulk_free(int num_consumers, |
267 | struct regulator_bulk_data *consumers); | |
268 | ||
4367cfdc DB |
269 | int regulator_count_voltages(struct regulator *regulator); |
270 | int regulator_list_voltage(struct regulator *regulator, unsigned selector); | |
a7a1ad90 MB |
271 | int regulator_is_supported_voltage(struct regulator *regulator, |
272 | int min_uV, int max_uV); | |
2a668a8b | 273 | unsigned int regulator_get_linear_step(struct regulator *regulator); |
e2ce4eaa | 274 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); |
88cd222b LW |
275 | int regulator_set_voltage_time(struct regulator *regulator, |
276 | int old_uV, int new_uV); | |
e2ce4eaa | 277 | int regulator_get_voltage(struct regulator *regulator); |
606a2562 | 278 | int regulator_sync_voltage(struct regulator *regulator); |
e2ce4eaa LG |
279 | int regulator_set_current_limit(struct regulator *regulator, |
280 | int min_uA, int max_uA); | |
281 | int regulator_get_current_limit(struct regulator *regulator); | |
282 | ||
283 | int regulator_set_mode(struct regulator *regulator, unsigned int mode); | |
284 | unsigned int regulator_get_mode(struct regulator *regulator); | |
1b5b4221 AH |
285 | int regulator_get_error_flags(struct regulator *regulator, |
286 | unsigned int *flags); | |
e39ce48f | 287 | int regulator_set_load(struct regulator *regulator, int load_uA); |
e2ce4eaa | 288 | |
f59c8f9f MB |
289 | int regulator_allow_bypass(struct regulator *regulator, bool allow); |
290 | ||
04eca28c TT |
291 | struct regmap *regulator_get_regmap(struct regulator *regulator); |
292 | int regulator_get_hardware_vsel_register(struct regulator *regulator, | |
293 | unsigned *vsel_reg, | |
294 | unsigned *vsel_mask); | |
295 | int regulator_list_hardware_vsel(struct regulator *regulator, | |
296 | unsigned selector); | |
297 | ||
e2ce4eaa LG |
298 | /* regulator notifier block */ |
299 | int regulator_register_notifier(struct regulator *regulator, | |
300 | struct notifier_block *nb); | |
046db763 CK |
301 | int devm_regulator_register_notifier(struct regulator *regulator, |
302 | struct notifier_block *nb); | |
e2ce4eaa LG |
303 | int regulator_unregister_notifier(struct regulator *regulator, |
304 | struct notifier_block *nb); | |
046db763 CK |
305 | void devm_regulator_unregister_notifier(struct regulator *regulator, |
306 | struct notifier_block *nb); | |
e2ce4eaa | 307 | |
da669076 LJ |
308 | /* regulator suspend */ |
309 | int regulator_suspend_enable(struct regulator_dev *rdev, | |
310 | suspend_state_t state); | |
311 | int regulator_suspend_disable(struct regulator_dev *rdev, | |
312 | suspend_state_t state); | |
313 | int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV, | |
314 | int max_uV, suspend_state_t state); | |
315 | ||
e2ce4eaa LG |
316 | /* driver data - core doesn't touch */ |
317 | void *regulator_get_drvdata(struct regulator *regulator); | |
318 | void regulator_set_drvdata(struct regulator *regulator, void *data); | |
319 | ||
d0087e72 BG |
320 | /* misc helpers */ |
321 | ||
322 | void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | |
323 | const char *const *supply_names, | |
324 | unsigned int num_supplies); | |
325 | ||
b059b7e0 MV |
326 | bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2); |
327 | ||
e2ce4eaa LG |
328 | #else |
329 | ||
330 | /* | |
331 | * Make sure client drivers will still build on systems with no software | |
332 | * controllable voltage or current regulators. | |
333 | */ | |
334 | static inline struct regulator *__must_check regulator_get(struct device *dev, | |
335 | const char *id) | |
336 | { | |
337 | /* Nothing except the stubbed out regulator API should be | |
338 | * looking at the value except to check if it is an error | |
be1a50d4 JD |
339 | * value. Drivers are free to handle NULL specifically by |
340 | * skipping all regulator API calls, but they don't have to. | |
341 | * Drivers which don't, should make sure they properly handle | |
342 | * corner cases of the API, such as regulator_get_voltage() | |
343 | * returning 0. | |
e2ce4eaa | 344 | */ |
be1a50d4 | 345 | return NULL; |
e2ce4eaa | 346 | } |
070b9079 SB |
347 | |
348 | static inline struct regulator *__must_check | |
349 | devm_regulator_get(struct device *dev, const char *id) | |
350 | { | |
351 | return NULL; | |
352 | } | |
353 | ||
4bdfb272 MB |
354 | static inline struct regulator *__must_check |
355 | regulator_get_exclusive(struct device *dev, const char *id) | |
356 | { | |
70b946f9 | 357 | return ERR_PTR(-ENODEV); |
4bdfb272 MB |
358 | } |
359 | ||
51dfb6ca DO |
360 | static inline struct regulator *__must_check |
361 | devm_regulator_get_exclusive(struct device *dev, const char *id) | |
362 | { | |
363 | return ERR_PTR(-ENODEV); | |
364 | } | |
365 | ||
da279e69 MV |
366 | static inline int devm_regulator_get_enable(struct device *dev, const char *id) |
367 | { | |
368 | return -ENODEV; | |
369 | } | |
370 | ||
371 | static inline int devm_regulator_get_enable_optional(struct device *dev, | |
372 | const char *id) | |
373 | { | |
374 | return -ENODEV; | |
375 | } | |
376 | ||
de1dd9fd MB |
377 | static inline struct regulator *__must_check |
378 | regulator_get_optional(struct device *dev, const char *id) | |
379 | { | |
df7926ff | 380 | return ERR_PTR(-ENODEV); |
de1dd9fd MB |
381 | } |
382 | ||
4bdfb272 | 383 | |
070b9079 | 384 | static inline struct regulator *__must_check |
de1dd9fd | 385 | devm_regulator_get_optional(struct device *dev, const char *id) |
070b9079 | 386 | { |
df7926ff | 387 | return ERR_PTR(-ENODEV); |
070b9079 SB |
388 | } |
389 | ||
e2ce4eaa LG |
390 | static inline void regulator_put(struct regulator *regulator) |
391 | { | |
392 | } | |
393 | ||
2950c4bb AL |
394 | static inline void devm_regulator_put(struct regulator *regulator) |
395 | { | |
396 | } | |
397 | ||
da279e69 MV |
398 | static inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers) |
399 | { | |
400 | } | |
401 | ||
a06ccd9c CK |
402 | static inline int regulator_register_supply_alias(struct device *dev, |
403 | const char *id, | |
404 | struct device *alias_dev, | |
405 | const char *alias_id) | |
406 | { | |
407 | return 0; | |
408 | } | |
409 | ||
410 | static inline void regulator_unregister_supply_alias(struct device *dev, | |
411 | const char *id) | |
412 | { | |
413 | } | |
414 | ||
415 | static inline int regulator_bulk_register_supply_alias(struct device *dev, | |
9f8c0fe9 LJ |
416 | const char *const *id, |
417 | struct device *alias_dev, | |
418 | const char * const *alias_id, | |
419 | int num_id) | |
a06ccd9c CK |
420 | { |
421 | return 0; | |
422 | } | |
423 | ||
424 | static inline void regulator_bulk_unregister_supply_alias(struct device *dev, | |
9f8c0fe9 LJ |
425 | const char * const *id, |
426 | int num_id) | |
a06ccd9c CK |
427 | { |
428 | } | |
429 | ||
430 | static inline int devm_regulator_register_supply_alias(struct device *dev, | |
431 | const char *id, | |
432 | struct device *alias_dev, | |
433 | const char *alias_id) | |
434 | { | |
435 | return 0; | |
436 | } | |
437 | ||
9f8c0fe9 LJ |
438 | static inline int devm_regulator_bulk_register_supply_alias(struct device *dev, |
439 | const char *const *id, | |
440 | struct device *alias_dev, | |
441 | const char *const *alias_id, | |
442 | int num_id) | |
a06ccd9c CK |
443 | { |
444 | return 0; | |
445 | } | |
446 | ||
e2ce4eaa LG |
447 | static inline int regulator_enable(struct regulator *regulator) |
448 | { | |
449 | return 0; | |
450 | } | |
451 | ||
452 | static inline int regulator_disable(struct regulator *regulator) | |
453 | { | |
454 | return 0; | |
455 | } | |
456 | ||
935a5210 MH |
457 | static inline int regulator_force_disable(struct regulator *regulator) |
458 | { | |
459 | return 0; | |
460 | } | |
461 | ||
da07ecd9 MB |
462 | static inline int regulator_disable_deferred(struct regulator *regulator, |
463 | int ms) | |
464 | { | |
465 | return 0; | |
466 | } | |
467 | ||
e2ce4eaa LG |
468 | static inline int regulator_is_enabled(struct regulator *regulator) |
469 | { | |
470 | return 1; | |
471 | } | |
472 | ||
473 | static inline int regulator_bulk_get(struct device *dev, | |
474 | int num_consumers, | |
475 | struct regulator_bulk_data *consumers) | |
476 | { | |
477 | return 0; | |
478 | } | |
479 | ||
e24abd6e AL |
480 | static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers, |
481 | struct regulator_bulk_data *consumers) | |
482 | { | |
483 | return 0; | |
484 | } | |
485 | ||
27b9ecc7 CL |
486 | static inline int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, |
487 | struct regulator_bulk_data **consumers) | |
488 | { | |
489 | return 0; | |
490 | } | |
491 | ||
e2ce4eaa LG |
492 | static inline int regulator_bulk_enable(int num_consumers, |
493 | struct regulator_bulk_data *consumers) | |
494 | { | |
495 | return 0; | |
496 | } | |
497 | ||
da279e69 MV |
498 | static inline int devm_regulator_bulk_get_enable(struct device *dev, |
499 | int num_consumers, | |
500 | const char * const *id) | |
501 | { | |
502 | return 0; | |
503 | } | |
504 | ||
e2ce4eaa LG |
505 | static inline int regulator_bulk_disable(int num_consumers, |
506 | struct regulator_bulk_data *consumers) | |
507 | { | |
508 | return 0; | |
509 | } | |
510 | ||
e1de2f42 DK |
511 | static inline int regulator_bulk_force_disable(int num_consumers, |
512 | struct regulator_bulk_data *consumers) | |
513 | { | |
514 | return 0; | |
515 | } | |
516 | ||
e2ce4eaa LG |
517 | static inline void regulator_bulk_free(int num_consumers, |
518 | struct regulator_bulk_data *consumers) | |
519 | { | |
520 | } | |
521 | ||
522 | static inline int regulator_set_voltage(struct regulator *regulator, | |
523 | int min_uV, int max_uV) | |
524 | { | |
525 | return 0; | |
526 | } | |
527 | ||
d660e92a VK |
528 | static inline int regulator_set_voltage_time(struct regulator *regulator, |
529 | int old_uV, int new_uV) | |
530 | { | |
531 | return 0; | |
532 | } | |
533 | ||
e2ce4eaa LG |
534 | static inline int regulator_get_voltage(struct regulator *regulator) |
535 | { | |
08aed2f6 | 536 | return -EINVAL; |
e2ce4eaa LG |
537 | } |
538 | ||
51dfb6ca DO |
539 | static inline int regulator_sync_voltage(struct regulator *regulator) |
540 | { | |
541 | return -EINVAL; | |
542 | } | |
543 | ||
4fe23791 PR |
544 | static inline int regulator_is_supported_voltage(struct regulator *regulator, |
545 | int min_uV, int max_uV) | |
546 | { | |
547 | return 0; | |
548 | } | |
549 | ||
7287275b AB |
550 | static inline unsigned int regulator_get_linear_step(struct regulator *regulator) |
551 | { | |
552 | return 0; | |
553 | } | |
554 | ||
e2ce4eaa LG |
555 | static inline int regulator_set_current_limit(struct regulator *regulator, |
556 | int min_uA, int max_uA) | |
557 | { | |
558 | return 0; | |
559 | } | |
560 | ||
561 | static inline int regulator_get_current_limit(struct regulator *regulator) | |
562 | { | |
563 | return 0; | |
564 | } | |
565 | ||
566 | static inline int regulator_set_mode(struct regulator *regulator, | |
567 | unsigned int mode) | |
568 | { | |
569 | return 0; | |
570 | } | |
571 | ||
572 | static inline unsigned int regulator_get_mode(struct regulator *regulator) | |
573 | { | |
574 | return REGULATOR_MODE_NORMAL; | |
575 | } | |
576 | ||
30103b5b DL |
577 | static inline int regulator_get_error_flags(struct regulator *regulator, |
578 | unsigned int *flags) | |
1b5b4221 AH |
579 | { |
580 | return -EINVAL; | |
581 | } | |
582 | ||
e39ce48f | 583 | static inline int regulator_set_load(struct regulator *regulator, int load_uA) |
e2ce4eaa | 584 | { |
f1abf672 | 585 | return 0; |
e2ce4eaa LG |
586 | } |
587 | ||
f59c8f9f MB |
588 | static inline int regulator_allow_bypass(struct regulator *regulator, |
589 | bool allow) | |
590 | { | |
591 | return 0; | |
592 | } | |
593 | ||
3bc0312e | 594 | static inline struct regmap *regulator_get_regmap(struct regulator *regulator) |
04eca28c TT |
595 | { |
596 | return ERR_PTR(-EOPNOTSUPP); | |
597 | } | |
598 | ||
3bc0312e MB |
599 | static inline int regulator_get_hardware_vsel_register(struct regulator *regulator, |
600 | unsigned *vsel_reg, | |
601 | unsigned *vsel_mask) | |
04eca28c TT |
602 | { |
603 | return -EOPNOTSUPP; | |
604 | } | |
605 | ||
3bc0312e MB |
606 | static inline int regulator_list_hardware_vsel(struct regulator *regulator, |
607 | unsigned selector) | |
04eca28c TT |
608 | { |
609 | return -EOPNOTSUPP; | |
610 | } | |
611 | ||
e2ce4eaa LG |
612 | static inline int regulator_register_notifier(struct regulator *regulator, |
613 | struct notifier_block *nb) | |
614 | { | |
615 | return 0; | |
616 | } | |
617 | ||
046db763 CK |
618 | static inline int devm_regulator_register_notifier(struct regulator *regulator, |
619 | struct notifier_block *nb) | |
620 | { | |
621 | return 0; | |
622 | } | |
623 | ||
e2ce4eaa LG |
624 | static inline int regulator_unregister_notifier(struct regulator *regulator, |
625 | struct notifier_block *nb) | |
626 | { | |
627 | return 0; | |
628 | } | |
629 | ||
046db763 CK |
630 | static inline int devm_regulator_unregister_notifier(struct regulator *regulator, |
631 | struct notifier_block *nb) | |
632 | { | |
633 | return 0; | |
634 | } | |
635 | ||
51dfb6ca DO |
636 | static inline int regulator_suspend_enable(struct regulator_dev *rdev, |
637 | suspend_state_t state) | |
638 | { | |
639 | return -EINVAL; | |
640 | } | |
641 | ||
642 | static inline int regulator_suspend_disable(struct regulator_dev *rdev, | |
643 | suspend_state_t state) | |
644 | { | |
645 | return -EINVAL; | |
646 | } | |
647 | ||
648 | static inline int regulator_set_suspend_voltage(struct regulator *regulator, | |
649 | int min_uV, int max_uV, | |
650 | suspend_state_t state) | |
651 | { | |
652 | return -EINVAL; | |
653 | } | |
654 | ||
e2ce4eaa LG |
655 | static inline void *regulator_get_drvdata(struct regulator *regulator) |
656 | { | |
657 | return NULL; | |
658 | } | |
659 | ||
660 | static inline void regulator_set_drvdata(struct regulator *regulator, | |
661 | void *data) | |
662 | { | |
663 | } | |
664 | ||
1a8f85d4 PR |
665 | static inline int regulator_count_voltages(struct regulator *regulator) |
666 | { | |
667 | return 0; | |
668 | } | |
5127e31a SP |
669 | |
670 | static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector) | |
671 | { | |
672 | return -EINVAL; | |
673 | } | |
674 | ||
d072cb26 BG |
675 | static inline void |
676 | regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | |
677 | const char *const *supply_names, | |
678 | unsigned int num_supplies) | |
d0087e72 BG |
679 | { |
680 | } | |
681 | ||
b059b7e0 | 682 | static inline bool |
0468e667 | 683 | regulator_is_equal(struct regulator *reg1, struct regulator *reg2) |
b059b7e0 MV |
684 | { |
685 | return false; | |
686 | } | |
e2ce4eaa LG |
687 | #endif |
688 | ||
30f93ca8 VK |
689 | static inline int regulator_set_voltage_triplet(struct regulator *regulator, |
690 | int min_uV, int target_uV, | |
691 | int max_uV) | |
692 | { | |
693 | if (regulator_set_voltage(regulator, target_uV, max_uV) == 0) | |
694 | return 0; | |
695 | ||
696 | return regulator_set_voltage(regulator, min_uV, max_uV); | |
697 | } | |
698 | ||
3f196577 SG |
699 | static inline int regulator_set_voltage_tol(struct regulator *regulator, |
700 | int new_uV, int tol_uV) | |
701 | { | |
dc9ceed6 MB |
702 | if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0) |
703 | return 0; | |
704 | else | |
705 | return regulator_set_voltage(regulator, | |
706 | new_uV - tol_uV, new_uV + tol_uV); | |
3f196577 SG |
707 | } |
708 | ||
fe1e43f7 MB |
709 | static inline int regulator_is_supported_voltage_tol(struct regulator *regulator, |
710 | int target_uV, int tol_uV) | |
711 | { | |
712 | return regulator_is_supported_voltage(regulator, | |
713 | target_uV - tol_uV, | |
714 | target_uV + tol_uV); | |
715 | } | |
716 | ||
e2ce4eaa | 717 | #endif |