Smbus.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /** @file
  2. This file declares the Smbus PPI, which provides the basic I/O interfaces that a PEIM
  3. uses to access its SMBus controller and the slave devices attached to it.
  4. Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. @par Revision Reference:
  7. This PPI is defined in Framework of EFI SmBus PPI spec.
  8. Version 0.9.
  9. **/
  10. #ifndef _PEI_SMBUS_PPI_H_
  11. #define _PEI_SMBUS_PPI_H_
  12. #include <Ppi/Smbus2.h>
  13. #define EFI_PEI_SMBUS_PPI_GUID \
  14. { \
  15. 0xabd42895, 0x78cf, 0x4872, {0x84, 0x44, 0x1b, 0x5c, 0x18, 0xb, 0xfb, 0xda } \
  16. }
  17. typedef struct _EFI_PEI_SMBUS_PPI EFI_PEI_SMBUS_PPI;
  18. /**
  19. Executes an SMBus operation to an SMBus controller.
  20. @param[in] PeiServices A pointer to the system PEI Services Table.
  21. @param[in] This A pointer to the EFI_PEI_SMBUS_PPI instance.
  22. @param[in] SlaveAddress The SMBUS hardware address to which the SMBUS
  23. device is preassigned or allocated.
  24. @param[in] Command This command is transmitted by the SMBus host
  25. controller to the SMBus slave device, and the
  26. interpretation is SMBus slave device specific.
  27. @param[in] Operation Signifies which particular SMBus hardware protocol
  28. instance to use to execute the SMBus transactions.
  29. @param[in] PecCheck Defines if Packet Error Code (PEC) checking is
  30. required for this operation.
  31. @param[in, out] Length The number of bytes for this operation.
  32. @param[in, out] Buffer Contains the value of data to execute to the SMBus
  33. slave device.
  34. @retval EFI_SUCCESS The last data that was returned from the access
  35. matched the poll exit criteria.
  36. @retval EFI_CRC_ERROR The checksum is not correct (PEC is incorrect).
  37. @retval EFI_TIMEOUT Timeout expired before the operation was completed.
  38. Timeout is determined by the SMBus host controller device.
  39. @retval EFI_OUT_OF_RESOURCES The request could not be completed
  40. due to a lack of resources.
  41. @retval EFI_DEVICE_ERROR The request was not completed because a failure
  42. was recorded in the Host Status Register bit.
  43. @retval EFI_INVALID_PARAMETER The operation is not defined in EFI_SMBUS_OPERATION.
  44. @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations except for
  45. EfiSmbusQuickRead and EfiSmbusQuickWrite. Length
  46. is outside the range of valid values.
  47. @retval EFI_UNSUPPORTED The SMBus operation or PEC is not supported.
  48. @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operation.
  49. **/
  50. typedef
  51. EFI_STATUS
  52. (EFIAPI *EFI_PEI_SMBUS_PPI_EXECUTE_OPERATION)(
  53. IN EFI_PEI_SERVICES **PeiServices,
  54. IN EFI_PEI_SMBUS_PPI *This,
  55. IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
  56. IN EFI_SMBUS_DEVICE_COMMAND Command,
  57. IN EFI_SMBUS_OPERATION Operation,
  58. IN BOOLEAN PecCheck,
  59. IN OUT UINTN *Length,
  60. IN OUT VOID *Buffer
  61. );
  62. /**
  63. This function is user-defined, and is called when the SlaveAddress/Data pair happens.
  64. @param[in] PeiServices A pointer to the system PEI Services Table.
  65. @param[in] This A pointer to the EFI_PEI_SMBUS_PPI instance.
  66. @param[in] SlaveAddress The SMBUS hardware address to which the SMBUS
  67. device is preassigned or allocated.
  68. @param[in] Data Data of the SMBus host notify command, which denotes that
  69. the caller wants to be called.
  70. @return Status Code returned by callback function.
  71. **/
  72. typedef
  73. EFI_STATUS
  74. (EFIAPI *EFI_PEI_SMBUS_NOTIFY_FUNCTION)(
  75. IN EFI_PEI_SERVICES **PeiServices,
  76. IN EFI_PEI_SMBUS_PPI *SmbusPpi,
  77. IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
  78. IN UINTN Data
  79. );
  80. /**
  81. The ArpDevice() function enumerates either the entire bus or a specific
  82. device identified by SmbusUdid.
  83. @param[in] PeiServices A pointer to the system PEI Services Table.
  84. @param[in] This A pointer to the EFI_PEI_SMBUS_PPI instance.
  85. @param[in] ArpAll A Boolean expression that indicates if the host
  86. drivers need to enumerate all the devices or to
  87. enumerate only the device that is identified
  88. by SmbusUdid. If ArpAll is TRUE, SmbusUdid and
  89. SlaveAddress are optional and ignored if entered.
  90. If ArpAll is FALSE, ArpDevice will enumerate
  91. SmbusUdid, and the address will be at SlaveAddress.
  92. @param[in] SmbusUdid The targeted SMBus Unique Device Identifier (UDID).
  93. The UDID may not exist for SMBus devices with fixed
  94. addresses.
  95. @param[in, out] SlaveAddress The new SMBus address for the slave device for
  96. which the operation is targeted.
  97. This address may be NULL.
  98. @retval EFI_SUCCESS The SMBus slave device address was set.
  99. @retval EFI_INVALID_PARAMETER SlaveAddress is NULL.
  100. @retval EFI_OUT_OF_RESOURCES The request could not be completed
  101. due to a lack of resources.
  102. @retval EFI_TIMEOUT The SMBus slave device did not respond.
  103. @retval EFI_DEVICE_ERROR The request was not completed because the transaction failed.
  104. @retval EFI_UNSUPPORTED ArpDevice() is not implemented by this PEIM.
  105. This return value is not defined in the Framework Specification.
  106. This return value was introduced in the PI Specification.
  107. **/
  108. typedef
  109. EFI_STATUS
  110. (EFIAPI *EFI_PEI_SMBUS_PPI_ARP_DEVICE)(
  111. IN EFI_PEI_SERVICES **PeiServices,
  112. IN EFI_PEI_SMBUS_PPI *This,
  113. IN BOOLEAN ArpAll,
  114. IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL
  115. IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL
  116. );
  117. /**
  118. The GetArpMap() function returns the mapping of all the SMBus devices
  119. that are enumerated by the SMBus host driver.
  120. @param[in] PeiServices A pointer to the system PEI Services Table.
  121. @param[in] This A pointer to the EFI_PEI_SMBUS_PPI instance.
  122. @param[in, out] Length The size of the buffer that contains the SMBus device map.
  123. @param[in, out] SmbusDeviceMap The pointer to the device map as enumerated
  124. by the SMBus controller driver.
  125. @retval EFI_SUCCESS The device map was returned correctly in the buffer.
  126. @retval EFI_UNSUPPORTED GetArpMap() are not implemented by this PEIM.
  127. This return value was not defined in the Framework Specification.
  128. This return value was introduced in the PI Specification.
  129. **/
  130. typedef
  131. EFI_STATUS
  132. (EFIAPI *EFI_PEI_SMBUS_PPI_GET_ARP_MAP)(
  133. IN EFI_PEI_SERVICES **PeiServices,
  134. IN EFI_PEI_SMBUS_PPI *This,
  135. IN OUT UINTN *Length,
  136. IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap
  137. );
  138. /**
  139. Allows a device driver to register for a callback when the bus driver detects a state that it needs to
  140. propagate to other PEIMs that are registered for a callback.
  141. The Notify() function registers all the callback functions to allow the
  142. bus driver to call these functions when the SlaveAddress/Data pair occur.
  143. All functions to be registered with EFI_PEI_SMBUS_PPI_NOTIFY must be of type
  144. EFI_PEI_SMBUS_NOTIFY_FUNCTION.
  145. @param[in] PeiServices A pointer to the system PEI Services Table.
  146. @param[in] This A pointer to the EFI_PEI_SMBUS_PPI instance.
  147. @param[in] SlaveAddress The address that the host controller detects as
  148. sending a message and triggers all the registered functions.
  149. @param[in] Data Data that the host controller detects as sending a message
  150. and triggers all the registered functions.
  151. @param[in] NotifyFunction The function to call when the bus driver
  152. detects the SlaveAddress and Data pair.
  153. @retval EFI_SUCCESS NotifyFunction has been registered.
  154. @retval EFI_UNSUPPORTED Notify() are not implemented by this PEIM.
  155. This return value is not defined in the Framework Specification.
  156. This return value was introduced in the PI Specification.
  157. **/
  158. typedef
  159. EFI_STATUS
  160. (EFIAPI *EFI_PEI_SMBUS_PPI_NOTIFY)(
  161. IN EFI_PEI_SERVICES **PeiServices,
  162. IN EFI_PEI_SMBUS_PPI *This,
  163. IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
  164. IN UINTN Data,
  165. IN EFI_PEI_SMBUS_NOTIFY_FUNCTION NotifyFunction
  166. );
  167. ///
  168. /// Provides the basic I/O interfaces that a PEIM uses to access
  169. /// its SMBus controller and the slave devices attached to it.
  170. ///
  171. struct _EFI_PEI_SMBUS_PPI {
  172. ///
  173. /// Executes the SMBus operation to an SMBus slave device.
  174. ///
  175. EFI_PEI_SMBUS_PPI_EXECUTE_OPERATION Execute;
  176. ///
  177. /// Allows an SMBus 2.0 device(s) to be Address Resolution Protocol (ARP)
  178. ///
  179. EFI_PEI_SMBUS_PPI_ARP_DEVICE ArpDevice;
  180. ///
  181. /// Allows a PEIM to retrieve the address that was allocated by the SMBus
  182. /// host controller during enumeration/ARP.
  183. ///
  184. EFI_PEI_SMBUS_PPI_GET_ARP_MAP GetArpMap;
  185. ///
  186. /// Allows a driver to register for a callback to the SMBus host
  187. /// controller driver when the bus issues a notification to the bus controller PEIM.
  188. ///
  189. EFI_PEI_SMBUS_PPI_NOTIFY Notify;
  190. };
  191. extern EFI_GUID gEfiPeiSmbusPpiGuid;
  192. #endif