]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
MN10300: ASB2364: Handle the IRQ multiplexer in the FPGA
authorDavid Howells <dhowells@redhat.com>
Wed, 27 Oct 2010 16:28:58 +0000 (17:28 +0100)
committerDavid Howells <dhowells@redhat.com>
Wed, 27 Oct 2010 16:28:58 +0000 (17:28 +0100)
Handle the IRQ multiplexer in the FPGA by implementing a cascade interrupt
driver for it.

Signed-off-by: David Howells <dhowells@redhat.com>
arch/mn10300/include/asm/irq.h
arch/mn10300/kernel/irq.c
arch/mn10300/unit-asb2364/Makefile
arch/mn10300/unit-asb2364/include/unit/fpga-regs.h
arch/mn10300/unit-asb2364/include/unit/irq.h [new file with mode: 0644]
arch/mn10300/unit-asb2364/irq-fpga.c [new file with mode: 0644]
arch/mn10300/unit-asb2364/unit-init.c

index b7b8e175b167baa36b02172ffb079fcf6640a9ef..1a73fb3f60c6607734a57470b391c9f5b4085ebc 100644 (file)
 /* this number is used when no interrupt has been assigned */
 #define NO_IRQ         INT_MAX
 
-/* hardware irq numbers */
-#ifdef CONFIG_SMP
-#define NR_IRQS                GxICR_NUM_EXT_IRQS
+/*
+ * hardware irq numbers
+ * - the ASB2364 has an FPGA with an IRQ multiplexer on it
+ */
+#ifdef CONFIG_MN10300_UNIT_ASB2364
+#include <unit/irq.h>
 #else
-#define NR_IRQS                GxICR_NUM_IRQS
+#define NR_CPU_IRQS    GxICR_NUM_IRQS
+#define NR_IRQS                NR_CPU_IRQS
 #endif
 
 /* external hardware irq numbers */
index 2f66a45dcd18d843df30d6d5439b497b28eccc53..c2e44597c22b1fc5b69ebf13cca307d43c2d1a52 100644 (file)
@@ -381,9 +381,16 @@ int show_interrupts(struct seq_file *p, void *v)
                        seq_printf(p, "%3d: ", i);
                        for_each_present_cpu(cpu)
                                seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu));
-                       seq_printf(p, " %14s.%u", irq_desc[i].chip->name,
-                                  (GxICR(i) & GxICR_LEVEL) >>
-                                  GxICR_LEVEL_SHIFT);
+
+                       if (i < NR_CPU_IRQS)
+                               seq_printf(p, " %14s.%u",
+                                          irq_desc[i].chip->name,
+                                          (GxICR(i) & GxICR_LEVEL) >>
+                                          GxICR_LEVEL_SHIFT);
+                       else
+                               seq_printf(p, " %14s",
+                                          irq_desc[i].chip->name);
+
                        seq_printf(p, "  %s", action->name);
 
                        for (action = action->next;
index 6dd27d65877aeb7c1799067934e80e14fa004f82..e9d9b90ef6dab7020b4f8466314992ebf57bcc97 100644 (file)
@@ -7,4 +7,4 @@
 #
 # Note 2! The CFLAGS definitions are now in the main makefile...
 
-obj-y   := unit-init.o leds.o
+obj-y   := unit-init.o leds.o irq-fpga.o
index a039a50c91dbc317a346aacaa9819e793fc7f967..7cf12054db65da40b87d3cffe4f48ec13a322daa 100644 (file)
 #define ASB2364_FPGA_REG_RESET_USB     __SYSREG(0xa900130c, u16)
 #define ASB2364_FPGA_REG_RESET_AV      __SYSREG(0xa9001310, u16)
 
-#define ASB2364_FPGA_REG_IRQ_LAN       __SYSREG(0xa9001510, u16)
-#define ASB2364_FPGA_REG_IRQ_UART      __SYSREG(0xa9001514, u16)
-#define ASB2364_FPGA_REG_IRQ_I2C       __SYSREG(0xa9001518, u16)
-#define ASB2364_FPGA_REG_IRQ_USB       __SYSREG(0xa900151c, u16)
-#define ASB2364_FPGA_REG_IRQ_FPGA      __SYSREG(0xa9001524, u16)
-
-#define ASB2364_FPGA_REG_MASK_LAN      __SYSREG(0xa9001590, u16)
-#define ASB2364_FPGA_REG_MASK_UART     __SYSREG(0xa9001594, u16)
-#define ASB2364_FPGA_REG_MASK_I2C      __SYSREG(0xa9001598, u16)
-#define ASB2364_FPGA_REG_MASK_USB      __SYSREG(0xa900159c, u16)
-#define ASB2364_FPGA_REG_MASK_FPGA     __SYSREG(0xa90015a4, u16)
+#define ASB2364_FPGA_REG_IRQ(X)                __SYSREG(0xa9001590+((X)*4), u16)
+#define ASB2364_FPGA_REG_IRQ_LAN       ASB2364_FPGA_REG_IRQ(0)
+#define ASB2364_FPGA_REG_IRQ_UART      ASB2364_FPGA_REG_IRQ(1)
+#define ASB2364_FPGA_REG_IRQ_I2C       ASB2364_FPGA_REG_IRQ(2)
+#define ASB2364_FPGA_REG_IRQ_USB       ASB2364_FPGA_REG_IRQ(3)
+#define ASB2364_FPGA_REG_IRQ_FPGA      ASB2364_FPGA_REG_IRQ(5)
+
+#define ASB2364_FPGA_REG_MASK(X)       __SYSREG(0xa9001590+((X)*4), u16)
+#define ASB2364_FPGA_REG_MASK_LAN      ASB2364_FPGA_REG_MASK(0)
+#define ASB2364_FPGA_REG_MASK_UART     ASB2364_FPGA_REG_MASK(1)
+#define ASB2364_FPGA_REG_MASK_I2C      ASB2364_FPGA_REG_MASK(2)
+#define ASB2364_FPGA_REG_MASK_USB      ASB2364_FPGA_REG_MASK(3)
+#define ASB2364_FPGA_REG_MASK_FPGA     ASB2364_FPGA_REG_MASK(5)
 
 #define ASB2364_FPGA_REG_CPLD5_SET1    __SYSREG(0xa9002500, u16)
 #define ASB2364_FPGA_REG_CPLD5_SET2    __SYSREG(0xa9002504, u16)
diff --git a/arch/mn10300/unit-asb2364/include/unit/irq.h b/arch/mn10300/unit-asb2364/include/unit/irq.h
new file mode 100644 (file)
index 0000000..786148e
--- /dev/null
@@ -0,0 +1,35 @@
+/* ASB2364 FPGA irq numbers
+ *
+ * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+#ifndef _UNIT_IRQ_H
+#define _UNIT_IRQ_H
+
+#ifndef __ASSEMBLY__
+
+#ifdef CONFIG_SMP
+#define NR_CPU_IRQS    GxICR_NUM_EXT_IRQS
+#else
+#define NR_CPU_IRQS    GxICR_NUM_IRQS
+#endif
+
+enum {
+       FPGA_LAN_IRQ    = NR_CPU_IRQS,
+       FPGA_UART_IRQ,
+       FPGA_I2C_IRQ,
+       FPGA_USB_IRQ,
+       FPGA_RESERVED_IRQ,
+       FPGA_FPGA_IRQ,
+       NR_IRQS
+};
+
+extern void __init irq_fpga_init(void);
+
+#endif /* !__ASSEMBLY__ */
+#endif /* _UNIT_IRQ_H */
diff --git a/arch/mn10300/unit-asb2364/irq-fpga.c b/arch/mn10300/unit-asb2364/irq-fpga.c
new file mode 100644 (file)
index 0000000..fcf2975
--- /dev/null
@@ -0,0 +1,96 @@
+/* ASB2364 FPGA interrupt multiplexing
+ *
+ * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <unit/fpga-regs.h>
+
+/*
+ * FPGA PIC operations
+ */
+static void asb2364_fpga_mask(unsigned int irq)
+{
+       ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0001;
+       SyncExBus();
+}
+
+static void asb2364_fpga_ack(unsigned int irq)
+{
+       ASB2364_FPGA_REG_IRQ(irq - NR_CPU_IRQS) = 0x0001;
+       SyncExBus();
+}
+
+static void asb2364_fpga_mask_ack(unsigned int irq)
+{
+       ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0001;
+       SyncExBus();
+       ASB2364_FPGA_REG_IRQ(irq - NR_CPU_IRQS) = 0x0001;
+       SyncExBus();
+}
+
+static void asb2364_fpga_unmask(unsigned int irq)
+{
+       ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0000;
+       SyncExBus();
+}
+
+static struct irq_chip asb2364_fpga_pic = {
+       .name           = "fpga",
+       .ack            = asb2364_fpga_ack,
+       .mask           = asb2364_fpga_mask,
+       .mask_ack       = asb2364_fpga_mask_ack,
+       .unmask         = asb2364_fpga_unmask,
+};
+
+/*
+ * FPGA PIC interrupt handler
+ */
+static irqreturn_t fpga_interrupt(int irq, void *_mask)
+{
+       if ((ASB2364_FPGA_REG_IRQ_LAN  & 0x0001) != 0x0001)
+               generic_handle_irq(FPGA_LAN_IRQ);
+       if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) != 0x0001)
+               generic_handle_irq(FPGA_UART_IRQ);
+       if ((ASB2364_FPGA_REG_IRQ_I2C  & 0x0001) != 0x0001)
+               generic_handle_irq(FPGA_I2C_IRQ);
+       if ((ASB2364_FPGA_REG_IRQ_USB  & 0x0001) != 0x0001)
+               generic_handle_irq(FPGA_USB_IRQ);
+       if ((ASB2364_FPGA_REG_IRQ_FPGA & 0x0001) != 0x0001)
+               generic_handle_irq(FPGA_FPGA_IRQ);
+
+       return IRQ_HANDLED;
+}
+
+/*
+ * Define an interrupt action for each FPGA PIC output
+ */
+static struct irqaction fpga_irq[]  = {
+       [0] = {
+               .handler        = fpga_interrupt,
+               .flags          = IRQF_DISABLED | IRQF_SHARED,
+               .name           = "fpga",
+       },
+};
+
+/*
+ * Initialise the FPGA's PIC
+ */
+void __init irq_fpga_init(void)
+{
+       int irq;
+
+       for (irq = NR_CPU_IRQS; irq < NR_IRQS; irq++)
+               set_irq_chip_and_handler(irq, &asb2364_fpga_pic, handle_level_irq);
+
+       /* the FPGA drives the XIRQ1 input on the CPU PIC */
+       setup_irq(XIRQ1, &fpga_irq[0]);
+}
index a3fc09b43f8429058a112b8cb2dfcb35a7fdf5e3..11440803db10f97a8adfdb320541850939f7535e 100644 (file)
@@ -20,6 +20,7 @@
 #include <asm/processor.h>
 #include <asm/irq.h>
 #include <asm/intctl-regs.h>
+#include <unit/fpga-regs.h>
 
 /*
  * initialise some of the unit hardware before gdbstub is set up
@@ -82,4 +83,6 @@ void __init unit_init_IRQ(void)
 
 #define IRQCTL __SYSREG(0xd5000090, u32)
        IRQCTL |= 0x02;
+
+       irq_fpga_init();
 }