// SPDX-License-Identifier: GPL-2.0-or-later /* * This file implements an irqchip for OPAL events. Whenever there is * an interrupt that is handled by OPAL we get passed a list of events * that Linux needs to do something about. These basically look like * interrupts to Linux so we implement an irqchip to handle them. * * Copyright Alistair Popple, IBM Corporation 2014.
*/ #include <linux/bitops.h> #include <linux/irq.h> #include <linux/irqchip.h> #include <linux/irqdomain.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> #include <linux/kthread.h> #include <linux/delay.h> #include <linux/slab.h> #include <linux/of_irq.h>
#include <asm/machdep.h> #include <asm/opal.h>
#include"powernv.h"
/* Maximum number of events supported by OPAL firmware */ #define MAX_NUM_EVENTS 64
staticint opal_event_set_type(struct irq_data *d, unsignedint flow_type)
{ /* * For now we only support level triggered events. The irq * handler will be called continuously until the event has * been cleared in OPAL.
*/ if (flow_type != IRQ_TYPE_LEVEL_HIGH) return -EINVAL;
/* First free interrupts, which will also mask them */ for (i = 0; i < opal_irq_count; i++) { if (!opal_irqs || !opal_irqs[i].start) continue;
if (in_interrupt() || irqs_disabled())
disable_irq_nosync(opal_irqs[i].start); else
free_irq(opal_irqs[i].start, NULL);
opal_irqs[i].start = 0;
}
}
int __init opal_event_init(void)
{ struct device_node *dn, *opal_node; bool old_style = false; int i, rc = 0;
opal_node = of_find_node_by_path("/ibm,opal"); if (!opal_node) {
pr_warn("opal: Node not found\n"); return -ENODEV;
}
/* If dn is NULL it means the domain won't be linked to a DT * node so therefore irq_of_parse_and_map(...) wont work. But * that shouldn't be problem because if we're running a * version of skiboot that doesn't have the dn then the * devices won't have the correct properties and will have to * fall back to the legacy method (opal_event_request(...))
* anyway. */
dn = of_find_compatible_node(NULL, NULL, "ibm,opal-event");
opal_event_irqchip.domain = irq_domain_create_linear(of_fwnode_handle(dn),
MAX_NUM_EVENTS,
&opal_event_domain_ops, &opal_event_irqchip);
of_node_put(dn); if (!opal_event_irqchip.domain) {
pr_warn("opal: Unable to create irq domain\n");
rc = -ENOMEM; goto out;
}
/* Absent ? Look for the old one */ if (opal_irq_count < 1) { /* Get opal-interrupts property and names if present */
rc = of_property_count_u32_elems(opal_node, "opal-interrupts"); if (rc > 0)
opal_irq_count = rc;
old_style = true;
}
/* No interrupts ? Bail out */ if (!opal_irq_count) goto out;
pr_debug("OPAL: Found %d interrupts reserved for OPAL using %s scheme\n",
opal_irq_count, old_style ? "old" : "new");
/** * opal_event_request(unsigned int opal_event_nr) - Request an event * @opal_event_nr: the opal event number to request * * This routine can be used to find the linux virq number which can * then be passed to request_irq to assign a handler for a particular * opal event. This should only be used by legacy devices which don't * have proper device tree bindings. Most devices should use * irq_of_parse_and_map() instead.
*/ int opal_event_request(unsignedint opal_event_nr)
{ if (WARN_ON_ONCE(!opal_event_irqchip.domain)) return 0;
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.