Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* irq.c: FRV IRQ handling |
| 2 | * |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 3 | * Copyright (C) 2003, 2004, 2006 Red Hat, Inc. All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/ptrace.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/signal.h> |
| 15 | #include <linux/sched.h> |
| 16 | #include <linux/ioport.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/timex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/random.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/init.h> |
| 21 | #include <linux/kernel_stat.h> |
| 22 | #include <linux/irq.h> |
| 23 | #include <linux/proc_fs.h> |
| 24 | #include <linux/seq_file.h> |
David Howells | 4023440 | 2006-01-08 01:01:19 -0800 | [diff] [blame] | 25 | #include <linux/module.h> |
Jiri Slaby | 1977f03 | 2007-10-18 23:40:25 -0700 | [diff] [blame] | 26 | #include <linux/bitops.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame^] | 28 | #include <linux/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <asm/io.h> |
| 30 | #include <asm/smp.h> |
| 31 | #include <asm/system.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/uaccess.h> |
| 33 | #include <asm/pgalloc.h> |
| 34 | #include <asm/delay.h> |
| 35 | #include <asm/irq.h> |
| 36 | #include <asm/irc-regs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <asm/gdb-stub.h> |
| 38 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 39 | #define set_IRR(N,A,B,C,D) __set_IRR(N, (A << 28) | (B << 24) | (C << 20) | (D << 16)) |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | extern void __init fpga_init(void); |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 42 | #ifdef CONFIG_FUJITSU_MB93493 |
| 43 | extern void __init mb93493_init(void); |
| 44 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 46 | #define __reg16(ADDR) (*(volatile unsigned short *)(ADDR)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | atomic_t irq_err_count; |
| 49 | |
Thomas Gleixner | a120017 | 2011-03-24 18:48:36 +0100 | [diff] [blame] | 50 | int arch_show_interrupts(struct seq_file *p, int prec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
Thomas Gleixner | a120017 | 2011-03-24 18:48:36 +0100 | [diff] [blame] | 52 | seq_printf(p, "%*s: ", prec, "ERR"); |
| 53 | seq_printf(p, "%10u\n", atomic_read(&irq_err_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | return 0; |
| 55 | } |
| 56 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | /* |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 58 | * on-CPU PIC operations |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | */ |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 60 | static void frv_cpupic_ack(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | { |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 62 | __clr_RC(d->irq); |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 63 | __clr_IRL(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 66 | static void frv_cpupic_mask(struct irq_data *d) |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 67 | { |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 68 | __set_MASK(d->irq); |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 69 | } |
David Howells | 4023440 | 2006-01-08 01:01:19 -0800 | [diff] [blame] | 70 | |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 71 | static void frv_cpupic_mask_ack(struct irq_data *d) |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 72 | { |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 73 | __set_MASK(d->irq); |
| 74 | __clr_RC(d->irq); |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 75 | __clr_IRL(); |
| 76 | } |
| 77 | |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 78 | static void frv_cpupic_unmask(struct irq_data *d) |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 79 | { |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 80 | __clr_MASK(d->irq); |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 81 | } |
| 82 | |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 83 | static struct irq_chip frv_cpu_pic = { |
| 84 | .name = "cpu", |
Thomas Gleixner | 380e311 | 2011-02-06 20:20:38 +0100 | [diff] [blame] | 85 | .irq_ack = frv_cpupic_ack, |
| 86 | .irq_mask = frv_cpupic_mask, |
| 87 | .irq_mask_ack = frv_cpupic_mask_ack, |
| 88 | .irq_unmask = frv_cpupic_unmask, |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | /* |
Simon Arlott | 761a7e3 | 2007-10-20 01:09:42 +0200 | [diff] [blame] | 92 | * handles all normal device IRQs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | * - registers are referred to by the __frame variable (GR28) |
| 94 | * - IRQ distribution is complicated in this arch because of the many PICs, the |
| 95 | * way they work and the way they cascade |
| 96 | */ |
| 97 | asmlinkage void do_IRQ(void) |
| 98 | { |
David Howells | 28baeba | 2006-02-14 13:53:20 -0800 | [diff] [blame] | 99 | irq_enter(); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 100 | generic_handle_irq(__get_IRL()); |
David Howells | 28baeba | 2006-02-14 13:53:20 -0800 | [diff] [blame] | 101 | irq_exit(); |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 102 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | /* |
| 105 | * handles all NMIs when not co-opted by the debugger |
| 106 | * - registers are referred to by the __frame variable (GR28) |
| 107 | */ |
| 108 | asmlinkage void do_NMI(void) |
| 109 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | /* |
| 113 | * initialise the interrupt system |
| 114 | */ |
| 115 | void __init init_IRQ(void) |
| 116 | { |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 117 | int level; |
| 118 | |
| 119 | for (level = 1; level <= 14; level++) |
Thomas Gleixner | de2e95a | 2011-03-24 16:38:49 +0100 | [diff] [blame] | 120 | irq_set_chip_and_handler(level, &frv_cpu_pic, |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 121 | handle_level_irq); |
| 122 | |
Thomas Gleixner | de2e95a | 2011-03-24 16:38:49 +0100 | [diff] [blame] | 123 | irq_set_handler(IRQ_CPU_TIMER0, handle_edge_irq); |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 124 | |
| 125 | /* set the trigger levels for internal interrupt sources |
| 126 | * - timers all falling-edge |
| 127 | * - ERR0 is rising-edge |
| 128 | * - all others are high-level |
| 129 | */ |
| 130 | __set_IITMR(0, 0x003f0000); /* DMA0-3, TIMER0-2 */ |
| 131 | __set_IITMR(1, 0x20000000); /* ERR0-1, UART0-1, DMA4-7 */ |
| 132 | |
| 133 | /* route internal interrupts */ |
| 134 | set_IRR(4, IRQ_DMA3_LEVEL, IRQ_DMA2_LEVEL, IRQ_DMA1_LEVEL, |
| 135 | IRQ_DMA0_LEVEL); |
| 136 | set_IRR(5, 0, IRQ_TIMER2_LEVEL, IRQ_TIMER1_LEVEL, IRQ_TIMER0_LEVEL); |
| 137 | set_IRR(6, IRQ_GDBSTUB_LEVEL, IRQ_GDBSTUB_LEVEL, |
| 138 | IRQ_UART1_LEVEL, IRQ_UART0_LEVEL); |
| 139 | set_IRR(7, IRQ_DMA7_LEVEL, IRQ_DMA6_LEVEL, IRQ_DMA5_LEVEL, |
| 140 | IRQ_DMA4_LEVEL); |
| 141 | |
| 142 | /* route external interrupts */ |
| 143 | set_IRR(2, IRQ_XIRQ7_LEVEL, IRQ_XIRQ6_LEVEL, IRQ_XIRQ5_LEVEL, |
| 144 | IRQ_XIRQ4_LEVEL); |
| 145 | set_IRR(3, IRQ_XIRQ3_LEVEL, IRQ_XIRQ2_LEVEL, IRQ_XIRQ1_LEVEL, |
| 146 | IRQ_XIRQ0_LEVEL); |
| 147 | |
| 148 | #if defined(CONFIG_MB93091_VDK) |
| 149 | __set_TM1(0x55550000); /* XIRQ7-0 all active low */ |
| 150 | #elif defined(CONFIG_MB93093_PDK) |
| 151 | __set_TM1(0x15550000); /* XIRQ7 active high, 6-0 all active low */ |
| 152 | #else |
| 153 | #error dont know external IRQ trigger levels for this setup |
| 154 | #endif |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | fpga_init(); |
| 157 | #ifdef CONFIG_FUJITSU_MB93493 |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 158 | mb93493_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | #endif |
David Howells | 1bcbba3 | 2006-09-25 23:32:04 -0700 | [diff] [blame] | 160 | } |