Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * consumer.h -- SoC Regulator consumer support.
0004  *
0005  * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
0006  *
0007  * Author: Liam Girdwood <lrg@slimlogic.co.uk>
0008  *
0009  * Regulator Consumer Interface.
0010  *
0011  * A Power Management Regulator framework for SoC based devices.
0012  * Features:-
0013  *   o Voltage and current level control.
0014  *   o Operating mode control.
0015  *   o Regulator status.
0016  *   o sysfs entries for showing client devices and status
0017  *
0018  * EXPERIMENTAL FEATURES:
0019  *   Dynamic Regulator operating Mode Switching (DRMS) - allows regulators
0020  *   to use most efficient operating mode depending upon voltage and load and
0021  *   is transparent to client drivers.
0022  *
0023  *   e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during
0024  *   IO and 1mA at idle. Device z draws 100mA when under load and 5mA when
0025  *   idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA
0026  *   but this drops rapidly to 60% when below 100mA. Regulator r has > 90%
0027  *   efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate
0028  *   in normal mode for loads > 10mA and in IDLE mode for load <= 10mA.
0029  */
0030 
0031 #ifndef __LINUX_REGULATOR_CONSUMER_H_
0032 #define __LINUX_REGULATOR_CONSUMER_H_
0033 
0034 #include <linux/err.h>
0035 #include <linux/suspend.h>
0036 
0037 struct device;
0038 struct notifier_block;
0039 struct regmap;
0040 struct regulator_dev;
0041 
0042 /*
0043  * Regulator operating modes.
0044  *
0045  * Regulators can run in a variety of different operating modes depending on
0046  * output load. This allows further system power savings by selecting the
0047  * best (and most efficient) regulator mode for a desired load.
0048  *
0049  * Most drivers will only care about NORMAL. The modes below are generic and
0050  * will probably not match the naming convention of your regulator data sheet
0051  * but should match the use cases in the datasheet.
0052  *
0053  * In order of power efficiency (least efficient at top).
0054  *
0055  *  Mode       Description
0056  *  FAST       Regulator can handle fast changes in it's load.
0057  *             e.g. useful in CPU voltage & frequency scaling where
0058  *             load can quickly increase with CPU frequency increases.
0059  *
0060  *  NORMAL     Normal regulator power supply mode. Most drivers will
0061  *             use this mode.
0062  *
0063  *  IDLE       Regulator runs in a more efficient mode for light
0064  *             loads. Can be used for devices that have a low power
0065  *             requirement during periods of inactivity. This mode
0066  *             may be more noisy than NORMAL and may not be able
0067  *             to handle fast load switching.
0068  *
0069  *  STANDBY    Regulator runs in the most efficient mode for very
0070  *             light loads. Can be used by devices when they are
0071  *             in a sleep/standby state. This mode is likely to be
0072  *             the most noisy and may not be able to handle fast load
0073  *             switching.
0074  *
0075  * NOTE: Most regulators will only support a subset of these modes. Some
0076  * will only just support NORMAL.
0077  *
0078  * These modes can be OR'ed together to make up a mask of valid register modes.
0079  */
0080 
0081 #define REGULATOR_MODE_INVALID          0x0
0082 #define REGULATOR_MODE_FAST         0x1
0083 #define REGULATOR_MODE_NORMAL           0x2
0084 #define REGULATOR_MODE_IDLE         0x4
0085 #define REGULATOR_MODE_STANDBY          0x8
0086 
0087 /*
0088  * Regulator notifier events.
0089  *
0090  * UNDER_VOLTAGE  Regulator output is under voltage.
0091  * OVER_CURRENT   Regulator output current is too high.
0092  * REGULATION_OUT Regulator output is out of regulation.
0093  * FAIL           Regulator output has failed.
0094  * OVER_TEMP      Regulator over temp.
0095  * FORCE_DISABLE  Regulator forcibly shut down by software.
0096  * VOLTAGE_CHANGE Regulator voltage changed.
0097  *                Data passed is old voltage cast to (void *).
0098  * DISABLE        Regulator was disabled.
0099  * PRE_VOLTAGE_CHANGE   Regulator is about to have voltage changed.
0100  *                      Data passed is "struct pre_voltage_change_data"
0101  * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
0102  *                      Data passed is old voltage cast to (void *).
0103  * PRE_DISABLE    Regulator is about to be disabled
0104  * ABORT_DISABLE  Regulator disable failed for some reason
0105  *
0106  * NOTE: These events can be OR'ed together when passed into handler.
0107  */
0108 
0109 #define REGULATOR_EVENT_UNDER_VOLTAGE       0x01
0110 #define REGULATOR_EVENT_OVER_CURRENT        0x02
0111 #define REGULATOR_EVENT_REGULATION_OUT      0x04
0112 #define REGULATOR_EVENT_FAIL            0x08
0113 #define REGULATOR_EVENT_OVER_TEMP       0x10
0114 #define REGULATOR_EVENT_FORCE_DISABLE       0x20
0115 #define REGULATOR_EVENT_VOLTAGE_CHANGE      0x40
0116 #define REGULATOR_EVENT_DISABLE         0x80
0117 #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE  0x100
0118 #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE    0x200
0119 #define REGULATOR_EVENT_PRE_DISABLE     0x400
0120 #define REGULATOR_EVENT_ABORT_DISABLE       0x800
0121 #define REGULATOR_EVENT_ENABLE          0x1000
0122 /*
0123  * Following notifications should be emitted only if detected condition
0124  * is such that the HW is likely to still be working but consumers should
0125  * take a recovery action to prevent problems esacalating into errors.
0126  */
0127 #define REGULATOR_EVENT_UNDER_VOLTAGE_WARN  0x2000
0128 #define REGULATOR_EVENT_OVER_CURRENT_WARN   0x4000
0129 #define REGULATOR_EVENT_OVER_VOLTAGE_WARN   0x8000
0130 #define REGULATOR_EVENT_OVER_TEMP_WARN      0x10000
0131 #define REGULATOR_EVENT_WARN_MASK       0x1E000
0132 
0133 /*
0134  * Regulator errors that can be queried using regulator_get_error_flags
0135  *
0136  * UNDER_VOLTAGE  Regulator output is under voltage.
0137  * OVER_CURRENT   Regulator output current is too high.
0138  * REGULATION_OUT Regulator output is out of regulation.
0139  * FAIL           Regulator output has failed.
0140  * OVER_TEMP      Regulator over temp.
0141  *
0142  * NOTE: These errors can be OR'ed together.
0143  */
0144 
0145 #define REGULATOR_ERROR_UNDER_VOLTAGE       BIT(1)
0146 #define REGULATOR_ERROR_OVER_CURRENT        BIT(2)
0147 #define REGULATOR_ERROR_REGULATION_OUT      BIT(3)
0148 #define REGULATOR_ERROR_FAIL            BIT(4)
0149 #define REGULATOR_ERROR_OVER_TEMP       BIT(5)
0150 
0151 #define REGULATOR_ERROR_UNDER_VOLTAGE_WARN  BIT(6)
0152 #define REGULATOR_ERROR_OVER_CURRENT_WARN   BIT(7)
0153 #define REGULATOR_ERROR_OVER_VOLTAGE_WARN   BIT(8)
0154 #define REGULATOR_ERROR_OVER_TEMP_WARN      BIT(9)
0155 
0156 /**
0157  * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
0158  *
0159  * @old_uV: Current voltage before change.
0160  * @min_uV: Min voltage we'll change to.
0161  * @max_uV: Max voltage we'll change to.
0162  */
0163 struct pre_voltage_change_data {
0164     unsigned long old_uV;
0165     unsigned long min_uV;
0166     unsigned long max_uV;
0167 };
0168 
0169 struct regulator;
0170 
0171 /**
0172  * struct regulator_bulk_data - Data used for bulk regulator operations.
0173  *
0174  * @supply:       The name of the supply.  Initialised by the user before
0175  *                using the bulk regulator APIs.
0176  * @init_load_uA: After getting the regulator, regulator_set_load() will be
0177  *                called with this load.  Initialised by the user before
0178  *                using the bulk regulator APIs.
0179  * @consumer:     The regulator consumer for the supply.  This will be managed
0180  *                by the bulk API.
0181  *
0182  * The regulator APIs provide a series of regulator_bulk_() API calls as
0183  * a convenience to consumers which require multiple supplies.  This
0184  * structure is used to manage data for these calls.
0185  */
0186 struct regulator_bulk_data {
0187     const char *supply;
0188     int init_load_uA;
0189     struct regulator *consumer;
0190 
0191     /* private: Internal use */
0192     int ret;
0193 };
0194 
0195 #if defined(CONFIG_REGULATOR)
0196 
0197 /* regulator get and put */
0198 struct regulator *__must_check regulator_get(struct device *dev,
0199                          const char *id);
0200 struct regulator *__must_check devm_regulator_get(struct device *dev,
0201                          const char *id);
0202 struct regulator *__must_check regulator_get_exclusive(struct device *dev,
0203                                const char *id);
0204 struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
0205                             const char *id);
0206 struct regulator *__must_check regulator_get_optional(struct device *dev,
0207                               const char *id);
0208 struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
0209                                const char *id);
0210 void regulator_put(struct regulator *regulator);
0211 void devm_regulator_put(struct regulator *regulator);
0212 
0213 int regulator_register_supply_alias(struct device *dev, const char *id,
0214                     struct device *alias_dev,
0215                     const char *alias_id);
0216 void regulator_unregister_supply_alias(struct device *dev, const char *id);
0217 
0218 int regulator_bulk_register_supply_alias(struct device *dev,
0219                      const char *const *id,
0220                      struct device *alias_dev,
0221                      const char *const *alias_id,
0222                      int num_id);
0223 void regulator_bulk_unregister_supply_alias(struct device *dev,
0224                         const char * const *id, int num_id);
0225 
0226 int devm_regulator_register_supply_alias(struct device *dev, const char *id,
0227                      struct device *alias_dev,
0228                      const char *alias_id);
0229 
0230 int devm_regulator_bulk_register_supply_alias(struct device *dev,
0231                           const char *const *id,
0232                           struct device *alias_dev,
0233                           const char *const *alias_id,
0234                           int num_id);
0235 
0236 /* regulator output control and status */
0237 int __must_check regulator_enable(struct regulator *regulator);
0238 int regulator_disable(struct regulator *regulator);
0239 int regulator_force_disable(struct regulator *regulator);
0240 int regulator_is_enabled(struct regulator *regulator);
0241 int regulator_disable_deferred(struct regulator *regulator, int ms);
0242 
0243 int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
0244                     struct regulator_bulk_data *consumers);
0245 int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
0246                      struct regulator_bulk_data *consumers);
0247 int __must_check devm_regulator_bulk_get_const(
0248     struct device *dev, int num_consumers,
0249     const struct regulator_bulk_data *in_consumers,
0250     struct regulator_bulk_data **out_consumers);
0251 int __must_check regulator_bulk_enable(int num_consumers,
0252                        struct regulator_bulk_data *consumers);
0253 int regulator_bulk_disable(int num_consumers,
0254                struct regulator_bulk_data *consumers);
0255 int regulator_bulk_force_disable(int num_consumers,
0256                struct regulator_bulk_data *consumers);
0257 void regulator_bulk_free(int num_consumers,
0258              struct regulator_bulk_data *consumers);
0259 
0260 int regulator_count_voltages(struct regulator *regulator);
0261 int regulator_list_voltage(struct regulator *regulator, unsigned selector);
0262 int regulator_is_supported_voltage(struct regulator *regulator,
0263                    int min_uV, int max_uV);
0264 unsigned int regulator_get_linear_step(struct regulator *regulator);
0265 int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
0266 int regulator_set_voltage_time(struct regulator *regulator,
0267                    int old_uV, int new_uV);
0268 int regulator_get_voltage(struct regulator *regulator);
0269 int regulator_sync_voltage(struct regulator *regulator);
0270 int regulator_set_current_limit(struct regulator *regulator,
0271                    int min_uA, int max_uA);
0272 int regulator_get_current_limit(struct regulator *regulator);
0273 
0274 int regulator_set_mode(struct regulator *regulator, unsigned int mode);
0275 unsigned int regulator_get_mode(struct regulator *regulator);
0276 int regulator_get_error_flags(struct regulator *regulator,
0277                 unsigned int *flags);
0278 int regulator_set_load(struct regulator *regulator, int load_uA);
0279 
0280 int regulator_allow_bypass(struct regulator *regulator, bool allow);
0281 
0282 struct regmap *regulator_get_regmap(struct regulator *regulator);
0283 int regulator_get_hardware_vsel_register(struct regulator *regulator,
0284                      unsigned *vsel_reg,
0285                      unsigned *vsel_mask);
0286 int regulator_list_hardware_vsel(struct regulator *regulator,
0287                  unsigned selector);
0288 
0289 /* regulator notifier block */
0290 int regulator_register_notifier(struct regulator *regulator,
0291                   struct notifier_block *nb);
0292 int devm_regulator_register_notifier(struct regulator *regulator,
0293                      struct notifier_block *nb);
0294 int regulator_unregister_notifier(struct regulator *regulator,
0295                 struct notifier_block *nb);
0296 void devm_regulator_unregister_notifier(struct regulator *regulator,
0297                     struct notifier_block *nb);
0298 
0299 /* regulator suspend */
0300 int regulator_suspend_enable(struct regulator_dev *rdev,
0301                  suspend_state_t state);
0302 int regulator_suspend_disable(struct regulator_dev *rdev,
0303                   suspend_state_t state);
0304 int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV,
0305                   int max_uV, suspend_state_t state);
0306 
0307 /* driver data - core doesn't touch */
0308 void *regulator_get_drvdata(struct regulator *regulator);
0309 void regulator_set_drvdata(struct regulator *regulator, void *data);
0310 
0311 /* misc helpers */
0312 
0313 void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
0314                      const char *const *supply_names,
0315                      unsigned int num_supplies);
0316 
0317 bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2);
0318 
0319 #else
0320 
0321 /*
0322  * Make sure client drivers will still build on systems with no software
0323  * controllable voltage or current regulators.
0324  */
0325 static inline struct regulator *__must_check regulator_get(struct device *dev,
0326     const char *id)
0327 {
0328     /* Nothing except the stubbed out regulator API should be
0329      * looking at the value except to check if it is an error
0330      * value. Drivers are free to handle NULL specifically by
0331      * skipping all regulator API calls, but they don't have to.
0332      * Drivers which don't, should make sure they properly handle
0333      * corner cases of the API, such as regulator_get_voltage()
0334      * returning 0.
0335      */
0336     return NULL;
0337 }
0338 
0339 static inline struct regulator *__must_check
0340 devm_regulator_get(struct device *dev, const char *id)
0341 {
0342     return NULL;
0343 }
0344 
0345 static inline struct regulator *__must_check
0346 regulator_get_exclusive(struct device *dev, const char *id)
0347 {
0348     return ERR_PTR(-ENODEV);
0349 }
0350 
0351 static inline struct regulator *__must_check
0352 devm_regulator_get_exclusive(struct device *dev, const char *id)
0353 {
0354     return ERR_PTR(-ENODEV);
0355 }
0356 
0357 static inline struct regulator *__must_check
0358 regulator_get_optional(struct device *dev, const char *id)
0359 {
0360     return ERR_PTR(-ENODEV);
0361 }
0362 
0363 
0364 static inline struct regulator *__must_check
0365 devm_regulator_get_optional(struct device *dev, const char *id)
0366 {
0367     return ERR_PTR(-ENODEV);
0368 }
0369 
0370 static inline void regulator_put(struct regulator *regulator)
0371 {
0372 }
0373 
0374 static inline void devm_regulator_put(struct regulator *regulator)
0375 {
0376 }
0377 
0378 static inline int regulator_register_supply_alias(struct device *dev,
0379                           const char *id,
0380                           struct device *alias_dev,
0381                           const char *alias_id)
0382 {
0383     return 0;
0384 }
0385 
0386 static inline void regulator_unregister_supply_alias(struct device *dev,
0387                             const char *id)
0388 {
0389 }
0390 
0391 static inline int regulator_bulk_register_supply_alias(struct device *dev,
0392                         const char *const *id,
0393                         struct device *alias_dev,
0394                         const char * const *alias_id,
0395                         int num_id)
0396 {
0397     return 0;
0398 }
0399 
0400 static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
0401                         const char * const *id,
0402                         int num_id)
0403 {
0404 }
0405 
0406 static inline int devm_regulator_register_supply_alias(struct device *dev,
0407                                const char *id,
0408                                struct device *alias_dev,
0409                                const char *alias_id)
0410 {
0411     return 0;
0412 }
0413 
0414 static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
0415                         const char *const *id,
0416                         struct device *alias_dev,
0417                         const char *const *alias_id,
0418                         int num_id)
0419 {
0420     return 0;
0421 }
0422 
0423 static inline int regulator_enable(struct regulator *regulator)
0424 {
0425     return 0;
0426 }
0427 
0428 static inline int regulator_disable(struct regulator *regulator)
0429 {
0430     return 0;
0431 }
0432 
0433 static inline int regulator_force_disable(struct regulator *regulator)
0434 {
0435     return 0;
0436 }
0437 
0438 static inline int regulator_disable_deferred(struct regulator *regulator,
0439                          int ms)
0440 {
0441     return 0;
0442 }
0443 
0444 static inline int regulator_is_enabled(struct regulator *regulator)
0445 {
0446     return 1;
0447 }
0448 
0449 static inline int regulator_bulk_get(struct device *dev,
0450                      int num_consumers,
0451                      struct regulator_bulk_data *consumers)
0452 {
0453     return 0;
0454 }
0455 
0456 static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
0457                       struct regulator_bulk_data *consumers)
0458 {
0459     return 0;
0460 }
0461 
0462 static inline int regulator_bulk_enable(int num_consumers,
0463                     struct regulator_bulk_data *consumers)
0464 {
0465     return 0;
0466 }
0467 
0468 static inline int regulator_bulk_disable(int num_consumers,
0469                      struct regulator_bulk_data *consumers)
0470 {
0471     return 0;
0472 }
0473 
0474 static inline int regulator_bulk_force_disable(int num_consumers,
0475                     struct regulator_bulk_data *consumers)
0476 {
0477     return 0;
0478 }
0479 
0480 static inline void regulator_bulk_free(int num_consumers,
0481                        struct regulator_bulk_data *consumers)
0482 {
0483 }
0484 
0485 static inline int regulator_set_voltage(struct regulator *regulator,
0486                     int min_uV, int max_uV)
0487 {
0488     return 0;
0489 }
0490 
0491 static inline int regulator_set_voltage_time(struct regulator *regulator,
0492                          int old_uV, int new_uV)
0493 {
0494     return 0;
0495 }
0496 
0497 static inline int regulator_get_voltage(struct regulator *regulator)
0498 {
0499     return -EINVAL;
0500 }
0501 
0502 static inline int regulator_sync_voltage(struct regulator *regulator)
0503 {
0504     return -EINVAL;
0505 }
0506 
0507 static inline int regulator_is_supported_voltage(struct regulator *regulator,
0508                    int min_uV, int max_uV)
0509 {
0510     return 0;
0511 }
0512 
0513 static inline unsigned int regulator_get_linear_step(struct regulator *regulator)
0514 {
0515     return 0;
0516 }
0517 
0518 static inline int regulator_set_current_limit(struct regulator *regulator,
0519                          int min_uA, int max_uA)
0520 {
0521     return 0;
0522 }
0523 
0524 static inline int regulator_get_current_limit(struct regulator *regulator)
0525 {
0526     return 0;
0527 }
0528 
0529 static inline int regulator_set_mode(struct regulator *regulator,
0530     unsigned int mode)
0531 {
0532     return 0;
0533 }
0534 
0535 static inline unsigned int regulator_get_mode(struct regulator *regulator)
0536 {
0537     return REGULATOR_MODE_NORMAL;
0538 }
0539 
0540 static inline int regulator_get_error_flags(struct regulator *regulator,
0541                         unsigned int *flags)
0542 {
0543     return -EINVAL;
0544 }
0545 
0546 static inline int regulator_set_load(struct regulator *regulator, int load_uA)
0547 {
0548     return 0;
0549 }
0550 
0551 static inline int regulator_allow_bypass(struct regulator *regulator,
0552                      bool allow)
0553 {
0554     return 0;
0555 }
0556 
0557 static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
0558 {
0559     return ERR_PTR(-EOPNOTSUPP);
0560 }
0561 
0562 static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
0563                                unsigned *vsel_reg,
0564                                unsigned *vsel_mask)
0565 {
0566     return -EOPNOTSUPP;
0567 }
0568 
0569 static inline int regulator_list_hardware_vsel(struct regulator *regulator,
0570                            unsigned selector)
0571 {
0572     return -EOPNOTSUPP;
0573 }
0574 
0575 static inline int regulator_register_notifier(struct regulator *regulator,
0576                   struct notifier_block *nb)
0577 {
0578     return 0;
0579 }
0580 
0581 static inline int devm_regulator_register_notifier(struct regulator *regulator,
0582                            struct notifier_block *nb)
0583 {
0584     return 0;
0585 }
0586 
0587 static inline int regulator_unregister_notifier(struct regulator *regulator,
0588                 struct notifier_block *nb)
0589 {
0590     return 0;
0591 }
0592 
0593 static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
0594                              struct notifier_block *nb)
0595 {
0596     return 0;
0597 }
0598 
0599 static inline int regulator_suspend_enable(struct regulator_dev *rdev,
0600                        suspend_state_t state)
0601 {
0602     return -EINVAL;
0603 }
0604 
0605 static inline int regulator_suspend_disable(struct regulator_dev *rdev,
0606                         suspend_state_t state)
0607 {
0608     return -EINVAL;
0609 }
0610 
0611 static inline int regulator_set_suspend_voltage(struct regulator *regulator,
0612                         int min_uV, int max_uV,
0613                         suspend_state_t state)
0614 {
0615     return -EINVAL;
0616 }
0617 
0618 static inline void *regulator_get_drvdata(struct regulator *regulator)
0619 {
0620     return NULL;
0621 }
0622 
0623 static inline void regulator_set_drvdata(struct regulator *regulator,
0624     void *data)
0625 {
0626 }
0627 
0628 static inline int regulator_count_voltages(struct regulator *regulator)
0629 {
0630     return 0;
0631 }
0632 
0633 static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
0634 {
0635     return -EINVAL;
0636 }
0637 
0638 static inline void
0639 regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
0640                 const char *const *supply_names,
0641                 unsigned int num_supplies)
0642 {
0643 }
0644 
0645 static inline bool
0646 regulator_is_equal(struct regulator *reg1, struct regulator *reg2)
0647 {
0648     return false;
0649 }
0650 #endif
0651 
0652 static inline int regulator_set_voltage_triplet(struct regulator *regulator,
0653                         int min_uV, int target_uV,
0654                         int max_uV)
0655 {
0656     if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
0657         return 0;
0658 
0659     return regulator_set_voltage(regulator, min_uV, max_uV);
0660 }
0661 
0662 static inline int regulator_set_voltage_tol(struct regulator *regulator,
0663                         int new_uV, int tol_uV)
0664 {
0665     if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
0666         return 0;
0667     else
0668         return regulator_set_voltage(regulator,
0669                          new_uV - tol_uV, new_uV + tol_uV);
0670 }
0671 
0672 static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
0673                              int target_uV, int tol_uV)
0674 {
0675     return regulator_is_supported_voltage(regulator,
0676                           target_uV - tol_uV,
0677                           target_uV + tol_uV);
0678 }
0679 
0680 #endif