axi.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2018
  4. * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
  5. */
  6. #ifndef __asm_axi_h
  7. #define __asm_axi_h
  8. #define axi_emul_get_ops(dev) ((struct axi_emul_ops *)(dev)->driver->ops)
  9. /**
  10. * axi_sandbox_get_emul() - Retrieve a pointer to a AXI emulation device
  11. * @bus: The AXI bus from which to retrieve a emulation device
  12. * @address: The address of a transfer that should be handled by a emulation
  13. * device
  14. * @length: The data width of a transfer that should be handled by a emulation
  15. * device
  16. * @emulp: Pointer to a buffer receiving the emulation device that handles
  17. * the transfer specified by the address and length parameters
  18. *
  19. * To test the AXI uclass, we implement a simple AXI emulation device, which is
  20. * a virtual device on a AXI bus that exposes a simple storage interface: When
  21. * reading and writing from the device, the addresses are translated to offsets
  22. * within the device's storage. For write accesses the data is written to the
  23. * specified storage offset, and for read accesses the data is read from the
  24. * specified storage offset.
  25. *
  26. * A DTS entry might look like this:
  27. *
  28. * axi: axi@0 {
  29. * compatible = "sandbox,axi";
  30. * #address-cells = <0x1>;
  31. * #size-cells = <0x1>;
  32. * store@0 {
  33. * compatible = "sandbox,sandbox_store";
  34. * reg = <0x0 0x400>;
  35. * };
  36. * };
  37. *
  38. * This function may then be used to retrieve the pointer to the sandbox_store
  39. * emulation device given the AXI bus device, and the data (address, data
  40. * width) of a AXI transfer which should be handled by a emulation device.
  41. *
  42. * Return: 0 of OK, -ENODEV if no device capable of handling the specified
  43. * transfer exists or the device could not be retrieved
  44. */
  45. int axi_sandbox_get_emul(struct udevice *bus, ulong address, uint length,
  46. struct udevice **emulp);
  47. /**
  48. * axi_get_store() - Get address of internal storage of a emulated AXI device
  49. * @dev: Emulated AXI device to get the pointer of the internal storage
  50. * for.
  51. * @storep: Pointer to the internal storage of the emulated AXI device.
  52. *
  53. * To preset or read back the contents internal storage of the emulated AXI
  54. * device, this function returns the pointer to the storage. Changes to the
  55. * contents of the storage are reflected when using the AXI read/write API
  56. * methods, and vice versa, so by using this method expected read data can be
  57. * set up in advance, and written data can be checked in unit tests.
  58. *
  59. * Return: 0 if OK, -ve on error.
  60. */
  61. int axi_get_store(struct udevice *dev, u8 **storep);
  62. #endif /* __asm_axi_h */