mcdi_functions.h 3.7 KB

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