Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Sergei Shtylyov | 0167509 | 2008-03-24 23:15:50 +0300 | [diff] [blame] | 2 | * Copyright 2001, 2007-2008 MontaVista Software Inc. |
| 3 | * Author: MontaVista Software, Inc. <source@mvista.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Ralf Baechle | f3e8d1d | 2007-10-17 10:58:43 +0100 | [diff] [blame] | 5 | * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) |
| 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2 of the License, or (at your |
| 10 | * option) any later version. |
| 11 | * |
| 12 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 13 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
| 15 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 16 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 17 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 18 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 19 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 20 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 21 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License along |
| 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 25 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 26 | */ |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/bitops.h> |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 29 | #include <linux/init.h> |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 30 | #include <linux/interrupt.h> |
| 31 | #include <linux/irq.h> |
Manuel Lauss | 0f0d85b | 2010-04-13 20:49:14 +0200 | [diff] [blame] | 32 | #include <linux/slab.h> |
| 33 | #include <linux/sysdev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Ralf Baechle | f3e8d1d | 2007-10-17 10:58:43 +0100 | [diff] [blame] | 35 | #include <asm/irq_cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <asm/mipsregs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <asm/mach-au1x00/au1000.h> |
| 38 | #ifdef CONFIG_MIPS_PB1000 |
| 39 | #include <asm/mach-pb1x00/pb1000.h> |
| 40 | #endif |
| 41 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 42 | /* Interrupt Controller register offsets */ |
| 43 | #define IC_CFG0RD 0x40 |
| 44 | #define IC_CFG0SET 0x40 |
| 45 | #define IC_CFG0CLR 0x44 |
| 46 | #define IC_CFG1RD 0x48 |
| 47 | #define IC_CFG1SET 0x48 |
| 48 | #define IC_CFG1CLR 0x4C |
| 49 | #define IC_CFG2RD 0x50 |
| 50 | #define IC_CFG2SET 0x50 |
| 51 | #define IC_CFG2CLR 0x54 |
| 52 | #define IC_REQ0INT 0x54 |
| 53 | #define IC_SRCRD 0x58 |
| 54 | #define IC_SRCSET 0x58 |
| 55 | #define IC_SRCCLR 0x5C |
| 56 | #define IC_REQ1INT 0x5C |
| 57 | #define IC_ASSIGNRD 0x60 |
| 58 | #define IC_ASSIGNSET 0x60 |
| 59 | #define IC_ASSIGNCLR 0x64 |
| 60 | #define IC_WAKERD 0x68 |
| 61 | #define IC_WAKESET 0x68 |
| 62 | #define IC_WAKECLR 0x6C |
| 63 | #define IC_MASKRD 0x70 |
| 64 | #define IC_MASKSET 0x70 |
| 65 | #define IC_MASKCLR 0x74 |
| 66 | #define IC_RISINGRD 0x78 |
| 67 | #define IC_RISINGCLR 0x78 |
| 68 | #define IC_FALLINGRD 0x7C |
| 69 | #define IC_FALLINGCLR 0x7C |
| 70 | #define IC_TESTBIT 0x80 |
| 71 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 72 | static int au1x_ic_settype(struct irq_data *d, unsigned int flow_type); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 73 | |
Manuel Lauss | 5047201 | 2009-10-07 20:15:12 +0200 | [diff] [blame] | 74 | /* NOTE on interrupt priorities: The original writers of this code said: |
| 75 | * |
| 76 | * Because of the tight timing of SETUP token to reply transactions, |
| 77 | * the USB devices-side packet complete interrupt (USB_DEV_REQ_INT) |
| 78 | * needs the highest priority. |
| 79 | */ |
| 80 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 81 | /* per-processor fixed function irqs */ |
Manuel Lauss | 7e50b2b | 2009-10-04 14:55:26 +0200 | [diff] [blame] | 82 | struct au1xxx_irqmap { |
| 83 | int im_irq; |
| 84 | int im_type; |
Manuel Lauss | 5047201 | 2009-10-07 20:15:12 +0200 | [diff] [blame] | 85 | int im_request; /* set 1 to get higher priority */ |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | struct au1xxx_irqmap au1000_irqmap[] __initdata = { |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 89 | { AU1000_UART0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 90 | { AU1000_UART1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 91 | { AU1000_UART2_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 92 | { AU1000_UART3_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 93 | { AU1000_SSI0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 94 | { AU1000_SSI1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 95 | { AU1000_DMA_INT_BASE, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 96 | { AU1000_DMA_INT_BASE+1, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 97 | { AU1000_DMA_INT_BASE+2, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 98 | { AU1000_DMA_INT_BASE+3, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 99 | { AU1000_DMA_INT_BASE+4, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 100 | { AU1000_DMA_INT_BASE+5, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 101 | { AU1000_DMA_INT_BASE+6, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 102 | { AU1000_DMA_INT_BASE+7, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 103 | { AU1000_TOY_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 104 | { AU1000_TOY_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 105 | { AU1000_TOY_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 106 | { AU1000_TOY_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 107 | { AU1000_RTC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 108 | { AU1000_RTC_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 109 | { AU1000_RTC_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 110 | { AU1000_RTC_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 1 }, |
| 111 | { AU1000_IRDA_TX_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 112 | { AU1000_IRDA_RX_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 113 | { AU1000_USB_DEV_REQ_INT, IRQ_TYPE_LEVEL_HIGH, 1 }, |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 114 | { AU1000_USB_DEV_SUS_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 115 | { AU1000_USB_HOST_INT, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 116 | { AU1000_ACSYNC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 117 | { AU1000_MAC0_DMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 118 | { AU1000_MAC1_DMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 119 | { AU1000_AC97C_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 120 | { -1, }, |
| 121 | }; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 122 | |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 123 | struct au1xxx_irqmap au1500_irqmap[] __initdata = { |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 124 | { AU1500_UART0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 125 | { AU1500_PCI_INTA, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 126 | { AU1500_PCI_INTB, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 127 | { AU1500_UART3_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 128 | { AU1500_PCI_INTC, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 129 | { AU1500_PCI_INTD, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 130 | { AU1500_DMA_INT_BASE, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 131 | { AU1500_DMA_INT_BASE+1, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 132 | { AU1500_DMA_INT_BASE+2, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 133 | { AU1500_DMA_INT_BASE+3, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 134 | { AU1500_DMA_INT_BASE+4, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 135 | { AU1500_DMA_INT_BASE+5, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 136 | { AU1500_DMA_INT_BASE+6, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 137 | { AU1500_DMA_INT_BASE+7, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 138 | { AU1500_TOY_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 139 | { AU1500_TOY_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 140 | { AU1500_TOY_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 141 | { AU1500_TOY_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 142 | { AU1500_RTC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 143 | { AU1500_RTC_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 144 | { AU1500_RTC_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 145 | { AU1500_RTC_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 1 }, |
| 146 | { AU1500_USB_DEV_REQ_INT, IRQ_TYPE_LEVEL_HIGH, 1 }, |
| 147 | { AU1500_USB_DEV_SUS_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 148 | { AU1500_USB_HOST_INT, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 149 | { AU1500_ACSYNC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 150 | { AU1500_MAC0_DMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 151 | { AU1500_MAC1_DMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 152 | { AU1500_AC97C_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 153 | { -1, }, |
| 154 | }; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 155 | |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 156 | struct au1xxx_irqmap au1100_irqmap[] __initdata = { |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 157 | { AU1100_UART0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 158 | { AU1100_UART1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 159 | { AU1100_SD_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 160 | { AU1100_UART3_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 161 | { AU1100_SSI0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 162 | { AU1100_SSI1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 163 | { AU1100_DMA_INT_BASE, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 164 | { AU1100_DMA_INT_BASE+1, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 165 | { AU1100_DMA_INT_BASE+2, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 166 | { AU1100_DMA_INT_BASE+3, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 167 | { AU1100_DMA_INT_BASE+4, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 168 | { AU1100_DMA_INT_BASE+5, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 169 | { AU1100_DMA_INT_BASE+6, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 170 | { AU1100_DMA_INT_BASE+7, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 171 | { AU1100_TOY_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 172 | { AU1100_TOY_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 173 | { AU1100_TOY_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 174 | { AU1100_TOY_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 175 | { AU1100_RTC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 176 | { AU1100_RTC_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 177 | { AU1100_RTC_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 178 | { AU1100_RTC_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 1 }, |
| 179 | { AU1100_IRDA_TX_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 180 | { AU1100_IRDA_RX_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 181 | { AU1100_USB_DEV_REQ_INT, IRQ_TYPE_LEVEL_HIGH, 1 }, |
| 182 | { AU1100_USB_DEV_SUS_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 183 | { AU1100_USB_HOST_INT, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 184 | { AU1100_ACSYNC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 185 | { AU1100_MAC0_DMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 186 | { AU1100_LCD_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 187 | { AU1100_AC97C_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 188 | { -1, }, |
| 189 | }; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 190 | |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 191 | struct au1xxx_irqmap au1550_irqmap[] __initdata = { |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 192 | { AU1550_UART0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 193 | { AU1550_PCI_INTA, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 194 | { AU1550_PCI_INTB, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 195 | { AU1550_DDMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 196 | { AU1550_CRYPTO_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 197 | { AU1550_PCI_INTC, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 198 | { AU1550_PCI_INTD, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 199 | { AU1550_PCI_RST_INT, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 200 | { AU1550_UART1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 201 | { AU1550_UART3_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 202 | { AU1550_PSC0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 203 | { AU1550_PSC1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 204 | { AU1550_PSC2_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 205 | { AU1550_PSC3_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 206 | { AU1550_TOY_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 207 | { AU1550_TOY_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 208 | { AU1550_TOY_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 209 | { AU1550_TOY_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 210 | { AU1550_RTC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 211 | { AU1550_RTC_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 212 | { AU1550_RTC_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 213 | { AU1550_RTC_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 1 }, |
| 214 | { AU1550_NAND_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 215 | { AU1550_USB_DEV_REQ_INT, IRQ_TYPE_LEVEL_HIGH, 1 }, |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 216 | { AU1550_USB_DEV_SUS_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 217 | { AU1550_USB_HOST_INT, IRQ_TYPE_LEVEL_LOW, 0 }, |
| 218 | { AU1550_MAC0_DMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 219 | { AU1550_MAC1_DMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 220 | { -1, }, |
| 221 | }; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 222 | |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 223 | struct au1xxx_irqmap au1200_irqmap[] __initdata = { |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 224 | { AU1200_UART0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 225 | { AU1200_SWT_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 226 | { AU1200_SD_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 227 | { AU1200_DDMA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 228 | { AU1200_MAE_BE_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 229 | { AU1200_UART1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 230 | { AU1200_MAE_FE_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 231 | { AU1200_PSC0_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 232 | { AU1200_PSC1_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 233 | { AU1200_AES_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 234 | { AU1200_CAMERA_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 235 | { AU1200_TOY_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 236 | { AU1200_TOY_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 237 | { AU1200_TOY_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 238 | { AU1200_TOY_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 239 | { AU1200_RTC_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 240 | { AU1200_RTC_MATCH0_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 241 | { AU1200_RTC_MATCH1_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 242 | { AU1200_RTC_MATCH2_INT, IRQ_TYPE_EDGE_RISING, 1 }, |
| 243 | { AU1200_NAND_INT, IRQ_TYPE_EDGE_RISING, 0 }, |
| 244 | { AU1200_USB_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 245 | { AU1200_LCD_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
| 246 | { AU1200_MAE_BOTH_INT, IRQ_TYPE_LEVEL_HIGH, 0 }, |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 247 | { -1, }, |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 251 | static void au1x_ic0_unmask(struct irq_data *d) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 252 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 253 | unsigned int bit = d->irq - AU1000_INTC0_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 254 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR); |
| 255 | |
| 256 | __raw_writel(1 << bit, base + IC_MASKSET); |
| 257 | __raw_writel(1 << bit, base + IC_WAKESET); |
| 258 | wmb(); |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 259 | } |
| 260 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 261 | static void au1x_ic1_unmask(struct irq_data *d) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 262 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 263 | unsigned int bit = d->irq - AU1000_INTC1_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 264 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR); |
| 265 | |
| 266 | __raw_writel(1 << bit, base + IC_MASKSET); |
| 267 | __raw_writel(1 << bit, base + IC_WAKESET); |
Ralf Baechle | f3e8d1d | 2007-10-17 10:58:43 +0100 | [diff] [blame] | 268 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 269 | /* very hacky. does the pb1000 cpld auto-disable this int? |
| 270 | * nowhere in the current kernel sources is it disabled. --mlau |
| 271 | */ |
| 272 | #if defined(CONFIG_MIPS_PB1000) |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 273 | if (d->irq == AU1000_GPIO15_INT) |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 274 | __raw_writel(0x4000, (void __iomem *)PB1000_MDR); /* enable int */ |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 275 | #endif |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 276 | wmb(); |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 277 | } |
| 278 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 279 | static void au1x_ic0_mask(struct irq_data *d) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 280 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 281 | unsigned int bit = d->irq - AU1000_INTC0_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 282 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR); |
| 283 | |
| 284 | __raw_writel(1 << bit, base + IC_MASKCLR); |
| 285 | __raw_writel(1 << bit, base + IC_WAKECLR); |
| 286 | wmb(); |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 287 | } |
| 288 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 289 | static void au1x_ic1_mask(struct irq_data *d) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 290 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 291 | unsigned int bit = d->irq - AU1000_INTC1_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 292 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR); |
| 293 | |
| 294 | __raw_writel(1 << bit, base + IC_MASKCLR); |
| 295 | __raw_writel(1 << bit, base + IC_WAKECLR); |
| 296 | wmb(); |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 297 | } |
| 298 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 299 | static void au1x_ic0_ack(struct irq_data *d) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 300 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 301 | unsigned int bit = d->irq - AU1000_INTC0_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 302 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR); |
Ralf Baechle | f3e8d1d | 2007-10-17 10:58:43 +0100 | [diff] [blame] | 303 | |
| 304 | /* |
| 305 | * This may assume that we don't get interrupts from |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 306 | * both edges at once, or if we do, that we don't care. |
| 307 | */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 308 | __raw_writel(1 << bit, base + IC_FALLINGCLR); |
| 309 | __raw_writel(1 << bit, base + IC_RISINGCLR); |
| 310 | wmb(); |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 311 | } |
| 312 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 313 | static void au1x_ic1_ack(struct irq_data *d) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 314 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 315 | unsigned int bit = d->irq - AU1000_INTC1_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 316 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 317 | |
| 318 | /* |
| 319 | * This may assume that we don't get interrupts from |
| 320 | * both edges at once, or if we do, that we don't care. |
| 321 | */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 322 | __raw_writel(1 << bit, base + IC_FALLINGCLR); |
| 323 | __raw_writel(1 << bit, base + IC_RISINGCLR); |
| 324 | wmb(); |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 325 | } |
| 326 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 327 | static void au1x_ic0_maskack(struct irq_data *d) |
Manuel Lauss | 44f2c58 | 2009-10-14 12:22:20 +0200 | [diff] [blame] | 328 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 329 | unsigned int bit = d->irq - AU1000_INTC0_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 330 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR); |
Manuel Lauss | 44f2c58 | 2009-10-14 12:22:20 +0200 | [diff] [blame] | 331 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 332 | __raw_writel(1 << bit, base + IC_WAKECLR); |
| 333 | __raw_writel(1 << bit, base + IC_MASKCLR); |
| 334 | __raw_writel(1 << bit, base + IC_RISINGCLR); |
| 335 | __raw_writel(1 << bit, base + IC_FALLINGCLR); |
| 336 | wmb(); |
Manuel Lauss | 44f2c58 | 2009-10-14 12:22:20 +0200 | [diff] [blame] | 337 | } |
| 338 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 339 | static void au1x_ic1_maskack(struct irq_data *d) |
Manuel Lauss | 44f2c58 | 2009-10-14 12:22:20 +0200 | [diff] [blame] | 340 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 341 | unsigned int bit = d->irq - AU1000_INTC1_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 342 | void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR); |
Manuel Lauss | 44f2c58 | 2009-10-14 12:22:20 +0200 | [diff] [blame] | 343 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 344 | __raw_writel(1 << bit, base + IC_WAKECLR); |
| 345 | __raw_writel(1 << bit, base + IC_MASKCLR); |
| 346 | __raw_writel(1 << bit, base + IC_RISINGCLR); |
| 347 | __raw_writel(1 << bit, base + IC_FALLINGCLR); |
| 348 | wmb(); |
Manuel Lauss | 44f2c58 | 2009-10-14 12:22:20 +0200 | [diff] [blame] | 349 | } |
| 350 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 351 | static int au1x_ic1_setwake(struct irq_data *d, unsigned int on) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 352 | { |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 353 | int bit = d->irq - AU1000_INTC1_INT_BASE; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 354 | unsigned long wakemsk, flags; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 355 | |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 356 | /* only GPIO 0-7 can act as wakeup source. Fortunately these |
| 357 | * are wired up identically on all supported variants. |
| 358 | */ |
| 359 | if ((bit < 0) || (bit > 7)) |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 360 | return -EINVAL; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 361 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 362 | local_irq_save(flags); |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 363 | wakemsk = __raw_readl((void __iomem *)SYS_WAKEMSK); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 364 | if (on) |
| 365 | wakemsk |= 1 << bit; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 366 | else |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 367 | wakemsk &= ~(1 << bit); |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 368 | __raw_writel(wakemsk, (void __iomem *)SYS_WAKEMSK); |
| 369 | wmb(); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 370 | local_irq_restore(flags); |
| 371 | |
| 372 | return 0; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | /* |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 376 | * irq_chips for both ICs; this way the mask handlers can be |
| 377 | * as short as possible. |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 378 | */ |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 379 | static struct irq_chip au1x_ic0_chip = { |
| 380 | .name = "Alchemy-IC0", |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 381 | .irq_ack = au1x_ic0_ack, |
| 382 | .irq_mask = au1x_ic0_mask, |
| 383 | .irq_mask_ack = au1x_ic0_maskack, |
| 384 | .irq_unmask = au1x_ic0_unmask, |
| 385 | .irq_set_type = au1x_ic_settype, |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 386 | }; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 387 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 388 | static struct irq_chip au1x_ic1_chip = { |
| 389 | .name = "Alchemy-IC1", |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 390 | .irq_ack = au1x_ic1_ack, |
| 391 | .irq_mask = au1x_ic1_mask, |
| 392 | .irq_mask_ack = au1x_ic1_maskack, |
| 393 | .irq_unmask = au1x_ic1_unmask, |
| 394 | .irq_set_type = au1x_ic_settype, |
| 395 | .irq_set_wake = au1x_ic1_setwake, |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 396 | }; |
| 397 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 398 | static int au1x_ic_settype(struct irq_data *d, unsigned int flow_type) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 399 | { |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 400 | struct irq_chip *chip; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 401 | unsigned int bit, irq = d->irq; |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 402 | irq_flow_handler_t handler = NULL; |
| 403 | unsigned char *name = NULL; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 404 | void __iomem *base; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 405 | int ret; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 406 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 407 | if (irq >= AU1000_INTC1_INT_BASE) { |
| 408 | bit = irq - AU1000_INTC1_INT_BASE; |
| 409 | chip = &au1x_ic1_chip; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 410 | base = (void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 411 | } else { |
| 412 | bit = irq - AU1000_INTC0_INT_BASE; |
| 413 | chip = &au1x_ic0_chip; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 414 | base = (void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 415 | } |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 416 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 417 | if (bit > 31) |
| 418 | return -EINVAL; |
| 419 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 420 | ret = 0; |
| 421 | |
| 422 | switch (flow_type) { /* cfgregs 2:1:0 */ |
| 423 | case IRQ_TYPE_EDGE_RISING: /* 0:0:1 */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 424 | __raw_writel(1 << bit, base + IC_CFG2CLR); |
| 425 | __raw_writel(1 << bit, base + IC_CFG1CLR); |
| 426 | __raw_writel(1 << bit, base + IC_CFG0SET); |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 427 | handler = handle_edge_irq; |
| 428 | name = "riseedge"; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 429 | break; |
| 430 | case IRQ_TYPE_EDGE_FALLING: /* 0:1:0 */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 431 | __raw_writel(1 << bit, base + IC_CFG2CLR); |
| 432 | __raw_writel(1 << bit, base + IC_CFG1SET); |
| 433 | __raw_writel(1 << bit, base + IC_CFG0CLR); |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 434 | handler = handle_edge_irq; |
| 435 | name = "falledge"; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 436 | break; |
| 437 | case IRQ_TYPE_EDGE_BOTH: /* 0:1:1 */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 438 | __raw_writel(1 << bit, base + IC_CFG2CLR); |
| 439 | __raw_writel(1 << bit, base + IC_CFG1SET); |
| 440 | __raw_writel(1 << bit, base + IC_CFG0SET); |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 441 | handler = handle_edge_irq; |
| 442 | name = "bothedge"; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 443 | break; |
| 444 | case IRQ_TYPE_LEVEL_HIGH: /* 1:0:1 */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 445 | __raw_writel(1 << bit, base + IC_CFG2SET); |
| 446 | __raw_writel(1 << bit, base + IC_CFG1CLR); |
| 447 | __raw_writel(1 << bit, base + IC_CFG0SET); |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 448 | handler = handle_level_irq; |
| 449 | name = "hilevel"; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 450 | break; |
| 451 | case IRQ_TYPE_LEVEL_LOW: /* 1:1:0 */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 452 | __raw_writel(1 << bit, base + IC_CFG2SET); |
| 453 | __raw_writel(1 << bit, base + IC_CFG1SET); |
| 454 | __raw_writel(1 << bit, base + IC_CFG0CLR); |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 455 | handler = handle_level_irq; |
| 456 | name = "lowlevel"; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 457 | break; |
| 458 | case IRQ_TYPE_NONE: /* 0:0:0 */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 459 | __raw_writel(1 << bit, base + IC_CFG2CLR); |
| 460 | __raw_writel(1 << bit, base + IC_CFG1CLR); |
| 461 | __raw_writel(1 << bit, base + IC_CFG0CLR); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 462 | break; |
| 463 | default: |
| 464 | ret = -EINVAL; |
| 465 | } |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 466 | __irq_set_chip_handler_name_locked(d->irq, chip, handler, name); |
| 467 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 468 | wmb(); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 469 | |
| 470 | return ret; |
| 471 | } |
| 472 | |
| 473 | asmlinkage void plat_irq_dispatch(void) |
| 474 | { |
| 475 | unsigned int pending = read_c0_status() & read_c0_cause(); |
Manuel Lauss | 5047201 | 2009-10-07 20:15:12 +0200 | [diff] [blame] | 476 | unsigned long s, off; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 477 | |
| 478 | if (pending & CAUSEF_IP7) { |
Manuel Lauss | f1fc664 | 2009-10-13 20:26:31 +0200 | [diff] [blame] | 479 | off = MIPS_CPU_IRQ_BASE + 7; |
| 480 | goto handle; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 481 | } else if (pending & CAUSEF_IP2) { |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 482 | s = KSEG1ADDR(AU1000_IC0_PHYS_ADDR) + IC_REQ0INT; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 483 | off = AU1000_INTC0_INT_BASE; |
| 484 | } else if (pending & CAUSEF_IP3) { |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 485 | s = KSEG1ADDR(AU1000_IC0_PHYS_ADDR) + IC_REQ1INT; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 486 | off = AU1000_INTC0_INT_BASE; |
| 487 | } else if (pending & CAUSEF_IP4) { |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 488 | s = KSEG1ADDR(AU1000_IC1_PHYS_ADDR) + IC_REQ0INT; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 489 | off = AU1000_INTC1_INT_BASE; |
| 490 | } else if (pending & CAUSEF_IP5) { |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 491 | s = KSEG1ADDR(AU1000_IC1_PHYS_ADDR) + IC_REQ1INT; |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 492 | off = AU1000_INTC1_INT_BASE; |
| 493 | } else |
| 494 | goto spurious; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 495 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 496 | s = __raw_readl((void __iomem *)s); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 497 | if (unlikely(!s)) { |
| 498 | spurious: |
| 499 | spurious_interrupt(); |
| 500 | return; |
| 501 | } |
Manuel Lauss | f1fc664 | 2009-10-13 20:26:31 +0200 | [diff] [blame] | 502 | off += __ffs(s); |
| 503 | handle: |
| 504 | do_IRQ(off); |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 505 | } |
| 506 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 507 | |
| 508 | static inline void ic_init(void __iomem *base) |
| 509 | { |
| 510 | /* initialize interrupt controller to a safe state */ |
| 511 | __raw_writel(0xffffffff, base + IC_CFG0CLR); |
| 512 | __raw_writel(0xffffffff, base + IC_CFG1CLR); |
| 513 | __raw_writel(0xffffffff, base + IC_CFG2CLR); |
| 514 | __raw_writel(0xffffffff, base + IC_MASKCLR); |
| 515 | __raw_writel(0xffffffff, base + IC_ASSIGNCLR); |
| 516 | __raw_writel(0xffffffff, base + IC_WAKECLR); |
| 517 | __raw_writel(0xffffffff, base + IC_SRCSET); |
| 518 | __raw_writel(0xffffffff, base + IC_FALLINGCLR); |
| 519 | __raw_writel(0xffffffff, base + IC_RISINGCLR); |
| 520 | __raw_writel(0x00000000, base + IC_TESTBIT); |
| 521 | wmb(); |
| 522 | } |
| 523 | |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 524 | static void __init au1000_init_irq(struct au1xxx_irqmap *map) |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 525 | { |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 526 | unsigned int bit, irq_nr; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 527 | void __iomem *base; |
Ralf Baechle | 41bd61a | 2007-10-15 00:51:34 +0100 | [diff] [blame] | 528 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 529 | ic_init((void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR)); |
| 530 | ic_init((void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR)); |
Ralf Baechle | f3e8d1d | 2007-10-17 10:58:43 +0100 | [diff] [blame] | 531 | mips_cpu_irq_init(); |
| 532 | |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 533 | /* register all 64 possible IC0+IC1 irq sources as type "none". |
| 534 | * Use set_irq_type() to set edge/level behaviour at runtime. |
| 535 | */ |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 536 | for (irq_nr = AU1000_INTC0_INT_BASE; |
| 537 | (irq_nr < AU1000_INTC0_INT_BASE + 32); irq_nr++) |
| 538 | au1x_ic_settype(irq_get_irq_data(irq_nr), IRQ_TYPE_NONE); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 539 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 540 | for (irq_nr = AU1000_INTC1_INT_BASE; |
| 541 | (irq_nr < AU1000_INTC1_INT_BASE + 32); irq_nr++) |
| 542 | au1x_ic_settype(irq_get_irq_data(irq_nr), IRQ_TYPE_NONE); |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 543 | |
Ralf Baechle | f3e8d1d | 2007-10-17 10:58:43 +0100 | [diff] [blame] | 544 | /* |
| 545 | * Initialize IC0, which is fixed per processor. |
| 546 | */ |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 547 | while (map->im_irq != -1) { |
| 548 | irq_nr = map->im_irq; |
| 549 | |
| 550 | if (irq_nr >= AU1000_INTC1_INT_BASE) { |
| 551 | bit = irq_nr - AU1000_INTC1_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 552 | base = (void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR); |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 553 | } else { |
| 554 | bit = irq_nr - AU1000_INTC0_INT_BASE; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 555 | base = (void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR); |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 556 | } |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 557 | if (map->im_request) |
| 558 | __raw_writel(1 << bit, base + IC_ASSIGNSET); |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 559 | |
Thomas Gleixner | d24c1a2 | 2011-03-23 21:08:44 +0000 | [diff] [blame] | 560 | au1x_ic_settype(irq_get_irq_data(irq_nr), map->im_type); |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 561 | ++map; |
| 562 | } |
Manuel Lauss | 785e326 | 2008-12-21 09:26:17 +0100 | [diff] [blame] | 563 | |
| 564 | set_c0_status(IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3); |
| 565 | } |
Manuel Lauss | ef6c1fd6 | 2009-11-23 20:40:02 +0100 | [diff] [blame] | 566 | |
| 567 | void __init arch_init_irq(void) |
| 568 | { |
| 569 | switch (alchemy_get_cputype()) { |
| 570 | case ALCHEMY_CPU_AU1000: |
| 571 | au1000_init_irq(au1000_irqmap); |
| 572 | break; |
| 573 | case ALCHEMY_CPU_AU1500: |
| 574 | au1000_init_irq(au1500_irqmap); |
| 575 | break; |
| 576 | case ALCHEMY_CPU_AU1100: |
| 577 | au1000_init_irq(au1100_irqmap); |
| 578 | break; |
| 579 | case ALCHEMY_CPU_AU1550: |
| 580 | au1000_init_irq(au1550_irqmap); |
| 581 | break; |
| 582 | case ALCHEMY_CPU_AU1200: |
| 583 | au1000_init_irq(au1200_irqmap); |
| 584 | break; |
| 585 | } |
| 586 | } |
Manuel Lauss | 0f0d85b | 2010-04-13 20:49:14 +0200 | [diff] [blame] | 587 | |
| 588 | struct alchemy_ic_sysdev { |
| 589 | struct sys_device sysdev; |
| 590 | void __iomem *base; |
| 591 | unsigned long pmdata[7]; |
| 592 | }; |
| 593 | |
| 594 | static int alchemy_ic_suspend(struct sys_device *dev, pm_message_t state) |
| 595 | { |
| 596 | struct alchemy_ic_sysdev *icdev = |
| 597 | container_of(dev, struct alchemy_ic_sysdev, sysdev); |
| 598 | |
| 599 | icdev->pmdata[0] = __raw_readl(icdev->base + IC_CFG0RD); |
| 600 | icdev->pmdata[1] = __raw_readl(icdev->base + IC_CFG1RD); |
| 601 | icdev->pmdata[2] = __raw_readl(icdev->base + IC_CFG2RD); |
| 602 | icdev->pmdata[3] = __raw_readl(icdev->base + IC_SRCRD); |
| 603 | icdev->pmdata[4] = __raw_readl(icdev->base + IC_ASSIGNRD); |
| 604 | icdev->pmdata[5] = __raw_readl(icdev->base + IC_WAKERD); |
| 605 | icdev->pmdata[6] = __raw_readl(icdev->base + IC_MASKRD); |
| 606 | |
| 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | static int alchemy_ic_resume(struct sys_device *dev) |
| 611 | { |
| 612 | struct alchemy_ic_sysdev *icdev = |
| 613 | container_of(dev, struct alchemy_ic_sysdev, sysdev); |
| 614 | |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 615 | ic_init(icdev->base); |
| 616 | |
Manuel Lauss | 0f0d85b | 2010-04-13 20:49:14 +0200 | [diff] [blame] | 617 | __raw_writel(icdev->pmdata[0], icdev->base + IC_CFG0SET); |
| 618 | __raw_writel(icdev->pmdata[1], icdev->base + IC_CFG1SET); |
| 619 | __raw_writel(icdev->pmdata[2], icdev->base + IC_CFG2SET); |
| 620 | __raw_writel(icdev->pmdata[3], icdev->base + IC_SRCSET); |
| 621 | __raw_writel(icdev->pmdata[4], icdev->base + IC_ASSIGNSET); |
| 622 | __raw_writel(icdev->pmdata[5], icdev->base + IC_WAKESET); |
| 623 | wmb(); |
| 624 | |
| 625 | __raw_writel(icdev->pmdata[6], icdev->base + IC_MASKSET); |
| 626 | wmb(); |
| 627 | |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | static struct sysdev_class alchemy_ic_sysdev_class = { |
| 632 | .name = "ic", |
| 633 | .suspend = alchemy_ic_suspend, |
| 634 | .resume = alchemy_ic_resume, |
| 635 | }; |
| 636 | |
| 637 | static int __init alchemy_ic_sysdev_init(void) |
| 638 | { |
| 639 | struct alchemy_ic_sysdev *icdev; |
Manuel Lauss | dca7587 | 2011-05-08 10:42:14 +0200 | [diff] [blame^] | 640 | unsigned long icbase[2] = { AU1000_IC0_PHYS_ADDR, AU1000_IC1_PHYS_ADDR }; |
Manuel Lauss | 0f0d85b | 2010-04-13 20:49:14 +0200 | [diff] [blame] | 641 | int err, i; |
| 642 | |
| 643 | err = sysdev_class_register(&alchemy_ic_sysdev_class); |
| 644 | if (err) |
| 645 | return err; |
| 646 | |
| 647 | for (i = 0; i < 2; i++) { |
| 648 | icdev = kzalloc(sizeof(struct alchemy_ic_sysdev), GFP_KERNEL); |
| 649 | if (!icdev) |
| 650 | return -ENOMEM; |
| 651 | |
| 652 | icdev->base = ioremap(icbase[i], 0x1000); |
| 653 | |
| 654 | icdev->sysdev.id = i; |
| 655 | icdev->sysdev.cls = &alchemy_ic_sysdev_class; |
| 656 | err = sysdev_register(&icdev->sysdev); |
| 657 | if (err) { |
| 658 | kfree(icdev); |
| 659 | return err; |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | return 0; |
| 664 | } |
| 665 | device_initcall(alchemy_ic_sysdev_init); |