xref: /openbmc/u-boot/include/axi.h (revision a63e54ab5fea8aa15c561dd29bd10edfccc1609c)
1*a63e54abSMario Six /* SPDX-License-Identifier: GPL-2.0+ */
2*a63e54abSMario Six /*
3*a63e54abSMario Six  * (C) Copyright 2017
4*a63e54abSMario Six  * Mario Six,  Guntermann & Drunck GmbH, mario.six@gdsys.cc
5*a63e54abSMario Six  */
6*a63e54abSMario Six 
7*a63e54abSMario Six #ifndef _AXI_H_
8*a63e54abSMario Six #define _AXI_H_
9*a63e54abSMario Six 
10*a63e54abSMario Six enum axi_size_t {
11*a63e54abSMario Six 	AXI_SIZE_8,
12*a63e54abSMario Six 	AXI_SIZE_16,
13*a63e54abSMario Six 	AXI_SIZE_32,
14*a63e54abSMario Six };
15*a63e54abSMario Six 
16*a63e54abSMario Six /**
17*a63e54abSMario Six  * struct axi_ops - driver operations for AXI uclass
18*a63e54abSMario Six  *
19*a63e54abSMario Six  * Drivers should support these operations unless otherwise noted. These
20*a63e54abSMario Six  * operations are intended to be used by uclass code, not directly from
21*a63e54abSMario Six  * other code.
22*a63e54abSMario Six  */
23*a63e54abSMario Six struct axi_ops {
24*a63e54abSMario Six 	/**
25*a63e54abSMario Six 	 * read() - Read a single value from a specified address on a AXI bus
26*a63e54abSMario Six 	 *
27*a63e54abSMario Six 	 * @dev:	AXI bus to read from.
28*a63e54abSMario Six 	 * @address:	The address to read from.
29*a63e54abSMario Six 	 * @data:	Pointer to a variable that takes the data value read
30*a63e54abSMario Six 	 *		from the address on the AXI bus.
31*a63e54abSMario Six 	 * @size:	The size of the data to be read.
32*a63e54abSMario Six 	 * @return 0 if OK, -ve on error.
33*a63e54abSMario Six 	 */
34*a63e54abSMario Six 	int (*read)(struct udevice *dev, ulong address, void *data,
35*a63e54abSMario Six 		    enum axi_size_t size);
36*a63e54abSMario Six 
37*a63e54abSMario Six 	/**
38*a63e54abSMario Six 	 * write() - Write a single value to a specified address on a AXI bus
39*a63e54abSMario Six 	 *
40*a63e54abSMario Six 	 * @dev:	AXI bus to write to.
41*a63e54abSMario Six 	 * @address:	The address to write to.
42*a63e54abSMario Six 	 * @data:	Pointer to the data value to be written to the address
43*a63e54abSMario Six 	 *		on the AXI bus.
44*a63e54abSMario Six 	 * @size:	The size of the data to write.
45*a63e54abSMario Six 	 * @return 0 if OK, -ve on error.
46*a63e54abSMario Six 	 */
47*a63e54abSMario Six 	int (*write)(struct udevice *dev, ulong address, void *data,
48*a63e54abSMario Six 		     enum axi_size_t size);
49*a63e54abSMario Six };
50*a63e54abSMario Six 
51*a63e54abSMario Six #define axi_get_ops(dev)	((struct axi_ops *)(dev)->driver->ops)
52*a63e54abSMario Six 
53*a63e54abSMario Six /**
54*a63e54abSMario Six  * axi_read() - Read a single value from a specified address on a AXI bus
55*a63e54abSMario Six  *
56*a63e54abSMario Six  * @dev:	AXI bus to read from.
57*a63e54abSMario Six  * @address:	The address to read from.
58*a63e54abSMario Six  * @data:	Pointer to a variable that takes the data value read from the
59*a63e54abSMario Six  *              address on the AXI bus.
60*a63e54abSMario Six  * @size:	The size of the data to write.
61*a63e54abSMario Six  * @return 0 if OK, -ve on error.
62*a63e54abSMario Six  */
63*a63e54abSMario Six int axi_read(struct udevice *dev, ulong address, void *data,
64*a63e54abSMario Six 	     enum axi_size_t size);
65*a63e54abSMario Six 
66*a63e54abSMario Six /**
67*a63e54abSMario Six  * axi_write() - Write a single value to a specified address on a AXI bus
68*a63e54abSMario Six  *
69*a63e54abSMario Six  * @dev:	AXI bus to write to.
70*a63e54abSMario Six  * @address:	The address to write to.
71*a63e54abSMario Six  * @data:	Pointer to the data value to be written to the address on the
72*a63e54abSMario Six  *		AXI bus.
73*a63e54abSMario Six  * @size:	The size of the data to write.
74*a63e54abSMario Six  * @return 0 if OK, -ve on error.
75*a63e54abSMario Six  */
76*a63e54abSMario Six int axi_write(struct udevice *dev, ulong address, void *data,
77*a63e54abSMario Six 	      enum axi_size_t size);
78*a63e54abSMario Six #endif
79