PINT irqchip driver for NXP LPC18xx family
Subsystems (3)
v2 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 a irqchip driver for PINT on LPC18xx.
This version address the comments from Thomas and Rob.
Changes since v1:
- use irq_gc_ack_set_bit for edge ack
- switch to generic functions on level mask/unmask
- use revmap to look up hwirq in handler
- describe the interrupts property better in dt doc
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 | 26 +++ drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-lpc18xx-gpio-pint.c | 219 +++++++++++++++++++++ 4 files changed, 251 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
2.8.0
PATCH v2 1/2 irqchip: add lpc18xx gpio pin interrupt driver
--- drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-lpc18xx-gpio-pint.c | 219 ++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 drivers/irqchip/irq-lpc18xx-gpio-pint.c
drivers/irqchip/Kconfig +5 -0
@@ -211,6 +211,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 GENERIC_IRQ_IPI
drivers/irqchip/Makefile +1 -0
@@ -55,6 +55,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 +219 -0
219 lines not on this page · raw message
Signature · 1 line
2.8.0
PATCH v2 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 | 26 ++++++++++++++++++++++ 1 file changed, 26 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 +26 -0
@@ -0,0 +1,26 @@ +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 : Must contain the interrupt numbers from the parent controller. + This defines the mapping between the controllers where the first + interrupt is mapped to pint hwirq 0 and so on. Which interrupts + that are connected to where and the number of is device specific. + For lpc1850 the mapping is 32 33 34 35 36 37 38 39 (8 in total). +- clocks: Must contain a reference to the functional clock. + +Example: + +pint: interrupt-controller@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
2.8.0
Re: [PATCH v2 2/2] devicetree: document NXP LPC1850 PINT irq controller binding
Quoted 8 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 | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/nxp,lpc1850-gpio-pint.txt
Re: [PATCH v2 1/2] irqchip: add lpc18xx gpio pin interrupt driver
In reply to Joachim EastwoodHi Joachim,
Quoted 1 line · Joachim Eastwood
Signed-off-by Joachim Eastwood <[email protected]>
As a start, a commit message would be appreciated.
Quoted 76 lines
--- drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-lpc18xx-gpio-pint.c | 219 ++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 drivers/irqchip/irq-lpc18xx-gpio-pint.cdrivers/irqchip/Kconfig +5
-0@@ -211,6 +211,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 GENERIC_IRQ_IPIdrivers/irqchip/Makefile +1
-0@@ -55,6 +55,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.odrivers/irqchip/irq-lpc18xx-gpio-pint.c new file +35
-0@@ -0,0 +1,219 @@ +/* +* Irqchip driver for GPIO Pin Interrupt (PINT) on NXP LPC18xx/43xx. +* +* Copyright (C) 2016 Joachim Eastwood <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#include <linux/clk.h> +#include <linux/init.h> +#include <linux/irq.h> +#include <linux/irqdomain.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/platform_device.h> + +/* LPC18xx GPIO pin interrupt register offsets */ +#define LPC18XX_GPIO_PINT_ISEL 0x000 +#define LPC18XX_GPIO_PINT_SIENR 0x008 +#define LPC18XX_GPIO_PINT_CIENR 0x00c +#define LPC18XX_GPIO_PINT_SIENF 0x014 +#define LPC18XX_GPIO_PINT_CIENF 0x018 +#define LPC18XX_GPIO_PINT_IST 0x024 + +#define PINT_MAX_IRQS 32 + +struct lpc18xx_gpio_pint_chip { +struct irq_domain *domain; +void __iomem *base; +struct clk *clk; +unsigned int revmap[]; +};
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 45
Quoted 10 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +10
-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); +unsigned int hwirq = pint->revmap[irq]; +unsigned int virq; + + virq =irq_find_mapping (pint->domain, hwirq); +generic_handle_irq (virq);
Two things here:
- It feels a bit weird that you are indirecting everything through a cascade interrupt. As you have a 1:1 relationship between the PINT interrupts and their NVIC counterparts, this would be better described as a hierarchical irqchip (see drivers/irqchip/irq-vf610-mscm-ir.c for an example)
- If you decide to stick with the current approach, you're then missing the usual chained_irq_{enter,exit}.
Thanks,
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... -- 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
Re: [PATCH v2 1/2] irqchip: add lpc18xx gpio pin interrupt driver
Hi Marc,
Quoted 6 lines · Marc Zyngier
Hi Joachim,
Quoted 1 line · Joachim Eastwood
Signed-off-by Joachim Eastwood <[email protected]>As a start, a commit message would be appreciated.
Ops! I wonder where that disappeared to. The previous version did have one:
https://www.marc.info/?l=devicetree&m=145643797630859&w=3
I'll add it back in the next version.
Quoted 85 lines
Quoted 85 lines
--- drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-lpc18xx-gpio-pint.c | 219 ++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 drivers/irqchip/irq-lpc18xx-gpio-pint.cdrivers/irqchip/Kconfig +5
-0@@ -211,6 +211,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 GENERIC_IRQ_IPIdrivers/irqchip/Makefile +1
-0@@ -55,6 +55,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.odrivers/irqchip/irq-lpc18xx-gpio-pint.c new file +44
-0@@ -0,0 +1,219 @@ +/* +* Irqchip driver for GPIO Pin Interrupt (PINT) on NXP LPC18xx/43xx. +* +* Copyright (C) 2016 Joachim Eastwood <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#include <linux/clk.h> +#include <linux/init.h> +#include <linux/irq.h> +#include <linux/irqdomain.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/platform_device.h> + +/* LPC18xx GPIO pin interrupt register offsets */ +#define LPC18XX_GPIO_PINT_ISEL 0x000 +#define LPC18XX_GPIO_PINT_SIENR 0x008 +#define LPC18XX_GPIO_PINT_CIENR 0x00c +#define LPC18XX_GPIO_PINT_SIENF 0x014 +#define LPC18XX_GPIO_PINT_CIENF 0x018 +#define LPC18XX_GPIO_PINT_IST 0x024 + +#define PINT_MAX_IRQS 32 + +struct lpc18xx_gpio_pint_chip { +struct irq_domain *domain; +void __iomem *base; +struct clk *clk; +unsigned int revmap[]; +}; + +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); +unsigned int hwirq = pint->revmap[irq]; +unsigned int virq; + + virq =irq_find_mapping (pint->domain, hwirq);
Quoted 8 lines
drivers/irqchip/irq-lpc18xx-gpio-pint.c line 45
Quoted 1 line
drivers/irqchip/irq-lpc18xx-gpio-pint.c new file +1
-0+generic_handle_irq (virq);Two things here:
- It feels a bit weird that you are indirecting everything through a cascade interrupt. As you have a 1:1 relationship between the PINT interrupts and their NVIC counterparts, this would be better described as a hierarchical irqchip (seedrivers/irqchip/irq-vf610-mscm-ir.cfor an example)
Okey, I'll have a look at how irq-vf610-mscm-ir handels it.
Quoted 2 lines
- If you decide to stick with the current approach, you're then missing the usual chained_irq_{enter,exit}.
Indeed.
Thanks for looking through.
regards,
Joachim Eastwood
--
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