| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Paul Mundt | 18bc813 | 2007-11-21 23:16:33 +0900 | [diff] [blame] | 2 | * arch/sh/mach-cayman/irq.c - SH-5 Cayman Interrupt Support | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * | 
|  | 4 | * This file handles the board specific parts of the Cayman interrupt system | 
|  | 5 | * | 
|  | 6 | * Copyright (C) 2002 Stuart Menefy | 
| Paul Mundt | 18bc813 | 2007-11-21 23:16:33 +0900 | [diff] [blame] | 7 | * | 
|  | 8 | * This file is subject to the terms and conditions of the GNU General Public | 
|  | 9 | * License.  See the file "COPYING" in the main directory of this archive | 
|  | 10 | * for more details. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | */ | 
| Paul Mundt | 18bc813 | 2007-11-21 23:16:33 +0900 | [diff] [blame] | 12 | #include <linux/io.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/irq.h> | 
|  | 14 | #include <linux/interrupt.h> | 
|  | 15 | #include <linux/signal.h> | 
| Paul Mundt | 18bc813 | 2007-11-21 23:16:33 +0900 | [diff] [blame] | 16 | #include <asm/cpu/irq.h> | 
|  | 17 | #include <asm/page.h> | 
|  | 18 |  | 
|  | 19 | /* Setup for the SMSC FDC37C935 / LAN91C100FD */ | 
|  | 20 | #define SMSC_IRQ         IRQ_IRL1 | 
|  | 21 |  | 
|  | 22 | /* Setup for PCI Bus 2, which transmits interrupts via the EPLD */ | 
|  | 23 | #define PCI2_IRQ         IRQ_IRL3 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 |  | 
|  | 25 | unsigned long epld_virt; | 
|  | 26 |  | 
|  | 27 | #define EPLD_BASE        0x04002000 | 
|  | 28 | #define EPLD_STATUS_BASE (epld_virt + 0x10) | 
|  | 29 | #define EPLD_MASK_BASE   (epld_virt + 0x20) | 
|  | 30 |  | 
|  | 31 | /* Note the SMSC SuperIO chip and SMSC LAN chip interrupts are all muxed onto | 
|  | 32 | the same SH-5 interrupt */ | 
|  | 33 |  | 
| Paul Mundt | a226d33 | 2007-05-14 09:10:01 +0900 | [diff] [blame] | 34 | static irqreturn_t cayman_interrupt_smsc(int irq, void *dev_id) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { | 
|  | 36 | printk(KERN_INFO "CAYMAN: spurious SMSC interrupt\n"); | 
|  | 37 | return IRQ_NONE; | 
|  | 38 | } | 
|  | 39 |  | 
| Paul Mundt | a226d33 | 2007-05-14 09:10:01 +0900 | [diff] [blame] | 40 | static irqreturn_t cayman_interrupt_pci2(int irq, void *dev_id) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | { | 
|  | 42 | printk(KERN_INFO "CAYMAN: spurious PCI interrupt, IRQ %d\n", irq); | 
|  | 43 | return IRQ_NONE; | 
|  | 44 | } | 
|  | 45 |  | 
|  | 46 | static struct irqaction cayman_action_smsc = { | 
|  | 47 | .name		= "Cayman SMSC Mux", | 
|  | 48 | .handler	= cayman_interrupt_smsc, | 
| Thomas Gleixner | 5fb55ae | 2006-07-01 19:29:24 -0700 | [diff] [blame] | 49 | .flags		= IRQF_DISABLED, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; | 
|  | 51 |  | 
|  | 52 | static struct irqaction cayman_action_pci2 = { | 
|  | 53 | .name		= "Cayman PCI2 Mux", | 
|  | 54 | .handler	= cayman_interrupt_pci2, | 
| Thomas Gleixner | 5fb55ae | 2006-07-01 19:29:24 -0700 | [diff] [blame] | 55 | .flags		= IRQF_DISABLED, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | }; | 
|  | 57 |  | 
|  | 58 | static void enable_cayman_irq(unsigned int irq) | 
|  | 59 | { | 
|  | 60 | unsigned long flags; | 
|  | 61 | unsigned long mask; | 
|  | 62 | unsigned int reg; | 
|  | 63 | unsigned char bit; | 
|  | 64 |  | 
|  | 65 | irq -= START_EXT_IRQS; | 
|  | 66 | reg = EPLD_MASK_BASE + ((irq / 8) << 2); | 
|  | 67 | bit = 1<<(irq % 8); | 
|  | 68 | local_irq_save(flags); | 
|  | 69 | mask = ctrl_inl(reg); | 
|  | 70 | mask |= bit; | 
|  | 71 | ctrl_outl(mask, reg); | 
|  | 72 | local_irq_restore(flags); | 
|  | 73 | } | 
|  | 74 |  | 
|  | 75 | void disable_cayman_irq(unsigned int irq) | 
|  | 76 | { | 
|  | 77 | unsigned long flags; | 
|  | 78 | unsigned long mask; | 
|  | 79 | unsigned int reg; | 
|  | 80 | unsigned char bit; | 
|  | 81 |  | 
|  | 82 | irq -= START_EXT_IRQS; | 
|  | 83 | reg = EPLD_MASK_BASE + ((irq / 8) << 2); | 
|  | 84 | bit = 1<<(irq % 8); | 
|  | 85 | local_irq_save(flags); | 
|  | 86 | mask = ctrl_inl(reg); | 
|  | 87 | mask &= ~bit; | 
|  | 88 | ctrl_outl(mask, reg); | 
|  | 89 | local_irq_restore(flags); | 
|  | 90 | } | 
|  | 91 |  | 
|  | 92 | static void ack_cayman_irq(unsigned int irq) | 
|  | 93 | { | 
|  | 94 | disable_cayman_irq(irq); | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | static void end_cayman_irq(unsigned int irq) | 
|  | 98 | { | 
|  | 99 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) | 
|  | 100 | enable_cayman_irq(irq); | 
|  | 101 | } | 
|  | 102 |  | 
|  | 103 | static unsigned int startup_cayman_irq(unsigned int irq) | 
|  | 104 | { | 
|  | 105 | enable_cayman_irq(irq); | 
|  | 106 | return 0; /* never anything pending */ | 
|  | 107 | } | 
|  | 108 |  | 
|  | 109 | static void shutdown_cayman_irq(unsigned int irq) | 
|  | 110 | { | 
|  | 111 | disable_cayman_irq(irq); | 
|  | 112 | } | 
|  | 113 |  | 
|  | 114 | struct hw_interrupt_type cayman_irq_type = { | 
|  | 115 | .typename	= "Cayman-IRQ", | 
|  | 116 | .startup	= startup_cayman_irq, | 
|  | 117 | .shutdown	= shutdown_cayman_irq, | 
|  | 118 | .enable		= enable_cayman_irq, | 
|  | 119 | .disable	= disable_cayman_irq, | 
|  | 120 | .ack		= ack_cayman_irq, | 
|  | 121 | .end		= end_cayman_irq, | 
|  | 122 | }; | 
|  | 123 |  | 
|  | 124 | int cayman_irq_demux(int evt) | 
|  | 125 | { | 
|  | 126 | int irq = intc_evt_to_irq[evt]; | 
|  | 127 |  | 
|  | 128 | if (irq == SMSC_IRQ) { | 
|  | 129 | unsigned long status; | 
|  | 130 | int i; | 
|  | 131 |  | 
|  | 132 | status = ctrl_inl(EPLD_STATUS_BASE) & | 
|  | 133 | ctrl_inl(EPLD_MASK_BASE) & 0xff; | 
|  | 134 | if (status == 0) { | 
|  | 135 | irq = -1; | 
|  | 136 | } else { | 
|  | 137 | for (i=0; i<8; i++) { | 
|  | 138 | if (status & (1<<i)) | 
|  | 139 | break; | 
|  | 140 | } | 
|  | 141 | irq = START_EXT_IRQS + i; | 
|  | 142 | } | 
|  | 143 | } | 
|  | 144 |  | 
|  | 145 | if (irq == PCI2_IRQ) { | 
|  | 146 | unsigned long status; | 
|  | 147 | int i; | 
|  | 148 |  | 
|  | 149 | status = ctrl_inl(EPLD_STATUS_BASE + 3 * sizeof(u32)) & | 
|  | 150 | ctrl_inl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff; | 
|  | 151 | if (status == 0) { | 
|  | 152 | irq = -1; | 
|  | 153 | } else { | 
|  | 154 | for (i=0; i<8; i++) { | 
|  | 155 | if (status & (1<<i)) | 
|  | 156 | break; | 
|  | 157 | } | 
|  | 158 | irq = START_EXT_IRQS + (3 * 8) + i; | 
|  | 159 | } | 
|  | 160 | } | 
|  | 161 |  | 
|  | 162 | return irq; | 
|  | 163 | } | 
|  | 164 |  | 
|  | 165 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL) | 
|  | 166 | int cayman_irq_describe(char* p, int irq) | 
|  | 167 | { | 
|  | 168 | if (irq < NR_INTC_IRQS) { | 
|  | 169 | return intc_irq_describe(p, irq); | 
|  | 170 | } else if (irq < NR_INTC_IRQS + 8) { | 
|  | 171 | return sprintf(p, "(SMSC %d)", irq - NR_INTC_IRQS); | 
|  | 172 | } else if ((irq >= NR_INTC_IRQS + 24) && (irq < NR_INTC_IRQS + 32)) { | 
|  | 173 | return sprintf(p, "(PCI2 %d)", irq - (NR_INTC_IRQS + 24)); | 
|  | 174 | } | 
|  | 175 |  | 
|  | 176 | return 0; | 
|  | 177 | } | 
|  | 178 | #endif | 
|  | 179 |  | 
|  | 180 | void init_cayman_irq(void) | 
|  | 181 | { | 
|  | 182 | int i; | 
|  | 183 |  | 
|  | 184 | epld_virt = onchip_remap(EPLD_BASE, 1024, "EPLD"); | 
|  | 185 | if (!epld_virt) { | 
|  | 186 | printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n"); | 
|  | 187 | return; | 
|  | 188 | } | 
|  | 189 |  | 
|  | 190 | for (i=0; i<NR_EXT_IRQS; i++) { | 
| Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 191 | irq_desc[START_EXT_IRQS + i].chip = &cayman_irq_type; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | } | 
|  | 193 |  | 
|  | 194 | /* Setup the SMSC interrupt */ | 
|  | 195 | setup_irq(SMSC_IRQ, &cayman_action_smsc); | 
|  | 196 | setup_irq(PCI2_IRQ, &cayman_action_pci2); | 
|  | 197 | } |