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