axi.h 3.3 KB

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