mcdi_functions.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * Header file for MCDI FW interaction for CDX bus.
  4. *
  5. * Copyright (C) 2022-2023, Advanced Micro Devices, Inc.
  6. */
  7. #ifndef CDX_MCDI_FUNCTIONS_H
  8. #define CDX_MCDI_FUNCTIONS_H
  9. #include "mcdi.h"
  10. #include "../cdx.h"
  11. /**
  12. * cdx_mcdi_get_num_buses - Get the total number of buses on
  13. * the controller.
  14. * @cdx: pointer to MCDI interface.
  15. *
  16. * Return: total number of buses available on the controller,
  17. * <0 on failure
  18. */
  19. int cdx_mcdi_get_num_buses(struct cdx_mcdi *cdx);
  20. /**
  21. * cdx_mcdi_get_num_devs - Get the total number of devices on
  22. * a particular bus of the controller.
  23. * @cdx: pointer to MCDI interface.
  24. * @bus_num: Bus number.
  25. *
  26. * Return: total number of devices available on the bus, <0 on failure
  27. */
  28. int cdx_mcdi_get_num_devs(struct cdx_mcdi *cdx, int bus_num);
  29. /**
  30. * cdx_mcdi_get_dev_config - Get configuration for a particular
  31. * bus_num:dev_num
  32. * @cdx: pointer to MCDI interface.
  33. * @bus_num: Bus number.
  34. * @dev_num: Device number.
  35. * @dev_params: Pointer to cdx_dev_params, this is populated by this
  36. * device with the configuration corresponding to the provided
  37. * bus_num:dev_num.
  38. *
  39. * Return: 0 total number of devices available on the bus, <0 on failure
  40. */
  41. int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
  42. u8 bus_num, u8 dev_num,
  43. struct cdx_dev_params *dev_params);
  44. /**
  45. * cdx_mcdi_bus_enable - Enable CDX bus represented by bus_num
  46. * @cdx: pointer to MCDI interface.
  47. * @bus_num: Bus number.
  48. *
  49. * Return: 0 on success, <0 on failure
  50. */
  51. int cdx_mcdi_bus_enable(struct cdx_mcdi *cdx, u8 bus_num);
  52. /**
  53. * cdx_mcdi_bus_disable - Disable CDX bus represented by bus_num
  54. * @cdx: pointer to MCDI interface.
  55. * @bus_num: Bus number.
  56. *
  57. * Return: 0 on success, <0 on failure
  58. */
  59. int cdx_mcdi_bus_disable(struct cdx_mcdi *cdx, u8 bus_num);
  60. /**
  61. * cdx_mcdi_write_msi - Write MSI configuration for CDX device
  62. * @cdx: pointer to MCDI interface.
  63. * @bus_num: Bus number.
  64. * @dev_num: Device number.
  65. * @msi_vector: Device-relative MSI vector number.
  66. * Must be < MSI_COUNT reported for the device.
  67. * @msi_address: MSI address to be used by the hardware. Typically, on ARM
  68. * systems this address is translated by the IOMMU (if enabled) and
  69. * it is the responsibility of the entity managing the IOMMU (APU kernel)
  70. * to supply the correct IOVA here.
  71. * @msi_data: MSI data to be used by the hardware. On versal-net, only the
  72. * lower 16-bits are used, the remaining bits are ignored and should be
  73. * set to zero.
  74. *
  75. * Return: 0 on success, <0 on failure
  76. */
  77. int cdx_mcdi_write_msi(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num,
  78. u32 msi_vector, u64 msi_address, u32 msi_data);
  79. /**
  80. * cdx_mcdi_reset_device - Reset cdx device represented by bus_num:dev_num
  81. * @cdx: pointer to MCDI interface.
  82. * @bus_num: Bus number.
  83. * @dev_num: Device number.
  84. *
  85. * Return: 0 on success, <0 on failure
  86. */
  87. int cdx_mcdi_reset_device(struct cdx_mcdi *cdx,
  88. u8 bus_num, u8 dev_num);
  89. /**
  90. * cdx_mcdi_bus_master_enable - Set/Reset bus mastering for cdx device
  91. * represented by bus_num:dev_num
  92. * @cdx: pointer to MCDI interface.
  93. * @bus_num: Bus number.
  94. * @dev_num: Device number.
  95. * @enable: Enable bus mastering if set, disable otherwise.
  96. *
  97. * Return: 0 on success, <0 on failure
  98. */
  99. int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num,
  100. u8 dev_num, bool enable);
  101. /**
  102. * cdx_mcdi_msi_enable - Enable/Disable MSIs for cdx device represented
  103. * by bus_num:dev_num
  104. * @cdx: pointer to MCDI interface.
  105. * @bus_num: Bus number.
  106. * @dev_num: Device number.
  107. * @enable: Enable msi's if set, disable otherwise.
  108. *
  109. * Return: 0 on success, <0 on failure
  110. */
  111. int cdx_mcdi_msi_enable(struct cdx_mcdi *cdx, u8 bus_num,
  112. u8 dev_num, bool enable);
  113. #endif /* CDX_MCDI_FUNCTIONS_H */