// SPDX-License-Identifier: GPL-2.0-or-later /* * Support for the interrupt controllers found on Power Macintosh, * currently Apple's "Grand Central" interrupt controller in all * its incarnations. OpenPIC support used on newer machines is * in a separate file * * Copyright (C) 1997 Paul Mackerras (paulus@samba.org) * Copyright (C) 2005 Benjamin Herrenschmidt (benh@kernel.crashing.org) * IBM, Corp.
*/
/* The max irq number this driver deals with is 128; see max_irqs */ static DECLARE_BITMAP(ppc_lost_interrupts, 128); static DECLARE_BITMAP(ppc_cached_irq_mask, 128); staticint pmac_irq_cascade = -1; staticstruct irq_domain *pmac_pic_host;
do { /* make sure mask gets to controller before we
return to user */
mb();
} while((in_le32(&pmac_irq_hw[i]->enable) & bit)
!= (ppc_cached_irq_mask[i] & bit));
/* * Unfortunately, setting the bit in the enable register * when the device interrupt is already on *doesn't* set * the bit in the flag register or request another interrupt.
*/ if (bit & ppc_cached_irq_mask[i] & in_le32(&pmac_irq_hw[i]->level))
__pmac_retrigger(irq_nr);
}
/* When an irq gets requested for the first client, if it's an * edge interrupt, we clear any previous one on the controller
*/ staticunsignedint pmac_startup_irq(struct irq_data *d)
{ unsignedlong flags; unsignedint src = irqd_to_hwirq(d); unsignedlong bit = 1UL << (src & 0x1f); int i = src >> 5;
#ifdef CONFIG_PPC_PMAC32_PSURGE /* IPI's are a hack on the powersurge -- Cort */ if (smp_processor_id() != 0) { return psurge_secondary_virq;
} #endif/* CONFIG_PPC_PMAC32_PSURGE */
raw_spin_lock_irqsave(&pmac_pic_lock, flags); for (irq = max_real_irqs; (irq -= 32) >= 0; ) { int i = irq >> 5;
bits = in_le32(&pmac_irq_hw[i]->event) | ppc_lost_interrupts[i];
bits |= in_le32(&pmac_irq_hw[i]->level);
bits &= ppc_cached_irq_mask[i]; if (bits == 0) continue;
irq += __ilog2(bits); break;
}
raw_spin_unlock_irqrestore(&pmac_pic_lock, flags); if (unlikely(irq < 0)) return 0; return irq_find_mapping(pmac_pic_host, irq);
}
staticint pmac_pic_host_match(struct irq_domain *h, struct device_node *node, enum irq_domain_bus_token bus_token)
{ /* We match all, we don't always have a node anyway */ return 1;
}
/* Mark level interrupts, set delayed disable for edge ones and set * handlers
*/
irq_set_status_flags(virq, IRQ_LEVEL);
irq_set_chip_and_handler(virq, &pmac_pic, handle_level_irq); return 0;
}
printk(KERN_INFO "irq: Found slave Apple PIC %pOF for %d irqs" " cascade: %d\n", slave,
max_irqs - max_real_irqs, pmac_irq_cascade);
}
of_node_put(slave);
/* Disable all interrupts in all controllers */ for (i = 0; i * 32 < max_irqs; ++i)
out_le32(&pmac_irq_hw[i]->enable, 0);
/* Hookup cascade irq */ if (slave && pmac_irq_cascade) { if (request_irq(pmac_irq_cascade, gatwick_action,
IRQF_NO_THREAD, "cascade", NULL))
pr_err("Failed to register cascade interrupt\n");
}
printk(KERN_INFO "irq: System has %d possible interrupts\n", max_irqs); #ifdef CONFIG_XMON
i = irq_create_mapping(NULL, 20); if (request_irq(i, xmon_irq, IRQF_NO_THREAD, "NMI - XMON", NULL))
pr_err("Failed to register NMI-XMON interrupt\n"); #endif
}
int of_irq_parse_oldworld(conststruct device_node *device, int index, struct of_phandle_args *out_irq)
{ const u32 *ints = NULL; int intlen;
/* * Old machines just have a list of interrupt numbers * and no interrupt-controller nodes. We also have dodgy * cases where the APPL,interrupts property is completely * missing behind pci-pci bridges and we have to get it * from the parent (the bridge itself, as apple just wired * everything together on these)
*/ while (device) {
ints = of_get_property(device, "AAPL,interrupts", &intlen); if (ints != NULL) break;
device = device->parent; if (!of_node_is_type(device, "pci")) break;
} if (ints == NULL) return -EINVAL;
intlen /= sizeof(u32);
if (of_property_read_bool(np, "big-endian"))
flags |= MPIC_BIG_ENDIAN;
/* Primary Big Endian means HT interrupts. This is quite dodgy * but works until I find a better way
*/ if (master && (flags & MPIC_BIG_ENDIAN))
flags |= MPIC_U3_HT_IRQS;
/* Install NMI if any */
pmac_pic_setup_mpic_nmi(mpic1);
of_node_put(master);
/* Set up a cascaded controller, if present */ if (slave) {
mpic2 = pmac_setup_one_mpic(slave, 0); if (mpic2 == NULL)
printk(KERN_ERR "Failed to setup slave MPIC\n");
of_node_put(slave);
}
return 0;
}
void __init pmac_pic_init(void)
{ /* We configure the OF parsing based on our oldworld vs. newworld * platform type and whether we were booted by BootX.
*/ #ifdef CONFIG_PPC32 if (!pmac_newworld)
of_irq_workarounds |= OF_IMAP_OLDWORLD_MAC; if (of_property_read_bool(of_chosen, "linux,bootx"))
of_irq_workarounds |= OF_IMAP_NO_PHANDLE;
/* If we don't have phandles on a newworld, then try to locate a * default interrupt controller (happens when booting with BootX). * We do a first match here, hopefully, that only ever happens on * machines with one controller.
*/ if (pmac_newworld && (of_irq_workarounds & OF_IMAP_NO_PHANDLE)) { struct device_node *np;
for_each_node_with_property(np, "interrupt-controller") { /* Skip /chosen/interrupt-controller */ if (of_node_name_eq(np, "chosen")) continue; /* It seems like at least one person wants * to use BootX on a machine with an AppleKiwi * controller which happens to pretend to be an
* interrupt controller too. */ if (of_node_name_eq(np, "AppleKiwi")) continue; /* I think we found one ! */
of_irq_dflt_pic = np; break;
}
} #endif/* CONFIG_PPC32 */
/* We first try to detect Apple's new Core99 chipset, since mac-io * is quite different on those machines and contains an IBM MPIC2.
*/ if (pmac_pic_probe_mpic() == 0) return;
#ifdefined(CONFIG_PM) && defined(CONFIG_PPC32) /* * These procedures are used in implementing sleep on the powerbooks. * sleep_save_intrs() saves the states of all interrupt enables * and disables all interrupts except for the nominated one. * sleep_restore_intrs() restores the states of all interrupt enables.
*/ unsignedlong sleep_save_mask[2];
/* This used to be passed by the PMU driver but that link got * broken with the new driver model. We use this tweak for now... * We really want to do things differently though...
*/ staticint pmacpic_find_viaint(void)
{ int viaint = -1;
staticint pmacpic_suspend(void)
{ int viaint = pmacpic_find_viaint();
sleep_save_mask[0] = ppc_cached_irq_mask[0];
sleep_save_mask[1] = ppc_cached_irq_mask[1];
ppc_cached_irq_mask[0] = 0;
ppc_cached_irq_mask[1] = 0; if (viaint > 0)
set_bit(viaint, ppc_cached_irq_mask);
out_le32(&pmac_irq_hw[0]->enable, ppc_cached_irq_mask[0]); if (max_real_irqs > 32)
out_le32(&pmac_irq_hw[1]->enable, ppc_cached_irq_mask[1]);
(void)in_le32(&pmac_irq_hw[0]->event); /* make sure mask gets to controller before we return to caller */
mb();
(void)in_le32(&pmac_irq_hw[0]->enable);
return 0;
}
staticvoid pmacpic_resume(void)
{ int i;
out_le32(&pmac_irq_hw[0]->enable, 0); if (max_real_irqs > 32)
out_le32(&pmac_irq_hw[1]->enable, 0);
mb(); for (i = 0; i < max_real_irqs; ++i) if (test_bit(i, sleep_save_mask))
pmac_unmask_irq(irq_get_irq_data(i));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.