Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 1 | /* |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 2 | * Toshiba RBTX4938 specific interrupt handlers |
| 3 | * Copyright (C) 2000-2001 Toshiba Corporation |
| 4 | * |
| 5 | * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the |
| 6 | * terms of the GNU General Public License version 2. This program is |
| 7 | * licensed "as is" without any warranty of any kind, whether express |
| 8 | * or implied. |
| 9 | * |
| 10 | * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) |
| 11 | */ |
| 12 | |
| 13 | /* |
Atsushi Nemoto | bb72f1f | 2008-07-24 00:25:21 +0900 | [diff] [blame] | 14 | * MIPS_CPU_IRQ_BASE+00 Software 0 |
| 15 | * MIPS_CPU_IRQ_BASE+01 Software 1 |
| 16 | * MIPS_CPU_IRQ_BASE+02 Cascade TX4938-CP0 |
| 17 | * MIPS_CPU_IRQ_BASE+03 Multiplexed -- do not use |
| 18 | * MIPS_CPU_IRQ_BASE+04 Multiplexed -- do not use |
| 19 | * MIPS_CPU_IRQ_BASE+05 Multiplexed -- do not use |
| 20 | * MIPS_CPU_IRQ_BASE+06 Multiplexed -- do not use |
| 21 | * MIPS_CPU_IRQ_BASE+07 CPU TIMER |
| 22 | * |
| 23 | * TXX9_IRQ_BASE+00 |
| 24 | * TXX9_IRQ_BASE+01 |
| 25 | * TXX9_IRQ_BASE+02 Cascade RBTX4938-IOC |
| 26 | * TXX9_IRQ_BASE+03 RBTX4938 RTL-8019AS Ethernet |
| 27 | * TXX9_IRQ_BASE+04 |
| 28 | * TXX9_IRQ_BASE+05 TX4938 ETH1 |
| 29 | * TXX9_IRQ_BASE+06 TX4938 ETH0 |
| 30 | * TXX9_IRQ_BASE+07 |
| 31 | * TXX9_IRQ_BASE+08 TX4938 SIO 0 |
| 32 | * TXX9_IRQ_BASE+09 TX4938 SIO 1 |
| 33 | * TXX9_IRQ_BASE+10 TX4938 DMA0 |
| 34 | * TXX9_IRQ_BASE+11 TX4938 DMA1 |
| 35 | * TXX9_IRQ_BASE+12 TX4938 DMA2 |
| 36 | * TXX9_IRQ_BASE+13 TX4938 DMA3 |
| 37 | * TXX9_IRQ_BASE+14 |
| 38 | * TXX9_IRQ_BASE+15 |
| 39 | * TXX9_IRQ_BASE+16 TX4938 PCIC |
| 40 | * TXX9_IRQ_BASE+17 TX4938 TMR0 |
| 41 | * TXX9_IRQ_BASE+18 TX4938 TMR1 |
| 42 | * TXX9_IRQ_BASE+19 TX4938 TMR2 |
| 43 | * TXX9_IRQ_BASE+20 |
| 44 | * TXX9_IRQ_BASE+21 |
| 45 | * TXX9_IRQ_BASE+22 TX4938 PCIERR |
| 46 | * TXX9_IRQ_BASE+23 |
| 47 | * TXX9_IRQ_BASE+24 |
| 48 | * TXX9_IRQ_BASE+25 |
| 49 | * TXX9_IRQ_BASE+26 |
| 50 | * TXX9_IRQ_BASE+27 |
| 51 | * TXX9_IRQ_BASE+28 |
| 52 | * TXX9_IRQ_BASE+29 |
| 53 | * TXX9_IRQ_BASE+30 |
| 54 | * TXX9_IRQ_BASE+31 TX4938 SPI |
| 55 | * |
| 56 | * RBTX4938_IRQ_IOC+00 PCI-D |
| 57 | * RBTX4938_IRQ_IOC+01 PCI-C |
| 58 | * RBTX4938_IRQ_IOC+02 PCI-B |
| 59 | * RBTX4938_IRQ_IOC+03 PCI-A |
| 60 | * RBTX4938_IRQ_IOC+04 RTC |
| 61 | * RBTX4938_IRQ_IOC+05 ATA |
| 62 | * RBTX4938_IRQ_IOC+06 MODEM |
| 63 | * RBTX4938_IRQ_IOC+07 SWINT |
| 64 | */ |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 65 | #include <linux/init.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 66 | #include <linux/interrupt.h> |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 67 | #include <asm/mipsregs.h> |
| 68 | #include <asm/txx9/generic.h> |
Atsushi Nemoto | 22b1d70 | 2008-07-11 00:31:36 +0900 | [diff] [blame] | 69 | #include <asm/txx9/rbtx4938.h> |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 70 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 71 | static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq); |
| 72 | static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 73 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 74 | #define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC" |
Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 75 | static struct irq_chip toshiba_rbtx4938_irq_ioc_type = { |
Atsushi Nemoto | 70d21cd | 2007-01-15 00:07:25 +0900 | [diff] [blame] | 76 | .name = TOSHIBA_RBTX4938_IOC_NAME, |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 77 | .ack = toshiba_rbtx4938_irq_ioc_disable, |
| 78 | .mask = toshiba_rbtx4938_irq_ioc_disable, |
| 79 | .mask_ack = toshiba_rbtx4938_irq_ioc_disable, |
| 80 | .unmask = toshiba_rbtx4938_irq_ioc_enable, |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 83 | static int toshiba_rbtx4938_irq_nested(int sw_irq) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 84 | { |
| 85 | u8 level3; |
| 86 | |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 87 | level3 = readb(rbtx4938_imstat_addr); |
Atsushi Nemoto | 21e77df | 2008-09-01 22:22:37 +0900 | [diff] [blame] | 88 | if (unlikely(!level3)) |
| 89 | return -1; |
| 90 | /* must use fls so onboard ATA has priority */ |
| 91 | return RBTX4938_IRQ_IOC + __fls8(level3); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 94 | static void __init |
| 95 | toshiba_rbtx4938_irq_ioc_init(void) |
| 96 | { |
| 97 | int i; |
| 98 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 99 | for (i = RBTX4938_IRQ_IOC; |
| 100 | i < RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC; i++) |
Atsushi Nemoto | 1417836 | 2006-11-14 01:13:18 +0900 | [diff] [blame] | 101 | set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type, |
| 102 | handle_level_irq); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 103 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 104 | set_irq_chained_handler(RBTX4938_IRQ_IOCINT, handle_simple_irq); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 107 | static void |
| 108 | toshiba_rbtx4938_irq_ioc_enable(unsigned int irq) |
| 109 | { |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 110 | unsigned char v; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 111 | |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 112 | v = readb(rbtx4938_imask_addr); |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 113 | v |= (1 << (irq - RBTX4938_IRQ_IOC)); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 114 | writeb(v, rbtx4938_imask_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 115 | mmiowb(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | static void |
| 119 | toshiba_rbtx4938_irq_ioc_disable(unsigned int irq) |
| 120 | { |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 121 | unsigned char v; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 122 | |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 123 | v = readb(rbtx4938_imask_addr); |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 124 | v &= ~(1 << (irq - RBTX4938_IRQ_IOC)); |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 125 | writeb(v, rbtx4938_imask_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 126 | mmiowb(); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 129 | static int rbtx4938_irq_dispatch(int pending) |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 130 | { |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 131 | int irq; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 132 | |
Atsushi Nemoto | edcaf1a | 2008-07-11 23:27:54 +0900 | [diff] [blame] | 133 | if (pending & STATUSF_IP7) |
| 134 | irq = MIPS_CPU_IRQ_BASE + 7; |
| 135 | else if (pending & STATUSF_IP2) { |
| 136 | irq = txx9_irq(); |
| 137 | if (irq == RBTX4938_IRQ_IOCINT) |
| 138 | irq = toshiba_rbtx4938_irq_nested(irq); |
| 139 | } else if (pending & STATUSF_IP1) |
| 140 | irq = MIPS_CPU_IRQ_BASE + 0; |
| 141 | else if (pending & STATUSF_IP0) |
| 142 | irq = MIPS_CPU_IRQ_BASE + 1; |
| 143 | else |
| 144 | irq = -1; |
| 145 | return irq; |
| 146 | } |
| 147 | |
| 148 | void __init rbtx4938_irq_setup(void) |
| 149 | { |
| 150 | txx9_irq_dispatch = rbtx4938_irq_dispatch; |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 151 | /* Now, interrupt control disabled, */ |
| 152 | /* all IRC interrupts are masked, */ |
| 153 | /* all IRC interrupt mode are Low Active. */ |
| 154 | |
| 155 | /* mask all IOC interrupts */ |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 156 | writeb(0, rbtx4938_imask_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 157 | |
| 158 | /* clear SoftInt interrupts */ |
Atsushi Nemoto | 66140c8 | 2008-04-14 21:49:07 +0900 | [diff] [blame] | 159 | writeb(0, rbtx4938_softint_addr); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 160 | tx4938_irq_init(); |
| 161 | toshiba_rbtx4938_irq_ioc_init(); |
| 162 | /* Onboard 10M Ether: High Active */ |
Atsushi Nemoto | c87abd7 | 2007-08-02 23:36:02 +0900 | [diff] [blame] | 163 | set_irq_type(RBTX4938_IRQ_ETHER, IRQF_TRIGGER_HIGH); |
Ralf Baechle | 23fbee9 | 2005-07-25 22:45:45 +0000 | [diff] [blame] | 164 | } |