ARM: irqchip: add support for MOXA ART SoCs
PATCH 1/1 ARM: irqchip: add support for MOXA ART SoCs
This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
Applies to 3.10-rc1 and arm-soc/for-next (2013-06-15)
--- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 163 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 0 deletions(-) create mode 100644 drivers/irqchip/irq-moxart.c
drivers/irqchip/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o
drivers/irqchip/irq-moxart.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Quoted 16 lines · Jonas Jensen
drivers/irqchip/irq-moxart.c new file +16
-0+void moxart_irq_ack (struct irq_data *irqd) +{ +unsigned int irq =irqd_to_hwirq (irqd); + +writel (1 << irq,IRQ_CLEAR (moxart_irq_base)); +} + +static void moxart_irq_mask (struct irq_data *irqd) +{ +unsigned int irq =irqd_to_hwirq (irqd); +unsigned int mask; + + mask =readl (IRQ_MASK (moxart_irq_base)); + mask &= ~(1 << irq); +writel (mask,IRQ_MASK (moxart_irq_base)); +}
drivers/irqchip/irq-moxart.c line 82
Quoted 10 lines
drivers/irqchip/irq-moxart.c new file +10
-0+ +static void moxart_irq_unmask (struct irq_data *irqd) +{ +unsigned int irq =irqd_to_hwirq (irqd); +unsigned int mask; + + mask =readl (IRQ_MASK (moxart_irq_base)); + mask |= (1 << irq); +writel (mask,IRQ_MASK (moxart_irq_base)); +}
Is there a reason this isn't using the irq_chip_generic stuff which would eliminate all the above?
Quoted 2 lines · Russell King - ARM Linux
Is there a reason this isn't using the
irq_chip_genericstuff which would eliminate all the above?
When I first reviewed the moxart code, the generic irqchip wasn't compatible with the linear irq domain. However this has changed now and it should indeed use that.
Arnd
Dear Jonas Jensen,
Quoted 1 line · Jonas Jensen
+asmlinkage void
__exception_irq_entrymoxart_handle_irq(struct pt_regs *regs);
This forward declaration could be removed if moxart_handle_irq() was implemented before the initialization function of your driver.
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v2 1/1 irqchip: add support for MOXA ART SoCs
This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
v2:
* use irq_chip_generic
* remove macro duplicates
Applies to next-20130619
--- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 109 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 0 deletions(-) create mode 100644 drivers/irqchip/irq-moxart.c
drivers/irqchip/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o
drivers/irqchip/irq-moxart.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Re: [PATCH v2] irqchip: add support for MOXA ART SoCs
Quoted 10 lines · Jonas Jensen
This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
v2:
* useirq_chip_generic
* remove macro duplicatesApplies to next-20130619
Signed-off-by Jonas Jensen <[email protected]>
Re: [PATCH v2] irqchip: add support for MOXA ART SoCs
In reply to Jonas JensenQuoted 88 lines · Jonas Jensen
This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
v2:
* useirq_chip_generic
* remove macro duplicatesApplies to next-20130619
Signed-off-by Jonas Jensen <[email protected]>--- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 109 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 0 deletions(-) create mode 100644 drivers/irqchip/irq-moxart.cdrivers/irqchip/Makefile +1
-0@@ -16,3 +16,4 @@ obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.odrivers/irqchip/irq-moxart.c new file +57
-0@@ -0,0 +1,109 @@ +/* +* MOXA ART SoCs IRQ chip driver. +* +* Copyright (C) 2013 Jonas Jensen +* +* Jonas Jensen <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/irqdomain.h> + +#include <asm/exception.h> + +#include "irqchip.h" + +#define IRQ_SOURCE_REG 0 +#define IRQ_MASK_REG 0x04 +#define IRQ_CLEAR_REG 0x08 +#define IRQ_MODE_REG 0x0c +#define IRQ_LEVEL_REG 0x10 +#define IRQ_STATUS_REG 0x14 + +#define FIQ_SOURCE_REG 0x20 +#define FIQ_MASK_REG 0x24 +#define FIQ_CLEAR_REG 0x28 +#define FIQ_MODE_REG 0x2c +#define FIQ_LEVEL_REG 0x30 +#define FIQ_STATUS_REG 0x34 + +static void __iomem *moxart_irq_base; +static struct irq_domain *moxart_irq_domain; +static unsigned int interrupt_mask; + +asmlinkage void __exception_irq_entry moxart_handle_irq(struct pt_regs *regs) +{ +u32 irqstat; +int hwirq; + + irqstat =readl (moxart_irq_base +IRQ_STATUS_REG ); + +while (irqstat) { + hwirq =ffs (irqstat) -1 ; +handle_IRQ (irq_find_mapping (moxart_irq_domain, hwirq), regs); + irqstat &= ~(1 << hwirq); + } +} + +static __init void moxart_alloc_gc (void __iomem *base, +unsigned int irq_start,unsigned int num)
drivers/irqchip/irq-moxart.c line 67
Quoted 10 lines
drivers/irqchip/irq-moxart.c new file +10
-0+{ +unsigned int clr =IRQ_NOREQUEST |IRQ_NOPROBE |IRQ_NOAUTOEN ; +int ret; +struct irq_chip_generic *gc; + + ret =irq_alloc_domain_generic_chips (moxart_irq_domain,32 ,1 , +"MOXARTINTC" , handle_edge_irq, clr,0 ,IRQ_GC_INIT_MASK_CACHE ); + +if (ret) +pr_err ("%s: could not alloc generic chip\n" , __func__);
If this failure point is hit, the code following it will segfault. Need to bail at this point.
drivers/irqchip/irq-moxart.c line 77
Quoted 10 lines
drivers/irqchip/irq-moxart.c new file +10
-0+ + gc =irq_get_domain_generic_chip (moxart_irq_domain,0 ); + + gc->reg_base = base; + gc->chip_types[0 ].regs.mask =IRQ_MASK_REG ; + gc->chip_types[0 ].regs.ack =IRQ_CLEAR_REG ; + gc->chip_types[0 ].chip.irq_ack = irq_gc_ack_set_bit; + gc->chip_types[0 ].chip.irq_mask = irq_gc_mask_clr_bit; + gc->chip_types[0 ].chip.irq_unmask = irq_gc_mask_set_bit; +}
Why is this split into a separate function? There really isn't any need to.
drivers/irqchip/irq-moxart.c line 89
Quoted 12 lines
drivers/irqchip/irq-moxart.c new file +12
-0+ +static int __init moxart_of_init (struct device_node *node, +struct device_node *parent) +{ + interrupt_mask =be32_to_cpup (of_get_property (node, +"interrupt-mask" ,NULL )); +pr_debug ("%s: interrupt-mask=%x\n" , node->full_name, interrupt_mask); + + moxart_irq_base =of_iomap (node,0 ); +if (!moxart_irq_base) +panic ("%s: unable to map INTC CPU registers\n" , + node->full_name);
Is in necessary to panic here? Often even if the interrupt controller setup fails, it is valueable to print an error, exit gracefully and let the kernel try to continue. There is a greater chance of getting some form output useful for debug that way.
Quoted 28 lines
drivers/irqchip/irq-moxart.c new file +20
-0+ + moxart_irq_domain =irq_domain_add_linear (node, +32 , &irq_generic_chip_ops, moxart_irq_base); + +moxart_alloc_gc (moxart_irq_base,0 ,32 ); + +writel (0 , moxart_irq_base +IRQ_MASK_REG ); +writel (0xffffffff , moxart_irq_base +IRQ_CLEAR_REG ); + +writel (interrupt_mask, moxart_irq_base +IRQ_MODE_REG ); +writel (interrupt_mask, moxart_irq_base +IRQ_LEVEL_REG ); + +set_handle_irq (moxart_handle_irq); + +pr_info ("%s: %s finished\n" , node->full_name, __func__); + +return 0 ; +} +IRQCHIP_DECLARE (moxa_moxart_ic,"moxa,moxart-interrupt-controller" , + moxart_of_init);Signature · 7 lines
1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
email sent from notmuch.vim plugin
PATCH v3 1/1 ARM: irqchip: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
---
Notes:
Applies to next-20130619
Changes since v2:
1. bail if irq_alloc_domain_generic_chips fails
2. remove separate function "moxart_alloc_gc", move all code to main init
3. if of_iomap fails, instead of panic, print error and return -EINVAL
4. use of_property_read_u32 instead of be32_to_cpup(of_get_property(..))
drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 110 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 drivers/irqchip/irq-moxart.c
drivers/irqchip/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o
drivers/irqchip/irq-moxart.c new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Hi Jonas,
Quoted 66 lines · Jonas Jensen
This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
Signed-off-by Jonas Jensen <[email protected]>---
Notes:
Applies to next-20130619Changes since v2:
1. bail if
irq_alloc_domain_generic_chipsfails
2. remove separate function "moxart_alloc_gc", move all code to main init
3. ifof_iomapfails, instead of panic, print error and return-EINVAL
4. useof_property_read_u32instead of be32_to_cpup(of_get_property(..))drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 110 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 drivers/irqchip/irq-moxart.cdrivers/irqchip/Makefile +1
-0@@ -16,3 +16,4 @@ obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.odrivers/irqchip/irq-moxart.c new file +30
-0@@ -0,0 +1,110 @@ +/* +* MOXA ART SoCs IRQ chip driver. +* +* Copyright (C) 2013 Jonas Jensen +* +* Jonas Jensen <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/irqdomain.h> + +#include <asm/exception.h> + +#include "irqchip.h" + +#define IRQ_SOURCE_REG 0 +#define IRQ_MASK_REG 0x04 +#define IRQ_CLEAR_REG 0x08 +#define IRQ_MODE_REG 0x0c +#define IRQ_LEVEL_REG 0x10 +#define IRQ_STATUS_REG 0x14 +
drivers/irqchip/irq-moxart.c line 40
Quoted 10 lines
drivers/irqchip/irq-moxart.c new file +10
-0+#define FIQ_SOURCE_REG 0x20 +#define FIQ_MASK_REG 0x24 +#define FIQ_CLEAR_REG 0x28 +#define FIQ_MODE_REG 0x2c +#define FIQ_LEVEL_REG 0x30 +#define FIQ_STATUS_REG 0x34 + +static void __iomem *moxart_irq_base; +static struct irq_domain *moxart_irq_domain; +static unsigned int interrupt_mask;
I would pack this into a struct s.t. you have only one global variable for the chip instance. More or less a matter of taste.
drivers/irqchip/irq-moxart.c line 42
Quoted 2 lines
drivers/irqchip/irq-moxart.c new file +2
-0+ +asmlinkage void __exception_irq_entry moxart_handle_irq(struct pt_regs *regs)
can this be static?
drivers/irqchip/irq-moxart.c line 51
Quoted 9 lines
drivers/irqchip/irq-moxart.c new file +9
-0+{ +u32 irqstat; +int hwirq; + + irqstat =readl (moxart_irq_base +IRQ_STATUS_REG ); + +while (irqstat) { + hwirq =ffs (irqstat) -1 ; +handle_IRQ (irq_find_mapping (moxart_irq_domain, hwirq), regs);
Call irq_linear_revmap instead of irq_find_mapping.
drivers/irqchip/irq-moxart.c line 57
Quoted 6 lines
drivers/irqchip/irq-moxart.c new file +6
-0+ irqstat &= ~(1 << hwirq); + } +} + +static int __init moxart_of_intc_init (struct device_node *node, +struct device_node *parent)
wrong indention.
drivers/irqchip/irq-moxart.c line 66
Quoted 9 lines
drivers/irqchip/irq-moxart.c new file +9
-0+{ +unsigned int clr =IRQ_NOREQUEST |IRQ_NOPROBE |IRQ_NOAUTOEN ; +int ret; +struct irq_chip_generic *gc; + + ret =of_property_read_u32 (node,"interrupt-mask" , &interrupt_mask); +if (ret) +pr_err ("%s: can't read interrupt-mask DT property\n" , + node->full_name);
ditto
drivers/irqchip/irq-moxart.c line 77
Quoted 11 lines
drivers/irqchip/irq-moxart.c new file +11
-0+pr_debug ("%s: interrupt-mask=%x\n" , node->full_name, interrupt_mask); + + moxart_irq_base =of_iomap (node,0 ); +if (!moxart_irq_base) { +pr_err ("%s: unable to map INTC CPU registers\n" , + node->full_name); +return -EINVAL ; + } + + moxart_irq_domain =irq_domain_add_linear (node,32 , + &irq_generic_chip_ops, moxart_irq_base);
if (!moxart_irq_domain) {
/* error handling */
}drivers/irqchip/irq-moxart.c line 84
Quoted 7 lines
drivers/irqchip/irq-moxart.c new file +7
-0+ + ret =irq_alloc_domain_generic_chips (moxart_irq_domain,32 ,1 , +"MOXARTINTC" , handle_edge_irq, + clr,0 ,IRQ_GC_INIT_MASK_CACHE ); + +if (ret) { +pr_err ("%s: could not allocate generic chip\n" , __func__);
you should free moxart_irq_domain here.
Quoted 11 lines
drivers/irqchip/irq-moxart.c new file +11
-0+return -EINVAL ; + } + + gc =irq_get_domain_generic_chip (moxart_irq_domain,0 ); + + gc->reg_base = moxart_irq_base; + gc->chip_types[0 ].regs.mask =IRQ_MASK_REG ; + gc->chip_types[0 ].regs.ack =IRQ_CLEAR_REG ; + gc->chip_types[0 ].chip.irq_ack = irq_gc_ack_set_bit; + gc->chip_types[0 ].chip.irq_mask = irq_gc_mask_clr_bit; + gc->chip_types[0 ].chip.irq_unmask = irq_gc_mask_set_bit;
drivers/irqchip/irq-moxart.c line 105
Quoted 10 lines
drivers/irqchip/irq-moxart.c new file +10
-0+ +writel (0 , moxart_irq_base +IRQ_MASK_REG ); +writel (0xffffffff , moxart_irq_base +IRQ_CLEAR_REG ); + +writel (interrupt_mask, moxart_irq_base +IRQ_MODE_REG ); +writel (interrupt_mask, moxart_irq_base +IRQ_LEVEL_REG ); + +set_handle_irq (moxart_handle_irq); + +pr_info ("%s: %s finished\n" , node->full_name, __func__);
"finished" looks like a debug message. IMHO either drop the message or write something more useful.
drivers/irqchip/irq-moxart.c line 110
Quoted 6 lines
drivers/irqchip/irq-moxart.c new file +5
-0+ +return 0 ; +} +IRQCHIP_DECLARE (moxa_moxart_ic,"moxa,moxart-interrupt-controller" , + moxart_of_intc_init);
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v4 1/1 ARM: irqchip: add support for MOXA ART SoCs
In reply to Jonas JensenThis patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
---
Notes:
Applies to next-20130619
Changes since v3:
1. pack global variables in struct
2. make handle_irq function static
3. call irq_linear_revmap instead of irq_find_mapping
4. fix indentation
5. add error handling after irq_domain_add_linear
6. free the domain if irq_alloc_domain_generic_chips fails
7. use node->full_name instead of __func__ in messages
8. remove debug messages
9. make messages more consistent
drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 118 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 drivers/irqchip/irq-moxart.c
drivers/irqchip/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_RENESAS_INTC_IRQPIN) += irq-renesas-intc-irqpin.o obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o
drivers/irqchip/irq-moxart.c new file +118 -0
118 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v5 1/1 ARM: irqchip: add support for MOXA ART SoCs
This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
---
Notes:
Applies to next-20130703
Changes since v4:
1. shorten DT compatible value to "moxart-ic"
2. use alphabetic ordering in Makefile
drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 118 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 drivers/irqchip/irq-moxart.c
drivers/irqchip/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_ARCH_MXS) += irq-mxs.o obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o obj-$(CONFIG_METAG) += irq-metag-ext.o obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o obj-$(CONFIG_ORION_IRQCHIP) += irq-orion.o obj-$(CONFIG_ARCH_SUNXI) += irq-sun4i.o obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o
drivers/irqchip/irq-moxart.c new file +118 -0
118 lines not on this page · raw message
Signature · 1 line
1.8.2.1
tip-bot for Jonas Jensen
merge bot[tip:irq/urgent] irqchip: Add support for MOXA ART SoCs
irqchip: Add support for MOXA ART SoCs
Commit-ID: 4de563ae821b1935b3c467a4606e5738b0b0df87 Gitweb: http://git.kernel.org/tip/4de563ae821b1935b3c467a4606e5738b0b0df87 Author: Jonas Jensen <[email protected]> AuthorDate: Thu, 4 Jul 2013 14:38:51 +0200 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 5 Jul 2013 11:39:25 +0200
irqchip: Add support for MOXA ART SoCs
This patch adds an irqchip driver for the main interrupt controller found on MOXA ART SoCs.
--- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-moxart.c | 117 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+)
drivers/irqchip/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_ARCH_MXS) += irq-mxs.o obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o obj-$(CONFIG_METAG) += irq-metag-ext.o obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o +obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o obj-$(CONFIG_ORION_IRQCHIP) += irq-orion.o obj-$(CONFIG_ARCH_SUNXI) += irq-sun4i.o obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o
drivers/irqchip/irq-moxart.c new file +117 -0
117 lines not on this page · raw message