Lines Matching +full:used +full:- +full:by +full:- +full:rtas
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
48 #include <machine/rtas.h>
57 #include "phyp-hvcall.h"
60 #define XICP_PRIORITY 5 /* Random non-zero number */
62 #define MAX_XICP_IRQS (1<<24) /* 24-bit XIRR field */
124 /* XXX: inefficient -- hash table? tree? */
149 * real address by nature that the bus width is smaller than 64-bits. Placing
156 EARLY_DRIVER_MODULE(xicp, ofwbus, xicp_driver, 0, 0, BUS_PASS_INTERRUPT - 1);
171 if (cpu >= sc->cpu_range[0] && cpu < sc->cpu_range[1]) in xicp_mem_for_cpu()
172 return (sc->mem[cpu - sc->cpu_range[0]]); in xicp_mem_for_cpu()
183 if (!ofw_bus_is_compatible(dev, "ibm,ppc-xicp") && in xicp_probe()
184 !ofw_bus_is_compatible(dev, "ibm,opal-intc")) in xicp_probe()
195 if (!ofw_bus_is_compatible(dev, "ibm,ppc-xics") && in xics_probe()
196 !ofw_bus_is_compatible(dev, "IBM,opal-xics")) in xics_probe()
210 sc->ibm_int_on = rtas_token_lookup("ibm,int-on"); in xicp_attach()
211 sc->ibm_int_off = rtas_token_lookup("ibm,int-off"); in xicp_attach()
212 sc->ibm_set_xive = rtas_token_lookup("ibm,set-xive"); in xicp_attach()
213 sc->ibm_get_xive = rtas_token_lookup("ibm,get-xive"); in xicp_attach()
219 device_printf(dev, "Cannot attach without RTAS or OPAL\n"); in xicp_attach()
223 if (OF_hasprop(phandle, "ibm,interrupt-server-ranges")) { in xicp_attach()
224 OF_getencprop(phandle, "ibm,interrupt-server-ranges", in xicp_attach()
225 sc->cpu_range, sizeof(sc->cpu_range)); in xicp_attach()
226 sc->cpu_range[1] += sc->cpu_range[0]; in xicp_attach()
227 device_printf(dev, "Handling CPUs %d-%d\n", sc->cpu_range[0], in xicp_attach()
228 sc->cpu_range[1]-1); in xicp_attach()
230 } else if (ofw_bus_is_compatible(dev, "ibm,opal-intc")) { in xicp_attach()
235 sc->xics_emu = true; in xicp_attach()
239 sc->cpu_range[0] = 0; in xicp_attach()
240 sc->cpu_range[1] = mp_ncpus; in xicp_attach()
247 if (sc->xics_emu) { in xicp_attach()
251 pcpu_find(i)->pc_hwref, 0xff); in xicp_attach()
254 for (i = 0; i < sc->cpu_range[1] - sc->cpu_range[0]; i++) { in xicp_attach()
255 sc->mem[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in xicp_attach()
257 if (sc->mem[i] == NULL) { in xicp_attach()
264 bus_write_1(sc->mem[i], 4, 0xff); in xicp_attach()
265 bus_write_1(sc->mem[i], 12, 0xff); in xicp_attach()
271 mtx_init(&sc->sc_mtx, "XICP", NULL, MTX_DEF); in xicp_attach()
272 sc->nintvecs = 0; in xicp_attach()
279 if (sc->xics_emu) in xicp_attach()
302 KASSERT(sc->nintvecs + 1 < nitems(sc->intvecs), in xicp_setup_priv()
304 mtx_lock(&sc->sc_mtx); in xicp_setup_priv()
305 *priv = &sc->intvecs[sc->nintvecs++]; in xicp_setup_priv()
306 mtx_unlock(&sc->sc_mtx); in xicp_setup_priv()
322 int ncpus, i, error = -1; in xicp_bind()
348 cpu = pcpu_find(cpu)->pc_hwref; in xicp_bind()
349 iv->cpu = cpu; in xicp_bind()
352 error = rtas_call_method(sc->ibm_set_xive, 3, 1, irq, cpu, in xicp_bind()
373 if ((mfmsr() & PSL_HV) && !sc->xics_emu) { in xicp_dispatch()
385 } else if (sc->xics_emu) { in xicp_dispatch()
406 else if (sc->xics_emu) in xicp_dispatch()
413 i = sc->ipi_vec; in xicp_dispatch()
416 for (i = 0; i < sc->nintvecs; i++) { in xicp_dispatch()
417 if (sc->intvecs[i].irq == xirr) in xicp_dispatch()
420 KASSERT(i < sc->nintvecs, ("Unmapped XIRR")); in xicp_dispatch()
423 powerpc_dispatch_intr(sc->intvecs[i].vector, tf); in xicp_dispatch()
441 intr->irq = irq; in xicp_enable()
442 intr->vector = vector; in xicp_enable()
443 intr->cpu = cpu; in xicp_enable()
448 sc->ipi_vec = intr - sc->intvecs; in xicp_enable()
453 rtas_call_method(sc->ibm_set_xive, 3, 1, irq, cpu, in xicp_enable()
462 panic("OPAL_SET_XIVE IRQ %d -> cpu %d failed: %d", irq, in xicp_enable()
483 if (sc->xics_emu) in xicp_eoi()
498 cpu = pcpu_find(cpu)->pc_hwref; in xicp_ipi()
502 if (sc->xics_emu) { in xicp_ipi()
524 rtas_call_method(sc->ibm_int_off, 1, 1, irq, &status); in xicp_mask()
530 opal_call(OPAL_SET_XIVE, irq, ivec->cpu << 2, 0xff); in xicp_mask()
545 rtas_call_method(sc->ibm_int_on, 1, 1, irq, &status); in xicp_unmask()
551 opal_call(OPAL_SET_XIVE, irq, ivec->cpu << 2, XICP_PRIORITY); in xicp_unmask()
557 /* This is only used on POWER9 systems with the XIVE's XICS emulation. */
566 if (sc->xics_emu) in xicp_smp_cpu_startup()