xref: /openbmc/u-boot/arch/sandbox/include/asm/axi.h (revision 3fda0262)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2018
4  * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
5  */
6 
7 #ifndef __asm_axi_h
8 #define __asm_axi_h
9 
10 #define axi_emul_get_ops(dev)	((struct axi_emul_ops *)(dev)->driver->ops)
11 
12 /**
13  * axi_sandbox_get_emul() - Retrieve a pointer to a AXI emulation device
14  * @bus:     The AXI bus from which to retrieve a emulation device
15  * @address: The address of a transfer that should be handled by a emulation
16  *	     device
17  * @length:  The data width of a transfer that should be handled by a emulation
18  *	     device
19  * @emulp:   Pointer to a buffer receiving the emulation device that handles
20  *	     the transfer specified by the address and length parameters
21  *
22  * To test the AXI uclass, we implement a simple AXI emulation device, which is
23  * a virtual device on a AXI bus that exposes a simple storage interface: When
24  * reading and writing from the device, the addresses are translated to offsets
25  * within the device's storage. For write accesses the data is written to the
26  * specified storage offset, and for read accesses the data is read from the
27  * specified storage offset.
28  *
29  * A DTS entry might look like this:
30  *
31  * axi: axi@0 {
32  *	compatible = "sandbox,axi";
33  *	#address-cells = <0x1>;
34  *	#size-cells = <0x1>;
35  *	store@0 {
36  *		compatible = "sandbox,sandbox_store";
37  *		reg = <0x0 0x400>;
38  *	};
39  * };
40  *
41  * This function may then be used to retrieve the pointer to the sandbox_store
42  * emulation device given the AXI bus device, and the data (address, data
43  * width) of a AXI transfer which should be handled by a emulation device.
44  *
45  * Return: 0 of OK, -ENODEV if no device capable of handling the specified
46  *	   transfer exists or the device could not be retrieved
47  */
48 int axi_sandbox_get_emul(struct udevice *bus, ulong address, uint length,
49 			 struct udevice **emulp);
50 /**
51  * axi_get_store() - Get address of internal storage of a emulated AXI device
52  * @dev:	Emulated AXI device to get the pointer of the internal storage
53  *		for.
54  * @storep:	Pointer to the internal storage of the emulated AXI device.
55  *
56  * To preset or read back the contents internal storage of the emulated AXI
57  * device, this function returns the pointer to the storage. Changes to the
58  * contents of the storage are reflected when using the AXI read/write API
59  * methods, and vice versa, so by using this method expected read data can be
60  * set up in advance, and written data can be checked in unit tests.
61  *
62  * Return: 0 if OK, -ve on error.
63  */
64 int axi_get_store(struct udevice *dev, u8 **storep);
65 
66 #endif /* __asm_axi_h */
67