Skip to contentSkip to conversation

dt/bindings: gpio: Document ZTE zx296702 GPIO

PATCH In review Jun Nie 3 participants 10 messages Jun 29, 2015 – Aug 3, 2015

Subsystems (2)
lore
Share & tools
lore

Jun Nie

author
#0 lore raw

PATCH v3 1/2 dt/bindings: gpio: Document ZTE zx296702 GPIO

Add document of ZTE zx296702 GPIO binding

---
 .../devicetree/bindings/gpio/zx296702-gpio.txt     | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/zx296702-gpio.txt
Documentation/devicetree/bindings/gpio/zx296702-gpio.txt new file +24 -0
new file mode 100644
index 0000000..0dab156
@@ -0,0 +1,24 @@
+ZTE ZX296702 GPIO controller
+
+Required properties:
+- compatible : "zte,zx296702-gpio"
+- #gpio-cells : Should be two. The first cell is the pin number and the
+  second cell is used to specify optional parameters:
+  - bit 0 specifies polarity (0 for normal, 1 for inverted)
+- gpio-controller : Marks the device node as a GPIO controller.
+- interrupts : Interrupt mapping for GPIO IRQ.
+- gpio-ranges : Interaction with the PINCTRL subsystem.
+
+gpio1: gpio@b008040 {
+	compatible = "zte,zx296702-gpio";
+	reg = <0xb008040 0x40>;
+	gpio-controller;
+	#gpio-cells = <2>;
+	gpio-ranges = < &pmx0 0 54 2 &pmx0 2 59 14>;
+	interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
+	interrupt-parent = <&intc>;
+	interrupt-controller;
+	#interrupt-cells = <2>;
+	clock-names = "gpio_pclk";
+	clocks = <&lsp0clk ZX296702_GPIO_CLK>;
+};
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v3 2/2 gpio: zx: Add ZTE zx296702 GPIO support

Add ZTE zx296702 GPIO controller support

---
 drivers/gpio/Kconfig   |   6 +
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/gpio-zx.c | 324 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 331 insertions(+)
 create mode 100644 drivers/gpio/gpio-zx.c
drivers/gpio/Kconfig +6 -0
index caefe80..26d34f8 100644
@@ -970,6 +970,12 @@ config GPIO_MC33880
 	  SPI driver for Freescale MC33880 high-side/low-side switch.
 	  This provides GPIO interface supporting inputs and outputs.
 
+config GPIO_ZX
+	bool "ZTE ZX GPIO support"
+	select GPIOLIB_IRQCHIP
+	help
+	  Say yes here to support the GPIO device on ZTE ZX SoCs.
+
 endmenu
 
 menu "USB GPIO expanders"
drivers/gpio/Makefile +1 -0
index f71bb97..e4675c7 100644
@@ -112,3 +112,4 @@ obj-$(CONFIG_GPIO_XILINX)	+= gpio-xilinx.o
 obj-$(CONFIG_GPIO_XTENSA)	+= gpio-xtensa.o
 obj-$(CONFIG_GPIO_ZEVIO)	+= gpio-zevio.o
 obj-$(CONFIG_GPIO_ZYNQ)		+= gpio-zynq.o
+obj-$(CONFIG_GPIO_ZX)		+= gpio-zx.o
drivers/gpio/gpio-zx.c new file +324 -0

324 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#8 lore raw

2015-06-29 16:45 GMT+08:00 Shawn Guo <[email protected]>:

Quoted 8 lines · Jun Nie
Quoted 3 lines

Add document of ZTE zx296702 GPIO binding

For both patches,

Hi Linus,

Could you help merge these two patches? Or you see any issue? Thanks!

[PATCH v3 1/2] dt/bindings: gpio: Document ZTE zx296702 GPIO [PATCH v3 2/2] gpio: zx: Add ZTE zx296702 GPIO support

Jun

#2 lore raw

Re: [PATCH v3 2/2] gpio: zx: Add ZTE zx296702 GPIO support

In reply to Jun Nie
Quoted 3 lines · Jun Nie

Add ZTE zx296702 GPIO controller support

Patch applied with Shawn's ACK.

Kudos for using GPIOLIB_IRQCHIP, well done.

drivers/gpio/gpio-zx.c line 256

Quoted 2 lines
drivers/gpio/gpio-zx.c new file +2 -0
+       if (of_property_read_bool(dev->of_node, "gpio-ranges"))
+               chip->uses_pinctrl = true;

I see this follows the PL061 pattern, maybe we should start doing this in the gpiolib core.

Yours,
Linus Walleij

author
#3 lore raw

Re: [PATCH v3 2/2] gpio: zx: Add ZTE zx296702 GPIO support

2015-07-16 16:17 GMT+08:00 Linus Walleij <[email protected]>:

Quoted 8 lines · Jun Nie
Quoted 4 lines

Add ZTE zx296702 GPIO controller support

Patch applied with Shawn's ACK.

Quoted 7 lines

Kudos for using GPIOLIB_IRQCHIP, well done.

drivers/gpio/gpio-zx.c line 256

Quoted 2 lines
drivers/gpio/gpio-zx.c new file +2 -0
+       if (of_property_read_bool(dev->of_node, "gpio-ranges"))
+               chip->uses_pinctrl = true;

I see this follows the PL061 pattern, maybe we should start doing this in the gpiolib core.

A structure with all functions and flags can be feed to a new function that calls gpiochip_add(). We can abstract logic of struct gpio_chip members value assignment. For example, a struct gpio_chip with these members assigned at compiling stage can be copied directly to instantiation memory space and call gpiochip_add(). We can do this in driver too.

For interrupt stuff, it is hard to abstract because argument vary much from driver to driver and different functions are called in different drivers. A structure can also serve more or less to abstract function calls, but not much.

What's your thoughts?

Quoted 3 lines

Yours,
Linus Walleij

#4 lore raw

Re: [PATCH v3 2/2] gpio: zx: Add ZTE zx296702 GPIO support

Quoted 8 lines · Jun Nie

2015-07-16 16:17 GMT+08:00 Linus Walleij <[email protected]>:

Quoted 5 lines

drivers/gpio/gpio-zx.c line 256

Quoted 2 lines
drivers/gpio/gpio-zx.c new file +2 -0
+       if (of_property_read_bool(dev->of_node, "gpio-ranges"))
+               chip->uses_pinctrl = true;

I see this follows the PL061 pattern, maybe we should start doing this in the gpiolib core.

Quoted 6 lines

A structure with all functions and flags can be feed to a new function that calls gpiochip_add(). We can abstract logic of struct gpio_chip members value assignment. For example, a struct gpio_chip with these members assigned at compiling stage can be copied directly to instantiation memory space and call gpiochip_add(). We can do this in driver too.

Hm anything that will result in a lot of code lines saved in drivers is by definition good. This could be a good start.

Quoted 4 lines

For interrupt stuff, it is hard to abstract because argument vary much from driver to driver and different functions are called in different drivers. A structure can also serve more or less to abstract function calls, but not much.

Yeah I really tried my best with gpiolib_irqchip_add() and managed to cut down on all the simple IRQ drivers. Don't think we get any further with these.

Yours,
Linus Walleij

author
#5 lore raw

Re: [PATCH v3 2/2] gpio: zx: Add ZTE zx296702 GPIO support

2015-07-27 17:51 GMT+08:00 Linus Walleij <[email protected]>:

Quoted 16 lines · Jun Nie
Quoted 8 lines

2015-07-16 16:17 GMT+08:00 Linus Walleij <[email protected]>:

Quoted 5 lines

drivers/gpio/gpio-zx.c line 256

Quoted 2 lines
drivers/gpio/gpio-zx.c new file +2 -0
+       if (of_property_read_bool(dev->of_node, "gpio-ranges"))
+               chip->uses_pinctrl = true;

I see this follows the PL061 pattern, maybe we should start doing this in the gpiolib core.

Quoted 6 lines

A structure with all functions and flags can be feed to a new function that calls gpiochip_add(). We can abstract logic of struct gpio_chip members value assignment. For example, a struct gpio_chip with these members assigned at compiling stage can be copied directly to instantiation memory space and call gpiochip_add(). We can do this in driver too.

Quoted 2 lines

Hm anything that will result in a lot of code lines saved in drivers is by definition good. This could be a good start.

Above solution only save runtime CPU cycle with a memory copy because structure with member assigned in compile time also takes code lines.

We can wrap gpiochip_add into new function gpiochip_add_arg() and feed below info to it and assign the value in the common code. It is make the function argument list too long. Any better idea? Or you think it is OK, then I can draft a patch for review.

gpio_chip members: direction_input, direction_output, get, set, request, free, ngpio, label, dev.

Jun

Quoted 12 lines
Quoted 5 lines

For interrupt stuff, it is hard to abstract because argument vary much from driver to driver and different functions are called in different drivers. A structure can also serve more or less to abstract function calls, but not much.

Yeah I really tried my best with gpiolib_irqchip_add() and managed to cut down on all the simple IRQ drivers. Don't think we get any further with these.

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH v3 2/2] gpio: zx: Add ZTE zx296702 GPIO support

Quoted 7 lines · Jun Nie

We can wrap gpiochip_add into new function gpiochip_add_arg() and feed below info to it and assign the value in the common code. It is make the function argument list too long. Any better idea? Or you think it is OK, then I can draft a patch for review.

gpio_chip members: direction_input, direction_output, get, set, request, free, ngpio, label, dev.

Nah I don't see that very different from assigning the vtable directly in the code, it merely creates a function call to do the same so don't bother with it.

Yours,
Linus Walleij