amd-apml.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright (C) 2021-2024 Advanced Micro Devices, Inc.
  4. */
  5. #ifndef _AMD_APML_H_
  6. #define _AMD_APML_H_
  7. #include <linux/types.h>
  8. /* Mailbox data size for data_in and data_out */
  9. #define AMD_SBI_MB_DATA_SIZE 4
  10. struct apml_mbox_msg {
  11. /*
  12. * Mailbox Message ID
  13. */
  14. __u32 cmd;
  15. /*
  16. * [0]...[3] mailbox 32bit input/output data
  17. */
  18. __u32 mb_in_out;
  19. /*
  20. * Error code is returned in case of soft mailbox error
  21. */
  22. __u32 fw_ret_code;
  23. };
  24. struct apml_cpuid_msg {
  25. /*
  26. * CPUID input
  27. * [0]...[3] cpuid func,
  28. * [4][5] cpuid: thread
  29. * [6] cpuid: ext function & read eax/ebx or ecx/edx
  30. * [7:0] -> bits [7:4] -> ext function &
  31. * bit [0] read eax/ebx or ecx/edx
  32. * CPUID output
  33. */
  34. __u64 cpu_in_out;
  35. /*
  36. * Status code for CPUID read
  37. */
  38. __u32 fw_ret_code;
  39. __u32 pad;
  40. };
  41. struct apml_mcamsr_msg {
  42. /*
  43. * MCAMSR input
  44. * [0]...[3] mca msr func,
  45. * [4][5] thread
  46. * MCAMSR output
  47. */
  48. __u64 mcamsr_in_out;
  49. /*
  50. * Status code for MCA/MSR access
  51. */
  52. __u32 fw_ret_code;
  53. __u32 pad;
  54. };
  55. struct apml_reg_xfer_msg {
  56. /*
  57. * RMI register address offset
  58. */
  59. __u16 reg_addr;
  60. /*
  61. * Register data for read/write
  62. */
  63. __u8 data_in_out;
  64. /*
  65. * Register read or write
  66. */
  67. __u8 rflag;
  68. };
  69. /*
  70. * AMD sideband interface base IOCTL
  71. */
  72. #define SB_BASE_IOCTL_NR 0xF9
  73. /**
  74. * DOC: SBRMI_IOCTL_MBOX_CMD
  75. *
  76. * @Parameters
  77. *
  78. * @struct apml_mbox_msg
  79. * Pointer to the &struct apml_mbox_msg that will contain the protocol
  80. * information
  81. *
  82. * @Description
  83. * IOCTL command for APML messages using generic _IOWR
  84. * The IOCTL provides userspace access to AMD sideband mailbox protocol
  85. * - Mailbox message read/write(0x0~0xFF)
  86. * - returning "-EFAULT" if none of the above
  87. * "-EPROTOTYPE" error is returned to provide additional error details
  88. */
  89. #define SBRMI_IOCTL_MBOX_CMD _IOWR(SB_BASE_IOCTL_NR, 0, struct apml_mbox_msg)
  90. /**
  91. * DOC: SBRMI_IOCTL_CPUID_CMD
  92. *
  93. * @Parameters
  94. *
  95. * @struct apml_cpuid_msg
  96. * Pointer to the &struct apml_cpuid_msg that will contain the protocol
  97. * information
  98. *
  99. * @Description
  100. * IOCTL command for APML messages using generic _IOWR
  101. * The IOCTL provides userspace access to AMD sideband cpuid protocol
  102. * - CPUID protocol to get CPU details for Function/Ext Function
  103. * at thread level
  104. * - returning "-EFAULT" if none of the above
  105. * "-EPROTOTYPE" error is returned to provide additional error details
  106. */
  107. #define SBRMI_IOCTL_CPUID_CMD _IOWR(SB_BASE_IOCTL_NR, 1, struct apml_cpuid_msg)
  108. /**
  109. * DOC: SBRMI_IOCTL_MCAMSR_CMD
  110. *
  111. * @Parameters
  112. *
  113. * @struct apml_mcamsr_msg
  114. * Pointer to the &struct apml_mcamsr_msg that will contain the protocol
  115. * information
  116. *
  117. * @Description
  118. * IOCTL command for APML messages using generic _IOWR
  119. * The IOCTL provides userspace access to AMD sideband MCAMSR protocol
  120. * - MCAMSR protocol to get MCA bank details for Function at thread level
  121. * - returning "-EFAULT" if none of the above
  122. * "-EPROTOTYPE" error is returned to provide additional error details
  123. */
  124. #define SBRMI_IOCTL_MCAMSR_CMD _IOWR(SB_BASE_IOCTL_NR, 2, struct apml_mcamsr_msg)
  125. /**
  126. * DOC: SBRMI_IOCTL_REG_XFER_CMD
  127. *
  128. * @Parameters
  129. *
  130. * @struct apml_reg_xfer_msg
  131. * Pointer to the &struct apml_reg_xfer_msg that will contain the protocol
  132. * information
  133. *
  134. * @Description
  135. * IOCTL command for APML messages using generic _IOWR
  136. * The IOCTL provides userspace access to AMD sideband register xfer protocol
  137. * - Register xfer protocol to get/set hardware register for given offset
  138. */
  139. #define SBRMI_IOCTL_REG_XFER_CMD _IOWR(SB_BASE_IOCTL_NR, 3, struct apml_reg_xfer_msg)
  140. #endif /*_AMD_APML_H_*/