gpio: Add APM X-Gene standy platform GPIO driver
Subsystems (2)
v2 cover gpio: Add APM X-Gene standy platform GPIO driver
This patch add the GPIO standby controller in the APM X-Gene platform.
v1 Change:
1. Do not access GIC register from driver.
2. Duplicate gpio probe funtion.
3. Function gpiochip_remove doesn't return value.
Y Vo (3):
gpio: Add APM X-Gene standby GPIO controller driver
Documentation: gpio: Add APM X-Gene standby GPIO controller DTS
binding
arm64:dts: Add APM X-Gene standby GPIO controller DTS entries
.../devicetree/bindings/gpio/gpio-xgene-sb.txt | 31 +++ arch/arm64/boot/dts/apm-storm.dtsi | 13 ++ drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-xgene-sb.c | 217 +++++++++++++++++++++ 5 files changed, 269 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt create mode 100644 drivers/gpio/gpio-xgene-sb.c
Signature · 1 line
2.2.0
PATCH RESEND v2 1/3 gpio: Add APM X-Gene standby GPIO controller driver
Add APM X-Gene standby GPIO controller driver.
--- drivers/gpio/Kconfig | 7 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-xgene-sb.c | 217 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 drivers/gpio/gpio-xgene-sb.c
drivers/gpio/Kconfig +7 -0
@@ -342,6 +342,13 @@ config GPIO_XGENE the generic flash controller's address and data pins. Say yes here to enable the GFC GPIO functionality. +config GPIO_XGENE_SB + tristate "APM X-Gene GPIO standby controller support" + depends on ARCH_XGENE && OF_GPIO + help + This driver supports the GPIO block within the APM X-Gene + Standby Domain. Say yes here to enable the GPIO functionality. + config GPIO_XILINX bool "Xilinx GPIO support" depends on PPC_OF || MICROBLAZE || ARCH_ZYNQ
drivers/gpio/Makefile +1 -0
@@ -102,6 +102,7 @@ obj-$(CONFIG_GPIO_WM831X) += gpio-wm831x.o obj-$(CONFIG_GPIO_WM8350) += gpio-wm8350.o obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o obj-$(CONFIG_GPIO_XGENE) += gpio-xgene.o +obj-$(CONFIG_GPIO_XGENE_SB) += gpio-xgene-sb.o obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o
drivers/gpio/gpio-xgene-sb.c new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.2.0
PATCH RESEND v2 1/3 gpio: Add APM X-Gene standby GPIO controller driver
Quoted 1 line · Y Vo
Add APM X-Gene standby GPIO controller driver.
Write something about what platform an arch this is and so on, this is too terse commit message for a new driver.
Quoted 1 line
Signed-off-by Y Vo <[email protected]>
(...)
drivers/gpio/Kconfig config GPIO_XGENE · line 347
Quoted 3 lines
drivers/gpio/Kconfig +3
-0+config GPIO_XGENE_SB + tristate "APM X-Gene GPIO standby controller support" + depends on ARCH_XGENE && OF_GPIO
select GPIO_GENERIC
see below on why.
Quoted 10 lines
drivers/gpio/Kconfig +4
-0+ help + This driver supports the GPIO block within the APM X-Gene + Standby Domain. Say yes here to enable the GPIO functionality. + config GPIO_XILINX bool "Xilinx GPIO support" depends on PPC_OF || MICROBLAZE || ARCH_ZYNQdrivers/gpio/gpio-xgene-sb.c new file +0
-0
(...)
drivers/gpio/gpio-xgene-sb.c line 26
Quoted 6 lines
+++
b/drivers/gpio/gpio-xgene-sb.cdrivers/gpio/gpio-xgene-sb.c new file +5
-0+#include <linux/module.h> +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/of_gpio.h> +#include <linux/gpio.h>
#include <linux/gpio/driver.h>
instead.
drivers/gpio/gpio-xgene-sb.c line 28
Quoted 2 lines
drivers/gpio/gpio-xgene-sb.c new file +2
-0+#include <linux/of_irq.h> +#include <linux/acpi.h>
OK, why?
Quoted 1 line
+#include <
linux/efi.h>
Why?
drivers/gpio/gpio-xgene-sb.c line 31
Quoted 2 lines
drivers/gpio/gpio-xgene-sb.c new file +2
-0+#include <linux/string.h> +#include <linux/of_address.h>
#include <linux/basic_mmio_gpio.h>
when you start using GENERIC_GPIO
Quoted 11 lines
drivers/gpio/gpio-xgene-sb.c new file +11
-0+ +#define XGENE_MAX_GPIO_DS 22 +#define XGENE_MAX_GPIO_DS_IRQ 6 + +#define GPIO_MASK (x) (1U << ((x) % 32)) +#define GPIO_DIR_IN 0 +#define GPIO_DIR_OUT 1 + +#define MPA_GPIO_INT_LVL 0x0290 +#define MPA_GPIO_OE_ADDR 0x029c +#define MPA_GPIO_OUT_ADDR 0x02a0
drivers/gpio/gpio-xgene-sb.c line 52
Quoted 10 lines
drivers/gpio/gpio-xgene-sb.c new file +10
-0+#define MPA_GPIO_IN_ADDR 0x02a4 +#define MPA_GPIO_SEL_LO 0x0294 +#define MPA_GPIO_SEL_HIGH 0x029c + +struct xgene_gpio_sb { +struct of_mm_gpio_chip mm; +u32 *irq; +u32 nirq; +spinlock_t lock;/* mutual exclusion */ +};
Add kerneldoc to this struct.
Quoted 1 line
+static void
xgene_gpio_set_bit(void __iomem *reg, u32 gpio, int val)
(...)
Quoted 1 line
+static int
xgene_gpio_sb_get(struct gpio_chip *gc, u32 gpio)
This looks very much like a memory-mapped standard GPIO controller, use drivers/gpio/gpio-generic.c with some IRQ add-on, compare to any other driver selecting GPIO_GENERIC for guidance:drivers/gpio/gpio-74xx-mmio.c, gpio-dwapb.c etc.
Quoted 7 lines
drivers/gpio/gpio-xgene-sb.c new file +7
-0+static int apm_gpio_sb_to_irq (struct gpio_chip *gc,u32 gpio) +{ +struct of_mm_gpio_chip *mm_gc =to_of_mm_gpio_chip (gc); +struct xgene_gpio_sb *chip =to_xgene_gpio_sb (mm_gc); + +if (chip->irq[gpio]) +return chip->irq[gpio];
drivers/gpio/gpio-xgene-sb.c line 141
Quoted 10 lines
drivers/gpio/gpio-xgene-sb.c new file +10
-0+ +return -ENXIO ; +} + +static int xgene_gpio_sb_probe (struct platform_device *pdev) +{ +struct of_mm_gpio_chip *mm; +struct xgene_gpio_sb *apm_gc; +u32 ret, i; +u32 default_pins[] = {0x08 ,0x09 ,0x0A ,0x0B ,0x0C ,0x0D };
Um, pins... call these "lines" instead to avoid confusion with the pin control subsystem.
Quoted 4 lines
drivers/gpio/gpio-xgene-sb.c new file +4
-0+struct resource *res; + + apm_gc =devm_kzalloc (&pdev->dev,sizeof (*apm_gc),GFP_KERNEL ); +if (!apm_gc)
drivers/gpio/gpio-xgene-sb.c line 155
Quoted 10 lines
drivers/gpio/gpio-xgene-sb.c new file +10
-0+return -ENOMEM ; + + mm = &apm_gc->mm; + mm->gc.direction_input = xgene_gpio_sb_dir_in; + mm->gc.direction_output = xgene_gpio_sb_dir_out; + mm->gc.get = xgene_gpio_sb_get; + mm->gc.set = xgene_gpio_sb_set; + mm->gc.to_irq = apm_gpio_sb_to_irq; + mm->gc.base =-1 ; + mm->gc.label =dev_name (&pdev->dev);
gc has a device tree .np node and a .dev struct device * pointer, assign them here. (Also after you switch to GENERIC_GPIO.)
Yours,
Linus Walleij
PATCH RESEND v2 1/3 gpio: Add APM X-Gene standby GPIO controller driver
Quoted 7 lines · Linus Walleij
Quoted 1 line · Y Vo
Add APM X-Gene standby GPIO controller driver.
Write something about what platform an arch this is and so on, this is too terse commit message for a new driver.
Quoted 8 lines
Quoted 1 line
Signed-off-by Y Vo <[email protected]>(...)
drivers/gpio/Kconfig config GPIO_XGENE · line 347
Quoted 3 lines
drivers/gpio/Kconfig +3
-0+config GPIO_XGENE_SB + tristate "APM X-Gene GPIO standby controller support" + depends on ARCH_XGENE && OF_GPIOselect
GPIO_GENERIC
Why ?
Quoted 23 lines
see below on why.
Quoted 10 lines
drivers/gpio/Kconfig +4
-0+ help + This driver supports the GPIO block within the APM X-Gene + Standby Domain. Say yes here to enable the GPIO functionality. + config GPIO_XILINX bool "Xilinx GPIO support" depends on PPC_OF || MICROBLAZE || ARCH_ZYNQdrivers/gpio/gpio-xgene-sb.c new file +0
-0(...)
drivers/gpio/gpio-xgene-sb.c line 26
Quoted 6 lines
+++
b/drivers/gpio/gpio-xgene-sb.cdrivers/gpio/gpio-xgene-sb.c new file +5
-0+#include <linux/module.h> +#include <linux/io.h> +#include <linux/platform_device.h> +#include <linux/of_gpio.h> +#include <linux/gpio.h> #include <
linux/gpio/driver.h>
Quoted 4 lines
instead.
drivers/gpio/gpio-xgene-sb.c line 28
Quoted 2 lines
drivers/gpio/gpio-xgene-sb.c new file +2
-0+#include <linux/of_irq.h> +#include <linux/acpi.h>
OK.
Quoted 3 lines
OK, why?
Quoted 1 line
+#include <
linux/efi.h>
I will remove.
Quoted 4 lines
Why?
drivers/gpio/gpio-xgene-sb.c line 31
Quoted 2 lines
drivers/gpio/gpio-xgene-sb.c new file +2
-0+#include <linux/string.h> +#include <linux/of_address.h>
I will remove.
Quoted 27 lines
#include <
linux/basic_mmio_gpio.h>
when you start usingGENERIC_GPIOQuoted 11 lines
drivers/gpio/gpio-xgene-sb.c new file +11
-0+ +#define XGENE_MAX_GPIO_DS 22 +#define XGENE_MAX_GPIO_DS_IRQ 6 + +#define GPIO_MASK (x) (1U << ((x) % 32)) +#define GPIO_DIR_IN 0 +#define GPIO_DIR_OUT 1 + +#define MPA_GPIO_INT_LVL 0x0290 +#define MPA_GPIO_OE_ADDR 0x029c +#define MPA_GPIO_OUT_ADDR 0x02a0drivers/gpio/gpio-xgene-sb.c line 52
Quoted 10 lines
drivers/gpio/gpio-xgene-sb.c new file +10
-0+#define MPA_GPIO_IN_ADDR 0x02a4 +#define MPA_GPIO_SEL_LO 0x0294 +#define MPA_GPIO_SEL_HIGH 0x029c + +struct xgene_gpio_sb { +struct of_mm_gpio_chip mm; +u32 *irq; +u32 nirq; +spinlock_t lock;/* mutual exclusion */ +};Add kerneldoc to this struct.
Quoted 8 lines
Quoted 1 line
+static void
xgene_gpio_set_bit(void __iomem *reg, u32 gpio, int val)(...)
Quoted 1 line
+static int
xgene_gpio_sb_get(struct gpio_chip *gc, u32 gpio)This looks very much like a memory-mapped standard GPIO controller, use
drivers/gpio/gpio-generic.cwith some IRQ add-on, compare to any other driver selectingGPIO_GENERICfor guidance:drivers/gpio/gpio-74xx-mmio.c,gpio-dwapb.cetc.
You mean I must rewrite to use GPIO_GENERIC follow gpio-74xx-mmio.c, gpio-dwapb.c ?
Quoted 12 lines
Quoted 12 lines
drivers/gpio/gpio-xgene-sb.c new file +12
-0+static int apm_gpio_sb_to_irq (struct gpio_chip *gc,u32 gpio) +{ +struct of_mm_gpio_chip *mm_gc =to_of_mm_gpio_chip (gc); +struct xgene_gpio_sb *chip =to_xgene_gpio_sb (mm_gc); + +if (chip->irq[gpio]) +return chip->irq[gpio]; + +return -ENXIO ; +} + +static int xgene_gpio_sb_probe (struct platform_device *pdev)
Quoted 8 lines
drivers/gpio/gpio-xgene-sb.c line 141
Quoted 5 lines
drivers/gpio/gpio-xgene-sb.c new file +5
-0+{ +struct of_mm_gpio_chip *mm; +struct xgene_gpio_sb *apm_gc; +u32 ret, i; +u32 default_pins[] = {0x08 ,0x09 ,0x0A ,0x0B ,0x0C ,0x0D };Um, pins... call these "lines" instead to avoid confusion with the pin control subsystem.
I will change.
Quoted 20 lines
Quoted 4 lines
drivers/gpio/gpio-xgene-sb.c new file +4
-0+struct resource *res; + + apm_gc =devm_kzalloc (&pdev->dev,sizeof (*apm_gc),GFP_KERNEL ); +if (!apm_gc)drivers/gpio/gpio-xgene-sb.c line 155
Quoted 10 lines
drivers/gpio/gpio-xgene-sb.c new file +10
-0+return -ENOMEM ; + + mm = &apm_gc->mm; + mm->gc.direction_input = xgene_gpio_sb_dir_in; + mm->gc.direction_output = xgene_gpio_sb_dir_out; + mm->gc.get = xgene_gpio_sb_get; + mm->gc.set = xgene_gpio_sb_set; + mm->gc.to_irq = apm_gpio_sb_to_irq; + mm->gc.base =-1 ; + mm->gc.label =dev_name (&pdev->dev);gc has a device tree .np node and a .dev struct device * pointer, assign them here. (Also after you switch to
GENERIC_GPIO.)Yours,
Linus Walleij
PATCH RESEND v2 1/3 gpio: Add APM X-Gene standby GPIO controller driver
Quoted 9 lines · Y Vo
Quoted 4 lines · Linus Walleij
This looks very much like a memory-mapped standard GPIO controller, use
drivers/gpio/gpio-generic.cwith some IRQ add-on, compare to any other driver selectingGPIO_GENERICfor guidance:drivers/gpio/gpio-74xx-mmio.c,gpio-dwapb.cetc.You mean I must rewrite to use
GPIO_GENERICfollowgpio-74xx-mmio.c,gpio-dwapb.c?
Yes.
Yours,
Linus Walleij
PATCH RESEND v2 2/3 Documentation: gpio: Add APM X-Gene standby GPIO controller DTS binding
In reply to Y VoDocumentation for APM X-Gene standby GPIO controller DTS binding.
--- .../devicetree/bindings/gpio/gpio-xgene-sb.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt
Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt new file +31 -0
@@ -0,0 +1,31 @@ +APM X-Gene Standby GPIO controller bindings + +This is a gpio controller in standby domain. + +There are 20 GPIO pins from 0..21. There is no GPIO_DS14 and GPIO_DS15. +Only GPIO_DS8..GPIO_DS13 support interrupt. IRQ mapping 0x28..0x2d. + +Required properties: +- compatible: "apm,xgene-gpio-sb" for X-Gene Standby GPIO controller +- reg: Physical base address and size of the controller's registers +- #gpio-cells: Should be two. + - first cell is the pin number + - second cell is used to specify the gpio polarity: + 0 = active high + 1 = active low +- gpio-controller: Marks the device node as a GPIO controller. +- interrupts: Shall contains the interrupts. + +Example: + sbgpio: sbgpio at 17001000 { + compatible = "apm,xgene-gpio-sb"; + reg = <0x0 0x17001000 0x0 0x400>; + #gpio-cells = <2>; + gpio-controller; + interrupts = <0x0 0x28 0x1>, + <0x0 0x29 0x1>, + <0x0 0x2a 0x1>, + <0x0 0x2b 0x1>, + <0x0 0x2c 0x1>, + <0x0 0x2d 0x1>; + };
Signature · 1 line
2.2.0
PATCH RESEND v2 2/3 Documentation: gpio: Add APM X-Gene standby GPIO controller DTS binding
Quoted 32 lines · Y Vo
Documentation for APM X-Gene standby GPIO controller DTS binding.
Signed-off-by Y Vo <[email protected]>--- .../devicetree/bindings/gpio/gpio-xgene-sb.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txtDocumentation/devicetree/bindings/gpio/gpio-xgene-sb.txt new file +17
-0@@ -0,0 +1,31 @@ +APM X-Gene Standby GPIO controller bindings + +This is a gpio controller in standby domain. + +There are 20 GPIO pins from 0..21. There is no GPIO_DS14 and GPIO_DS15. +Only GPIO_DS8..GPIO_DS13 support interrupt. IRQ mapping 0x28..0x2d. + +Required properties: +- compatible: "apm,xgene-gpio-sb" for X-Gene Standby GPIO controller +- reg: Physical base address and size of the controller's registers +- #gpio-cells: Should be two. + - first cell is the pin number + - second cell is used to specify the gpio polarity: + 0 = active high + 1 = active low +- gpio-controller: Marks the device node as a GPIO controller. +- interrupts: Shall contains the interrupts.
Quoted 1 line
From the example it seems it must contain exactly 6 interrupts?
Then state this.
Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt line 31
Quoted 13 lines
Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt new file +13
-0+Example: + sbgpio: sbgpio at 17001000 { + compatible = "apm,xgene-gpio-sb"; + reg = <0x0 0x17001000 0x0 0x400>; + #gpio-cells = <2>; + gpio-controller; + interrupts = <0x0 0x28 0x1>, + <0x0 0x29 0x1>, + <0x0 0x2a 0x1>, + <0x0 0x2b 0x1>, + <0x0 0x2c 0x1>, + <0x0 0x2d 0x1>; + };
Yours,
Linus Walleij
PATCH RESEND v2 2/3 Documentation: gpio: Add APM X-Gene standby GPIO controller DTS binding
Yes, exactly 6 interrupts. As I describe before:
- There are 22 GPIO_DSs.
- Only 6 GPIO_DSs from 0x08..0xD which supports interrupts
Regards,
Y
Quoted 52 lines · Linus Walleij
Quoted 21 lines · Y Vo
Documentation for APM X-Gene standby GPIO controller DTS binding.
Signed-off-by Y Vo <[email protected]>--- .../devicetree/bindings/gpio/gpio-xgene-sb.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txtDocumentation/devicetree/bindings/gpio/gpio-xgene-sb.txt new file +7
-0@@ -0,0 +1,31 @@ +APM X-Gene Standby GPIO controller bindings + +This is a gpio controller in standby domain. + +There are 20 GPIO pins from 0..21. There is no GPIO_DS14 and GPIO_DS15. +Only GPIO_DS8..GPIO_DS13 support interrupt. IRQ mapping 0x28..0x2d. +Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt line 17
Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt new file +10
-0+Required properties: +- compatible: "apm,xgene-gpio-sb" for X-Gene Standby GPIO controller +- reg: Physical base address and size of the controller's registers +- #gpio-cells: Should be two. + - first cell is the pin number + - second cell is used to specify the gpio polarity: + 0 = active high + 1 = active low +- gpio-controller: Marks the device node as a GPIO controller. +- interrupts: Shall contains the interrupts.From the example it seems it must contain exactly 6 interrupts? Then state this.
Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt line 31
Quoted 13 lines
Documentation/devicetree/bindings/gpio/gpio-xgene-sb.txt new file +13
-0+Example: + sbgpio: sbgpio at 17001000 { + compatible = "apm,xgene-gpio-sb"; + reg = <0x0 0x17001000 0x0 0x400>; + #gpio-cells = <2>; + gpio-controller; + interrupts = <0x0 0x28 0x1>, + <0x0 0x29 0x1>, + <0x0 0x2a 0x1>, + <0x0 0x2b 0x1>, + <0x0 0x2c 0x1>, + <0x0 0x2d 0x1>; + };Yours,
Linus Walleij
PATCH RESEND v2 2/3 Documentation: gpio: Add APM X-Gene standby GPIO controller DTS binding
Quoted 3 lines · Y Vo
Yes, exactly 6 interrupts. As I describe before:
- There are 22GPIO_DSs.
- Only 6GPIO_DSsfrom 0x08..0xD which supports interrupts
What I'm saying is that you need to describe this in the binding document itself.
If you described it somewhere else doesn't count.
So update the patch.
Yours,
Linus Walleij
PATCH RESEND v2 3/3 arm64:dts: Add APM X-Gene standby GPIO controller DTS entries
In reply to Y VoAdd standby domain gpio controller for APM X-Gene SoC platform.
--- arch/arm64/boot/dts/apm-storm.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/apm-storm.dtsi +13 -0
@@ -587,6 +587,19 @@ phy-names = "sata-phy"; }; + sbgpio: sbgpio at 17001000{ + compatible = "apm,xgene-gpio-sb"; + reg = <0x0 0x17001000 0x0 0x400>; + #gpio-cells = <2>; + gpio-controller; + interrupts = <0x0 0x28 0x1>, + <0x0 0x29 0x1>, + <0x0 0x2a 0x1>, + <0x0 0x2b 0x1>, + <0x0 0x2c 0x1>, + <0x0 0x2d 0x1>; + }; + rtc: rtc at 10510000 { compatible = "apm,xgene-rtc"; reg = <0x0 0x10510000 0x0 0x400>;
Signature · 1 line
2.2.0