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 = kcalloc(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()
1017 else if (hw >= mpic->ipi_vecs[0]) { in mpic_host_map()
1018 WARN_ON(mpic->flags & MPIC_SECONDARY); in mpic_host_map()
1021 irq_set_chip_data(virq, mpic); in mpic_host_map()
1022 irq_set_chip_and_handler(virq, &mpic->hc_ipi, in mpic_host_map()
1028 if (hw >= mpic->timer_vecs[0] && hw <= mpic->timer_vecs[7]) { in mpic_host_map()
1029 WARN_ON(mpic->flags & MPIC_SECONDARY); in mpic_host_map()
1032 irq_set_chip_data(virq, mpic); in mpic_host_map()
1033 irq_set_chip_and_handler(virq, &mpic->hc_tm, in mpic_host_map()
1038 if (mpic_map_error_int(mpic, virq, hw)) in mpic_host_map()
1041 if (hw >= mpic->num_sources) { in mpic_host_map()
1047 mpic_msi_reserve_hwirq(mpic, hw); in mpic_host_map()
1050 chip = &mpic->hc_irq; in mpic_host_map()
1054 if (mpic_is_ht_interrupt(mpic, hw)) in mpic_host_map()
1055 chip = &mpic->hc_ht_irq; in mpic_host_map()
1060 irq_set_chip_data(virq, mpic); in mpic_host_map()
1070 if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) { in mpic_host_map()
1074 cpu = mpic_processor_id(mpic); in mpic_host_map()
1090 struct mpic *mpic = h->host_data; in mpic_host_xlate() local
1099 if (intsize >= 4 && (mpic->flags & MPIC_FSL)) { in mpic_host_xlate()
1111 if (!(mpic->flags & MPIC_FSL_HAS_EIMR)) in mpic_host_xlate()
1114 if (intspec[3] >= ARRAY_SIZE(mpic->err_int_vecs)) in mpic_host_xlate()
1117 *out_hwirq = mpic->err_int_vecs[intspec[3]]; in mpic_host_xlate()
1121 if (intspec[0] >= ARRAY_SIZE(mpic->ipi_vecs)) in mpic_host_xlate()
1124 *out_hwirq = mpic->ipi_vecs[intspec[0]]; in mpic_host_xlate()
1127 if (intspec[0] >= ARRAY_SIZE(mpic->timer_vecs)) in mpic_host_xlate()
1130 *out_hwirq = mpic->timer_vecs[intspec[0]]; in mpic_host_xlate()
1168 struct mpic *mpic = irq_desc_get_handler_data(desc); in mpic_cascade() local
1171 BUG_ON(!(mpic->flags & MPIC_SECONDARY)); in mpic_cascade()
1173 virq = mpic_get_one_irq(mpic); in mpic_cascade()
1186 static u32 fsl_mpic_get_version(struct mpic *mpic) in fsl_mpic_get_version() argument
1190 if (!(mpic->flags & MPIC_FSL)) in fsl_mpic_get_version()
1193 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs, in fsl_mpic_get_version()
1205 struct mpic *mpic = mpic_primary; in fsl_mpic_primary_get_version() local
1207 if (mpic) in fsl_mpic_primary_get_version()
1208 return fsl_mpic_get_version(mpic); in fsl_mpic_primary_get_version()
1213 struct mpic * __init mpic_alloc(struct device_node *node, in mpic_alloc()
1221 struct mpic *mpic; in mpic_alloc() local
1273 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL); in mpic_alloc()
1274 if (mpic == NULL) in mpic_alloc()
1277 mpic->name = name; in mpic_alloc()
1278 mpic->node = node; in mpic_alloc()
1279 mpic->paddr = phys_addr; in mpic_alloc()
1280 mpic->flags = flags; in mpic_alloc()
1282 mpic->hc_irq = mpic_irq_chip; in mpic_alloc()
1283 mpic->hc_irq.name = name; in mpic_alloc()
1284 if (!(mpic->flags & MPIC_SECONDARY)) in mpic_alloc()
1285 mpic->hc_irq.irq_set_affinity = mpic_set_affinity; in mpic_alloc()
1287 mpic->hc_ht_irq = mpic_irq_ht_chip; in mpic_alloc()
1288 mpic->hc_ht_irq.name = name; in mpic_alloc()
1289 if (!(mpic->flags & MPIC_SECONDARY)) in mpic_alloc()
1290 mpic->hc_ht_irq.irq_set_affinity = mpic_set_affinity; in mpic_alloc()
1294 mpic->hc_ipi = mpic_ipi_chip; in mpic_alloc()
1295 mpic->hc_ipi.name = name; in mpic_alloc()
1298 mpic->hc_tm = mpic_tm_chip; in mpic_alloc()
1299 mpic->hc_tm.name = name; in mpic_alloc()
1301 mpic->num_sources = 0; /* so far */ in mpic_alloc()
1303 if (mpic->flags & MPIC_LARGE_VECTORS) in mpic_alloc()
1308 mpic->timer_vecs[0] = intvec_top - 12; in mpic_alloc()
1309 mpic->timer_vecs[1] = intvec_top - 11; in mpic_alloc()
1310 mpic->timer_vecs[2] = intvec_top - 10; in mpic_alloc()
1311 mpic->timer_vecs[3] = intvec_top - 9; in mpic_alloc()
1312 mpic->timer_vecs[4] = intvec_top - 8; in mpic_alloc()
1313 mpic->timer_vecs[5] = intvec_top - 7; in mpic_alloc()
1314 mpic->timer_vecs[6] = intvec_top - 6; in mpic_alloc()
1315 mpic->timer_vecs[7] = intvec_top - 5; in mpic_alloc()
1316 mpic->ipi_vecs[0] = intvec_top - 4; in mpic_alloc()
1317 mpic->ipi_vecs[1] = intvec_top - 3; in mpic_alloc()
1318 mpic->ipi_vecs[2] = intvec_top - 2; in mpic_alloc()
1319 mpic->ipi_vecs[3] = intvec_top - 1; in mpic_alloc()
1320 mpic->spurious_vec = intvec_top; in mpic_alloc()
1323 psrc = of_get_property(mpic->node, "protected-sources", &psize); in mpic_alloc()
1327 mpic->protected = kcalloc(mapsize, sizeof(long), GFP_KERNEL); in mpic_alloc()
1328 BUG_ON(mpic->protected == NULL); in mpic_alloc()
1332 __set_bit(psrc[i], mpic->protected); in mpic_alloc()
1337 mpic->hw_set = mpic_infos[MPIC_GET_REGSET(mpic->flags)]; in mpic_alloc()
1341 if (mpic->flags & MPIC_BIG_ENDIAN) in mpic_alloc()
1342 mpic->reg_type = mpic_access_mmio_be; in mpic_alloc()
1344 mpic->reg_type = mpic_access_mmio_le; in mpic_alloc()
1351 if (mpic->flags & MPIC_USES_DCR) in mpic_alloc()
1352 mpic->reg_type = mpic_access_dcr; in mpic_alloc()
1354 BUG_ON(mpic->flags & MPIC_USES_DCR); in mpic_alloc()
1358 mpic_map(mpic, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000); in mpic_alloc()
1359 mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); in mpic_alloc()
1361 if (mpic->flags & MPIC_FSL) { in mpic_alloc()
1369 mpic_map(mpic, mpic->paddr, &mpic->thiscpuregs, in mpic_alloc()
1372 fsl_version = fsl_mpic_get_version(mpic); in mpic_alloc()
1388 ret = mpic_setup_error_int(mpic, intvec_top - 13); in mpic_alloc()
1418 if (!(mpic->flags & MPIC_NO_RESET)) { in mpic_alloc()
1420 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_alloc()
1421 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1423 while( mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1429 if (mpic->flags & MPIC_ENABLE_COREINT) in mpic_alloc()
1430 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_alloc()
1431 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1434 if (mpic->flags & MPIC_ENABLE_MCK) in mpic_alloc()
1435 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_alloc()
1436 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_alloc()
1449 mpic_map(mpic, mpic->paddr, &mpic->cpuregs[cpu], in mpic_alloc()
1458 greg_feature = mpic_read(mpic->gregs, MPIC_INFO(GREG_FEATURE_0)); in mpic_alloc()
1470 of_property_read_u32(mpic->node, "last-interrupt-source", &last_irq); in mpic_alloc()
1477 mpic->num_sources = isu_size; in mpic_alloc()
1478 mpic_map(mpic, mpic->paddr, &mpic->isus[0], in mpic_alloc()
1483 mpic->isu_size = isu_size; in mpic_alloc()
1484 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1); in mpic_alloc()
1485 mpic->isu_mask = (1 << mpic->isu_shift) - 1; in mpic_alloc()
1487 mpic->irqhost = irq_domain_add_linear(mpic->node, in mpic_alloc()
1489 &mpic_host_ops, mpic); in mpic_alloc()
1495 if (mpic->irqhost == NULL) in mpic_alloc()
1515 name, vers, (unsigned long long)mpic->paddr, num_possible_cpus()); in mpic_alloc()
1517 mpic->isu_size, mpic->isu_shift, mpic->isu_mask); in mpic_alloc()
1519 mpic->next = mpics; in mpic_alloc()
1520 mpics = mpic; in mpic_alloc()
1522 if (!(mpic->flags & MPIC_SECONDARY)) { in mpic_alloc()
1523 mpic_primary = mpic; in mpic_alloc()
1524 irq_set_default_host(mpic->irqhost); in mpic_alloc()
1527 return mpic; in mpic_alloc()
1534 void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, in mpic_assign_isu() argument
1537 unsigned int isu_first = isu_num * mpic->isu_size; in mpic_assign_isu()
1541 mpic_map(mpic, in mpic_assign_isu()
1542 paddr, &mpic->isus[isu_num], 0, in mpic_assign_isu()
1543 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); in mpic_assign_isu()
1545 if ((isu_first + mpic->isu_size) > mpic->num_sources) in mpic_assign_isu()
1546 mpic->num_sources = isu_first + mpic->isu_size; in mpic_assign_isu()
1549 void __init mpic_init(struct mpic *mpic) in mpic_init() argument
1554 BUG_ON(mpic->num_sources == 0); in mpic_init()
1556 printk(KERN_INFO "mpic: Initializing for %d sources\n", mpic->num_sources); in mpic_init()
1561 if (mpic->flags & MPIC_FSL) { in mpic_init()
1562 u32 version = fsl_mpic_get_version(mpic); in mpic_init()
1576 unsigned int offset = mpic_tm_offset(mpic, i); in mpic_init()
1578 mpic_write(mpic->tmregs, in mpic_init()
1581 mpic_write(mpic->tmregs, in mpic_init()
1585 (mpic->timer_vecs[0] + i)); in mpic_init()
1589 mpic_test_broken_ipi(mpic); in mpic_init()
1594 (mpic->ipi_vecs[0] + i)); in mpic_init()
1598 DBG("MPIC flags: %x\n", mpic->flags); in mpic_init()
1599 if ((mpic->flags & MPIC_U3_HT_IRQS) && !(mpic->flags & MPIC_SECONDARY)) { in mpic_init()
1600 mpic_scan_ht_pics(mpic); in mpic_init()
1601 mpic_u3msi_init(mpic); in mpic_init()
1604 mpic_pasemi_msi_init(mpic); in mpic_init()
1606 cpu = mpic_processor_id(mpic); in mpic_init()
1608 if (!(mpic->flags & MPIC_NO_RESET)) { in mpic_init()
1609 for (i = 0; i < mpic->num_sources; i++) { in mpic_init()
1615 if (mpic->protected && test_bit(i, mpic->protected)) in mpic_init()
1624 mpic_write(mpic->gregs, MPIC_INFO(GREG_SPURIOUS), mpic->spurious_vec); in mpic_init()
1627 if (!(mpic->flags & MPIC_NO_PTHROU_DIS)) in mpic_init()
1628 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_init()
1629 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_init()
1632 if (mpic->flags & MPIC_NO_BIAS) in mpic_init()
1633 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), in mpic_init()
1634 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) in mpic_init()
1642 mpic->save_data = kmalloc_array(mpic->num_sources, in mpic_init()
1643 sizeof(*mpic->save_data), in mpic_init()
1645 BUG_ON(mpic->save_data == NULL); in mpic_init()
1649 if (mpic->flags & MPIC_SECONDARY) { in mpic_init()
1650 int virq = irq_of_parse_and_map(mpic->node, 0); in mpic_init()
1653 mpic->node, virq); in mpic_init()
1654 irq_set_handler_data(virq, mpic); in mpic_init()
1660 if (mpic->flags & MPIC_FSL_HAS_EIMR) in mpic_init()
1661 mpic_err_int_init(mpic, MPIC_FSL_ERR_INT); in mpic_init()
1666 struct mpic *mpic = mpic_find(irq); in mpic_irq_set_priority() local
1671 if (!mpic) in mpic_irq_set_priority()
1675 if (mpic_is_ipi(mpic, src)) { in mpic_irq_set_priority()
1676 reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) & in mpic_irq_set_priority()
1678 mpic_ipi_write(src - mpic->ipi_vecs[0], in mpic_irq_set_priority()
1680 } else if (mpic_is_tm(mpic, src)) { in mpic_irq_set_priority()
1681 reg = mpic_tm_read(src - mpic->timer_vecs[0]) & in mpic_irq_set_priority()
1683 mpic_tm_write(src - mpic->timer_vecs[0], in mpic_irq_set_priority()
1697 struct mpic *mpic = mpic_primary; in mpic_setup_this_cpu() local
1702 BUG_ON(mpic == NULL); in mpic_setup_this_cpu()
1704 DBG("%s: setup_this_cpu(%d)\n", mpic->name, hard_smp_processor_id()); in mpic_setup_this_cpu()
1713 if (distribute_irqs && !(mpic->flags & MPIC_SINGLE_DEST_CPU)) { in mpic_setup_this_cpu()
1714 for (i = 0; i < mpic->num_sources ; i++) in mpic_setup_this_cpu()
1728 struct mpic *mpic = mpic_primary; in mpic_cpu_get_priority() local
1735 struct mpic *mpic = mpic_primary; in mpic_cpu_set_priority() local
1743 struct mpic *mpic = mpic_primary; in mpic_teardown_this_cpu() local
1748 BUG_ON(mpic == NULL); in mpic_teardown_this_cpu()
1750 DBG("%s: teardown_this_cpu(%d)\n", mpic->name, hard_smp_processor_id()); in mpic_teardown_this_cpu()
1754 for (i = 0; i < mpic->num_sources ; i++) in mpic_teardown_this_cpu()
1763 mpic_eoi(mpic); in mpic_teardown_this_cpu()
1769 static unsigned int _mpic_get_one_irq(struct mpic *mpic, int reg) in _mpic_get_one_irq() argument
1775 DBG("%s: get_one_irq(reg 0x%x): %d\n", mpic->name, reg, src); in _mpic_get_one_irq()
1777 if (unlikely(src == mpic->spurious_vec)) { in _mpic_get_one_irq()
1778 if (mpic->flags & MPIC_SPV_EOI) in _mpic_get_one_irq()
1779 mpic_eoi(mpic); in _mpic_get_one_irq()
1782 if (unlikely(mpic->protected && test_bit(src, mpic->protected))) { in _mpic_get_one_irq()
1784 mpic->name, (int)src); in _mpic_get_one_irq()
1785 mpic_eoi(mpic); in _mpic_get_one_irq()
1789 return irq_linear_revmap(mpic->irqhost, src); in _mpic_get_one_irq()
1792 unsigned int mpic_get_one_irq(struct mpic *mpic) in mpic_get_one_irq() argument
1794 return _mpic_get_one_irq(mpic, MPIC_INFO(CPU_INTACK)); in mpic_get_one_irq()
1799 struct mpic *mpic = mpic_primary; in mpic_get_irq() local
1801 BUG_ON(mpic == NULL); in mpic_get_irq()
1803 return mpic_get_one_irq(mpic); in mpic_get_irq()
1809 struct mpic *mpic = mpic_primary; in mpic_get_coreint_irq() local
1812 BUG_ON(mpic == NULL); in mpic_get_coreint_irq()
1816 if (unlikely(src == mpic->spurious_vec)) { in mpic_get_coreint_irq()
1817 if (mpic->flags & MPIC_SPV_EOI) in mpic_get_coreint_irq()
1818 mpic_eoi(mpic); in mpic_get_coreint_irq()
1821 if (unlikely(mpic->protected && test_bit(src, mpic->protected))) { in mpic_get_coreint_irq()
1823 mpic->name, (int)src); in mpic_get_coreint_irq()
1827 return irq_linear_revmap(mpic->irqhost, src); in mpic_get_coreint_irq()
1835 struct mpic *mpic = mpic_primary; in mpic_get_mcirq() local
1837 BUG_ON(mpic == NULL); in mpic_get_mcirq()
1839 return _mpic_get_one_irq(mpic, MPIC_INFO(CPU_MCACK)); in mpic_get_mcirq()
1845 struct mpic *mpic = mpic_primary; in mpic_request_ipis() local
1847 BUG_ON(mpic == NULL); in mpic_request_ipis()
1852 unsigned int vipi = irq_create_mapping(mpic->irqhost, in mpic_request_ipis()
1853 mpic->ipi_vecs[0] + i); in mpic_request_ipis()
1864 struct mpic *mpic = mpic_primary; in smp_mpic_message_pass() local
1867 BUG_ON(mpic == NULL); in smp_mpic_message_pass()
1877 DBG("%s: send_ipi(ipi_no: %d)\n", mpic->name, msg); in smp_mpic_message_pass()
1907 struct mpic *mpic = mpic_primary; in mpic_reset_core() local
1913 pir = mpic_read(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT)); in mpic_reset_core()
1915 mpic_write(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT), pir); in mpic_reset_core()
1916 mpic_read(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT)); in mpic_reset_core()
1920 mpic_write(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT), pir); in mpic_reset_core()
1921 mpic_read(mpic->gregs, MPIC_INFO(GREG_PROCESSOR_INIT)); in mpic_reset_core()
1925 if (mpic->flags & MPIC_FSL) { in mpic_reset_core()
1927 _mpic_write(mpic->reg_type, &mpic->cpuregs[cpuid], in mpic_reset_core()
1935 static void mpic_suspend_one(struct mpic *mpic) in mpic_suspend_one() argument
1939 for (i = 0; i < mpic->num_sources; i++) { in mpic_suspend_one()
1940 mpic->save_data[i].vecprio = in mpic_suspend_one()
1942 mpic->save_data[i].dest = in mpic_suspend_one()
1949 struct mpic *mpic = mpics; in mpic_suspend() local
1951 while (mpic) { in mpic_suspend()
1952 mpic_suspend_one(mpic); in mpic_suspend()
1953 mpic = mpic->next; in mpic_suspend()
1959 static void mpic_resume_one(struct mpic *mpic) in mpic_resume_one() argument
1963 for (i = 0; i < mpic->num_sources; i++) { in mpic_resume_one()
1965 mpic->save_data[i].vecprio); in mpic_resume_one()
1967 mpic->save_data[i].dest); in mpic_resume_one()
1970 if (mpic->fixups) { in mpic_resume_one()
1971 struct mpic_irq_fixup *fixup = &mpic->fixups[i]; in mpic_resume_one()
1975 if ((mpic->save_data[i].fixup_data & 1) == 0) in mpic_resume_one()
1981 writel(mpic->save_data[i].fixup_data & ~1, in mpic_resume_one()
1991 struct mpic *mpic = mpics; in mpic_resume() local
1993 while (mpic) { in mpic_resume()
1994 mpic_resume_one(mpic); in mpic_resume()
1995 mpic = mpic->next; in mpic_resume()