]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | |
2 | /* | |
3 | * Copyright (C) 2014-2015 Samsung Electronics | |
4 | * Przemyslaw Marczak <[email protected]> | |
5 | */ | |
6 | ||
7 | #ifndef _INCLUDE_REGULATOR_H_ | |
8 | #define _INCLUDE_REGULATOR_H_ | |
9 | ||
10 | struct udevice; | |
11 | ||
12 | /** | |
13 | * U-Boot Voltage/Current Regulator | |
14 | * ================================ | |
15 | * | |
16 | * The regulator API is based on a driver model, with the device tree support. | |
17 | * And this header describes the functions and data types for the uclass id: | |
18 | * 'UCLASS_REGULATOR' and the regulator driver API. | |
19 | * | |
20 | * The regulator uclass - is based on uclass platform data which is allocated, | |
21 | * automatically for each regulator device on bind and 'dev->uclass_plat' | |
22 | * points to it. The data type is: 'struct dm_regulator_uclass_plat'. | |
23 | * The uclass file: 'drivers/power/regulator/regulator-uclass.c' | |
24 | * | |
25 | * The regulator device - is based on driver's model 'struct udevice'. | |
26 | * The API can use regulator name in two meanings: | |
27 | * - devname - the regulator device's name: 'dev->name' | |
28 | * - platname - the device's plat's name. So in the code it looks like: | |
29 | * 'uc_pdata = dev->uclass_plat'; 'name = uc_pdata->name'. | |
30 | * | |
31 | * The regulator device driver - provide an implementation of uclass operations | |
32 | * pointed by 'dev->driver->ops' as a struct of type 'struct dm_regulator_ops'. | |
33 | * | |
34 | * To proper bind the regulator device, the device tree node should provide | |
35 | * regulator constraints, like in the example below: | |
36 | * | |
37 | * ldo1 { | |
38 | * regulator-name = "VDD_MMC_1.8V"; (must be unique for proper bind) | |
39 | * regulator-min-microvolt = <1000000>; (optional) | |
40 | * regulator-max-microvolt = <1000000>; (optional) | |
41 | * regulator-min-microamp = <1000>; (optional) | |
42 | * regulator-max-microamp = <1000>; (optional) | |
43 | * regulator-always-on; (optional) | |
44 | * regulator-boot-on; (optional) | |
45 | * }; | |
46 | * | |
47 | * Note: For the proper operation, at least name constraint is needed, since | |
48 | * it can be used when calling regulator_get_by_platname(). And the mandatory | |
49 | * rule for this name is, that it must be globally unique for the single dts. | |
50 | * If regulator-name property is not provided, node name will be chosen. | |
51 | * | |
52 | * Regulator bind: | |
53 | * For each regulator device, the device_bind() should be called with passed | |
54 | * device tree offset. This is required for this uclass's '.post_bind' method, | |
55 | * which does the scan on the device node, for the 'regulator-name' constraint. | |
56 | * If the parent is not a PMIC device, and the child is not bind by function: | |
57 | * 'pmic_bind_childs()', then it's recommended to bind the device by call to | |
58 | * dm_scan_fdt_dev() - this is usually done automatically for bus devices, | |
59 | * as a post bind method. | |
60 | * | |
61 | * Regulator get: | |
62 | * Having the device's name constraint, we can call regulator_by_platname(), | |
63 | * to find the required regulator. Before return, the regulator is probed, | |
64 | * and the rest of its constraints are put into the device's uclass platform | |
65 | * data, by the uclass regulator '.pre_probe' method. | |
66 | * | |
67 | * For more info about PMIC bind, please refer to file: 'include/power/pmic.h' | |
68 | * | |
69 | * Note: | |
70 | * Please do not use the device_bind_by_name() function, since it pass '-1' as | |
71 | * device node offset - and the bind will fail on uclass .post_bind method, | |
72 | * because of missing 'regulator-name' constraint. | |
73 | * | |
74 | * | |
75 | * Fixed Voltage/Current Regulator | |
76 | * =============================== | |
77 | * | |
78 | * When fixed voltage regulator is needed, then enable the config: | |
79 | * - CONFIG_DM_REGULATOR_FIXED | |
80 | * | |
81 | * The driver file: 'drivers/power/regulator/fixed.c', provides basic support | |
82 | * for control the GPIO, and return the device tree constraint values. | |
83 | * | |
84 | * To bind the fixed voltage regulator device, we usually use a 'simple-bus' | |
85 | * node as a parent. And 'regulator-fixed' for the driver compatible. This is | |
86 | * the same as in the kernel. The example node of fixed regulator: | |
87 | * | |
88 | * simple-bus { | |
89 | * compatible = "simple-bus"; | |
90 | * #address-cells = <1>; | |
91 | * #size-cells = <0>; | |
92 | * | |
93 | * blue_led { | |
94 | * compatible = "regulator-fixed"; | |
95 | * regulator-name = "VDD_LED_3.3V"; | |
96 | * regulator-min-microvolt = <3300000>; | |
97 | * regulator-max-microvolt = <3300000>; | |
98 | * gpio = <&gpc1 0 GPIO_ACTIVE_LOW>; | |
99 | * }; | |
100 | * }; | |
101 | * | |
102 | * The fixed regulator devices also provide regulator uclass platform data. And | |
103 | * devices bound from such node, can use the regulator drivers API. | |
104 | */ | |
105 | ||
106 | /* enum regulator_type - used for regulator_*() variant calls */ | |
107 | enum regulator_type { | |
108 | REGULATOR_TYPE_LDO = 0, | |
109 | REGULATOR_TYPE_BUCK, | |
110 | REGULATOR_TYPE_DVS, | |
111 | REGULATOR_TYPE_FIXED, | |
112 | REGULATOR_TYPE_GPIO, | |
113 | REGULATOR_TYPE_OTHER, | |
114 | }; | |
115 | ||
116 | /** | |
117 | * struct dm_regulator_mode - this structure holds an information about | |
118 | * each regulator operation mode. Probably in most cases - an array. | |
119 | * This will be probably a driver-static data, since it is device-specific. | |
120 | * | |
121 | * @id - a driver-specific mode id | |
122 | * @register_value - a driver-specific value for its mode id | |
123 | * @name - the name of mode - used for regulator command | |
124 | * Note: | |
125 | * The field 'id', should be always a positive number, since the negative values | |
126 | * are reserved for the errno numbers when returns the mode id. | |
127 | */ | |
128 | struct dm_regulator_mode { | |
129 | int id; /* Set only as >= 0 (negative value is reserved for errno) */ | |
130 | int register_value; | |
131 | const char *name; | |
132 | }; | |
133 | ||
134 | enum regulator_flag { | |
135 | REGULATOR_FLAG_AUTOSET_UV = 1 << 0, | |
136 | REGULATOR_FLAG_AUTOSET_UA = 1 << 1, | |
137 | REGULATOR_FLAG_AUTOSET_DONE = 1 << 2, | |
138 | }; | |
139 | ||
140 | /** | |
141 | * struct dm_regulator_uclass_plat - pointed by dev->uclass_plat, and | |
142 | * allocated on each regulator bind. This structure holds an information | |
143 | * about each regulator's constraints and supported operation modes. | |
144 | * There is no "step" voltage value - so driver should take care of this. | |
145 | * | |
146 | * @type - one of 'enum regulator_type' | |
147 | * @mode - pointer to the regulator mode (array if more than one) | |
148 | * @mode_count - number of '.mode' entries | |
149 | * @min_uV* - minimum voltage (micro Volts) | |
150 | * @max_uV* - maximum voltage (micro Volts) | |
151 | * @min_uA* - minimum amperage (micro Amps) | |
152 | * @max_uA* - maximum amperage (micro Amps) | |
153 | * @always_on* - bool type, true or false | |
154 | * @boot_on* - bool type, true or false | |
155 | * @force_off* - bool type, true or false | |
156 | * TODO([email protected]): Consider putting the above two into @flags | |
157 | * @ramp_delay - Time to settle down after voltage change (unit: uV/us) | |
158 | * @flags: - flags value (see REGULATOR_FLAG_...) | |
159 | * @name** - fdt regulator name - should be taken from the device tree | |
160 | * ctrl_reg: - Control register offset used to enable/disable regulator | |
161 | * volt_reg: - register offset for writing voltage vsel values | |
162 | * | |
163 | * Note: | |
164 | * * - set automatically on device probe by the uclass's '.pre_probe' method. | |
165 | * ** - set automatically on device bind by the uclass's '.post_bind' method. | |
166 | * The constraints: type, mode, mode_count, can be set by device driver, e.g. | |
167 | * by the driver '.probe' method. | |
168 | */ | |
169 | struct dm_regulator_uclass_plat { | |
170 | enum regulator_type type; | |
171 | struct dm_regulator_mode *mode; | |
172 | int mode_count; | |
173 | int min_uV; | |
174 | int max_uV; | |
175 | int init_uV; | |
176 | int min_uA; | |
177 | int max_uA; | |
178 | unsigned int ramp_delay; | |
179 | bool always_on; | |
180 | bool boot_on; | |
181 | bool force_off; | |
182 | const char *name; | |
183 | int flags; | |
184 | u8 ctrl_reg; | |
185 | u8 volt_reg; | |
186 | bool suspend_on; | |
187 | u32 suspend_uV; | |
188 | }; | |
189 | ||
190 | /* Regulator device operations */ | |
191 | struct dm_regulator_ops { | |
192 | /** | |
193 | * The regulator output value function calls operates on a micro Volts. | |
194 | * | |
195 | * get/set_value - get/set output value of the given output number | |
196 | * @dev - regulator device | |
197 | * Sets: | |
198 | * @uV - set the output value [micro Volts] | |
199 | * @return output value [uV] on success or negative errno if fail. | |
200 | */ | |
201 | int (*get_value)(struct udevice *dev); | |
202 | int (*set_value)(struct udevice *dev, int uV); | |
203 | ||
204 | /** | |
205 | * The regulator suspend output value function calls operates | |
206 | * on a micro Volts. | |
207 | * | |
208 | * get/set_suspen_value - get/set suspend mode output value | |
209 | * @dev - regulator device | |
210 | * Sets: | |
211 | * @uV - set the suspend output value [micro Volts] | |
212 | * @return output value [uV] on success or negative errno if fail. | |
213 | */ | |
214 | int (*set_suspend_value)(struct udevice *dev, int uV); | |
215 | int (*get_suspend_value)(struct udevice *dev); | |
216 | ||
217 | /** | |
218 | * The regulator output current function calls operates on a micro Amps. | |
219 | * | |
220 | * get/set_current - get/set output current of the given output number | |
221 | * @dev - regulator device | |
222 | * Sets: | |
223 | * @uA - set the output current [micro Amps] | |
224 | * @return output value [uA] on success or negative errno if fail. | |
225 | */ | |
226 | int (*get_current)(struct udevice *dev); | |
227 | int (*set_current)(struct udevice *dev, int uA); | |
228 | ||
229 | /** | |
230 | * The most basic feature of the regulator output is its enable state. | |
231 | * | |
232 | * get/set_enable - get/set enable state of the given output number | |
233 | * @dev - regulator device | |
234 | * Sets: | |
235 | * @enable - set true - enable or false - disable | |
236 | * @return true/false for get or -errno if fail; 0 / -errno for set. | |
237 | */ | |
238 | int (*get_enable)(struct udevice *dev); | |
239 | int (*set_enable)(struct udevice *dev, bool enable); | |
240 | ||
241 | /** | |
242 | * The most basic feature of the regulator output is its enable state | |
243 | * in suspend mode. | |
244 | * | |
245 | * get/set_suspend_enable - get/set enable state of the suspend output | |
246 | * @dev - regulator device | |
247 | * Sets: | |
248 | * @enable - set true - enable or false - disable | |
249 | * @return true/false for get or -errno if fail; 0 / -errno for set. | |
250 | */ | |
251 | int (*set_suspend_enable)(struct udevice *dev, bool enable); | |
252 | int (*get_suspend_enable)(struct udevice *dev); | |
253 | ||
254 | /** | |
255 | * The 'get/set_mode()' function calls should operate on a driver- | |
256 | * specific mode id definitions, which should be found in: | |
257 | * field 'id' of struct dm_regulator_mode. | |
258 | * | |
259 | * get/set_mode - get/set operation mode of the given output number | |
260 | * @dev - regulator device | |
261 | * Sets | |
262 | * @mode_id - set output mode id (struct dm_regulator_mode->id) | |
263 | * @return id/0 for get/set on success or negative errno if fail. | |
264 | * Note: | |
265 | * The field 'id' of struct type 'dm_regulator_mode', should be always | |
266 | * a positive number, since the negative is reserved for the error. | |
267 | */ | |
268 | int (*get_mode)(struct udevice *dev); | |
269 | int (*set_mode)(struct udevice *dev, int mode_id); | |
270 | }; | |
271 | ||
272 | #if CONFIG_IS_ENABLED(DM_REGULATOR) | |
273 | /** | |
274 | * regulator_mode: returns a pointer to the array of regulator mode info | |
275 | * | |
276 | * @dev - pointer to the regulator device | |
277 | * @modep - pointer to the returned mode info array | |
278 | * Return: - count of modep entries on success or negative errno if fail. | |
279 | */ | |
280 | int regulator_mode(struct udevice *dev, struct dm_regulator_mode **modep); | |
281 | ||
282 | /** | |
283 | * regulator_get_value: get microvoltage voltage value of a given regulator | |
284 | * | |
285 | * @dev - pointer to the regulator device | |
286 | * Return: - positive output value [uV] on success or negative errno if fail. | |
287 | */ | |
288 | int regulator_get_value(struct udevice *dev); | |
289 | ||
290 | /** | |
291 | * regulator_set_value: set the microvoltage value of a given regulator. | |
292 | * | |
293 | * @dev - pointer to the regulator device | |
294 | * @uV - the output value to set [micro Volts] | |
295 | * Return: - 0 on success or -errno val if fails | |
296 | */ | |
297 | int regulator_set_value(struct udevice *dev, int uV); | |
298 | ||
299 | /** | |
300 | * regulator_set_suspend_value: set the suspend microvoltage value of a given regulator. | |
301 | * | |
302 | * @dev - pointer to the regulator device | |
303 | * @uV - the output suspend value to set [micro Volts] | |
304 | * Return: - 0 on success or -errno val if fails | |
305 | */ | |
306 | int regulator_set_suspend_value(struct udevice *dev, int uV); | |
307 | ||
308 | /** | |
309 | * regulator_get_suspend_value: get the suspend microvoltage value of a given regulator. | |
310 | * | |
311 | * @dev - pointer to the regulator device | |
312 | * Return: - positive output value [uV] on success or negative errno if fail. | |
313 | */ | |
314 | int regulator_get_suspend_value(struct udevice *dev); | |
315 | ||
316 | /** | |
317 | * regulator_set_value_force: set the microvoltage value of a given regulator | |
318 | * without any min-,max condition check | |
319 | * | |
320 | * @dev - pointer to the regulator device | |
321 | * @uV - the output value to set [micro Volts] | |
322 | * Return: - 0 on success or -errno val if fails | |
323 | */ | |
324 | int regulator_set_value_force(struct udevice *dev, int uV); | |
325 | ||
326 | /** | |
327 | * regulator_get_current: get microampere value of a given regulator | |
328 | * | |
329 | * @dev - pointer to the regulator device | |
330 | * Return: - positive output current [uA] on success or negative errno if fail. | |
331 | */ | |
332 | int regulator_get_current(struct udevice *dev); | |
333 | ||
334 | /** | |
335 | * regulator_set_current: set the microampere value of a given regulator. | |
336 | * | |
337 | * @dev - pointer to the regulator device | |
338 | * @uA - set the output current [micro Amps] | |
339 | * Return: - 0 on success or -errno val if fails | |
340 | */ | |
341 | int regulator_set_current(struct udevice *dev, int uA); | |
342 | ||
343 | /** | |
344 | * regulator_get_enable: get regulator device enable state. | |
345 | * | |
346 | * @dev - pointer to the regulator device | |
347 | * Return: - true/false of enable state or -errno val if fails | |
348 | */ | |
349 | int regulator_get_enable(struct udevice *dev); | |
350 | ||
351 | /** | |
352 | * regulator_set_enable: set regulator enable state | |
353 | * | |
354 | * @dev - pointer to the regulator device | |
355 | * @enable - set true or false | |
356 | * Return: - 0 on success or -errno val if fails | |
357 | */ | |
358 | int regulator_set_enable(struct udevice *dev, bool enable); | |
359 | ||
360 | /** | |
361 | * regulator_set_enable_if_allowed: set regulator enable state if allowed by | |
362 | * regulator | |
363 | * | |
364 | * @dev - pointer to the regulator device | |
365 | * @enable - set true or false | |
366 | * Return: - 0 on success or if enabling is not supported | |
367 | * -errno val if fails. | |
368 | */ | |
369 | int regulator_set_enable_if_allowed(struct udevice *dev, bool enable); | |
370 | ||
371 | /** | |
372 | * regulator_set_suspend_enable: set regulator suspend enable state | |
373 | * | |
374 | * @dev - pointer to the regulator device | |
375 | * @enable - set true or false | |
376 | * Return: - 0 on success or -errno val if fails | |
377 | */ | |
378 | int regulator_set_suspend_enable(struct udevice *dev, bool enable); | |
379 | ||
380 | /** | |
381 | * regulator_get_suspend_enable: get regulator suspend enable state | |
382 | * | |
383 | * @dev - pointer to the regulator device | |
384 | * Return: - true/false of enable state or -errno val if fails | |
385 | */ | |
386 | int regulator_get_suspend_enable(struct udevice *dev); | |
387 | ||
388 | /** | |
389 | * regulator_get_mode: get active operation mode id of a given regulator | |
390 | * | |
391 | * @dev - pointer to the regulator device | |
392 | * Return: - positive mode 'id' number on success or -errno val if fails | |
393 | * Note: | |
394 | * The device can provide an array of operating modes, which is type of struct | |
395 | * dm_regulator_mode. Each mode has it's own 'id', which should be unique inside | |
396 | * that array. By calling this function, the driver should return an active mode | |
397 | * id of the given regulator device. | |
398 | */ | |
399 | int regulator_get_mode(struct udevice *dev); | |
400 | ||
401 | /** | |
402 | * regulator_set_mode: set the given regulator's, active mode id | |
403 | * | |
404 | * @dev - pointer to the regulator device | |
405 | * @mode_id - mode id to set ('id' field of struct type dm_regulator_mode) | |
406 | * Return: - 0 on success or -errno value if fails | |
407 | * Note: | |
408 | * The device can provide an array of operating modes, which is type of struct | |
409 | * dm_regulator_mode. Each mode has it's own 'id', which should be unique inside | |
410 | * that array. By calling this function, the driver should set the active mode | |
411 | * of a given regulator to given by "mode_id" argument. | |
412 | */ | |
413 | int regulator_set_mode(struct udevice *dev, int mode_id); | |
414 | ||
415 | /** | |
416 | * regulators_enable_boot_on() - enable regulators needed for boot | |
417 | * | |
418 | * This enables all regulators which are marked to be on at boot time. This | |
419 | * only works for regulators which don't have a range for voltage/current, | |
420 | * since in that case it is not possible to know which value to use. | |
421 | * | |
422 | * This effectively calls regulator_autoset() for every regulator. | |
423 | */ | |
424 | int regulators_enable_boot_on(bool verbose); | |
425 | ||
426 | /** | |
427 | * regulators_enable_boot_off() - disable regulators needed for boot | |
428 | * | |
429 | * This disables all regulators which are marked to be off at boot time. | |
430 | * | |
431 | * This effectively calls regulator_unset() for every regulator. | |
432 | */ | |
433 | int regulators_enable_boot_off(bool verbose); | |
434 | ||
435 | /** | |
436 | * regulator_autoset: setup the voltage/current on a regulator | |
437 | * | |
438 | * The setup depends on constraints found in device's uclass's platform data | |
439 | * (struct dm_regulator_uclass_plat): | |
440 | * | |
441 | * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, | |
442 | * or if both are unset, then the function returns | |
443 | * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal | |
444 | * - Current limit - will set - if '.min_uA' and '.max_uA' values are equal | |
445 | * | |
446 | * The function returns on the first-encountered error. | |
447 | * | |
448 | * @platname - expected string for dm_regulator_uclass_plat .name field | |
449 | * @devp - returned pointer to the regulator device - if non-NULL passed | |
450 | * @return: 0 on success or negative value of errno. | |
451 | */ | |
452 | int regulator_autoset(struct udevice *dev); | |
453 | ||
454 | /** | |
455 | * regulator_unset: turn off a regulator | |
456 | * | |
457 | * The setup depends on constraints found in device's uclass's platform data | |
458 | * (struct dm_regulator_uclass_platdata): | |
459 | * | |
460 | * - Disable - will set - if 'force_off' is set to true, | |
461 | * | |
462 | * The function returns on the first-encountered error. | |
463 | */ | |
464 | int regulator_unset(struct udevice *dev); | |
465 | ||
466 | /** | |
467 | * regulator_autoset_by_name: setup the regulator given by its uclass's | |
468 | * platform data name field. The setup depends on constraints found in device's | |
469 | * uclass's platform data (struct dm_regulator_uclass_plat): | |
470 | * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, | |
471 | * or if both are unset, then the function returns | |
472 | * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal | |
473 | * - Current limit - will set - if '.min_uA' and '.max_uA' values are equal | |
474 | * | |
475 | * The function returns on first encountered error. | |
476 | * | |
477 | * @platname - expected string for dm_regulator_uclass_plat .name field | |
478 | * @devp - returned pointer to the regulator device - if non-NULL passed | |
479 | * @return: 0 on success or negative value of errno. | |
480 | * | |
481 | * The returned 'regulator' device can be used with: | |
482 | * - regulator_get/set_* | |
483 | */ | |
484 | int regulator_autoset_by_name(const char *platname, struct udevice **devp); | |
485 | ||
486 | /** | |
487 | * regulator_list_autoset: setup the regulators given by list of their uclass's | |
488 | * platform data name field. The setup depends on constraints found in device's | |
489 | * uclass's platform data. The function loops with calls to: | |
490 | * regulator_autoset_by_name() for each name from the list. | |
491 | * | |
492 | * @list_platname - an array of expected strings for .name field of each | |
493 | * regulator's uclass plat | |
494 | * @list_devp - an array of returned pointers to the successfully setup | |
495 | * regulator devices if non-NULL passed | |
496 | * @verbose - (true/false) print each regulator setup info, or be quiet | |
497 | * Return: 0 on successfully setup of all list entries, otherwise first error. | |
498 | * | |
499 | * The returned 'regulator' devices can be used with: | |
500 | * - regulator_get/set_* | |
501 | * | |
502 | * Note: The list must ends with NULL entry, like in the "platname" list below: | |
503 | * char *my_regulators[] = { | |
504 | * "VCC_3.3V", | |
505 | * "VCC_1.8V", | |
506 | * NULL, | |
507 | * }; | |
508 | */ | |
509 | int regulator_list_autoset(const char *list_platname[], | |
510 | struct udevice *list_devp[], | |
511 | bool verbose); | |
512 | ||
513 | /** | |
514 | * regulator_get_by_devname: returns the pointer to the pmic regulator device. | |
515 | * Search by name, found in regulator device's name. | |
516 | * | |
517 | * @devname - expected string for 'dev->name' of regulator device | |
518 | * @devp - returned pointer to the regulator device | |
519 | * Return: 0 on success or negative value of errno. | |
520 | * | |
521 | * The returned 'regulator' device is probed and can be used with: | |
522 | * - regulator_get/set_* | |
523 | */ | |
524 | int regulator_get_by_devname(const char *devname, struct udevice **devp); | |
525 | ||
526 | /** | |
527 | * regulator_get_by_platname: returns the pointer to the pmic regulator device. | |
528 | * Search by name, found in regulator uclass plat. | |
529 | * | |
530 | * @platname - expected string for uc_pdata->name of regulator uclass plat | |
531 | * @devp - returns pointer to the regulator device or NULL on error | |
532 | * Return: 0 on success or negative value of errno. | |
533 | * | |
534 | * The returned 'regulator' device is probed and can be used with: | |
535 | * - regulator_get/set_* | |
536 | */ | |
537 | int regulator_get_by_platname(const char *platname, struct udevice **devp); | |
538 | ||
539 | /** | |
540 | * device_get_supply_regulator: returns the pointer to the supply regulator. | |
541 | * Search by phandle, found in device's node. | |
542 | * | |
543 | * Note: Please pay attention to proper order of device bind sequence. | |
544 | * The regulator device searched by the phandle, must be binded before | |
545 | * this function call. | |
546 | * | |
547 | * @dev - device with supply phandle | |
548 | * @supply_name - phandle name of regulator | |
549 | * @devp - returned pointer to the supply device | |
550 | * Return: 0 on success or negative value of errno. | |
551 | */ | |
552 | int device_get_supply_regulator(struct udevice *dev, const char *supply_name, | |
553 | struct udevice **devp); | |
554 | #else | |
555 | static inline int regulator_mode(struct udevice *dev, struct dm_regulator_mode **modep) | |
556 | { | |
557 | return -ENOSYS; | |
558 | } | |
559 | ||
560 | static inline int regulator_get_value(struct udevice *dev) | |
561 | { | |
562 | return -ENOSYS; | |
563 | } | |
564 | ||
565 | static inline int regulator_set_value(struct udevice *dev, int uV) | |
566 | { | |
567 | return -ENOSYS; | |
568 | } | |
569 | ||
570 | static inline int regulator_set_suspend_value(struct udevice *dev, int uV) | |
571 | { | |
572 | return -ENOSYS; | |
573 | } | |
574 | ||
575 | static inline int regulator_get_suspend_value(struct udevice *dev) | |
576 | { | |
577 | return -ENOSYS; | |
578 | } | |
579 | ||
580 | static inline int regulator_set_value_force(struct udevice *dev, int uV) | |
581 | { | |
582 | return -ENOSYS; | |
583 | } | |
584 | ||
585 | static inline int regulator_get_current(struct udevice *dev) | |
586 | { | |
587 | return -ENOSYS; | |
588 | } | |
589 | ||
590 | static inline int regulator_set_current(struct udevice *dev, int uA) | |
591 | { | |
592 | return -ENOSYS; | |
593 | } | |
594 | ||
595 | static inline int regulator_get_enable(struct udevice *dev) | |
596 | { | |
597 | return -ENOSYS; | |
598 | } | |
599 | ||
600 | static inline int regulator_set_enable(struct udevice *dev, bool enable) | |
601 | { | |
602 | return -ENOSYS; | |
603 | } | |
604 | ||
605 | static inline int regulator_set_enable_if_allowed(struct udevice *dev, bool enable) | |
606 | { | |
607 | return -ENOSYS; | |
608 | } | |
609 | ||
610 | static inline int regulator_set_suspend_enable(struct udevice *dev, bool enable) | |
611 | { | |
612 | return -ENOSYS; | |
613 | } | |
614 | ||
615 | static inline int regulator_get_suspend_enable(struct udevice *dev) | |
616 | { | |
617 | return -ENOSYS; | |
618 | } | |
619 | ||
620 | static inline int regulator_get_mode(struct udevice *dev) | |
621 | { | |
622 | return -ENOSYS; | |
623 | } | |
624 | ||
625 | static inline int regulator_set_mode(struct udevice *dev, int mode_id) | |
626 | { | |
627 | return -ENOSYS; | |
628 | } | |
629 | ||
630 | static inline int regulators_enable_boot_on(bool verbose) | |
631 | { | |
632 | return -ENOSYS; | |
633 | } | |
634 | ||
635 | static inline int regulator_autoset(struct udevice *dev) | |
636 | { | |
637 | return -ENOSYS; | |
638 | } | |
639 | ||
640 | static inline int regulator_autoset_by_name(const char *platname, struct udevice **devp) | |
641 | { | |
642 | return -ENOSYS; | |
643 | } | |
644 | ||
645 | static inline int regulator_list_autoset(const char *list_platname[], struct udevice *list_devp[], | |
646 | bool verbose) | |
647 | { | |
648 | return -ENOSYS; | |
649 | } | |
650 | ||
651 | static inline int regulator_get_by_devname(const char *devname, struct udevice **devp) | |
652 | { | |
653 | return -ENOSYS; | |
654 | } | |
655 | ||
656 | static inline int regulator_get_by_platname(const char *platname, struct udevice **devp) | |
657 | { | |
658 | return -ENOSYS; | |
659 | } | |
660 | ||
661 | static inline int device_get_supply_regulator(struct udevice *dev, const char *supply_name, | |
662 | struct udevice **devp) | |
663 | { | |
664 | return -ENOSYS; | |
665 | } | |
666 | #endif | |
667 | ||
668 | #endif /* _INCLUDE_REGULATOR_H_ */ |