GpioExpanderLib.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /** @file
  2. Support for IO expander TCA6424.
  3. Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _GPIO_EXPANDER_LIB_H_
  7. #define _GPIO_EXPANDER_LIB_H_
  8. #include <Uefi.h>
  9. #include <Library/DebugLib.h>
  10. #include <Library/TimerLib.h>
  11. #include <Library/IoLib.h>
  12. #include <Library/UefiLib.h>
  13. #include <PchAccess.h>
  14. #include <Library/PchSerialIoLib.h>
  15. /**
  16. Set the Direction value for the given Expander Gpio pin.
  17. This function is to Set the direction value for the GPIO
  18. Pin within the giving Expander.
  19. @param[in] Expander Expander Value with in the Contoller
  20. @param[in] Pin Pin with in the Expnader Value
  21. @param[in] Value none
  22. **/
  23. VOID
  24. GpioExpSetDirection (
  25. IN UINT8 Expander,
  26. IN UINT8 Pin,
  27. IN UINT8 Direction
  28. );
  29. /**
  30. Set the input value for the given Expander Gpio pin.
  31. This function is to get the input value for the GPIO
  32. Pin within the giving Expander.
  33. @param[in] Expander Expander Value with in the Contoller
  34. @param[in] Pin Pin with in the Expnader Value
  35. @param[in] Value none
  36. **/
  37. VOID
  38. GpioExpSetPolarity (
  39. IN UINT8 Expander,
  40. IN UINT8 Pin,
  41. IN UINT8 Polarity
  42. );
  43. /**
  44. Set the Output value for the given Expander Gpio pin.
  45. This function is to Set the Output value for the GPIO
  46. Pin within the giving Expander.
  47. @param[in] Expander Expander Value with in the Contoller
  48. @param[in] Pin Pin with in the Expnader Value
  49. @param[in] Value none
  50. **/
  51. VOID
  52. GpioExpSetOutput (
  53. IN UINT8 Expander,
  54. IN UINT8 Pin,
  55. IN UINT8 Value
  56. );
  57. /**
  58. Returns the data from register value giving in the input.
  59. This function is to get the data from the Expander
  60. Registers by following the I2C Protocol communication
  61. @param[in] Bar0 Bar address of the SerialIo Controller
  62. @param[in] Address Expander Value with in the Contoller
  63. @param[in] Register Address of Input/Output/Configure/Polarity
  64. registers with in the Expander
  65. @retval UINT8 Value returned from the register
  66. **/
  67. UINT8
  68. GpioExpGetInput (
  69. IN UINT8 Expander,
  70. IN UINT8 Pin
  71. );
  72. /**
  73. Configures all registers of a single IO Expander in one go.
  74. @param[in] Expander Expander number (0/1)
  75. @param[in] Direction Bit-encoded direction values. BIT0 is for pin0, etc. 0=output, 1=input
  76. @param[in] Polarity Bit-encoded input inversion values. BIT0 is for pin0, etc. 0=normal, 1=inversion
  77. @param[in] Output Bit-encoded output state, ignores polarity, only applicable if direction=INPUT. BIT0 is for pin0, etc. 0=low, 1=high
  78. **/
  79. VOID
  80. GpioExpBulkConfig (
  81. IN UINT8 Expander,
  82. IN UINT32 Direction,
  83. IN UINT32 Polarity,
  84. IN UINT32 Output
  85. );
  86. /**
  87. Returns the Controller on which GPIO expander is present.
  88. This function returns the Controller value
  89. @param[out] Controller Pointer to a Controller value on
  90. which I2C expander is configured.
  91. @retval EFI_SUCCESS non.
  92. **/
  93. EFI_STATUS
  94. GpioExpGetController (
  95. OUT UINT8 *Controller
  96. );
  97. #endif