devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mfd: arizona: Update reset pin to use GPIOD
@ 2018-02-14 15:55 Charles Keepax
  2018-02-14 15:55 ` [PATCH 2/2] mfd: arizona: Update DT doc to support more standard reset binding Charles Keepax
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Charles Keepax @ 2018-02-14 15:55 UTC (permalink / raw)
  To: lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	patches-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5

Now GPIOD has support for both pdata systems and for non-standard DT
bindings the Arizona reset GPIO can be converted to use it.

Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5@public.gmane.org>
---
 drivers/mfd/arizona-core.c        | 50 ++++++++++++++++++++++++++-------------
 include/linux/mfd/arizona/pdata.h |  3 ++-
 2 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 77875250abe5..50e35e90d42b 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -278,8 +278,7 @@ static int arizona_wait_for_boot(struct arizona *arizona)
 
 static inline void arizona_enable_reset(struct arizona *arizona)
 {
-	if (arizona->pdata.reset)
-		gpio_set_value_cansleep(arizona->pdata.reset, 0);
+	gpiod_set_value_cansleep(arizona->pdata.reset, 0);
 }
 
 static void arizona_disable_reset(struct arizona *arizona)
@@ -295,7 +294,7 @@ static void arizona_disable_reset(struct arizona *arizona)
 			break;
 		}
 
-		gpio_set_value_cansleep(arizona->pdata.reset, 1);
+		gpiod_set_value_cansleep(arizona->pdata.reset, 1);
 		usleep_range(1000, 5000);
 	}
 }
@@ -799,14 +798,25 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
 	struct arizona_pdata *pdata = &arizona->pdata;
 	int ret, i;
 
-	pdata->reset = of_get_named_gpio(arizona->dev->of_node, "wlf,reset", 0);
-	if (pdata->reset == -EPROBE_DEFER) {
-		return pdata->reset;
-	} else if (pdata->reset < 0) {
-		dev_err(arizona->dev, "Reset GPIO missing/malformed: %d\n",
-			pdata->reset);
+	pdata->reset = devm_gpiod_get_from_of_node(arizona->dev,
+						   arizona->dev->of_node,
+						   "wlf,reset", 0,
+						   GPIOD_OUT_LOW,
+						   "arizona /RESET");
+	if (IS_ERR(pdata->reset)) {
+		ret = PTR_ERR(pdata->reset);
+		switch (ret) {
+		case -ENOENT:
+			break;
+		case -EPROBE_DEFER:
+			return ret;
+		default:
+			dev_err(arizona->dev, "Reset GPIO malformed: %d\n",
+				ret);
+			break;
+		}
 
-		pdata->reset = 0;
+		pdata->reset = NULL;
 	}
 
 	ret = of_property_read_u32_array(arizona->dev->of_node,
@@ -1050,14 +1060,20 @@ int arizona_dev_init(struct arizona *arizona)
 		goto err_early;
 	}
 
-	if (arizona->pdata.reset) {
+	if (!arizona->pdata.reset) {
 		/* Start out with /RESET low to put the chip into reset */
-		ret = devm_gpio_request_one(arizona->dev, arizona->pdata.reset,
-					    GPIOF_DIR_OUT | GPIOF_INIT_LOW,
-					    "arizona /RESET");
-		if (ret != 0) {
-			dev_err(dev, "Failed to request /RESET: %d\n", ret);
-			goto err_dcvdd;
+		arizona->pdata.reset = devm_gpiod_get(arizona->dev, "wlf,reset",
+						      GPIOD_OUT_LOW);
+		if (IS_ERR(arizona->pdata.reset)) {
+			ret = PTR_ERR(arizona->pdata.reset);
+			if (ret == -EPROBE_DEFER)
+				goto err_dcvdd;
+			else
+				dev_err(arizona->dev,
+					"Reset GPIO missing/malformed: %d\n",
+					ret);
+
+			arizona->pdata.reset = NULL;
 		}
 	}
 
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index f72dc53848d7..0013075d4cda 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -56,6 +56,7 @@
 #define ARIZONA_MAX_PDM_SPK 2
 
 struct regulator_init_data;
+struct gpio_desc;
 
 struct arizona_micbias {
 	int mV;                    /** Regulated voltage */
@@ -77,7 +78,7 @@ struct arizona_micd_range {
 };
 
 struct arizona_pdata {
-	int reset;      /** GPIO controlling /RESET, if any */
+	struct gpio_desc *reset;      /** GPIO controlling /RESET, if any */
 
 	/** Regulator configuration for MICVDD */
 	struct arizona_micsupp_pdata micvdd;
-- 
2.11.0

--
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] 6+ messages in thread

* [PATCH 2/2] mfd: arizona: Update DT doc to support more standard reset binding
  2018-02-14 15:55 [PATCH 1/2] mfd: arizona: Update reset pin to use GPIOD Charles Keepax
@ 2018-02-14 15:55 ` Charles Keepax
  2018-02-19  3:13   ` Rob Herring
       [not found] ` <20180214155512.17218-1-ckeepax-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5@public.gmane.org>
  2018-02-22 14:46 ` Linus Walleij
  2 siblings, 1 reply; 6+ messages in thread
From: Charles Keepax @ 2018-02-14 15:55 UTC (permalink / raw)
  To: lee.jones
  Cc: robh+dt, mark.rutland, linus.walleij, devicetree, linux-kernel, patches

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

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index bdd017686ea5..a1557220825e 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -50,7 +50,7 @@ Required properties:
 
 Optional properties:
 
-  - wlf,reset : GPIO specifier for the GPIO controlling /RESET
+  - wlf,reset-gpios : GPIO specifier for the GPIO controlling /RESET
 
   - clocks: Should reference the clocks supplied on MCLK1 and MCLK2
   - clock-names: Should contains two strings:
@@ -70,6 +70,10 @@ Optional properties:
     Documentation/devicetree/bindings/regulator/regulator.txt
     (wm5102, wm5110, wm8280, wm8997, wm8998, wm1814)
 
+Deprecated properties:
+
+  - wlf,reset : GPIO specifier for the GPIO controlling /RESET
+
 Also see child specific device properties:
   Regulator - ../regulator/arizona-regulator.txt
   Extcon    - ../extcon/extcon-arizona.txt
-- 
2.11.0

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

* Re: [PATCH 1/2] mfd: arizona: Update reset pin to use GPIOD
       [not found] ` <20180214155512.17218-1-ckeepax-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5@public.gmane.org>
@ 2018-02-14 16:05   ` Charles Keepax
  0 siblings, 0 replies; 6+ messages in thread
From: Charles Keepax @ 2018-02-14 16:05 UTC (permalink / raw)
  To: lee.jones-QSEj5FYQhm4dnm+yROfE0A
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	linus.walleij-QSEj5FYQhm4dnm+yROfE0A,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	patches-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5

On Wed, Feb 14, 2018 at 03:55:11PM +0000, Charles Keepax wrote:
> Now GPIOD has support for both pdata systems and for non-standard DT
> bindings the Arizona reset GPIO can be converted to use it.
> 
> Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5@public.gmane.org>
> ---

Very sorry I forgot to add this email based these two patches on
v4.16-rc1 since the public mfd for-next branch is still a little
behind and they depend on stuff merged through GPIO in v4.16.

Thanks,
Charles
--
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] 6+ messages in thread

* Re: [PATCH 2/2] mfd: arizona: Update DT doc to support more standard reset binding
  2018-02-14 15:55 ` [PATCH 2/2] mfd: arizona: Update DT doc to support more standard reset binding Charles Keepax
@ 2018-02-19  3:13   ` Rob Herring
  2018-02-19 10:28     ` Charles Keepax
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2018-02-19  3:13 UTC (permalink / raw)
  To: Charles Keepax
  Cc: lee.jones, mark.rutland, linus.walleij, devicetree, linux-kernel,
	patches

On Wed, Feb 14, 2018 at 03:55:12PM +0000, Charles Keepax wrote:
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> index bdd017686ea5..a1557220825e 100644
> --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> @@ -50,7 +50,7 @@ Required properties:
>  
>  Optional properties:
>  
> -  - wlf,reset : GPIO specifier for the GPIO controlling /RESET
> +  - wlf,reset-gpios : GPIO specifier for the GPIO controlling /RESET

Just reset-gpios is widely used, so you can use that and drop the 
vendor.

>  
>    - clocks: Should reference the clocks supplied on MCLK1 and MCLK2
>    - clock-names: Should contains two strings:
> @@ -70,6 +70,10 @@ Optional properties:
>      Documentation/devicetree/bindings/regulator/regulator.txt
>      (wm5102, wm5110, wm8280, wm8997, wm8998, wm1814)
>  
> +Deprecated properties:
> +
> +  - wlf,reset : GPIO specifier for the GPIO controlling /RESET
> +
>  Also see child specific device properties:
>    Regulator - ../regulator/arizona-regulator.txt
>    Extcon    - ../extcon/extcon-arizona.txt
> -- 
> 2.11.0
> 

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

* Re: [PATCH 2/2] mfd: arizona: Update DT doc to support more standard reset binding
  2018-02-19  3:13   ` Rob Herring
@ 2018-02-19 10:28     ` Charles Keepax
  0 siblings, 0 replies; 6+ messages in thread
From: Charles Keepax @ 2018-02-19 10:28 UTC (permalink / raw)
  To: Rob Herring
  Cc: lee.jones, mark.rutland, linus.walleij, devicetree, linux-kernel,
	patches

On Sun, Feb 18, 2018 at 09:13:35PM -0600, Rob Herring wrote:
> On Wed, Feb 14, 2018 at 03:55:12PM +0000, Charles Keepax wrote:
> > Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> > ---
> >  Documentation/devicetree/bindings/mfd/arizona.txt | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> > index bdd017686ea5..a1557220825e 100644
> > --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> > +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> > @@ -50,7 +50,7 @@ Required properties:
> >  
> >  Optional properties:
> >  
> > -  - wlf,reset : GPIO specifier for the GPIO controlling /RESET
> > +  - wlf,reset-gpios : GPIO specifier for the GPIO controlling /RESET
> 
> Just reset-gpios is widely used, so you can use that and drop the 
> vendor.
> 

Yes sorry should have realised that will drop the prefix and
resend.

Thanks,
Charles

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

* Re: [PATCH 1/2] mfd: arizona: Update reset pin to use GPIOD
  2018-02-14 15:55 [PATCH 1/2] mfd: arizona: Update reset pin to use GPIOD Charles Keepax
  2018-02-14 15:55 ` [PATCH 2/2] mfd: arizona: Update DT doc to support more standard reset binding Charles Keepax
       [not found] ` <20180214155512.17218-1-ckeepax-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5@public.gmane.org>
@ 2018-02-22 14:46 ` Linus Walleij
  2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2018-02-22 14:46 UTC (permalink / raw)
  To: Charles Keepax
  Cc: Lee Jones, Rob Herring, Mark Rutland,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-kernel, patches

On Wed, Feb 14, 2018 at 4:55 PM, Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:

> Now GPIOD has support for both pdata systems and for non-standard DT
> bindings the Arizona reset GPIO can be converted to use it.
>
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
(...)
> +       pdata->reset = devm_gpiod_get_from_of_node(arizona->dev,
> +                                                  arizona->dev->of_node,
> +                                                  "wlf,reset", 0,
> +                                                  GPIOD_OUT_LOW,
> +                                                  "arizona /RESET");

It seems this call is really useful.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Also thanks for testing this API, I had nothing to test it on...

Yours,
Linus Walleij

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

end of thread, other threads:[~2018-02-22 14:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 15:55 [PATCH 1/2] mfd: arizona: Update reset pin to use GPIOD Charles Keepax
2018-02-14 15:55 ` [PATCH 2/2] mfd: arizona: Update DT doc to support more standard reset binding Charles Keepax
2018-02-19  3:13   ` Rob Herring
2018-02-19 10:28     ` Charles Keepax
     [not found] ` <20180214155512.17218-1-ckeepax-yzvPICuk2AA4QjBA90+/kJqQE7yCjDx5@public.gmane.org>
2018-02-14 16:05   ` [PATCH 1/2] mfd: arizona: Update reset pin to use GPIOD Charles Keepax
2018-02-22 14:46 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).