gpio: Add support for IDT 79RC3243x GPIO controller
Subsystems (2)
PATCH v5 1/2 gpio: Add support for IDT 79RC3243x GPIO controller
IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as an interrupt source.
---
Changes in v5:
- use bgpio spinlock
- made interrupt controller optional
- made ngpios optional
Changes in v4:
- added spinlock to serialize access to irq registers
- reworked checking of irq sense bits
- start with handle_bad_irq and set handle_level_irq in idt_gpio_irq_set_type
- cleaned up #includes
- use platform_get_irq
Changes in v3:
- changed compatible string to idt,32434-gpio
- registers now start with gpio direction register and leaves out alternate function register for pinmux/pinctrl driver
Changes in v2:
- made driver buildable as module
- use for_each_set_bit() in irq dispatch handler
- use gpiochip_get_data instead of own container_of helper
- use module_platform_driver() instead of arch_initcall
- don't default y for Mikrotik RB532
drivers/gpio/Kconfig | 12 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-idt3243x.c | 206 +++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 drivers/gpio/gpio-idt3243x.c
drivers/gpio/Kconfig +12 -0
@@ -782,6 +782,18 @@ config GPIO_MSC313 Say Y here to support the main GPIO block on MStar/SigmaStar ARMv7 based SoCs. +config GPIO_IDT3243X + tristate "IDT 79RC3243X GPIO support" + depends on MIKROTIK_RB532 || COMPILE_TEST + select GPIO_GENERIC + select GPIOLIB_IRQCHIP + help + Select this option to enable GPIO driver for + IDT 79RC3243X based devices like Mikrotik RB532. + + To compile this driver as a module, choose M here: the module will + be called gpio-idt3243x. + endmenu menu "Port-mapped I/O GPIO drivers"
drivers/gpio/Makefile +1 -0
@@ -68,6 +68,7 @@ obj-$(CONFIG_GPIO_HISI) += gpio-hisi.o obj-$(CONFIG_GPIO_HLWD) += gpio-hlwd.o obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o obj-$(CONFIG_GPIO_ICH) += gpio-ich.o +obj-$(CONFIG_GPIO_IDT3243X) += gpio-idt3243x.o obj-$(CONFIG_GPIO_IOP) += gpio-iop.o obj-$(CONFIG_GPIO_IT87) += gpio-it87.o obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o
drivers/gpio/gpio-idt3243x.c new file +206 -0
206 lines not on this page · raw message
Signature · 1 line
2.29.2
PATCH v5 2/2 dt-bindings: gpio: Add devicetree binding for IDT 79RC32434 GPIO controller
Add YAML devicetree binding for IDT 79RC32434 GPIO controller
---
Changes in v5:
- made interrupt controller optional
- made ngpios setting optional
Changes in v4:
- renamed to idt,32434-gpio this time for real
Changes in v3:
- renamed to idt,32434-gpio
- drop ngpio description
- use gpio0: gpio@50004 in example
.../bindings/gpio/idt,32434-gpio.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/idt,32434-gpio.yaml
Documentation/devicetree/bindings/gpio/idt,32434-gpio.yaml new file +67 -0
@@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/idt,32434-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: IDT 79RC32434 GPIO controller + +maintainers: + - Thomas Bogendoerfer <[email protected]> + +properties: + compatible: + const: idt,32434-gpio + + reg: + maxItems: 2 + + reg-names: + items: + - const: gpio + - const: pic + + gpio-controller: true + + "#gpio-cells": + const: 2 + + ngpios: + minimum: 1 + maximum: 32 + + interrupt-controller: true + + "#interrupt-cells": + const: 2 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - reg-names + - gpio-controller + - "#gpio-cells" + +additionalProperties: false + +examples: + - | + gpio0: gpio@50004 { + compatible = "idt,32434-gpio"; + reg = <0x50004 0x10>, <0x38030 0x0c>; + reg-names = "gpio", "pic"; + + interrupt-controller; + #interrupt-cells = <2>; + + interrupt-parent = <&cpuintc>; + interrupts = <6>; + + gpio-controller; + #gpio-cells = <2>; + + ngpios = <14>; + };
Signature · 1 line
2.29.2
Re: [PATCH v5 2/2] dt-bindings: gpio: Add devicetree binding for IDT 79RC32434 GPIO controller
Quoted 17 lines · Thomas Bogendoerfer
Add YAML devicetree binding for IDT 79RC32434 GPIO controller
Signed-off-by Thomas Bogendoerfer <[email protected]>---
Changes in v5:
- made interrupt controller optional
- made ngpios setting optionalChanges in v4:
- renamed to idt,32434-gpio this time for realChanges in v3:
- renamed to idt,32434-gpio
- drop ngpio description
- use gpio0: gpio@50004 in example
Quoted 4 lines
.../bindings/gpio/idt,32434-gpio.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/idt,32434-gpio.yaml
Re: [PATCH v5 2/2] dt-bindings: gpio: Add devicetree binding for IDT 79RC32434 GPIO controller
In reply to Thomas BogendoerferQuoted 5 lines · Thomas Bogendoerfer
Add YAML devicetree binding for IDT 79RC32434 GPIO controller
Signed-off-by Thomas Bogendoerfer <[email protected]>---
Changes in v5:
Yours,
Linus Walleij
Hi Thomas,
thanks for your patch!
I can see this is starting to look really good.
There is one thing that confuses me:
Quoted 6 lines · Thomas Bogendoerfer
IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as an interrupt source.
Signed-off-by Thomas Bogendoerfer <[email protected]>---
Changes in v5:
(...)
Quoted 2 lines
(quoted diff) +2
-0+static int idt_gpio_irq_set_type(struct irq_data *d, unsigned int flow_type) +{
(...)
Quoted 3 lines
drivers/gpio/gpio-idt3243x.c new file +3
-0+/* hardware only supports level triggered */ +if (sense ==IRQ_TYPE_NONE || (sense &IRQ_TYPE_EDGE_BOTH )) +return -EINVAL ;
(...)
Quoted 1 line
+
irq_set_handler_locked(d, handle_level_irq);
But:
Quoted 7 lines
drivers/gpio/gpio-idt3243x.c new file +7
-0+static void idt_gpio_ack (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct idt_gpio_ctrl *ctrl =gpiochip_get_data (gc); + +writel (~BIT (d->hwirq), ctrl->gpio +IDT_GPIO_ISTAT ); +}
(...)
Quoted 1 line
+ .irq_ack =
idt_gpio_ack,
Correct me if I'm wrong but I thing .irq_ack() is only called from handle_edge_irq ... so never in this case.
Can this ACK just be deleted?
The code in the ACK callback also looks really weird:
write all bits except for the current IRQ into the status register? It's usually the other way around with these things. That really makes me suspect it is unused.
Yours,
Linus Walleij
Quoted 38 lines · Linus Walleij
Hi Thomas,
thanks for your patch!
I can see this is starting to look really good.
There is one thing that confuses me:
Quoted 6 lines · Thomas Bogendoerfer
IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as an interrupt source.
Signed-off-by Thomas Bogendoerfer <[email protected]>---
Changes in v5:(...)
Quoted 2 lines
(quoted diff) +2
-0+static int idt_gpio_irq_set_type(struct irq_data *d, unsigned int flow_type) +{(...)
Quoted 3 lines
drivers/gpio/gpio-idt3243x.c new file +3
-0+/* hardware only supports level triggered */ +if (sense ==IRQ_TYPE_NONE || (sense &IRQ_TYPE_EDGE_BOTH )) +return -EINVAL ;(...)
Quoted 1 line
+
irq_set_handler_locked(d, handle_level_irq);But:
Quoted 7 lines
drivers/gpio/gpio-idt3243x.c new file +7
-0+static void idt_gpio_ack (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct idt_gpio_ctrl *ctrl =gpiochip_get_data (gc); + +writel (~BIT (d->hwirq), ctrl->gpio +IDT_GPIO_ISTAT ); +}(...)
Quoted 4 lines
Quoted 1 line
+ .irq_ack =
idt_gpio_ack,Correct me if I'm wrong but I thing .irq_ack() is only called from
handle_edge_irq... so never in this case.
handle_level_irq() does a mask_ack_irq() and this uses mask_irq() and desc->irq_data.chip->irq_ack(), if there is no irq_mask_ack function.
Quoted 1 line
Can this ACK just be deleted?
no without it interrupts won't go away.
Quoted 4 lines
The code in the ACK callback also looks really weird:
write all bits except for the current IRQ into the status register? It's usually the other way around with these things. That really makes me suspect it is unused.
interrupts are acked by writing a 0 to the bit position. I know it's unusal...
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Quoted 29 lines · Thomas Bogendoerfer
IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as an interrupt source.
Signed-off-by Thomas Bogendoerfer <[email protected]>---
Changes in v5:
- use bgpio spinlock
- made interrupt controller optional
- made ngpios optionalChanges in v4:
- added spinlock to serialize access to irq registers
- reworked checking of irq sense bits
- start withhandle_bad_irqand sethandle_level_irqinidt_gpio_irq_set_type
- cleaned up #includes
- useplatform_get_irqChanges in v3:
- changed compatible string to idt,32434-gpio
- registers now start with gpio direction register and leaves out alternate function register for pinmux/pinctrl driverChanges in v2:
- made driver buildable as module
- usefor_each_set_bit()in irq dispatch handler
- usegpiochip_get_datainstead of owncontainer_ofhelper
- usemodule_platform_driver()instead ofarch_initcall
- don't default y for Mikrotik RB532
Quoted 6 lines
drivers/gpio/Kconfig | 12 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-idt3243x.c | 206 +++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 drivers/gpio/gpio-idt3243x.c[...]
is there anything a still need to do to get this integrated for v5.14 ?
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
Linus Walleij
Reviewed-byQuoted 1 line · Thomas Bogendoerfer
is there anything a still need to do to get this integrated for v5.14 ?
IMO not really:
Bartosz is collecting the patches for v5.14.
Yours,
Linus Walleij
Quoted 6 lines · Linus Walleij
Quoted 1 line · Thomas Bogendoerfer
is there anything a still need to do to get this integrated for v5.14 ?
Quoted 7 lines
IMO not really:
Reviewed-by Linus Walleij <[email protected]>Bartosz is collecting the patches for v5.14.
Yours,
Linus Walleij
Sorry for the delay, I'm currently overwhelmed with a house renovation and the approaching move. Now applied (together with the bindings), thanks!
Bartosz