]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
af41e8db PM |
2 | /* |
3 | * Copyright (C) 2014-2015 Samsung Electronics | |
4 | * Przemyslaw Marczak <[email protected]> | |
af41e8db PM |
5 | */ |
6 | ||
7 | #ifndef _INCLUDE_REGULATOR_H_ | |
8 | #define _INCLUDE_REGULATOR_H_ | |
9 | ||
401d1c4f SG |
10 | struct udevice; |
11 | ||
af41e8db PM |
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, | |
caa4daa2 SG |
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'. | |
af41e8db PM |
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' | |
caa4daa2 SG |
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'. | |
af41e8db PM |
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 { | |
3b880757 | 38 | * regulator-name = "VDD_MMC_1.8V"; (must be unique for proper bind) |
af41e8db PM |
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 | * | |
3b880757 PM |
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. | |
40ade2ce | 50 | * If regulator-name property is not provided, node name will be chosen. |
af41e8db PM |
51 | * |
52 | * Regulator bind: | |
a2703ce1 | 53 | * For each regulator device, the device_bind() should be called with passed |
af41e8db | 54 | * device tree offset. This is required for this uclass's '.post_bind' method, |
3b880757 | 55 | * which does the scan on the device node, for the 'regulator-name' constraint. |
af41e8db PM |
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 | |
2e3f1ff6 | 58 | * dm_scan_fdt_dev() - this is usually done automatically for bus devices, |
af41e8db | 59 | * as a post bind method. |
3b880757 PM |
60 | * |
61 | * Regulator get: | |
af41e8db | 62 | * Having the device's name constraint, we can call regulator_by_platname(), |
3b880757 | 63 | * to find the required regulator. Before return, the regulator is probed, |
af41e8db PM |
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, | |
477dfe2f | 112 | REGULATOR_TYPE_GPIO, |
af41e8db PM |
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 | ||
7837ceab SG |
134 | enum regulator_flag { |
135 | REGULATOR_FLAG_AUTOSET_UV = 1 << 0, | |
136 | REGULATOR_FLAG_AUTOSET_UA = 1 << 1, | |
137 | }; | |
138 | ||
af41e8db | 139 | /** |
caa4daa2 | 140 | * struct dm_regulator_uclass_plat - pointed by dev->uclass_plat, and |
af41e8db PM |
141 | * allocated on each regulator bind. This structure holds an information |
142 | * about each regulator's constraints and supported operation modes. | |
143 | * There is no "step" voltage value - so driver should take care of this. | |
144 | * | |
145 | * @type - one of 'enum regulator_type' | |
146 | * @mode - pointer to the regulator mode (array if more than one) | |
147 | * @mode_count - number of '.mode' entries | |
148 | * @min_uV* - minimum voltage (micro Volts) | |
149 | * @max_uV* - maximum voltage (micro Volts) | |
150 | * @min_uA* - minimum amperage (micro Amps) | |
151 | * @max_uA* - maximum amperage (micro Amps) | |
152 | * @always_on* - bool type, true or false | |
153 | * @boot_on* - bool type, true or false | |
7837ceab | 154 | * TODO([email protected]): Consider putting the above two into @flags |
e66d1cb3 | 155 | * @ramp_delay - Time to settle down after voltage change (unit: uV/us) |
7837ceab | 156 | * @flags: - flags value (see REGULATOR_FLAG_...) |
af41e8db | 157 | * @name** - fdt regulator name - should be taken from the device tree |
34514b8b K |
158 | * ctrl_reg: - Control register offset used to enable/disable regulator |
159 | * volt_reg: - register offset for writing voltage vsel values | |
af41e8db PM |
160 | * |
161 | * Note: | |
162 | * * - set automatically on device probe by the uclass's '.pre_probe' method. | |
163 | * ** - set automatically on device bind by the uclass's '.post_bind' method. | |
164 | * The constraints: type, mode, mode_count, can be set by device driver, e.g. | |
165 | * by the driver '.probe' method. | |
166 | */ | |
caa4daa2 | 167 | struct dm_regulator_uclass_plat { |
af41e8db PM |
168 | enum regulator_type type; |
169 | struct dm_regulator_mode *mode; | |
170 | int mode_count; | |
171 | int min_uV; | |
172 | int max_uV; | |
11406b8f | 173 | int init_uV; |
af41e8db PM |
174 | int min_uA; |
175 | int max_uA; | |
e66d1cb3 | 176 | unsigned int ramp_delay; |
af41e8db PM |
177 | bool always_on; |
178 | bool boot_on; | |
179 | const char *name; | |
7837ceab | 180 | int flags; |
34514b8b K |
181 | u8 ctrl_reg; |
182 | u8 volt_reg; | |
11406b8f JC |
183 | bool suspend_on; |
184 | u32 suspend_uV; | |
af41e8db PM |
185 | }; |
186 | ||
187 | /* Regulator device operations */ | |
188 | struct dm_regulator_ops { | |
189 | /** | |
190 | * The regulator output value function calls operates on a micro Volts. | |
191 | * | |
192 | * get/set_value - get/set output value of the given output number | |
193 | * @dev - regulator device | |
194 | * Sets: | |
195 | * @uV - set the output value [micro Volts] | |
1757df46 | 196 | * @return output value [uV] on success or negative errno if fail. |
af41e8db PM |
197 | */ |
198 | int (*get_value)(struct udevice *dev); | |
199 | int (*set_value)(struct udevice *dev, int uV); | |
200 | ||
11406b8f JC |
201 | /** |
202 | * The regulator suspend output value function calls operates | |
203 | * on a micro Volts. | |
204 | * | |
205 | * get/set_suspen_value - get/set suspend mode output value | |
206 | * @dev - regulator device | |
207 | * Sets: | |
208 | * @uV - set the suspend output value [micro Volts] | |
209 | * @return output value [uV] on success or negative errno if fail. | |
210 | */ | |
211 | int (*set_suspend_value)(struct udevice *dev, int uV); | |
212 | int (*get_suspend_value)(struct udevice *dev); | |
213 | ||
af41e8db PM |
214 | /** |
215 | * The regulator output current function calls operates on a micro Amps. | |
216 | * | |
217 | * get/set_current - get/set output current of the given output number | |
218 | * @dev - regulator device | |
219 | * Sets: | |
220 | * @uA - set the output current [micro Amps] | |
1757df46 | 221 | * @return output value [uA] on success or negative errno if fail. |
af41e8db PM |
222 | */ |
223 | int (*get_current)(struct udevice *dev); | |
224 | int (*set_current)(struct udevice *dev, int uA); | |
225 | ||
226 | /** | |
227 | * The most basic feature of the regulator output is its enable state. | |
228 | * | |
229 | * get/set_enable - get/set enable state of the given output number | |
230 | * @dev - regulator device | |
231 | * Sets: | |
232 | * @enable - set true - enable or false - disable | |
06bdf600 | 233 | * @return true/false for get or -errno if fail; 0 / -errno for set. |
af41e8db | 234 | */ |
06bdf600 | 235 | int (*get_enable)(struct udevice *dev); |
af41e8db PM |
236 | int (*set_enable)(struct udevice *dev, bool enable); |
237 | ||
11406b8f JC |
238 | /** |
239 | * The most basic feature of the regulator output is its enable state | |
240 | * in suspend mode. | |
241 | * | |
242 | * get/set_suspend_enable - get/set enable state of the suspend output | |
243 | * @dev - regulator device | |
244 | * Sets: | |
245 | * @enable - set true - enable or false - disable | |
246 | * @return true/false for get or -errno if fail; 0 / -errno for set. | |
247 | */ | |
248 | int (*set_suspend_enable)(struct udevice *dev, bool enable); | |
249 | int (*get_suspend_enable)(struct udevice *dev); | |
250 | ||
af41e8db | 251 | /** |
1757df46 | 252 | * The 'get/set_mode()' function calls should operate on a driver- |
3b880757 PM |
253 | * specific mode id definitions, which should be found in: |
254 | * field 'id' of struct dm_regulator_mode. | |
af41e8db PM |
255 | * |
256 | * get/set_mode - get/set operation mode of the given output number | |
257 | * @dev - regulator device | |
258 | * Sets | |
259 | * @mode_id - set output mode id (struct dm_regulator_mode->id) | |
1757df46 | 260 | * @return id/0 for get/set on success or negative errno if fail. |
af41e8db PM |
261 | * Note: |
262 | * The field 'id' of struct type 'dm_regulator_mode', should be always | |
3b880757 | 263 | * a positive number, since the negative is reserved for the error. |
af41e8db PM |
264 | */ |
265 | int (*get_mode)(struct udevice *dev); | |
266 | int (*set_mode)(struct udevice *dev, int mode_id); | |
267 | }; | |
268 | ||
16cc5ad0 | 269 | #if CONFIG_IS_ENABLED(DM_REGULATOR) |
af41e8db PM |
270 | /** |
271 | * regulator_mode: returns a pointer to the array of regulator mode info | |
272 | * | |
273 | * @dev - pointer to the regulator device | |
274 | * @modep - pointer to the returned mode info array | |
1757df46 | 275 | * @return - count of modep entries on success or negative errno if fail. |
af41e8db PM |
276 | */ |
277 | int regulator_mode(struct udevice *dev, struct dm_regulator_mode **modep); | |
278 | ||
279 | /** | |
280 | * regulator_get_value: get microvoltage voltage value of a given regulator | |
281 | * | |
282 | * @dev - pointer to the regulator device | |
1757df46 | 283 | * @return - positive output value [uV] on success or negative errno if fail. |
af41e8db PM |
284 | */ |
285 | int regulator_get_value(struct udevice *dev); | |
286 | ||
287 | /** | |
288 | * regulator_set_value: set the microvoltage value of a given regulator. | |
289 | * | |
290 | * @dev - pointer to the regulator device | |
291 | * @uV - the output value to set [micro Volts] | |
1757df46 | 292 | * @return - 0 on success or -errno val if fails |
af41e8db PM |
293 | */ |
294 | int regulator_set_value(struct udevice *dev, int uV); | |
295 | ||
11406b8f JC |
296 | /** |
297 | * regulator_set_suspend_value: set the suspend microvoltage value of a given regulator. | |
298 | * | |
299 | * @dev - pointer to the regulator device | |
300 | * @uV - the output suspend value to set [micro Volts] | |
301 | * @return - 0 on success or -errno val if fails | |
302 | */ | |
303 | int regulator_set_suspend_value(struct udevice *dev, int uV); | |
304 | ||
305 | /** | |
306 | * regulator_get_suspend_value: get the suspend microvoltage value of a given regulator. | |
307 | * | |
308 | * @dev - pointer to the regulator device | |
309 | * @return - positive output value [uV] on success or negative errno if fail. | |
310 | */ | |
311 | int regulator_get_suspend_value(struct udevice *dev); | |
312 | ||
2f5d532f K |
313 | /** |
314 | * regulator_set_value_force: set the microvoltage value of a given regulator | |
315 | * without any min-,max condition check | |
316 | * | |
317 | * @dev - pointer to the regulator device | |
318 | * @uV - the output value to set [micro Volts] | |
319 | * @return - 0 on success or -errno val if fails | |
320 | */ | |
321 | int regulator_set_value_force(struct udevice *dev, int uV); | |
322 | ||
af41e8db PM |
323 | /** |
324 | * regulator_get_current: get microampere value of a given regulator | |
325 | * | |
326 | * @dev - pointer to the regulator device | |
1757df46 | 327 | * @return - positive output current [uA] on success or negative errno if fail. |
af41e8db PM |
328 | */ |
329 | int regulator_get_current(struct udevice *dev); | |
330 | ||
331 | /** | |
332 | * regulator_set_current: set the microampere value of a given regulator. | |
333 | * | |
334 | * @dev - pointer to the regulator device | |
335 | * @uA - set the output current [micro Amps] | |
1757df46 | 336 | * @return - 0 on success or -errno val if fails |
af41e8db PM |
337 | */ |
338 | int regulator_set_current(struct udevice *dev, int uA); | |
339 | ||
340 | /** | |
341 | * regulator_get_enable: get regulator device enable state. | |
342 | * | |
343 | * @dev - pointer to the regulator device | |
06bdf600 | 344 | * @return - true/false of enable state or -errno val if fails |
af41e8db | 345 | */ |
06bdf600 | 346 | int regulator_get_enable(struct udevice *dev); |
af41e8db PM |
347 | |
348 | /** | |
349 | * regulator_set_enable: set regulator enable state | |
350 | * | |
351 | * @dev - pointer to the regulator device | |
352 | * @enable - set true or false | |
1757df46 | 353 | * @return - 0 on success or -errno val if fails |
af41e8db PM |
354 | */ |
355 | int regulator_set_enable(struct udevice *dev, bool enable); | |
356 | ||
cc4a224a LV |
357 | /** |
358 | * regulator_set_enable_if_allowed: set regulator enable state if allowed by | |
359 | * regulator | |
360 | * | |
361 | * @dev - pointer to the regulator device | |
362 | * @enable - set true or false | |
363 | * @return - 0 on success or if enabling is not supported | |
364 | * -errno val if fails. | |
365 | */ | |
366 | int regulator_set_enable_if_allowed(struct udevice *dev, bool enable); | |
367 | ||
11406b8f JC |
368 | /** |
369 | * regulator_set_suspend_enable: set regulator suspend enable state | |
370 | * | |
371 | * @dev - pointer to the regulator device | |
372 | * @enable - set true or false | |
373 | * @return - 0 on success or -errno val if fails | |
374 | */ | |
375 | int regulator_set_suspend_enable(struct udevice *dev, bool enable); | |
376 | ||
377 | /** | |
378 | * regulator_get_suspend_enable: get regulator suspend enable state | |
379 | * | |
380 | * @dev - pointer to the regulator device | |
381 | * @return - true/false of enable state or -errno val if fails | |
382 | */ | |
383 | int regulator_get_suspend_enable(struct udevice *dev); | |
384 | ||
af41e8db | 385 | /** |
3b880757 | 386 | * regulator_get_mode: get active operation mode id of a given regulator |
af41e8db PM |
387 | * |
388 | * @dev - pointer to the regulator device | |
3b880757 | 389 | * @return - positive mode 'id' number on success or -errno val if fails |
af41e8db | 390 | * Note: |
3b880757 PM |
391 | * The device can provide an array of operating modes, which is type of struct |
392 | * dm_regulator_mode. Each mode has it's own 'id', which should be unique inside | |
393 | * that array. By calling this function, the driver should return an active mode | |
394 | * id of the given regulator device. | |
af41e8db PM |
395 | */ |
396 | int regulator_get_mode(struct udevice *dev); | |
397 | ||
398 | /** | |
3b880757 | 399 | * regulator_set_mode: set the given regulator's, active mode id |
af41e8db | 400 | * |
3b880757 PM |
401 | * @dev - pointer to the regulator device |
402 | * @mode_id - mode id to set ('id' field of struct type dm_regulator_mode) | |
403 | * @return - 0 on success or -errno value if fails | |
af41e8db | 404 | * Note: |
3b880757 PM |
405 | * The device can provide an array of operating modes, which is type of struct |
406 | * dm_regulator_mode. Each mode has it's own 'id', which should be unique inside | |
407 | * that array. By calling this function, the driver should set the active mode | |
408 | * of a given regulator to given by "mode_id" argument. | |
af41e8db | 409 | */ |
3b880757 | 410 | int regulator_set_mode(struct udevice *dev, int mode_id); |
af41e8db | 411 | |
083fc83a SG |
412 | /** |
413 | * regulators_enable_boot_on() - enable regulators needed for boot | |
414 | * | |
415 | * This enables all regulators which are marked to be on at boot time. This | |
416 | * only works for regulators which don't have a range for voltage/current, | |
417 | * since in that case it is not possible to know which value to use. | |
418 | * | |
419 | * This effectively calls regulator_autoset() for every regulator. | |
420 | */ | |
421 | int regulators_enable_boot_on(bool verbose); | |
422 | ||
af41e8db | 423 | /** |
3b55d30f SG |
424 | * regulator_autoset: setup the voltage/current on a regulator |
425 | * | |
426 | * The setup depends on constraints found in device's uclass's platform data | |
caa4daa2 | 427 | * (struct dm_regulator_uclass_plat): |
3b55d30f SG |
428 | * |
429 | * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, | |
430 | * or if both are unset, then the function returns | |
431 | * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal | |
432 | * - Current limit - will set - if '.min_uA' and '.max_uA' values are equal | |
433 | * | |
434 | * The function returns on the first-encountered error. | |
435 | * | |
caa4daa2 | 436 | * @platname - expected string for dm_regulator_uclass_plat .name field |
3b55d30f SG |
437 | * @devp - returned pointer to the regulator device - if non-NULL passed |
438 | * @return: 0 on success or negative value of errno. | |
439 | */ | |
440 | int regulator_autoset(struct udevice *dev); | |
441 | ||
442 | /** | |
443 | * regulator_autoset_by_name: setup the regulator given by its uclass's | |
444 | * platform data name field. The setup depends on constraints found in device's | |
caa4daa2 | 445 | * uclass's platform data (struct dm_regulator_uclass_plat): |
3b880757 PM |
446 | * - Enable - will set - if any of: 'always_on' or 'boot_on' is set to true, |
447 | * or if both are unset, then the function returns | |
af41e8db PM |
448 | * - Voltage value - will set - if '.min_uV' and '.max_uV' values are equal |
449 | * - Current limit - will set - if '.min_uA' and '.max_uA' values are equal | |
af41e8db PM |
450 | * |
451 | * The function returns on first encountered error. | |
452 | * | |
caa4daa2 | 453 | * @platname - expected string for dm_regulator_uclass_plat .name field |
3b880757 | 454 | * @devp - returned pointer to the regulator device - if non-NULL passed |
1757df46 | 455 | * @return: 0 on success or negative value of errno. |
af41e8db PM |
456 | * |
457 | * The returned 'regulator' device can be used with: | |
458 | * - regulator_get/set_* | |
af41e8db | 459 | */ |
3b55d30f | 460 | int regulator_autoset_by_name(const char *platname, struct udevice **devp); |
af41e8db PM |
461 | |
462 | /** | |
3b880757 PM |
463 | * regulator_list_autoset: setup the regulators given by list of their uclass's |
464 | * platform data name field. The setup depends on constraints found in device's | |
465 | * uclass's platform data. The function loops with calls to: | |
3b55d30f | 466 | * regulator_autoset_by_name() for each name from the list. |
af41e8db PM |
467 | * |
468 | * @list_platname - an array of expected strings for .name field of each | |
caa4daa2 | 469 | * regulator's uclass plat |
af41e8db PM |
470 | * @list_devp - an array of returned pointers to the successfully setup |
471 | * regulator devices if non-NULL passed | |
472 | * @verbose - (true/false) print each regulator setup info, or be quiet | |
3b880757 | 473 | * @return 0 on successfully setup of all list entries, otherwise first error. |
af41e8db PM |
474 | * |
475 | * The returned 'regulator' devices can be used with: | |
476 | * - regulator_get/set_* | |
3b880757 PM |
477 | * |
478 | * Note: The list must ends with NULL entry, like in the "platname" list below: | |
479 | * char *my_regulators[] = { | |
480 | * "VCC_3.3V", | |
481 | * "VCC_1.8V", | |
482 | * NULL, | |
483 | * }; | |
af41e8db | 484 | */ |
3b880757 PM |
485 | int regulator_list_autoset(const char *list_platname[], |
486 | struct udevice *list_devp[], | |
487 | bool verbose); | |
af41e8db PM |
488 | |
489 | /** | |
3b880757 PM |
490 | * regulator_get_by_devname: returns the pointer to the pmic regulator device. |
491 | * Search by name, found in regulator device's name. | |
af41e8db PM |
492 | * |
493 | * @devname - expected string for 'dev->name' of regulator device | |
1757df46 PM |
494 | * @devp - returned pointer to the regulator device |
495 | * @return 0 on success or negative value of errno. | |
af41e8db | 496 | * |
3b880757 | 497 | * The returned 'regulator' device is probed and can be used with: |
af41e8db PM |
498 | * - regulator_get/set_* |
499 | */ | |
3b880757 | 500 | int regulator_get_by_devname(const char *devname, struct udevice **devp); |
af41e8db PM |
501 | |
502 | /** | |
3b880757 | 503 | * regulator_get_by_platname: returns the pointer to the pmic regulator device. |
caa4daa2 | 504 | * Search by name, found in regulator uclass plat. |
af41e8db | 505 | * |
caa4daa2 | 506 | * @platname - expected string for uc_pdata->name of regulator uclass plat |
3b55d30f | 507 | * @devp - returns pointer to the regulator device or NULL on error |
1757df46 | 508 | * @return 0 on success or negative value of errno. |
af41e8db | 509 | * |
3b880757 | 510 | * The returned 'regulator' device is probed and can be used with: |
af41e8db PM |
511 | * - regulator_get/set_* |
512 | */ | |
3b880757 | 513 | int regulator_get_by_platname(const char *platname, struct udevice **devp); |
af41e8db | 514 | |
7c816e24 PM |
515 | /** |
516 | * device_get_supply_regulator: returns the pointer to the supply regulator. | |
517 | * Search by phandle, found in device's node. | |
518 | * | |
519 | * Note: Please pay attention to proper order of device bind sequence. | |
520 | * The regulator device searched by the phandle, must be binded before | |
521 | * this function call. | |
522 | * | |
523 | * @dev - device with supply phandle | |
524 | * @supply_name - phandle name of regulator | |
525 | * @devp - returned pointer to the supply device | |
526 | * @return 0 on success or negative value of errno. | |
527 | */ | |
528 | int device_get_supply_regulator(struct udevice *dev, const char *supply_name, | |
529 | struct udevice **devp); | |
16cc5ad0 PF |
530 | #else |
531 | static inline int regulator_mode(struct udevice *dev, struct dm_regulator_mode **modep) | |
532 | { | |
533 | return -ENOSYS; | |
534 | } | |
535 | ||
536 | static inline int regulator_get_value(struct udevice *dev) | |
537 | { | |
538 | return -ENOSYS; | |
539 | } | |
540 | ||
541 | static inline int regulator_set_value(struct udevice *dev, int uV) | |
542 | { | |
543 | return -ENOSYS; | |
544 | } | |
545 | ||
546 | static inline int regulator_set_suspend_value(struct udevice *dev, int uV) | |
547 | { | |
548 | return -ENOSYS; | |
549 | } | |
550 | ||
551 | static inline int regulator_get_suspend_value(struct udevice *dev) | |
552 | { | |
553 | return -ENOSYS; | |
554 | } | |
555 | ||
556 | static inline int regulator_set_value_force(struct udevice *dev, int uV) | |
557 | { | |
558 | return -ENOSYS; | |
559 | } | |
560 | ||
561 | static inline int regulator_get_current(struct udevice *dev) | |
562 | { | |
563 | return -ENOSYS; | |
564 | } | |
565 | ||
566 | static inline int regulator_set_current(struct udevice *dev, int uA) | |
567 | { | |
568 | return -ENOSYS; | |
569 | } | |
570 | ||
571 | static inline int regulator_get_enable(struct udevice *dev) | |
572 | { | |
573 | return -ENOSYS; | |
574 | } | |
575 | ||
576 | static inline int regulator_set_enable(struct udevice *dev, bool enable) | |
577 | { | |
578 | return -ENOSYS; | |
579 | } | |
580 | ||
581 | static inline int regulator_set_enable_if_allowed(struct udevice *dev, bool enable) | |
582 | { | |
583 | return -ENOSYS; | |
584 | } | |
585 | ||
586 | static inline int regulator_set_suspend_enable(struct udevice *dev, bool enable) | |
587 | { | |
588 | return -ENOSYS; | |
589 | } | |
590 | ||
591 | static inline int regulator_get_suspend_enable(struct udevice *dev) | |
592 | { | |
593 | return -ENOSYS; | |
594 | } | |
595 | ||
596 | static inline int regulator_get_mode(struct udevice *dev) | |
597 | { | |
598 | return -ENOSYS; | |
599 | } | |
600 | ||
601 | static inline int regulator_set_mode(struct udevice *dev, int mode_id) | |
602 | { | |
603 | return -ENOSYS; | |
604 | } | |
605 | ||
606 | static inline int regulators_enable_boot_on(bool verbose) | |
607 | { | |
608 | return -ENOSYS; | |
609 | } | |
610 | ||
611 | static inline int regulator_autoset(struct udevice *dev) | |
612 | { | |
613 | return -ENOSYS; | |
614 | } | |
615 | ||
616 | static inline int regulator_autoset_by_name(const char *platname, struct udevice **devp) | |
617 | { | |
618 | return -ENOSYS; | |
619 | } | |
620 | ||
621 | static inline int regulator_list_autoset(const char *list_platname[], struct udevice *list_devp[], | |
622 | bool verbose) | |
623 | { | |
624 | return -ENOSYS; | |
625 | } | |
626 | ||
627 | static inline int regulator_get_by_devname(const char *devname, struct udevice **devp) | |
628 | { | |
629 | return -ENOSYS; | |
630 | } | |
631 | ||
632 | static inline int regulator_get_by_platname(const char *platname, struct udevice **devp) | |
633 | { | |
634 | return -ENOSYS; | |
635 | } | |
636 | ||
637 | static inline int device_get_supply_regulator(struct udevice *dev, const char *supply_name, | |
638 | struct udevice **devp) | |
639 | { | |
640 | return -ENOSYS; | |
641 | } | |
642 | #endif | |
7c816e24 | 643 | |
af41e8db | 644 | #endif /* _INCLUDE_REGULATOR_H_ */ |