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