Skip to contentSkip to conversation

ARM: shmobile: Add rcar-gpio clock support

PATCH In review Geert Uytterhoeven 4 participants 10 messages Apr 14, 2014 – Apr 23, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover ARM: shmobile: Add rcar-gpio clock support

This series adds support to control the MSTP clocks of the GPIO blocks on R-Car Gen2 SoCs. Currently we depend on reset state / the bootloader to have the right clocks enabled. If they're not enabled, GPIO will fail, but not crash:
- No heartbeat LED (if you had it enabled),
- Keypad switches don't work,
- System doesn't wake-up from suspend when pressing a keypad switch.

After applying this series, the MSTP clocks of the GPIO blocks will be enabled automatically by runtime PM (or statically, if CONFIG_PM_RUNTIME=n) during boot up.

- [1/6] gpio: rcar: Add optional functional clock to bindings
- [2/6] gpio: rcar: Add minimal runtime PM support
- [3/6] ARM: shmobile: r8a7790 dtsi: Add GPIO clocks
- [4/6] ARM: shmobile: r8a7791 dtsi: Add GPIO clocks
- [5/6] ARM: shmobile: r8a7790 legacy: Add GPIO clocks
- [6/6] ARM: shmobile: r8a7791 legacy: Add GPIO clocks

For legacy, this should work as-is.
For multiplatform, this needs a method to enable drivers/sh/pm_runtime.c to actually work.

This was tested on r8a7791/Koelsch, both legacy and multiplatform. The changes for r8a7790 were straight-forward.
R-Car Gen1 doesn't seem to be affected, at least the r8a7778 datasheet doesn't mention MSTP bits for GPIO modules.

Thanks for applying!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#1 lore raw

PATCH v2 1/6 gpio: rcar: Add optional functional clock to bindings

From: Geert Uytterhoeven <[email protected]>

---
v2:
- Functional clock is mandatory depending on hardware (thanks, Laurent)

---
 .../devicetree/bindings/gpio/renesas,gpio-rcar.txt |    6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt +6 -0
index f61cef74a212..941a26aa4322 100644
@@ -21,6 +21,12 @@ Required Properties:
     GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported.
   - gpio-ranges: Range of pins managed by the GPIO controller.
 
+Optional properties:
+
+  - clocks: Must contain a reference to the functional clock.  The property is
+    mandatory if the hardware implements a controllable functional clock for
+    the GPIO instance.
+
 Please refer to gpio.txt in this directory for details of gpio-ranges property
 and the common GPIO bindings used by client devices.
 
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v2 2/6 gpio: rcar: Add minimal runtime PM support

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

This is just enough to automatically enable the functional clock, if present. Clock management during suspend/resume is still to be added.

---
v2:
- Use pm_runtime_put() instead of pm_runtime_put_sync()

---
 drivers/gpio/gpio-rcar.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpio/gpio-rcar.c +8 -0
index 03c91482432c..bfcfeeefcf78 100644
@@ -26,6 +26,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 
@@ -377,6 +378,9 @@ static int gpio_rcar_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, p);
 
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);
+
 	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
@@ -460,6 +464,8 @@ static int gpio_rcar_probe(struct platform_device *pdev)
 err1:
 	irq_domain_remove(p->irq_domain);
 err0:
+	pm_runtime_put(dev);
+	pm_runtime_disable(dev);
 	return ret;
 }
 
@@ -473,6 +479,8 @@ static int gpio_rcar_remove(struct platform_device *pdev)
 		return ret;
 
 	irq_domain_remove(p->irq_domain);
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	return 0;
 }
 
Signature · 1 line
1.7.9.5
#8 lore raw
In reply to Geert Uytterhoeven
Quoted 8 lines · Geert Uytterhoeven

This series adds support to control the MSTP clocks of the GPIO blocks on R-Car Gen2 SoCs. Currently we depend on reset state / the bootloader to have the right clocks enabled. If they're not enabled, GPIO will fail, but not crash:
- No heartbeat LED (if you had it enabled),
- Keypad switches don't work,
- System doesn't wake-up from suspend when pressing a keypad switch.

Quoted 6 lines

After applying this series, the MSTP clocks of the GPIO blocks will be enabled automatically by runtime PM (or statically, if CONFIG_PM_RUNTIME=n) during boot up.

- [1/6] gpio: rcar: Add optional functional clock to bindings
- [2/6] gpio: rcar: Add minimal runtime PM support

I believe that the above two patches need to be merged by Linus Walleij.

Quoted 2 lines

- [3/6] ARM: shmobile: r8a7790 dtsi: Add GPIO clocks
- [4/6] ARM: shmobile: r8a7791 dtsi: Add GPIO clocks

The above two dtsi patches appear to depend on the new binding added by patch 1. If that is so please repost them once the binding has been merged.

Quoted 4 lines

- [5/6] ARM: shmobile: r8a7790 legacy: Add GPIO clocks
- [6/6] ARM: shmobile: r8a7791 legacy: Add GPIO clocks

For legacy, this should work as-is.

For legacy, is patch 2 required in order for patches 5 and 6 to have any effect?

Quoted 7 lines

For multiplatform, this needs a method to enable drivers/sh/pm_runtime.c to actually work.

This was tested on r8a7791/Koelsch, both legacy and multiplatform. The changes for r8a7790 were straight-forward.
R-Car Gen1 doesn't seem to be affected, at least the r8a7778 datasheet doesn't mention MSTP bits for GPIO modules.

Thanks, good to know.

Quoted 13 lines

Thanks for applying!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#9 lore raw
In reply to Geert Uytterhoeven

Hi Simon,

Quoted 13 lines · Simon Horman
Quoted 12 lines · Geert Uytterhoeven

This series adds support to control the MSTP clocks of the GPIO blocks on R-Car Gen2 SoCs. Currently we depend on reset state / the bootloader to have the right clocks enabled. If they're not enabled, GPIO will fail, but not crash:
- No heartbeat LED (if you had it enabled),
- Keypad switches don't work,
- System doesn't wake-up from suspend when pressing a keypad switch.

After applying this series, the MSTP clocks of the GPIO blocks will be enabled automatically by runtime PM (or statically, if CONFIG_PM_RUNTIME=n) during boot up.

Quoted 5 lines
Quoted 2 lines

- [1/6] gpio: rcar: Add optional functional clock to bindings
- [2/6] gpio: rcar: Add minimal runtime PM support

I believe that the above two patches need to be merged by Linus Walleij.

Indeed, that's why I CCed him.

Quoted 6 lines
Quoted 2 lines

- [3/6] ARM: shmobile: r8a7790 dtsi: Add GPIO clocks
- [4/6] ARM: shmobile: r8a7791 dtsi: Add GPIO clocks

The above two dtsi patches appear to depend on the new binding added by patch 1. If that is so please repost them once the binding has been merged.

That's true. But it's just the standard way of specifying clocks. Not much can go wrong there ;-)

Quoted 7 lines
Quoted 4 lines

- [5/6] ARM: shmobile: r8a7790 legacy: Add GPIO clocks
- [6/6] ARM: shmobile: r8a7791 legacy: Add GPIO clocks

For legacy, this should work as-is.

For legacy, is patch 2 required in order for patches 5 and 6 to have any effect?

Yes, without patch 2, all other patches are no-ops. It doesn't hurt to apply them, though.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Acked-by on v2 1/6
#2 lore raw

Re: [PATCH v2 1/6] gpio: rcar: Add optional functional clock to bindings

In reply to Geert Uytterhoeven

Hi Geert,

Thank you for the patch.

Quoted 7 lines · On Monday 14 April 2014 20:33:12 Geert Uytterhoeven wrote:

From: Geert Uytterhoeven <[email protected]>

Quoted 24 lines

---
v2:
- Functional clock is mandatory depending on hardware (thanks, Laurent)

---
 .../devicetree/bindings/gpio/renesas,gpio-rcar.txt |    6 ++++++
 1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt index f61cef74a212..941a26aa4322 100644

Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt +3 -0
@@ -21,6 +21,12 @@ Required Properties:
     GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported.
   - gpio-ranges: Range of pins managed by the GPIO controller.
 
+Optional properties:
+
+  - clocks: Must contain a reference to the functional clock.  The property

is + mandatory if the hardware implements a controllable functional
clock for + the GPIO instance.
+
Please refer to gpio.txt in this directory for details of gpio-ranges
property and the common GPIO bindings used by client devices.

Signature · 3 lines
Regards,

Laurent Pinchart
Acked-by on v2 2/6
#5 lore raw

Re: [PATCH v2 2/6] gpio: rcar: Add minimal runtime PM support

In reply to Geert Uytterhoeven

Hi Geert,

Thank you for the patch.

Quoted 9 lines · On Monday 14 April 2014 20:33:13 Geert Uytterhoeven wrote:

From: Geert Uytterhoeven <[email protected]>

This is just enough to automatically enable the functional clock, if present. Clock management during suspend/resume is still to be added.

Quoted 46 lines

---
v2:
- Use pm_runtime_put() instead of pm_runtime_put_sync()

---
 drivers/gpio/gpio-rcar.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpio/gpio-rcar.c +4 -0
index 03c91482432c..bfcfeeefcf78 100644
@@ -26,6 +26,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 
@@ -377,6 +378,9 @@ static int gpio_rcar_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, p);
 
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);
+
 	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
@@ -460,6 +464,8 @@ static int gpio_rcar_probe(struct platform_device *pdev)

err1:

drivers/gpio/gpio-rcar.c +4 -0
 	irq_domain_remove(p->irq_domain);
 err0:
+	pm_runtime_put(dev);
+	pm_runtime_disable(dev);
 	return ret;
 }
@@ -473,6 +479,8 @@ static int gpio_rcar_remove(struct platform_device
 *pdev) return ret;
 
 	irq_domain_remove(p->irq_domain);
+	pm_runtime_put(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	return 0;
 }
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Re: [PATCH v2 1/6] gpio: rcar: Add optional functional clock to bindings

In reply to Geert Uytterhoeven
Quoted 10 lines · Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

---
v2:
- Functional clock is mandatory depending on hardware (thanks, Laurent)

This v2 version applied with Laurent's ACK.

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH v2 2/6] gpio: rcar: Add minimal runtime PM support

In reply to Geert Uytterhoeven
Quoted 5 lines · Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

This is just enough to automatically enable the functional clock, if present. Clock management during suspend/resume is still to be added.

Quoted 7 lines

---
v2:
- Use pm_runtime_put() instead of pm_runtime_put_sync()

This v2 version applied with Laurent's ACK. I guess you wanted it applied to the GPIO tree, I don't see the other patches.

Yours,
Linus Walleij

#7 lore raw

Re: [PATCH v2 2/6] gpio: rcar: Add minimal runtime PM support

Hi Linus,

Quoted 15 lines · Linus Walleij
Quoted 5 lines · Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

This is just enough to automatically enable the functional clock, if present. Clock management during suspend/resume is still to be added.

Quoted 7 lines

---
v2:
- Use pm_runtime_put() instead of pm_runtime_put_sync()

Quoted 2 lines

This v2 version applied with Laurent's ACK. I guess you wanted it applied to the GPIO tree, I don't see the other patches.

Thanks, yes that was the idea.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds