I2cDebugPortProtocol.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /** @file
  2. I2C Debug Port Protocol Implementation
  3. Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Uefi/UefiBaseType.h>
  7. #define I2C_DEBUG_PORT_WRITE_DEVICE_ADDRESS 0xDE
  8. #define I2C_DEBUG_PORT_READ_DEVICE_ADDRESS 0xDF
  9. #define I2C_DEBUG_PORT_WRITE_COMMAND 0x00
  10. #define I2C_DEBUG_PORT_READ_COMMAND 0x01
  11. #define I2C_DEBUG_PORT_READY_TO_READ_COMMAND 0x02
  12. #define I2C_DEBUG_PORT_COMMAND_BIT_POSITION 5
  13. #define I2C_DEBUG_PORT_COMMAND_BIT_MASK 0x7
  14. #define I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK 0x1F
  15. #define I2C_DEBUG_PORT_MAX_DATA_SIZE I2C_DEBUG_PORT_DATA_SIZE_BIT_MASK
  16. /**
  17. Writes data to the I2C debug port
  18. @param[in] Buffer - The data to be written to the I2C debug port.
  19. @param[in] Count - The number of bytes to write to the I2C debug port.
  20. @retval EFI_SUCCESS - The data was successfully written.
  21. @retval EFI_INVALID_PARAMETER - One of the following conditions:
  22. * ByteCount is 0
  23. * Buffer is NULL
  24. @retval EFI_TIMEOUT - The I2C controller did not respond within the required timeout period.
  25. @retval EFI_DEVICE_ERROR - An error occurred while accessing the I2C controller.
  26. **/
  27. EFI_STATUS
  28. I2cDebugPortWrite (
  29. IN UINT8 *Buffer,
  30. IN UINT32 Count
  31. );
  32. /**
  33. Reads data from the I2C debug port
  34. @param[out] Buffer - The memory buffer to return the read data.
  35. @param[in, out] Count - The number of bytes to read from the I2C debug port.
  36. On output, the number of bytes actually read.
  37. @retval EFI_SUCCESS - The data was successfully read.
  38. @retval EFI_INVALID_PARAMETER - One of the following conditions:
  39. * ByteCount is 0
  40. * Buffer is NULL
  41. @retval EFI_TIMEOUT - The I2C controller did not respond within the required timeout period.
  42. @retval EFI_DEVICE_ERROR - An error occurred while accessing the I2C controller.
  43. **/
  44. EFI_STATUS
  45. I2cDebugPortRead (
  46. OUT UINT8 *Buffer,
  47. IN OUT UINT32 *Count
  48. );
  49. /**
  50. Queries the I2C debug port to see if there are any data waiting to be read
  51. @param[out] NumberOfBytesInFifoBuffer - The number of bytes sitting in the I2C debug port's
  52. FIFO buffer waiting to be read
  53. @retval EFI_SUCCESS - The I2C debug port was successfully queried
  54. @retval EFI_INVALID_PARAMETER - One of the following conditions:
  55. * NumberOfBytesInFifoBuffer is NULL
  56. @retval EFI_TIMEOUT - The I2C controller did not respond within the required timeout period.
  57. @retval EFI_DEVICE_ERROR - An error occurred while accessing the I2C controller.
  58. **/
  59. EFI_STATUS
  60. I2cDebugPortReadyToRead (
  61. OUT UINT8 *NumberOfBytesInFifoBuffer
  62. );