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