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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 9 | static void iomd_ack_irq_a(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | { |
| 11 | unsigned int val, mask; |
| 12 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 13 | mask = 1 << d->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | val = iomd_readb(IOMD_IRQMASKA); |
| 15 | iomd_writeb(val & ~mask, IOMD_IRQMASKA); |
| 16 | iomd_writeb(mask, IOMD_IRQCLRA); |
| 17 | } |
| 18 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 19 | static void iomd_mask_irq_a(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | { |
| 21 | unsigned int val, mask; |
| 22 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 23 | mask = 1 << d->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | val = iomd_readb(IOMD_IRQMASKA); |
| 25 | iomd_writeb(val & ~mask, IOMD_IRQMASKA); |
| 26 | } |
| 27 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 28 | static void iomd_unmask_irq_a(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | { |
| 30 | unsigned int val, mask; |
| 31 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 32 | mask = 1 << d->irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | val = iomd_readb(IOMD_IRQMASKA); |
| 34 | iomd_writeb(val | mask, IOMD_IRQMASKA); |
| 35 | } |
| 36 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 37 | static struct irq_chip iomd_a_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 38 | .irq_ack = iomd_ack_irq_a, |
| 39 | .irq_mask = iomd_mask_irq_a, |
| 40 | .irq_unmask = iomd_unmask_irq_a, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 43 | static void iomd_mask_irq_b(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | { |
| 45 | unsigned int val, mask; |
| 46 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 47 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | val = iomd_readb(IOMD_IRQMASKB); |
| 49 | iomd_writeb(val & ~mask, IOMD_IRQMASKB); |
| 50 | } |
| 51 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 52 | static void iomd_unmask_irq_b(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
| 54 | unsigned int val, mask; |
| 55 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 56 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | val = iomd_readb(IOMD_IRQMASKB); |
| 58 | iomd_writeb(val | mask, IOMD_IRQMASKB); |
| 59 | } |
| 60 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 61 | static struct irq_chip iomd_b_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 62 | .irq_ack = iomd_mask_irq_b, |
| 63 | .irq_mask = iomd_mask_irq_b, |
| 64 | .irq_unmask = iomd_unmask_irq_b, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 67 | static void iomd_mask_irq_dma(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | { |
| 69 | unsigned int val, mask; |
| 70 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 71 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | val = iomd_readb(IOMD_DMAMASK); |
| 73 | iomd_writeb(val & ~mask, IOMD_DMAMASK); |
| 74 | } |
| 75 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 76 | static void iomd_unmask_irq_dma(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { |
| 78 | unsigned int val, mask; |
| 79 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 80 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | val = iomd_readb(IOMD_DMAMASK); |
| 82 | iomd_writeb(val | mask, IOMD_DMAMASK); |
| 83 | } |
| 84 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 85 | static struct irq_chip iomd_dma_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 86 | .irq_ack = iomd_mask_irq_dma, |
| 87 | .irq_mask = iomd_mask_irq_dma, |
| 88 | .irq_unmask = iomd_unmask_irq_dma, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 91 | static void iomd_mask_irq_fiq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | { |
| 93 | unsigned int val, mask; |
| 94 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 95 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | val = iomd_readb(IOMD_FIQMASK); |
| 97 | iomd_writeb(val & ~mask, IOMD_FIQMASK); |
| 98 | } |
| 99 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 100 | static void iomd_unmask_irq_fiq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | { |
| 102 | unsigned int val, mask; |
| 103 | |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 104 | mask = 1 << (d->irq & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | val = iomd_readb(IOMD_FIQMASK); |
| 106 | iomd_writeb(val | mask, IOMD_FIQMASK); |
| 107 | } |
| 108 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 109 | static struct irq_chip iomd_fiq_chip = { |
Lennert Buytenhek | 9a364da | 2010-11-29 11:07:20 +0100 | [diff] [blame] | 110 | .irq_ack = iomd_mask_irq_fiq, |
| 111 | .irq_mask = iomd_mask_irq_fiq, |
| 112 | .irq_unmask = iomd_unmask_irq_fiq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | void __init rpc_init_irq(void) |
| 116 | { |
| 117 | unsigned int irq, flags; |
| 118 | |
| 119 | iomd_writeb(0, IOMD_IRQMASKA); |
| 120 | iomd_writeb(0, IOMD_IRQMASKB); |
| 121 | iomd_writeb(0, IOMD_FIQMASK); |
| 122 | iomd_writeb(0, IOMD_DMAMASK); |
| 123 | |
| 124 | for (irq = 0; irq < NR_IRQS; irq++) { |
| 125 | flags = IRQF_VALID; |
| 126 | |
| 127 | if (irq <= 6 || (irq >= 9 && irq <= 15)) |
| 128 | flags |= IRQF_PROBE; |
| 129 | |
| 130 | if (irq == 21 || (irq >= 16 && irq <= 19) || |
| 131 | irq == IRQ_KEYBOARDTX) |
| 132 | flags |= IRQF_NOAUTOEN; |
| 133 | |
| 134 | switch (irq) { |
| 135 | case 0 ... 7: |
| 136 | set_irq_chip(irq, &iomd_a_chip); |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 137 | set_irq_handler(irq, handle_level_irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | set_irq_flags(irq, flags); |
| 139 | break; |
| 140 | |
| 141 | case 8 ... 15: |
| 142 | set_irq_chip(irq, &iomd_b_chip); |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 143 | set_irq_handler(irq, 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 16 ... 21: |
| 148 | set_irq_chip(irq, &iomd_dma_chip); |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 149 | set_irq_handler(irq, 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 64 ... 71: |
| 154 | set_irq_chip(irq, &iomd_fiq_chip); |
| 155 | set_irq_flags(irq, IRQF_VALID); |
| 156 | break; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | init_FIQ(); |
| 161 | } |
| 162 | |