irqchip: add basic infrastructure
Subsystems (6)
PATCH 1/3 irqchip: add basic infrastructure
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.
--- 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
drivers/irqchip/Kconfig +2 -1
@@ -1 +1,2 @@ -# empty +config USE_IRQCHIP + bool
drivers/irqchip/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_USE_IRQCHIP) += irqchip.o obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
drivers/irqchip/irqchip.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (C) 2012 Thomas Petazzoni +* +* Thomas Petazzoni <[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/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); +}
drivers/irqchip/irqchip.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* Copyright (C) 2012 Thomas Petazzoni +* +* Thomas Petazzoni <[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. +*/ + +#ifndef _IRQCHIP_H +#define _IRQCHIP_H + +#endif
include/linux/irqchip.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright (C) 2012 Thomas Petazzoni +* +* Thomas Petazzoni <[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. +*/ + +#ifndef _LINUX_IRQCHIP_H +#define _LINUX_IRQCHIP_H + +void irqchip_init (void ); + +#endif
Signature · 1 line
1.7.9.5
PATCH 2/3 arm: bcm2835: convert to the irqchip infrastructure
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.
--- 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
arch/arm/Kconfig +1 -0
@@ -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.
arch/arm/mach-bcm2835/bcm2835.c +2 -3
@@ -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
drivers/irqchip/irq-bcm2835.c +53 -57
136 lines not on this page · raw message
drivers/irqchip/irqchip.c +3 -0
@@ -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 {}, };
drivers/irqchip/irqchip.h +2 -0
@@ -11,4 +11,6 @@#ifndef _IRQCHIP_H#define _IRQCHIP_H +int armctrl_of_init (struct device_node *node,struct device_node *parent); +#endif
include/linux/irqchip/bcm2835.h deleted +0 -29
@@ -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
Signature · 1 line
1.7.9.5
PATCH 2/3 arm: bcm2835: convert to the irqchip infrastructure
Quoted 12 lines · Thomas Petazzoni
Register the irq controller driver in the main
drivers/irqchip/irqchip.cfile, and make sure that the initialization function of the driver setshandle_arch_irq()appropriately. This requires a bit of movement in the driver since thebcm2835_handle_irq()must move before thearmctrl_of_init()function to avoid a forward declaration.On the
arch/armside, useirqchip_init()as the ->init_irq() callback, and remove the definition of ->handle_irq() since this is now done by the irq controller driver.
drivers/irqchip/irq-bcm2835.c struct armctrl_ic { · line 105
Quoted 2 lines
drivers/irqchip/irq-bcm2835.c +1
-0+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.
drivers/irqchip/irq-bcm2835.c static struct irq_domain_ops armctrl_ops = { · line 187
Quoted 4 lines
drivers/irqchip/irq-bcm2835.c +2
-2-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,
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.
PATCH 2/3 arm: bcm2835: convert to the irqchip infrastructure
Dear Stephen Warren,
Quoted 6 lines · Stephen Warren
Quoted 5 lines
On the
arch/armside, useirqchip_init()as the ->init_irq() callback, and remove the definition of ->handle_irq() since this is now done by the irq controller driver.drivers/irqchip/irq-bcm2835.c +0
-0
Quoted 7 lines
Quoted 1 line
+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.
Quoted 7 lines
drivers/irqchip/irq-bcm2835.c static struct irq_domain_ops armctrl_ops = { · line 187
Quoted 4 lines
drivers/irqchip/irq-bcm2835.c +2
-2-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.
Quoted 2 lines
Aside from that,
Acked-by Stephen Warren <[email protected]>
Thanks!
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 3/3 arm: mvebu: move irq controller driver to drivers/irqchip
In reply to Thomas Petazzoni---
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%)arch/arm/mach-mvebu/Kconfig +1 -0
@@ -9,6 +9,7 @@ config ARCH_MVEBU select PINCTRL select PLAT_ORION select SPARSE_IRQ + select USE_IRQCHIP if ARCH_MVEBU
arch/arm/mach-mvebu/Makefile +1 -1
@@ -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
arch/arm/mach-mvebu/armada-370-xp.c +2 -2
@@ -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,
arch/arm/mach-mvebu/common.h +0 -3
@@ -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
drivers/irqchip/Makefile +1 -0
@@ -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
drivers/irqchip/irq-armada-370-xp.c renamed from arch/arm/mach-mvebu/irq-armada-370-xp.c +26 -32
82 lines not on this page · raw message
drivers/irqchip/irqchip.c +3 -0
@@ -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 {}, };
drivers/irqchip/irqchip.h +2 -0
@@ -12,5 +12,7 @@#define _IRQCHIP_Hint 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
Signature · 1 line
1.7.9.5
PATCH 3/3 arm: mvebu: move irq controller driver to drivers/irqchip
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,
PATCH 1/3 irqchip: add basic infrastructure
In reply to Thomas PetazzoniQuoted 7 lines · Thomas Petazzoni
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
PATCH 1/3 irqchip: add basic infrastructure
Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · Thomas Petazzoni
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>.
Quoted 5 lines
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/irqchipdirectory to thatMAINTAINERSentry.
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
PATCH 1/3 irqchip: add basic infrastructure
In reply to Arnd BergmannArnd,
Quoted 10 lines · Arnd Bergmann
Quoted 7 lines · Thomas Petazzoni
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!
Quoted 3 lines
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/irqchipdirectory to thatMAINTAINERSentry.
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
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/3 irqchip: add basic infrastructure
In reply to Thomas PetazzoniOn 10/27/2012 10:45 AM, Thomas Petazzoni wrote:
...
Quoted 4 lines
So, upon the suggestion of Rob Herring and Arnd Bergmann, this commit introduces a small infrastructure that defines a central
irqchip_init()function indrivers/irqchip/irqchip.c, which is meant to be called as the ->init_irq() callback of ARM platforms.
This patch.
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.
PATCH 1/3 irqchip: add basic infrastructure
Quoted 9 lines · Stephen Warren
On 10/27/2012 10:45 AM, Thomas Petazzoni wrote:
...Quoted 4 lines
So, upon the suggestion of Rob Herring and Arnd Bergmann, this commit introduces a small infrastructure that defines a central
irqchip_init()function indrivers/irqchip/irqchip.c, which is meant to be called as the ->init_irq() callback of ARM platforms.This patch.
Reviewed-by Stephen Warren <[email protected]>
Thanks.
Quoted 3 lines
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
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com