gpio: mvebu: new gpio driver for mvebu platforms
Subsystems (5)
PATCH v4 1/1 gpio: mvebu: new gpio driver for mvebu platforms
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 isn't however a problem, as those older platforms need to explictly be converted over to the new pinctrl driver and the new gpio driver. Until that, they will happily continue to use the old, known-working gpio driver. So this patch set has no chance to break any of the existing Marvell platforms.
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.
This patch set should be applied on top of the pinctrl-mvebu patch set from Sebastian Hesselbarth, as it depends on it.
Changes since v3:
* Added #interrupt-cells in both the DT binding documentation example, and in the DT data for Armada 370 and XP (noticed by Stephen Warren)
* Fixed a typo on the #interrupt-cells description in the DT binding description (noticed by Stephen Warren).
* Fixed a bug in gpio_mvebu_irq_set_type() when the GPIO used was not from the first bank (noticed, debugged and fix provided by Andrew Lunn)
* Added the Acked-by or Reviewed-by that were received from Rob Herring and Linus Walleij on certain patches.
Changes since v2:
* Use inline functions for the register accessors, and rename them lower-case since they are functions, as suggested by Jean-Christophe Plagnol-Villard.
* Use _relaxed() variants of readl/writel, as suggested by Jean-Christophe Plagnol-Villard.
* Use switch() instead of long list of if() conditions in mvebu_gpio_irq_set_type(), as suggested by Jean-Christophe Plagnol-Villard.
* Add DT aliases gpio0, gpio1, gpio2, and then use of_alias_get_id() to get the number of GPIO bank, and deduce the GPIO base from it. We don't use automatic allocation because we really want the internal SoC GPIOs to have 0-31, 32-63, 64-... numbers (while automatic allocation allocates 224... for the first bank 202... for the second bank, etc.). This strategy was recommended by Uwe Kleine-Koenig and is already used in gpio-mxs.c.
* Use gpio-cells = <2> instead of gpio-cells = <1>, as suggested by Olof Johansson. This allows to re-use the default .xlate() function, and therefore make the GPIO DT binding actually work (it was broken in previous versions of this patch set).
* Use dev_name() to fill the gpio_chip->name field, instead of manually computing a name. This allows to get rid of the global variable counting GPIO chips.
* Rebase on top of the latest pinctrl work from Sebastian Hesselbarth.
* Added the Acked-by from Linus Walleij on the DT binding documentation patch.
Changes since v1:
* Added fixes for Dove from Sebastian Hesselbarth, and his Tested-by on the driver patch.
Thanks,
Thomas
PATCH v4 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.
--- drivers/gpio/Kconfig | 6 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-mvebu.c | 679 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 686 insertions(+) create mode 100644 drivers/gpio/gpio-mvebu.c
drivers/gpio/Kconfig +6 -0
@@ -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
@@ -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 +679 -0
679 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Andrew Lunn
maintainerPATCH v4 1/5 gpio: introduce gpio-mvebu driver for Marvell SoCs
Hi Gregory
Quoted 20 lines · Thomas Petazzoni
This driver aims at replacing the
arch/arm/plat-orion/gpio.cdriver, 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 indrivers/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.
Quoted 8 lines
Signed-off-by Thomas Petazzoni <[email protected]>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]>Reviewed-by Linus Walleij <[email protected]>
Thanks for incorporating my IRQ fix. I retested on Kirkwood. Please add a
Andrew
PATCH v4 1/5 gpio: introduce gpio-mvebu driver for Marvell SoCs
Dear Andrew Lunn,
Quoted 4 lines · Andrew Lunn
Thanks for incorporating my IRQ fix. I retested on Kirkwood. Please add a
Tested-by Andrew Lunn <[email protected]>
Thanks!
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v4 2/5 Documentation: add description of DT binding for the gpio-mvebu driver
In reply to Thomas Petazzoni--- .../devicetree/bindings/gpio/gpio-mvebu.txt | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mvebu.txt
Documentation/devicetree/bindings/gpio/gpio-mvebu.txt new file +53 -0
@@ -0,0 +1,53 @@ +* 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 cells needed to encode an + interrupt source. Should be two. + The first cell is the GPIO number. + The second cell is used to specify flags: + bits[3:0] trigger type and level flags: + 1 = low-to-high edge triggered. + 2 = high-to-low edge triggered. + 4 = active high level-sensitive. + 8 = active low level-sensitive. + +- gpio-controller: marks the device node as a gpio controller + +- ngpios: number of GPIOs this controller has + +- #gpio-cells: Should be two. The first cell is the pin number. The + second cell is reserved for flags, unused at the moment. + +Example: + + gpio0: gpio at d0018100 { + compatible = "marvell,armadaxp-gpio"; + reg = <0xd0018100 0x40>, + <0xd0018800 0x30>; + ngpios = <32>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = <16>, <17>, <18>, <19>; + };
Signature · 1 line
1.7.9.5
PATCH v4 3/5 arm: mvebu: use GPIO support now that a driver is available
In reply to Thomas Petazzoni--- 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
@@ -575,6 +575,7 @@ config ARCH_MVEBU select COMMON_CLK select PLAT_ORION 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
@@ -0,0 +1 @@ +/* empty */
Signature · 1 line
1.7.9.5
PATCH v4 4/5 arm: mvebu: add DT information for GPIO banks on Armada 370 and XP
In reply to Thomas PetazzoniThe gpioX aliases are needed so that the driver can use of_alias_get_id() to get a 0-based number of the GPIO bank, which we then use to compute the base GPIO of the bank being probed. This is similar to what gpio-mxs.c is doing.
--- arch/arm/boot/dts/armada-370.dtsi | 39 +++++++++++++++++++++++++++ arch/arm/boot/dts/armada-xp-mv78230.dtsi | 29 +++++++++++++++++++++ arch/arm/boot/dts/armada-xp-mv78260.dtsi | 42 ++++++++++++++++++++++++++++++ arch/arm/boot/dts/armada-xp-mv78460.dtsi | 42 ++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+)
arch/arm/boot/dts/armada-370.dtsi +39 -0
@@ -21,6 +21,12 @@ model = "Marvell Armada 370 family SoC"; compatible = "marvell,armada370", "marvell,armada-370-xp"; + aliases { + gpio0 = &gpio0; + gpio1 = &gpio1; + gpio2 = &gpio2; + }; + mpic: interrupt-controller at d0020000 { reg = <0xd0020a00 0x1d0>, <0xd0021870 0x58>;
@@ -35,6 +41,39 @@ pinctrl { compatible = "marvell,mv88f6710-pinctrl"; reg = <0xd0018000 0x38>; + }; + + gpio0: gpio at d0018100 { + compatible = "marvell,orion-gpio"; + reg = <0xd0018100 0x40>; + ngpios = <32>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupts-cells = <2>; + interrupts = <82>, <83>, <84>, <85>; + }; + + gpio1: gpio at d0018140 { + compatible = "marvell,orion-gpio"; + reg = <0xd0018140 0x40>; + ngpios = <32>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupts-cells = <2>; + interrupts = <87>, <88>, <89>, <90>; + }; + + gpio2: gpio at d0018180 { + compatible = "marvell,orion-gpio"; + reg = <0xd0018180 0x40>; + ngpios = <2>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupts-cells = <2>; + interrupts = <91>; }; }; };
arch/arm/boot/dts/armada-xp-mv78230.dtsi +29 -0
@@ -19,10 +19,39 @@ model = "Marvell Armada XP MV78230 SoC"; compatible = "marvell,armadaxp-mv78230", "marvell,armadaxp", "marvell,armada-370-xp"; + aliases { + gpio0 = &gpio0; + gpio1 = &gpio1; + }; + soc { pinctrl { compatible = "marvell,mv78230-pinctrl"; reg = <0xd0018000 0x38>; }; + + gpio0: gpio at d0018100 { + compatible = "marvell,armadaxp-gpio"; + reg = <0xd0018100 0x40>, + <0xd0018800 0x30>; + ngpios = <32>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupts-cells = <2>; + interrupts = <16>, <17>, <18>, <19>; + }; + + gpio1: gpio at d0018140 { + compatible = "marvell,armadaxp-gpio"; + reg = <0xd0018140 0x40>, + <0xd0018840 0x30>; + ngpios = <17>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupts-cells = <2>; + interrupts = <20>, <21>, <22>; + }; }; };
arch/arm/boot/dts/armada-xp-mv78260.dtsi +42 -0
52 lines not on this page · raw message
arch/arm/boot/dts/armada-xp-mv78460.dtsi +42 -0
52 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v4 5/5 arm: mvebu: add gpio support in defconfig
In reply to Thomas Petazzoni--- arch/arm/configs/mvebu_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/mvebu_defconfig +2 -0
@@ -21,6 +21,8 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_OF_PLATFORM=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
PATCH v4 1/1 gpio: mvebu: new gpio driver for mvebu platforms
In reply to Thomas PetazzoniQuoted 11 lines · Thomas Petazzoni
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 isn't however a problem, as those older platforms need to explictly be converted over to the new pinctrl driver and the new gpio driver. Until that, they will happily continue to use the old, known-working gpio driver. So this patch set has no chance to break any of the existing Marvell platforms.