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 | f15cbe6 | 2008-07-29 08:09:44 +0900 | [diff] [blame] | 16 | #include <cpu/irq.h> |
Paul Mundt | 18bc813 | 2007-11-21 23:16:33 +0900 | [diff] [blame] | 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 | |
Paul Mundt | 815db14 | 2010-10-27 15:38:59 +0900 | [diff] [blame] | 58 | static void enable_cayman_irq(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | { |
Paul Mundt | 815db14 | 2010-10-27 15:38:59 +0900 | [diff] [blame] | 60 | unsigned int irq = data->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | unsigned long flags; |
| 62 | unsigned long mask; |
| 63 | unsigned int reg; |
| 64 | unsigned char bit; |
| 65 | |
| 66 | irq -= START_EXT_IRQS; |
| 67 | reg = EPLD_MASK_BASE + ((irq / 8) << 2); |
| 68 | bit = 1<<(irq % 8); |
| 69 | local_irq_save(flags); |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 70 | mask = __raw_readl(reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | mask |= bit; |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 72 | __raw_writel(mask, reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | local_irq_restore(flags); |
| 74 | } |
| 75 | |
Paul Mundt | 815db14 | 2010-10-27 15:38:59 +0900 | [diff] [blame] | 76 | static void disable_cayman_irq(struct irq_data *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { |
Paul Mundt | 815db14 | 2010-10-27 15:38:59 +0900 | [diff] [blame] | 78 | unsigned int irq = data->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | unsigned long flags; |
| 80 | unsigned long mask; |
| 81 | unsigned int reg; |
| 82 | unsigned char bit; |
| 83 | |
| 84 | irq -= START_EXT_IRQS; |
| 85 | reg = EPLD_MASK_BASE + ((irq / 8) << 2); |
| 86 | bit = 1<<(irq % 8); |
| 87 | local_irq_save(flags); |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 88 | mask = __raw_readl(reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | mask &= ~bit; |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 90 | __raw_writel(mask, reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | local_irq_restore(flags); |
| 92 | } |
| 93 | |
Matt Fleming | 1a94757 | 2008-12-14 12:02:27 +0000 | [diff] [blame] | 94 | struct irq_chip cayman_irq_type = { |
| 95 | .name = "Cayman-IRQ", |
Paul Mundt | 815db14 | 2010-10-27 15:38:59 +0900 | [diff] [blame] | 96 | .irq_unmask = enable_cayman_irq, |
| 97 | .irq_mask = disable_cayman_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | int cayman_irq_demux(int evt) |
| 101 | { |
| 102 | int irq = intc_evt_to_irq[evt]; |
| 103 | |
| 104 | if (irq == SMSC_IRQ) { |
| 105 | unsigned long status; |
| 106 | int i; |
| 107 | |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 108 | status = __raw_readl(EPLD_STATUS_BASE) & |
| 109 | __raw_readl(EPLD_MASK_BASE) & 0xff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | if (status == 0) { |
| 111 | irq = -1; |
| 112 | } else { |
| 113 | for (i=0; i<8; i++) { |
| 114 | if (status & (1<<i)) |
| 115 | break; |
| 116 | } |
| 117 | irq = START_EXT_IRQS + i; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | if (irq == PCI2_IRQ) { |
| 122 | unsigned long status; |
| 123 | int i; |
| 124 | |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 125 | status = __raw_readl(EPLD_STATUS_BASE + 3 * sizeof(u32)) & |
| 126 | __raw_readl(EPLD_MASK_BASE + 3 * sizeof(u32)) & 0xff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | if (status == 0) { |
| 128 | irq = -1; |
| 129 | } else { |
| 130 | for (i=0; i<8; i++) { |
| 131 | if (status & (1<<i)) |
| 132 | break; |
| 133 | } |
| 134 | irq = START_EXT_IRQS + (3 * 8) + i; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return irq; |
| 139 | } |
| 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | void init_cayman_irq(void) |
| 142 | { |
| 143 | int i; |
| 144 | |
Paul Mundt | 0fb849b | 2009-05-07 18:10:27 +0900 | [diff] [blame] | 145 | epld_virt = (unsigned long)ioremap_nocache(EPLD_BASE, 1024); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | if (!epld_virt) { |
| 147 | printk(KERN_ERR "Cayman IRQ: Unable to remap EPLD\n"); |
| 148 | return; |
| 149 | } |
| 150 | |
Matt Fleming | 1a94757 | 2008-12-14 12:02:27 +0000 | [diff] [blame] | 151 | for (i = 0; i < NR_EXT_IRQS; i++) { |
Thomas Gleixner | fcb8918 | 2011-03-24 16:31:17 +0100 | [diff] [blame] | 152 | irq_set_chip_and_handler(START_EXT_IRQS + i, |
| 153 | &cayman_irq_type, handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | /* Setup the SMSC interrupt */ |
| 157 | setup_irq(SMSC_IRQ, &cayman_action_smsc); |
| 158 | setup_irq(PCI2_IRQ, &cayman_action_pci2); |
| 159 | } |