The branch main has been updated by br:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c7ffe32b1b7de9d72add1b44d5d3a3a14605a8f0

commit c7ffe32b1b7de9d72add1b44d5d3a3a14605a8f0
Author:     Ruslan Bukin <b...@freebsd.org>
AuthorDate: 2025-03-26 11:53:24 +0000
Commit:     Ruslan Bukin <b...@freebsd.org>
CommitDate: 2025-03-26 12:08:27 +0000

    xilinx quad spi: various fixes.
    
    - add compat table and a string for an older IP
    - name driver properly
    - depend on ofw_spibus
    - add missing ofw_bus_get_node() method
    - connect to GENERIC (similar to other Xilinx IP)
    
    Tested on Codasip A730.
---
 sys/dev/xilinx/axi_quad_spi.c | 31 +++++++++++++++++++++++++------
 sys/riscv/conf/GENERIC        |  1 +
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/sys/dev/xilinx/axi_quad_spi.c b/sys/dev/xilinx/axi_quad_spi.c
index eba320731659..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 <b...@bsdpad.com>
+ * Copyright (c) 2016-2025 Ruslan Bukin <b...@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,7 +154,7 @@ spi_attach(device_t dev)
        reg = (CR_MASTER | CR_MSS | CR_SPE);
        WRITE4(sc, SPI_CR, reg);
 
-       device_add_child(dev, "spibus", 0);
+       device_add_child(dev, "spibus", DEVICE_UNIT_ANY);
        bus_attach_children(dev);
        return (0);
 }
@@ -212,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/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC
index 8dca3bdb3369..7d7d0ca6e79c 100644
--- a/sys/riscv/conf/GENERIC
+++ b/sys/riscv/conf/GENERIC
@@ -161,6 +161,7 @@ device              fdt_pinctrl
 # SPI
 device         spibus
 device         spigen
+device         xilinx_spi      # Xilinx AXI SPI Controller
 
 # Debugging support.  Always need this:
 options        KDB                     # Enable kernel debugger support.

Reply via email to