Skip to contentSkip to conversation

gpio: mvebu: new gpio driver for mvebu platforms

PATCH New Thomas Petazzoni 3 participants 11 messages Aug 11, 2012 – Sep 5, 2012

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

Hello,

This patch set adds a new GPIO driver for Marvell EBU SoCs, which aims at replacing the existing GPIO driver from plat-orion/gpio.c. The driver comes with the necessary DT changes to make it work on Armada 370 and Armada XP, and it has been tested successfully by Sebastian Hesselbarth on Dove. It should also work flawlessly on other Marvell EBU SoCs (Kirkwood, Orion, Discovery), but this remains to be tested by the relevant maintainers.

This new driver reuses a lot of code from the existing plat-orion/gpio.c driver, but has a number of advantages:

*) Support for Armada 370 and Armada XP
*) It is integrated with the mvebu pinctrl driver so that GPIO pins
are properly muxed, and the GPIO driver knows which GPIO pins are output-only or input-only. This driver has been submitted by Sebastian Hesselbarth today on the LAKML.
*) Properly placed in drivers/gpio
*) More extensible mechanism to support platform differences. The
plat-orion driver uses a simple mask-offset DT property, which works fine for Discovery MV78200 but not for Armada XP. The new driver uses different compatible strings to identify the different variants of the GPIO controllers.

Thanks,

Thomas

The following changes since commit 872b6be95abf9d57e0639d0345fa2b5a0e4fa0f4:

arm: mvebu: add pinctrl support in defconfig (2012-08-11 11:27:33 +0200)

are available in the git repository at:

git://github.com/MISL-EBU-System-SW/mainline-public.git mvebu-gpio

for you to fetch changes up to 92dffc2d360b84d154ffdc049346d5011592bc7f:

arm: mvebu: add gpio support in defconfig (2012-08-11 15:20:55 +0200)

----------------------------------------------------------------
Thomas Petazzoni (5):
gpio: introduce gpio-mvebu driver for Marvell SoCs
Documentation: add description of DT binding for the gpio-mvebu driver
arm: mvebu: use GPIO support now that a driver is available
arm: mvebu: add DT information for GPIO banks on Armada 370 and XP
arm: mvebu: add gpio support in defconfig

 .../devicetree/bindings/gpio/gpio-mvebu.txt        |   44 ++
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boot/dts/armada-370.dtsi                  |   30 +
 arch/arm/boot/dts/armada-xp-mv78230.dtsi           |   22 +
 arch/arm/boot/dts/armada-xp-mv78260.dtsi           |   33 +
 arch/arm/boot/dts/armada-xp-mv78460.dtsi           |   33 +
 arch/arm/configs/mvebu_defconfig                   |    2 +
 arch/arm/mach-mvebu/include/mach/gpio.h            |    1 +
 drivers/gpio/Kconfig                               |    6 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-mvebu.c                          |  650 ++++++++++++++++++++
 11 files changed, 823 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mvebu.txt
 create mode 100644 arch/arm/mach-mvebu/include/mach/gpio.h
 create mode 100644 drivers/gpio/gpio-mvebu.c
#1 lore raw

PATCH 1/5 gpio: introduce gpio-mvebu driver for Marvell SoCs

This driver aims at replacing the arch/arm/plat-orion/gpio.c driver, and is designed to be compatible with all Marvell EBU SoCs: Orion, Kirkwood, Dove, Armada 370/XP and Discovery.

It has been successfully tested on Dove and Armada XP at the moment.

Compared to the plat-orion driver, this new driver has the following added benefits:

*) Support for Armada 370 and Armada XP
*) It is integrated with the mvebu pinctrl driver so that GPIO pins
are properly muxed, and the GPIO driver knows which GPIO pins are output-only or input-only.
*) Properly placed in drivers/gpio
*) More extensible mechanism to support platform differences. The
plat-orion driver uses a simple mask-offset DT property, which works fine for Discovery MV78200 but not for Armada XP. The new driver uses different compatible strings to identify the different variants of the GPIO controllers.

Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Gregory Clement <[email protected]>
---
 drivers/gpio/Kconfig      |    6 +
 drivers/gpio/Makefile     |    1 +
 drivers/gpio/gpio-mvebu.c |  650 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 657 insertions(+)
 create mode 100644 drivers/gpio/gpio-mvebu.c
drivers/gpio/Kconfig +6 -0
index b16c8a7..993b0c4 100644
@@ -150,6 +150,12 @@ config GPIO_MSM_V2
 	  Qualcomm MSM chips.  Most of the pins on the MSM can be
 	  selected for GPIO, and are controlled by this driver.
 
+config GPIO_MVEBU
+	def_bool y
+	depends on ARCH_MVEBU
+	select GPIO_GENERIC
+	select GENERIC_IRQ_CHIP
+
 config GPIO_MXC
 	def_bool y
 	depends on ARCH_MXC
drivers/gpio/Makefile +1 -0
index 153cace..1a33e67 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_GPIO_MPC8XXX)	+= gpio-mpc8xxx.o
 obj-$(CONFIG_GPIO_MSIC)		+= gpio-msic.o
 obj-$(CONFIG_GPIO_MSM_V1)	+= gpio-msm-v1.o
 obj-$(CONFIG_GPIO_MSM_V2)	+= gpio-msm-v2.o
+obj-$(CONFIG_GPIO_MVEBU)        += gpio-mvebu.o
 obj-$(CONFIG_GPIO_MXC)		+= gpio-mxc.o
 obj-$(CONFIG_GPIO_MXS)		+= gpio-mxs.o
 obj-$(CONFIG_ARCH_OMAP)		+= gpio-omap.o
drivers/gpio/gpio-mvebu.c new file +650 -0

650 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/5 Documentation: add description of DT binding for the gpio-mvebu driver

In reply to Thomas Petazzoni
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Gregory Clement <[email protected]>
---
 .../devicetree/bindings/gpio/gpio-mvebu.txt        |   44 ++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mvebu.txt
Documentation/devicetree/bindings/gpio/gpio-mvebu.txt new file +44 -0
new file mode 100644
index 0000000..298436c
@@ -0,0 +1,44 @@
+* Marvell EBU GPIO controller
+
+Required properties:
+
+- compatible : Should be "marvell,orion-gpio", "marvell,mv78200-gpio"
+  or "marvell,armadaxp-gpio". "marvell,orion-gpio" should be used for
+  Orion, Kirkwood, Dove, Discovery (except MV78200) and Armada
+  370. "marvell,mv78200-gpio" should be used for the Discovery
+  MV78200. "marvel,armadaxp-gpio" should be used for all Armada XP
+  SoCs (MV78230, MV78260, MV78460).
+
+- reg: Address and length of the register set for the device. Only one
+  entry is expected, except for the "marvell,armadaxp-gpio" variant
+  for which two entries are expected: one for the general registers,
+  one for the per-cpu registers.
+
+- interrupts: The list of interrupts that are used for all the pins
+  managed by this GPIO bank. There can be more than one interrupt
+  (example: 1 interrupt per 8 pins on Armada XP, which means 4
+  interrupts per bank of 32 GPIOs).
+
+- interrupt-controller: identifies the node as an interrupt controller
+
+- #interrupt-cells: specifies the number of celles needed to encode an
+   interrupt source
+
+- gpio-controller: marks the device node as a gpio controller
+
+- ngpios: number of GPIOs this controller has
+
+- #gpio-cells: Should be one. It is the pin number.
+
+Example:
+
+		gpio0: gpio at d0018100 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018100 0x40>,
+			    <0xd0018800 0x30>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <16>, <17>, <18>, <19>;
+		};
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 2/5 Documentation: add description of DT binding for the gpio-mvebu driver

In reply to Thomas Petazzoni

Hi,

Documentation/devicetree/bindings/gpio/gpio-mvebu.txt line 31

Quoted 5 lines · Thomas Petazzoni

+- gpio-controller: marks the device node as a gpio controller

Documentation/devicetree/bindings/gpio/gpio-mvebu.txt new file +4 -0
+
+- ngpios: number of GPIOs this controller has
+
+- #gpio-cells: Should be one. It is the pin number.

Most platforms will hit a need to encode polarity of the GPIO, in particular on inputs. Having an extra cell for flags is quite useful.

#5 lore raw

PATCH 2/5 Documentation: add description of DT binding for the gpio-mvebu driver

Quoted 11 lines · Olof Johansson

Hi,

Documentation/devicetree/bindings/gpio/gpio-mvebu.txt line 31

Quoted 5 lines · Thomas Petazzoni

+- gpio-controller: marks the device node as a gpio controller

Documentation/devicetree/bindings/gpio/gpio-mvebu.txt new file +4 -0
+
+- ngpios: number of GPIOs this controller has
+
+- #gpio-cells: Should be one. It is the pin number.

Most platforms will hit a need to encode polarity of the GPIO, in particular on inputs. Having an extra cell for flags is quite useful.

Isn't that surplus in this case since this driver has a proper pinctrl backend controlling such stuff? I don't really like pinctrl portions of GPIOs being showeled into the GPIO actually. Or am I just getting this wrong...?

Yours,
Linus Walleij

#6 lore raw

PATCH 2/5 Documentation: add description of DT binding for the gpio-mvebu driver

Quoted 13 lines · Linus Walleij
Quoted 11 lines · Olof Johansson

Hi,

Documentation/devicetree/bindings/gpio/gpio-mvebu.txt line 31

Quoted 5 lines · Thomas Petazzoni

+- gpio-controller: marks the device node as a gpio controller

Documentation/devicetree/bindings/gpio/gpio-mvebu.txt new file +4 -0
+
+- ngpios: number of GPIOs this controller has
+
+- #gpio-cells: Should be one. It is the pin number.

Most platforms will hit a need to encode polarity of the GPIO, in particular on inputs. Having an extra cell for flags is quite useful.

Quoted 4 lines

Isn't that surplus in this case since this driver has a proper pinctrl backend controlling such stuff? I don't really like pinctrl portions of GPIOs being showeled into the GPIO actually. Or am I just getting this wrong...?

Ah, yes, true. Last time I had to add this was for a platform that lacked pinctrl bindings (exynos).

I guess it doesn't hurt to add the flag since it might be used on other OSes that have a gpio driver but not a pinctrl one, but that's a pretty far corner case, no need to revise for it.

-Olof

#7 lore raw

PATCH 2/5 Documentation: add description of DT binding for the gpio-mvebu driver

Quoted 3 lines · Olof Johansson

I guess it doesn't hurt to add the flag since it might be used on other OSes that have a gpio driver but not a pinctrl one, but that's a pretty far corner case, no need to revise for it.

Sounds a bit ambigous and redundant, as we are in the driver seat for device tree I'd prefer to force every other OS to get their pinctrl concepts right ;-)

Linus Walleij

#8 lore raw

PATCH 3/5 arm: mvebu: use GPIO support now that a driver is available

In reply to Thomas Petazzoni
Cc Andrew Lunn <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Gregory Clement <[email protected]>
---
 arch/arm/Kconfig                        |    1 +
 arch/arm/mach-mvebu/include/mach/gpio.h |    1 +
 2 files changed, 2 insertions(+)
 create mode 100644 arch/arm/mach-mvebu/include/mach/gpio.h
arch/arm/Kconfig +1 -0
index 95317a9..15b224c 100644
@@ -574,6 +574,7 @@ config ARCH_MVEBU
 	select IRQ_DOMAIN
 	select COMMON_CLK
 	select PINCTRL
+	select ARCH_WANT_OPTIONAL_GPIOLIB
 	help
 	  Support for the Marvell SoC Family with device tree support
 
arch/arm/mach-mvebu/include/mach/gpio.h new file +1 -0
new file mode 100644
index 0000000..40a8c17
@@ -0,0 +1 @@
+/* empty */
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH 4/5 arm: mvebu: add DT information for GPIO banks on Armada 370 and XP

In reply to Thomas Petazzoni
Cc Jason Cooper <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Gregory Clement <[email protected]>
---
 arch/arm/boot/dts/armada-370.dtsi        |   30 +++++++++++++++++++++++++++
 arch/arm/boot/dts/armada-xp-mv78230.dtsi |   22 ++++++++++++++++++++
 arch/arm/boot/dts/armada-xp-mv78260.dtsi |   33 ++++++++++++++++++++++++++++++
 arch/arm/boot/dts/armada-xp-mv78460.dtsi |   33 ++++++++++++++++++++++++++++++
 4 files changed, 118 insertions(+)
arch/arm/boot/dts/armada-370.dtsi +30 -0
index 875fcd8..b0c832c 100644
@@ -35,5 +35,35 @@
                 pinctrl at d0018000 {
 			        compatible = "marvell,mv88f6710-pinctrl";
 	        };
+
+		gpio0: gpio at d0018100 {
+			compatible = "marvell,orion-gpio";
+			reg = <0xd0018100 0x40>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <82>, <83>, <84>, <85>;
+		};
+
+		gpio1: gpio at d0018140 {
+			compatible = "marvell,orion-gpio";
+			reg = <0xd0018140 0x40>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <87>, <88>, <89>, <90>;
+		};
+
+		gpio2: gpio at d0018180 {
+			compatible = "marvell,orion-gpio";
+			reg = <0xd0018180 0x40>;
+			ngpios = <2>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <91>;
+		};
 	};
 };
arch/arm/boot/dts/armada-xp-mv78230.dtsi +22 -0
index 69ad287..081f3f7 100644
@@ -23,5 +23,27 @@
 		pinctrl at d0018000 {
 			compatible = "marvell,mv78230-pinctrl";
 		};
+
+		gpio0: gpio at d0018100 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018100 0x40>,
+			    <0xd0018800 0x30>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <16>, <17>, <18>, <19>;
+		};
+
+		gpio1: gpio at d0018140 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018140 0x40>,
+			    <0xd0018840 0x30>;
+			ngpios = <17>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <20>, <21>, <22>;
+		};
 	};
 };
arch/arm/boot/dts/armada-xp-mv78260.dtsi +33 -0
index 0f38fa9..fa791fa 100644
@@ -23,5 +23,38 @@
 		pinctrl at d0018000 {
 			compatible = "marvell,mv78260-pinctrl";
 		};
+
+		gpio0: gpio at d0018100 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018100 0x40>,
+			    <0xd0018800 0x30>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <16>, <17>, <18>, <19>;
+		};
+
+		gpio1: gpio at d0018140 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018140 0x40>,
+			    <0xd0018840 0x30>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <20>, <21>, <22>, <23>;
+		};
+
+		gpio2: gpio at d0018180 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018180 0x40>,
+			    <0xd0018870 0x30>;
+			ngpios = <3>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <24>;
+		};
 	};
 };
arch/arm/boot/dts/armada-xp-mv78460.dtsi +33 -0
index 9e61836..a372d13 100644
@@ -23,5 +23,38 @@
 		pinctrl at d0018000 {
 			compatible = "marvell,mv78460-pinctrl";
 		};
+
+		gpio0: gpio at d0018100 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018100 0x40>,
+			    <0xd0018800 0x30>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <16>, <17>, <18>, <19>;
+		};
+
+		gpio1: gpio at d0018140 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018140 0x40>,
+			    <0xd0018840 0x30>;
+			ngpios = <32>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <20>, <21>, <22>, <23>;
+		};
+
+		gpio2: gpio at d0018180 {
+			compatible = "marvell,armadaxp-gpio";
+			reg = <0xd0018180 0x40>,
+			    <0xd0018870 0x30>;
+			ngpios = <3>;
+			gpio-controller;
+			#gpio-cells = <1>;
+			interrupt-controller;
+			interrupts = <24>;
+		};
 	};
  };
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH 5/5 arm: mvebu: add gpio support in defconfig

In reply to Thomas Petazzoni
Cc Jason Cooper <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Gregory Clement <[email protected]>
---
 arch/arm/configs/mvebu_defconfig |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/configs/mvebu_defconfig +2 -0
index cb07e64..8dbb0bf 100644
@@ -23,6 +23,8 @@ CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_OF_PLATFORM=y
 CONFIG_PINCTRL_ARMADA_370=y
 CONFIG_PINCTRL_ARMADA_XP=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 # CONFIG_EXT3_FS_XATTR is not set
Signature · 1 line
1.7.9.5