xref: /openbmc/u-boot/include/axi.h (revision 725e09b8)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2017, 2018
4  * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
5  */
6 
7 #ifndef _AXI_H_
8 #define _AXI_H_
9 
10 /**
11  * enum axi_size_t - Determine size of AXI transfer
12  * @AXI_SIZE_8:  AXI sransfer is 8-bit wide
13  * @AXI_SIZE_16: AXI sransfer is 16-bit wide
14  * @AXI_SIZE_32: AXI sransfer is 32-bit wide
15  */
16 enum axi_size_t {
17 	AXI_SIZE_8,
18 	AXI_SIZE_16,
19 	AXI_SIZE_32,
20 };
21 
22 struct axi_ops {
23 	/**
24 	 * read() - Read a single value from a specified address on a AXI bus
25 	 * @dev:	AXI bus to read from.
26 	 * @address:	The address to read from.
27 	 * @data:	Pointer to a variable that takes the data value read
28 	 *		from the address on the AXI bus.
29 	 * @size:	The size of the data to be read.
30 	 *
31 	 * Return: 0 if OK, -ve on error.
32 	 */
33 	int (*read)(struct udevice *dev, ulong address, void *data,
34 		    enum axi_size_t size);
35 
36 	/**
37 	 * write() - Write a single value to a specified address on a AXI bus
38 	 * @dev:	AXI bus to write to.
39 	 * @address:	The address to write to.
40 	 * @data:	Pointer to the data value to be written to the address
41 	 *		on the AXI bus.
42 	 * @size:	The size of the data to write.
43 	 *
44 	 * Return 0 if OK, -ve on error.
45 	 */
46 	int (*write)(struct udevice *dev, ulong address, void *data,
47 		     enum axi_size_t size);
48 };
49 
50 #define axi_get_ops(dev)	((struct axi_ops *)(dev)->driver->ops)
51 
52 /**
53  * axi_read() - Read a single value from a specified address on a AXI bus
54  * @dev:	AXI bus to read from.
55  * @address:	The address to read from.
56  * @data:	Pointer to a variable that takes the data value read from the
57  *              address on the AXI bus.
58  * @size:	The size of the data to write.
59  *
60  * Return: 0 if OK, -ve on error.
61  */
62 int axi_read(struct udevice *dev, ulong address, void *data,
63 	     enum axi_size_t size);
64 
65 /**
66  * axi_write() - Write a single value to a specified address on a AXI bus
67  * @dev:	AXI bus to write to.
68  * @address:	The address to write to.
69  * @data:	Pointer to the data value to be written to the address on the
70  *		AXI bus.
71  * @size:	The size of the data to write.
72  *
73  * Return: 0 if OK, -ve on error.
74  */
75 int axi_write(struct udevice *dev, ulong address, void *data,
76 	      enum axi_size_t size);
77 
78 struct axi_emul_ops {
79 	/**
80 	 * read() - Read a single value from a specified address on a AXI bus
81 	 * @dev:	AXI bus to read from.
82 	 * @address:	The address to read from.
83 	 * @data:	Pointer to a variable that takes the data value read
84 	 *		from the address on the AXI bus.
85 	 * @size:	The size of the data to be read.
86 	 *
87 	 * Return: 0 if OK, -ve on error.
88 	 */
89 	int (*read)(struct udevice *dev, ulong address, void *data,
90 		    enum axi_size_t size);
91 
92 	/**
93 	 * write() - Write a single value to a specified address on a AXI bus
94 	 * @dev:	AXI bus to write to.
95 	 * @address:	The address to write to.
96 	 * @data:	Pointer to the data value to be written to the address
97 	 *		on the AXI bus.
98 	 * @size:	The size of the data to write.
99 	 *
100 	 * Return: 0 if OK, -ve on error.
101 	 */
102 	int (*write)(struct udevice *dev, ulong address, void *data,
103 		     enum axi_size_t size);
104 
105 	/**
106 	 * get_store() - Get address of internal storage of a emulated AXI
107 	 *		 device
108 	 * @dev:	Emulated AXI device to get the pointer of the internal
109 	 *		storage for.
110 	 * @storep:	Pointer to the internal storage of the emulated AXI
111 	 *		device.
112 	 *
113 	 * Return: 0 if OK, -ve on error.
114 	 */
115 	int (*get_store)(struct udevice *dev, u8 **storep);
116 };
117 
118 #endif
119