From mboxrd@z Thu Jan 1 00:00:00 1970
From: Przemyslaw Marczak
Date: Wed, 01 Jul 2015 11:44:16 +0200
Subject: [U-Boot] [PATCH v3 35/54] dm: power: Add regulator flags to
centralise auto-set logic
In-Reply-To: <1435095556-15924-36-git-send-email-sjg@chromium.org>
References: <1435095556-15924-1-git-send-email-sjg@chromium.org>
<1435095556-15924-36-git-send-email-sjg@chromium.org>
Message-ID: <5593B670.4000301@samsung.com>
List-Id:
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
To: u-boot@lists.denx.de
Hello Simon,
On 06/23/2015 11:38 PM, Simon Glass wrote:
> 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
> ---
>
> Changes in v3: None
> Changes in v2: None
>
> drivers/power/regulator/regulator-uclass.c | 12 ++++++++++++
> include/power/regulator.h | 8 ++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
> index 31ffd44..0f1ca77 100644
> --- a/drivers/power/regulator/regulator-uclass.c
> +++ b/drivers/power/regulator/regulator-uclass.c
> @@ -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;
> }
>
> diff --git a/include/power/regulator.h b/include/power/regulator.h
> index 03a2cef..79ce0a4 100644
> --- a/include/power/regulator.h
> +++ b/include/power/regulator.h
> @@ -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 at 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 */
>
Tested on:
- Odroid U3 (odroid_defconfig)
- Sandbox - ut pmic/regulator
Tested-by: Przemyslaw Marczak
Acked-by: Przemyslaw Marczak
Best regards,
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com