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