From: Lars-Peter Clausen <lars@metafoo.de>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH v3] MIPS: jz4740: Add IRQ handler code
Date: Sat, 17 Jul 2010 14:08:43 +0200 [thread overview]
Message-ID: <1279368523-20427-1-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1276924111-11158-3-git-send-email-lars@metafoo.de>
This patch adds support for IRQ handling on a JZ4740 SoC.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
--
Changes since v1
- Reserve IRQ numbers for ADC IRQ demultiplexing
Changes since v2
- Use __fls instead of ffs in the interrupt demuxer
---
arch/mips/include/asm/mach-jz4740/irq.h | 57 +++++++++++
arch/mips/jz4740/irq.c | 167 +++++++++++++++++++++++++++++++
arch/mips/jz4740/irq.h | 21 ++++
3 files changed, 245 insertions(+), 0 deletions(-)
create mode 100644 arch/mips/include/asm/mach-jz4740/irq.h
create mode 100644 arch/mips/jz4740/irq.c
create mode 100644 arch/mips/jz4740/irq.h
diff --git a/arch/mips/include/asm/mach-jz4740/irq.h b/arch/mips/include/asm/mach-jz4740/irq.h
new file mode 100644
index 0000000..a865c98
--- /dev/null
+++ b/arch/mips/include/asm/mach-jz4740/irq.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
+ * JZ4740 IRQ definitions
+ *
+ * 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.
+ *
+ * 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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __ASM_MACH_JZ4740_IRQ_H__
+#define __ASM_MACH_JZ4740_IRQ_H__
+
+#define MIPS_CPU_IRQ_BASE 0
+#define JZ4740_IRQ_BASE 8
+
+/* 1st-level interrupts */
+#define JZ4740_IRQ(x) (JZ4740_IRQ_BASE + (x))
+#define JZ4740_IRQ_I2C JZ4740_IRQ(1)
+#define JZ4740_IRQ_UHC JZ4740_IRQ(3)
+#define JZ4740_IRQ_UART1 JZ4740_IRQ(8)
+#define JZ4740_IRQ_UART0 JZ4740_IRQ(9)
+#define JZ4740_IRQ_SADC JZ4740_IRQ(12)
+#define JZ4740_IRQ_MSC JZ4740_IRQ(14)
+#define JZ4740_IRQ_RTC JZ4740_IRQ(15)
+#define JZ4740_IRQ_SSI JZ4740_IRQ(16)
+#define JZ4740_IRQ_CIM JZ4740_IRQ(17)
+#define JZ4740_IRQ_AIC JZ4740_IRQ(18)
+#define JZ4740_IRQ_ETH JZ4740_IRQ(19)
+#define JZ4740_IRQ_DMAC JZ4740_IRQ(20)
+#define JZ4740_IRQ_TCU2 JZ4740_IRQ(21)
+#define JZ4740_IRQ_TCU1 JZ4740_IRQ(22)
+#define JZ4740_IRQ_TCU0 JZ4740_IRQ(23)
+#define JZ4740_IRQ_UDC JZ4740_IRQ(24)
+#define JZ4740_IRQ_GPIO3 JZ4740_IRQ(25)
+#define JZ4740_IRQ_GPIO2 JZ4740_IRQ(26)
+#define JZ4740_IRQ_GPIO1 JZ4740_IRQ(27)
+#define JZ4740_IRQ_GPIO0 JZ4740_IRQ(28)
+#define JZ4740_IRQ_IPU JZ4740_IRQ(29)
+#define JZ4740_IRQ_LCD JZ4740_IRQ(30)
+
+/* 2nd-level interrupts */
+#define JZ4740_IRQ_DMA(x) (JZ4740_IRQ(32) + (X))
+
+#define JZ4740_IRQ_INTC_GPIO(x) (JZ4740_IRQ_GPIO0 - (x))
+#define JZ4740_IRQ_GPIO(x) (JZ4740_IRQ(48) + (x))
+
+#define JZ4740_IRQ_ADC_BASE JZ4740_IRQ(176)
+
+#define NR_IRQS (JZ4740_IRQ_ADC_BASE + 6)
+
+#endif
diff --git a/arch/mips/jz4740/irq.c b/arch/mips/jz4740/irq.c
new file mode 100644
index 0000000..7d33ff8
--- /dev/null
+++ b/arch/mips/jz4740/irq.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
+ * JZ4740 platform IRQ support
+ *
+ * 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.
+ *
+ * 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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/ioport.h>
+#include <linux/timex.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+
+#include <asm/io.h>
+#include <asm/mipsregs.h>
+#include <asm/irq_cpu.h>
+
+#include <asm/mach-jz4740/base.h>
+
+static void __iomem *jz_intc_base;
+static uint32_t jz_intc_wakeup;
+static uint32_t jz_intc_saved;
+
+#define JZ_REG_INTC_STATUS 0x00
+#define JZ_REG_INTC_MASK 0x04
+#define JZ_REG_INTC_SET_MASK 0x08
+#define JZ_REG_INTC_CLEAR_MASK 0x0c
+#define JZ_REG_INTC_PENDING 0x10
+
+#define IRQ_BIT(x) BIT((x) - JZ4740_IRQ_BASE)
+
+static void intc_irq_unmask(unsigned int irq)
+{
+ writel(IRQ_BIT(irq), jz_intc_base + JZ_REG_INTC_CLEAR_MASK);
+}
+
+static void intc_irq_mask(unsigned int irq)
+{
+ writel(IRQ_BIT(irq), jz_intc_base + JZ_REG_INTC_SET_MASK);
+}
+
+static int intc_irq_set_wake(unsigned int irq, unsigned int on)
+{
+ if (on)
+ jz_intc_wakeup |= IRQ_BIT(irq);
+ else
+ jz_intc_wakeup &= ~IRQ_BIT(irq);
+
+ return 0;
+}
+
+static struct irq_chip intc_irq_type = {
+ .name = "INTC",
+ .mask = intc_irq_mask,
+ .mask_ack = intc_irq_mask,
+ .unmask = intc_irq_unmask,
+ .set_wake = intc_irq_set_wake,
+};
+
+static irqreturn_t jz4740_cascade(int irq, void *data)
+{
+ uint32_t irq_reg;
+
+ irq_reg = readl(jz_intc_base + JZ_REG_INTC_PENDING);
+
+ if (irq_reg)
+ generic_handle_irq(__fls(irq_reg) + JZ4740_IRQ_BASE);
+
+ return IRQ_HANDLED;
+}
+
+static struct irqaction jz4740_cascade_action = {
+ .handler = jz4740_cascade,
+ .name = "JZ4740 cascade interrupt",
+};
+
+void __init arch_init_irq(void)
+{
+ int i;
+ mips_cpu_irq_init();
+
+ jz_intc_base = ioremap(JZ4740_INTC_BASE_ADDR, 0x14);
+
+ for (i = JZ4740_IRQ_BASE; i < JZ4740_IRQ_BASE + 32; i++) {
+ intc_irq_mask(i);
+ set_irq_chip_and_handler(i, &intc_irq_type, handle_level_irq);
+ }
+
+ setup_irq(2, &jz4740_cascade_action);
+}
+
+asmlinkage void plat_irq_dispatch(void)
+{
+ unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
+ if (pending & STATUSF_IP2)
+ do_IRQ(2);
+ else if (pending & STATUSF_IP3)
+ do_IRQ(3);
+ else
+ spurious_interrupt();
+}
+
+void jz4740_intc_suspend(void)
+{
+ jz_intc_saved = readl(jz_intc_base + JZ_REG_INTC_MASK);
+ writel(~jz_intc_wakeup, jz_intc_base + JZ_REG_INTC_SET_MASK);
+ writel(jz_intc_wakeup, jz_intc_base + JZ_REG_INTC_CLEAR_MASK);
+}
+
+void jz4740_intc_resume(void)
+{
+ writel(~jz_intc_saved, jz_intc_base + JZ_REG_INTC_CLEAR_MASK);
+ writel(jz_intc_saved, jz_intc_base + JZ_REG_INTC_SET_MASK);
+}
+
+#ifdef CONFIG_DEBUG_FS
+
+static inline void intc_seq_reg(struct seq_file *s, const char *name,
+ unsigned int reg)
+{
+ seq_printf(s, "%s:\t\t%08x\n", name, readl(jz_intc_base + reg));
+}
+
+static int intc_regs_show(struct seq_file *s, void *unused)
+{
+ intc_seq_reg(s, "Status", JZ_REG_INTC_STATUS);
+ intc_seq_reg(s, "Mask", JZ_REG_INTC_MASK);
+ intc_seq_reg(s, "Pending", JZ_REG_INTC_PENDING);
+
+ return 0;
+}
+
+static int intc_regs_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, intc_regs_show, NULL);
+}
+
+static const struct file_operations intc_regs_operations = {
+ .open = intc_regs_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static int __init intc_debugfs_init(void)
+{
+ (void) debugfs_create_file("jz_regs_intc", S_IFREG | S_IRUGO,
+ NULL, NULL, &intc_regs_operations);
+ return 0;
+}
+subsys_initcall(intc_debugfs_init);
+
+#endif
diff --git a/arch/mips/jz4740/irq.h b/arch/mips/jz4740/irq.h
new file mode 100644
index 0000000..56b5ead
--- /dev/null
+++ b/arch/mips/jz4740/irq.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
+ *
+ * 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.
+ *
+ * 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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __MIPS_JZ4740_IRQ_H__
+#define __MIPS_JZ4740_IRQ_H__
+
+extern void jz4740_intc_suspend(void);
+extern void jz4740_intc_resume(void);
+
+#endif
--
1.5.6.5
next prev parent reply other threads:[~2010-07-17 12:09 UTC|newest]
Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-19 5:08 [PATCH v2 00/26] Add support for the Ingenic JZ4740 System-on-a-Chip Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 01/26] MIPS: Add base support for " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 02/26] MIPS: jz4740: Add IRQ handler code Lars-Peter Clausen
2010-07-17 12:08 ` Lars-Peter Clausen [this message]
2010-06-19 5:08 ` [PATCH v2 03/26] MIPS: JZ4740: Add clock API support Lars-Peter Clausen
2010-06-28 1:24 ` [PATCH v3 " Lars-Peter Clausen
2010-07-17 12:10 ` [PATCH v4] " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 04/26] MIPS: JZ4740: Add timer support Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 05/26] MIPS: JZ4740: Add clocksource/clockevent support Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 06/26] MIPS: JZ4740: Add power-management and system reset support Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 07/26] MIPS: JZ4740: Add setup code Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 08/26] MIPS: JZ4740: Add gpio support Lars-Peter Clausen
2010-07-17 12:11 ` [PATCH v3] " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 09/26] MIPS: JZ4740: Add DMA support Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 10/26] MIPS: JZ4740: Add PWM support Lars-Peter Clausen
2010-06-28 1:23 ` [PATCH v3 " Lars-Peter Clausen
2010-07-17 12:12 ` [PATCH v4] " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 11/26] MIPS: JZ4740: Add serial support Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 12/26] MIPS: JZ4740: Add prom support Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 13/26] MIPS: JZ4740: Add platform devices Lars-Peter Clausen
2010-07-17 12:13 ` [PATCH v3] " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 14/26] MIPS: JZ4740: Add Kbuild files Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 15/26] RTC: Add JZ4740 RTC driver Lars-Peter Clausen
2010-06-19 10:43 ` Marek Vasut
2010-06-19 13:05 ` Lars-Peter Clausen
2010-06-19 13:37 ` Wan ZongShun
2010-06-19 13:53 ` Lars-Peter Clausen
2010-06-19 14:36 ` Wan ZongShun
2010-06-19 14:04 ` Marek Vasut
2010-06-19 17:42 ` Lars-Peter Clausen
2010-06-19 17:53 ` Geert Uytterhoeven
2010-06-19 19:29 ` [PATCH v3] " Lars-Peter Clausen
2010-06-20 1:13 ` [rtc-linux] " Wan ZongShun
2010-06-20 1:23 ` Lars-Peter Clausen
2010-06-20 1:30 ` Wan ZongShun
2010-06-22 5:53 ` Alessandro Zummo
2010-06-19 5:08 ` [PATCH v2 16/26] fbdev: Add JZ4740 framebuffer driver Lars-Peter Clausen
2010-07-04 22:27 ` Lars-Peter Clausen
2010-07-07 23:41 ` Andrew Morton
2010-07-08 13:28 ` Lars-Peter Clausen
2010-07-08 16:46 ` Andrew Morton
2010-07-09 1:26 ` Jaya Kumar
2010-07-09 15:31 ` Lars-Peter Clausen
2010-07-17 12:14 ` [PATCH v3] " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 17/26] MTD: Nand: Add JZ4740 NAND driver Lars-Peter Clausen
2010-07-04 22:35 ` [PATCH v2 17/26] MTD: Nand: Add JZ4740 NAND Lars-Peter Clausen
2010-07-08 6:06 ` [PATCH v2 17/26] MTD: Nand: Add JZ4740 NAND driver Artem Bityutskiy
2010-07-08 13:20 ` Lars-Peter Clausen
2010-07-08 13:19 ` Artem Bityutskiy
2010-07-08 14:02 ` Lars-Peter Clausen
2010-07-08 14:14 ` Artem Bityutskiy
2010-07-17 12:15 ` [PATCH v3] " Lars-Peter Clausen
2010-07-18 16:54 ` Artem Bityutskiy
2010-07-18 17:02 ` Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 18/26] MMC: Add JZ4740 mmc driver Lars-Peter Clausen
2010-06-19 14:46 ` Matt Fleming
2010-06-19 15:29 ` Lars-Peter Clausen
2010-06-28 1:20 ` [PATCH v3] " Lars-Peter Clausen
2010-06-29 20:17 ` Matt Fleming
2010-07-01 15:47 ` Lars-Peter Clausen
2010-06-30 20:55 ` Andrew Morton
2010-07-01 15:45 ` Lars-Peter Clausen
2010-07-12 21:33 ` [PATCH v4] " Lars-Peter Clausen
2010-07-12 21:41 ` Randy Dunlap
2010-07-12 22:07 ` Lars-Peter Clausen
2010-07-12 22:20 ` [PATCH v5] " Lars-Peter Clausen
2010-07-12 22:45 ` Joe Perches
2010-07-12 23:45 ` Lars-Peter Clausen
2010-07-15 21:06 ` [PATCH v6] " Lars-Peter Clausen
2010-07-15 21:16 ` Andrew Morton
2010-07-15 21:37 ` Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 19/26] USB: Add JZ4740 ohci support Lars-Peter Clausen
2010-06-19 17:17 ` Greg KH
2010-06-19 5:08 ` [PATCH v2 20/26] alsa: ASoC: Add JZ4740 codec driver Lars-Peter Clausen
2010-06-19 14:49 ` [PATCH v3] " Lars-Peter Clausen
2010-06-20 13:11 ` Mark Brown
2010-06-21 22:46 ` [PATCH v4] " Lars-Peter Clausen
2010-06-22 10:12 ` Liam Girdwood
2010-06-22 23:12 ` Mark Brown
2010-06-19 5:08 ` [PATCH v2 21/26] alsa: ASoC: Add JZ4740 ASoC support Lars-Peter Clausen
2010-06-19 14:50 ` [PATCH v3] " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 22/26] MFD: Add JZ4740 ADC driver Lars-Peter Clausen
2010-07-04 22:47 ` Lars-Peter Clausen
2010-07-05 14:53 ` Samuel Ortiz
2010-07-05 15:43 ` Lars-Peter Clausen
2010-07-05 15:53 ` Samuel Ortiz
2010-07-12 1:48 ` [PATCH v3] " Lars-Peter Clausen
2010-07-14 9:19 ` Samuel Ortiz
2010-06-19 5:08 ` [PATCH v2 23/26] hwmon: " Lars-Peter Clausen
2010-06-19 8:36 ` [lm-sensors] " Jean Delvare
2010-06-19 12:58 ` Lars-Peter Clausen
2010-06-19 14:47 ` [PATCH v3] " Lars-Peter Clausen
2010-06-19 16:24 ` [lm-sensors] " Jean Delvare
2010-06-19 17:59 ` Lars-Peter Clausen
2010-06-19 19:32 ` [PATCH v4] " Lars-Peter Clausen
2010-06-20 6:32 ` [lm-sensors] " Jean Delvare
2010-06-19 5:08 ` [PATCH v2 24/26] power: Add JZ4740 battery driver Lars-Peter Clausen
2010-06-27 1:58 ` Lars-Peter Clausen
2010-06-28 11:43 ` Anton Vorontsov
2010-06-19 5:08 ` [PATCH v2 25/26] MIPS: JZ4740: Add qi_lb60 board support Lars-Peter Clausen
2010-07-17 12:16 ` [PATCH v3] " Lars-Peter Clausen
2010-06-19 5:08 ` [PATCH v2 26/26] alsa: ASoC: JZ4740: Add qi_lb60 board driver Lars-Peter Clausen
2010-06-19 14:52 ` [PATCH v3] " Lars-Peter Clausen
2010-06-20 9:26 ` [PATCH v2 00/26] Add support for the Ingenic JZ4740 System-on-a-Chip Thomas Bogendoerfer
2010-06-20 14:31 ` Lars-Peter Clausen
2010-06-20 16:34 ` Thomas Bogendoerfer
2010-06-20 16:49 ` Lars-Peter Clausen
2010-06-20 17:01 ` Thomas Bogendoerfer
2010-06-20 17:57 ` Florian Fainelli
2010-06-20 18:30 ` Lars-Peter Clausen
2010-06-21 2:56 ` Xiangfu Liu
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=1279368523-20427-1-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/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).