Lines Matching +full:child +full:- +full:interrupt +full:- +full:base
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
8 * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
98 { -1, 0 }
113 reg = bus_read_4(sc->res, XLNX_PCIE_RPERRFRR); in xlnx_pcib_clear_err_interrupts()
116 device_printf(sc->dev, "Requested ID: %x\n", in xlnx_pcib_clear_err_interrupts()
118 bus_write_4(sc->res, XLNX_PCIE_RPERRFRR, ~0U); in xlnx_pcib_clear_err_interrupts()
131 fdt_sc = &xlnx_sc->fdt_sc; in xlnx_pcib_intr()
132 sc = &fdt_sc->base; in xlnx_pcib_intr()
134 val = bus_read_4(sc->res, XLNX_PCIE_IDR); in xlnx_pcib_intr()
135 mask = bus_read_4(sc->res, XLNX_PCIE_IMR); in xlnx_pcib_intr()
142 device_printf(sc->dev, "Link down"); in xlnx_pcib_intr()
145 device_printf(sc->dev, "Hot reset"); in xlnx_pcib_intr()
157 device_printf(sc->dev, "MSI interrupt"); in xlnx_pcib_intr()
163 device_printf(sc->dev, "INTx received"); in xlnx_pcib_intr()
169 device_printf(sc->dev, "Slave unsupported request"); in xlnx_pcib_intr()
172 device_printf(sc->dev, "Slave unexpected completion"); in xlnx_pcib_intr()
175 device_printf(sc->dev, "Slave completion timeout"); in xlnx_pcib_intr()
178 device_printf(sc->dev, "Slave error poison"); in xlnx_pcib_intr()
181 device_printf(sc->dev, "Slave completion abort"); in xlnx_pcib_intr()
184 device_printf(sc->dev, "Slave illegal burst"); in xlnx_pcib_intr()
187 device_printf(sc->dev, "Master decode error"); in xlnx_pcib_intr()
190 device_printf(sc->dev, "Master slave error"); in xlnx_pcib_intr()
192 bus_write_4(sc->res, XLNX_PCIE_IDR, val); in xlnx_pcib_intr()
210 fdt_sc = &xlnx_sc->fdt_sc; in xlnx_pcib_handle_msi_intr()
211 sc = &fdt_sc->base; in xlnx_pcib_handle_msi_intr()
212 tf = curthread->td_intr_frame; in xlnx_pcib_handle_msi_intr()
215 reg = bus_read_4(sc->res, msireg); in xlnx_pcib_handle_msi_intr()
219 bus_write_4(sc->res, msireg, (1 << i)); in xlnx_pcib_handle_msi_intr()
225 xi = &xlnx_sc->isrcs[irq]; in xlnx_pcib_handle_msi_intr()
226 if (intr_isrc_dispatch(&xi->isrc, tf) != 0) { in xlnx_pcib_handle_msi_intr()
228 xlnx_pcib_msi_mask(sc->dev, in xlnx_pcib_handle_msi_intr()
229 &xi->isrc, 1); in xlnx_pcib_handle_msi_intr()
230 device_printf(sc->dev, in xlnx_pcib_handle_msi_intr()
263 sc->isrcs = malloc(sizeof(*sc->isrcs) * XLNX_PCIB_MAX_MSI, M_DEVBUF, in xlnx_pcib_register_msi()
266 name = device_get_nameunit(sc->dev); in xlnx_pcib_register_msi()
269 sc->isrcs[irq].irq = irq; in xlnx_pcib_register_msi()
270 error = intr_isrc_register(&sc->isrcs[irq].isrc, in xlnx_pcib_register_msi()
271 sc->dev, 0, "%s,%u", name, irq); in xlnx_pcib_register_msi()
276 if (intr_msi_register(sc->dev, in xlnx_pcib_register_msi()
277 OF_xref_from_node(ofw_bus_get_node(sc->dev))) != 0) in xlnx_pcib_register_msi()
290 bus_write_4(sc->res[0], XLNX_PCIE_IMR, 0); in xlnx_pcib_init()
293 reg = bus_read_4(sc->res[0], XLNX_PCIE_IDR); in xlnx_pcib_init()
294 bus_write_4(sc->res[0], XLNX_PCIE_IDR, reg); in xlnx_pcib_init()
297 sc->msi_page = kmem_alloc_contig(PAGE_SIZE, M_WAITOK, 0, in xlnx_pcib_init()
299 addr = vtophys(sc->msi_page); in xlnx_pcib_init()
300 bus_write_4(sc->res[0], XLNX_PCIE_RPMSIBR1, (addr >> 32)); in xlnx_pcib_init()
301 bus_write_4(sc->res[0], XLNX_PCIE_RPMSIBR2, (addr >> 0)); in xlnx_pcib_init()
304 reg = bus_read_4(sc->res[0], XLNX_PCIE_RPSCR); in xlnx_pcib_init()
306 bus_write_4(sc->res[0], XLNX_PCIE_RPSCR, reg); in xlnx_pcib_init()
326 bus_write_4(sc->res[0], XLNX_PCIE_IMR, reg); in xlnx_pcib_init()
336 if (ofw_bus_is_compatible(dev, "xlnx,xdma-host-3.00")) { in xlnx_pcib_fdt_probe()
351 sc->dev = dev; in xlnx_pcib_fdt_attach()
353 mtx_init(&sc->mtx, "msi_mtx", NULL, MTX_DEF); in xlnx_pcib_fdt_attach()
355 if (bus_alloc_resources(dev, xlnx_pcib_spec, sc->res)) { in xlnx_pcib_fdt_attach()
360 /* Setup MISC interrupt handler. */ in xlnx_pcib_fdt_attach()
361 error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE, in xlnx_pcib_fdt_attach()
362 xlnx_pcib_intr, NULL, sc, &sc->intr_cookie[0]); in xlnx_pcib_fdt_attach()
364 device_printf(dev, "could not setup interrupt handler.\n"); in xlnx_pcib_fdt_attach()
368 /* Setup MSI0 interrupt handler. */ in xlnx_pcib_fdt_attach()
369 error = bus_setup_intr(dev, sc->res[2], INTR_TYPE_MISC | INTR_MPSAFE, in xlnx_pcib_fdt_attach()
370 xlnx_pcib_msi0_intr, NULL, sc, &sc->intr_cookie[1]); in xlnx_pcib_fdt_attach()
372 device_printf(dev, "could not setup interrupt handler.\n"); in xlnx_pcib_fdt_attach()
376 /* Setup MSI1 interrupt handler. */ in xlnx_pcib_fdt_attach()
377 error = bus_setup_intr(dev, sc->res[3], INTR_TYPE_MISC | INTR_MPSAFE, in xlnx_pcib_fdt_attach()
378 xlnx_pcib_msi1_intr, NULL, sc, &sc->intr_cookie[2]); in xlnx_pcib_fdt_attach()
380 device_printf(dev, "could not setup interrupt handler.\n"); in xlnx_pcib_fdt_attach()
390 bus_release_resources(dev, xlnx_pcib_spec, sc->res); in xlnx_pcib_fdt_attach()
400 xlnx_pcib_fdt_get_id(device_t pci, device_t child, enum pci_id_type type, in xlnx_pcib_fdt_get_id() argument
407 return (pcib_get_id(pci, child, type, id)); in xlnx_pcib_fdt_get_id()
410 if (OF_hasprop(node, "msi-map")) in xlnx_pcib_fdt_get_id()
411 return (generic_pcie_get_id(pci, child, type, id)); in xlnx_pcib_fdt_get_id()
413 bsf = pci_get_rid(child); in xlnx_pcib_fdt_get_id()
414 *id = (pci_get_domain(child) << PCI_RID_DOMAIN_SHIFT) | bsf; in xlnx_pcib_fdt_get_id()
427 t = sc->bst; in xlnx_pcib_req_valid()
428 h = sc->bsh; in xlnx_pcib_req_valid()
430 if ((bus < sc->bus_start) || (bus > sc->bus_end)) in xlnx_pcib_req_valid()
463 fdt_sc = &xlnx_sc->fdt_sc; in xlnx_pcib_read_config()
464 sc = &fdt_sc->base; in xlnx_pcib_read_config()
469 offset = PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, reg); in xlnx_pcib_read_config()
470 t = sc->bst; in xlnx_pcib_read_config()
471 h = sc->bsh; in xlnx_pcib_read_config()
507 fdt_sc = &xlnx_sc->fdt_sc; in xlnx_pcib_write_config()
508 sc = &fdt_sc->base; in xlnx_pcib_write_config()
513 offset = PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, reg); in xlnx_pcib_write_config()
515 t = sc->bst; in xlnx_pcib_write_config()
516 h = sc->bsh; in xlnx_pcib_write_config()
519 * 32-bit access used due to a bug in the Xilinx bridge that in xlnx_pcib_write_config()
522 * TODO: This is probably wrong on big-endian. in xlnx_pcib_write_config()
546 xlnx_pcib_alloc_msi(device_t pci, device_t child, int count, int maxcount, in xlnx_pcib_alloc_msi() argument
551 ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, in xlnx_pcib_alloc_msi()
554 return (intr_alloc_msi(pci, child, msi_parent, count, maxcount, in xlnx_pcib_alloc_msi()
559 xlnx_pcib_release_msi(device_t pci, device_t child, int count, int *irqs) in xlnx_pcib_release_msi() argument
563 ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, in xlnx_pcib_release_msi()
566 return (intr_release_msi(pci, child, msi_parent, count, irqs)); in xlnx_pcib_release_msi()
570 xlnx_pcib_map_msi(device_t pci, device_t child, int irq, uint64_t *addr, in xlnx_pcib_map_msi() argument
575 ofw_bus_msimap(ofw_bus_get_node(pci), pci_get_rid(child), &msi_parent, in xlnx_pcib_map_msi()
578 return (intr_map_msi(pci, child, msi_parent, irq, addr, data)); in xlnx_pcib_map_msi()
582 xlnx_pcib_msi_alloc_msi(device_t dev, device_t child, int count, int maxcount, in xlnx_pcib_msi_alloc_msi() argument
591 mtx_lock(&sc->mtx); in xlnx_pcib_msi_alloc_msi()
595 for (irq = 0; (irq + count - 1) < XLNX_PCIB_MAX_MSI; irq++) { in xlnx_pcib_msi_alloc_msi()
601 if (sc->isrcs[end_irq].flags & XLNX_IRQ_FLAG_USED) { in xlnx_pcib_msi_alloc_msi()
612 if (!found || irq == (XLNX_PCIB_MAX_MSI - 1)) { in xlnx_pcib_msi_alloc_msi()
614 mtx_unlock(&sc->mtx); in xlnx_pcib_msi_alloc_msi()
618 /* Mark the interrupt as used. */ in xlnx_pcib_msi_alloc_msi()
620 sc->isrcs[irq + i].flags |= XLNX_IRQ_FLAG_USED; in xlnx_pcib_msi_alloc_msi()
622 mtx_unlock(&sc->mtx); in xlnx_pcib_msi_alloc_msi()
625 srcs[i] = (struct intr_irqsrc *)&sc->isrcs[irq + i]; in xlnx_pcib_msi_alloc_msi()
633 xlnx_pcib_msi_release_msi(device_t dev, device_t child, int count, in xlnx_pcib_msi_release_msi() argument
641 mtx_lock(&sc->mtx); in xlnx_pcib_msi_release_msi()
645 KASSERT(xi->flags & XLNX_IRQ_FLAG_USED, in xlnx_pcib_msi_release_msi()
646 ("%s: Releasing an unused MSI interrupt", __func__)); in xlnx_pcib_msi_release_msi()
648 xi->flags &= ~XLNX_IRQ_FLAG_USED; in xlnx_pcib_msi_release_msi()
651 mtx_unlock(&sc->mtx); in xlnx_pcib_msi_release_msi()
656 xlnx_pcib_msi_map_msi(device_t dev, device_t child, struct intr_irqsrc *isrc, in xlnx_pcib_msi_map_msi() argument
665 *addr = vtophys(sc->msi_page); in xlnx_pcib_msi_map_msi()
666 *data = xi->irq; in xlnx_pcib_msi_map_msi()
682 fdt_sc = &xlnx_sc->fdt_sc; in xlnx_pcib_msi_mask()
683 sc = &fdt_sc->base; in xlnx_pcib_msi_mask()
687 irq = xi->irq; in xlnx_pcib_msi_mask()
693 reg = bus_read_4(sc->res, msireg); in xlnx_pcib_msi_mask()
698 bus_write_4(sc->res, msireg, reg); in xlnx_pcib_msi_mask()
769 /* Interrupt controller interface */