Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 1992 Linus Torvalds |
| 7 | * Copyright (C) 1994 - 2001, 2003 Ralf Baechle |
| 8 | */ |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/interrupt.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/spinlock.h> |
| 13 | |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 14 | #include <asm/irq_cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/i8259.h> |
| 16 | #include <asm/io.h> |
| 17 | #include <asm/jazz.h> |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 18 | #include <asm/pgtable.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | static DEFINE_SPINLOCK(r4030_lock); |
| 21 | |
| 22 | static void enable_r4030_irq(unsigned int irq) |
| 23 | { |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 24 | unsigned int mask = 1 << (irq - JAZZ_IRQ_START); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | unsigned long flags; |
| 26 | |
| 27 | spin_lock_irqsave(&r4030_lock, flags); |
| 28 | mask |= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE); |
| 29 | r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask); |
| 30 | spin_unlock_irqrestore(&r4030_lock, flags); |
| 31 | } |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | void disable_r4030_irq(unsigned int irq) |
| 34 | { |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 35 | unsigned int mask = ~(1 << (irq - JAZZ_IRQ_START)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | unsigned long flags; |
| 37 | |
| 38 | spin_lock_irqsave(&r4030_lock, flags); |
| 39 | mask &= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE); |
| 40 | r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask); |
| 41 | spin_unlock_irqrestore(&r4030_lock, flags); |
| 42 | } |
| 43 | |
Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 44 | static struct irq_chip r4030_irq_type = { |
Atsushi Nemoto | 70d21cd | 2007-01-15 00:07:25 +0900 | [diff] [blame] | 45 | .name = "R4030", |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 46 | .ack = disable_r4030_irq, |
| 47 | .mask = disable_r4030_irq, |
| 48 | .mask_ack = disable_r4030_irq, |
| 49 | .unmask = enable_r4030_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | void __init init_r4030_ints(void) |
| 53 | { |
| 54 | int i; |
| 55 | |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 56 | for (i = JAZZ_IRQ_START; i <= JAZZ_IRQ_END; i++) |
Atsushi Nemoto | 1417836 | 2006-11-14 01:13:18 +0900 | [diff] [blame] | 57 | set_irq_chip_and_handler(i, &r4030_irq_type, handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0); |
| 60 | r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */ |
| 61 | r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */ |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | * On systems with i8259-style interrupt controllers we assume for |
| 66 | * driver compatibility reasons interrupts 0 - 15 to be the i8259 |
| 67 | * interrupts even if the hardware uses a different interrupt numbering. |
| 68 | */ |
| 69 | void __init arch_init_irq(void) |
| 70 | { |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 71 | /* |
| 72 | * this is a hack to get back the still needed wired mapping |
| 73 | * killed by init_mm() |
| 74 | */ |
| 75 | |
| 76 | /* Map 0xe0000000 -> 0x0:800005C0, 0xe0010000 -> 0x1:30000580 */ |
| 77 | add_wired_entry(0x02000017, 0x03c00017, 0xe0000000, PM_64K); |
| 78 | /* Map 0xe2000000 -> 0x0:900005C0, 0xe3010000 -> 0x0:910005C0 */ |
| 79 | add_wired_entry(0x02400017, 0x02440017, 0xe2000000, PM_16M); |
| 80 | /* Map 0xe4000000 -> 0x0:600005C0, 0xe4100000 -> 400005C0 */ |
| 81 | add_wired_entry(0x01800017, 0x01000017, 0xe4000000, PM_4M); |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | init_i8259_irqs(); /* Integrated i8259 */ |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 84 | mips_cpu_irq_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | init_r4030_ints(); |
| 86 | |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 87 | change_c0_status(ST0_IM, IE_IRQ2 | IE_IRQ1); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 88 | } |
| 89 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 90 | asmlinkage void plat_irq_dispatch(void) |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 91 | { |
Thiemo Seufer | 119537c | 2007-03-19 00:13:37 +0000 | [diff] [blame] | 92 | unsigned int pending = read_c0_cause() & read_c0_status(); |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 93 | unsigned int irq; |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 94 | |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 95 | if (pending & IE_IRQ4) { |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 96 | r4030_read_reg32(JAZZ_TIMER_REGISTER); |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 97 | do_IRQ(JAZZ_TIMER_IRQ); |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 98 | } else if (pending & IE_IRQ2) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 99 | do_IRQ(r4030_read_reg32(JAZZ_EISA_IRQ_ACK)); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 100 | else if (pending & IE_IRQ1) { |
Thomas Bogendoerfer | ea202c6 | 2007-08-25 11:01:50 +0200 | [diff] [blame^] | 101 | irq = *(volatile u8 *)JAZZ_IO_IRQ_SOURCE >> 2; |
| 102 | if (likely(irq > 0)) |
| 103 | do_IRQ(irq + JAZZ_IRQ_START - 1); |
| 104 | else |
| 105 | panic("Unimplemented loc_no_irq handler"); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 106 | } |
| 107 | } |