]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
dm: power: Add regulator flags to centralise auto-set logic
authorSimon Glass <sjg@chromium.org>
Tue, 23 Jun 2015 21:38:57 +0000 (15:38 -0600)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Sep 2015 11:48:53 +0000 (13:48 +0200)
Decide when the regulator is set up whether we want to auto-set the voltage
or current. This avoids the complex logic spilling into the processing code.

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 31ffd44454cf30e5d0b51b3c57799b4c21a8e802..0f1ca774021f98896136385daa2e4a93f195b8e1 100644 (file)
@@ -319,6 +319,18 @@ static int regulator_pre_probe(struct udevice *dev)
        uc_pdata->boot_on = fdtdec_get_bool(gd->fdt_blob, offset,
                                            "regulator-boot-on");
 
+       /* Those values are optional (-ENODATA if unset) */
+       if ((uc_pdata->min_uV != -ENODATA) &&
+           (uc_pdata->max_uV != -ENODATA) &&
+           (uc_pdata->min_uV == uc_pdata->max_uV))
+               uc_pdata->flags |= REGULATOR_FLAG_AUTOSET_UV;
+
+       /* Those values are optional (-ENODATA if unset) */
+       if ((uc_pdata->min_uA != -ENODATA) &&
+           (uc_pdata->max_uA != -ENODATA) &&
+           (uc_pdata->min_uA == uc_pdata->max_uA))
+               uc_pdata->flags |= REGULATOR_FLAG_AUTOSET_UA;
+
        return 0;
 }
 
index 03a2cefcd61bc4a56d7070d9756c41623b6244a3..79ce0a4183255af23a9b1ad26a5c04214cabd9dc 100644 (file)
@@ -128,6 +128,11 @@ struct dm_regulator_mode {
        const char *name;
 };
 
+enum regulator_flag {
+       REGULATOR_FLAG_AUTOSET_UV       = 1 << 0,
+       REGULATOR_FLAG_AUTOSET_UA       = 1 << 1,
+};
+
 /**
  * struct dm_regulator_uclass_platdata - pointed by dev->uclass_platdata, and
  * allocated on each regulator bind. This structure holds an information
@@ -143,6 +148,8 @@ struct dm_regulator_mode {
  * @max_uA*    - maximum amperage (micro Amps)
  * @always_on* - bool type, true or false
  * @boot_on*   - bool type, true or false
+ * TODO(sjg@chromium.org): Consider putting the above two into @flags
+ * @flags:     - flags value (see REGULATOR_FLAG_...)
  * @name**     - fdt regulator name - should be taken from the device tree
  *
  * Note:
@@ -162,6 +169,7 @@ struct dm_regulator_uclass_platdata {
        bool always_on;
        bool boot_on;
        const char *name;
+       int flags;
 };
 
 /* Regulator device operations */