From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>,
Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
Gregory Clement <gregory.clement@free-electrons.com>,
Thomas Gleixner <tglx@linutronix.de>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [RFC v1 1/5] irqchip: add Armada 1500 APB interrupt controller
Date: Fri, 16 Aug 2013 21:41:34 +0200 [thread overview]
Message-ID: <1376682098-10580-2-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1376682098-10580-1-git-send-email-sebastian.hesselbarth@gmail.com>
This adds irqchip drivers for the secondary interrupt controllers found
on Armada 1500 APB and SYSMGT APB bus.
I tried to find a compatible irqchip driver within v3.11-rc5, but there
is no. I guess that it is a common IP core to buy for your SoC, so maybe
one of the maintainers knows a better name for it. Could be DesignWare
type-of as timers are DW, too.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@free-electrons.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
drivers/irqchip/Makefile | 1 +
drivers/irqchip/irq-armada-1500-apb.c | 108 +++++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+)
create mode 100644 drivers/irqchip/irq-armada-1500-apb.c
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index e65c41a..f02f4db 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_IRQCHIP) += irqchip.o
+obj-$(CONFIG_MACH_ARMADA_1500) += irq-armada-1500-apb.o
obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
obj-$(CONFIG_ARCH_EXYNOS) += exynos-combiner.o
obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o
diff --git a/drivers/irqchip/irq-armada-1500-apb.c b/drivers/irqchip/irq-armada-1500-apb.c
new file mode 100644
index 0000000..8626eb1
--- /dev/null
+++ b/drivers/irqchip/irq-armada-1500-apb.c
@@ -0,0 +1,108 @@
+/*
+ * Marvell Armada 1500 SoC APB IRQ chip driver.
+ *
+ * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.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/io.h>
+#include <linux/irq.h>
+#include <linux/irqchip/chained_irq.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <asm/exception.h>
+#include <asm/mach/irq.h>
+
+#include "irqchip.h"
+
+#define APB_INT_ENABLE 0x00
+#define APB_INT_MASK 0x08
+#define APB_INT_FINALSTATUS 0x30
+
+static void armada_1500_apb_irq_handler(unsigned int irq, struct irq_desc *desc)
+{
+ struct irq_chip *chip = irq_get_chip(irq);
+ struct irq_chip_generic *gc = irq_get_handler_data(irq);
+ struct irq_domain *d = gc->private;
+ u32 stat;
+
+ chained_irq_enter(chip, desc);
+
+ stat = readl_relaxed(gc->reg_base + APB_INT_FINALSTATUS);
+
+ while (stat) {
+ u32 hwirq = ffs(stat) - 1;
+ generic_handle_irq(irq_find_mapping(d, gc->irq_base + hwirq));
+ stat &= ~(1 << hwirq);
+ }
+ chained_irq_exit(chip, desc);
+}
+
+static int __init armada_1500_apb_irq_init(struct device_node *np,
+ struct device_node *parent)
+{
+ unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
+ struct resource r;
+ struct irq_domain *domain;
+ struct irq_chip_generic *gc;
+ int ret, irq;
+
+ domain = irq_domain_add_linear(np, 32,
+ &irq_generic_chip_ops, NULL);
+ if (!domain) {
+ pr_err("%s: unable to add irq domain\n", np->name);
+ return -ENOMEM;
+ }
+
+ ret = irq_alloc_domain_generic_chips(domain, 32, 1, np->name,
+ handle_level_irq, clr, 0, IRQ_GC_INIT_MASK_CACHE);
+ if (ret) {
+ pr_err("%s: unable to alloc irq domain gc\n", np->name);
+ return ret;
+ }
+
+ ret = of_address_to_resource(np, 0, &r);
+ if (ret) {
+ pr_err("%s: unable to get resource\n", np->name);
+ return ret;
+ }
+
+ if (!request_mem_region(r.start, resource_size(&r), np->name)) {
+ pr_err("%s: unable to request mem region\n", np->name);
+ return -ENOMEM;
+ }
+
+ /* Map the parent interrupt for the chained handler */
+ irq = irq_of_parse_and_map(np, 0);
+ if (irq <= 0) {
+ pr_err("%s: unable to parse irq\n", np->name);
+ return -EINVAL;
+ }
+
+ gc = irq_get_domain_generic_chip(domain, 0);
+ gc->private = domain;
+ gc->reg_base = ioremap(r.start, resource_size(&r));
+ if (!gc->reg_base) {
+ pr_err("%s: unable to map resource\n", np->name);
+ return -ENOMEM;
+ }
+
+ gc->chip_types[0].regs.mask = APB_INT_MASK;
+ gc->chip_types[0].chip.irq_mask = irq_gc_mask_set_bit;
+ gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit;
+
+ /* mask and enable all interrupts */
+ writel(~0, gc->reg_base + APB_INT_MASK);
+ writel(~0, gc->reg_base + APB_INT_ENABLE);
+
+ irq_set_handler_data(irq, gc);
+ irq_set_chained_handler(irq, armada_1500_apb_irq_handler);
+
+ return 0;
+}
+IRQCHIP_DECLARE(armada_1500_apb_intc,
+ "marvell,armada-1500-apb-intc", armada_1500_apb_irq_init);
--
1.7.10.4
next prev parent reply other threads:[~2013-08-16 22:36 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-16 19:41 [RFC v1 0/5] ARM: Initial support for Marvell Armada 1500 Sebastian Hesselbarth
2013-08-16 19:41 ` Sebastian Hesselbarth [this message]
2013-08-17 13:24 ` [RFC v1 1/5] irqchip: add Armada 1500 APB interrupt controller Sebastian Hesselbarth
2013-08-16 19:41 ` [RFC v1 2/5] ARM: mvebu: add Armada 1500 to defconfig Sebastian Hesselbarth
2013-08-16 19:41 ` [RFC v1 3/5] ARM: mvebu: add Armada 150 uart to lowlevel debug Sebastian Hesselbarth
2013-08-16 20:39 ` Jason Cooper
2013-08-17 19:01 ` Arnd Bergmann
2013-08-16 19:41 ` [RFC v1 4/5] ARM: mvebu: add Armada 1500 and Sony NSZ-GS7 device tree files Sebastian Hesselbarth
2013-08-16 19:50 ` Jason Cooper
2013-08-16 19:54 ` Sebastian Hesselbarth
2013-08-16 20:22 ` Jason Cooper
2013-08-17 19:28 ` Arnd Bergmann
2013-08-18 23:11 ` Sebastian Hesselbarth
2013-08-19 8:46 ` Arnd Bergmann
2013-08-16 19:41 ` [RFC v1 5/5] ARM: mvebu: add board init for Armada 1500 Sebastian Hesselbarth
2013-08-16 20:48 ` Jason Cooper
2013-08-17 13:01 ` Sebastian Hesselbarth
2013-08-17 19:08 ` Arnd Bergmann
2013-08-17 19:13 ` Arnd Bergmann
2013-08-18 23:01 ` Sebastian Hesselbarth
2013-08-19 7:44 ` Arnd Bergmann
2013-08-19 14:52 ` Sebastian Hesselbarth
2013-08-19 17:47 ` Arnd Bergmann
2013-08-17 15:38 ` Thomas Petazzoni
2013-08-17 19:12 ` Arnd Bergmann
2013-08-18 23:02 ` Sebastian Hesselbarth
2013-08-19 7:58 ` Arnd Bergmann
2013-08-17 19:32 ` [RFC v1 0/5] ARM: Initial support for Marvell " Arnd Bergmann
2013-08-18 23:21 ` Sebastian Hesselbarth
2013-08-19 8:03 ` Arnd Bergmann
2013-08-18 16:34 ` Thomas Petazzoni
2013-08-27 14:19 ` Thomas Petazzoni
2013-08-27 16:45 ` Sebastian Hesselbarth
2013-08-27 16:51 ` Thomas Petazzoni
2013-08-27 19:38 ` Arnd Bergmann
2013-08-28 0:14 ` [PATCH RFC v2 0/6] " Sebastian Hesselbarth
2013-08-28 0:14 ` [PATCH RFC v2 1/6] irqchip: add DesignWare APB ICTL interrupt controller Sebastian Hesselbarth
2013-08-28 0:14 ` [PATCH RFC v2 2/6] ARM: add Marvell Berlin SoC familiy to Marvell doc Sebastian Hesselbarth
2013-08-28 0:14 ` [PATCH RFC v2 3/6] ARM: add Marvell Berlin and Armada 1500 to multi_v7_defconfig Sebastian Hesselbarth
2013-08-28 0:14 ` [PATCH RFC v2 4/6] ARM: add Marvell Berlin UART0 lowlevel debug Sebastian Hesselbarth
2013-08-28 0:14 ` [PATCH RFC v2 5/6] ARM: add Armada 1500 and Sony NSZ-GS7 device tree files Sebastian Hesselbarth
2013-08-28 12:14 ` Jason Cooper
2013-08-28 12:23 ` Sebastian Hesselbarth
2013-08-28 0:14 ` [PATCH RFC v2 6/6] ARM: add initial support for Marvell Berlin SoCs Sebastian Hesselbarth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1376682098-10580-2-git-send-email-sebastian.hesselbarth@gmail.com \
--to=sebastian.hesselbarth@gmail.com \
--cc=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=gregory.clement@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=tglx@linutronix.de \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).