]> git.sur5r.net Git - u-boot/commitdiff
dm: power: Add a function to set up all regulators
authorSimon Glass <sjg@chromium.org>
Tue, 23 Jun 2015 21:38:59 +0000 (15:38 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 21 Jul 2015 23:39:26 +0000 (17:39 -0600)
The device tree provides information about which regulators should be
on at boot, or always on. Use this to set them up automatically.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Przemyslaw Marczak <p.marczak@samsung.com>
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>
drivers/power/regulator/regulator-uclass.c
include/power/regulator.h

index 687d3b1e31b6574a8099a675b801113335c00671..a2d0b9fa8bd2cee923d66baa05fca3065328355d 100644 (file)
@@ -306,6 +306,28 @@ static int regulator_pre_probe(struct udevice *dev)
        return 0;
 }
 
+int regulators_enable_boot_on(bool verbose)
+{
+       struct udevice *dev;
+       struct uclass *uc;
+       int ret;
+
+       ret = uclass_get(UCLASS_REGULATOR, &uc);
+       if (ret)
+               return ret;
+       for (uclass_first_device(UCLASS_REGULATOR, &dev);
+            dev && !ret;
+            uclass_next_device(&dev)) {
+               ret = regulator_autoset(dev);
+               if (ret == -EMEDIUMTYPE)
+                       continue;
+               if (verbose)
+                       regulator_show(dev, ret);
+       }
+
+       return ret;
+}
+
 UCLASS_DRIVER(regulator) = {
        .id             = UCLASS_REGULATOR,
        .name           = "regulator",
index dd043711405c4ad24dad3c7ce7180364b512e720..015229027c874eeb860b91000eda11accf604e51 100644 (file)
@@ -315,6 +315,17 @@ int regulator_get_mode(struct udevice *dev);
  */
 int regulator_set_mode(struct udevice *dev, int mode_id);
 
+/**
+ * regulators_enable_boot_on() - enable regulators needed for boot
+ *
+ * This enables all regulators which are marked to be on at boot time. This
+ * only works for regulators which don't have a range for voltage/current,
+ * since in that case it is not possible to know which value to use.
+ *
+ * This effectively calls regulator_autoset() for every regulator.
+ */
+int regulators_enable_boot_on(bool verbose);
+
 /**
  * regulator_autoset: setup the voltage/current on a regulator
  *