Lines Matching +full:dma +full:- +full:window
1 /*-
2 * SPDX-License-Identifier: ISC
22 * BCM2838-compatible PCI-express controller.
95 * is 8 GiB). However, the system DMA controller is capable of accessing only a
96 * limited portion of the address space. Worse, the PCI-e controller has further
97 * constraints for DMA, and those limitations are not wholly clear to the
98 * author. NetBSD and Linux allow DMA on the lower 3 GiB of the physical memory,
99 * but experimentation shows DMA performed above 960 MiB results in data
108 #define REG_VALUE_DMA_WINDOW_LOW (MAX_MEMORY_LOG2 - 0xf)
112 (((MAX_MEMORY_LOG2 - 0xf) << 0x1b) | DMA_WINDOW_ENABLE)
135 {"brcm,bcm2711-pcie", 1},
136 {"brcm,bcm7211-pcie", 1},
137 {"brcm,bcm7445-pcie", 1},
148 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
152 "BCM2838-compatible PCI-express controller");
162 return (sc->dmat);
169 bus_write_4(sc->base.base.res, reg, htole32(val));
176 return (le32toh(bus_read_4(sc->base.base.res, reg)));
221 ranges = &sc->base.base.ranges[0];
223 /* The first range needs to be non-zero. */
270 * Config for an end point is only available through a narrow window for
272 * we want, then access it through the window.
279 * through the zero-offset.
295 if ((bus < sc->base.base.bus_start) || (bus > sc->base.base.bus_end))
324 mtx_lock(&sc->config_mtx);
329 data = bus_read_1(sc->base.base.res, offset);
332 data = le16toh(bus_read_2(sc->base.base.res, offset));
335 data = le32toh(bus_read_4(sc->base.base.res, offset));
342 mtx_unlock(&sc->config_mtx);
357 mtx_lock(&sc->config_mtx);
362 bus_write_1(sc->base.base.res, offset, val);
365 bus_write_2(sc->base.base.res, offset, htole16(val));
368 bus_write_4(sc->base.base.res, offset, htole32(val));
374 mtx_unlock(&sc->config_mtx);
385 irq = bit - 1;
394 irqsrc = &sc->msi_isrcs[irq];
395 if (intr_isrc_dispatch(&irqsrc->isrc, tf))
396 device_printf(sc->dev,
413 tf = curthread->td_intr_frame;
429 mtx_lock(&sc->msi_mtx);
431 /* Find a continguous region of free message-signalled interrupts. */
434 if (sc->msi_isrcs[i].allocated)
443 mtx_unlock(&sc->msi_mtx);
451 sc->msi_isrcs[i + first_int].allocated = true;
452 srcs[i] = &(sc->msi_isrcs[i + first_int].isrc);
455 mtx_unlock(&sc->msi_mtx);
471 *addr = sc->msi_addr;
472 *data = (REG_VALUE_MSI_CONFIG & 0xffff) | msi_msg->irq;
485 mtx_lock(&sc->msi_mtx);
489 msi_isrc->allocated = false;
492 mtx_unlock(&sc->msi_mtx);
505 sc->msi_addr = 0xffffffffc;
511 sc->msi_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
513 if (sc->msi_irq_res == NULL) {
518 sc->msi_isrcs = malloc(sizeof(*sc->msi_isrcs) * NUM_MSI, M_DEVBUF,
521 error = bus_setup_intr(dev, sc->msi_irq_res, INTR_TYPE_BIO |
522 INTR_MPSAFE, bcm_pcib_msi_intr, NULL, sc, &sc->msi_intr_cookie);
530 sc->msi_isrcs[i].irq = i;
531 error = intr_isrc_register(&sc->msi_isrcs[i].isrc, dev, 0,
548 mtx_init(&sc->msi_mtx, "bcm_pcib: msi_mtx", NULL, MTX_DEF);
551 bcm_pcib_set_reg(sc, REG_MSI_ADDR_LOW, (sc->msi_addr & 0xffffffff) | 1);
552 bcm_pcib_set_reg(sc, REG_MSI_ADDR_HIGH, (sc->msi_addr >> 32));
562 * In principle an out-of-bounds bridge window could be automatically
563 * adjusted at resource-activation time to lie within the bus address
565 * out-of-bounds resource allocation fails at allocation time. Instead,
566 * we will just fix up the window on the controller here, before it is
567 * re-discovered by pcib_probe_windows().
580 size = PCI_PPBMEMLIMIT(0, val) - base;
582 new_base = sc->base.base.ranges[0].pci_base;
596 ((phys_base + size - 1) & 0xfff00000));
610 return (((phys_base + size - 1) >> 0x20) & 0xff);
623 sc->dev = dev;
639 &sc->dmat);
651 mtx_init(&sc->config_mtx, "bcm_pcib: config_mtx", NULL, MTX_DEF);
660 * Set PCI->CPU memory window. This encodes the inbound window showing
700 * Set the CPU->PCI memory window. The map in this direction is not 1:1.
702 * controller as they pass through the window.
704 pci_base = sc->base.base.ranges[0].pci_base;
705 phys_base = sc->base.base.ranges[0].phys_base;
706 size = sc->base.base.ranges[0].size;
728 if (ofw_bus_has_prop(dev, "brcm,enable-l1ss")) {
731 "property brcm,enable-l1ss\n");