axi.h 3.3 KB

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