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 | #include <regulator/regulator.h> |
37 | |
38 | struct device; |
39 | struct notifier_block; |
40 | struct regmap; |
41 | struct regulator_dev; |
42 | |
43 | /* |
44 | * Regulator operating modes. |
45 | * |
46 | * Regulators can run in a variety of different operating modes depending on |
47 | * output load. This allows further system power savings by selecting the |
48 | * best (and most efficient) regulator mode for a desired load. |
49 | * |
50 | * Most drivers will only care about NORMAL. The modes below are generic and |
51 | * will probably not match the naming convention of your regulator data sheet |
52 | * but should match the use cases in the datasheet. |
53 | * |
54 | * In order of power efficiency (least efficient at top). |
55 | * |
56 | * Mode Description |
57 | * FAST Regulator can handle fast changes in it's load. |
58 | * e.g. useful in CPU voltage & frequency scaling where |
59 | * load can quickly increase with CPU frequency increases. |
60 | * |
61 | * NORMAL Normal regulator power supply mode. Most drivers will |
62 | * use this mode. |
63 | * |
64 | * IDLE Regulator runs in a more efficient mode for light |
65 | * loads. Can be used for devices that have a low power |
66 | * requirement during periods of inactivity. This mode |
67 | * may be more noisy than NORMAL and may not be able |
68 | * to handle fast load switching. |
69 | * |
70 | * STANDBY Regulator runs in the most efficient mode for very |
71 | * light loads. Can be used by devices when they are |
72 | * in a sleep/standby state. This mode is likely to be |
73 | * the most noisy and may not be able to handle fast load |
74 | * switching. |
75 | * |
76 | * NOTE: Most regulators will only support a subset of these modes. Some |
77 | * will only just support NORMAL. |
78 | * |
79 | * These modes can be OR'ed together to make up a mask of valid register modes. |
80 | */ |
81 | |
82 | #define REGULATOR_MODE_INVALID 0x0 |
83 | #define REGULATOR_MODE_FAST 0x1 |
84 | #define REGULATOR_MODE_NORMAL 0x2 |
85 | #define REGULATOR_MODE_IDLE 0x4 |
86 | #define REGULATOR_MODE_STANDBY 0x8 |
87 | |
88 | /* |
89 | * Regulator errors that can be queried using regulator_get_error_flags |
90 | * |
91 | * UNDER_VOLTAGE Regulator output is under voltage. |
92 | * OVER_CURRENT Regulator output current is too high. |
93 | * REGULATION_OUT Regulator output is out of regulation. |
94 | * FAIL Regulator output has failed. |
95 | * OVER_TEMP Regulator over temp. |
96 | * |
97 | * NOTE: These errors can be OR'ed together. |
98 | */ |
99 | |
100 | #define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1) |
101 | #define REGULATOR_ERROR_OVER_CURRENT BIT(2) |
102 | #define REGULATOR_ERROR_REGULATION_OUT BIT(3) |
103 | #define REGULATOR_ERROR_FAIL BIT(4) |
104 | #define REGULATOR_ERROR_OVER_TEMP BIT(5) |
105 | |
106 | #define REGULATOR_ERROR_UNDER_VOLTAGE_WARN BIT(6) |
107 | #define REGULATOR_ERROR_OVER_CURRENT_WARN BIT(7) |
108 | #define REGULATOR_ERROR_OVER_VOLTAGE_WARN BIT(8) |
109 | #define REGULATOR_ERROR_OVER_TEMP_WARN BIT(9) |
110 | |
111 | /** |
112 | * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event |
113 | * |
114 | * @old_uV: Current voltage before change. |
115 | * @min_uV: Min voltage we'll change to. |
116 | * @max_uV: Max voltage we'll change to. |
117 | */ |
118 | struct pre_voltage_change_data { |
119 | unsigned long old_uV; |
120 | unsigned long min_uV; |
121 | unsigned long max_uV; |
122 | }; |
123 | |
124 | struct regulator; |
125 | |
126 | /** |
127 | * struct regulator_bulk_data - Data used for bulk regulator operations. |
128 | * |
129 | * @supply: The name of the supply. Initialised by the user before |
130 | * using the bulk regulator APIs. |
131 | * @init_load_uA: After getting the regulator, regulator_set_load() will be |
132 | * called with this load. Initialised by the user before |
133 | * using the bulk regulator APIs. |
134 | * @consumer: The regulator consumer for the supply. This will be managed |
135 | * by the bulk API. |
136 | * |
137 | * The regulator APIs provide a series of regulator_bulk_() API calls as |
138 | * a convenience to consumers which require multiple supplies. This |
139 | * structure is used to manage data for these calls. |
140 | */ |
141 | struct regulator_bulk_data { |
142 | const char *supply; |
143 | int init_load_uA; |
144 | struct regulator *consumer; |
145 | |
146 | /* private: Internal use */ |
147 | int ret; |
148 | }; |
149 | |
150 | #if defined(CONFIG_REGULATOR) |
151 | |
152 | /* regulator get and put */ |
153 | struct regulator *__must_check regulator_get(struct device *dev, |
154 | const char *id); |
155 | struct regulator *__must_check devm_regulator_get(struct device *dev, |
156 | const char *id); |
157 | struct regulator *__must_check regulator_get_exclusive(struct device *dev, |
158 | const char *id); |
159 | struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev, |
160 | const char *id); |
161 | struct regulator *__must_check regulator_get_optional(struct device *dev, |
162 | const char *id); |
163 | struct regulator *__must_check devm_regulator_get_optional(struct device *dev, |
164 | const char *id); |
165 | int devm_regulator_get_enable(struct device *dev, const char *id); |
166 | int devm_regulator_get_enable_optional(struct device *dev, const char *id); |
167 | void regulator_put(struct regulator *regulator); |
168 | void devm_regulator_put(struct regulator *regulator); |
169 | |
170 | int regulator_register_supply_alias(struct device *dev, const char *id, |
171 | struct device *alias_dev, |
172 | const char *alias_id); |
173 | void regulator_unregister_supply_alias(struct device *dev, const char *id); |
174 | |
175 | int regulator_bulk_register_supply_alias(struct device *dev, |
176 | const char *const *id, |
177 | struct device *alias_dev, |
178 | const char *const *alias_id, |
179 | int num_id); |
180 | void regulator_bulk_unregister_supply_alias(struct device *dev, |
181 | const char * const *id, int num_id); |
182 | |
183 | int devm_regulator_register_supply_alias(struct device *dev, const char *id, |
184 | struct device *alias_dev, |
185 | const char *alias_id); |
186 | |
187 | int devm_regulator_bulk_register_supply_alias(struct device *dev, |
188 | const char *const *id, |
189 | struct device *alias_dev, |
190 | const char *const *alias_id, |
191 | int num_id); |
192 | |
193 | /* regulator output control and status */ |
194 | int __must_check regulator_enable(struct regulator *regulator); |
195 | int regulator_disable(struct regulator *regulator); |
196 | int regulator_force_disable(struct regulator *regulator); |
197 | int regulator_is_enabled(struct regulator *regulator); |
198 | int regulator_disable_deferred(struct regulator *regulator, int ms); |
199 | |
200 | int __must_check regulator_bulk_get(struct device *dev, int num_consumers, |
201 | struct regulator_bulk_data *consumers); |
202 | int __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np, |
203 | struct regulator_bulk_data **consumers); |
204 | int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers, |
205 | struct regulator_bulk_data *consumers); |
206 | void devm_regulator_bulk_put(struct regulator_bulk_data *consumers); |
207 | int __must_check devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers, |
208 | struct regulator_bulk_data *consumers); |
209 | int __must_check devm_regulator_bulk_get_const( |
210 | struct device *dev, int num_consumers, |
211 | const struct regulator_bulk_data *in_consumers, |
212 | struct regulator_bulk_data **out_consumers); |
213 | int __must_check regulator_bulk_enable(int num_consumers, |
214 | struct regulator_bulk_data *consumers); |
215 | int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, |
216 | const char * const *id); |
217 | int regulator_bulk_disable(int num_consumers, |
218 | struct regulator_bulk_data *consumers); |
219 | int regulator_bulk_force_disable(int num_consumers, |
220 | struct regulator_bulk_data *consumers); |
221 | void regulator_bulk_free(int num_consumers, |
222 | struct regulator_bulk_data *consumers); |
223 | |
224 | int regulator_count_voltages(struct regulator *regulator); |
225 | int regulator_list_voltage(struct regulator *regulator, unsigned selector); |
226 | int regulator_is_supported_voltage(struct regulator *regulator, |
227 | int min_uV, int max_uV); |
228 | unsigned int regulator_get_linear_step(struct regulator *regulator); |
229 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); |
230 | int regulator_set_voltage_time(struct regulator *regulator, |
231 | int old_uV, int new_uV); |
232 | int regulator_get_voltage(struct regulator *regulator); |
233 | int regulator_sync_voltage(struct regulator *regulator); |
234 | int regulator_set_current_limit(struct regulator *regulator, |
235 | int min_uA, int max_uA); |
236 | int regulator_get_current_limit(struct regulator *regulator); |
237 | |
238 | int regulator_set_mode(struct regulator *regulator, unsigned int mode); |
239 | unsigned int regulator_get_mode(struct regulator *regulator); |
240 | int regulator_get_error_flags(struct regulator *regulator, |
241 | unsigned int *flags); |
242 | int regulator_set_load(struct regulator *regulator, int load_uA); |
243 | |
244 | int regulator_allow_bypass(struct regulator *regulator, bool allow); |
245 | |
246 | struct regmap *regulator_get_regmap(struct regulator *regulator); |
247 | int regulator_get_hardware_vsel_register(struct regulator *regulator, |
248 | unsigned *vsel_reg, |
249 | unsigned *vsel_mask); |
250 | int regulator_list_hardware_vsel(struct regulator *regulator, |
251 | unsigned selector); |
252 | |
253 | /* regulator notifier block */ |
254 | int regulator_register_notifier(struct regulator *regulator, |
255 | struct notifier_block *nb); |
256 | int devm_regulator_register_notifier(struct regulator *regulator, |
257 | struct notifier_block *nb); |
258 | int regulator_unregister_notifier(struct regulator *regulator, |
259 | struct notifier_block *nb); |
260 | void devm_regulator_unregister_notifier(struct regulator *regulator, |
261 | struct notifier_block *nb); |
262 | |
263 | /* regulator suspend */ |
264 | int regulator_suspend_enable(struct regulator_dev *rdev, |
265 | suspend_state_t state); |
266 | int regulator_suspend_disable(struct regulator_dev *rdev, |
267 | suspend_state_t state); |
268 | int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV, |
269 | int max_uV, suspend_state_t state); |
270 | |
271 | /* driver data - core doesn't touch */ |
272 | void *regulator_get_drvdata(struct regulator *regulator); |
273 | void regulator_set_drvdata(struct regulator *regulator, void *data); |
274 | |
275 | /* misc helpers */ |
276 | |
277 | void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, |
278 | const char *const *supply_names, |
279 | unsigned int num_supplies); |
280 | |
281 | bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2); |
282 | |
283 | #else |
284 | |
285 | /* |
286 | * Make sure client drivers will still build on systems with no software |
287 | * controllable voltage or current regulators. |
288 | */ |
289 | static inline struct regulator *__must_check regulator_get(struct device *dev, |
290 | const char *id) |
291 | { |
292 | /* Nothing except the stubbed out regulator API should be |
293 | * looking at the value except to check if it is an error |
294 | * value. Drivers are free to handle NULL specifically by |
295 | * skipping all regulator API calls, but they don't have to. |
296 | * Drivers which don't, should make sure they properly handle |
297 | * corner cases of the API, such as regulator_get_voltage() |
298 | * returning 0. |
299 | */ |
300 | return NULL; |
301 | } |
302 | |
303 | static inline struct regulator *__must_check |
304 | devm_regulator_get(struct device *dev, const char *id) |
305 | { |
306 | return NULL; |
307 | } |
308 | |
309 | static inline struct regulator *__must_check |
310 | regulator_get_exclusive(struct device *dev, const char *id) |
311 | { |
312 | return ERR_PTR(-ENODEV); |
313 | } |
314 | |
315 | static inline struct regulator *__must_check |
316 | devm_regulator_get_exclusive(struct device *dev, const char *id) |
317 | { |
318 | return ERR_PTR(-ENODEV); |
319 | } |
320 | |
321 | static inline int devm_regulator_get_enable(struct device *dev, const char *id) |
322 | { |
323 | return -ENODEV; |
324 | } |
325 | |
326 | static inline int devm_regulator_get_enable_optional(struct device *dev, |
327 | const char *id) |
328 | { |
329 | return -ENODEV; |
330 | } |
331 | |
332 | static inline struct regulator *__must_check |
333 | regulator_get_optional(struct device *dev, const char *id) |
334 | { |
335 | return ERR_PTR(-ENODEV); |
336 | } |
337 | |
338 | |
339 | static inline struct regulator *__must_check |
340 | devm_regulator_get_optional(struct device *dev, const char *id) |
341 | { |
342 | return ERR_PTR(-ENODEV); |
343 | } |
344 | |
345 | static inline void regulator_put(struct regulator *regulator) |
346 | { |
347 | } |
348 | |
349 | static inline void devm_regulator_put(struct regulator *regulator) |
350 | { |
351 | } |
352 | |
353 | static inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers) |
354 | { |
355 | } |
356 | |
357 | static inline int regulator_register_supply_alias(struct device *dev, |
358 | const char *id, |
359 | struct device *alias_dev, |
360 | const char *alias_id) |
361 | { |
362 | return 0; |
363 | } |
364 | |
365 | static inline void regulator_unregister_supply_alias(struct device *dev, |
366 | const char *id) |
367 | { |
368 | } |
369 | |
370 | static inline int regulator_bulk_register_supply_alias(struct device *dev, |
371 | const char *const *id, |
372 | struct device *alias_dev, |
373 | const char * const *alias_id, |
374 | int num_id) |
375 | { |
376 | return 0; |
377 | } |
378 | |
379 | static inline void regulator_bulk_unregister_supply_alias(struct device *dev, |
380 | const char * const *id, |
381 | int num_id) |
382 | { |
383 | } |
384 | |
385 | static inline int devm_regulator_register_supply_alias(struct device *dev, |
386 | const char *id, |
387 | struct device *alias_dev, |
388 | const char *alias_id) |
389 | { |
390 | return 0; |
391 | } |
392 | |
393 | static inline int devm_regulator_bulk_register_supply_alias(struct device *dev, |
394 | const char *const *id, |
395 | struct device *alias_dev, |
396 | const char *const *alias_id, |
397 | int num_id) |
398 | { |
399 | return 0; |
400 | } |
401 | |
402 | static inline int regulator_enable(struct regulator *regulator) |
403 | { |
404 | return 0; |
405 | } |
406 | |
407 | static inline int regulator_disable(struct regulator *regulator) |
408 | { |
409 | return 0; |
410 | } |
411 | |
412 | static inline int regulator_force_disable(struct regulator *regulator) |
413 | { |
414 | return 0; |
415 | } |
416 | |
417 | static inline int regulator_disable_deferred(struct regulator *regulator, |
418 | int ms) |
419 | { |
420 | return 0; |
421 | } |
422 | |
423 | static inline int regulator_is_enabled(struct regulator *regulator) |
424 | { |
425 | return 1; |
426 | } |
427 | |
428 | static inline int regulator_bulk_get(struct device *dev, |
429 | int num_consumers, |
430 | struct regulator_bulk_data *consumers) |
431 | { |
432 | return 0; |
433 | } |
434 | |
435 | static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers, |
436 | struct regulator_bulk_data *consumers) |
437 | { |
438 | return 0; |
439 | } |
440 | |
441 | static inline int of_regulator_bulk_get_all(struct device *dev, struct device_node *np, |
442 | struct regulator_bulk_data **consumers) |
443 | { |
444 | return 0; |
445 | } |
446 | |
447 | static inline int regulator_bulk_enable(int num_consumers, |
448 | struct regulator_bulk_data *consumers) |
449 | { |
450 | return 0; |
451 | } |
452 | |
453 | static inline int devm_regulator_bulk_get_enable(struct device *dev, |
454 | int num_consumers, |
455 | const char * const *id) |
456 | { |
457 | return 0; |
458 | } |
459 | |
460 | static inline int regulator_bulk_disable(int num_consumers, |
461 | struct regulator_bulk_data *consumers) |
462 | { |
463 | return 0; |
464 | } |
465 | |
466 | static inline int regulator_bulk_force_disable(int num_consumers, |
467 | struct regulator_bulk_data *consumers) |
468 | { |
469 | return 0; |
470 | } |
471 | |
472 | static inline void regulator_bulk_free(int num_consumers, |
473 | struct regulator_bulk_data *consumers) |
474 | { |
475 | } |
476 | |
477 | static inline int regulator_set_voltage(struct regulator *regulator, |
478 | int min_uV, int max_uV) |
479 | { |
480 | return 0; |
481 | } |
482 | |
483 | static inline int regulator_set_voltage_time(struct regulator *regulator, |
484 | int old_uV, int new_uV) |
485 | { |
486 | return 0; |
487 | } |
488 | |
489 | static inline int regulator_get_voltage(struct regulator *regulator) |
490 | { |
491 | return -EINVAL; |
492 | } |
493 | |
494 | static inline int regulator_sync_voltage(struct regulator *regulator) |
495 | { |
496 | return -EINVAL; |
497 | } |
498 | |
499 | static inline int regulator_is_supported_voltage(struct regulator *regulator, |
500 | int min_uV, int max_uV) |
501 | { |
502 | return 0; |
503 | } |
504 | |
505 | static inline unsigned int regulator_get_linear_step(struct regulator *regulator) |
506 | { |
507 | return 0; |
508 | } |
509 | |
510 | static inline int regulator_set_current_limit(struct regulator *regulator, |
511 | int min_uA, int max_uA) |
512 | { |
513 | return 0; |
514 | } |
515 | |
516 | static inline int regulator_get_current_limit(struct regulator *regulator) |
517 | { |
518 | return 0; |
519 | } |
520 | |
521 | static inline int regulator_set_mode(struct regulator *regulator, |
522 | unsigned int mode) |
523 | { |
524 | return 0; |
525 | } |
526 | |
527 | static inline unsigned int regulator_get_mode(struct regulator *regulator) |
528 | { |
529 | return REGULATOR_MODE_NORMAL; |
530 | } |
531 | |
532 | static inline int regulator_get_error_flags(struct regulator *regulator, |
533 | unsigned int *flags) |
534 | { |
535 | return -EINVAL; |
536 | } |
537 | |
538 | static inline int regulator_set_load(struct regulator *regulator, int load_uA) |
539 | { |
540 | return 0; |
541 | } |
542 | |
543 | static inline int regulator_allow_bypass(struct regulator *regulator, |
544 | bool allow) |
545 | { |
546 | return 0; |
547 | } |
548 | |
549 | static inline struct regmap *regulator_get_regmap(struct regulator *regulator) |
550 | { |
551 | return ERR_PTR(-EOPNOTSUPP); |
552 | } |
553 | |
554 | static inline int regulator_get_hardware_vsel_register(struct regulator *regulator, |
555 | unsigned *vsel_reg, |
556 | unsigned *vsel_mask) |
557 | { |
558 | return -EOPNOTSUPP; |
559 | } |
560 | |
561 | static inline int regulator_list_hardware_vsel(struct regulator *regulator, |
562 | unsigned selector) |
563 | { |
564 | return -EOPNOTSUPP; |
565 | } |
566 | |
567 | static inline int regulator_register_notifier(struct regulator *regulator, |
568 | struct notifier_block *nb) |
569 | { |
570 | return 0; |
571 | } |
572 | |
573 | static inline int devm_regulator_register_notifier(struct regulator *regulator, |
574 | struct notifier_block *nb) |
575 | { |
576 | return 0; |
577 | } |
578 | |
579 | static inline int regulator_unregister_notifier(struct regulator *regulator, |
580 | struct notifier_block *nb) |
581 | { |
582 | return 0; |
583 | } |
584 | |
585 | static inline int devm_regulator_unregister_notifier(struct regulator *regulator, |
586 | struct notifier_block *nb) |
587 | { |
588 | return 0; |
589 | } |
590 | |
591 | static inline int regulator_suspend_enable(struct regulator_dev *rdev, |
592 | suspend_state_t state) |
593 | { |
594 | return -EINVAL; |
595 | } |
596 | |
597 | static inline int regulator_suspend_disable(struct regulator_dev *rdev, |
598 | suspend_state_t state) |
599 | { |
600 | return -EINVAL; |
601 | } |
602 | |
603 | static 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 | |
610 | static inline void *regulator_get_drvdata(struct regulator *regulator) |
611 | { |
612 | return NULL; |
613 | } |
614 | |
615 | static inline void regulator_set_drvdata(struct regulator *regulator, |
616 | void *data) |
617 | { |
618 | } |
619 | |
620 | static inline int regulator_count_voltages(struct regulator *regulator) |
621 | { |
622 | return 0; |
623 | } |
624 | |
625 | static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector) |
626 | { |
627 | return -EINVAL; |
628 | } |
629 | |
630 | static inline void |
631 | regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, |
632 | const char *const *supply_names, |
633 | unsigned int num_supplies) |
634 | { |
635 | } |
636 | |
637 | static inline bool |
638 | regulator_is_equal(struct regulator *reg1, struct regulator *reg2) |
639 | { |
640 | return false; |
641 | } |
642 | #endif |
643 | |
644 | static 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, min_uV: target_uV, max_uV) == 0) |
649 | return 0; |
650 | |
651 | return regulator_set_voltage(regulator, min_uV, max_uV); |
652 | } |
653 | |
654 | static inline int regulator_set_voltage_tol(struct regulator *regulator, |
655 | int new_uV, int tol_uV) |
656 | { |
657 | if (regulator_set_voltage(regulator, min_uV: new_uV, max_uV: new_uV + tol_uV) == 0) |
658 | return 0; |
659 | else |
660 | return regulator_set_voltage(regulator, |
661 | min_uV: new_uV - tol_uV, max_uV: new_uV + tol_uV); |
662 | } |
663 | |
664 | static 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 | min_uV: target_uV - tol_uV, |
669 | max_uV: target_uV + tol_uV); |
670 | } |
671 | |
672 | #endif |
673 | |