blob: 6c6e2cd4f99635611c0bc19f8969ebfa268f762c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Przemyslaw Marczak08edd002015-04-20 20:07:42 +02002/*
3 * Copyright (C) 2014-2015 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
Przemyslaw Marczak08edd002015-04-20 20:07:42 +02005 */
6
7#ifndef _INCLUDE_REGULATOR_H_
8#define _INCLUDE_REGULATOR_H_
9
10/**
11 * U-Boot Voltage/Current Regulator
12 * ================================
13 *
14 * The regulator API is based on a driver model, with the device tree support.
15 * And this header describes the functions and data types for the uclass id:
16 * 'UCLASS_REGULATOR' and the regulator driver API.
17 *
18 * The regulator uclass - is based on uclass platform data which is allocated,
19 * automatically for each regulator device on bind and 'dev->uclass_platdata'
20 * points to it. The data type is: 'struct dm_regulator_uclass_platdata'.
21 * The uclass file: 'drivers/power/regulator/regulator-uclass.c'
22 *
23 * The regulator device - is based on driver's model 'struct udevice'.
24 * The API can use regulator name in two meanings:
25 * - devname - the regulator device's name: 'dev->name'
26 * - platname - the device's platdata's name. So in the code it looks like:
27 * 'uc_pdata = dev->uclass_platdata'; 'name = uc_pdata->name'.
28 *
29 * The regulator device driver - provide an implementation of uclass operations
30 * pointed by 'dev->driver->ops' as a struct of type 'struct dm_regulator_ops'.
31 *
32 * To proper bind the regulator device, the device tree node should provide
33 * regulator constraints, like in the example below:
34 *
35 * ldo1 {
Przemyslaw Marczak75692a32015-05-13 13:38:27 +020036 * regulator-name = "VDD_MMC_1.8V"; (must be unique for proper bind)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020037 * regulator-min-microvolt = <1000000>; (optional)
38 * regulator-max-microvolt = <1000000>; (optional)
39 * regulator-min-microamp = <1000>; (optional)
40 * regulator-max-microamp = <1000>; (optional)
41 * regulator-always-on; (optional)
42 * regulator-boot-on; (optional)
43 * };
44 *
Przemyslaw Marczak75692a32015-05-13 13:38:27 +020045 * Note: For the proper operation, at least name constraint is needed, since
46 * it can be used when calling regulator_get_by_platname(). And the mandatory
47 * rule for this name is, that it must be globally unique for the single dts.
Peng Fanb4cb9ce2015-08-07 16:43:43 +080048 * If regulator-name property is not provided, node name will be chosen.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020049 *
50 * Regulator bind:
51 * For each regulator device, the device_bind() should be called with passed
52 * device tree offset. This is required for this uclass's '.post_bind' method,
Przemyslaw Marczak75692a32015-05-13 13:38:27 +020053 * which does the scan on the device node, for the 'regulator-name' constraint.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020054 * If the parent is not a PMIC device, and the child is not bind by function:
55 * 'pmic_bind_childs()', then it's recommended to bind the device by call to
Simon Glass09128c52016-07-05 17:10:09 -060056 * dm_scan_fdt_dev() - this is usually done automatically for bus devices,
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020057 * as a post bind method.
Przemyslaw Marczak75692a32015-05-13 13:38:27 +020058 *
59 * Regulator get:
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020060 * Having the device's name constraint, we can call regulator_by_platname(),
Przemyslaw Marczak75692a32015-05-13 13:38:27 +020061 * to find the required regulator. Before return, the regulator is probed,
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020062 * and the rest of its constraints are put into the device's uclass platform
63 * data, by the uclass regulator '.pre_probe' method.
64 *
65 * For more info about PMIC bind, please refer to file: 'include/power/pmic.h'
66 *
67 * Note:
68 * Please do not use the device_bind_by_name() function, since it pass '-1' as
69 * device node offset - and the bind will fail on uclass .post_bind method,
70 * because of missing 'regulator-name' constraint.
71 *
72 *
73 * Fixed Voltage/Current Regulator
74 * ===============================
75 *
76 * When fixed voltage regulator is needed, then enable the config:
77 * - CONFIG_DM_REGULATOR_FIXED
78 *
79 * The driver file: 'drivers/power/regulator/fixed.c', provides basic support
80 * for control the GPIO, and return the device tree constraint values.
81 *
82 * To bind the fixed voltage regulator device, we usually use a 'simple-bus'
83 * node as a parent. And 'regulator-fixed' for the driver compatible. This is
84 * the same as in the kernel. The example node of fixed regulator:
85 *
86 * simple-bus {
87 * compatible = "simple-bus";
88 * #address-cells = <1>;
89 * #size-cells = <0>;
90 *
91 * blue_led {
92 * compatible = "regulator-fixed";
93 * regulator-name = "VDD_LED_3.3V";
94 * regulator-min-microvolt = <3300000>;
95 * regulator-max-microvolt = <3300000>;
96 * gpio = <&gpc1 0 GPIO_ACTIVE_LOW>;
97 * };
98 * };
99 *
100 * The fixed regulator devices also provide regulator uclass platform data. And
101 * devices bound from such node, can use the regulator drivers API.
102*/
103
104/* enum regulator_type - used for regulator_*() variant calls */
105enum regulator_type {
106 REGULATOR_TYPE_LDO = 0,
107 REGULATOR_TYPE_BUCK,
108 REGULATOR_TYPE_DVS,
109 REGULATOR_TYPE_FIXED,
Keerthy17b3fe72016-09-15 17:04:06 +0530110 REGULATOR_TYPE_GPIO,
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200111 REGULATOR_TYPE_OTHER,
112};
113
114/**
115 * struct dm_regulator_mode - this structure holds an information about
116 * each regulator operation mode. Probably in most cases - an array.
117 * This will be probably a driver-static data, since it is device-specific.
118 *
119 * @id - a driver-specific mode id
120 * @register_value - a driver-specific value for its mode id
121 * @name - the name of mode - used for regulator command
122 * Note:
123 * The field 'id', should be always a positive number, since the negative values
124 * are reserved for the errno numbers when returns the mode id.
125 */
126struct dm_regulator_mode {
127 int id; /* Set only as >= 0 (negative value is reserved for errno) */
128 int register_value;
129 const char *name;
130};
131
Simon Glass991f9bc2015-06-23 15:38:57 -0600132enum regulator_flag {
133 REGULATOR_FLAG_AUTOSET_UV = 1 << 0,
134 REGULATOR_FLAG_AUTOSET_UA = 1 << 1,
135};
136
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200137/**
138 * struct dm_regulator_uclass_platdata - pointed by dev->uclass_platdata, and
139 * allocated on each regulator bind. This structure holds an information
140 * about each regulator's constraints and supported operation modes.
141 * There is no "step" voltage value - so driver should take care of this.
142 *
143 * @type - one of 'enum regulator_type'
144 * @mode - pointer to the regulator mode (array if more than one)
145 * @mode_count - number of '.mode' entries
146 * @min_uV* - minimum voltage (micro Volts)
147 * @max_uV* - maximum voltage (micro Volts)
148 * @min_uA* - minimum amperage (micro Amps)
149 * @max_uA* - maximum amperage (micro Amps)
150 * @always_on* - bool type, true or false
151 * @boot_on* - bool type, true or false
Simon Glass991f9bc2015-06-23 15:38:57 -0600152 * TODO(sjg@chromium.org): Consider putting the above two into @flags
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +0100153 * @ramp_delay - Time to settle down after voltage change (unit: uV/us)
Simon Glass991f9bc2015-06-23 15:38:57 -0600154 * @flags: - flags value (see REGULATOR_FLAG_...)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200155 * @name** - fdt regulator name - should be taken from the device tree
Keerthy4d96cd02016-09-30 09:20:42 +0530156 * ctrl_reg: - Control register offset used to enable/disable regulator
157 * volt_reg: - register offset for writing voltage vsel values
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200158 *
159 * Note:
160 * * - set automatically on device probe by the uclass's '.pre_probe' method.
161 * ** - set automatically on device bind by the uclass's '.post_bind' method.
162 * The constraints: type, mode, mode_count, can be set by device driver, e.g.
163 * by the driver '.probe' method.
164 */
165struct dm_regulator_uclass_platdata {
166 enum regulator_type type;
167 struct dm_regulator_mode *mode;
168 int mode_count;
169 int min_uV;
170 int max_uV;
171 int min_uA;
172 int max_uA;
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +0100173 unsigned int ramp_delay;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200174 bool always_on;
175 bool boot_on;
176 const char *name;
Simon Glass991f9bc2015-06-23 15:38:57 -0600177 int flags;
Keerthy4d96cd02016-09-30 09:20:42 +0530178 u8 ctrl_reg;
179 u8 volt_reg;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200180};
181
182/* Regulator device operations */
183struct dm_regulator_ops {
184 /**
185 * The regulator output value function calls operates on a micro Volts.
186 *
187 * get/set_value - get/set output value of the given output number
188 * @dev - regulator device
189 * Sets:
190 * @uV - set the output value [micro Volts]
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200191 * @return output value [uV] on success or negative errno if fail.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200192 */
193 int (*get_value)(struct udevice *dev);
194 int (*set_value)(struct udevice *dev, int uV);
195
196 /**
197 * The regulator output current function calls operates on a micro Amps.
198 *
199 * get/set_current - get/set output current of the given output number
200 * @dev - regulator device
201 * Sets:
202 * @uA - set the output current [micro Amps]
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200203 * @return output value [uA] on success or negative errno if fail.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200204 */
205 int (*get_current)(struct udevice *dev);
206 int (*set_current)(struct udevice *dev, int uA);
207
208 /**
209 * The most basic feature of the regulator output is its enable state.
210 *
211 * get/set_enable - get/set enable state of the given output number
212 * @dev - regulator device
213 * Sets:
214 * @enable - set true - enable or false - disable
Keerthy23be7fb2017-06-13 09:53:45 +0530215 * @return true/false for get or -errno if fail; 0 / -errno for set.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200216 */
Keerthy23be7fb2017-06-13 09:53:45 +0530217 int (*get_enable)(struct udevice *dev);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200218 int (*set_enable)(struct udevice *dev, bool enable);
219
220 /**
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200221 * The 'get/set_mode()' function calls should operate on a driver-
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200222 * specific mode id definitions, which should be found in:
223 * field 'id' of struct dm_regulator_mode.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200224 *
225 * get/set_mode - get/set operation mode of the given output number
226 * @dev - regulator device
227 * Sets
228 * @mode_id - set output mode id (struct dm_regulator_mode->id)
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200229 * @return id/0 for get/set on success or negative errno if fail.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200230 * Note:
231 * The field 'id' of struct type 'dm_regulator_mode', should be always
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200232 * a positive number, since the negative is reserved for the error.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200233 */
234 int (*get_mode)(struct udevice *dev);
235 int (*set_mode)(struct udevice *dev, int mode_id);
236};
237
238/**
239 * regulator_mode: returns a pointer to the array of regulator mode info
240 *
241 * @dev - pointer to the regulator device
242 * @modep - pointer to the returned mode info array
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200243 * @return - count of modep entries on success or negative errno if fail.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200244 */
245int regulator_mode(struct udevice *dev, struct dm_regulator_mode **modep);
246
247/**
248 * regulator_get_value: get microvoltage voltage value of a given regulator
249 *
250 * @dev - pointer to the regulator device
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200251 * @return - positive output value [uV] on success or negative errno if fail.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200252 */
253int regulator_get_value(struct udevice *dev);
254
255/**
256 * regulator_set_value: set the microvoltage value of a given regulator.
257 *
258 * @dev - pointer to the regulator device
259 * @uV - the output value to set [micro Volts]
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200260 * @return - 0 on success or -errno val if fails
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200261 */
262int regulator_set_value(struct udevice *dev, int uV);
263
264/**
Keerthy162c02e2016-10-26 13:42:30 +0530265 * regulator_set_value_force: set the microvoltage value of a given regulator
266 * without any min-,max condition check
267 *
268 * @dev - pointer to the regulator device
269 * @uV - the output value to set [micro Volts]
270 * @return - 0 on success or -errno val if fails
271 */
272int regulator_set_value_force(struct udevice *dev, int uV);
273
274/**
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200275 * regulator_get_current: get microampere value of a given regulator
276 *
277 * @dev - pointer to the regulator device
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200278 * @return - positive output current [uA] on success or negative errno if fail.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200279 */
280int regulator_get_current(struct udevice *dev);
281
282/**
283 * regulator_set_current: set the microampere value of a given regulator.
284 *
285 * @dev - pointer to the regulator device
286 * @uA - set the output current [micro Amps]
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200287 * @return - 0 on success or -errno val if fails
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200288 */
289int regulator_set_current(struct udevice *dev, int uA);
290
291/**
292 * regulator_get_enable: get regulator device enable state.
293 *
294 * @dev - pointer to the regulator device
Keerthy23be7fb2017-06-13 09:53:45 +0530295 * @return - true/false of enable state or -errno val if fails
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200296 */
Keerthy23be7fb2017-06-13 09:53:45 +0530297int regulator_get_enable(struct udevice *dev);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200298
299/**
300 * regulator_set_enable: set regulator enable state
301 *
302 * @dev - pointer to the regulator device
303 * @enable - set true or false
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200304 * @return - 0 on success or -errno val if fails
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200305 */
306int regulator_set_enable(struct udevice *dev, bool enable);
307
308/**
Lokesh Vutla7106b782019-01-11 15:15:51 +0530309 * regulator_set_enable_if_allowed: set regulator enable state if allowed by
310 * regulator
311 *
312 * @dev - pointer to the regulator device
313 * @enable - set true or false
314 * @return - 0 on success or if enabling is not supported
315 * -errno val if fails.
316 */
317int regulator_set_enable_if_allowed(struct udevice *dev, bool enable);
318
319/**
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200320 * regulator_get_mode: get active operation mode id of a given regulator
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200321 *
322 * @dev - pointer to the regulator device
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200323 * @return - positive mode 'id' number on success or -errno val if fails
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200324 * Note:
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200325 * The device can provide an array of operating modes, which is type of struct
326 * dm_regulator_mode. Each mode has it's own 'id', which should be unique inside
327 * that array. By calling this function, the driver should return an active mode
328 * id of the given regulator device.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200329 */
330int regulator_get_mode(struct udevice *dev);
331
332/**
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200333 * regulator_set_mode: set the given regulator's, active mode id
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200334 *
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200335 * @dev - pointer to the regulator device
336 * @mode_id - mode id to set ('id' field of struct type dm_regulator_mode)
337 * @return - 0 on success or -errno value if fails
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200338 * Note:
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200339 * The device can provide an array of operating modes, which is type of struct
340 * dm_regulator_mode. Each mode has it's own 'id', which should be unique inside
341 * that array. By calling this function, the driver should set the active mode
342 * of a given regulator to given by "mode_id" argument.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200343 */
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200344int regulator_set_mode(struct udevice *dev, int mode_id);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200345
346/**
Simon Glassefeeb2c2015-06-23 15:38:59 -0600347 * regulators_enable_boot_on() - enable regulators needed for boot
348 *
349 * This enables all regulators which are marked to be on at boot time. This
350 * only works for regulators which don't have a range for voltage/current,
351 * since in that case it is not possible to know which value to use.
352 *
353 * This effectively calls regulator_autoset() for every regulator.
354 */
355int regulators_enable_boot_on(bool verbose);
356
357/**
Simon Glass46cb8242015-06-23 15:38:58 -0600358 * regulator_autoset: setup the voltage/current on a regulator
359 *
360 * The setup depends on constraints found in device's uclass's platform data
361 * (struct dm_regulator_uclass_platdata):
362 *
363 * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true,
364 * or if both are unset, then the function returns
365 * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal
366 * - Current limit - will set - if '.min_uA' and '.max_uA' values are equal
367 *
368 * The function returns on the first-encountered error.
369 *
370 * @platname - expected string for dm_regulator_uclass_platdata .name field
371 * @devp - returned pointer to the regulator device - if non-NULL passed
372 * @return: 0 on success or negative value of errno.
373 */
374int regulator_autoset(struct udevice *dev);
375
376/**
377 * regulator_autoset_by_name: setup the regulator given by its uclass's
378 * platform data name field. The setup depends on constraints found in device's
379 * uclass's platform data (struct dm_regulator_uclass_platdata):
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200380 * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true,
381 * or if both are unset, then the function returns
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200382 * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal
383 * - Current limit - will set - if '.min_uA' and '.max_uA' values are equal
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200384 *
385 * The function returns on first encountered error.
386 *
387 * @platname - expected string for dm_regulator_uclass_platdata .name field
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200388 * @devp - returned pointer to the regulator device - if non-NULL passed
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200389 * @return: 0 on success or negative value of errno.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200390 *
391 * The returned 'regulator' device can be used with:
392 * - regulator_get/set_*
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200393 */
Simon Glass46cb8242015-06-23 15:38:58 -0600394int regulator_autoset_by_name(const char *platname, struct udevice **devp);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200395
396/**
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200397 * regulator_list_autoset: setup the regulators given by list of their uclass's
398 * platform data name field. The setup depends on constraints found in device's
399 * uclass's platform data. The function loops with calls to:
Simon Glass46cb8242015-06-23 15:38:58 -0600400 * regulator_autoset_by_name() for each name from the list.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200401 *
402 * @list_platname - an array of expected strings for .name field of each
403 * regulator's uclass platdata
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200404 * @list_devp - an array of returned pointers to the successfully setup
405 * regulator devices if non-NULL passed
406 * @verbose - (true/false) print each regulator setup info, or be quiet
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200407 * @return 0 on successfully setup of all list entries, otherwise first error.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200408 *
409 * The returned 'regulator' devices can be used with:
410 * - regulator_get/set_*
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200411 *
412 * Note: The list must ends with NULL entry, like in the "platname" list below:
413 * char *my_regulators[] = {
414 * "VCC_3.3V",
415 * "VCC_1.8V",
416 * NULL,
417 * };
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200418 */
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200419int regulator_list_autoset(const char *list_platname[],
420 struct udevice *list_devp[],
421 bool verbose);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200422
423/**
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200424 * regulator_get_by_devname: returns the pointer to the pmic regulator device.
425 * Search by name, found in regulator device's name.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200426 *
427 * @devname - expected string for 'dev->name' of regulator device
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200428 * @devp - returned pointer to the regulator device
429 * @return 0 on success or negative value of errno.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200430 *
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200431 * The returned 'regulator' device is probed and can be used with:
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200432 * - regulator_get/set_*
433 */
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200434int regulator_get_by_devname(const char *devname, struct udevice **devp);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200435
436/**
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200437 * regulator_get_by_platname: returns the pointer to the pmic regulator device.
438 * Search by name, found in regulator uclass platdata.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200439 *
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200440 * @platname - expected string for uc_pdata->name of regulator uclass platdata
Simon Glass46cb8242015-06-23 15:38:58 -0600441 * @devp - returns pointer to the regulator device or NULL on error
Przemyslaw Marczakafee81e2015-04-20 20:07:47 +0200442 * @return 0 on success or negative value of errno.
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200443 *
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200444 * The returned 'regulator' device is probed and can be used with:
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200445 * - regulator_get/set_*
446 */
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200447int regulator_get_by_platname(const char *platname, struct udevice **devp);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200448
Przemyslaw Marczakc9001032015-10-27 13:07:59 +0100449/**
450 * device_get_supply_regulator: returns the pointer to the supply regulator.
451 * Search by phandle, found in device's node.
452 *
453 * Note: Please pay attention to proper order of device bind sequence.
454 * The regulator device searched by the phandle, must be binded before
455 * this function call.
456 *
457 * @dev - device with supply phandle
458 * @supply_name - phandle name of regulator
459 * @devp - returned pointer to the supply device
460 * @return 0 on success or negative value of errno.
461 */
462int device_get_supply_regulator(struct udevice *dev, const char *supply_name,
463 struct udevice **devp);
464
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200465#endif /* _INCLUDE_REGULATOR_H_ */