diff options
| author | David Howells <dhowells@redhat.com> | 2010-10-27 12:28:58 -0400 |
|---|---|---|
| committer | David Howells <dhowells@redhat.com> | 2010-10-27 12:28:58 -0400 |
| commit | 6044cf1d9426dfd5cdc1e7b9cf8eaed6418e1ff6 (patch) | |
| tree | 3f6f209d37328ce1635df8f5d0b5df1cef1afe30 | |
| parent | 730c1fad0ee22a170d2ee76a904709ee304931c0 (diff) | |
MN10300: ASB2364: Handle the IRQ multiplexer in the FPGA
Handle the IRQ multiplexer in the FPGA by implementing a cascade interrupt
driver for it.
Signed-off-by: David Howells <dhowells@redhat.com>
| -rw-r--r-- | arch/mn10300/include/asm/irq.h | 12 | ||||
| -rw-r--r-- | arch/mn10300/kernel/irq.c | 13 | ||||
| -rw-r--r-- | arch/mn10300/unit-asb2364/Makefile | 2 | ||||
| -rw-r--r-- | arch/mn10300/unit-asb2364/include/unit/fpga-regs.h | 24 | ||||
| -rw-r--r-- | arch/mn10300/unit-asb2364/include/unit/irq.h | 35 | ||||
| -rw-r--r-- | arch/mn10300/unit-asb2364/irq-fpga.c | 96 | ||||
| -rw-r--r-- | arch/mn10300/unit-asb2364/unit-init.c | 3 |
7 files changed, 166 insertions, 19 deletions
diff --git a/arch/mn10300/include/asm/irq.h b/arch/mn10300/include/asm/irq.h index b7b8e175b167..1a73fb3f60c6 100644 --- a/arch/mn10300/include/asm/irq.h +++ b/arch/mn10300/include/asm/irq.h | |||
| @@ -21,11 +21,15 @@ | |||
| 21 | /* this number is used when no interrupt has been assigned */ | 21 | /* this number is used when no interrupt has been assigned */ |
| 22 | #define NO_IRQ INT_MAX | 22 | #define NO_IRQ INT_MAX |
| 23 | 23 | ||
| 24 | /* hardware irq numbers */ | 24 | /* |
| 25 | #ifdef CONFIG_SMP | 25 | * hardware irq numbers |
| 26 | #define NR_IRQS GxICR_NUM_EXT_IRQS | 26 | * - the ASB2364 has an FPGA with an IRQ multiplexer on it |
| 27 | */ | ||
| 28 | #ifdef CONFIG_MN10300_UNIT_ASB2364 | ||
| 29 | #include <unit/irq.h> | ||
| 27 | #else | 30 | #else |
| 28 | #define NR_IRQS GxICR_NUM_IRQS | 31 | #define NR_CPU_IRQS GxICR_NUM_IRQS |
| 32 | #define NR_IRQS NR_CPU_IRQS | ||
| 29 | #endif | 33 | #endif |
| 30 | 34 | ||
| 31 | /* external hardware irq numbers */ | 35 | /* external hardware irq numbers */ |
diff --git a/arch/mn10300/kernel/irq.c b/arch/mn10300/kernel/irq.c index 2f66a45dcd18..c2e44597c22b 100644 --- a/arch/mn10300/kernel/irq.c +++ b/arch/mn10300/kernel/irq.c | |||
| @@ -381,9 +381,16 @@ int show_interrupts(struct seq_file *p, void *v) | |||
| 381 | seq_printf(p, "%3d: ", i); | 381 | seq_printf(p, "%3d: ", i); |
| 382 | for_each_present_cpu(cpu) | 382 | for_each_present_cpu(cpu) |
| 383 | seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu)); | 383 | seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu)); |
| 384 | seq_printf(p, " %14s.%u", irq_desc[i].chip->name, | 384 | |
| 385 | (GxICR(i) & GxICR_LEVEL) >> | 385 | if (i < NR_CPU_IRQS) |
| 386 | GxICR_LEVEL_SHIFT); | 386 | seq_printf(p, " %14s.%u", |
| 387 | irq_desc[i].chip->name, | ||
| 388 | (GxICR(i) & GxICR_LEVEL) >> | ||
| 389 | GxICR_LEVEL_SHIFT); | ||
| 390 | else | ||
| 391 | seq_printf(p, " %14s", | ||
| 392 | irq_desc[i].chip->name); | ||
| 393 | |||
| 387 | seq_printf(p, " %s", action->name); | 394 | seq_printf(p, " %s", action->name); |
| 388 | 395 | ||
| 389 | for (action = action->next; | 396 | for (action = action->next; |
diff --git a/arch/mn10300/unit-asb2364/Makefile b/arch/mn10300/unit-asb2364/Makefile index 6dd27d65877a..e9d9b90ef6da 100644 --- a/arch/mn10300/unit-asb2364/Makefile +++ b/arch/mn10300/unit-asb2364/Makefile | |||
| @@ -7,4 +7,4 @@ | |||
| 7 | # | 7 | # |
| 8 | # Note 2! The CFLAGS definitions are now in the main makefile... | 8 | # Note 2! The CFLAGS definitions are now in the main makefile... |
| 9 | 9 | ||
| 10 | obj-y := unit-init.o leds.o | 10 | obj-y := unit-init.o leds.o irq-fpga.o |
diff --git a/arch/mn10300/unit-asb2364/include/unit/fpga-regs.h b/arch/mn10300/unit-asb2364/include/unit/fpga-regs.h index a039a50c91db..7cf12054db65 100644 --- a/arch/mn10300/unit-asb2364/include/unit/fpga-regs.h +++ b/arch/mn10300/unit-asb2364/include/unit/fpga-regs.h | |||
| @@ -14,17 +14,19 @@ | |||
| 14 | #define ASB2364_FPGA_REG_RESET_USB __SYSREG(0xa900130c, u16) | 14 | #define ASB2364_FPGA_REG_RESET_USB __SYSREG(0xa900130c, u16) |
| 15 | #define ASB2364_FPGA_REG_RESET_AV __SYSREG(0xa9001310, u16) | 15 | #define ASB2364_FPGA_REG_RESET_AV __SYSREG(0xa9001310, u16) |
| 16 | 16 | ||
| 17 | #define ASB2364_FPGA_REG_IRQ_LAN __SYSREG(0xa9001510, u16) | 17 | #define ASB2364_FPGA_REG_IRQ(X) __SYSREG(0xa9001590+((X)*4), u16) |
| 18 | #define ASB2364_FPGA_REG_IRQ_UART __SYSREG(0xa9001514, u16) | 18 | #define ASB2364_FPGA_REG_IRQ_LAN ASB2364_FPGA_REG_IRQ(0) |
| 19 | #define ASB2364_FPGA_REG_IRQ_I2C __SYSREG(0xa9001518, u16) | 19 | #define ASB2364_FPGA_REG_IRQ_UART ASB2364_FPGA_REG_IRQ(1) |
| 20 | #define ASB2364_FPGA_REG_IRQ_USB __SYSREG(0xa900151c, u16) | 20 | #define ASB2364_FPGA_REG_IRQ_I2C ASB2364_FPGA_REG_IRQ(2) |
| 21 | #define ASB2364_FPGA_REG_IRQ_FPGA __SYSREG(0xa9001524, u16) | 21 | #define ASB2364_FPGA_REG_IRQ_USB ASB2364_FPGA_REG_IRQ(3) |
| 22 | 22 | #define ASB2364_FPGA_REG_IRQ_FPGA ASB2364_FPGA_REG_IRQ(5) | |
| 23 | #define ASB2364_FPGA_REG_MASK_LAN __SYSREG(0xa9001590, u16) | 23 | |
| 24 | #define ASB2364_FPGA_REG_MASK_UART __SYSREG(0xa9001594, u16) | 24 | #define ASB2364_FPGA_REG_MASK(X) __SYSREG(0xa9001590+((X)*4), u16) |
| 25 | #define ASB2364_FPGA_REG_MASK_I2C __SYSREG(0xa9001598, u16) | 25 | #define ASB2364_FPGA_REG_MASK_LAN ASB2364_FPGA_REG_MASK(0) |
| 26 | #define ASB2364_FPGA_REG_MASK_USB __SYSREG(0xa900159c, u16) | 26 | #define ASB2364_FPGA_REG_MASK_UART ASB2364_FPGA_REG_MASK(1) |
| 27 | #define ASB2364_FPGA_REG_MASK_FPGA __SYSREG(0xa90015a4, u16) | 27 | #define ASB2364_FPGA_REG_MASK_I2C ASB2364_FPGA_REG_MASK(2) |
| 28 | #define ASB2364_FPGA_REG_MASK_USB ASB2364_FPGA_REG_MASK(3) | ||
| 29 | #define ASB2364_FPGA_REG_MASK_FPGA ASB2364_FPGA_REG_MASK(5) | ||
| 28 | 30 | ||
| 29 | #define ASB2364_FPGA_REG_CPLD5_SET1 __SYSREG(0xa9002500, u16) | 31 | #define ASB2364_FPGA_REG_CPLD5_SET1 __SYSREG(0xa9002500, u16) |
| 30 | #define ASB2364_FPGA_REG_CPLD5_SET2 __SYSREG(0xa9002504, u16) | 32 | #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 index 000000000000..786148e46565 --- /dev/null +++ b/arch/mn10300/unit-asb2364/include/unit/irq.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /* ASB2364 FPGA irq numbers | ||
| 2 | * | ||
| 3 | * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved. | ||
| 4 | * Written by David Howells (dhowells@redhat.com) | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public Licence | ||
| 8 | * as published by the Free Software Foundation; either version | ||
| 9 | * 2 of the Licence, or (at your option) any later version. | ||
| 10 | */ | ||
| 11 | #ifndef _UNIT_IRQ_H | ||
| 12 | #define _UNIT_IRQ_H | ||
| 13 | |||
| 14 | #ifndef __ASSEMBLY__ | ||
| 15 | |||
| 16 | #ifdef CONFIG_SMP | ||
| 17 | #define NR_CPU_IRQS GxICR_NUM_EXT_IRQS | ||
| 18 | #else | ||
| 19 | #define NR_CPU_IRQS GxICR_NUM_IRQS | ||
| 20 | #endif | ||
| 21 | |||
| 22 | enum { | ||
| 23 | FPGA_LAN_IRQ = NR_CPU_IRQS, | ||
| 24 | FPGA_UART_IRQ, | ||
| 25 | FPGA_I2C_IRQ, | ||
| 26 | FPGA_USB_IRQ, | ||
| 27 | FPGA_RESERVED_IRQ, | ||
| 28 | FPGA_FPGA_IRQ, | ||
| 29 | NR_IRQS | ||
| 30 | }; | ||
| 31 | |||
| 32 | extern void __init irq_fpga_init(void); | ||
| 33 | |||
| 34 | #endif /* !__ASSEMBLY__ */ | ||
| 35 | #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 index 000000000000..fcf29754e4d1 --- /dev/null +++ b/arch/mn10300/unit-asb2364/irq-fpga.c | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | /* ASB2364 FPGA interrupt multiplexing | ||
| 2 | * | ||
| 3 | * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved. | ||
| 4 | * Written by David Howells (dhowells@redhat.com) | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public Licence | ||
| 8 | * as published by the Free Software Foundation; either version | ||
| 9 | * 2 of the Licence, or (at your option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/interrupt.h> | ||
| 13 | #include <linux/init.h> | ||
| 14 | #include <linux/irq.h> | ||
| 15 | #include <unit/fpga-regs.h> | ||
| 16 | |||
| 17 | /* | ||
| 18 | * FPGA PIC operations | ||
| 19 | */ | ||
| 20 | static void asb2364_fpga_mask(unsigned int irq) | ||
| 21 | { | ||
| 22 | ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0001; | ||
| 23 | SyncExBus(); | ||
| 24 | } | ||
| 25 | |||
| 26 | static void asb2364_fpga_ack(unsigned int irq) | ||
| 27 | { | ||
| 28 | ASB2364_FPGA_REG_IRQ(irq - NR_CPU_IRQS) = 0x0001; | ||
| 29 | SyncExBus(); | ||
| 30 | } | ||
| 31 | |||
| 32 | static void asb2364_fpga_mask_ack(unsigned int irq) | ||
| 33 | { | ||
| 34 | ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0001; | ||
| 35 | SyncExBus(); | ||
| 36 | ASB2364_FPGA_REG_IRQ(irq - NR_CPU_IRQS) = 0x0001; | ||
| 37 | SyncExBus(); | ||
| 38 | } | ||
| 39 | |||
| 40 | static void asb2364_fpga_unmask(unsigned int irq) | ||
| 41 | { | ||
| 42 | ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0000; | ||
| 43 | SyncExBus(); | ||
| 44 | } | ||
| 45 | |||
| 46 | static struct irq_chip asb2364_fpga_pic = { | ||
| 47 | .name = "fpga", | ||
| 48 | .ack = asb2364_fpga_ack, | ||
| 49 | .mask = asb2364_fpga_mask, | ||
| 50 | .mask_ack = asb2364_fpga_mask_ack, | ||
| 51 | .unmask = asb2364_fpga_unmask, | ||
| 52 | }; | ||
| 53 | |||
| 54 | /* | ||
| 55 | * FPGA PIC interrupt handler | ||
| 56 | */ | ||
| 57 | static irqreturn_t fpga_interrupt(int irq, void *_mask) | ||
| 58 | { | ||
| 59 | if ((ASB2364_FPGA_REG_IRQ_LAN & 0x0001) != 0x0001) | ||
| 60 | generic_handle_irq(FPGA_LAN_IRQ); | ||
| 61 | if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) != 0x0001) | ||
| 62 | generic_handle_irq(FPGA_UART_IRQ); | ||
| 63 | if ((ASB2364_FPGA_REG_IRQ_I2C & 0x0001) != 0x0001) | ||
| 64 | generic_handle_irq(FPGA_I2C_IRQ); | ||
| 65 | if ((ASB2364_FPGA_REG_IRQ_USB & 0x0001) != 0x0001) | ||
| 66 | generic_handle_irq(FPGA_USB_IRQ); | ||
| 67 | if ((ASB2364_FPGA_REG_IRQ_FPGA & 0x0001) != 0x0001) | ||
| 68 | generic_handle_irq(FPGA_FPGA_IRQ); | ||
| 69 | |||
| 70 | return IRQ_HANDLED; | ||
| 71 | } | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Define an interrupt action for each FPGA PIC output | ||
| 75 | */ | ||
| 76 | static struct irqaction fpga_irq[] = { | ||
| 77 | [0] = { | ||
| 78 | .handler = fpga_interrupt, | ||
| 79 | .flags = IRQF_DISABLED | IRQF_SHARED, | ||
| 80 | .name = "fpga", | ||
| 81 | }, | ||
| 82 | }; | ||
| 83 | |||
| 84 | /* | ||
| 85 | * Initialise the FPGA's PIC | ||
| 86 | */ | ||
| 87 | void __init irq_fpga_init(void) | ||
| 88 | { | ||
| 89 | int irq; | ||
| 90 | |||
| 91 | for (irq = NR_CPU_IRQS; irq < NR_IRQS; irq++) | ||
| 92 | set_irq_chip_and_handler(irq, &asb2364_fpga_pic, handle_level_irq); | ||
| 93 | |||
| 94 | /* the FPGA drives the XIRQ1 input on the CPU PIC */ | ||
| 95 | setup_irq(XIRQ1, &fpga_irq[0]); | ||
| 96 | } | ||
diff --git a/arch/mn10300/unit-asb2364/unit-init.c b/arch/mn10300/unit-asb2364/unit-init.c index a3fc09b43f84..11440803db10 100644 --- a/arch/mn10300/unit-asb2364/unit-init.c +++ b/arch/mn10300/unit-asb2364/unit-init.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <asm/processor.h> | 20 | #include <asm/processor.h> |
| 21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
| 22 | #include <asm/intctl-regs.h> | 22 | #include <asm/intctl-regs.h> |
| 23 | #include <unit/fpga-regs.h> | ||
| 23 | 24 | ||
| 24 | /* | 25 | /* |
| 25 | * initialise some of the unit hardware before gdbstub is set up | 26 | * initialise some of the unit hardware before gdbstub is set up |
| @@ -82,4 +83,6 @@ void __init unit_init_IRQ(void) | |||
| 82 | 83 | ||
| 83 | #define IRQCTL __SYSREG(0xd5000090, u32) | 84 | #define IRQCTL __SYSREG(0xd5000090, u32) |
| 84 | IRQCTL |= 0x02; | 85 | IRQCTL |= 0x02; |
| 86 | |||
| 87 | irq_fpga_init(); | ||
| 85 | } | 88 | } |
