Lines Matching refs:mpic
56 static struct mpic *mpics;
57 static struct mpic *mpic_primary;
150 #define MPIC_INFO(name) mpic->hw_set[MPIC_IDX_##name]
158 static inline unsigned int mpic_processor_id(struct mpic *mpic) in mpic_processor_id() argument
162 if (!(mpic->flags & MPIC_SECONDARY)) in mpic_processor_id()
210 static inline u32 _mpic_ipi_read(struct mpic *mpic, unsigned int ipi) in _mpic_ipi_read() argument
212 enum mpic_reg_type type = mpic->reg_type; in _mpic_ipi_read()
216 if ((mpic->flags & MPIC_BROKEN_IPI) && type == mpic_access_mmio_le) in _mpic_ipi_read()
218 return _mpic_read(type, &mpic->gregs, offset); in _mpic_ipi_read()
221 static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 value) in _mpic_ipi_write() argument
226 _mpic_write(mpic->reg_type, &mpic->gregs, offset, value); in _mpic_ipi_write()
229 static inline unsigned int mpic_tm_offset(struct mpic *mpic, unsigned int tm) in mpic_tm_offset() argument
235 static inline u32 _mpic_tm_read(struct mpic *mpic, unsigned int tm) in _mpic_tm_read() argument
237 unsigned int offset = mpic_tm_offset(mpic, tm) + in _mpic_tm_read()
240 return _mpic_read(mpic->reg_type, &mpic->tmregs, offset); in _mpic_tm_read()
243 static inline void _mpic_tm_write(struct mpic *mpic, unsigned int tm, u32 value) in _mpic_tm_write() argument
245 unsigned int offset = mpic_tm_offset(mpic, tm) + in _mpic_tm_write()
248 _mpic_write(mpic->reg_type, &mpic->tmregs, offset, value); in _mpic_tm_write()
251 static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg) in _mpic_cpu_read() argument
253 unsigned int cpu = mpic_processor_id(mpic); in _mpic_cpu_read()
255 return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg); in _mpic_cpu_read()
258 static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value) in _mpic_cpu_write() argument
260 unsigned int cpu = mpic_processor_id(mpic); in _mpic_cpu_write()
262 _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value); in _mpic_cpu_write()
265 static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigned int reg) in _mpic_irq_read() argument
267 unsigned int isu = src_no >> mpic->isu_shift; in _mpic_irq_read()
268 unsigned int idx = src_no & mpic->isu_mask; in _mpic_irq_read()
271 val = _mpic_read(mpic->reg_type, &mpic->isus[isu], in _mpic_irq_read()
276 mpic->isu_reg0_shadow[src_no]; in _mpic_irq_read()
281 static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no, in _mpic_irq_write() argument
284 unsigned int isu = src_no >> mpic->isu_shift; in _mpic_irq_write()
285 unsigned int idx = src_no & mpic->isu_mask; in _mpic_irq_write()
287 _mpic_write(mpic->reg_type, &mpic->isus[isu], in _mpic_irq_write()
292 mpic->isu_reg0_shadow[src_no] = in _mpic_irq_write()
297 #define mpic_read(b,r) _mpic_read(mpic->reg_type,&(b),(r))
298 #define mpic_write(b,r,v) _mpic_write(mpic->reg_type,&(b),(r),(v))
299 #define mpic_ipi_read(i) _mpic_ipi_read(mpic,(i))
300 #define mpic_ipi_write(i,v) _mpic_ipi_write(mpic,(i),(v))
301 #define mpic_tm_read(i) _mpic_tm_read(mpic,(i))
302 #define mpic_tm_write(i,v) _mpic_tm_write(mpic,(i),(v))
303 #define mpic_cpu_read(i) _mpic_cpu_read(mpic,(i))
304 #define mpic_cpu_write(i,v) _mpic_cpu_write(mpic,(i),(v))
305 #define mpic_irq_read(s,r) _mpic_irq_read(mpic,(s),(r))
306 #define mpic_irq_write(s,r,v) _mpic_irq_write(mpic,(s),(r),(v))
314 static void _mpic_map_mmio(struct mpic *mpic, phys_addr_t phys_addr, in _mpic_map_mmio() argument
323 static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb, in _mpic_map_dcr() argument
326 phys_addr_t phys_addr = dcr_resource_start(mpic->node, 0); in _mpic_map_dcr()
327 rb->dhost = dcr_map(mpic->node, phys_addr + offset, size); in _mpic_map_dcr()
331 static inline void mpic_map(struct mpic *mpic, in mpic_map() argument
335 if (mpic->flags & MPIC_USES_DCR) in mpic_map()
336 _mpic_map_dcr(mpic, rb, offset, size); in mpic_map()
338 _mpic_map_mmio(mpic, phys_addr, rb, offset, size); in mpic_map()
349 static void __init mpic_test_broken_ipi(struct mpic *mpic) in mpic_test_broken_ipi() argument
353 mpic_write(mpic->gregs, MPIC_INFO(GREG_IPI_VECTOR_PRI_0), MPIC_VECPRI_MASK); in mpic_test_broken_ipi()
354 r = mpic_read(mpic->gregs, MPIC_INFO(GREG_IPI_VECTOR_PRI_0)); in mpic_test_broken_ipi()
358 mpic->flags |= MPIC_BROKEN_IPI; in mpic_test_broken_ipi()
367 static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source) in mpic_is_ht_interrupt() argument
369 if (source >= 128 || !mpic->fixups) in mpic_is_ht_interrupt()
371 return mpic->fixups[source].base != NULL; in mpic_is_ht_interrupt()
375 static inline void mpic_ht_end_irq(struct mpic *mpic, unsigned int source) in mpic_ht_end_irq() argument
377 struct mpic_irq_fixup *fixup = &mpic->fixups[source]; in mpic_ht_end_irq()
384 raw_spin_lock(&mpic->fixup_lock); in mpic_ht_end_irq()
387 raw_spin_unlock(&mpic->fixup_lock); in mpic_ht_end_irq()
391 static void mpic_startup_ht_interrupt(struct mpic *mpic, unsigned int source, in mpic_startup_ht_interrupt() argument
394 struct mpic_irq_fixup *fixup = &mpic->fixups[source]; in mpic_startup_ht_interrupt()
403 raw_spin_lock_irqsave(&mpic->fixup_lock, flags); in mpic_startup_ht_interrupt()
411 raw_spin_unlock_irqrestore(&mpic->fixup_lock, flags); in mpic_startup_ht_interrupt()
416 mpic->save_data[source].fixup_data = tmp | 1; in mpic_startup_ht_interrupt()
420 static void mpic_shutdown_ht_interrupt(struct mpic *mpic, unsigned int source) in mpic_shutdown_ht_interrupt() argument
422 struct mpic_irq_fixup *fixup = &mpic->fixups[source]; in mpic_shutdown_ht_interrupt()
432 raw_spin_lock_irqsave(&mpic->fixup_lock, flags); in mpic_shutdown_ht_interrupt()
437 raw_spin_unlock_irqrestore(&mpic->fixup_lock, flags); in mpic_shutdown_ht_interrupt()
442 mpic->save_data[source].fixup_data = tmp & ~1; in mpic_shutdown_ht_interrupt()
447 static void __init mpic_scan_ht_msi(struct mpic *mpic, u8 __iomem *devbase, in mpic_scan_ht_msi() argument
483 static void __init mpic_scan_ht_msi(struct mpic *mpic, u8 __iomem *devbase, in mpic_scan_ht_msi() argument
490 static void __init mpic_scan_ht_pic(struct mpic *mpic, u8 __iomem *devbase, in mpic_scan_ht_pic() argument
526 mpic->fixups[irq].index = i; in mpic_scan_ht_pic()
527 mpic->fixups[irq].base = base; in mpic_scan_ht_pic()
530 mpic->fixups[irq].applebase = devbase + 0x60; in mpic_scan_ht_pic()
532 mpic->fixups[irq].applebase = NULL; in mpic_scan_ht_pic()
534 mpic->fixups[irq].data = readl(base + 4) | 0x80000000; in mpic_scan_ht_pic()
539 static void __init mpic_scan_ht_pics(struct mpic *mpic) in mpic_scan_ht_pics() argument
547 mpic->fixups = kzalloc(128 * sizeof(*mpic->fixups), GFP_KERNEL); in mpic_scan_ht_pics()
548 BUG_ON(mpic->fixups == NULL); in mpic_scan_ht_pics()
551 raw_spin_lock_init(&mpic->fixup_lock); in mpic_scan_ht_pics()
579 mpic_scan_ht_pic(mpic, devbase, devfn, l); in mpic_scan_ht_pics()
580 mpic_scan_ht_msi(mpic, devbase, devfn); in mpic_scan_ht_pics()
591 static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source) in mpic_is_ht_interrupt() argument
596 static void __init mpic_scan_ht_pics(struct mpic *mpic) in mpic_scan_ht_pics() argument
603 static struct mpic *mpic_find(unsigned int irq) in mpic_find()
612 static unsigned int mpic_is_ipi(struct mpic *mpic, unsigned int src) in mpic_is_ipi() argument
614 return (src >= mpic->ipi_vecs[0] && src <= mpic->ipi_vecs[3]); in mpic_is_ipi()
618 static unsigned int mpic_is_tm(struct mpic *mpic, unsigned int src) in mpic_is_tm() argument
620 return (src >= mpic->timer_vecs[0] && src <= mpic->timer_vecs[7]); in mpic_is_tm()
636 static inline struct mpic * mpic_from_ipi(struct irq_data *d) in mpic_from_ipi()
643 static inline struct mpic * mpic_from_irq(unsigned int irq) in mpic_from_irq()
649 static inline struct mpic * mpic_from_irq_data(struct irq_data *d) in mpic_from_irq_data()
655 static inline void mpic_eoi(struct mpic *mpic) in mpic_eoi() argument
668 struct mpic *mpic = mpic_from_irq_data(d); in mpic_unmask_irq() local
671 DBG("%p: %s: enable_irq: %d (src %d)\n", mpic, mpic->name, d->irq, src); in mpic_unmask_irq()
689 struct mpic *mpic = mpic_from_irq_data(d); in mpic_mask_irq() local
692 DBG("%s: disable_irq: %d (src %d)\n", mpic->name, d->irq, src); in mpic_mask_irq()
710 struct mpic *mpic = mpic_from_irq_data(d); in mpic_end_irq() local
713 DBG("%s: end_irq: %d\n", mpic->name, d->irq); in mpic_end_irq()
720 mpic_eoi(mpic); in mpic_end_irq()
727 struct mpic *mpic = mpic_from_irq_data(d); in mpic_unmask_ht_irq() local
733 mpic_ht_end_irq(mpic, src); in mpic_unmask_ht_irq()
738 struct mpic *mpic = mpic_from_irq_data(d); in mpic_startup_ht_irq() local
742 mpic_startup_ht_interrupt(mpic, src, irqd_is_level_type(d)); in mpic_startup_ht_irq()
749 struct mpic *mpic = mpic_from_irq_data(d); in mpic_shutdown_ht_irq() local
752 mpic_shutdown_ht_interrupt(mpic, src); in mpic_shutdown_ht_irq()
758 struct mpic *mpic = mpic_from_irq_data(d); in mpic_end_ht_irq() local
762 DBG("%s: end_irq: %d\n", mpic->name, d->irq); in mpic_end_ht_irq()
770 mpic_ht_end_irq(mpic, src); in mpic_end_ht_irq()
771 mpic_eoi(mpic); in mpic_end_ht_irq()
779 struct mpic *mpic = mpic_from_ipi(d); in mpic_unmask_ipi() local
780 unsigned int src = virq_to_hw(d->irq) - mpic->ipi_vecs[0]; in mpic_unmask_ipi()
782 DBG("%s: enable_ipi: %d (ipi %d)\n", mpic->name, d->irq, src); in mpic_unmask_ipi()
793 struct mpic *mpic = mpic_from_ipi(d); in mpic_end_ipi() local
800 mpic_eoi(mpic); in mpic_end_ipi()
807 struct mpic *mpic = mpic_from_irq_data(d); in mpic_unmask_tm() local
808 unsigned int src = virq_to_hw(d->irq) - mpic->timer_vecs[0]; in mpic_unmask_tm()
810 DBG("%s: enable_tm: %d (tm %d)\n", mpic->name, d->irq, src); in mpic_unmask_tm()
817 struct mpic *mpic = mpic_from_irq_data(d); in mpic_mask_tm() local
818 unsigned int src = virq_to_hw(d->irq) - mpic->timer_vecs[0]; in mpic_mask_tm()
827 struct mpic *mpic = mpic_from_irq_data(d); in mpic_set_affinity() local
830 if (mpic->flags & MPIC_SINGLE_DEST_CPU) { in mpic_set_affinity()
846 static unsigned int mpic_type_to_vecpri(struct mpic *mpic, unsigned int type) in mpic_type_to_vecpri() argument
869 struct mpic *mpic = mpic_from_irq_data(d); in mpic_set_irq_type() local
874 mpic, d->irq, src, flow_type); in mpic_set_irq_type()
876 if (src >= mpic->num_sources) in mpic_set_irq_type()
912 if (mpic_is_ht_interrupt(mpic, src)) in mpic_set_irq_type()
916 vecpri = mpic_type_to_vecpri(mpic, flow_type); in mpic_set_irq_type()
929 struct mpic *mpic = mpic_from_irq(virq); in mpic_set_vector() local
934 mpic, virq, src, vector); in mpic_set_vector()
936 if (src >= mpic->num_sources) in mpic_set_vector()
947 struct mpic *mpic = mpic_from_irq(virq); in mpic_set_destination() local
951 mpic, virq, src, cpuid); in mpic_set_destination()
953 if (src >= mpic->num_sources) in mpic_set_destination()
1003 struct mpic *mpic = h->host_data; in mpic_host_map() local
1008 if (hw == mpic->spurious_vec) in mpic_host_map()
1010 if (mpic->protected && test_bit(hw, mpic->protected)) { in mpic_host_map()
1018 else if (hw >= mpic->ipi_vecs[0]) { in mpic_host_map()
1019 WARN_ON(mpic->flags & MPIC_SECONDARY); in mpic_host_map()
1022 irq_set_chip_data(virq, mpic); in mpic_host_map()
1023 irq_set_chip_and_handler(virq, &mpic->hc_ipi, in mpic_host_map()
1029 if (hw >= mpic->timer_vecs[0] && hw <= mpic->timer_vecs[7]) { in mpic_host_map()
1030 WARN_ON(mpic->flags & MPIC_SECONDARY); in mpic_host_map()
1033 irq_set_chip_data(virq, mpic); in mpic_host_map()
1034 irq_set_chip_and_handler(virq, &mpic->hc_tm, in mpic_host_map()
1039 if (mpic_map_error_int(mpic, virq, hw)) in mpic_host_map()
1042 if (hw >= mpic->num_sources) { in mpic_host_map()
1049 mpic_msi_reserve_hwirq(mpic, hw); in mpic_host_map()
1052 chip = &mpic->hc_irq; in mpic_host_map()
1056 if (mpic_is_ht_interrupt(mpic, hw)) in mpic_host_map()
1057 chip = &mpic->hc_ht_irq; in mpic_host_map()
1062 irq_set_chip_data(virq, mpic); in mpic_host_map()
1072 if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) { in mpic_host_map()
1076 cpu = mpic_processor_id(mpic); in mpic_host_map()
1092 struct mpic *mpic = h->host_data; in mpic_host_xlate() local
1101 if (intsize >= 4 && (mpic->flags & MPIC_FSL)) { in mpic_host_xlate()
1113 if (!(mpic->flags & MPIC_FSL_HAS_EIMR)) in mpic_host_xlate()
1116 if (intspec[3] >= ARRAY_SIZE(mpic->err_int_vecs)) in mpic_host_xlate()
1119 *out_hwirq = mpic->err_int_vecs[intspec[3]]; in mpic_host_xlate()
1123 if (intspec[0] >= ARRAY_SIZE(mpic->ipi_vecs)) in mpic_host_xlate()
1126 *out_hwirq = mpic->ipi_vecs[intspec[0]]; in mpic_host_xlate()
1129 if (intspec[0] >= ARRAY_SIZE(mpic->timer_vecs)) in mpic_host_xlate()
1132 *out_hwirq = mpic->timer_vecs[intspec[0]]; in mpic_host_xlate()
1170 struct mpic *mpic = irq_desc_get_handler_data(desc); in mpic_cascade() local
1173 BUG_ON(!(mpic->flags & MPIC_SECONDARY)); in mpic_cascade()
1175 virq = mpic_get_one_irq(mpic); in mpic_cascade()
1188 static u32 fsl_mpic_get_version(struct mpic *mpic) in fsl_mpic_get_version() argument
1192 if (!(mpic->flags & MPIC_FSL)) in fsl_mpic_get_version()
1195 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs, in fsl_mpic_get_version()
1207 struct mpic *mpic = mpic_primary; in fsl_mpic_primary_get_version() local
1209 if (mpic) in fsl_mpic_primary_get_version()
1210 return fsl_mpic_get_version(mpic); in fsl_mpic_primary_get_version()
1215 struct mpic * __init mpic_alloc(struct device_node *node, in mpic_alloc()
1223 struct mpic *mpic; in mpic_alloc() local
1275 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL); in mpic_alloc()
1276 if (mpic == NULL) in mpic_alloc()
1279 mpic->name = name; in mpic_alloc()
1280 mpic->node = node; in mpic_alloc()
1281 mpic->paddr = phys_addr; in mpic_alloc()
1282 mpic->flags = flags; in mpic_alloc()
1284 mpic->hc_irq = mpic_irq_chip; in mpic_alloc()
1285 mpic->hc_irq.name = name; in mpic_alloc()
1286 if (!(mpic->flags & MPIC_SECONDARY)) in mpic_alloc()
1287 mpic->hc_irq.irq_set_affinity = mpic_set_affinity; in mpic_alloc()
1289 mpic->hc_ht_irq = mpic_irq_ht_chip; in mpic_alloc()
1290 mpic->hc_ht_irq.name = name; in mpic_alloc()
1291 if (!(mpic->flags & MPIC_SECONDARY)) in mpic_alloc()
1292 mpic->hc_ht_irq.irq_set_affinity = mpic_set_affinity; in mpic_alloc()
1296 mpic->hc_ipi = mpic_ipi_chip; in mpic_alloc()
1297 mpic->hc_ipi.name = name; in mpic_alloc()
1300 mpic->hc_tm = mpic_tm_chip; in mpic_alloc()
1301 mpic->hc_tm.name = name; in mpic_alloc()
1303 mpic->num_sources = 0; /* so far */ in mpic_alloc()
1305 if (mpic->flags & MPIC_LARGE_VECTORS) in mpic_alloc()
1310 mpic->timer_vecs[0] = intvec_top - 12; in mpic_alloc()
1311 mpic->timer_vecs[1] = intvec_top - 11; in mpic_alloc()
1312 mpic->timer_vecs[2] = intvec_top - 10; in mpic_alloc()
1313 mpic->timer_vecs[3] = intvec_top - 9; in mpic_alloc()
1314 mpic->timer_vecs[4] = intvec_top - 8; in mpic_alloc()
1315 mpic->timer_vecs[5] = intvec_top - 7; in mpic_alloc()
1316 mpic->timer_vecs[6] = intvec_top - 6; in mpic_alloc()
1317 mpic->timer_vecs[7] = intvec_top - 5; in mpic_alloc()
1318 mpic->ipi_vecs[0] = intvec_top - 4; in mpic_alloc()
1319 mpic->ipi_vecs[1] = intvec_top - 3; in mpic_alloc()
1320 mpic->ipi_vecs[2] = intvec_top - 2; in mpic_alloc()
1321 mpic->ipi_vecs[3] = intvec_top - 1; in mpic_alloc()
1322 mpic->spurious_vec = intvec_top; in mpic_alloc()
1325 psrc = of_get_property(mpic->node, "protected-sources", &psize); in mpic_alloc()
1329 mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL); in mpic_alloc()
1330 BUG_ON(mpic->protected == NULL); in mpic_alloc()
1334 __set_bit(psrc[i], mpic->protected); in mpic_alloc()
1339 mpic->hw_set = mpic_infos[MPIC_GET_REGSET(mpic->flags)]; in mpic_alloc()
1343 if (mpic->flags & MPIC_BIG_ENDIAN) in mpic_alloc()
1344 mpic->reg_type = mpic_access_mmio_be; in mpic_alloc()
1346 mpic->reg_type = mpic_access_mmio_le; in mpic_alloc()
1353 if (mpic->flags & MPIC_USES_DCR) in mpic_alloc()
1354 mpic->reg_type = mpic_access_dcr; in mpic_alloc()
1356 BUG_ON(mpic->flags & MPIC_USES_DCR); in mpic_alloc()
1360 mpic_map(mpic, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000); in mpic_alloc()
1361 mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); in mpic_alloc()
1363 if (mpic->flags & MPIC_FSL) { in mpic_alloc()
1371 mpic_map(mpic, mpic->paddr, &mpic->thiscpuregs, in mpic_alloc()
1374 fsl_version = fsl_mpic_get_version(mpic); in mpic_alloc()
1390 ret = mpic_setup_error_int(mpic, intvec_top - 12); in mpic_alloc()
1420 if (!(mpic->flags & MPIC_NO_RESET)) { in mpic_alloc()
1422 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_alloc()
1423 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1425 while( mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1431 if (mpic->flags & MPIC_ENABLE_COREINT) in mpic_alloc()
1432 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_alloc()
1433 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1436 if (mpic->flags & MPIC_ENABLE_MCK) in mpic_alloc()
1437 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_alloc()
1438 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1451 mpic_map(mpic, mpic->paddr, &mpic->cpuregs[cpu], in mpic_alloc()
1460 greg_feature = mpic_read(mpic->gregs, MPIC_INFO(GREG_FEATURE_0)); in mpic_alloc()
1472 of_property_read_u32(mpic->node, "last-interrupt-source", &last_irq); in mpic_alloc()
1479 mpic->num_sources = isu_size; in mpic_alloc()
1480 mpic_map(mpic, mpic->paddr, &mpic->isus[0], in mpic_alloc()
1485 mpic->isu_size = isu_size; in mpic_alloc()
1486 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1); in mpic_alloc()
1487 mpic->isu_mask = (1 << mpic->isu_shift) - 1; in mpic_alloc()
1489 mpic->irqhost = irq_domain_add_linear(mpic->node, in mpic_alloc()
1491 &mpic_host_ops, mpic); in mpic_alloc()
1497 if (mpic->irqhost == NULL) in mpic_alloc()
1517 name, vers, (unsigned long long)mpic->paddr, num_possible_cpus()); in mpic_alloc()
1519 mpic->isu_size, mpic->isu_shift, mpic->isu_mask); in mpic_alloc()
1521 mpic->next = mpics; in mpic_alloc()
1522 mpics = mpic; in mpic_alloc()
1524 if (!(mpic->flags & MPIC_SECONDARY)) { in mpic_alloc()
1525 mpic_primary = mpic; in mpic_alloc()
1526 irq_set_default_host(mpic->irqhost); in mpic_alloc()
1529 return mpic; in mpic_alloc()
1536 void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, in mpic_assign_isu() argument
1539 unsigned int isu_first = isu_num * mpic->isu_size; in mpic_assign_isu()
1543 mpic_map(mpic, in mpic_assign_isu()
1544 paddr, &mpic->isus[isu_num], 0, in mpic_assign_isu()
1545 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); in mpic_assign_isu()
1547 if ((isu_first + mpic->isu_size) > mpic->num_sources) in mpic_assign_isu()
1548 mpic->num_sources = isu_first + mpic->isu_size; in mpic_assign_isu()
1551 void __init mpic_init(struct mpic *mpic) in mpic_init() argument
1556 BUG_ON(mpic->num_sources == 0); in mpic_init()
1558 printk(KERN_INFO "mpic: Initializing for %d sources\n", mpic->num_sources); in mpic_init()
1563 if (mpic->flags & MPIC_FSL) { in mpic_init()
1564 u32 version = fsl_mpic_get_version(mpic); in mpic_init()
1578 unsigned int offset = mpic_tm_offset(mpic, i); in mpic_init()
1580 mpic_write(mpic->tmregs, in mpic_init()
1583 mpic_write(mpic->tmregs, in mpic_init()
1587 (mpic->timer_vecs[0] + i)); in mpic_init()
1591 mpic_test_broken_ipi(mpic); in mpic_init()
1596 (mpic->ipi_vecs[0] + i)); in mpic_init()
1600 DBG("MPIC flags: %x\n", mpic->flags); in mpic_init()
1601 if ((mpic->flags & MPIC_U3_HT_IRQS) && !(mpic->flags & MPIC_SECONDARY)) { in mpic_init()
1602 mpic_scan_ht_pics(mpic); in mpic_init()
1603 mpic_u3msi_init(mpic); in mpic_init()
1606 mpic_pasemi_msi_init(mpic); in mpic_init()
1608 cpu = mpic_processor_id(mpic); in mpic_init()
1610 if (!(mpic->flags & MPIC_NO_RESET)) { in mpic_init()
1611 for (i = 0; i < mpic->num_sources; i++) { in mpic_init()
1617 if (mpic->protected && test_bit(i, mpic->protected)) in mpic_init()
1626 mpic_write(mpic->gregs, MPIC_INFO(GREG_SPURIOUS), mpic->spurious_vec); in mpic_init()
1629 if (!(mpic->flags & MPIC_NO_PTHROU_DIS)) in mpic_init()
1630 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_init()
1631 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_init()
1634 if (mpic->flags & MPIC_NO_BIAS) in mpic_init()
1635 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_init()
1636 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_init()
1644 mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data), in mpic_init()
1646 BUG_ON(mpic->save_data == NULL); in mpic_init()
1650 if (mpic->flags & MPIC_SECONDARY) { in mpic_init()
1651 int virq = irq_of_parse_and_map(mpic->node, 0); in mpic_init()
1654 mpic->node->full_name, virq); in mpic_init()
1655 irq_set_handler_data(virq, mpic); in mpic_init()
1661 if (mpic->flags & MPIC_FSL_HAS_EIMR) in mpic_init()
1662 mpic_err_int_init(mpic, MPIC_FSL_ERR_INT); in mpic_init()
1667 struct mpic *mpic = mpic_find(irq); in mpic_irq_set_priority() local
1672 if (!mpic) in mpic_irq_set_priority()
1676 if (mpic_is_ipi(mpic, src)) { in mpic_irq_set_priority()
1677 reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) & in mpic_irq_set_priority()
1679 mpic_ipi_write(src - mpic->ipi_vecs[0], in mpic_irq_set_priority()
1681 } else if (mpic_is_tm(mpic, src)) { in mpic_irq_set_priority()
1682 reg = mpic_tm_read(src - mpic->timer_vecs[0]) & in mpic_irq_set_priority()
1684 mpic_tm_write(src - mpic->timer_vecs[0], in mpic_irq_set_priority()
1698 struct mpic *mpic = mpic_primary; in mpic_setup_this_cpu() local
1703 BUG_ON(mpic == NULL); in mpic_setup_this_cpu()
1705 DBG("%s: setup_this_cpu(%d)\n", mpic->name, hard_smp_processor_id()); in mpic_setup_this_cpu()
1714 if (distribute_irqs && !(mpic->flags & MPIC_SINGLE_DEST_CPU)) { in mpic_setup_this_cpu()
1715 for (i = 0; i < mpic->num_sources ; i++) in mpic_setup_this_cpu()
1729 struct mpic *mpic = mpic_primary; in mpic_cpu_get_priority() local
1736 struct mpic *mpic = mpic_primary; in mpic_cpu_set_priority() local
1744 struct mpic *mpic = mpic_primary; in mpic_teardown_this_cpu() local
1749 BUG_ON(mpic == NULL); in mpic_teardown_this_cpu()
1751 DBG("%s: teardown_this_cpu(%d)\n", mpic->name, hard_smp_processor_id()); in mpic_teardown_this_cpu()
1755 for (i = 0; i < mpic->num_sources ; i++) in mpic_teardown_this_cpu()
1764 mpic_eoi(mpic); in mpic_teardown_this_cpu()
1770 static unsigned int _mpic_get_one_irq(struct mpic *mpic, int reg) in _mpic_get_one_irq() argument
1776 DBG("%s: get_one_irq(reg 0x%x): %d\n", mpic->name, reg, src); in _mpic_get_one_irq()
1778 if (unlikely(src == mpic->spurious_vec)) { in _mpic_get_one_irq()
1779 if (mpic->flags & MPIC_SPV_EOI) in _mpic_get_one_irq()
1780 mpic_eoi(mpic); in _mpic_get_one_irq()
1783 if (unlikely(mpic->protected && test_bit(src, mpic->protected))) { in _mpic_get_one_irq()
1785 mpic->name, (int)src); in _mpic_get_one_irq()
1786 mpic_eoi(mpic); in _mpic_get_one_irq()
1790 return irq_linear_revmap(mpic->irqhost, src); in _mpic_get_one_irq()
1793 unsigned int mpic_get_one_irq(struct mpic *mpic) in mpic_get_one_irq() argument
1795 return _mpic_get_one_irq(mpic, MPIC_INFO(CPU_INTACK)); in mpic_get_one_irq()
1800 struct mpic *mpic = mpic_primary; in mpic_get_irq() local
1802 BUG_ON(mpic == NULL); in mpic_get_irq()
1804 return mpic_get_one_irq(mpic); in mpic_get_irq()
1810 struct mpic *mpic = mpic_primary; in mpic_get_coreint_irq() local
1813 BUG_ON(mpic == NULL); in mpic_get_coreint_irq()
1817 if (unlikely(src == mpic->spurious_vec)) { in mpic_get_coreint_irq()
1818 if (mpic->flags & MPIC_SPV_EOI) in mpic_get_coreint_irq()
1819 mpic_eoi(mpic); in mpic_get_coreint_irq()
1822 if (unlikely(mpic->protected && test_bit(src, mpic->protected))) { in mpic_get_coreint_irq()
1824 mpic->name, (int)src); in mpic_get_coreint_irq()
1828 return irq_linear_revmap(mpic->irqhost, src); in mpic_get_coreint_irq()
1836 struct mpic *mpic = mpic_primary; in mpic_get_mcirq() local
1838 BUG_ON(mpic == NULL); in mpic_get_mcirq()
1840 return _mpic_get_one_irq(mpic, MPIC_INFO(CPU_MCACK)); in mpic_get_mcirq()
1846 struct mpic *mpic = mpic_primary; in mpic_request_ipis() local
1848 BUG_ON(mpic == NULL); in mpic_request_ipis()
1853 unsigned int vipi = irq_create_mapping(mpic->irqhost, in mpic_request_ipis()
1854 mpic->ipi_vecs[0] + i); in mpic_request_ipis()
1865 struct mpic *mpic = mpic_primary; in smp_mpic_message_pass() local
1868 BUG_ON(mpic == NULL); in smp_mpic_message_pass()
1878 DBG("%s: send_ipi(ipi_no: %d)\n", mpic->name, msg); in smp_mpic_message_pass()
1908 struct mpic *mpic = mpic_primary; in mpic_reset_core() local
1914 pir = mpic_read(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT)); in mpic_reset_core()
1916 mpic_write(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT), pir); in mpic_reset_core()
1917 mpic_read(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT)); in mpic_reset_core()
1921 mpic_write(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT), pir); in mpic_reset_core()
1922 mpic_read(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT)); in mpic_reset_core()
1926 if (mpic->flags & MPIC_FSL) { in mpic_reset_core()
1928 _mpic_write(mpic->reg_type, &mpic->cpuregs[cpuid], in mpic_reset_core()
1936 static void mpic_suspend_one(struct mpic *mpic) in mpic_suspend_one() argument
1940 for (i = 0; i < mpic->num_sources; i++) { in mpic_suspend_one()
1941 mpic->save_data[i].vecprio = in mpic_suspend_one()
1943 mpic->save_data[i].dest = in mpic_suspend_one()
1950 struct mpic *mpic = mpics; in mpic_suspend() local
1952 while (mpic) { in mpic_suspend()
1953 mpic_suspend_one(mpic); in mpic_suspend()
1954 mpic = mpic->next; in mpic_suspend()
1960 static void mpic_resume_one(struct mpic *mpic) in mpic_resume_one() argument
1964 for (i = 0; i < mpic->num_sources; i++) { in mpic_resume_one()
1966 mpic->save_data[i].vecprio); in mpic_resume_one()
1968 mpic->save_data[i].dest); in mpic_resume_one()
1971 if (mpic->fixups) { in mpic_resume_one()
1972 struct mpic_irq_fixup *fixup = &mpic->fixups[i]; in mpic_resume_one()
1976 if ((mpic->save_data[i].fixup_data & 1) == 0) in mpic_resume_one()
1982 writel(mpic->save_data[i].fixup_data & ~1, in mpic_resume_one()
1992 struct mpic *mpic = mpics; in mpic_resume() local
1994 while (mpic) { in mpic_resume()
1995 mpic_resume_one(mpic); in mpic_resume()
1996 mpic = mpic->next; in mpic_resume()