Merge tag 'mfd-next-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
[linux-2.6-microblaze.git] / include / linux / regulator / consumer.h
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
37 struct device;
38 struct notifier_block;
39 struct regmap;
40 struct regulator_dev;
41
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
81 #define REGULATOR_MODE_INVALID                  0x0
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.
95  * FORCE_DISABLE  Regulator forcibly shut down by software.
96  * VOLTAGE_CHANGE Regulator voltage changed.
97  *                Data passed is old voltage cast to (void *).
98  * DISABLE        Regulator was disabled.
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 *).
103  * PRE_DISABLE    Regulator is about to be disabled
104  * ABORT_DISABLE  Regulator disable failed for some reason
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
115 #define REGULATOR_EVENT_VOLTAGE_CHANGE          0x40
116 #define REGULATOR_EVENT_DISABLE                 0x80
117 #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE      0x100
118 #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE    0x200
119 #define REGULATOR_EVENT_PRE_DISABLE             0x400
120 #define REGULATOR_EVENT_ABORT_DISABLE           0x800
121 #define REGULATOR_EVENT_ENABLE                  0x1000
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
132
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
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)
155
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 };
168
169 struct regulator;
170
171 /**
172  * struct regulator_bulk_data - Data used for bulk regulator operations.
173  *
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.
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;
188         int init_load_uA;
189         struct regulator *consumer;
190
191         /* private: Internal use */
192         int ret;
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);
200 struct regulator *__must_check devm_regulator_get(struct device *dev,
201                                              const char *id);
202 struct regulator *__must_check regulator_get_exclusive(struct device *dev,
203                                                        const char *id);
204 struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
205                                                         const char *id);
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);
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);
212 void regulator_put(struct regulator *regulator);
213 void devm_regulator_put(struct regulator *regulator);
214
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
220 int regulator_bulk_register_supply_alias(struct device *dev,
221                                          const char *const *id,
222                                          struct device *alias_dev,
223                                          const char *const *alias_id,
224                                          int num_id);
225 void regulator_bulk_unregister_supply_alias(struct device *dev,
226                                             const char * const *id, int num_id);
227
228 int devm_regulator_register_supply_alias(struct device *dev, const char *id,
229                                          struct device *alias_dev,
230                                          const char *alias_id);
231
232 int devm_regulator_bulk_register_supply_alias(struct device *dev,
233                                               const char *const *id,
234                                               struct device *alias_dev,
235                                               const char *const *alias_id,
236                                               int num_id);
237
238 /* regulator output control and status */
239 int __must_check regulator_enable(struct regulator *regulator);
240 int regulator_disable(struct regulator *regulator);
241 int regulator_force_disable(struct regulator *regulator);
242 int regulator_is_enabled(struct regulator *regulator);
243 int regulator_disable_deferred(struct regulator *regulator, int ms);
244
245 int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
246                                     struct regulator_bulk_data *consumers);
247 int __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np,
248                                            struct regulator_bulk_data **consumers);
249 int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
250                                          struct regulator_bulk_data *consumers);
251 void devm_regulator_bulk_put(struct regulator_bulk_data *consumers);
252 int __must_check devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers,
253                                                    struct regulator_bulk_data *consumers);
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);
258 int __must_check regulator_bulk_enable(int num_consumers,
259                                        struct regulator_bulk_data *consumers);
260 int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers,
261                                    const char * const *id);
262 int regulator_bulk_disable(int num_consumers,
263                            struct regulator_bulk_data *consumers);
264 int regulator_bulk_force_disable(int num_consumers,
265                            struct regulator_bulk_data *consumers);
266 void regulator_bulk_free(int num_consumers,
267                          struct regulator_bulk_data *consumers);
268
269 int regulator_count_voltages(struct regulator *regulator);
270 int regulator_list_voltage(struct regulator *regulator, unsigned selector);
271 int regulator_is_supported_voltage(struct regulator *regulator,
272                                    int min_uV, int max_uV);
273 unsigned int regulator_get_linear_step(struct regulator *regulator);
274 int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
275 int regulator_set_voltage_time(struct regulator *regulator,
276                                int old_uV, int new_uV);
277 int regulator_get_voltage(struct regulator *regulator);
278 int regulator_sync_voltage(struct regulator *regulator);
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);
285 int regulator_get_error_flags(struct regulator *regulator,
286                                 unsigned int *flags);
287 int regulator_set_load(struct regulator *regulator, int load_uA);
288
289 int regulator_allow_bypass(struct regulator *regulator, bool allow);
290
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
298 /* regulator notifier block */
299 int regulator_register_notifier(struct regulator *regulator,
300                               struct notifier_block *nb);
301 int devm_regulator_register_notifier(struct regulator *regulator,
302                                      struct notifier_block *nb);
303 int regulator_unregister_notifier(struct regulator *regulator,
304                                 struct notifier_block *nb);
305 void devm_regulator_unregister_notifier(struct regulator *regulator,
306                                         struct notifier_block *nb);
307
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
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
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
326 bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2);
327
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
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.
344          */
345         return NULL;
346 }
347
348 static inline struct regulator *__must_check
349 devm_regulator_get(struct device *dev, const char *id)
350 {
351         return NULL;
352 }
353
354 static inline struct regulator *__must_check
355 regulator_get_exclusive(struct device *dev, const char *id)
356 {
357         return ERR_PTR(-ENODEV);
358 }
359
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
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
377 static inline struct regulator *__must_check
378 regulator_get_optional(struct device *dev, const char *id)
379 {
380         return ERR_PTR(-ENODEV);
381 }
382
383
384 static inline struct regulator *__must_check
385 devm_regulator_get_optional(struct device *dev, const char *id)
386 {
387         return ERR_PTR(-ENODEV);
388 }
389
390 static inline void regulator_put(struct regulator *regulator)
391 {
392 }
393
394 static inline void devm_regulator_put(struct regulator *regulator)
395 {
396 }
397
398 static inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers)
399 {
400 }
401
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,
416                                                 const char *const *id,
417                                                 struct device *alias_dev,
418                                                 const char * const *alias_id,
419                                                 int num_id)
420 {
421         return 0;
422 }
423
424 static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
425                                                 const char * const *id,
426                                                 int num_id)
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
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)
443 {
444         return 0;
445 }
446
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
457 static inline int regulator_force_disable(struct regulator *regulator)
458 {
459         return 0;
460 }
461
462 static inline int regulator_disable_deferred(struct regulator *regulator,
463                                              int ms)
464 {
465         return 0;
466 }
467
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
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
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
492 static inline int regulator_bulk_enable(int num_consumers,
493                                         struct regulator_bulk_data *consumers)
494 {
495         return 0;
496 }
497
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
505 static inline int regulator_bulk_disable(int num_consumers,
506                                          struct regulator_bulk_data *consumers)
507 {
508         return 0;
509 }
510
511 static inline int regulator_bulk_force_disable(int num_consumers,
512                                         struct regulator_bulk_data *consumers)
513 {
514         return 0;
515 }
516
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
528 static inline int regulator_set_voltage_time(struct regulator *regulator,
529                                              int old_uV, int new_uV)
530 {
531         return 0;
532 }
533
534 static inline int regulator_get_voltage(struct regulator *regulator)
535 {
536         return -EINVAL;
537 }
538
539 static inline int regulator_sync_voltage(struct regulator *regulator)
540 {
541         return -EINVAL;
542 }
543
544 static inline int regulator_is_supported_voltage(struct regulator *regulator,
545                                    int min_uV, int max_uV)
546 {
547         return 0;
548 }
549
550 static inline unsigned int regulator_get_linear_step(struct regulator *regulator)
551 {
552         return 0;
553 }
554
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
577 static inline int regulator_get_error_flags(struct regulator *regulator,
578                                             unsigned int *flags)
579 {
580         return -EINVAL;
581 }
582
583 static inline int regulator_set_load(struct regulator *regulator, int load_uA)
584 {
585         return 0;
586 }
587
588 static inline int regulator_allow_bypass(struct regulator *regulator,
589                                          bool allow)
590 {
591         return 0;
592 }
593
594 static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
595 {
596         return ERR_PTR(-EOPNOTSUPP);
597 }
598
599 static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
600                                                        unsigned *vsel_reg,
601                                                        unsigned *vsel_mask)
602 {
603         return -EOPNOTSUPP;
604 }
605
606 static inline int regulator_list_hardware_vsel(struct regulator *regulator,
607                                                unsigned selector)
608 {
609         return -EOPNOTSUPP;
610 }
611
612 static inline int regulator_register_notifier(struct regulator *regulator,
613                               struct notifier_block *nb)
614 {
615         return 0;
616 }
617
618 static inline int devm_regulator_register_notifier(struct regulator *regulator,
619                                                    struct notifier_block *nb)
620 {
621         return 0;
622 }
623
624 static inline int regulator_unregister_notifier(struct regulator *regulator,
625                                 struct notifier_block *nb)
626 {
627         return 0;
628 }
629
630 static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
631                                                      struct notifier_block *nb)
632 {
633         return 0;
634 }
635
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
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
665 static inline int regulator_count_voltages(struct regulator *regulator)
666 {
667         return 0;
668 }
669
670 static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
671 {
672         return -EINVAL;
673 }
674
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)
679 {
680 }
681
682 static inline bool
683 regulator_is_equal(struct regulator *reg1, struct regulator *reg2)
684 {
685         return false;
686 }
687 #endif
688
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
699 static inline int regulator_set_voltage_tol(struct regulator *regulator,
700                                             int new_uV, int tol_uV)
701 {
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);
707 }
708
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
717 #endif