Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/init.h> |
| 2 | #include <linux/list.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 3 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
| 5 | #include <asm/mach/irq.h> |
| 6 | #include <asm/hardware/iomd.h> |
| 7 | #include <asm/irq.h> |
Rob Herring | 78cbaac | 2012-02-08 18:24:23 -0600 | [diff] [blame] | 8 | #include <asm/fiq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 10 | static void iomd_ack_irq_a(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | { |
| 12 | unsigned int val, mask; |
| 13 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 14 | mask = 1 << d->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | val = iomd_readb(IOMD_IRQMASKA); |
| 16 | iomd_writeb(val & ~mask, IOMD_IRQMASKA); |
| 17 | iomd_writeb(mask, IOMD_IRQCLRA); |
| 18 | } |
| 19 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 20 | static void iomd_mask_irq_a(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | { |
| 22 | unsigned int val, mask; |
| 23 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 24 | mask = 1 << d->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | val = iomd_readb(IOMD_IRQMASKA); |
| 26 | iomd_writeb(val & ~mask, IOMD_IRQMASKA); |
| 27 | } |
| 28 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 29 | static void iomd_unmask_irq_a(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
| 31 | unsigned int val, mask; |
| 32 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 33 | mask = 1 << d->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | val = iomd_readb(IOMD_IRQMASKA); |
| 35 | iomd_writeb(val | mask, IOMD_IRQMASKA); |
| 36 | } |
| 37 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 38 | static struct irq_chip iomd_a_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 39 | .irq_ack = iomd_ack_irq_a, |
| 40 | .irq_mask = iomd_mask_irq_a, |
| 41 | .irq_unmask = iomd_unmask_irq_a, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 44 | static void iomd_mask_irq_b(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
| 46 | unsigned int val, mask; |
| 47 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 48 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | val = iomd_readb(IOMD_IRQMASKB); |
| 50 | iomd_writeb(val & ~mask, IOMD_IRQMASKB); |
| 51 | } |
| 52 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 53 | static void iomd_unmask_irq_b(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | { |
| 55 | unsigned int val, mask; |
| 56 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 57 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | val = iomd_readb(IOMD_IRQMASKB); |
| 59 | iomd_writeb(val | mask, IOMD_IRQMASKB); |
| 60 | } |
| 61 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 62 | static struct irq_chip iomd_b_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 63 | .irq_ack = iomd_mask_irq_b, |
| 64 | .irq_mask = iomd_mask_irq_b, |
| 65 | .irq_unmask = iomd_unmask_irq_b, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 68 | static void iomd_mask_irq_dma(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { |
| 70 | unsigned int val, mask; |
| 71 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 72 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | val = iomd_readb(IOMD_DMAMASK); |
| 74 | iomd_writeb(val & ~mask, IOMD_DMAMASK); |
| 75 | } |
| 76 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 77 | static void iomd_unmask_irq_dma(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
| 79 | unsigned int val, mask; |
| 80 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 81 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | val = iomd_readb(IOMD_DMAMASK); |
| 83 | iomd_writeb(val | mask, IOMD_DMAMASK); |
| 84 | } |
| 85 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 86 | static struct irq_chip iomd_dma_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 87 | .irq_ack = iomd_mask_irq_dma, |
| 88 | .irq_mask = iomd_mask_irq_dma, |
| 89 | .irq_unmask = iomd_unmask_irq_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 92 | static void iomd_mask_irq_fiq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | { |
| 94 | unsigned int val, mask; |
| 95 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 96 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | val = iomd_readb(IOMD_FIQMASK); |
| 98 | iomd_writeb(val & ~mask, IOMD_FIQMASK); |
| 99 | } |
| 100 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 101 | static void iomd_unmask_irq_fiq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | { |
| 103 | unsigned int val, mask; |
| 104 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 105 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | val = iomd_readb(IOMD_FIQMASK); |
| 107 | iomd_writeb(val | mask, IOMD_FIQMASK); |
| 108 | } |
| 109 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 110 | static struct irq_chip iomd_fiq_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 111 | .irq_ack = iomd_mask_irq_fiq, |
| 112 | .irq_mask = iomd_mask_irq_fiq, |
| 113 | .irq_unmask = iomd_unmask_irq_fiq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
Rob Herring | 78cbaac | 2012-02-08 18:24:23 -0600 | [diff] [blame] | 116 | extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end; |
| 117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | void __init rpc_init_irq(void) |
| 119 | { |
| 120 | unsigned int irq, flags; |
| 121 | |
| 122 | iomd_writeb(0, IOMD_IRQMASKA); |
| 123 | iomd_writeb(0, IOMD_IRQMASKB); |
| 124 | iomd_writeb(0, IOMD_FIQMASK); |
| 125 | iomd_writeb(0, IOMD_DMAMASK); |
| 126 | |
Rob Herring | 78cbaac | 2012-02-08 18:24:23 -0600 | [diff] [blame] | 127 | set_fiq_handler(&rpc_default_fiq_start, |
| 128 | &rpc_default_fiq_end - &rpc_default_fiq_start); |
| 129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | for (irq = 0; irq < NR_IRQS; irq++) { |
| 131 | flags = IRQF_VALID; |
| 132 | |
| 133 | if (irq <= 6 || (irq >= 9 && irq <= 15)) |
| 134 | flags |= IRQF_PROBE; |
| 135 | |
| 136 | if (irq == 21 || (irq >= 16 && irq <= 19) || |
| 137 | irq == IRQ_KEYBOARDTX) |
| 138 | flags |= IRQF_NOAUTOEN; |
| 139 | |
| 140 | switch (irq) { |
| 141 | case 0 ... 7: |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 142 | irq_set_chip_and_handler(irq, &iomd_a_chip, |
| 143 | handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | set_irq_flags(irq, flags); |
| 145 | break; |
| 146 | |
| 147 | case 8 ... 15: |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 148 | irq_set_chip_and_handler(irq, &iomd_b_chip, |
| 149 | handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | set_irq_flags(irq, flags); |
| 151 | break; |
| 152 | |
| 153 | case 16 ... 21: |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 154 | irq_set_chip_and_handler(irq, &iomd_dma_chip, |
| 155 | handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | set_irq_flags(irq, flags); |
| 157 | break; |
| 158 | |
| 159 | case 64 ... 71: |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 160 | irq_set_chip(irq, &iomd_fiq_chip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | set_irq_flags(irq, IRQF_VALID); |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | |
Shawn Guo | bc89663 | 2012-06-28 14:42:08 +0800 | [diff] [blame^] | 166 | init_FIQ(FIQ_START); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |