]>
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 |
7179569a | 122 | |
1b5b4221 AH |
123 | /* |
124 | * Regulator errors that can be queried using regulator_get_error_flags | |
125 | * | |
126 | * UNDER_VOLTAGE Regulator output is under voltage. | |
127 | * OVER_CURRENT Regulator output current is too high. | |
128 | * REGULATION_OUT Regulator output is out of regulation. | |
129 | * FAIL Regulator output has failed. | |
130 | * OVER_TEMP Regulator over temp. | |
131 | * | |
132 | * NOTE: These errors can be OR'ed together. | |
133 | */ | |
134 | ||
135 | #define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1) | |
136 | #define REGULATOR_ERROR_OVER_CURRENT BIT(2) | |
137 | #define REGULATOR_ERROR_REGULATION_OUT BIT(3) | |
138 | #define REGULATOR_ERROR_FAIL BIT(4) | |
139 | #define REGULATOR_ERROR_OVER_TEMP BIT(5) | |
140 | ||
141 | ||
7179569a HS |
142 | /** |
143 | * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event | |
144 | * | |
145 | * @old_uV: Current voltage before change. | |
146 | * @min_uV: Min voltage we'll change to. | |
147 | * @max_uV: Max voltage we'll change to. | |
148 | */ | |
149 | struct pre_voltage_change_data { | |
150 | unsigned long old_uV; | |
151 | unsigned long min_uV; | |
152 | unsigned long max_uV; | |
153 | }; | |
e2ce4eaa LG |
154 | |
155 | struct regulator; | |
156 | ||
157 | /** | |
158 | * struct regulator_bulk_data - Data used for bulk regulator operations. | |
159 | * | |
69279fb9 MB |
160 | * @supply: The name of the supply. Initialised by the user before |
161 | * using the bulk regulator APIs. | |
162 | * @consumer: The regulator consumer for the supply. This will be managed | |
163 | * by the bulk API. | |
e2ce4eaa LG |
164 | * |
165 | * The regulator APIs provide a series of regulator_bulk_() API calls as | |
166 | * a convenience to consumers which require multiple supplies. This | |
167 | * structure is used to manage data for these calls. | |
168 | */ | |
169 | struct regulator_bulk_data { | |
170 | const char *supply; | |
171 | struct regulator *consumer; | |
f21e0e81 | 172 | |
bff747c5 | 173 | /* private: Internal use */ |
f21e0e81 | 174 | int ret; |
e2ce4eaa LG |
175 | }; |
176 | ||
177 | #if defined(CONFIG_REGULATOR) | |
178 | ||
179 | /* regulator get and put */ | |
180 | struct regulator *__must_check regulator_get(struct device *dev, | |
181 | const char *id); | |
070b9079 SB |
182 | struct regulator *__must_check devm_regulator_get(struct device *dev, |
183 | const char *id); | |
5ffbd136 MB |
184 | struct regulator *__must_check regulator_get_exclusive(struct device *dev, |
185 | const char *id); | |
9efdd276 MK |
186 | struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev, |
187 | const char *id); | |
de1dd9fd MB |
188 | struct regulator *__must_check regulator_get_optional(struct device *dev, |
189 | const char *id); | |
190 | struct regulator *__must_check devm_regulator_get_optional(struct device *dev, | |
191 | const char *id); | |
e2ce4eaa | 192 | void regulator_put(struct regulator *regulator); |
2950c4bb | 193 | void devm_regulator_put(struct regulator *regulator); |
e2ce4eaa | 194 | |
a06ccd9c CK |
195 | int regulator_register_supply_alias(struct device *dev, const char *id, |
196 | struct device *alias_dev, | |
197 | const char *alias_id); | |
198 | void regulator_unregister_supply_alias(struct device *dev, const char *id); | |
199 | ||
9f8c0fe9 LJ |
200 | int regulator_bulk_register_supply_alias(struct device *dev, |
201 | const char *const *id, | |
a06ccd9c | 202 | struct device *alias_dev, |
9f8c0fe9 LJ |
203 | const char *const *alias_id, |
204 | int num_id); | |
a06ccd9c | 205 | void regulator_bulk_unregister_supply_alias(struct device *dev, |
9f8c0fe9 | 206 | const char * const *id, int num_id); |
a06ccd9c CK |
207 | |
208 | int devm_regulator_register_supply_alias(struct device *dev, const char *id, | |
209 | struct device *alias_dev, | |
210 | const char *alias_id); | |
211 | void devm_regulator_unregister_supply_alias(struct device *dev, | |
212 | const char *id); | |
213 | ||
214 | int devm_regulator_bulk_register_supply_alias(struct device *dev, | |
9f8c0fe9 | 215 | const char *const *id, |
a06ccd9c | 216 | struct device *alias_dev, |
9f8c0fe9 | 217 | const char *const *alias_id, |
a06ccd9c CK |
218 | int num_id); |
219 | void devm_regulator_bulk_unregister_supply_alias(struct device *dev, | |
9f8c0fe9 | 220 | const char *const *id, |
a06ccd9c CK |
221 | int num_id); |
222 | ||
e2ce4eaa | 223 | /* regulator output control and status */ |
c8801a8e | 224 | int __must_check regulator_enable(struct regulator *regulator); |
e2ce4eaa LG |
225 | int regulator_disable(struct regulator *regulator); |
226 | int regulator_force_disable(struct regulator *regulator); | |
227 | int regulator_is_enabled(struct regulator *regulator); | |
da07ecd9 | 228 | int regulator_disable_deferred(struct regulator *regulator, int ms); |
e2ce4eaa | 229 | |
c8801a8e MB |
230 | int __must_check regulator_bulk_get(struct device *dev, int num_consumers, |
231 | struct regulator_bulk_data *consumers); | |
232 | int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, | |
233 | struct regulator_bulk_data *consumers); | |
234 | int __must_check regulator_bulk_enable(int num_consumers, | |
235 | struct regulator_bulk_data *consumers); | |
e2ce4eaa LG |
236 | int regulator_bulk_disable(int num_consumers, |
237 | struct regulator_bulk_data *consumers); | |
e1de2f42 DK |
238 | int regulator_bulk_force_disable(int num_consumers, |
239 | struct regulator_bulk_data *consumers); | |
e2ce4eaa LG |
240 | void regulator_bulk_free(int num_consumers, |
241 | struct regulator_bulk_data *consumers); | |
242 | ||
4367cfdc DB |
243 | int regulator_count_voltages(struct regulator *regulator); |
244 | int regulator_list_voltage(struct regulator *regulator, unsigned selector); | |
a7a1ad90 MB |
245 | int regulator_is_supported_voltage(struct regulator *regulator, |
246 | int min_uV, int max_uV); | |
2a668a8b | 247 | unsigned int regulator_get_linear_step(struct regulator *regulator); |
e2ce4eaa | 248 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); |
88cd222b LW |
249 | int regulator_set_voltage_time(struct regulator *regulator, |
250 | int old_uV, int new_uV); | |
e2ce4eaa | 251 | int regulator_get_voltage(struct regulator *regulator); |
606a2562 | 252 | int regulator_sync_voltage(struct regulator *regulator); |
e2ce4eaa LG |
253 | int regulator_set_current_limit(struct regulator *regulator, |
254 | int min_uA, int max_uA); | |
255 | int regulator_get_current_limit(struct regulator *regulator); | |
256 | ||
257 | int regulator_set_mode(struct regulator *regulator, unsigned int mode); | |
258 | unsigned int regulator_get_mode(struct regulator *regulator); | |
1b5b4221 AH |
259 | int regulator_get_error_flags(struct regulator *regulator, |
260 | unsigned int *flags); | |
e39ce48f | 261 | int regulator_set_load(struct regulator *regulator, int load_uA); |
e2ce4eaa | 262 | |
f59c8f9f MB |
263 | int regulator_allow_bypass(struct regulator *regulator, bool allow); |
264 | ||
04eca28c TT |
265 | struct regmap *regulator_get_regmap(struct regulator *regulator); |
266 | int regulator_get_hardware_vsel_register(struct regulator *regulator, | |
267 | unsigned *vsel_reg, | |
268 | unsigned *vsel_mask); | |
269 | int regulator_list_hardware_vsel(struct regulator *regulator, | |
270 | unsigned selector); | |
271 | ||
e2ce4eaa LG |
272 | /* regulator notifier block */ |
273 | int regulator_register_notifier(struct regulator *regulator, | |
274 | struct notifier_block *nb); | |
046db763 CK |
275 | int devm_regulator_register_notifier(struct regulator *regulator, |
276 | struct notifier_block *nb); | |
e2ce4eaa LG |
277 | int regulator_unregister_notifier(struct regulator *regulator, |
278 | struct notifier_block *nb); | |
046db763 CK |
279 | void devm_regulator_unregister_notifier(struct regulator *regulator, |
280 | struct notifier_block *nb); | |
e2ce4eaa | 281 | |
da669076 LJ |
282 | /* regulator suspend */ |
283 | int regulator_suspend_enable(struct regulator_dev *rdev, | |
284 | suspend_state_t state); | |
285 | int regulator_suspend_disable(struct regulator_dev *rdev, | |
286 | suspend_state_t state); | |
287 | int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV, | |
288 | int max_uV, suspend_state_t state); | |
289 | ||
e2ce4eaa LG |
290 | /* driver data - core doesn't touch */ |
291 | void *regulator_get_drvdata(struct regulator *regulator); | |
292 | void regulator_set_drvdata(struct regulator *regulator, void *data); | |
293 | ||
d0087e72 BG |
294 | /* misc helpers */ |
295 | ||
296 | void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | |
297 | const char *const *supply_names, | |
298 | unsigned int num_supplies); | |
299 | ||
b059b7e0 MV |
300 | bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2); |
301 | ||
e2ce4eaa LG |
302 | #else |
303 | ||
304 | /* | |
305 | * Make sure client drivers will still build on systems with no software | |
306 | * controllable voltage or current regulators. | |
307 | */ | |
308 | static inline struct regulator *__must_check regulator_get(struct device *dev, | |
309 | const char *id) | |
310 | { | |
311 | /* Nothing except the stubbed out regulator API should be | |
312 | * looking at the value except to check if it is an error | |
be1a50d4 JD |
313 | * value. Drivers are free to handle NULL specifically by |
314 | * skipping all regulator API calls, but they don't have to. | |
315 | * Drivers which don't, should make sure they properly handle | |
316 | * corner cases of the API, such as regulator_get_voltage() | |
317 | * returning 0. | |
e2ce4eaa | 318 | */ |
be1a50d4 | 319 | return NULL; |
e2ce4eaa | 320 | } |
070b9079 SB |
321 | |
322 | static inline struct regulator *__must_check | |
323 | devm_regulator_get(struct device *dev, const char *id) | |
324 | { | |
325 | return NULL; | |
326 | } | |
327 | ||
4bdfb272 MB |
328 | static inline struct regulator *__must_check |
329 | regulator_get_exclusive(struct device *dev, const char *id) | |
330 | { | |
70b946f9 | 331 | return ERR_PTR(-ENODEV); |
4bdfb272 MB |
332 | } |
333 | ||
51dfb6ca DO |
334 | static inline struct regulator *__must_check |
335 | devm_regulator_get_exclusive(struct device *dev, const char *id) | |
336 | { | |
337 | return ERR_PTR(-ENODEV); | |
338 | } | |
339 | ||
de1dd9fd MB |
340 | static inline struct regulator *__must_check |
341 | regulator_get_optional(struct device *dev, const char *id) | |
342 | { | |
df7926ff | 343 | return ERR_PTR(-ENODEV); |
de1dd9fd MB |
344 | } |
345 | ||
4bdfb272 | 346 | |
070b9079 | 347 | static inline struct regulator *__must_check |
de1dd9fd | 348 | devm_regulator_get_optional(struct device *dev, const char *id) |
070b9079 | 349 | { |
df7926ff | 350 | return ERR_PTR(-ENODEV); |
070b9079 SB |
351 | } |
352 | ||
e2ce4eaa LG |
353 | static inline void regulator_put(struct regulator *regulator) |
354 | { | |
355 | } | |
356 | ||
2950c4bb AL |
357 | static inline void devm_regulator_put(struct regulator *regulator) |
358 | { | |
359 | } | |
360 | ||
a06ccd9c CK |
361 | static inline int regulator_register_supply_alias(struct device *dev, |
362 | const char *id, | |
363 | struct device *alias_dev, | |
364 | const char *alias_id) | |
365 | { | |
366 | return 0; | |
367 | } | |
368 | ||
369 | static inline void regulator_unregister_supply_alias(struct device *dev, | |
370 | const char *id) | |
371 | { | |
372 | } | |
373 | ||
374 | static inline int regulator_bulk_register_supply_alias(struct device *dev, | |
9f8c0fe9 LJ |
375 | const char *const *id, |
376 | struct device *alias_dev, | |
377 | const char * const *alias_id, | |
378 | int num_id) | |
a06ccd9c CK |
379 | { |
380 | return 0; | |
381 | } | |
382 | ||
383 | static inline void regulator_bulk_unregister_supply_alias(struct device *dev, | |
9f8c0fe9 LJ |
384 | const char * const *id, |
385 | int num_id) | |
a06ccd9c CK |
386 | { |
387 | } | |
388 | ||
389 | static inline int devm_regulator_register_supply_alias(struct device *dev, | |
390 | const char *id, | |
391 | struct device *alias_dev, | |
392 | const char *alias_id) | |
393 | { | |
394 | return 0; | |
395 | } | |
396 | ||
397 | static inline void devm_regulator_unregister_supply_alias(struct device *dev, | |
398 | const char *id) | |
399 | { | |
400 | } | |
401 | ||
9f8c0fe9 LJ |
402 | static inline int devm_regulator_bulk_register_supply_alias(struct device *dev, |
403 | const char *const *id, | |
404 | struct device *alias_dev, | |
405 | const char *const *alias_id, | |
406 | int num_id) | |
a06ccd9c CK |
407 | { |
408 | return 0; | |
409 | } | |
410 | ||
411 | static inline void devm_regulator_bulk_unregister_supply_alias( | |
9f8c0fe9 | 412 | struct device *dev, const char *const *id, int num_id) |
a06ccd9c CK |
413 | { |
414 | } | |
415 | ||
e2ce4eaa LG |
416 | static inline int regulator_enable(struct regulator *regulator) |
417 | { | |
418 | return 0; | |
419 | } | |
420 | ||
421 | static inline int regulator_disable(struct regulator *regulator) | |
422 | { | |
423 | return 0; | |
424 | } | |
425 | ||
935a5210 MH |
426 | static inline int regulator_force_disable(struct regulator *regulator) |
427 | { | |
428 | return 0; | |
429 | } | |
430 | ||
da07ecd9 MB |
431 | static inline int regulator_disable_deferred(struct regulator *regulator, |
432 | int ms) | |
433 | { | |
434 | return 0; | |
435 | } | |
436 | ||
e2ce4eaa LG |
437 | static inline int regulator_is_enabled(struct regulator *regulator) |
438 | { | |
439 | return 1; | |
440 | } | |
441 | ||
442 | static inline int regulator_bulk_get(struct device *dev, | |
443 | int num_consumers, | |
444 | struct regulator_bulk_data *consumers) | |
445 | { | |
446 | return 0; | |
447 | } | |
448 | ||
e24abd6e AL |
449 | static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers, |
450 | struct regulator_bulk_data *consumers) | |
451 | { | |
452 | return 0; | |
453 | } | |
454 | ||
e2ce4eaa LG |
455 | static inline int regulator_bulk_enable(int num_consumers, |
456 | struct regulator_bulk_data *consumers) | |
457 | { | |
458 | return 0; | |
459 | } | |
460 | ||
461 | static inline int regulator_bulk_disable(int num_consumers, | |
462 | struct regulator_bulk_data *consumers) | |
463 | { | |
464 | return 0; | |
465 | } | |
466 | ||
e1de2f42 DK |
467 | static inline int regulator_bulk_force_disable(int num_consumers, |
468 | struct regulator_bulk_data *consumers) | |
469 | { | |
470 | return 0; | |
471 | } | |
472 | ||
e2ce4eaa LG |
473 | static inline void regulator_bulk_free(int num_consumers, |
474 | struct regulator_bulk_data *consumers) | |
475 | { | |
476 | } | |
477 | ||
478 | static inline int regulator_set_voltage(struct regulator *regulator, | |
479 | int min_uV, int max_uV) | |
480 | { | |
481 | return 0; | |
482 | } | |
483 | ||
d660e92a VK |
484 | static inline int regulator_set_voltage_time(struct regulator *regulator, |
485 | int old_uV, int new_uV) | |
486 | { | |
487 | return 0; | |
488 | } | |
489 | ||
e2ce4eaa LG |
490 | static inline int regulator_get_voltage(struct regulator *regulator) |
491 | { | |
08aed2f6 | 492 | return -EINVAL; |
e2ce4eaa LG |
493 | } |
494 | ||
51dfb6ca DO |
495 | static inline int regulator_sync_voltage(struct regulator *regulator) |
496 | { | |
497 | return -EINVAL; | |
498 | } | |
499 | ||
4fe23791 PR |
500 | static inline int regulator_is_supported_voltage(struct regulator *regulator, |
501 | int min_uV, int max_uV) | |
502 | { | |
503 | return 0; | |
504 | } | |
505 | ||
7287275b AB |
506 | static inline unsigned int regulator_get_linear_step(struct regulator *regulator) |
507 | { | |
508 | return 0; | |
509 | } | |
510 | ||
e2ce4eaa LG |
511 | static inline int regulator_set_current_limit(struct regulator *regulator, |
512 | int min_uA, int max_uA) | |
513 | { | |
514 | return 0; | |
515 | } | |
516 | ||
517 | static inline int regulator_get_current_limit(struct regulator *regulator) | |
518 | { | |
519 | return 0; | |
520 | } | |
521 | ||
522 | static inline int regulator_set_mode(struct regulator *regulator, | |
523 | unsigned int mode) | |
524 | { | |
525 | return 0; | |
526 | } | |
527 | ||
528 | static inline unsigned int regulator_get_mode(struct regulator *regulator) | |
529 | { | |
530 | return REGULATOR_MODE_NORMAL; | |
531 | } | |
532 | ||
30103b5b DL |
533 | static inline int regulator_get_error_flags(struct regulator *regulator, |
534 | unsigned int *flags) | |
1b5b4221 AH |
535 | { |
536 | return -EINVAL; | |
537 | } | |
538 | ||
e39ce48f | 539 | static inline int regulator_set_load(struct regulator *regulator, int load_uA) |
e2ce4eaa | 540 | { |
f1abf672 | 541 | return 0; |
e2ce4eaa LG |
542 | } |
543 | ||
f59c8f9f MB |
544 | static inline int regulator_allow_bypass(struct regulator *regulator, |
545 | bool allow) | |
546 | { | |
547 | return 0; | |
548 | } | |
549 | ||
3bc0312e | 550 | static inline struct regmap *regulator_get_regmap(struct regulator *regulator) |
04eca28c TT |
551 | { |
552 | return ERR_PTR(-EOPNOTSUPP); | |
553 | } | |
554 | ||
3bc0312e MB |
555 | static inline int regulator_get_hardware_vsel_register(struct regulator *regulator, |
556 | unsigned *vsel_reg, | |
557 | unsigned *vsel_mask) | |
04eca28c TT |
558 | { |
559 | return -EOPNOTSUPP; | |
560 | } | |
561 | ||
3bc0312e MB |
562 | static inline int regulator_list_hardware_vsel(struct regulator *regulator, |
563 | unsigned selector) | |
04eca28c TT |
564 | { |
565 | return -EOPNOTSUPP; | |
566 | } | |
567 | ||
e2ce4eaa LG |
568 | static inline int regulator_register_notifier(struct regulator *regulator, |
569 | struct notifier_block *nb) | |
570 | { | |
571 | return 0; | |
572 | } | |
573 | ||
046db763 CK |
574 | static inline int devm_regulator_register_notifier(struct regulator *regulator, |
575 | struct notifier_block *nb) | |
576 | { | |
577 | return 0; | |
578 | } | |
579 | ||
e2ce4eaa LG |
580 | static inline int regulator_unregister_notifier(struct regulator *regulator, |
581 | struct notifier_block *nb) | |
582 | { | |
583 | return 0; | |
584 | } | |
585 | ||
046db763 CK |
586 | static inline int devm_regulator_unregister_notifier(struct regulator *regulator, |
587 | struct notifier_block *nb) | |
588 | { | |
589 | return 0; | |
590 | } | |
591 | ||
51dfb6ca DO |
592 | static inline int regulator_suspend_enable(struct regulator_dev *rdev, |
593 | suspend_state_t state) | |
594 | { | |
595 | return -EINVAL; | |
596 | } | |
597 | ||
598 | static inline int regulator_suspend_disable(struct regulator_dev *rdev, | |
599 | suspend_state_t state) | |
600 | { | |
601 | return -EINVAL; | |
602 | } | |
603 | ||
604 | static inline int regulator_set_suspend_voltage(struct regulator *regulator, | |
605 | int min_uV, int max_uV, | |
606 | suspend_state_t state) | |
607 | { | |
608 | return -EINVAL; | |
609 | } | |
610 | ||
e2ce4eaa LG |
611 | static inline void *regulator_get_drvdata(struct regulator *regulator) |
612 | { | |
613 | return NULL; | |
614 | } | |
615 | ||
616 | static inline void regulator_set_drvdata(struct regulator *regulator, | |
617 | void *data) | |
618 | { | |
619 | } | |
620 | ||
1a8f85d4 PR |
621 | static inline int regulator_count_voltages(struct regulator *regulator) |
622 | { | |
623 | return 0; | |
624 | } | |
5127e31a SP |
625 | |
626 | static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector) | |
627 | { | |
628 | return -EINVAL; | |
629 | } | |
630 | ||
d072cb26 BG |
631 | static inline void |
632 | regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, | |
633 | const char *const *supply_names, | |
634 | unsigned int num_supplies) | |
d0087e72 BG |
635 | { |
636 | } | |
637 | ||
b059b7e0 | 638 | static inline bool |
0468e667 | 639 | regulator_is_equal(struct regulator *reg1, struct regulator *reg2) |
b059b7e0 MV |
640 | { |
641 | return false; | |
642 | } | |
e2ce4eaa LG |
643 | #endif |
644 | ||
30f93ca8 VK |
645 | static inline int regulator_set_voltage_triplet(struct regulator *regulator, |
646 | int min_uV, int target_uV, | |
647 | int max_uV) | |
648 | { | |
649 | if (regulator_set_voltage(regulator, target_uV, max_uV) == 0) | |
650 | return 0; | |
651 | ||
652 | return regulator_set_voltage(regulator, min_uV, max_uV); | |
653 | } | |
654 | ||
3f196577 SG |
655 | static inline int regulator_set_voltage_tol(struct regulator *regulator, |
656 | int new_uV, int tol_uV) | |
657 | { | |
dc9ceed6 MB |
658 | if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0) |
659 | return 0; | |
660 | else | |
661 | return regulator_set_voltage(regulator, | |
662 | new_uV - tol_uV, new_uV + tol_uV); | |
3f196577 SG |
663 | } |
664 | ||
fe1e43f7 MB |
665 | static inline int regulator_is_supported_voltage_tol(struct regulator *regulator, |
666 | int target_uV, int tol_uV) | |
667 | { | |
668 | return regulator_is_supported_voltage(regulator, | |
669 | target_uV - tol_uV, | |
670 | target_uV + tol_uV); | |
671 | } | |
672 | ||
e2ce4eaa | 673 | #endif |