diff options
Diffstat (limited to 'sys/dev/xilinx')
-rw-r--r-- | sys/dev/xilinx/axi_quad_spi.c | 34 | ||||
-rw-r--r-- | sys/dev/xilinx/axidma.c | 9 | ||||
-rw-r--r-- | sys/dev/xilinx/if_xae.c | 30 |
3 files changed, 54 insertions, 19 deletions
diff --git a/sys/dev/xilinx/axi_quad_spi.c b/sys/dev/xilinx/axi_quad_spi.c index 54f4c6aa8810..86b00473fc96 100644 --- a/sys/dev/xilinx/axi_quad_spi.c +++ b/sys/dev/xilinx/axi_quad_spi.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Ruslan Bukin <br@bsdpad.com> + * Copyright (c) 2016-2025 Ruslan Bukin <br@bsdpad.com> * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -100,6 +100,12 @@ struct spi_softc { void *ih; }; +static struct ofw_compat_data compat_data[] = { + { "xlnx,xps-spi-3.2", 1 }, + { "xlnx,xps-spi-2.00.a", 1 }, + { NULL, 0 } +}; + static struct resource_spec spi_spec[] = { { SYS_RES_MEMORY, 0, RF_ACTIVE }, { -1, 0 } @@ -112,7 +118,7 @@ spi_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "xlnx,xps-spi-3.2")) + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) return (ENXIO); device_set_desc(dev, "Xilinx Quad SPI"); @@ -148,8 +154,9 @@ spi_attach(device_t dev) reg = (CR_MASTER | CR_MSS | CR_SPE); WRITE4(sc, SPI_CR, reg); - device_add_child(dev, "spibus", 0); - return (bus_generic_attach(dev)); + device_add_child(dev, "spibus", DEVICE_UNIT_ANY); + bus_attach_children(dev); + return (0); } static int @@ -211,20 +218,33 @@ spi_transfer(device_t dev, device_t child, struct spi_command *cmd) return (0); } +static phandle_t +axispi_get_node(device_t bus, device_t dev) +{ + + return (ofw_bus_get_node(bus)); +} + static device_method_t spi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, spi_probe), DEVMETHOD(device_attach, spi_attach), + /* ofw_bus_if */ + DEVMETHOD(ofw_bus_get_node, axispi_get_node), + /* SPI interface */ DEVMETHOD(spibus_transfer, spi_transfer), DEVMETHOD_END }; -static driver_t spi_driver = { - "spi", +static driver_t axispi_driver = { + "axispi", spi_methods, sizeof(struct spi_softc), }; -DRIVER_MODULE(spi, simplebus, spi_driver, 0, 0); +DRIVER_MODULE(axispi, simplebus, axispi_driver, 0, 0); +DRIVER_MODULE(ofw_spibus, axispi, ofw_spibus_driver, 0, 0); +MODULE_DEPEND(axispi, ofw_spibus, 1, 1, 1); +SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/dev/xilinx/axidma.c b/sys/dev/xilinx/axidma.c index 5b92f90df683..77a46c712980 100644 --- a/sys/dev/xilinx/axidma.c +++ b/sys/dev/xilinx/axidma.c @@ -169,6 +169,9 @@ axidma_intr(struct axidma_softc *sc, while (chan->idx_tail != chan->idx_head) { desc = chan->descs[chan->idx_tail]; + cpu_dcache_wbinv_range((vm_offset_t)desc, + sizeof(struct axidma_desc)); + if ((desc->status & BD_STATUS_CMPLT) == 0) break; @@ -357,7 +360,8 @@ axidma_desc_alloc(struct axidma_softc *sc, struct xdma_channel *xchan, return (-1); } chan->mem_vaddr = kva_alloc(chan->mem_size); - pmap_kenter_device(chan->mem_vaddr, chan->mem_size, chan->mem_paddr); + pmap_kenter(chan->mem_vaddr, chan->mem_size, chan->mem_paddr, + VM_MEMATTR_DEFAULT); device_printf(sc->dev, "Allocated chunk %lx %lu\n", chan->mem_paddr, chan->mem_size); @@ -493,6 +497,9 @@ axidma_channel_submit_sg(device_t dev, struct xdma_channel *xchan, if (sg[i].last == 1) desc->control |= BD_CONTROL_TXEOF; + cpu_dcache_wbinv_range((vm_offset_t)desc, + sizeof(struct axidma_desc)); + tmp = chan->idx_head; atomic_add_int(&chan->descs_used_count, 1); diff --git a/sys/dev/xilinx/if_xae.c b/sys/dev/xilinx/if_xae.c index 722be6a21cbd..97e7aa16dda4 100644 --- a/sys/dev/xilinx/if_xae.c +++ b/sys/dev/xilinx/if_xae.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2019 Ruslan Bukin <br@bsdpad.com> + * Copyright (c) 2019-2025 Ruslan Bukin <br@bsdpad.com> * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory (Department of Computer Science and @@ -43,6 +43,9 @@ #include <sys/socket.h> #include <sys/sockio.h> +#include <vm/vm.h> +#include <vm/vm_page.h> + #include <net/bpf.h> #include <net/if.h> #include <net/ethernet.h> @@ -94,6 +97,7 @@ #define NUM_RX_MBUF 16 #define BUFRING_SIZE 8192 #define MDIO_CLK_DIV_DEFAULT 29 +#define BUF_NPAGES 512 #define PHY1_RD(sc, _r) \ xae_miibus_read_reg(sc->dev, 1, _r) @@ -834,6 +838,8 @@ setup_xdma(struct xae_softc *sc) { device_t dev; vmem_t *vmem; + vm_paddr_t phys; + vm_page_t m; int error; dev = sc->dev; @@ -886,11 +892,19 @@ setup_xdma(struct xae_softc *sc) /* Setup bounce buffer */ vmem = xdma_get_memory(dev); - if (vmem) { - xchan_set_memory(sc->xchan_tx, vmem); - xchan_set_memory(sc->xchan_rx, vmem); + if (!vmem) { + m = vm_page_alloc_noobj_contig(VM_ALLOC_WIRED | VM_ALLOC_ZERO, + BUF_NPAGES, 0, BUS_SPACE_MAXADDR_32BIT, PAGE_SIZE, 0, + VM_MEMATTR_DEFAULT); + phys = VM_PAGE_TO_PHYS(m); + vmem = vmem_create("xdma vmem", 0, 0, PAGE_SIZE, PAGE_SIZE, + M_BESTFIT | M_WAITOK); + vmem_add(vmem, phys, BUF_NPAGES * PAGE_SIZE, 0); } + xchan_set_memory(sc->xchan_tx, vmem); + xchan_set_memory(sc->xchan_rx, vmem); + xdma_prep_sg(sc->xchan_tx, TX_QUEUE_SIZE, /* xchan requests queue size */ MCLBYTES, /* maxsegsize */ @@ -990,11 +1004,6 @@ xae_attach(device_t dev) /* Set up the ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "could not allocate ifp.\n"); - return (ENXIO); - } - if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); @@ -1057,8 +1066,7 @@ xae_detach(device_t dev) ether_ifdetach(ifp); } - if (sc->miibus != NULL) - device_delete_child(dev, sc->miibus); + bus_generic_detach(dev); if (ifp != NULL) if_free(ifp); |