All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs
@ 2017-05-16 15:31 Charles Keepax
       [not found] ` <1494948714-15203-1-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
  2017-05-16 15:31 ` [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag Charles Keepax
  0 siblings, 2 replies; 13+ messages in thread
From: Charles Keepax @ 2017-05-16 15:31 UTC (permalink / raw)
  To: linus.walleij
  Cc: lee.jones, robh+dt, mark.rutland, gnurou, linux-gpio, devicetree,
	patches

Add new flags to allow users to specify that they are not concerned with
the status of GPIOs whilst in a sleep/low power state.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 include/dt-bindings/gpio/gpio.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h
index b4f54da..48c28f0 100644
--- a/include/dt-bindings/gpio/gpio.h
+++ b/include/dt-bindings/gpio/gpio.h
@@ -21,6 +21,10 @@
 #define GPIO_LINE_OPEN_SOURCE 0
 #define GPIO_LINE_OPEN_DRAIN 4
 
+/* Bit 3 express GPIO suspend/resume persistence */
+#define GPIO_SLEEP_MAINTAIN_VALUE 0
+#define GPIO_SLEEP_MAY_LOOSE_VALUE 8
+
 /*
  * Open Drain/Collector is the combination of single-ended open drain interface.
  * Open Source/Emitter is the combination of single-ended open source interface.
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/3] gpio: arizona: Add support for GPIOs that need to be maintained
       [not found] ` <1494948714-15203-1-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
@ 2017-05-16 15:31   ` Charles Keepax
  2017-05-23  8:46     ` Linus Walleij
  2017-05-23  8:39   ` [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs Linus Walleij
  1 sibling, 1 reply; 13+ messages in thread
From: Charles Keepax @ 2017-05-16 15:31 UTC (permalink / raw)
  To: linus.walleij-QSEj5FYQhm4dnm+yROfE0A
  Cc: lee.jones-QSEj5FYQhm4dnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	mark.rutland-5wv7dgnIgG8, gnurou-Re5JQEeQqe8AvxtiuMwx3w,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E

The Arizona devices only maintain the state of output GPIOs whilst the
CODEC is active, this can cause issues if the CODEC suspends whilst
something is relying on the state of one of its GPIOs. However, in
many systems the CODEC GPIOs are used for audio related features
and thus the state of the GPIOs is unimportant whilst the CODEC is
suspended. Often keeping the CODEC resumed in such a system would
incur a power impact that is unacceptable.

Allow the user to select whether a GPIO output should keep the
CODEC resumed, by adding a flag through the second cell of the GPIO
specifier in device tree.

Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
---
 drivers/gpio/gpio-arizona.c | 59 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c
index cd23fd7..2d86776 100644
--- a/drivers/gpio/gpio-arizona.c
+++ b/drivers/gpio/gpio-arizona.c
@@ -12,10 +12,12 @@
  *
  */
 
+#include <dt-bindings/gpio/gpio.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/seq_file.h>
@@ -27,15 +29,30 @@
 struct arizona_gpio {
 	struct arizona *arizona;
 	struct gpio_chip gpio_chip;
+	int status[ARIZONA_MAX_GPIO];
 };
 
 static int arizona_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
 {
 	struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
 	struct arizona *arizona = arizona_gpio->arizona;
+	int status = arizona_gpio->status[offset];
+	bool change;
+	int ret;
 
-	return regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset,
-				  ARIZONA_GPN_DIR, ARIZONA_GPN_DIR);
+	ret = regmap_update_bits_check(arizona->regmap,
+				       ARIZONA_GPIO1_CTRL + offset,
+				       ARIZONA_GPN_DIR, ARIZONA_GPN_DIR,
+				       &change);
+	if (ret < 0)
+		return ret;
+
+	if (change && !(status & GPIO_SLEEP_MAY_LOOSE_VALUE)) {
+		pm_runtime_mark_last_busy(chip->parent);
+		pm_runtime_put_autosuspend(chip->parent);
+	}
+
+	return 0;
 }
 
 static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -85,6 +102,21 @@ static int arizona_gpio_direction_out(struct gpio_chip *chip,
 {
 	struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
 	struct arizona *arizona = arizona_gpio->arizona;
+	int status = arizona_gpio->status[offset];
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, &val);
+	if (ret < 0)
+		return ret;
+
+	if ((val & ARIZONA_GPN_DIR) && !(status & GPIO_SLEEP_MAY_LOOSE_VALUE)) {
+		ret = pm_runtime_get_sync(chip->parent);
+		if (ret < 0) {
+			dev_err(chip->parent, "Failed to resume: %d\n", ret);
+			return ret;
+		}
+	}
 
 	if (value)
 		value = ARIZONA_GPN_LVL;
@@ -105,6 +137,25 @@ static void arizona_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 			   ARIZONA_GPN_LVL, value);
 }
 
+#ifdef CONFIG_OF_GPIO
+static int arizona_gpio_of_xlate(struct gpio_chip *chip,
+				 const struct of_phandle_args *gpiospec,
+				 u32 *flags)
+{
+	struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
+	int offset;
+
+	offset = of_gpio_simple_xlate(chip, gpiospec, flags);
+	if (offset < 0)
+		return offset;
+
+	if (flags)
+		arizona_gpio->status[offset] = *flags;
+
+	return offset;
+}
+#endif
+
 static const struct gpio_chip template_chip = {
 	.label			= "arizona",
 	.owner			= THIS_MODULE,
@@ -132,6 +183,8 @@ static int arizona_gpio_probe(struct platform_device *pdev)
 	arizona_gpio->gpio_chip.parent = &pdev->dev;
 #ifdef CONFIG_OF_GPIO
 	arizona_gpio->gpio_chip.of_node = arizona->dev->of_node;
+	arizona_gpio->gpio_chip.of_xlate = arizona_gpio_of_xlate;
+	arizona_gpio->gpio_chip.of_gpio_n_cells = 2;
 #endif
 
 	switch (arizona->type) {
@@ -158,6 +211,8 @@ static int arizona_gpio_probe(struct platform_device *pdev)
 	else
 		arizona_gpio->gpio_chip.base = -1;
 
+	pm_runtime_enable(&pdev->dev);
+
 	ret = devm_gpiochip_add_data(&pdev->dev, &arizona_gpio->gpio_chip,
 				     arizona_gpio);
 	if (ret < 0) {
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag
  2017-05-16 15:31 [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs Charles Keepax
       [not found] ` <1494948714-15203-1-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
@ 2017-05-16 15:31 ` Charles Keepax
  2017-05-23  0:16   ` Rob Herring
       [not found]   ` <1494948714-15203-3-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
  1 sibling, 2 replies; 13+ messages in thread
From: Charles Keepax @ 2017-05-16 15:31 UTC (permalink / raw)
  To: linus.walleij
  Cc: lee.jones, robh+dt, mark.rutland, gnurou, linux-gpio, devicetree,
	patches

Update the device tree binding to show that the new GPIO_SLEEP flags are
now supported in the flags field of the GPIO binding for Arizona
devices.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 Documentation/devicetree/bindings/mfd/arizona.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 8f2e282..1729133 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -30,7 +30,10 @@ Required properties:
 
   - gpio-controller : Indicates this device is a GPIO controller.
   - #gpio-cells : Must be 2. The first cell is the pin number and the
-    second cell is used to specify optional parameters (currently unused).
+    second cell is used to specify optional parameters, the following flags
+    are supported:
+      "GPIO_SLEEP_MAY_LOOSE_OUTPUT" the output of this GPIO does not need to
+      be maintained whilst the CODEC is in low power mode.
 
   - AVDD-supply, DBVDD1-supply, CPVDD-supply : Power supplies for the device,
     as covered in Documentation/devicetree/bindings/regulator/regulator.txt
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag
       [not found]   ` <1494948714-15203-3-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
@ 2017-05-22 11:07     ` Lee Jones
  2017-05-22 11:07       ` Lee Jones
  2017-05-23  8:49     ` Linus Walleij
  1 sibling, 1 reply; 13+ messages in thread
From: Lee Jones @ 2017-05-22 11:07 UTC (permalink / raw)
  To: Charles Keepax
  Cc: linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	gnurou-Re5JQEeQqe8AvxtiuMwx3w, linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E

On Tue, 16 May 2017, Charles Keepax wrote:

> Update the device tree binding to show that the new GPIO_SLEEP flags are
> now supported in the flags field of the GPIO binding for Arizona
> devices.
> 
> Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> index 8f2e282..1729133 100644
> --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> @@ -30,7 +30,10 @@ Required properties:
>  
>    - gpio-controller : Indicates this device is a GPIO controller.
>    - #gpio-cells : Must be 2. The first cell is the pin number and the
> -    second cell is used to specify optional parameters (currently unused).
> +    second cell is used to specify optional parameters, the following flags
> +    are supported:
> +      "GPIO_SLEEP_MAY_LOOSE_OUTPUT" the output of this GPIO does not need to
> +      be maintained whilst the CODEC is in low power mode.

I guess this needs a GPIO and DT Ack.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag
  2017-05-22 11:07     ` Lee Jones
@ 2017-05-22 11:07       ` Lee Jones
  0 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2017-05-22 11:07 UTC (permalink / raw)
  To: Charles Keepax
  Cc: linus.walleij, robh+dt, mark.rutland, gnurou, linux-gpio,
	devicetree, patches

On Mon, 22 May 2017, Lee Jones wrote:

> On Tue, 16 May 2017, Charles Keepax wrote:
> 
> > Update the device tree binding to show that the new GPIO_SLEEP flags are
> > now supported in the flags field of the GPIO binding for Arizona
> > devices.
> > 
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> > ---
> >  Documentation/devicetree/bindings/mfd/arizona.txt | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> > index 8f2e282..1729133 100644
> > --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> > +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> > @@ -30,7 +30,10 @@ Required properties:
> >  
> >    - gpio-controller : Indicates this device is a GPIO controller.
> >    - #gpio-cells : Must be 2. The first cell is the pin number and the
> > -    second cell is used to specify optional parameters (currently unused).
> > +    second cell is used to specify optional parameters, the following flags
> > +    are supported:
> > +      "GPIO_SLEEP_MAY_LOOSE_OUTPUT" the output of this GPIO does not need to
> > +      be maintained whilst the CODEC is in low power mode.
> 
> I guess this needs a GPIO and DT Ack.

FYI, if you receive both of those, you can also add mine without any
further intervention from me.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag
  2017-05-16 15:31 ` [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag Charles Keepax
@ 2017-05-23  0:16   ` Rob Herring
       [not found]   ` <1494948714-15203-3-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Rob Herring @ 2017-05-23  0:16 UTC (permalink / raw)
  To: Charles Keepax
  Cc: linus.walleij, lee.jones, mark.rutland, gnurou, linux-gpio,
	devicetree, patches

On Tue, May 16, 2017 at 04:31:54PM +0100, Charles Keepax wrote:
> Update the device tree binding to show that the new GPIO_SLEEP flags are
> now supported in the flags field of the GPIO binding for Arizona
> devices.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs
       [not found] ` <1494948714-15203-1-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
  2017-05-16 15:31   ` [PATCH 2/3] gpio: arizona: Add support for GPIOs that need to be maintained Charles Keepax
@ 2017-05-23  8:39   ` Linus Walleij
       [not found]     ` <CACRpkdbiyZ9jPnuaX9OuYjVbrUYxtpqO-XMqb75ScCEH-=kOEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 13+ messages in thread
From: Linus Walleij @ 2017-05-23  8:39 UTC (permalink / raw)
  To: Charles Keepax
  Cc: Lee Jones, Rob Herring, Mark Rutland, Alexandre Courbot,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	open list:WOLFSON MICROELECTRONICS DRIVERS

On Tue, May 16, 2017 at 5:31 PM, Charles Keepax
<ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> wrote:

> Add new flags to allow users to specify that they are not concerned with
> the status of GPIOs whilst in a sleep/low power state.
>
> Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>

Would be nice to have some opinion from the DT maintainers about
this but seems all right to me.

> +++ b/include/dt-bindings/gpio/gpio.h
> @@ -21,6 +21,10 @@
>  #define GPIO_LINE_OPEN_SOURCE 0
>  #define GPIO_LINE_OPEN_DRAIN 4
>
> +/* Bit 3 express GPIO suspend/resume persistence */
> +#define GPIO_SLEEP_MAINTAIN_VALUE 0
> +#define GPIO_SLEEP_MAY_LOOSE_VALUE 8
> +
>  /*
>   * Open Drain/Collector is the combination of single-ended open drain interface.
>   * Open Source/Emitter is the combination of single-ended open source interface.

Please move the define below the comment and macros below it,
that is using the defines right above...

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/3] gpio: arizona: Add support for GPIOs that need to be maintained
  2017-05-16 15:31   ` [PATCH 2/3] gpio: arizona: Add support for GPIOs that need to be maintained Charles Keepax
@ 2017-05-23  8:46     ` Linus Walleij
  2017-05-23  8:56       ` Charles Keepax
  0 siblings, 1 reply; 13+ messages in thread
From: Linus Walleij @ 2017-05-23  8:46 UTC (permalink / raw)
  To: Charles Keepax
  Cc: Lee Jones, Rob Herring, Mark Rutland, Alexandre Courbot,
	linux-gpio, devicetree,
	open list:WOLFSON MICROELECTRONICS DRIVERS

On Tue, May 16, 2017 at 5:31 PM, Charles Keepax
<ckeepax@opensource.wolfsonmicro.com> wrote:

> The Arizona devices only maintain the state of output GPIOs whilst the
> CODEC is active, this can cause issues if the CODEC suspends whilst
> something is relying on the state of one of its GPIOs. However, in
> many systems the CODEC GPIOs are used for audio related features
> and thus the state of the GPIOs is unimportant whilst the CODEC is
> suspended. Often keeping the CODEC resumed in such a system would
> incur a power impact that is unacceptable.
>
> Allow the user to select whether a GPIO output should keep the
> CODEC resumed, by adding a flag through the second cell of the GPIO
> specifier in device tree.
>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

This adds the handling locally in the driver for a certain Arizona chip.

And then the next time you have to duplicate the code again and again.

That's not working, put this in the core.

>  static int arizona_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
>  {
>         struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
>         struct arizona *arizona = arizona_gpio->arizona;
> +       int status = arizona_gpio->status[offset];

Don't use a local array for this.

This should be something like gpiochip_get_sleep_persistance(chip, offset)

> +       if (change && !(status & GPIO_SLEEP_MAY_LOOSE_VALUE)) {

That us a dt-binfings header define, that is not a Linux constant.

Add FLAG_MAY_LOOSE_VALUE_DURING_SLEEP or something in
drivers/gpio/gpiolib.h, store this inside the struct gpio_desc like all
other flags and retrieve it from there.

Augment the code in gpiolib.c and gpiolib-of.c to parse this and
store it properly in the gpio_desc and use it as described above.

Then it is reusable for others.

> +#ifdef CONFIG_OF_GPIO
> +static int arizona_gpio_of_xlate(struct gpio_chip *chip,
> +                                const struct of_phandle_args *gpiospec,
> +                                u32 *flags)
> +{
> +       struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
> +       int offset;
> +
> +       offset = of_gpio_simple_xlate(chip, gpiospec, flags);
> +       if (offset < 0)
> +               return offset;
> +
> +       if (flags)
> +               arizona_gpio->status[offset] = *flags;
> +
> +       return offset;
> +}
> +#endif

No need for this hackery if you move the parsing to the core, so do that.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag
       [not found]   ` <1494948714-15203-3-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
  2017-05-22 11:07     ` Lee Jones
@ 2017-05-23  8:49     ` Linus Walleij
  2017-05-23  9:00       ` Charles Keepax
  1 sibling, 1 reply; 13+ messages in thread
From: Linus Walleij @ 2017-05-23  8:49 UTC (permalink / raw)
  To: Charles Keepax
  Cc: Lee Jones, Rob Herring, Mark Rutland, Alexandre Courbot,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	open list:WOLFSON MICROELECTRONICS DRIVERS

On Tue, May 16, 2017 at 5:31 PM, Charles Keepax
<ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> wrote:

> Update the device tree binding to show that the new GPIO_SLEEP flags are
> now supported in the flags field of the GPIO binding for Arizona
> devices.
>
> Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
(...)
>    - gpio-controller : Indicates this device is a GPIO controller.
>    - #gpio-cells : Must be 2. The first cell is the pin number and the
> -    second cell is used to specify optional parameters (currently unused).
> +    second cell is used to specify optional parameters, the following flags
> +    are supported:
> +      "GPIO_SLEEP_MAY_LOOSE_OUTPUT" the output of this GPIO does not need to
> +      be maintained whilst the CODEC is in low power mode.

Your gpio controller most definately support more options than that,
for example open drain.

But it is supposed to be a generic property so instead patch gpio.txt
and reference that file from here.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs
       [not found]     ` <CACRpkdbiyZ9jPnuaX9OuYjVbrUYxtpqO-XMqb75ScCEH-=kOEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-05-23  8:51       ` Lee Jones
  2017-05-23 13:38         ` Rob Herring
  0 siblings, 1 reply; 13+ messages in thread
From: Lee Jones @ 2017-05-23  8:51 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Charles Keepax, Rob Herring, Mark Rutland, Alexandre Courbot,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	open list:WOLFSON MICROELECTRONICS DRIVERS

On Tue, 23 May 2017, Linus Walleij wrote:

> On Tue, May 16, 2017 at 5:31 PM, Charles Keepax
> <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> wrote:
> 
> > Add new flags to allow users to specify that they are not concerned with
> > the status of GPIOs whilst in a sleep/low power state.
> >
> > Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
> 
> Would be nice to have some opinion from the DT maintainers about
> this but seems all right to me.

Not sure if it makes a difference, but Rob Acked the bindings already.

> > +++ b/include/dt-bindings/gpio/gpio.h
> > @@ -21,6 +21,10 @@
> >  #define GPIO_LINE_OPEN_SOURCE 0
> >  #define GPIO_LINE_OPEN_DRAIN 4
> >
> > +/* Bit 3 express GPIO suspend/resume persistence */
> > +#define GPIO_SLEEP_MAINTAIN_VALUE 0
> > +#define GPIO_SLEEP_MAY_LOOSE_VALUE 8
> > +
> >  /*
> >   * Open Drain/Collector is the combination of single-ended open drain interface.
> >   * Open Source/Emitter is the combination of single-ended open source interface.
> 
> Please move the define below the comment and macros below it,
> that is using the defines right above...
> 
> Yours,
> Linus Walleij

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/3] gpio: arizona: Add support for GPIOs that need to be maintained
  2017-05-23  8:46     ` Linus Walleij
@ 2017-05-23  8:56       ` Charles Keepax
  0 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2017-05-23  8:56 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Lee Jones, Rob Herring, Mark Rutland, Alexandre Courbot,
	linux-gpio, devicetree,
	open list:WOLFSON MICROELECTRONICS DRIVERS

On Tue, May 23, 2017 at 10:46:29AM +0200, Linus Walleij wrote:
> On Tue, May 16, 2017 at 5:31 PM, Charles Keepax
> <ckeepax@opensource.wolfsonmicro.com> wrote:
> 
> > The Arizona devices only maintain the state of output GPIOs whilst the
> > CODEC is active, this can cause issues if the CODEC suspends whilst
> > something is relying on the state of one of its GPIOs. However, in
> > many systems the CODEC GPIOs are used for audio related features
> > and thus the state of the GPIOs is unimportant whilst the CODEC is
> > suspended. Often keeping the CODEC resumed in such a system would
> > incur a power impact that is unacceptable.
> >
> > Allow the user to select whether a GPIO output should keep the
> > CODEC resumed, by adding a flag through the second cell of the GPIO
> > specifier in device tree.
> >
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> 
> This adds the handling locally in the driver for a certain Arizona chip.
> 
> And then the next time you have to duplicate the code again and again.
> 
> That's not working, put this in the core.
> 
> >  static int arizona_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> >  {
> >         struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
> >         struct arizona *arizona = arizona_gpio->arizona;
> > +       int status = arizona_gpio->status[offset];
> 
> Don't use a local array for this.
> 
> This should be something like gpiochip_get_sleep_persistance(chip, offset)
> 
> > +       if (change && !(status & GPIO_SLEEP_MAY_LOOSE_VALUE)) {
> 
> That us a dt-binfings header define, that is not a Linux constant.
> 
> Add FLAG_MAY_LOOSE_VALUE_DURING_SLEEP or something in
> drivers/gpio/gpiolib.h, store this inside the struct gpio_desc like all
> other flags and retrieve it from there.
> 
> Augment the code in gpiolib.c and gpiolib-of.c to parse this and
> store it properly in the gpio_desc and use it as described above.
> 
> Then it is reusable for others.
> 

Apologies hadn't realised you wanted me to put so much of the
functionality into the core, will respin again.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag
  2017-05-23  8:49     ` Linus Walleij
@ 2017-05-23  9:00       ` Charles Keepax
  0 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2017-05-23  9:00 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Lee Jones, Rob Herring, Mark Rutland, Alexandre Courbot,
	linux-gpio, devicetree,
	open list:WOLFSON MICROELECTRONICS DRIVERS

On Tue, May 23, 2017 at 10:49:23AM +0200, Linus Walleij wrote:
> On Tue, May 16, 2017 at 5:31 PM, Charles Keepax
> <ckeepax@opensource.wolfsonmicro.com> wrote:
> 
> > Update the device tree binding to show that the new GPIO_SLEEP flags are
> > now supported in the flags field of the GPIO binding for Arizona
> > devices.
> >
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> (...)
> >    - gpio-controller : Indicates this device is a GPIO controller.
> >    - #gpio-cells : Must be 2. The first cell is the pin number and the
> > -    second cell is used to specify optional parameters (currently unused).
> > +    second cell is used to specify optional parameters, the following flags
> > +    are supported:
> > +      "GPIO_SLEEP_MAY_LOOSE_OUTPUT" the output of this GPIO does not need to
> > +      be maintained whilst the CODEC is in low power mode.
> 
> Your gpio controller most definately support more options than that,
> for example open drain.
> 

Not at the moment, there are potentially a few more things we
could support with the hardware though.

> But it is supposed to be a generic property so instead patch gpio.txt
> and reference that file from here.
> 

Yeah happy to move it over there.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs
  2017-05-23  8:51       ` Lee Jones
@ 2017-05-23 13:38         ` Rob Herring
  0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2017-05-23 13:38 UTC (permalink / raw)
  To: Lee Jones
  Cc: Linus Walleij, Charles Keepax, Mark Rutland, Alexandre Courbot,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	open list:WOLFSON MICROELECTRONICS DRIVERS

On Tue, May 23, 2017 at 3:51 AM, Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> On Tue, 23 May 2017, Linus Walleij wrote:
>
>> On Tue, May 16, 2017 at 5:31 PM, Charles Keepax
>> <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> wrote:
>>
>> > Add new flags to allow users to specify that they are not concerned with
>> > the status of GPIOs whilst in a sleep/low power state.
>> >
>> > Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
>>
>> Would be nice to have some opinion from the DT maintainers about
>> this but seems all right to me.
>
> Not sure if it makes a difference, but Rob Acked the bindings already.

Seems PW doesn't pick-up header only patches, so I missed this.

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-05-23 13:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 15:31 [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs Charles Keepax
     [not found] ` <1494948714-15203-1-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-05-16 15:31   ` [PATCH 2/3] gpio: arizona: Add support for GPIOs that need to be maintained Charles Keepax
2017-05-23  8:46     ` Linus Walleij
2017-05-23  8:56       ` Charles Keepax
2017-05-23  8:39   ` [PATCH 1/3] gpio: Add new flags to control sleep status of GPIOs Linus Walleij
     [not found]     ` <CACRpkdbiyZ9jPnuaX9OuYjVbrUYxtpqO-XMqb75ScCEH-=kOEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-23  8:51       ` Lee Jones
2017-05-23 13:38         ` Rob Herring
2017-05-16 15:31 ` [PATCH 3/3] mfd: arizona: Update GPIO binding for newly supported flag Charles Keepax
2017-05-23  0:16   ` Rob Herring
     [not found]   ` <1494948714-15203-3-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-05-22 11:07     ` Lee Jones
2017-05-22 11:07       ` Lee Jones
2017-05-23  8:49     ` Linus Walleij
2017-05-23  9:00       ` Charles Keepax

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.