1 // SPDX-License-Identifier: GPL-2.0+
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
13 * This driver implements a AXI bus for the sandbox architecture for testing
16 * The bus forwards every access to it to a special AXI emulation device (which
17 * it gets via the axi_emul_get_ops function) that implements a simple
20 * The emulator device must still be contained in the device tree in the usual
21 * way, since configuration data for the storage is read from the DT.
24 static int axi_sandbox_read(struct udevice *bus, ulong address, void *data,
27 struct axi_emul_ops *ops;
31 /* Get emulator device */
32 ret = axi_sandbox_get_emul(bus, address, size, &emul);
34 return ret == -ENODEV ? 0 : ret;
35 /* Forward all reads to the AXI emulator */
36 ops = axi_emul_get_ops(emul);
37 if (!ops || !ops->read)
40 return ops->read(emul, address, data, size);
43 static int axi_sandbox_write(struct udevice *bus, ulong address, void *data,
46 struct axi_emul_ops *ops;
50 /* Get emulator device */
51 ret = axi_sandbox_get_emul(bus, address, size, &emul);
53 return ret == -ENODEV ? 0 : ret;
54 /* Forward all writes to the AXI emulator */
55 ops = axi_emul_get_ops(emul);
56 if (!ops || !ops->write)
59 return ops->write(emul, address, data, size);
62 static const struct udevice_id axi_sandbox_ids[] = {
63 { .compatible = "sandbox,axi" },
67 static const struct axi_ops axi_sandbox_ops = {
68 .read = axi_sandbox_read,
69 .write = axi_sandbox_write,
72 U_BOOT_DRIVER(axi_sandbox_bus) = {
73 .name = "axi_sandbox_bus",
75 .of_match = axi_sandbox_ids,
76 .ops = &axi_sandbox_ops,