aboutsummaryrefslogtreecommitdiff
path: root/include/axi.h
blob: 2ff81c16af6c1a9159182a74cb1bb081bf0ded14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * (C) Copyright 2017
 * Mario Six,  Guntermann & Drunck GmbH, mario.six@gdsys.cc
 */

#ifndef _AXI_H_
#define _AXI_H_

enum axi_size_t {
	AXI_SIZE_8,
	AXI_SIZE_16,
	AXI_SIZE_32,
};

/**
 * struct axi_ops - driver operations for AXI uclass
 *
 * Drivers should support these operations unless otherwise noted. These
 * operations are intended to be used by uclass code, not directly from
 * other code.
 */
struct axi_ops {
	/**
	 * read() - Read a single value from a specified address on a AXI bus
	 *
	 * @dev:	AXI bus to read from.
	 * @address:	The address to read from.
	 * @data:	Pointer to a variable that takes the data value read
	 *		from the address on the AXI bus.
	 * @size:	The size of the data to be read.
	 * @return 0 if OK, -ve on error.
	 */
	int (*read)(struct udevice *dev, ulong address, void *data,
		    enum axi_size_t size);

	/**
	 * write() - Write a single value to a specified address on a AXI bus
	 *
	 * @dev:	AXI bus to write to.
	 * @address:	The address to write to.
	 * @data:	Pointer to the data value to be written to the address
	 *		on the AXI bus.
	 * @size:	The size of the data to write.
	 * @return 0 if OK, -ve on error.
	 */
	int (*write)(struct udevice *dev, ulong address, void *data,
		     enum axi_size_t size);
};

#define axi_get_ops(dev)	((struct axi_ops *)(dev)->driver->ops)

/**
 * axi_read() - Read a single value from a specified address on a AXI bus
 *
 * @dev:	AXI bus to read from.
 * @address:	The address to read from.
 * @data:	Pointer to a variable that takes the data value read from the
 *              address on the AXI bus.
 * @size:	The size of the data to write.
 * @return 0 if OK, -ve on error.
 */
int axi_read(struct udevice *dev, ulong address, void *data,
	     enum axi_size_t size);

/**
 * axi_write() - Write a single value to a specified address on a AXI bus
 *
 * @dev:	AXI bus to write to.
 * @address:	The address to write to.
 * @data:	Pointer to the data value to be written to the address on the
 *		AXI bus.
 * @size:	The size of the data to write.
 * @return 0 if OK, -ve on error.
 */
int axi_write(struct udevice *dev, ulong address, void *data,
	      enum axi_size_t size);
#endif