Blame view

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