Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Shared interrupt handling code for IPR and INTC2 types of IRQs. |
| 3 | * |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame^] | 4 | * Copyright (C) 2007, 2008 Magnus Damm |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 5 | * |
| 6 | * Based on intc2.c and ipr.c |
| 7 | * |
| 8 | * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi |
| 9 | * Copyright (C) 2000 Kazumoto Kojima |
| 10 | * Copyright (C) 2001 David J. Mckay (david.mckay@st.com) |
| 11 | * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp> |
| 12 | * Copyright (C) 2005, 2006 Paul Mundt |
| 13 | * |
| 14 | * This file is subject to the terms and conditions of the GNU General Public |
| 15 | * License. See the file "COPYING" in the main directory of this archive |
| 16 | * for more details. |
| 17 | */ |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/irq.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/io.h> |
| 22 | #include <linux/interrupt.h> |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 23 | #include <linux/bootmem.h> |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 24 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 25 | #define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \ |
| 26 | ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \ |
| 27 | ((addr_e) << 16) | ((addr_d << 24))) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 28 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 29 | #define _INTC_SHIFT(h) (h & 0x1f) |
| 30 | #define _INTC_WIDTH(h) ((h >> 5) & 0xf) |
| 31 | #define _INTC_FN(h) ((h >> 9) & 0xf) |
| 32 | #define _INTC_MODE(h) ((h >> 13) & 0x7) |
| 33 | #define _INTC_ADDR_E(h) ((h >> 16) & 0xff) |
| 34 | #define _INTC_ADDR_D(h) ((h >> 24) & 0xff) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 35 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 36 | struct intc_handle_int { |
| 37 | unsigned int irq; |
| 38 | unsigned long handle; |
| 39 | }; |
| 40 | |
| 41 | struct intc_desc_int { |
| 42 | unsigned long *reg; |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 43 | #ifdef CONFIG_SMP |
| 44 | unsigned long *smp; |
| 45 | #endif |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 46 | unsigned int nr_reg; |
| 47 | struct intc_handle_int *prio; |
| 48 | unsigned int nr_prio; |
| 49 | struct intc_handle_int *sense; |
| 50 | unsigned int nr_sense; |
| 51 | struct irq_chip chip; |
| 52 | }; |
| 53 | |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 54 | #ifdef CONFIG_SMP |
| 55 | #define IS_SMP(x) x.smp |
| 56 | #define INTC_REG(d, x, c) (d->reg[(x)] + ((d->smp[(x)] & 0xff) * c)) |
| 57 | #define SMP_NR(d, x) ((d->smp[(x)] >> 8) ? (d->smp[(x)] >> 8) : 1) |
| 58 | #else |
| 59 | #define IS_SMP(x) 0 |
| 60 | #define INTC_REG(d, x, c) (d->reg[(x)]) |
| 61 | #define SMP_NR(d, x) 1 |
| 62 | #endif |
| 63 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 64 | static unsigned int intc_prio_level[NR_IRQS]; /* for now */ |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame^] | 65 | #ifdef CONFIG_CPU_SH3 |
| 66 | static unsigned long ack_handle[NR_IRQS]; |
| 67 | #endif |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 68 | |
| 69 | static inline struct intc_desc_int *get_intc_desc(unsigned int irq) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 70 | { |
| 71 | struct irq_chip *chip = get_irq_chip(irq); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 72 | return (void *)((char *)chip - offsetof(struct intc_desc_int, chip)); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | static inline unsigned int set_field(unsigned int value, |
| 76 | unsigned int field_value, |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 77 | unsigned int handle) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 78 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 79 | unsigned int width = _INTC_WIDTH(handle); |
| 80 | unsigned int shift = _INTC_SHIFT(handle); |
| 81 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 82 | value &= ~(((1 << width) - 1) << shift); |
| 83 | value |= field_value << shift; |
| 84 | return value; |
| 85 | } |
| 86 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 87 | static void write_8(unsigned long addr, unsigned long h, unsigned long data) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 88 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 89 | ctrl_outb(set_field(0, data, h), addr); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 90 | } |
| 91 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 92 | static void write_16(unsigned long addr, unsigned long h, unsigned long data) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 93 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 94 | ctrl_outw(set_field(0, data, h), addr); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 95 | } |
| 96 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 97 | static void write_32(unsigned long addr, unsigned long h, unsigned long data) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 98 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 99 | ctrl_outl(set_field(0, data, h), addr); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 100 | } |
| 101 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 102 | static void modify_8(unsigned long addr, unsigned long h, unsigned long data) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 103 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 104 | ctrl_outb(set_field(ctrl_inb(addr), data, h), addr); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 105 | } |
| 106 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 107 | static void modify_16(unsigned long addr, unsigned long h, unsigned long data) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 108 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 109 | ctrl_outw(set_field(ctrl_inw(addr), data, h), addr); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 110 | } |
| 111 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 112 | static void modify_32(unsigned long addr, unsigned long h, unsigned long data) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 113 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 114 | ctrl_outl(set_field(ctrl_inl(addr), data, h), addr); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 115 | } |
| 116 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 117 | enum { REG_FN_ERR = 0, REG_FN_WRITE_BASE = 1, REG_FN_MODIFY_BASE = 5 }; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 118 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 119 | static void (*intc_reg_fns[])(unsigned long addr, |
| 120 | unsigned long h, |
| 121 | unsigned long data) = { |
| 122 | [REG_FN_WRITE_BASE + 0] = write_8, |
| 123 | [REG_FN_WRITE_BASE + 1] = write_16, |
| 124 | [REG_FN_WRITE_BASE + 3] = write_32, |
| 125 | [REG_FN_MODIFY_BASE + 0] = modify_8, |
| 126 | [REG_FN_MODIFY_BASE + 1] = modify_16, |
| 127 | [REG_FN_MODIFY_BASE + 3] = modify_32, |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 128 | }; |
| 129 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 130 | enum { MODE_ENABLE_REG = 0, /* Bit(s) set -> interrupt enabled */ |
| 131 | MODE_MASK_REG, /* Bit(s) set -> interrupt disabled */ |
| 132 | MODE_DUAL_REG, /* Two registers, set bit to enable / disable */ |
| 133 | MODE_PRIO_REG, /* Priority value written to enable interrupt */ |
| 134 | MODE_PCLR_REG, /* Above plus all bits set to disable interrupt */ |
| 135 | }; |
| 136 | |
| 137 | static void intc_mode_field(unsigned long addr, |
| 138 | unsigned long handle, |
| 139 | void (*fn)(unsigned long, |
| 140 | unsigned long, |
| 141 | unsigned long), |
| 142 | unsigned int irq) |
| 143 | { |
| 144 | fn(addr, handle, ((1 << _INTC_WIDTH(handle)) - 1)); |
| 145 | } |
| 146 | |
| 147 | static void intc_mode_zero(unsigned long addr, |
| 148 | unsigned long handle, |
| 149 | void (*fn)(unsigned long, |
| 150 | unsigned long, |
| 151 | unsigned long), |
| 152 | unsigned int irq) |
| 153 | { |
| 154 | fn(addr, handle, 0); |
| 155 | } |
| 156 | |
| 157 | static void intc_mode_prio(unsigned long addr, |
| 158 | unsigned long handle, |
| 159 | void (*fn)(unsigned long, |
| 160 | unsigned long, |
| 161 | unsigned long), |
| 162 | unsigned int irq) |
| 163 | { |
| 164 | fn(addr, handle, intc_prio_level[irq]); |
| 165 | } |
| 166 | |
| 167 | static void (*intc_enable_fns[])(unsigned long addr, |
| 168 | unsigned long handle, |
| 169 | void (*fn)(unsigned long, |
| 170 | unsigned long, |
| 171 | unsigned long), |
| 172 | unsigned int irq) = { |
| 173 | [MODE_ENABLE_REG] = intc_mode_field, |
| 174 | [MODE_MASK_REG] = intc_mode_zero, |
| 175 | [MODE_DUAL_REG] = intc_mode_field, |
| 176 | [MODE_PRIO_REG] = intc_mode_prio, |
| 177 | [MODE_PCLR_REG] = intc_mode_prio, |
| 178 | }; |
| 179 | |
| 180 | static void (*intc_disable_fns[])(unsigned long addr, |
| 181 | unsigned long handle, |
| 182 | void (*fn)(unsigned long, |
| 183 | unsigned long, |
| 184 | unsigned long), |
| 185 | unsigned int irq) = { |
| 186 | [MODE_ENABLE_REG] = intc_mode_zero, |
| 187 | [MODE_MASK_REG] = intc_mode_field, |
| 188 | [MODE_DUAL_REG] = intc_mode_field, |
| 189 | [MODE_PRIO_REG] = intc_mode_zero, |
| 190 | [MODE_PCLR_REG] = intc_mode_field, |
| 191 | }; |
| 192 | |
| 193 | static inline void _intc_enable(unsigned int irq, unsigned long handle) |
| 194 | { |
| 195 | struct intc_desc_int *d = get_intc_desc(irq); |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 196 | unsigned long addr; |
| 197 | unsigned int cpu; |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 198 | |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 199 | for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_E(handle)); cpu++) { |
| 200 | addr = INTC_REG(d, _INTC_ADDR_E(handle), cpu); |
| 201 | intc_enable_fns[_INTC_MODE(handle)](addr, handle, intc_reg_fns\ |
| 202 | [_INTC_FN(handle)], irq); |
| 203 | } |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 204 | } |
| 205 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 206 | static void intc_enable(unsigned int irq) |
| 207 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 208 | _intc_enable(irq, (unsigned long)get_irq_chip_data(irq)); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | static void intc_disable(unsigned int irq) |
| 212 | { |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 213 | struct intc_desc_int *d = get_intc_desc(irq); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 214 | unsigned long handle = (unsigned long) get_irq_chip_data(irq); |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 215 | unsigned long addr; |
| 216 | unsigned int cpu; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 217 | |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 218 | for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_D(handle)); cpu++) { |
| 219 | addr = INTC_REG(d, _INTC_ADDR_D(handle), cpu); |
| 220 | intc_disable_fns[_INTC_MODE(handle)](addr, handle,intc_reg_fns\ |
| 221 | [_INTC_FN(handle)], irq); |
| 222 | } |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 223 | } |
| 224 | |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame^] | 225 | #ifdef CONFIG_CPU_SH3 |
| 226 | static void intc_mask_ack(unsigned int irq) |
| 227 | { |
| 228 | struct intc_desc_int *d = get_intc_desc(irq); |
| 229 | unsigned long handle = ack_handle[irq]; |
| 230 | unsigned long addr; |
| 231 | |
| 232 | intc_disable(irq); |
| 233 | |
| 234 | /* read register and write zero only to the assocaited bit */ |
| 235 | |
| 236 | if (handle) { |
| 237 | addr = INTC_REG(d, _INTC_ADDR_D(handle), 0); |
| 238 | ctrl_inb(addr); |
| 239 | ctrl_outb(0x3f ^ set_field(0, 1, handle), addr); |
| 240 | } |
| 241 | } |
| 242 | #endif |
| 243 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 244 | static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp, |
| 245 | unsigned int nr_hp, |
| 246 | unsigned int irq) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 247 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 248 | int i; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 249 | |
Magnus Damm | 3d37d94 | 2007-08-17 00:50:44 +0900 | [diff] [blame] | 250 | /* this doesn't scale well, but... |
| 251 | * |
| 252 | * this function should only be used for cerain uncommon |
| 253 | * operations such as intc_set_priority() and intc_set_sense() |
| 254 | * and in those rare cases performance doesn't matter that much. |
| 255 | * keeping the memory footprint low is more important. |
| 256 | * |
| 257 | * one rather simple way to speed this up and still keep the |
| 258 | * memory footprint down is to make sure the array is sorted |
| 259 | * and then perform a bisect to lookup the irq. |
| 260 | */ |
| 261 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 262 | for (i = 0; i < nr_hp; i++) { |
| 263 | if ((hp + i)->irq != irq) |
| 264 | continue; |
| 265 | |
| 266 | return hp + i; |
| 267 | } |
| 268 | |
| 269 | return NULL; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 270 | } |
| 271 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 272 | int intc_set_priority(unsigned int irq, unsigned int prio) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 273 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 274 | struct intc_desc_int *d = get_intc_desc(irq); |
| 275 | struct intc_handle_int *ihp; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 276 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 277 | if (!intc_prio_level[irq] || prio <= 1) |
| 278 | return -EINVAL; |
| 279 | |
| 280 | ihp = intc_find_irq(d->prio, d->nr_prio, irq); |
| 281 | if (ihp) { |
Magnus Damm | 3d37d94 | 2007-08-17 00:50:44 +0900 | [diff] [blame] | 282 | if (prio >= (1 << _INTC_WIDTH(ihp->handle))) |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 283 | return -EINVAL; |
| 284 | |
| 285 | intc_prio_level[irq] = prio; |
| 286 | |
| 287 | /* |
| 288 | * only set secondary masking method directly |
| 289 | * primary masking method is using intc_prio_level[irq] |
| 290 | * priority level will be set during next enable() |
| 291 | */ |
| 292 | |
Magnus Damm | 3d37d94 | 2007-08-17 00:50:44 +0900 | [diff] [blame] | 293 | if (_INTC_FN(ihp->handle) != REG_FN_ERR) |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 294 | _intc_enable(irq, ihp->handle); |
| 295 | } |
| 296 | return 0; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | #define VALID(x) (x | 0x80) |
| 300 | |
| 301 | static unsigned char intc_irq_sense_table[IRQ_TYPE_SENSE_MASK + 1] = { |
| 302 | [IRQ_TYPE_EDGE_FALLING] = VALID(0), |
| 303 | [IRQ_TYPE_EDGE_RISING] = VALID(1), |
| 304 | [IRQ_TYPE_LEVEL_LOW] = VALID(2), |
| 305 | [IRQ_TYPE_LEVEL_HIGH] = VALID(3), |
| 306 | }; |
| 307 | |
| 308 | static int intc_set_sense(unsigned int irq, unsigned int type) |
| 309 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 310 | struct intc_desc_int *d = get_intc_desc(irq); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 311 | unsigned char value = intc_irq_sense_table[type & IRQ_TYPE_SENSE_MASK]; |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 312 | struct intc_handle_int *ihp; |
| 313 | unsigned long addr; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 314 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 315 | if (!value) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 316 | return -EINVAL; |
| 317 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 318 | ihp = intc_find_irq(d->sense, d->nr_sense, irq); |
| 319 | if (ihp) { |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 320 | addr = INTC_REG(d, _INTC_ADDR_E(ihp->handle), 0); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 321 | intc_reg_fns[_INTC_FN(ihp->handle)](addr, ihp->handle, value); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 322 | } |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 323 | return 0; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 324 | } |
| 325 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 326 | static unsigned int __init intc_get_reg(struct intc_desc_int *d, |
| 327 | unsigned long address) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 328 | { |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 329 | unsigned int k; |
| 330 | |
| 331 | for (k = 0; k < d->nr_reg; k++) { |
| 332 | if (d->reg[k] == address) |
| 333 | return k; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | BUG(); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 337 | return 0; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 338 | } |
| 339 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 340 | static intc_enum __init intc_grp_id(struct intc_desc *desc, |
| 341 | intc_enum enum_id) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 342 | { |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 343 | struct intc_group *g = desc->groups; |
| 344 | unsigned int i, j; |
| 345 | |
| 346 | for (i = 0; g && enum_id && i < desc->nr_groups; i++) { |
| 347 | g = desc->groups + i; |
| 348 | |
| 349 | for (j = 0; g->enum_ids[j]; j++) { |
| 350 | if (g->enum_ids[j] != enum_id) |
| 351 | continue; |
| 352 | |
| 353 | return g->enum_id; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | return 0; |
| 358 | } |
| 359 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 360 | static unsigned int __init intc_mask_data(struct intc_desc *desc, |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 361 | struct intc_desc_int *d, |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 362 | intc_enum enum_id, int do_grps) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 363 | { |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 364 | struct intc_mask_reg *mr = desc->mask_regs; |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 365 | unsigned int i, j, fn, mode; |
| 366 | unsigned long reg_e, reg_d; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 367 | |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 368 | for (i = 0; mr && enum_id && i < desc->nr_mask_regs; i++) { |
| 369 | mr = desc->mask_regs + i; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 370 | |
| 371 | for (j = 0; j < ARRAY_SIZE(mr->enum_ids); j++) { |
| 372 | if (mr->enum_ids[j] != enum_id) |
| 373 | continue; |
| 374 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 375 | if (mr->set_reg && mr->clr_reg) { |
| 376 | fn = REG_FN_WRITE_BASE; |
| 377 | mode = MODE_DUAL_REG; |
| 378 | reg_e = mr->clr_reg; |
| 379 | reg_d = mr->set_reg; |
| 380 | } else { |
| 381 | fn = REG_FN_MODIFY_BASE; |
| 382 | if (mr->set_reg) { |
| 383 | mode = MODE_ENABLE_REG; |
| 384 | reg_e = mr->set_reg; |
| 385 | reg_d = mr->set_reg; |
| 386 | } else { |
| 387 | mode = MODE_MASK_REG; |
| 388 | reg_e = mr->clr_reg; |
| 389 | reg_d = mr->clr_reg; |
| 390 | } |
Magnus Damm | 51da642 | 2007-08-03 14:25:32 +0900 | [diff] [blame] | 391 | } |
| 392 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 393 | fn += (mr->reg_width >> 3) - 1; |
| 394 | return _INTC_MK(fn, mode, |
| 395 | intc_get_reg(d, reg_e), |
| 396 | intc_get_reg(d, reg_d), |
| 397 | 1, |
| 398 | (mr->reg_width - 1) - j); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 402 | if (do_grps) |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 403 | return intc_mask_data(desc, d, intc_grp_id(desc, enum_id), 0); |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 404 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | static unsigned int __init intc_prio_data(struct intc_desc *desc, |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 409 | struct intc_desc_int *d, |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 410 | intc_enum enum_id, int do_grps) |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 411 | { |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 412 | struct intc_prio_reg *pr = desc->prio_regs; |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 413 | unsigned int i, j, fn, mode, bit; |
| 414 | unsigned long reg_e, reg_d; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 415 | |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 416 | for (i = 0; pr && enum_id && i < desc->nr_prio_regs; i++) { |
| 417 | pr = desc->prio_regs + i; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 418 | |
| 419 | for (j = 0; j < ARRAY_SIZE(pr->enum_ids); j++) { |
| 420 | if (pr->enum_ids[j] != enum_id) |
| 421 | continue; |
| 422 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 423 | if (pr->set_reg && pr->clr_reg) { |
| 424 | fn = REG_FN_WRITE_BASE; |
| 425 | mode = MODE_PCLR_REG; |
| 426 | reg_e = pr->set_reg; |
| 427 | reg_d = pr->clr_reg; |
| 428 | } else { |
| 429 | fn = REG_FN_MODIFY_BASE; |
| 430 | mode = MODE_PRIO_REG; |
| 431 | if (!pr->set_reg) |
| 432 | BUG(); |
| 433 | reg_e = pr->set_reg; |
| 434 | reg_d = pr->set_reg; |
| 435 | } |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 436 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 437 | fn += (pr->reg_width >> 3) - 1; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 438 | bit = pr->reg_width - ((j + 1) * pr->field_width); |
| 439 | |
| 440 | BUG_ON(bit < 0); |
| 441 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 442 | return _INTC_MK(fn, mode, |
| 443 | intc_get_reg(d, reg_e), |
| 444 | intc_get_reg(d, reg_d), |
| 445 | pr->field_width, bit); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 446 | } |
| 447 | } |
| 448 | |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 449 | if (do_grps) |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 450 | return intc_prio_data(desc, d, intc_grp_id(desc, enum_id), 0); |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 451 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 452 | return 0; |
| 453 | } |
| 454 | |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame^] | 455 | #ifdef CONFIG_CPU_SH3 |
| 456 | static unsigned int __init intc_ack_data(struct intc_desc *desc, |
| 457 | struct intc_desc_int *d, |
| 458 | intc_enum enum_id) |
| 459 | { |
| 460 | struct intc_mask_reg *mr = desc->ack_regs; |
| 461 | unsigned int i, j, fn, mode; |
| 462 | unsigned long reg_e, reg_d; |
| 463 | |
| 464 | for (i = 0; mr && enum_id && i < desc->nr_ack_regs; i++) { |
| 465 | mr = desc->ack_regs + i; |
| 466 | |
| 467 | for (j = 0; j < ARRAY_SIZE(mr->enum_ids); j++) { |
| 468 | if (mr->enum_ids[j] != enum_id) |
| 469 | continue; |
| 470 | |
| 471 | fn = REG_FN_MODIFY_BASE; |
| 472 | mode = MODE_ENABLE_REG; |
| 473 | reg_e = mr->set_reg; |
| 474 | reg_d = mr->set_reg; |
| 475 | |
| 476 | fn += (mr->reg_width >> 3) - 1; |
| 477 | return _INTC_MK(fn, mode, |
| 478 | intc_get_reg(d, reg_e), |
| 479 | intc_get_reg(d, reg_d), |
| 480 | 1, |
| 481 | (mr->reg_width - 1) - j); |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | return 0; |
| 486 | } |
| 487 | #endif |
| 488 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 489 | static unsigned int __init intc_sense_data(struct intc_desc *desc, |
| 490 | struct intc_desc_int *d, |
| 491 | intc_enum enum_id) |
| 492 | { |
| 493 | struct intc_sense_reg *sr = desc->sense_regs; |
| 494 | unsigned int i, j, fn, bit; |
| 495 | |
| 496 | for (i = 0; sr && enum_id && i < desc->nr_sense_regs; i++) { |
| 497 | sr = desc->sense_regs + i; |
| 498 | |
| 499 | for (j = 0; j < ARRAY_SIZE(sr->enum_ids); j++) { |
| 500 | if (sr->enum_ids[j] != enum_id) |
| 501 | continue; |
| 502 | |
| 503 | fn = REG_FN_MODIFY_BASE; |
| 504 | fn += (sr->reg_width >> 3) - 1; |
| 505 | bit = sr->reg_width - ((j + 1) * sr->field_width); |
| 506 | |
| 507 | BUG_ON(bit < 0); |
| 508 | |
| 509 | return _INTC_MK(fn, 0, intc_get_reg(d, sr->reg), |
| 510 | 0, sr->field_width, bit); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | static void __init intc_register_irq(struct intc_desc *desc, |
| 518 | struct intc_desc_int *d, |
| 519 | intc_enum enum_id, |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 520 | unsigned int irq) |
| 521 | { |
Magnus Damm | 3d37d94 | 2007-08-17 00:50:44 +0900 | [diff] [blame] | 522 | struct intc_handle_int *hp; |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 523 | unsigned int data[2], primary; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 524 | |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 525 | /* Prefer single interrupt source bitmap over other combinations: |
| 526 | * 1. bitmap, single interrupt source |
| 527 | * 2. priority, single interrupt source |
| 528 | * 3. bitmap, multiple interrupt sources (groups) |
| 529 | * 4. priority, multiple interrupt sources (groups) |
| 530 | */ |
| 531 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 532 | data[0] = intc_mask_data(desc, d, enum_id, 0); |
| 533 | data[1] = intc_prio_data(desc, d, enum_id, 0); |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 534 | |
| 535 | primary = 0; |
| 536 | if (!data[0] && data[1]) |
| 537 | primary = 1; |
| 538 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 539 | data[0] = data[0] ? data[0] : intc_mask_data(desc, d, enum_id, 1); |
| 540 | data[1] = data[1] ? data[1] : intc_prio_data(desc, d, enum_id, 1); |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 541 | |
| 542 | if (!data[primary]) |
| 543 | primary ^= 1; |
| 544 | |
| 545 | BUG_ON(!data[primary]); /* must have primary masking method */ |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 546 | |
| 547 | disable_irq_nosync(irq); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 548 | set_irq_chip_and_handler_name(irq, &d->chip, |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 549 | handle_level_irq, "level"); |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 550 | set_irq_chip_data(irq, (void *)data[primary]); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 551 | |
Magnus Damm | 7f3edee | 2008-01-10 14:08:55 +0900 | [diff] [blame] | 552 | /* set priority level |
| 553 | * - this needs to be at least 2 for 5-bit priorities on 7780 |
| 554 | */ |
| 555 | intc_prio_level[irq] = 2; |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 556 | |
Magnus Damm | 680c459 | 2007-07-20 12:09:29 +0900 | [diff] [blame] | 557 | /* enable secondary masking method if present */ |
| 558 | if (data[!primary]) |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 559 | _intc_enable(irq, data[!primary]); |
| 560 | |
| 561 | /* add irq to d->prio list if priority is available */ |
| 562 | if (data[1]) { |
Magnus Damm | 3d37d94 | 2007-08-17 00:50:44 +0900 | [diff] [blame] | 563 | hp = d->prio + d->nr_prio; |
| 564 | hp->irq = irq; |
| 565 | hp->handle = data[1]; |
| 566 | |
| 567 | if (primary) { |
| 568 | /* |
| 569 | * only secondary priority should access registers, so |
| 570 | * set _INTC_FN(h) = REG_FN_ERR for intc_set_priority() |
| 571 | */ |
| 572 | |
| 573 | hp->handle &= ~_INTC_MK(0x0f, 0, 0, 0, 0, 0); |
| 574 | hp->handle |= _INTC_MK(REG_FN_ERR, 0, 0, 0, 0, 0); |
| 575 | } |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 576 | d->nr_prio++; |
| 577 | } |
| 578 | |
| 579 | /* add irq to d->sense list if sense is available */ |
| 580 | data[0] = intc_sense_data(desc, d, enum_id); |
| 581 | if (data[0]) { |
| 582 | (d->sense + d->nr_sense)->irq = irq; |
| 583 | (d->sense + d->nr_sense)->handle = data[0]; |
| 584 | d->nr_sense++; |
| 585 | } |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 586 | |
| 587 | /* irq should be disabled by default */ |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 588 | d->chip.mask(irq); |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame^] | 589 | |
| 590 | #ifdef CONFIG_CPU_SH3 |
| 591 | if (desc->ack_regs) |
| 592 | ack_handle[irq] = intc_ack_data(desc, d, enum_id); |
| 593 | #endif |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 594 | } |
| 595 | |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 596 | static unsigned int __init save_reg(struct intc_desc_int *d, |
| 597 | unsigned int cnt, |
| 598 | unsigned long value, |
| 599 | unsigned int smp) |
| 600 | { |
| 601 | if (value) { |
| 602 | d->reg[cnt] = value; |
| 603 | #ifdef CONFIG_SMP |
| 604 | d->smp[cnt] = smp; |
| 605 | #endif |
| 606 | return 1; |
| 607 | } |
| 608 | |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 613 | void __init register_intc_controller(struct intc_desc *desc) |
| 614 | { |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 615 | unsigned int i, k, smp; |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 616 | struct intc_desc_int *d; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 617 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 618 | d = alloc_bootmem(sizeof(*d)); |
| 619 | |
| 620 | d->nr_reg = desc->mask_regs ? desc->nr_mask_regs * 2 : 0; |
| 621 | d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0; |
| 622 | d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0; |
| 623 | |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame^] | 624 | #ifdef CONFIG_CPU_SH3 |
| 625 | d->nr_reg += desc->ack_regs ? desc->nr_ack_regs : 0; |
| 626 | #endif |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 627 | d->reg = alloc_bootmem(d->nr_reg * sizeof(*d->reg)); |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 628 | #ifdef CONFIG_SMP |
| 629 | d->smp = alloc_bootmem(d->nr_reg * sizeof(*d->smp)); |
| 630 | #endif |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 631 | k = 0; |
| 632 | |
| 633 | if (desc->mask_regs) { |
| 634 | for (i = 0; i < desc->nr_mask_regs; i++) { |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 635 | smp = IS_SMP(desc->mask_regs[i]); |
| 636 | k += save_reg(d, k, desc->mask_regs[i].set_reg, smp); |
| 637 | k += save_reg(d, k, desc->mask_regs[i].clr_reg, smp); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | |
| 641 | if (desc->prio_regs) { |
| 642 | d->prio = alloc_bootmem(desc->nr_vectors * sizeof(*d->prio)); |
| 643 | |
| 644 | for (i = 0; i < desc->nr_prio_regs; i++) { |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 645 | smp = IS_SMP(desc->prio_regs[i]); |
| 646 | k += save_reg(d, k, desc->prio_regs[i].set_reg, smp); |
| 647 | k += save_reg(d, k, desc->prio_regs[i].clr_reg, smp); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 648 | } |
| 649 | } |
| 650 | |
| 651 | if (desc->sense_regs) { |
| 652 | d->sense = alloc_bootmem(desc->nr_vectors * sizeof(*d->sense)); |
| 653 | |
| 654 | for (i = 0; i < desc->nr_sense_regs; i++) { |
Magnus Damm | f18d533 | 2007-09-21 18:16:42 +0900 | [diff] [blame] | 655 | k += save_reg(d, k, desc->sense_regs[i].reg, 0); |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 656 | } |
| 657 | } |
| 658 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 659 | d->chip.name = desc->name; |
| 660 | d->chip.mask = intc_disable; |
| 661 | d->chip.unmask = intc_enable; |
| 662 | d->chip.mask_ack = intc_disable; |
| 663 | d->chip.set_type = intc_set_sense; |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 664 | |
Magnus Damm | d58876e | 2008-04-24 21:36:34 +0900 | [diff] [blame^] | 665 | #ifdef CONFIG_CPU_SH3 |
| 666 | if (desc->ack_regs) { |
| 667 | for (i = 0; i < desc->nr_ack_regs; i++) |
| 668 | k += save_reg(d, k, desc->ack_regs[i].set_reg, 0); |
| 669 | |
| 670 | d->chip.mask_ack = intc_mask_ack; |
| 671 | } |
| 672 | #endif |
| 673 | |
| 674 | BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */ |
| 675 | |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 676 | for (i = 0; i < desc->nr_vectors; i++) { |
| 677 | struct intc_vect *vect = desc->vectors + i; |
| 678 | |
Magnus Damm | 73505b4 | 2007-08-12 15:26:12 +0900 | [diff] [blame] | 679 | intc_register_irq(desc, d, vect->enum_id, evt2irq(vect->vect)); |
Magnus Damm | 02ab3f7 | 2007-07-18 17:25:09 +0900 | [diff] [blame] | 680 | } |
| 681 | } |