linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] irqchip: add basic infrastructure
@ 2012-10-27 16:45 Thomas Petazzoni
  2012-10-27 16:45 ` [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure Thomas Petazzoni
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Thomas Petazzoni @ 2012-10-27 16:45 UTC (permalink / raw)
  To: linux-arm-kernel

With the recent creation of the drivers/irqchip/ directory, it is
desirable to move irq controller drivers here. At the moment, the only
driver here is irq-bcm2835, the driver for the irq controller found in
the ARM BCM2835 SoC, present in Rasberry Pi systems. This irq
controller driver was exporting its initialization function and its
irq handling function through a header file in
<linux/irqchip/bcm2835.h>.

When proposing to also move another irq controller driver in
drivers/irqchip, Rob Herring raised the very valid point that moving
things to drivers/irqchip was good in order to remove more stuff from
arch/arm, but if it means adding gazillions of headers files in
include/linux/irqchip/, it would not be very nice.

So, upon the suggestion of Rob Herring and Arnd Bergmann, this commit
introduces a small infrastructure that defines a central
irqchip_init() function in drivers/irqchip/irqchip.c, which is meant
to be called as the ->init_irq() callback of ARM platforms. This
function calls of_irq_init() with an array that will progressively
contain the compatible strings of each irq controller driver, and also
a reference to the initialization functions of such drivers. The
drivers/irqchip/irqchip.h header file, currently empty, is added to
allow irq controller drivers to expose their initialization function
to the main irqchip.c file. Note that the irq controller driver
initialization function is responsible for setting the global
handle_arch_irq() variable, so that ARM platforms no longer have to
define the ->handle_irq field in their DT_MACHINE structure.

A global header, <linux/irqchip.h> is also added to expose the single
irqchip_init() function to the reset of the kernel.

A further commit moves the BCM2835 irq controller driver to this new
small infrastructure, therefore removing the include/linux/irqchip/
directory.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 drivers/irqchip/Kconfig   |    3 ++-
 drivers/irqchip/Makefile  |    1 +
 drivers/irqchip/irqchip.c |   23 +++++++++++++++++++++++
 drivers/irqchip/irqchip.h |   14 ++++++++++++++
 include/linux/irqchip.h   |   16 ++++++++++++++++
 5 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 drivers/irqchip/irqchip.c
 create mode 100644 drivers/irqchip/irqchip.h
 create mode 100644 include/linux/irqchip.h

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 1bb8bf6..e0ff166 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -1 +1,2 @@
-# empty
+config USE_IRQCHIP
+	bool
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 054321d..77adcb1 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -1 +1,2 @@
+obj-$(CONFIG_USE_IRQCHIP) += irqchip.o
 obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
new file mode 100644
index 0000000..410f99f
--- /dev/null
+++ b/drivers/irqchip/irqchip.c
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2012 Thomas Petazzoni
+ *
+ * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+ *
+ * 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/init.h>
+#include <linux/of_irq.h>
+
+#include "irqchip.h"
+
+static const struct of_device_id irqchip_of_match[] __initconst = {
+	{},
+};
+
+void __init irqchip_init(void)
+{
+	of_irq_init(irqchip_of_match);
+}
diff --git a/drivers/irqchip/irqchip.h b/drivers/irqchip/irqchip.h
new file mode 100644
index 0000000..1e7a5c2
--- /dev/null
+++ b/drivers/irqchip/irqchip.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2012 Thomas Petazzoni
+ *
+ * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+ *
+ * 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.
+ */
+
+#ifndef _IRQCHIP_H
+#define _IRQCHIP_H
+
+#endif
diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
new file mode 100644
index 0000000..e0006f1
--- /dev/null
+++ b/include/linux/irqchip.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2012 Thomas Petazzoni
+ *
+ * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+ *
+ * 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.
+ */
+
+#ifndef _LINUX_IRQCHIP_H
+#define _LINUX_IRQCHIP_H
+
+void irqchip_init(void);
+
+#endif
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure
  2012-10-27 16:45 [PATCH 1/3] irqchip: add basic infrastructure Thomas Petazzoni
@ 2012-10-27 16:45 ` Thomas Petazzoni
  2012-10-28  2:23   ` Stephen Warren
  2012-10-27 16:45 ` [PATCH 3/3] arm: mvebu: move irq controller driver to drivers/irqchip Thomas Petazzoni
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Thomas Petazzoni @ 2012-10-27 16:45 UTC (permalink / raw)
  To: linux-arm-kernel

Register the irq controller driver in the main
drivers/irqchip/irqchip.c file, and make sure that the initialization
function of the driver sets handle_arch_irq() appropriately. This
requires a bit of movement in the driver since the
bcm2835_handle_irq() must move before the armctrl_of_init() function
to avoid a forward declaration.

On the arch/arm side, use irqchip_init() as the ->init_irq() callback,
and remove the definition of ->handle_irq() since this is now done by
the irq controller driver.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
---
 arch/arm/Kconfig                |    1 +
 arch/arm/mach-bcm2835/bcm2835.c |    5 +-
 drivers/irqchip/irq-bcm2835.c   |  110 +++++++++++++++++++--------------------
 drivers/irqchip/irqchip.c       |    3 ++
 drivers/irqchip/irqchip.h       |    2 +
 include/linux/irqchip/bcm2835.h |   29 -----------
 6 files changed, 61 insertions(+), 89 deletions(-)
 delete mode 100644 include/linux/irqchip/bcm2835.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 73067ef..7030500 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -347,6 +347,7 @@ config ARCH_BCM2835
 	select MULTI_IRQ_HANDLER
 	select SPARSE_IRQ
 	select USE_OF
+	select USE_IRQCHIP
 	help
 	  This enables support for the Broadcom BCM2835 SoC. This SoC is
 	  use in the Raspberry Pi, and Roku 2 devices.
diff --git a/arch/arm/mach-bcm2835/bcm2835.c b/arch/arm/mach-bcm2835/bcm2835.c
index f6fea49..ab1bccd 100644
--- a/arch/arm/mach-bcm2835/bcm2835.c
+++ b/arch/arm/mach-bcm2835/bcm2835.c
@@ -13,10 +13,10 @@
  */
 
 #include <linux/init.h>
-#include <linux/irqchip/bcm2835.h>
 #include <linux/of_platform.h>
 #include <linux/bcm2835_timer.h>
 #include <linux/clk/bcm2835.h>
+#include <linux/irqchip.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -56,8 +56,7 @@ static const char * const bcm2835_compat[] = {
 
 DT_MACHINE_START(BCM2835, "BCM2835")
 	.map_io = bcm2835_map_io,
-	.init_irq = bcm2835_init_irq,
-	.handle_irq = bcm2835_handle_irq,
+	.init_irq = irqchip_init,
 	.init_machine = bcm2835_init,
 	.timer = &bcm2835_timer,
 	.dt_compat = bcm2835_compat
diff --git a/drivers/irqchip/irq-bcm2835.c b/drivers/irqchip/irq-bcm2835.c
index dc670cc..6f845c7 100644
--- a/drivers/irqchip/irq-bcm2835.c
+++ b/drivers/irqchip/irq-bcm2835.c
@@ -49,9 +49,11 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/irqdomain.h>
-#include <linux/irqchip/bcm2835.h>
 
 #include <asm/exception.h>
+#include <asm/mach/irq.h>
+
+#include "irqchip.h"
 
 /* Put the bank and irq (32 bits) into the hwirq */
 #define MAKE_HWIRQ(b, n)	((b << 5) | (n))
@@ -94,6 +96,52 @@ struct armctrl_ic {
 
 static struct armctrl_ic intc __read_mostly;
 
+/*
+ * Handle each interrupt across the entire interrupt controller.  This reads the
+ * status register before handling each interrupt, which is necessary given that
+ * handle_IRQ may briefly re-enable interrupts for soft IRQ handling.
+ */
+
+static void armctrl_handle_bank(int bank, struct pt_regs *regs)
+{
+	u32 stat, irq;
+
+	while ((stat = readl_relaxed(intc.pending[bank]))) {
+		irq = MAKE_HWIRQ(bank, ffs(stat) - 1);
+		handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
+	}
+}
+
+static void armctrl_handle_shortcut(int bank, struct pt_regs *regs,
+	u32 stat)
+{
+	u32 irq = MAKE_HWIRQ(bank, shortcuts[ffs(stat >> SHORTCUT_SHIFT) - 1]);
+	handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
+}
+
+static asmlinkage void __exception_irq_entry
+bcm2835_handle_irq(struct pt_regs *regs)
+{
+	u32 stat, irq;
+
+	while ((stat = readl_relaxed(intc.pending[0]) & BANK0_VALID_MASK)) {
+		if (stat & BANK0_HWIRQ_MASK) {
+			irq = MAKE_HWIRQ(0, ffs(stat & BANK0_HWIRQ_MASK) - 1);
+			handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
+		} else if (stat & SHORTCUT1_MASK) {
+			armctrl_handle_shortcut(1, regs, stat & SHORTCUT1_MASK);
+		} else if (stat & SHORTCUT2_MASK) {
+			armctrl_handle_shortcut(2, regs, stat & SHORTCUT2_MASK);
+		} else if (stat & BANK1_HWIRQ) {
+			armctrl_handle_bank(1, regs);
+		} else if (stat & BANK2_HWIRQ) {
+			armctrl_handle_bank(2, regs);
+		} else {
+			BUG();
+		}
+	}
+}
+
 static void armctrl_mask_irq(struct irq_data *d)
 {
 	writel_relaxed(HWIRQ_BIT(d->hwirq), intc.disable[HWIRQ_BANK(d->hwirq)]);
@@ -135,8 +183,8 @@ static struct irq_domain_ops armctrl_ops = {
 	.xlate = armctrl_xlate
 };
 
-static int __init armctrl_of_init(struct device_node *node,
-	struct device_node *parent)
+int __init armctrl_of_init(struct device_node *node,
+			   struct device_node *parent)
 {
 	void __iomem *base;
 	int irq, b, i;
@@ -164,60 +212,8 @@ static int __init armctrl_of_init(struct device_node *node,
 			set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
 		}
 	}
-	return 0;
-}
-
-static struct of_device_id irq_of_match[] __initconst = {
-	{ .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init }
-};
-
-void __init bcm2835_init_irq(void)
-{
-	of_irq_init(irq_of_match);
-}
-
-/*
- * Handle each interrupt across the entire interrupt controller.  This reads the
- * status register before handling each interrupt, which is necessary given that
- * handle_IRQ may briefly re-enable interrupts for soft IRQ handling.
- */
-
-static void armctrl_handle_bank(int bank, struct pt_regs *regs)
-{
-	u32 stat, irq;
-
-	while ((stat = readl_relaxed(intc.pending[bank]))) {
-		irq = MAKE_HWIRQ(bank, ffs(stat) - 1);
-		handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
-	}
-}
 
-static void armctrl_handle_shortcut(int bank, struct pt_regs *regs,
-	u32 stat)
-{
-	u32 irq = MAKE_HWIRQ(bank, shortcuts[ffs(stat >> SHORTCUT_SHIFT) - 1]);
-	handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
-}
-
-asmlinkage void __exception_irq_entry bcm2835_handle_irq(
-	struct pt_regs *regs)
-{
-	u32 stat, irq;
+	handle_arch_irq = bcm2835_handle_irq;
 
-	while ((stat = readl_relaxed(intc.pending[0]) & BANK0_VALID_MASK)) {
-		if (stat & BANK0_HWIRQ_MASK) {
-			irq = MAKE_HWIRQ(0, ffs(stat & BANK0_HWIRQ_MASK) - 1);
-			handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
-		} else if (stat & SHORTCUT1_MASK) {
-			armctrl_handle_shortcut(1, regs, stat & SHORTCUT1_MASK);
-		} else if (stat & SHORTCUT2_MASK) {
-			armctrl_handle_shortcut(2, regs, stat & SHORTCUT2_MASK);
-		} else if (stat & BANK1_HWIRQ) {
-			armctrl_handle_bank(1, regs);
-		} else if (stat & BANK2_HWIRQ) {
-			armctrl_handle_bank(2, regs);
-		} else {
-			BUG();
-		}
-	}
+	return 0;
 }
diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
index 410f99f..f01cf6e 100644
--- a/drivers/irqchip/irqchip.c
+++ b/drivers/irqchip/irqchip.c
@@ -14,6 +14,9 @@
 #include "irqchip.h"
 
 static const struct of_device_id irqchip_of_match[] __initconst = {
+#ifdef CONFIG_ARCH_BCM2835
+	{ .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init },
+#endif
 	{},
 };
 
diff --git a/drivers/irqchip/irqchip.h b/drivers/irqchip/irqchip.h
index 1e7a5c2..0e68965 100644
--- a/drivers/irqchip/irqchip.h
+++ b/drivers/irqchip/irqchip.h
@@ -11,4 +11,6 @@
 #ifndef _IRQCHIP_H
 #define _IRQCHIP_H
 
+int armctrl_of_init(struct device_node *node, struct device_node *parent);
+
 #endif
diff --git a/include/linux/irqchip/bcm2835.h b/include/linux/irqchip/bcm2835.h
deleted file mode 100644
index 48a859b..0000000
--- a/include/linux/irqchip/bcm2835.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2010 Broadcom
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __LINUX_IRQCHIP_BCM2835_H_
-#define __LINUX_IRQCHIP_BCM2835_H_
-
-#include <asm/exception.h>
-
-extern void bcm2835_init_irq(void);
-
-extern asmlinkage void __exception_irq_entry bcm2835_handle_irq(
-	struct pt_regs *regs);
-
-#endif
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] arm: mvebu: move irq controller driver to drivers/irqchip
  2012-10-27 16:45 [PATCH 1/3] irqchip: add basic infrastructure Thomas Petazzoni
  2012-10-27 16:45 ` [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure Thomas Petazzoni
@ 2012-10-27 16:45 ` Thomas Petazzoni
  2012-10-28  2:25   ` Stephen Warren
  2012-10-27 19:21 ` [PATCH 1/3] irqchip: add basic infrastructure Arnd Bergmann
  2012-10-28  2:20 ` Stephen Warren
  3 siblings, 1 reply; 11+ messages in thread
From: Thomas Petazzoni @ 2012-10-27 16:45 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@free-electrons.com>
---
 arch/arm/mach-mvebu/Kconfig                        |    1 +
 arch/arm/mach-mvebu/Makefile                       |    2 +-
 arch/arm/mach-mvebu/armada-370-xp.c                |    4 +-
 arch/arm/mach-mvebu/common.h                       |    3 -
 drivers/irqchip/Makefile                           |    1 +
 .../irqchip}/irq-armada-370-xp.c                   |   58 +++++++++-----------
 drivers/irqchip/irqchip.c                          |    3 +
 drivers/irqchip/irqchip.h                          |    2 +
 8 files changed, 36 insertions(+), 38 deletions(-)
 rename {arch/arm/mach-mvebu => drivers/irqchip}/irq-armada-370-xp.c (87%)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 416d46e..415ed0f 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -9,6 +9,7 @@ config ARCH_MVEBU
 	select PINCTRL
 	select PLAT_ORION
 	select SPARSE_IRQ
+	select USE_IRQCHIP
 
 if ARCH_MVEBU
 
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index 57f996b..7f4e9f4 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -2,4 +2,4 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include \
 	-I$(srctree)/arch/arm/plat-orion/include
 
 obj-y += system-controller.o
-obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o irq-armada-370-xp.o addr-map.o
+obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o addr-map.o
diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c
index 68f1483..9b28991 100644
--- a/arch/arm/mach-mvebu/armada-370-xp.c
+++ b/arch/arm/mach-mvebu/armada-370-xp.c
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/of_platform.h>
 #include <linux/io.h>
+#include <linux/irqchip.h>
 #include <linux/time-armada-370-xp.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -56,8 +57,7 @@ static const char * const armada_370_xp_dt_board_dt_compat[] = {
 DT_MACHINE_START(ARMADA_XP_DT, "Marvell Aramada 370/XP (Device Tree)")
 	.init_machine	= armada_370_xp_dt_init,
 	.map_io		= armada_370_xp_map_io,
-	.init_irq	= armada_370_xp_init_irq,
-	.handle_irq     = armada_370_xp_handle_irq,
+	.init_irq	= irqchip_init,
 	.timer		= &armada_370_xp_timer,
 	.restart	= mvebu_restart,
 	.dt_compat	= armada_370_xp_dt_board_dt_compat,
diff --git a/arch/arm/mach-mvebu/common.h b/arch/arm/mach-mvebu/common.h
index 02f89ea..f0eaa21 100644
--- a/arch/arm/mach-mvebu/common.h
+++ b/arch/arm/mach-mvebu/common.h
@@ -17,7 +17,4 @@
 
 void mvebu_restart(char mode, const char *cmd);
 
-void armada_370_xp_init_irq(void);
-void armada_370_xp_handle_irq(struct pt_regs *regs);
-
 #endif
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 77adcb1..d1a163c 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_USE_IRQCHIP) += irqchip.o
 obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
+obj-$(CONFIG_ARCH_MVEBU)   += irq-armada-370-xp.o
diff --git a/arch/arm/mach-mvebu/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
similarity index 87%
rename from arch/arm/mach-mvebu/irq-armada-370-xp.c
rename to drivers/irqchip/irq-armada-370-xp.c
index 5f5f939..148a67c 100644
--- a/arch/arm/mach-mvebu/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -23,6 +23,7 @@
 #include <linux/of_irq.h>
 #include <linux/irqdomain.h>
 #include <asm/mach/arch.h>
+#include <asm/mach/irq.h>
 #include <asm/exception.h>
 
 /* Interrupt Controller Registers Map */
@@ -39,6 +40,27 @@ static void __iomem *per_cpu_int_base;
 static void __iomem *main_int_base;
 static struct irq_domain *armada_370_xp_mpic_domain;
 
+static asmlinkage void __exception_irq_entry
+armada_370_xp_handle_irq(struct pt_regs *regs)
+{
+	u32 irqstat, irqnr;
+
+	do {
+		irqstat = readl_relaxed(per_cpu_int_base +
+					ARMADA_370_XP_CPU_INTACK_OFFS);
+		irqnr = irqstat & 0x3FF;
+
+		if (irqnr < 1023) {
+			irqnr =
+			    irq_find_mapping(armada_370_xp_mpic_domain, irqnr);
+			handle_IRQ(irqnr, regs);
+			continue;
+		}
+
+		break;
+	} while (1);
+}
+
 static void armada_370_xp_irq_mask(struct irq_data *d)
 {
 	writel(irqd_to_hwirq(d),
@@ -77,8 +99,8 @@ static struct irq_domain_ops armada_370_xp_mpic_irq_ops = {
 	.xlate = irq_domain_xlate_onecell,
 };
 
-static int __init armada_370_xp_mpic_of_init(struct device_node *node,
-					     struct device_node *parent)
+int __init armada_370_xp_mpic_of_init(struct device_node *node,
+				      struct device_node *parent)
 {
 	u32 control;
 
@@ -98,36 +120,8 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
 		panic("Unable to add Armada_370_Xp MPIC irq domain (DT)\n");
 
 	irq_set_default_host(armada_370_xp_mpic_domain);
-	return 0;
-}
 
-asmlinkage void __exception_irq_entry armada_370_xp_handle_irq(struct pt_regs
-							       *regs)
-{
-	u32 irqstat, irqnr;
-
-	do {
-		irqstat = readl_relaxed(per_cpu_int_base +
-					ARMADA_370_XP_CPU_INTACK_OFFS);
-		irqnr = irqstat & 0x3FF;
+	handle_arch_irq = armada_370_xp_handle_irq;
 
-		if (irqnr < 1023) {
-			irqnr =
-			    irq_find_mapping(armada_370_xp_mpic_domain, irqnr);
-			handle_IRQ(irqnr, regs);
-			continue;
-		}
-
-		break;
-	} while (1);
-}
-
-static const struct of_device_id mpic_of_match[] __initconst = {
-	{.compatible = "marvell,mpic", .data = armada_370_xp_mpic_of_init},
-	{},
-};
-
-void __init armada_370_xp_init_irq(void)
-{
-	of_irq_init(mpic_of_match);
+	return 0;
 }
diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
index f01cf6e..f8fbf00 100644
--- a/drivers/irqchip/irqchip.c
+++ b/drivers/irqchip/irqchip.c
@@ -17,6 +17,9 @@ static const struct of_device_id irqchip_of_match[] __initconst = {
 #ifdef CONFIG_ARCH_BCM2835
 	{ .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init },
 #endif
+#ifdef CONFIG_ARCH_MVEBU
+	{.compatible = "marvell,mpic", .data = armada_370_xp_mpic_of_init },
+#endif
 	{},
 };
 
diff --git a/drivers/irqchip/irqchip.h b/drivers/irqchip/irqchip.h
index 0e68965..a961ca9 100644
--- a/drivers/irqchip/irqchip.h
+++ b/drivers/irqchip/irqchip.h
@@ -12,5 +12,7 @@
 #define _IRQCHIP_H
 
 int armctrl_of_init(struct device_node *node, struct device_node *parent);
+int armada_370_xp_mpic_of_init(struct device_node *node,
+			       struct device_node *parent);
 
 #endif
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 1/3] irqchip: add basic infrastructure
  2012-10-27 16:45 [PATCH 1/3] irqchip: add basic infrastructure Thomas Petazzoni
  2012-10-27 16:45 ` [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure Thomas Petazzoni
  2012-10-27 16:45 ` [PATCH 3/3] arm: mvebu: move irq controller driver to drivers/irqchip Thomas Petazzoni
@ 2012-10-27 19:21 ` Arnd Bergmann
  2012-10-27 21:31   ` Thomas Gleixner
  2012-10-28  8:58   ` Thomas Petazzoni
  2012-10-28  2:20 ` Stephen Warren
  3 siblings, 2 replies; 11+ messages in thread
From: Arnd Bergmann @ 2012-10-27 19:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Saturday 27 October 2012, Thomas Petazzoni wrote:
> With the recent creation of the drivers/irqchip/ directory, it is
> desirable to move irq controller drivers here. At the moment, the only
> driver here is irq-bcm2835, the driver for the irq controller found in
> the ARM BCM2835 SoC, present in Rasberry Pi systems. This irq
> controller driver was exporting its initialization function and its
> irq handling function through a header file in
> <linux/irqchip/bcm2835.h>.

Very nice series!

I think it would be good if Thomas Gleixner as the IRQ subsystem maintainer
could have a look as well. We should probably add the drivers/irqchip
directory to that MAINTAINERS entry.

	Arnd

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] irqchip: add basic infrastructure
  2012-10-27 19:21 ` [PATCH 1/3] irqchip: add basic infrastructure Arnd Bergmann
@ 2012-10-27 21:31   ` Thomas Gleixner
  2012-10-28  8:58   ` Thomas Petazzoni
  1 sibling, 0 replies; 11+ messages in thread
From: Thomas Gleixner @ 2012-10-27 21:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 27 Oct 2012, Arnd Bergmann wrote:

> On Saturday 27 October 2012, Thomas Petazzoni wrote:
> > With the recent creation of the drivers/irqchip/ directory, it is
> > desirable to move irq controller drivers here. At the moment, the only
> > driver here is irq-bcm2835, the driver for the irq controller found in
> > the ARM BCM2835 SoC, present in Rasberry Pi systems. This irq
> > controller driver was exporting its initialization function and its
> > irq handling function through a header file in
> > <linux/irqchip/bcm2835.h>.
> 
> Very nice series!
> 
> I think it would be good if Thomas Gleixner as the IRQ subsystem maintainer
> could have a look as well. We should probably add the drivers/irqchip
> directory to that MAINTAINERS entry.

I skimmed over the patches and they look very reasonable. I try to
find a time slot to give it a more thorough look.

So: Tentatively-acked-by-me

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] irqchip: add basic infrastructure
  2012-10-27 16:45 [PATCH 1/3] irqchip: add basic infrastructure Thomas Petazzoni
                   ` (2 preceding siblings ...)
  2012-10-27 19:21 ` [PATCH 1/3] irqchip: add basic infrastructure Arnd Bergmann
@ 2012-10-28  2:20 ` Stephen Warren
  2012-10-28  8:59   ` Thomas Petazzoni
  3 siblings, 1 reply; 11+ messages in thread
From: Stephen Warren @ 2012-10-28  2:20 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/27/2012 10:45 AM, Thomas Petazzoni wrote:
...
> So, upon the suggestion of Rob Herring and Arnd Bergmann, this commit
> introduces a small infrastructure that defines a central
> irqchip_init() function in drivers/irqchip/irqchip.c, which is meant
> to be called as the ->init_irq() callback of ARM platforms.

This patch.
Reviewed-by: Stephen Warren <swarren@wwwdotorg.org>

As a minor aside, I only received patch 2/3 in my inbox initially, and
that made no sense to me without reading this patch too. It would have
been helpful to have been CC'd on the whole series.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure
  2012-10-27 16:45 ` [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure Thomas Petazzoni
@ 2012-10-28  2:23   ` Stephen Warren
  2012-10-28  9:03     ` Thomas Petazzoni
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Warren @ 2012-10-28  2:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/27/2012 10:45 AM, Thomas Petazzoni wrote:
> Register the irq controller driver in the main
> drivers/irqchip/irqchip.c file, and make sure that the initialization
> function of the driver sets handle_arch_irq() appropriately. This
> requires a bit of movement in the driver since the
> bcm2835_handle_irq() must move before the armctrl_of_init() function
> to avoid a forward declaration.
> 
> On the arch/arm side, use irqchip_init() as the ->init_irq() callback,
> and remove the definition of ->handle_irq() since this is now done by
> the irq controller driver.

> diff --git a/drivers/irqchip/irq-bcm2835.c b/drivers/irqchip/irq-bcm2835.c

> +static void armctrl_handle_bank(int bank, struct pt_regs *regs)

To make the patch more readable, I'd suggest adding function prototypes
at the start of the file, and not re-arranging the code. That'll remove
the large cut/paste block in the diff. I wouldn't point out this trivial
issue except that I think this needs a respin for the minor issue I
raise below.

> -static int __init armctrl_of_init(struct device_node *node,
> -	struct device_node *parent)
> +int __init armctrl_of_init(struct device_node *node,
> +			   struct device_node *parent)

Since this is now a public API, it should probably be named better. How
about bcm2835_irqchip_init()?

Aside from that,
Acked-by: Stephen Warren <swarren@wwwdotorg.org>

I don't foresee any likely conflicts with anything I'll stage for 3.8 in
the bcm2835 tree, so feel free to take this through the irq tree or
directly into arm-soc as appropriate.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] arm: mvebu: move irq controller driver to drivers/irqchip
  2012-10-27 16:45 ` [PATCH 3/3] arm: mvebu: move irq controller driver to drivers/irqchip Thomas Petazzoni
@ 2012-10-28  2:25   ` Stephen Warren
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Warren @ 2012-10-28  2:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/27/2012 10:45 AM, Thomas Petazzoni wrote:

A patch description might be useful.

The same add-prototype-vs-cut/paste comment as in patch 2 could apply here.

Aside from that, this patch,
Reviewed-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] irqchip: add basic infrastructure
  2012-10-27 19:21 ` [PATCH 1/3] irqchip: add basic infrastructure Arnd Bergmann
  2012-10-27 21:31   ` Thomas Gleixner
@ 2012-10-28  8:58   ` Thomas Petazzoni
  1 sibling, 0 replies; 11+ messages in thread
From: Thomas Petazzoni @ 2012-10-28  8:58 UTC (permalink / raw)
  To: linux-arm-kernel

Arnd,

On Sat, 27 Oct 2012 19:21:17 +0000, Arnd Bergmann wrote:
> On Saturday 27 October 2012, Thomas Petazzoni wrote:
> > With the recent creation of the drivers/irqchip/ directory, it is
> > desirable to move irq controller drivers here. At the moment, the only
> > driver here is irq-bcm2835, the driver for the irq controller found in
> > the ARM BCM2835 SoC, present in Rasberry Pi systems. This irq
> > controller driver was exporting its initialization function and its
> > irq handling function through a header file in
> > <linux/irqchip/bcm2835.h>.
> 
> Very nice series!

Thanks!

> I think it would be good if Thomas Gleixner as the IRQ subsystem maintainer
> could have a look as well. We should probably add the drivers/irqchip
> directory to that MAINTAINERS entry.

Sure.

There are however two things I am not entirely happy with:

 (*) For each irqchip driver, we have to enclose the entry in the
     irqchip_of_match[] array between #ifdef CONFIG... #endif. Not
     really a problem, but not very pretty either, but I don't see a
     simple around it (I don't think we want to define yet another
     custom ELF section just for the purpose of irqchip drivers
     registration).

 (*) The fact that all the irqchip drivers have to mess around directly
     with handle_arch_irq, which is an internal/architecture specific
     symbol. But since the current drivers are only compiled when a ARM
     architecture is selected, maybe it isn't a problem.

But that said, it seems like it is a good enough solution for a start.
Trying to solve those two problems would probably lead to an
over-engineered solution.

Best regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] irqchip: add basic infrastructure
  2012-10-28  2:20 ` Stephen Warren
@ 2012-10-28  8:59   ` Thomas Petazzoni
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Petazzoni @ 2012-10-28  8:59 UTC (permalink / raw)
  To: linux-arm-kernel


On Sat, 27 Oct 2012 20:20:03 -0600, Stephen Warren wrote:
> On 10/27/2012 10:45 AM, Thomas Petazzoni wrote:
> ...
> > So, upon the suggestion of Rob Herring and Arnd Bergmann, this commit
> > introduces a small infrastructure that defines a central
> > irqchip_init() function in drivers/irqchip/irqchip.c, which is meant
> > to be called as the ->init_irq() callback of ARM platforms.
> 
> This patch.
> Reviewed-by: Stephen Warren <swarren@wwwdotorg.org>

Thanks.

> As a minor aside, I only received patch 2/3 in my inbox initially, and
> that made no sense to me without reading this patch too. It would have
> been helpful to have been CC'd on the whole series.

I did Cc: you on patch 2/3 specifically because it was the one
affecting the bcm2835 architecture you're maintaining. But agreed, it
doesn't make much sense to see only this patch 2/3, so I'll Cc you on
the entire series for the next version.

Thanks!

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure
  2012-10-28  2:23   ` Stephen Warren
@ 2012-10-28  9:03     ` Thomas Petazzoni
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Petazzoni @ 2012-10-28  9:03 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Stephen Warren,

On Sat, 27 Oct 2012 20:23:11 -0600, Stephen Warren wrote:

> > On the arch/arm side, use irqchip_init() as the ->init_irq() callback,
> > and remove the definition of ->handle_irq() since this is now done by
> > the irq controller driver.
> 
> > diff --git a/drivers/irqchip/irq-bcm2835.c b/drivers/irqchip/irq-bcm2835.c
> 
> > +static void armctrl_handle_bank(int bank, struct pt_regs *regs)
> 
> To make the patch more readable, I'd suggest adding function prototypes
> at the start of the file, and not re-arranging the code. That'll remove
> the large cut/paste block in the diff. I wouldn't point out this trivial
> issue except that I think this needs a respin for the minor issue I
> raise below.

OK. I thought that forward declarations were completely forbidden in
the kernel coding style, but I don't mind changing the patch with this.

> > -static int __init armctrl_of_init(struct device_node *node,
> > -	struct device_node *parent)
> > +int __init armctrl_of_init(struct device_node *node,
> > +			   struct device_node *parent)
> 
> Since this is now a public API, it should probably be named better. How
> about bcm2835_irqchip_init()?

Well, it is public only within the boundaries of the irqchip
infrastructure, it doesn't get exposed beyond that. But I agree a
better name is good, so I'll change this.

> Aside from that,
> Acked-by: Stephen Warren <swarren@wwwdotorg.org>

Thanks!

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-10-28  9:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-27 16:45 [PATCH 1/3] irqchip: add basic infrastructure Thomas Petazzoni
2012-10-27 16:45 ` [PATCH 2/3] arm: bcm2835: convert to the irqchip infrastructure Thomas Petazzoni
2012-10-28  2:23   ` Stephen Warren
2012-10-28  9:03     ` Thomas Petazzoni
2012-10-27 16:45 ` [PATCH 3/3] arm: mvebu: move irq controller driver to drivers/irqchip Thomas Petazzoni
2012-10-28  2:25   ` Stephen Warren
2012-10-27 19:21 ` [PATCH 1/3] irqchip: add basic infrastructure Arnd Bergmann
2012-10-27 21:31   ` Thomas Gleixner
2012-10-28  8:58   ` Thomas Petazzoni
2012-10-28  2:20 ` Stephen Warren
2012-10-28  8:59   ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).