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