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