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