Skip to contentSkip to conversation

add a driver for the Synopsys DesignWare APB GPIO block

PATCH Superseded Alan Tull 3 participants 7 messages Dec 3, 2013 – Dec 5, 2013

Subsystems (3)

v8 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Alan Tull

author
#0 lore raw

PATCH v8 1/1 add a driver for the Synopsys DesignWare APB GPIO block

From: Alan Tull <[email protected]>

Minor cleanup from v7 as noted below.

Hi Jamie,

I changed the interrupt implementation of your driver to work with the current kernel (wouldn't build othewise). Could you please test and let me know if this will work for you?

Alan

Jamie Iles (1):
gpio: add a driver for the Synopsys DesignWare APB GPIO block

 .../devicetree/bindings/gpio/snps-dwapb-gpio.txt   |   57 +++
 drivers/gpio/Kconfig                               |    9 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-dwapb.c                          |  426 ++++++++++++++++++++
 4 files changed, 493 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
 create mode 100644 drivers/gpio/gpio-dwapb.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v8 1/1 gpio: add a driver for the Synopsys DesignWare APB GPIO block

From: Jamie Iles <[email protected]>

The Synopsys DesignWare block is used in some ARM devices (picoxcell) and can be configured to provide multiple banks of GPIO pins.

v8: - remove socfpga.dtsi changes
- minor cleanup in devicetree documentation
v7: - use irq_generic_chip
- support one irq per gpio line or one irq for many
- s/bank/port/ and other cleanup
v6: - (atull) squash the set of patches
- use linear irq domain
- build fixes. Original driver was reviewed on v3.2.
- Fix setting irq edge type for 'rising' and 'both'.
- Support as a loadable module.
- Use bgpio_chip's spinlock during register access.
- Clean up register names to match spec
- s/bank/port/ because register names use the word 'port'
- s/nr-gpio/nr-gpios/
- don't get/put the of_node
- remove signoffs/acked-by's because of changes
- other cleanup
v5: - handle sparse bank population correctly
v3: - depend on rather than select IRQ_DOMAIN
- split IRQ support into a separate patch
v2: - use Rob Herring's irqdomain in generic irq chip patches
- use reg property to indicate bank index
- support irqs on both edges based on LinusW's u300 driver

---
 .../devicetree/bindings/gpio/snps-dwapb-gpio.txt   |   57 +++
 drivers/gpio/Kconfig                               |    9 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-dwapb.c                          |  426 ++++++++++++++++++++
 4 files changed, 493 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
 create mode 100644 drivers/gpio/gpio-dwapb.c
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +57 -0
new file mode 100644
index 0000000..e7f144f
@@ -0,0 +1,57 @@
+* Synopsys DesignWare APB GPIO controller
+
+Required properties:
+- compatible : Should be "snps,dw-apb-gpio"
+- reg : Address and length of the register set for the device
+
+The GPIO controller has a configurable number of ports, each of which are
+represented as child nodes with the following properties:
+
+Required properties:
+- compatible : "snps,dw-apb-gpio-port"
+- gpio-controller : Marks the device node as a gpio controller.
+- #gpio-cells : Should be two.  The first cell is the pin number and
+  the second cell is used to specify optional parameters (currently
+  unused).
+- reg : The integer port index of the port, a single cell.
+
+Optional properties:
+- interrupt-controller : The first port may be configured to be an interrupt
+controller.
+- #interrupt-cells : Specifies the number of cells needed to encode an
+interrupt.  Shall be set to 2.  The first cell defines the interrupt number,
+the second encodes the triger flags encoded as described in
+Documentation/devicetree/bindings/interrupts.txt
+- interrupt-parent : The parent interrupt controller.
+- interrupts : The interrupts to the parent controller raised when GPIOs
+generate the interrupts.
+- snps,nr-gpios : The number of pins in the port, a single cell.
+
+Example:
+
+gpio: gpio@20000 {
+	compatible = "snps,dw-apb-gpio";
+	reg = <0x20000 0x1000>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	porta: gpio-controller@0 {
+		compatible = "snps,dw-apb-gpio-port";
+		gpio-controller;
+		#gpio-cells = <2>;
+		snps,nr-gpio = <8>;
+		reg = <0>;
+		interrupt-controller;
+		#interrupt-cells = <2>;
+		interrupt-parent = <&vic1>;
+		interrupts = <0 1 2 3 4 5 6 7>;
+	};
+
+	portb: gpio-controller@1 {
+		compatible = "snps,dw-apb-gpio-port";
+		gpio-controller;
+		#gpio-cells = <2>;
+		snps,nr-gpio = <8>;
+		reg = <1>;
+	};
+};
drivers/gpio/Kconfig +9 -0
index b6ed304..14ec4e4 100644
@@ -121,6 +121,15 @@ config GPIO_GENERIC_PLATFORM
 	help
 	  Say yes here to support basic platform_device memory-mapped GPIO controllers.
 
+config GPIO_DWAPB
+	tristate "Synopsys DesignWare APB GPIO driver"
+	select GPIO_GENERIC
+	select GENERIC_IRQ_CHIP
+	depends on OF_GPIO && IRQ_DOMAIN
+	help
+	  Say Y or M here to build support for the Synopsys DesignWare APB
+	  GPIO block.
+
 config GPIO_IT8761E
 	tristate "IT8761E GPIO support"
 	depends on X86  # unconditional access to IO space.
drivers/gpio/Makefile +1 -0
index 98e23eb..8de041a 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_GPIO_CS5535)	+= gpio-cs5535.o
 obj-$(CONFIG_GPIO_DA9052)	+= gpio-da9052.o
 obj-$(CONFIG_GPIO_DA9055)	+= gpio-da9055.o
 obj-$(CONFIG_ARCH_DAVINCI)	+= gpio-davinci.o
+obj-$(CONFIG_GPIO_DWAPB)	+= gpio-dwapb.o
 obj-$(CONFIG_GPIO_EM)		+= gpio-em.o
 obj-$(CONFIG_GPIO_EP93XX)	+= gpio-ep93xx.o
 obj-$(CONFIG_GPIO_F7188X)	+= gpio-f7188x.o
drivers/gpio/gpio-dwapb.c new file +426 -0

426 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v8] gpio: add a driver for the Synopsys DesignWare APB GPIO block

Quoted 46 lines · Alan Tull

From: Jamie Iles <[email protected]>

The Synopsys DesignWare block is used in some ARM devices (picoxcell) and can be configured to provide multiple banks of GPIO pins.

v8: - remove socfpga.dtsi changes
- minor cleanup in devicetree documentation
v7: - use irq_generic_chip
- support one irq per gpio line or one irq for many
- s/bank/port/ and other cleanup
v6: - (atull) squash the set of patches
- use linear irq domain
- build fixes. Original driver was reviewed on v3.2.
- Fix setting irq edge type for 'rising' and 'both'.
- Support as a loadable module.
- Use bgpio_chip's spinlock during register access.
- Clean up register names to match spec
- s/bank/port/ because register names use the word 'port'
- s/nr-gpio/nr-gpios/
- don't get/put the of_node
- remove signoffs/acked-by's because of changes
- other cleanup

v5:     - handle sparse bank population correctly
v3:     - depend on rather than select IRQ_DOMAIN

- split IRQ support into a separate patch
v2: - use Rob Herring's irqdomain in generic irq chip patches
- use reg property to indicate bank index
- support irqs on both edges based on LinusW's u300 driver

---
 .../devicetree/bindings/gpio/snps-dwapb-gpio.txt   |   57 +++
 drivers/gpio/Kconfig                               |    9 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-dwapb.c                          |  426 ++++++++++++++++++++
 4 files changed, 493 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
 create mode 100644 drivers/gpio/gpio-dwapb.c
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +0 -0
new file mode 100644
index 0000000..e7f144f

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +4 -0
@@ -0,0 +1,57 @@
+* Synopsys DesignWare APB GPIO controller
+
+Required properties:
+- compatible : Should be "snps,dw-apb-gpio"

s/be/contain/

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt line 5

Quoted 1 line
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +1 -0
+- reg : Address and length of the register set for the device

As this has children with reg entries, it should have #address-cells and #size-cells (as the example does).

Quoted 32 lines
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +32 -0
+
+The GPIO controller has a configurable number of ports, each of which are
+represented as child nodes with the following properties:
+
+Required properties:
+- compatible : "snps,dw-apb-gpio-port"
+- gpio-controller : Marks the device node as a gpio controller.
+- #gpio-cells : Should be two.  The first cell is the pin number and
+  the second cell is used to specify optional parameters (currently
+  unused).
+- reg : The integer port index of the port, a single cell.
+
+Optional properties:
+- interrupt-controller : The first port may be configured to be an interrupt
+controller.
+- #interrupt-cells : Specifies the number of cells needed to encode an
+interrupt.  Shall be set to 2.  The first cell defines the interrupt number,
+the second encodes the triger flags encoded as described in
+Documentation/devicetree/bindings/interrupts.txt
+- interrupt-parent : The parent interrupt controller.
+- interrupts : The interrupts to the parent controller raised when GPIOs
+generate the interrupts.
+- snps,nr-gpios : The number of pins in the port, a single cell.
+
+Example:
+
+gpio: gpio@20000 {
+       compatible = "snps,dw-apb-gpio";
+       reg = <0x20000 0x1000>;
+       #address-cells = <1>;
+       #size-cells = <0>;
+

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt line 47

Quoted 10 lines
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +10 -0
+       porta: gpio-controller@0 {
+               compatible = "snps,dw-apb-gpio-port";
+               gpio-controller;
+               #gpio-cells = <2>;
+               snps,nr-gpio = <8>;
+               reg = <0>;
+               interrupt-controller;
+               #interrupt-cells = <2>;
+               interrupt-parent = <&vic1>;
+               interrupts = <0 1 2 3 4 5 6 7>;

Nit: please bracket list entries individually.

Otherwise this looks fine to me.

Thanks,
Mark.

#3 lore raw

Re: [PATCH v8] gpio: add a driver for the Synopsys DesignWare APB GPIO block

Quoted 104 lines · Mark Rutland
Quoted 46 lines · Alan Tull

From: Jamie Iles <[email protected]>

The Synopsys DesignWare block is used in some ARM devices (picoxcell) and can be configured to provide multiple banks of GPIO pins.

v8: - remove socfpga.dtsi changes
- minor cleanup in devicetree documentation
v7: - use irq_generic_chip
- support one irq per gpio line or one irq for many
- s/bank/port/ and other cleanup
v6: - (atull) squash the set of patches
- use linear irq domain
- build fixes. Original driver was reviewed on v3.2.
- Fix setting irq edge type for 'rising' and 'both'.
- Support as a loadable module.
- Use bgpio_chip's spinlock during register access.
- Clean up register names to match spec
- s/bank/port/ because register names use the word 'port'
- s/nr-gpio/nr-gpios/
- don't get/put the of_node
- remove signoffs/acked-by's because of changes
- other cleanup

v5:     - handle sparse bank population correctly
v3:     - depend on rather than select IRQ_DOMAIN

- split IRQ support into a separate patch
v2: - use Rob Herring's irqdomain in generic irq chip patches
- use reg property to indicate bank index
- support irqs on both edges based on LinusW's u300 driver

---
 .../devicetree/bindings/gpio/snps-dwapb-gpio.txt   |   57 +++
 drivers/gpio/Kconfig                               |    9 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-dwapb.c                          |  426 ++++++++++++++++++++
 4 files changed, 493 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt
 create mode 100644 drivers/gpio/gpio-dwapb.c
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +0 -0
new file mode 100644
index 0000000..e7f144f

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +4 -0
@@ -0,0 +1,57 @@
+* Synopsys DesignWare APB GPIO controller
+
+Required properties:
+- compatible : Should be "snps,dw-apb-gpio"

s/be/contain/

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt line 5

Quoted 1 line
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +1 -0
+- reg : Address and length of the register set for the device

As this has children with reg entries, it should have #address-cells and #size-cells (as the example does).

Quoted 32 lines
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +32 -0
+
+The GPIO controller has a configurable number of ports, each of which are
+represented as child nodes with the following properties:
+
+Required properties:
+- compatible : "snps,dw-apb-gpio-port"
+- gpio-controller : Marks the device node as a gpio controller.
+- #gpio-cells : Should be two.  The first cell is the pin number and
+  the second cell is used to specify optional parameters (currently
+  unused).
+- reg : The integer port index of the port, a single cell.
+
+Optional properties:
+- interrupt-controller : The first port may be configured to be an interrupt
+controller.
+- #interrupt-cells : Specifies the number of cells needed to encode an
+interrupt.  Shall be set to 2.  The first cell defines the interrupt number,
+the second encodes the triger flags encoded as described in
+Documentation/devicetree/bindings/interrupts.txt
+- interrupt-parent : The parent interrupt controller.
+- interrupts : The interrupts to the parent controller raised when GPIOs
+generate the interrupts.
+- snps,nr-gpios : The number of pins in the port, a single cell.
+
+Example:
+
+gpio: gpio@20000 {
+       compatible = "snps,dw-apb-gpio";
+       reg = <0x20000 0x1000>;
+       #address-cells = <1>;
+       #size-cells = <0>;
+

Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt line 47

Quoted 10 lines
Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt new file +10 -0
+       porta: gpio-controller@0 {
+               compatible = "snps,dw-apb-gpio-port";
+               gpio-controller;
+               #gpio-cells = <2>;
+               snps,nr-gpio = <8>;
+               reg = <0>;
+               interrupt-controller;
+               #interrupt-cells = <2>;
+               interrupt-parent = <&vic1>;
+               interrupts = <0 1 2 3 4 5 6 7>;

Nit: please bracket list entries individually.

Quoted 4 lines

Otherwise this looks fine to me.

Thanks,
Mark.

Hi Mark,

Thanks for the feedback. I'll include fixes in v9 which I'll post within a few days.

Alan Tull

#4 lore raw

Re: [PATCH v8] gpio: add a driver for the Synopsys DesignWare APB GPIO block

In reply to Alan Tull

Hi Alan,

One minor comment below, otherwise looks great!

Thanks,

Jamie

Quoted 5 lines · Alan Tull
drivers/gpio/gpio-dwapb.c new file +0 -0
new file mode 100644
index 0000000..e6dc61f

...

drivers/gpio/gpio-dwapb.c line 74

Quoted 10 lines
drivers/gpio/gpio-dwapb.c new file +10 -0
+static unsigned int dwapb_gpio_nr_ports(struct device_node *of_node)
+{
+	unsigned int nr_ports = 0;
+	struct device_node *np;
+
+	for_each_child_of_node(of_node, np)
+		++nr_ports;
+
+	return nr_ports;
+}

I notice that we now have of_get_child_count() which didn't exist when I first wrote the driver, we could use that now.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH v8] gpio: add a driver for the Synopsys DesignWare APB GPIO block

Quoted 17 lines · Jamie Iles

Hi Alan,

One minor comment below, otherwise looks great!

Thanks,

Jamie

Quoted 5 lines · Alan Tull
drivers/gpio/gpio-dwapb.c new file +0 -0
new file mode 100644
index 0000000..e6dc61f

...

Quoted 13 lines

drivers/gpio/gpio-dwapb.c line 74

Quoted 10 lines
drivers/gpio/gpio-dwapb.c new file +10 -0
+static unsigned int dwapb_gpio_nr_ports(struct device_node *of_node)
+{
+     unsigned int nr_ports = 0;
+     struct device_node *np;
+
+     for_each_child_of_node(of_node, np)
+             ++nr_ports;
+
+     return nr_ports;
+}

I notice that we now have of_get_child_count() which didn't exist when I first wrote the driver, we could use that now.

Thanks Jamie.

I'll include that in v8. I'll post that within a few days.

Alan

#6 lore raw

Re: [PATCH v8] gpio: add a driver for the Synopsys DesignWare APB GPIO block

Quoted 32 lines · delicious quinoa
Quoted 17 lines · Jamie Iles

Hi Alan,

One minor comment below, otherwise looks great!

Thanks,

Jamie

Quoted 5 lines · Alan Tull
drivers/gpio/gpio-dwapb.c new file +0 -0
new file mode 100644
index 0000000..e6dc61f

...

Quoted 13 lines

drivers/gpio/gpio-dwapb.c line 74

Quoted 10 lines
drivers/gpio/gpio-dwapb.c new file +10 -0
+static unsigned int dwapb_gpio_nr_ports(struct device_node *of_node)
+{
+     unsigned int nr_ports = 0;
+     struct device_node *np;
+
+     for_each_child_of_node(of_node, np)
+             ++nr_ports;
+
+     return nr_ports;
+}

I notice that we now have of_get_child_count() which didn't exist when I first wrote the driver, we could use that now.

Quoted 5 lines

Thanks Jamie.

I'll include that in v8. I'll post that within a few days.

Alan

er, I mean v9.

Alan
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html