/* * Open Multi-Processor Interrupt Controller driver * * Copyright (C) 2014 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> * Copyright (C) 2017 Stafford Horne <shorne@gmail.com> * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of any * kind, whether express or implied. * * The ompic device handles IPI communication between cores in multi-core * OpenRISC systems. * * Registers * * For each CPU the ompic has 2 registers. The control register for sending * and acking IPIs and the status register for receiving IPIs. The register * layouts are as follows: * * Control register * +---------+---------+----------+---------+ * | 31 | 30 | 29 .. 16 | 15 .. 0 | * ----------+---------+----------+---------- * | IRQ ACK | IRQ GEN | DST CORE | DATA | * +---------+---------+----------+---------+ * * Status register * +----------+-------------+----------+---------+ * | 31 | 30 | 29 .. 16 | 15 .. 0 | * -----------+-------------+----------+---------+ * | Reserved | IRQ Pending | SRC CORE | DATA | * +----------+-------------+----------+---------+ * * Architecture * * - The ompic generates a level interrupt to the CPU PIC when a message is * ready. Messages are delivered via the memory bus. * - The ompic does not have any interrupt input lines. * - The ompic is wired to the same irq line on each core. * - Devices are wired to the same irq line on each core. * * +---------+ +---------+ * | CPU | | CPU | * | Core 0 |<==\ (memory access) /==>| Core 1 | * | [ PIC ]| | | | [ PIC ]| * +----^-^--+ | | +----^-^--+ * | | v v | | * <====|=|=================================|=|==> (memory bus) * | | ^ ^ | | * (ipi | +------|---------+--------|-------|-+ (device irq) * irq | | | | | * core0)| +------|---------|--------|-------+ (ipi irq core1) * | | | | | * +----o-o-+ | +--------+ | * | ompic |<===/ | Device |<===/ * | IPI | +--------+ * +--------+* *
*/
/* * On OpenRISC the atomic set_bit() call implies a memory * barrier. Otherwise we would need: smp_wmb(); paired * with the read in ompic_ipi_handler.
*/
/* * On OpenRISC the atomic xchg() call implies a memory * barrier. Otherwise we may need an smp_rmb(); paired * with the write in ompic_raise_softirq.
*/
do { unsignedlong ipi_msg;
ipi_msg = __ffs(ops);
ops &= ~(1UL << ipi_msg);
handle_IPI(ipi_msg);
} while (ops);
}
return IRQ_HANDLED;
}
staticint __init ompic_of_init(struct device_node *node, struct device_node *parent)
{ struct resource res; int irq; int ret;
/* Validate the DT */ if (ompic_base) {
pr_err("ompic: duplicate ompic's are not supported"); return -EEXIST;
}
if (of_address_to_resource(node, 0, &res)) {
pr_err("ompic: reg property requires an address and size"); return -EINVAL;
}
if (resource_size(&res) < (num_possible_cpus() * OMPIC_CPUBYTES)) {
pr_err("ompic: reg size, currently %d must be at least %d",
resource_size(&res),
(num_possible_cpus() * OMPIC_CPUBYTES)); return -EINVAL;
}
/* Setup the device */
ompic_base = ioremap(res.start, resource_size(&res)); if (!ompic_base) {
pr_err("ompic: unable to map registers"); return -ENOMEM;
}
irq = irq_of_parse_and_map(node, 0); if (irq <= 0) {
pr_err("ompic: unable to parse device irq");
ret = -EINVAL; goto out_unmap;
}
ret = request_irq(irq, ompic_ipi_handler, IRQF_PERCPU, "ompic_ipi", NULL); if (ret) goto out_irq_disp;
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.