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 devm_regulator_bulk_get(struct device *dev, int num_consumers,
248 					 struct regulator_bulk_data *consumers);
249 void devm_regulator_bulk_put(struct regulator_bulk_data *consumers);
250 int __must_check devm_regulator_bulk_get_const(
251 	struct device *dev, int num_consumers,
252 	const struct regulator_bulk_data *in_consumers,
253 	struct regulator_bulk_data **out_consumers);
254 int __must_check regulator_bulk_enable(int num_consumers,
255 				       struct regulator_bulk_data *consumers);
256 int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers,
257 				   const char * const *id);
258 int regulator_bulk_disable(int num_consumers,
259 			   struct regulator_bulk_data *consumers);
260 int regulator_bulk_force_disable(int num_consumers,
261 			   struct regulator_bulk_data *consumers);
262 void regulator_bulk_free(int num_consumers,
263 			 struct regulator_bulk_data *consumers);
264 
265 int regulator_count_voltages(struct regulator *regulator);
266 int regulator_list_voltage(struct regulator *regulator, unsigned selector);
267 int regulator_is_supported_voltage(struct regulator *regulator,
268 				   int min_uV, int max_uV);
269 unsigned int regulator_get_linear_step(struct regulator *regulator);
270 int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
271 int regulator_set_voltage_time(struct regulator *regulator,
272 			       int old_uV, int new_uV);
273 int regulator_get_voltage(struct regulator *regulator);
274 int regulator_sync_voltage(struct regulator *regulator);
275 int regulator_set_current_limit(struct regulator *regulator,
276 			       int min_uA, int max_uA);
277 int regulator_get_current_limit(struct regulator *regulator);
278 
279 int regulator_set_mode(struct regulator *regulator, unsigned int mode);
280 unsigned int regulator_get_mode(struct regulator *regulator);
281 int regulator_get_error_flags(struct regulator *regulator,
282 				unsigned int *flags);
283 int regulator_set_load(struct regulator *regulator, int load_uA);
284 
285 int regulator_allow_bypass(struct regulator *regulator, bool allow);
286 
287 struct regmap *regulator_get_regmap(struct regulator *regulator);
288 int regulator_get_hardware_vsel_register(struct regulator *regulator,
289 					 unsigned *vsel_reg,
290 					 unsigned *vsel_mask);
291 int regulator_list_hardware_vsel(struct regulator *regulator,
292 				 unsigned selector);
293 
294 /* regulator notifier block */
295 int regulator_register_notifier(struct regulator *regulator,
296 			      struct notifier_block *nb);
297 int devm_regulator_register_notifier(struct regulator *regulator,
298 				     struct notifier_block *nb);
299 int regulator_unregister_notifier(struct regulator *regulator,
300 				struct notifier_block *nb);
301 void devm_regulator_unregister_notifier(struct regulator *regulator,
302 					struct notifier_block *nb);
303 
304 /* regulator suspend */
305 int regulator_suspend_enable(struct regulator_dev *rdev,
306 			     suspend_state_t state);
307 int regulator_suspend_disable(struct regulator_dev *rdev,
308 			      suspend_state_t state);
309 int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV,
310 				  int max_uV, suspend_state_t state);
311 
312 /* driver data - core doesn't touch */
313 void *regulator_get_drvdata(struct regulator *regulator);
314 void regulator_set_drvdata(struct regulator *regulator, void *data);
315 
316 /* misc helpers */
317 
318 void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
319 				     const char *const *supply_names,
320 				     unsigned int num_supplies);
321 
322 bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2);
323 
324 #else
325 
326 /*
327  * Make sure client drivers will still build on systems with no software
328  * controllable voltage or current regulators.
329  */
regulator_get(struct device * dev,const char * id)330 static inline struct regulator *__must_check regulator_get(struct device *dev,
331 	const char *id)
332 {
333 	/* Nothing except the stubbed out regulator API should be
334 	 * looking at the value except to check if it is an error
335 	 * value. Drivers are free to handle NULL specifically by
336 	 * skipping all regulator API calls, but they don't have to.
337 	 * Drivers which don't, should make sure they properly handle
338 	 * corner cases of the API, such as regulator_get_voltage()
339 	 * returning 0.
340 	 */
341 	return NULL;
342 }
343 
344 static inline struct regulator *__must_check
devm_regulator_get(struct device * dev,const char * id)345 devm_regulator_get(struct device *dev, const char *id)
346 {
347 	return NULL;
348 }
349 
350 static inline struct regulator *__must_check
regulator_get_exclusive(struct device * dev,const char * id)351 regulator_get_exclusive(struct device *dev, const char *id)
352 {
353 	return ERR_PTR(-ENODEV);
354 }
355 
356 static inline struct regulator *__must_check
devm_regulator_get_exclusive(struct device * dev,const char * id)357 devm_regulator_get_exclusive(struct device *dev, const char *id)
358 {
359 	return ERR_PTR(-ENODEV);
360 }
361 
devm_regulator_get_enable(struct device * dev,const char * id)362 static inline int devm_regulator_get_enable(struct device *dev, const char *id)
363 {
364 	return -ENODEV;
365 }
366 
devm_regulator_get_enable_optional(struct device * dev,const char * id)367 static inline int devm_regulator_get_enable_optional(struct device *dev,
368 						     const char *id)
369 {
370 	return -ENODEV;
371 }
372 
373 static inline struct regulator *__must_check
regulator_get_optional(struct device * dev,const char * id)374 regulator_get_optional(struct device *dev, const char *id)
375 {
376 	return ERR_PTR(-ENODEV);
377 }
378 
379 
380 static inline struct regulator *__must_check
devm_regulator_get_optional(struct device * dev,const char * id)381 devm_regulator_get_optional(struct device *dev, const char *id)
382 {
383 	return ERR_PTR(-ENODEV);
384 }
385 
regulator_put(struct regulator * regulator)386 static inline void regulator_put(struct regulator *regulator)
387 {
388 }
389 
devm_regulator_put(struct regulator * regulator)390 static inline void devm_regulator_put(struct regulator *regulator)
391 {
392 }
393 
devm_regulator_bulk_put(struct regulator_bulk_data * consumers)394 static inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers)
395 {
396 }
397 
regulator_register_supply_alias(struct device * dev,const char * id,struct device * alias_dev,const char * alias_id)398 static inline int 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 
regulator_unregister_supply_alias(struct device * dev,const char * id)406 static inline void regulator_unregister_supply_alias(struct device *dev,
407 						    const char *id)
408 {
409 }
410 
regulator_bulk_register_supply_alias(struct device * dev,const char * const * id,struct device * alias_dev,const char * const * alias_id,int num_id)411 static inline int regulator_bulk_register_supply_alias(struct device *dev,
412 						const char *const *id,
413 						struct device *alias_dev,
414 						const char * const *alias_id,
415 						int num_id)
416 {
417 	return 0;
418 }
419 
regulator_bulk_unregister_supply_alias(struct device * dev,const char * const * id,int num_id)420 static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
421 						const char * const *id,
422 						int num_id)
423 {
424 }
425 
devm_regulator_register_supply_alias(struct device * dev,const char * id,struct device * alias_dev,const char * alias_id)426 static inline int devm_regulator_register_supply_alias(struct device *dev,
427 						       const char *id,
428 						       struct device *alias_dev,
429 						       const char *alias_id)
430 {
431 	return 0;
432 }
433 
devm_regulator_bulk_register_supply_alias(struct device * dev,const char * const * id,struct device * alias_dev,const char * const * alias_id,int num_id)434 static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
435 						const char *const *id,
436 						struct device *alias_dev,
437 						const char *const *alias_id,
438 						int num_id)
439 {
440 	return 0;
441 }
442 
regulator_enable(struct regulator * regulator)443 static inline int regulator_enable(struct regulator *regulator)
444 {
445 	return 0;
446 }
447 
regulator_disable(struct regulator * regulator)448 static inline int regulator_disable(struct regulator *regulator)
449 {
450 	return 0;
451 }
452 
regulator_force_disable(struct regulator * regulator)453 static inline int regulator_force_disable(struct regulator *regulator)
454 {
455 	return 0;
456 }
457 
regulator_disable_deferred(struct regulator * regulator,int ms)458 static inline int regulator_disable_deferred(struct regulator *regulator,
459 					     int ms)
460 {
461 	return 0;
462 }
463 
regulator_is_enabled(struct regulator * regulator)464 static inline int regulator_is_enabled(struct regulator *regulator)
465 {
466 	return 1;
467 }
468 
regulator_bulk_get(struct device * dev,int num_consumers,struct regulator_bulk_data * consumers)469 static inline int regulator_bulk_get(struct device *dev,
470 				     int num_consumers,
471 				     struct regulator_bulk_data *consumers)
472 {
473 	return 0;
474 }
475 
devm_regulator_bulk_get(struct device * dev,int num_consumers,struct regulator_bulk_data * consumers)476 static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
477 					  struct regulator_bulk_data *consumers)
478 {
479 	return 0;
480 }
481 
regulator_bulk_enable(int num_consumers,struct regulator_bulk_data * consumers)482 static inline int regulator_bulk_enable(int num_consumers,
483 					struct regulator_bulk_data *consumers)
484 {
485 	return 0;
486 }
487 
devm_regulator_bulk_get_enable(struct device * dev,int num_consumers,const char * const * id)488 static inline int devm_regulator_bulk_get_enable(struct device *dev,
489 						 int num_consumers,
490 						 const char * const *id)
491 {
492 	return 0;
493 }
494 
regulator_bulk_disable(int num_consumers,struct regulator_bulk_data * consumers)495 static inline int regulator_bulk_disable(int num_consumers,
496 					 struct regulator_bulk_data *consumers)
497 {
498 	return 0;
499 }
500 
regulator_bulk_force_disable(int num_consumers,struct regulator_bulk_data * consumers)501 static inline int regulator_bulk_force_disable(int num_consumers,
502 					struct regulator_bulk_data *consumers)
503 {
504 	return 0;
505 }
506 
regulator_bulk_free(int num_consumers,struct regulator_bulk_data * consumers)507 static inline void regulator_bulk_free(int num_consumers,
508 				       struct regulator_bulk_data *consumers)
509 {
510 }
511 
regulator_set_voltage(struct regulator * regulator,int min_uV,int max_uV)512 static inline int regulator_set_voltage(struct regulator *regulator,
513 					int min_uV, int max_uV)
514 {
515 	return 0;
516 }
517 
regulator_set_voltage_time(struct regulator * regulator,int old_uV,int new_uV)518 static inline int regulator_set_voltage_time(struct regulator *regulator,
519 					     int old_uV, int new_uV)
520 {
521 	return 0;
522 }
523 
regulator_get_voltage(struct regulator * regulator)524 static inline int regulator_get_voltage(struct regulator *regulator)
525 {
526 	return -EINVAL;
527 }
528 
regulator_sync_voltage(struct regulator * regulator)529 static inline int regulator_sync_voltage(struct regulator *regulator)
530 {
531 	return -EINVAL;
532 }
533 
regulator_is_supported_voltage(struct regulator * regulator,int min_uV,int max_uV)534 static inline int regulator_is_supported_voltage(struct regulator *regulator,
535 				   int min_uV, int max_uV)
536 {
537 	return 0;
538 }
539 
regulator_get_linear_step(struct regulator * regulator)540 static inline unsigned int regulator_get_linear_step(struct regulator *regulator)
541 {
542 	return 0;
543 }
544 
regulator_set_current_limit(struct regulator * regulator,int min_uA,int max_uA)545 static inline int regulator_set_current_limit(struct regulator *regulator,
546 					     int min_uA, int max_uA)
547 {
548 	return 0;
549 }
550 
regulator_get_current_limit(struct regulator * regulator)551 static inline int regulator_get_current_limit(struct regulator *regulator)
552 {
553 	return 0;
554 }
555 
regulator_set_mode(struct regulator * regulator,unsigned int mode)556 static inline int regulator_set_mode(struct regulator *regulator,
557 	unsigned int mode)
558 {
559 	return 0;
560 }
561 
regulator_get_mode(struct regulator * regulator)562 static inline unsigned int regulator_get_mode(struct regulator *regulator)
563 {
564 	return REGULATOR_MODE_NORMAL;
565 }
566 
regulator_get_error_flags(struct regulator * regulator,unsigned int * flags)567 static inline int regulator_get_error_flags(struct regulator *regulator,
568 					    unsigned int *flags)
569 {
570 	return -EINVAL;
571 }
572 
regulator_set_load(struct regulator * regulator,int load_uA)573 static inline int regulator_set_load(struct regulator *regulator, int load_uA)
574 {
575 	return 0;
576 }
577 
regulator_allow_bypass(struct regulator * regulator,bool allow)578 static inline int regulator_allow_bypass(struct regulator *regulator,
579 					 bool allow)
580 {
581 	return 0;
582 }
583 
regulator_get_regmap(struct regulator * regulator)584 static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
585 {
586 	return ERR_PTR(-EOPNOTSUPP);
587 }
588 
regulator_get_hardware_vsel_register(struct regulator * regulator,unsigned * vsel_reg,unsigned * vsel_mask)589 static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
590 						       unsigned *vsel_reg,
591 						       unsigned *vsel_mask)
592 {
593 	return -EOPNOTSUPP;
594 }
595 
regulator_list_hardware_vsel(struct regulator * regulator,unsigned selector)596 static inline int regulator_list_hardware_vsel(struct regulator *regulator,
597 					       unsigned selector)
598 {
599 	return -EOPNOTSUPP;
600 }
601 
regulator_register_notifier(struct regulator * regulator,struct notifier_block * nb)602 static inline int regulator_register_notifier(struct regulator *regulator,
603 			      struct notifier_block *nb)
604 {
605 	return 0;
606 }
607 
devm_regulator_register_notifier(struct regulator * regulator,struct notifier_block * nb)608 static inline int devm_regulator_register_notifier(struct regulator *regulator,
609 						   struct notifier_block *nb)
610 {
611 	return 0;
612 }
613 
regulator_unregister_notifier(struct regulator * regulator,struct notifier_block * nb)614 static inline int regulator_unregister_notifier(struct regulator *regulator,
615 				struct notifier_block *nb)
616 {
617 	return 0;
618 }
619 
devm_regulator_unregister_notifier(struct regulator * regulator,struct notifier_block * nb)620 static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
621 						     struct notifier_block *nb)
622 {
623 	return 0;
624 }
625 
regulator_suspend_enable(struct regulator_dev * rdev,suspend_state_t state)626 static inline int regulator_suspend_enable(struct regulator_dev *rdev,
627 					   suspend_state_t state)
628 {
629 	return -EINVAL;
630 }
631 
regulator_suspend_disable(struct regulator_dev * rdev,suspend_state_t state)632 static inline int regulator_suspend_disable(struct regulator_dev *rdev,
633 					    suspend_state_t state)
634 {
635 	return -EINVAL;
636 }
637 
regulator_set_suspend_voltage(struct regulator * regulator,int min_uV,int max_uV,suspend_state_t state)638 static inline int regulator_set_suspend_voltage(struct regulator *regulator,
639 						int min_uV, int max_uV,
640 						suspend_state_t state)
641 {
642 	return -EINVAL;
643 }
644 
regulator_get_drvdata(struct regulator * regulator)645 static inline void *regulator_get_drvdata(struct regulator *regulator)
646 {
647 	return NULL;
648 }
649 
regulator_set_drvdata(struct regulator * regulator,void * data)650 static inline void regulator_set_drvdata(struct regulator *regulator,
651 	void *data)
652 {
653 }
654 
regulator_count_voltages(struct regulator * regulator)655 static inline int regulator_count_voltages(struct regulator *regulator)
656 {
657 	return 0;
658 }
659 
regulator_list_voltage(struct regulator * regulator,unsigned selector)660 static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
661 {
662 	return -EINVAL;
663 }
664 
665 static inline void
regulator_bulk_set_supply_names(struct regulator_bulk_data * consumers,const char * const * supply_names,unsigned int num_supplies)666 regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
667 				const char *const *supply_names,
668 				unsigned int num_supplies)
669 {
670 }
671 
672 static inline bool
regulator_is_equal(struct regulator * reg1,struct regulator * reg2)673 regulator_is_equal(struct regulator *reg1, struct regulator *reg2)
674 {
675 	return false;
676 }
677 #endif
678 
regulator_set_voltage_triplet(struct regulator * regulator,int min_uV,int target_uV,int max_uV)679 static inline int regulator_set_voltage_triplet(struct regulator *regulator,
680 						int min_uV, int target_uV,
681 						int max_uV)
682 {
683 	if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
684 		return 0;
685 
686 	return regulator_set_voltage(regulator, min_uV, max_uV);
687 }
688 
regulator_set_voltage_tol(struct regulator * regulator,int new_uV,int tol_uV)689 static inline int regulator_set_voltage_tol(struct regulator *regulator,
690 					    int new_uV, int tol_uV)
691 {
692 	if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
693 		return 0;
694 	else
695 		return regulator_set_voltage(regulator,
696 					     new_uV - tol_uV, new_uV + tol_uV);
697 }
698 
regulator_is_supported_voltage_tol(struct regulator * regulator,int target_uV,int tol_uV)699 static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
700 						     int target_uV, int tol_uV)
701 {
702 	return regulator_is_supported_voltage(regulator,
703 					      target_uV - tol_uV,
704 					      target_uV + tol_uV);
705 }
706 
707 #endif
708