PINT irqchip driver for NXP LPC18xx family
Subsystems (3)
cover PINT irqchip driver for NXP LPC18xx family
The LPC1850 has no less than 3 GPIO interrupt blocks. One of these blocks is called 'gpio pin interrupt' or just PINT. LPC1850 PINT can handle up to 8 interrupts and these have a one-to-one relationship with the main interrupt controller (NVIC).
The interrupts on PINT can be either level or edge trigger and supports any polarity.
This patch set adds an irqchip driver for the PINT found on lpc18xx.
Joachim Eastwood (2):
irqchip: add lpc18xx gpio pin interrupt driver
devicetree: document NXP LPC1850 PINT irq controller binding
.../interrupt-controller/nxp,lpc1850-gpio-pint.txt | 22 ++ drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-lpc18xx-gpio-pint.c | 238 +++++++++++++++++++++ 4 files changed, 266 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt create mode 100644 drivers/irqchip/irq-lpc18xx-gpio-pint.c
Signature · 1 line
1.8.0
PATCH 1/2 irqchip: add lpc18xx gpio pin interrupt driver
NXP LPC18xx has an interrupt controller called 'gpio pin interrupt' or just PINT. The PINT can handle up to 8 interrupts and these have a one-to-one relationship with the main interrupt controller (NVIC). The interrupts on PINT can be either level or edge trigger and supports any polarity.
Selection of which GPIOs that are connected to the PINT is done by the lpc18xx pinctrl driver (SCU).
--- drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-lpc18xx-gpio-pint.c | 238 ++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 drivers/irqchip/irq-lpc18xx-gpio-pint.c
drivers/irqchip/Kconfig +5 -0
@@ -190,6 +190,11 @@ config KEYSTONE_IRQ Support for Texas Instruments Keystone 2 IRQ controller IP which is part of the Keystone 2 IPC mechanism +config LPC18XX_GPIO_PINT + bool + select IRQ_DOMAIN + select GENERIC_IRQ_CHIP + config MIPS_GIC bool select MIPS_CM
drivers/irqchip/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_BCM7038_L1_IRQ) += irq-bcm7038-l1.o obj-$(CONFIG_BCM7120_L2_IRQ) += irq-bcm7120-l2.o obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o +obj-$(CONFIG_LPC18XX_GPIO_PINT) += irq-lpc18xx-gpio-pint.o obj-$(CONFIG_MIPS_GIC) += irq-mips-gic.o obj-$(CONFIG_ARCH_MEDIATEK) += irq-mtk-sysirq.o obj-$(CONFIG_ARCH_DIGICOLOR) += irq-digicolor.o
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +238 -0
238 lines not on this page · raw message
Signature · 1 line
1.8.0
Re: [PATCH 1/2] irqchip: add lpc18xx gpio pin interrupt driver
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 44
Quoted 9 lines · Joachim Eastwood
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +9
-0+static void lpc18xx_gpio_pint_handler (struct irq_desc *desc) +{ +struct lpc18xx_gpio_pint_chip *pint =irq_desc_get_handler_data (desc); +unsigned int irq =irq_desc_get_irq (desc); +int irq_no, i; + +/* Find the interrupt */ +for (i =0 ; i < pint->nrirqs; i++) { +if (pint->irqmap[i] == irq) {
Why don't you have a reverse map for this?
Quoted 5 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +5
-0+ irq_no =irq_find_mapping (pint->domain, i); +generic_handle_irq (irq_no); + } + } +}
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 59
Quoted 10 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +10
-0+ +static void lpc18xx_gpio_pint_edge_ack (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = d->mask; + +irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_IST ); +irq_gc_unlock (gc); +}
How is that different from irq_gc_ack_set_bit ?
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 70
Quoted 10 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +10
-0+static void lpc18xx_gpio_pint_edge_mask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = d->mask; + +irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_CIENR ); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_CIENF ); +irq_gc_unlock (gc); +}
If you use seperate irq types, then you can use the generic chip functions and be done with it.
Quoted 23 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +23
-0+static void lpc18xx_gpio_pint_edge_unmask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 type, mask = d->mask; + +irq_gc_lock (gc); + type =irqd_get_trigger_type (d); +if (type &IRQ_TYPE_EDGE_RISING ) +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_SIENR ); +if (type &IRQ_TYPE_EDGE_FALLING ) +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_SIENF ); +irq_gc_unlock (gc); +} + +static void lpc18xx_gpio_pint_level_mask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = d->mask; + +irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_CIENR ); +irq_gc_unlock (gc); +}
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 104
Quoted 10 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +10
-0+ +static void lpc18xx_gpio_pint_level_unmask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = d->mask; + +irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_SIENR ); +irq_gc_unlock (gc); +}
All the callbacks can go away.
Quoted 16 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +16
-0+static int lpc18xx_gpio_pint_type (struct irq_data *data,unsigned int type) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (data); +u32 mask = data->mask; + +irq_gc_lock (gc); +if (type &IRQ_TYPE_LEVEL_MASK ) + gc->type_cache |= mask; +else + gc->type_cache &= ~mask; +irq_reg_writel (gc, gc->type_cache,LPC18XX_GPIO_PINT_ISEL ); + +switch (type) { +case IRQ_TYPE_LEVEL_HIGH : +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_SIENF ); +break ;
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 131
Quoted 10 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +10
-0+ +case IRQ_TYPE_LEVEL_LOW : +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_CIENF ); +break ; + +/* IRQ_TYPE_EDGE_* is set in lpc18xx_gpio_pint_edge_unmask */ + } + +irqd_set_trigger_type (data, type); +irq_setup_alt_chip (data, type);
So you already use an alt chip, but still implement your own callbacks?
WHY?
Thanks,
tglx
Re: [PATCH 1/2] irqchip: add lpc18xx gpio pin interrupt driver
Hi Thomas,
Quoted 12 lines · Thomas Gleixner
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 44
Quoted 9 lines · Joachim Eastwood
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +9
-0+static void lpc18xx_gpio_pint_handler (struct irq_desc *desc) +{ +struct lpc18xx_gpio_pint_chip *pint =irq_desc_get_handler_data (desc); +unsigned int irq =irq_desc_get_irq (desc); +int irq_no, i; + +/* Find the interrupt */ +for (i =0 ; i < pint->nrirqs; i++) { +if (pint->irqmap[i] == irq) {Why don't you have a reverse map for this?
Is there any thing it the irq subsystem for this that I can use?
I have now implement one based on linear_revmap in the irq domain code and it seems to work. Slightly more code and I needed two loops in probe. First one to determine the max virq number from the main irq controller and then another one to create the mapping/register the irq themselves.
Looked at radix tree also, but I think it might be overkill here.
What do you think?
Quoted 9 lines
Quoted 9 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +9
-0+ irq_no =irq_find_mapping (pint->domain, i); +generic_handle_irq (irq_no); + } + } +} + +static void lpc18xx_gpio_pint_edge_ack (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);
Quoted 8 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 59
Quoted 6 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +6
-0+u32 mask = d->mask; + +irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_IST ); +irq_gc_unlock (gc); +}How is that different from
irq_gc_ack_set_bit?
No, the generic one is same. I'll fix it.
Quoted 5 lines
Quoted 5 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +5
-0+static void lpc18xx_gpio_pint_edge_mask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = d->mask; +
Quoted 8 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 70
Quoted 5 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +5
-0+irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_CIENR ); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_CIENF ); +irq_gc_unlock (gc); +}If you use seperate irq types, then you can use the generic chip functions and be done with it.
Do you mean one type for IRQ_TYPE_EDGE_RISING and one for IRQ_TYPE_EDGE_FALLING?
Will those two handle the EDGE_BOTH case too? or do I need a type for that also?
Quoted 27 lines
Quoted 27 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +27
-0+static void lpc18xx_gpio_pint_edge_unmask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 type, mask = d->mask; + +irq_gc_lock (gc); + type =irqd_get_trigger_type (d); +if (type &IRQ_TYPE_EDGE_RISING ) +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_SIENR ); +if (type &IRQ_TYPE_EDGE_FALLING ) +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_SIENF ); +irq_gc_unlock (gc); +} + +static void lpc18xx_gpio_pint_level_mask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +u32 mask = d->mask; + +irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_CIENR ); +irq_gc_unlock (gc); +} + +static void lpc18xx_gpio_pint_level_unmask (struct irq_data *d) +{ +struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);
Quoted 8 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 84
Quoted 6 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +6
-0+u32 mask = d->mask; + +irq_gc_lock (gc); +irq_reg_writel (gc, mask,LPC18XX_GPIO_PINT_SIENR ); +irq_gc_unlock (gc); +}All the callbacks can go away.
I have now replaced lpc18xx_gpio_pint_edge_ack, lpc18xx_gpio_pint_level_mask and lpc18xx_gpio_pint_level_unmask with the equivalent generic versions.
Thanks for taking the time to look at this, Thomas.
regards,
Joachim Eastwood
PATCH 2/2 devicetree: document NXP LPC1850 PINT irq controller binding
In reply to Joachim EastwoodAdd binding documentation for NXP LPC1850 GPIO Pin Interrupt (PINT) controller.
--- .../interrupt-controller/nxp,lpc1850-gpio-pint.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt
Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt new file +22 -0
@@ -0,0 +1,22 @@ +NXP LPC18xx/43xx GPIO Pin Interrupt (PINT) controller + +Required properties: + +- compatible : should be "nxp,lpc1850-gpio-pint". +- reg : Specifies base physical address and size of the registers. +- interrupt-controller : Identifies the node as an interrupt controller +- #interrupt-cells : Specifies the number of cells needed to encode an + interrupt source. The value shall be 2. +- interrupts : Specifies the CPU interrupts the controller is connected to. +- clocks: Must contain a reference to the functional clock. + +Example: + +pint: interrupt-controller at 40087000 { + compatible = "nxp,lpc1850-gpio-pint"; + reg = <0x40087000 0x1000>; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = <32 33 34 35 36 37 38 39>; + clocks = <&ccu1 CLK_CPU_GPIO>; +};
Signature · 1 line
1.8.0
Rob Herring
maintainerRe: [PATCH 2/2] devicetree: document NXP LPC1850 PINT irq controller binding
Quoted 15 lines · Joachim Eastwood
Add binding documentation for NXP LPC1850 GPIO Pin Interrupt (PINT) controller.
Signed-off-by Joachim Eastwood <[email protected]>--- .../interrupt-controller/nxp,lpc1850-gpio-pint.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txtDocumentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt new file +0
-0
Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt line 10
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt new file +10
-0@@ -0,0 +1,22 @@ +NXP LPC18xx/43xx GPIO Pin Interrupt (PINT) controller + +Required properties: + +- compatible : should be "nxp,lpc1850-gpio-pint". +- reg : Specifies base physical address and size of the registers. +- interrupt-controller : Identifies the node as an interrupt controller +- #interrupt-cells : Specifies the number of cells needed to encode an + interrupt source. The value shall be 2. +- interrupts : Specifies the CPU interrupts the controller is connected to.
How many (8?) and what's the ordering?
Quoted 19 lines
Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt new file +12
-0+- clocks: Must contain a reference to the functional clock. + +Example: + +pint: interrupt-controller at 40087000 { + compatible = "nxp,lpc1850-gpio-pint"; + reg = <0x40087000 0x1000>; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = <32 33 34 35 36 37 38 39>; + clocks = <&ccu1 CLK_CPU_GPIO>; +};Signature · 6 lines
1.8.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] devicetree: document NXP LPC1850 PINT irq controller binding
Quoted 20 lines · Rob Herring
Quoted 19 lines · Joachim Eastwood
Add binding documentation for NXP LPC1850 GPIO Pin Interrupt (PINT) controller.
Signed-off-by Joachim Eastwood <[email protected]>--- .../interrupt-controller/nxp,lpc1850-gpio-pint.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txtDocumentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt new file +4
-0@@ -0,0 +1,22 @@ +NXP LPC18xx/43xx GPIO Pin Interrupt (PINT) controller + +Required properties: +
Quoted 8 lines
Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt line 10
Quoted 6 lines
Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt new file +6
-0+- compatible : should be "nxp,lpc1850-gpio-pint". +- reg : Specifies base physical address and size of the registers. +- interrupt-controller : Identifies the node as an interrupt controller +- #interrupt-cells : Specifies the number of cells needed to encode an + interrupt source. The value shall be 2. +- interrupts : Specifies the CPU interrupts the controller is connected to.How many (8?) and what's the ordering?
The PINT on has 8 interrupts, but this is device dependent. Up to 32 could be supported.
The order is also device dependent. The interrupts on PINT are merely mapped onto the main interrupt controller.
I tried to keep the wording in the binding generic so it could support the PINT on different devices. I'll update the text with some more details.
regards,
Joachim Eastwood