diff mbox series

[U-Boot,V2] drivers: regulator: fixed: add u-boot, off-on-delay-us

Message ID 20180724081152.7536-1-peng.fan@nxp.com
State Rejected
Delegated to: Tom Rini
Headers show
Series [U-Boot,V2] drivers: regulator: fixed: add u-boot, off-on-delay-us | expand

Commit Message

Peng Fan July 24, 2018, 8:11 a.m. UTC
Add u-boot,off-on-delay-us for fixed regulator.

Depends on board design, the gpio regulator sometimes
connects with a big capacitance. When need to off, then
on the regulator, if there is no enough delay,
the voltage does not drop to 0, so introduce this
property to handle such case.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Simon Glass <sjg@chromium.org>
---

Simon, I droped your reviewed-by tag in V2, because I changed
"off-on-delay-us" to "u-boot,off-on-delay-us" and
add devicetree bindings.

Thanks,
Peng.

 .../devicetree/bindings/regulator/fixed-regulator.txt    | 16 ++++++++++++++++
 drivers/power/regulator/fixed.c                          |  6 ++++++
 2 files changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/fixed-regulator.txt

Comments

Simon Glass July 25, 2018, 2:45 a.m. UTC | #1
On 24 July 2018 at 02:11, Peng Fan <peng.fan@nxp.com> wrote:
> Add u-boot,off-on-delay-us for fixed regulator.
>
> Depends on board design, the gpio regulator sometimes
> connects with a big capacitance. When need to off, then
> on the regulator, if there is no enough delay,
> the voltage does not drop to 0, so introduce this
> property to handle such case.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>
> Simon, I droped your reviewed-by tag in V2, because I changed
> "off-on-delay-us" to "u-boot,off-on-delay-us" and
> add devicetree bindings.
>
> Thanks,
> Peng.
>
>  .../devicetree/bindings/regulator/fixed-regulator.txt    | 16 ++++++++++++++++
>  drivers/power/regulator/fixed.c                          |  6 ++++++
>  2 files changed, 22 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/regulator/fixed-regulator.txt

Reviewed-by: Simon Glass <sjg@chromium.org>
Fabio Estevam July 25, 2018, 2:59 a.m. UTC | #2
Hi Peng,

On Tue, Jul 24, 2018 at 5:11 AM, Peng Fan <peng.fan@nxp.com> wrote:

>  .../devicetree/bindings/regulator/fixed-regulator.txt    | 16 ++++++++++++++++
>  drivers/power/regulator/fixed.c                          |  6 ++++++
>  2 files changed, 22 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/regulator/fixed-regulator.txt

I thought that bindings should go into doc/device-tree-bindings/ in
U-Boot instead?
Peng Fan July 25, 2018, 3:02 a.m. UTC | #3
Hi Fabio,

> -----Original Message-----
> From: Fabio Estevam [mailto:festevam@gmail.com]
> Sent: 2018年7月25日 10:59
> To: Peng Fan <peng.fan@nxp.com>
> Cc: Simon Glass <sjg@chromium.org>; U-Boot-Denx <u-boot@lists.denx.de>;
> dl-linux-imx <linux-imx@nxp.com>; Breno Matheus Lima <breno.lima@nxp.com>
> Subject: Re: [U-Boot] [PATCH V2] drivers: regulator: fixed: add u-boot,
> off-on-delay-us
> 
> Hi Peng,
> 
> On Tue, Jul 24, 2018 at 5:11 AM, Peng Fan <peng.fan@nxp.com> wrote:
> 
> >  .../devicetree/bindings/regulator/fixed-regulator.txt    | 16
> ++++++++++++++++
> >  drivers/power/regulator/fixed.c                          |  6
> ++++++
> >  2 files changed, 22 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/regulator/fixed-regulator.txt
> 
> I thought that bindings should go into doc/device-tree-bindings/ in U-Boot
> instead?

I was not aware of this place. I am not sure, because there is also a Documentation/devicetree/bindings/ directory.

Tom,

Where should the new uboot bindings be put into?

Thanks,
Peng.
Fabio Estevam July 25, 2018, 3:08 a.m. UTC | #4
Hi Peng,

On Wed, Jul 25, 2018 at 12:02 AM, Peng Fan <peng.fan@nxp.com> wrote:

> I was not aware of this place. I am not sure, because there is also a Documentation/devicetree/bindings/ directory.

Yes, currently we have only a few bindings inside
Documentation/devicetree/bindings/.

Most of the bindings are inside doc/device-tree-bindings/ in U-Boot.

Breno has recently submitted a patch to move bindings to the more
common used doc/device-tree-bindings/ directory:
https://lists.denx.de/pipermail/u-boot/2018-July/335626.html

> Tom,
>
> Where should the new uboot bindings be put into?

Yes, some guidance here would be helpful to avoid inconsistent
placement of the bindings.

Thanks
Tom Rini July 25, 2018, 3:25 p.m. UTC | #5
On Wed, Jul 25, 2018 at 03:02:04AM +0000, Peng Fan wrote:
> Hi Fabio,
> 
> > -----Original Message-----
> > From: Fabio Estevam [mailto:festevam@gmail.com]
> > Sent: 2018年7月25日 10:59
> > To: Peng Fan <peng.fan@nxp.com>
> > Cc: Simon Glass <sjg@chromium.org>; U-Boot-Denx <u-boot@lists.denx.de>;
> > dl-linux-imx <linux-imx@nxp.com>; Breno Matheus Lima <breno.lima@nxp.com>
> > Subject: Re: [U-Boot] [PATCH V2] drivers: regulator: fixed: add u-boot,
> > off-on-delay-us
> > 
> > Hi Peng,
> > 
> > On Tue, Jul 24, 2018 at 5:11 AM, Peng Fan <peng.fan@nxp.com> wrote:
> > 
> > >  .../devicetree/bindings/regulator/fixed-regulator.txt    | 16
> > ++++++++++++++++
> > >  drivers/power/regulator/fixed.c                          |  6
> > ++++++
> > >  2 files changed, 22 insertions(+)
> > >  create mode 100644
> > > Documentation/devicetree/bindings/regulator/fixed-regulator.txt
> > 
> > I thought that bindings should go into doc/device-tree-bindings/ in U-Boot
> > instead?
> 
> I was not aware of this place. I am not sure, because there is also a
> Documentation/devicetree/bindings/ directory.
> 
> Tom,
> 
> Where should the new uboot bindings be put into?

I just yesterday consolidated into just doc/device-tree-bindings/ as
everything else was already in there.
Fabio Estevam July 26, 2018, 12:40 p.m. UTC | #6
Hi Tom,

On Wed, Jul 25, 2018 at 12:25 PM, Tom Rini <trini@konsulko.com> wrote:

> I just yesterday consolidated into just doc/device-tree-bindings/ as
> everything else was already in there.

Excellent, I saw that Breno's patch has been applied.

Thanks
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
new file mode 100644
index 0000000000..2b241cf563
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
@@ -0,0 +1,16 @@ 
+Fixed Voltage regulators
+
+Check Linux Kernel
+Documentation/devicetree/bindings/regulator/fixed-regulator.txt
+
+U-Boot Specific:
+Optional properties:
+- u-boot,off-on-delay-us: off delay time in microseconds
+
+Example:
+
+	abc: fixedregulator@0 {
+		...
+		u-boot,off-on-delay-us = <80000>;
+		...
+	};
diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index 0be5b7bd51..c5fe0ba43d 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -16,6 +16,7 @@ 
 struct fixed_regulator_platdata {
 	struct gpio_desc gpio; /* GPIO for regulator enable control */
 	unsigned int startup_delay_us;
+	unsigned int off_on_delay_us;
 };
 
 static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
@@ -50,6 +51,8 @@  static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
 	/* Get optional ramp up delay */
 	dev_pdata->startup_delay_us = dev_read_u32_default(dev,
 							"startup-delay-us", 0);
+	dev_pdata->off_on_delay_us = dev_read_u32_default(dev,
+							  "u-boot,off-on-delay-us", 0);
 
 	return 0;
 }
@@ -123,6 +126,9 @@  static int fixed_regulator_set_enable(struct udevice *dev, bool enable)
 		udelay(dev_pdata->startup_delay_us);
 	debug("%s: done\n", __func__);
 
+	if (!enable && dev_pdata->off_on_delay_us)
+		udelay(dev_pdata->off_on_delay_us);
+
 	return 0;
 }