blob: c9d26344d78028eb599078d18b4a484c58c89bd6 [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 */
Simon Glasseeb99de2017-05-18 20:09:34 -06006
Przemyslaw Marczak08edd002015-04-20 20:07:42 +02007#include <common.h>
Przemyslaw Marczak08edd002015-04-20 20:07:42 +02008#include <errno.h>
9#include <dm.h>
10#include <dm/uclass-internal.h>
11#include <power/pmic.h>
12#include <power/regulator.h>
13
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020014int regulator_mode(struct udevice *dev, struct dm_regulator_mode **modep)
15{
16 struct dm_regulator_uclass_platdata *uc_pdata;
17
18 *modep = NULL;
19
20 uc_pdata = dev_get_uclass_platdata(dev);
21 if (!uc_pdata)
22 return -ENXIO;
23
24 *modep = uc_pdata->mode;
25 return uc_pdata->mode_count;
26}
27
28int regulator_get_value(struct udevice *dev)
29{
30 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
31
32 if (!ops || !ops->get_value)
33 return -ENOSYS;
34
35 return ops->get_value(dev);
36}
37
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +010038static void regulator_set_value_ramp_delay(struct udevice *dev, int old_uV,
39 int new_uV, unsigned int ramp_delay)
40{
41 int delay = DIV_ROUND_UP(abs(new_uV - old_uV), ramp_delay);
42
43 debug("regulator %s: delay %u us (%d uV -> %d uV)\n", dev->name, delay,
44 old_uV, new_uV);
45
46 udelay(delay);
47}
48
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020049int regulator_set_value(struct udevice *dev, int uV)
50{
51 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
Keerthyc6e66692016-10-26 13:42:31 +053052 struct dm_regulator_uclass_platdata *uc_pdata;
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +010053 int ret, old_uV = uV, is_enabled = 0;
Keerthyc6e66692016-10-26 13:42:31 +053054
55 uc_pdata = dev_get_uclass_platdata(dev);
56 if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV)
57 return -EINVAL;
58 if (uc_pdata->max_uV != -ENODATA && uV > uc_pdata->max_uV)
59 return -EINVAL;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020060
61 if (!ops || !ops->set_value)
62 return -ENOSYS;
63
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +010064 if (uc_pdata->ramp_delay) {
65 is_enabled = regulator_get_enable(dev);
66 old_uV = regulator_get_value(dev);
67 }
68
69 ret = ops->set_value(dev, uV);
70
71 if (!ret) {
72 if (uc_pdata->ramp_delay && old_uV > 0 && is_enabled)
73 regulator_set_value_ramp_delay(dev, old_uV, uV,
74 uc_pdata->ramp_delay);
75 }
76
77 return ret;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +020078}
79
Joseph Chenbb511322019-09-26 15:43:52 +080080int regulator_set_suspend_value(struct udevice *dev, int uV)
81{
82 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
83 struct dm_regulator_uclass_platdata *uc_pdata;
84
85 uc_pdata = dev_get_uclass_platdata(dev);
86 if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV)
87 return -EINVAL;
88 if (uc_pdata->max_uV != -ENODATA && uV > uc_pdata->max_uV)
89 return -EINVAL;
90
91 if (!ops->set_suspend_value)
92 return -ENOSYS;
93
94 return ops->set_suspend_value(dev, uV);
95}
96
97int regulator_get_suspend_value(struct udevice *dev)
98{
99 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
100
101 if (!ops->get_suspend_value)
102 return -ENOSYS;
103
104 return ops->get_suspend_value(dev);
105}
106
Keerthy162c02e2016-10-26 13:42:30 +0530107/*
108 * To be called with at most caution as there is no check
109 * before setting the actual voltage value.
110 */
111int regulator_set_value_force(struct udevice *dev, int uV)
112{
113 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
114
115 if (!ops || !ops->set_value)
116 return -ENOSYS;
117
118 return ops->set_value(dev, uV);
119}
120
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200121int regulator_get_current(struct udevice *dev)
122{
123 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
124
125 if (!ops || !ops->get_current)
126 return -ENOSYS;
127
128 return ops->get_current(dev);
129}
130
131int regulator_set_current(struct udevice *dev, int uA)
132{
133 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
Keerthyce152be2016-10-26 13:42:32 +0530134 struct dm_regulator_uclass_platdata *uc_pdata;
135
136 uc_pdata = dev_get_uclass_platdata(dev);
137 if (uc_pdata->min_uA != -ENODATA && uA < uc_pdata->min_uA)
138 return -EINVAL;
139 if (uc_pdata->max_uA != -ENODATA && uA > uc_pdata->max_uA)
140 return -EINVAL;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200141
142 if (!ops || !ops->set_current)
143 return -ENOSYS;
144
145 return ops->set_current(dev, uA);
146}
147
Keerthy23be7fb2017-06-13 09:53:45 +0530148int regulator_get_enable(struct udevice *dev)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200149{
150 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
151
152 if (!ops || !ops->get_enable)
153 return -ENOSYS;
154
155 return ops->get_enable(dev);
156}
157
158int regulator_set_enable(struct udevice *dev, bool enable)
159{
160 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
Patrick Delaunayd7585f22018-11-15 13:45:31 +0100161 struct dm_regulator_uclass_platdata *uc_pdata;
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +0100162 int ret, old_enable = 0;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200163
164 if (!ops || !ops->set_enable)
165 return -ENOSYS;
166
Patrick Delaunayd7585f22018-11-15 13:45:31 +0100167 uc_pdata = dev_get_uclass_platdata(dev);
168 if (!enable && uc_pdata->always_on)
Lokesh Vutlaf870da22019-01-11 15:15:50 +0530169 return -EACCES;
Patrick Delaunayd7585f22018-11-15 13:45:31 +0100170
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +0100171 if (uc_pdata->ramp_delay)
172 old_enable = regulator_get_enable(dev);
173
174 ret = ops->set_enable(dev, enable);
175 if (!ret) {
176 if (uc_pdata->ramp_delay && !old_enable && enable) {
177 int uV = regulator_get_value(dev);
178
179 if (uV > 0) {
180 regulator_set_value_ramp_delay(dev, 0, uV,
181 uc_pdata->ramp_delay);
182 }
183 }
184 }
185
186 return ret;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200187}
188
Lokesh Vutla7106b782019-01-11 15:15:51 +0530189int regulator_set_enable_if_allowed(struct udevice *dev, bool enable)
190{
191 int ret;
192
193 ret = regulator_set_enable(dev, enable);
194 if (ret == -ENOSYS || ret == -EACCES)
195 return 0;
196
197 return ret;
198}
199
Joseph Chenbb511322019-09-26 15:43:52 +0800200int regulator_set_suspend_enable(struct udevice *dev, bool enable)
201{
202 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
203
204 if (!ops->set_suspend_enable)
205 return -ENOSYS;
206
207 return ops->set_suspend_enable(dev, enable);
208}
209
210int regulator_get_suspend_enable(struct udevice *dev)
211{
212 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
213
214 if (!ops->get_suspend_enable)
215 return -ENOSYS;
216
217 return ops->get_suspend_enable(dev);
218}
219
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200220int regulator_get_mode(struct udevice *dev)
221{
222 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
223
224 if (!ops || !ops->get_mode)
225 return -ENOSYS;
226
227 return ops->get_mode(dev);
228}
229
230int regulator_set_mode(struct udevice *dev, int mode)
231{
232 const struct dm_regulator_ops *ops = dev_get_driver_ops(dev);
233
234 if (!ops || !ops->set_mode)
235 return -ENOSYS;
236
237 return ops->set_mode(dev, mode);
238}
239
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200240int regulator_get_by_platname(const char *plat_name, struct udevice **devp)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200241{
242 struct dm_regulator_uclass_platdata *uc_pdata;
243 struct udevice *dev;
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200244 int ret;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200245
246 *devp = NULL;
247
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200248 for (ret = uclass_find_first_device(UCLASS_REGULATOR, &dev); dev;
249 ret = uclass_find_next_device(&dev)) {
Simon Glassfc3ebf12017-05-31 17:57:15 -0600250 if (ret) {
251 debug("regulator %s, ret=%d\n", dev->name, ret);
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200252 continue;
Simon Glassfc3ebf12017-05-31 17:57:15 -0600253 }
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200254
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200255 uc_pdata = dev_get_uclass_platdata(dev);
256 if (!uc_pdata || strcmp(plat_name, uc_pdata->name))
257 continue;
258
259 return uclass_get_device_tail(dev, 0, devp);
260 }
261
Simon Glassfc3ebf12017-05-31 17:57:15 -0600262 debug("%s: can't find: %s, ret=%d\n", __func__, plat_name, ret);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200263
264 return -ENODEV;
265}
266
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200267int regulator_get_by_devname(const char *devname, struct udevice **devp)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200268{
269 return uclass_get_device_by_name(UCLASS_REGULATOR, devname, devp);
270}
271
Przemyslaw Marczakc9001032015-10-27 13:07:59 +0100272int device_get_supply_regulator(struct udevice *dev, const char *supply_name,
273 struct udevice **devp)
274{
275 return uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
276 supply_name, devp);
277}
278
Simon Glass46cb8242015-06-23 15:38:58 -0600279int regulator_autoset(struct udevice *dev)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200280{
Simon Glass46cb8242015-06-23 15:38:58 -0600281 struct dm_regulator_uclass_platdata *uc_pdata;
282 int ret = 0;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200283
Simon Glass46cb8242015-06-23 15:38:58 -0600284 uc_pdata = dev_get_uclass_platdata(dev);
Joseph Chenbb511322019-09-26 15:43:52 +0800285
286 ret = regulator_set_suspend_enable(dev, uc_pdata->suspend_on);
287 if (!ret && uc_pdata->suspend_on) {
288 ret = regulator_set_suspend_value(dev, uc_pdata->suspend_uV);
289 if (!ret)
290 return ret;
291 }
292
Simon Glass46cb8242015-06-23 15:38:58 -0600293 if (!uc_pdata->always_on && !uc_pdata->boot_on)
294 return -EMEDIUMTYPE;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200295
Sven Schwermerd033cbf2019-06-12 08:32:38 +0200296 if (uc_pdata->type == REGULATOR_TYPE_FIXED)
297 return regulator_set_enable(dev, true);
298
Simon Glass46cb8242015-06-23 15:38:58 -0600299 if (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UV)
300 ret = regulator_set_value(dev, uc_pdata->min_uV);
Joseph Chenbb511322019-09-26 15:43:52 +0800301 if (uc_pdata->init_uV > 0)
302 ret = regulator_set_value(dev, uc_pdata->init_uV);
Simon Glass46cb8242015-06-23 15:38:58 -0600303 if (!ret && (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UA))
304 ret = regulator_set_current(dev, uc_pdata->min_uA);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200305
306 if (!ret)
Simon Glass46cb8242015-06-23 15:38:58 -0600307 ret = regulator_set_enable(dev, true);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200308
309 return ret;
310}
311
Simon Glass46cb8242015-06-23 15:38:58 -0600312static void regulator_show(struct udevice *dev, int ret)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200313{
314 struct dm_regulator_uclass_platdata *uc_pdata;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200315
316 uc_pdata = dev_get_uclass_platdata(dev);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200317
Simon Glass46cb8242015-06-23 15:38:58 -0600318 printf("%s@%s: ", dev->name, uc_pdata->name);
319 if (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UV)
320 printf("set %d uV", uc_pdata->min_uV);
321 if (uc_pdata->flags & REGULATOR_FLAG_AUTOSET_UA)
322 printf("; set %d uA", uc_pdata->min_uA);
323 printf("; enabling");
324 if (ret)
Simon Glass46ad8cb2016-01-21 19:43:58 -0700325 printf(" (ret: %d)", ret);
Simon Glass46cb8242015-06-23 15:38:58 -0600326 printf("\n");
327}
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200328
Simon Glass46cb8242015-06-23 15:38:58 -0600329int regulator_autoset_by_name(const char *platname, struct udevice **devp)
330{
331 struct udevice *dev;
332 int ret;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200333
Simon Glass46cb8242015-06-23 15:38:58 -0600334 ret = regulator_get_by_platname(platname, &dev);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200335 if (devp)
336 *devp = dev;
Simon Glass46cb8242015-06-23 15:38:58 -0600337 if (ret) {
Simon Glassfc3ebf12017-05-31 17:57:15 -0600338 debug("Can get the regulator: %s (err=%d)\n", platname, ret);
Simon Glass46cb8242015-06-23 15:38:58 -0600339 return ret;
340 }
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200341
Simon Glass46cb8242015-06-23 15:38:58 -0600342 return regulator_autoset(dev);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200343}
344
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200345int regulator_list_autoset(const char *list_platname[],
346 struct udevice *list_devp[],
347 bool verbose)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200348{
349 struct udevice *dev;
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200350 int error = 0, i = 0, ret;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200351
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200352 while (list_platname[i]) {
Simon Glass46cb8242015-06-23 15:38:58 -0600353 ret = regulator_autoset_by_name(list_platname[i], &dev);
354 if (ret != -EMEDIUMTYPE && verbose)
355 regulator_show(dev, ret);
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200356 if (ret & !error)
357 error = ret;
358
359 if (list_devp)
360 list_devp[i] = dev;
361
362 i++;
363 }
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200364
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200365 return error;
366}
367
368static bool regulator_name_is_unique(struct udevice *check_dev,
369 const char *check_name)
370{
371 struct dm_regulator_uclass_platdata *uc_pdata;
372 struct udevice *dev;
373 int check_len = strlen(check_name);
374 int ret;
375 int len;
376
377 for (ret = uclass_find_first_device(UCLASS_REGULATOR, &dev); dev;
378 ret = uclass_find_next_device(&dev)) {
379 if (ret || dev == check_dev)
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200380 continue;
381
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200382 uc_pdata = dev_get_uclass_platdata(dev);
383 len = strlen(uc_pdata->name);
384 if (len != check_len)
385 continue;
386
387 if (!strcmp(uc_pdata->name, check_name))
388 return false;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200389 }
390
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200391 return true;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200392}
393
394static int regulator_post_bind(struct udevice *dev)
395{
396 struct dm_regulator_uclass_platdata *uc_pdata;
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200397 const char *property = "regulator-name";
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200398
399 uc_pdata = dev_get_uclass_platdata(dev);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200400
401 /* Regulator's mandatory constraint */
Simon Glasseeb99de2017-05-18 20:09:34 -0600402 uc_pdata->name = dev_read_string(dev, property);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200403 if (!uc_pdata->name) {
Simon Glasseeb99de2017-05-18 20:09:34 -0600404 debug("%s: dev '%s' has no property '%s'\n",
405 __func__, dev->name, property);
406 uc_pdata->name = dev_read_name(dev);
Peng Fancd672d42015-08-07 16:43:42 +0800407 if (!uc_pdata->name)
408 return -EINVAL;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200409 }
410
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200411 if (regulator_name_is_unique(dev, uc_pdata->name))
412 return 0;
413
Simon Glasseeb99de2017-05-18 20:09:34 -0600414 debug("'%s' of dev: '%s', has nonunique value: '%s\n",
Przemyslaw Marczak75692a32015-05-13 13:38:27 +0200415 property, dev->name, uc_pdata->name);
416
417 return -EINVAL;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200418}
419
420static int regulator_pre_probe(struct udevice *dev)
421{
422 struct dm_regulator_uclass_platdata *uc_pdata;
Joseph Chenbb511322019-09-26 15:43:52 +0800423 ofnode node;
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200424
425 uc_pdata = dev_get_uclass_platdata(dev);
426 if (!uc_pdata)
427 return -ENXIO;
428
429 /* Regulator's optional constraints */
Simon Glasseeb99de2017-05-18 20:09:34 -0600430 uc_pdata->min_uV = dev_read_u32_default(dev, "regulator-min-microvolt",
431 -ENODATA);
432 uc_pdata->max_uV = dev_read_u32_default(dev, "regulator-max-microvolt",
433 -ENODATA);
Joseph Chenbb511322019-09-26 15:43:52 +0800434 uc_pdata->init_uV = dev_read_u32_default(dev, "regulator-init-microvolt",
435 -ENODATA);
Simon Glasseeb99de2017-05-18 20:09:34 -0600436 uc_pdata->min_uA = dev_read_u32_default(dev, "regulator-min-microamp",
437 -ENODATA);
438 uc_pdata->max_uA = dev_read_u32_default(dev, "regulator-max-microamp",
439 -ENODATA);
440 uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on");
441 uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on");
Krzysztof Kozlowskie2fa3972019-03-06 19:37:54 +0100442 uc_pdata->ramp_delay = dev_read_u32_default(dev, "regulator-ramp-delay",
443 0);
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200444
Joseph Chenbb511322019-09-26 15:43:52 +0800445 node = dev_read_subnode(dev, "regulator-state-mem");
446 if (ofnode_valid(node)) {
447 uc_pdata->suspend_on = !ofnode_read_bool(node, "regulator-off-in-suspend");
448 if (ofnode_read_u32(node, "regulator-suspend-microvolt", &uc_pdata->suspend_uV))
449 uc_pdata->suspend_uV = uc_pdata->max_uV;
450 } else {
451 uc_pdata->suspend_on = true;
452 uc_pdata->suspend_uV = uc_pdata->max_uV;
453 }
454
Simon Glass991f9bc2015-06-23 15:38:57 -0600455 /* Those values are optional (-ENODATA if unset) */
456 if ((uc_pdata->min_uV != -ENODATA) &&
457 (uc_pdata->max_uV != -ENODATA) &&
458 (uc_pdata->min_uV == uc_pdata->max_uV))
459 uc_pdata->flags |= REGULATOR_FLAG_AUTOSET_UV;
460
461 /* Those values are optional (-ENODATA if unset) */
462 if ((uc_pdata->min_uA != -ENODATA) &&
463 (uc_pdata->max_uA != -ENODATA) &&
464 (uc_pdata->min_uA == uc_pdata->max_uA))
465 uc_pdata->flags |= REGULATOR_FLAG_AUTOSET_UA;
466
Lukasz Majewski8460a6b2020-01-25 09:00:58 +0100467 if (uc_pdata->boot_on)
468 regulator_set_enable(dev, uc_pdata->boot_on);
469
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200470 return 0;
471}
472
Simon Glassefeeb2c2015-06-23 15:38:59 -0600473int regulators_enable_boot_on(bool verbose)
474{
475 struct udevice *dev;
476 struct uclass *uc;
477 int ret;
478
479 ret = uclass_get(UCLASS_REGULATOR, &uc);
480 if (ret)
481 return ret;
482 for (uclass_first_device(UCLASS_REGULATOR, &dev);
Simon Glassc7298e72016-02-11 13:23:26 -0700483 dev;
Simon Glassefeeb2c2015-06-23 15:38:59 -0600484 uclass_next_device(&dev)) {
485 ret = regulator_autoset(dev);
Simon Glassf55c9512015-07-02 18:16:06 -0600486 if (ret == -EMEDIUMTYPE) {
487 ret = 0;
Simon Glassefeeb2c2015-06-23 15:38:59 -0600488 continue;
Simon Glassf55c9512015-07-02 18:16:06 -0600489 }
Simon Glassefeeb2c2015-06-23 15:38:59 -0600490 if (verbose)
491 regulator_show(dev, ret);
Simon Glassd6eddad2016-01-21 19:43:59 -0700492 if (ret == -ENOSYS)
493 ret = 0;
Simon Glassefeeb2c2015-06-23 15:38:59 -0600494 }
495
496 return ret;
497}
498
Przemyslaw Marczak08edd002015-04-20 20:07:42 +0200499UCLASS_DRIVER(regulator) = {
500 .id = UCLASS_REGULATOR,
501 .name = "regulator",
502 .post_bind = regulator_post_bind,
503 .pre_probe = regulator_pre_probe,
504 .per_device_platdata_auto_alloc_size =
505 sizeof(struct dm_regulator_uclass_platdata),
506};