PlatformLeds.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /** @file
  2. Platform helper LED routines.
  3. Copyright (c) 2013-2015 Intel Corporation.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiDxe.h>
  7. #include "CommonHeader.h"
  8. //
  9. // Routines defined in other source modules of this component.
  10. //
  11. //
  12. // Routines local to this source module.
  13. //
  14. VOID
  15. GalileoGen2RouteOutFlashUpdateLed (
  16. VOID
  17. )
  18. {
  19. //
  20. // For GpioNums below values 0 to 7 are for Port0 ie P0-0 - P0-7 and
  21. // values 8 to 15 are for Port1 ie P1-0 - P1-7.
  22. //
  23. //
  24. // Disable Pull-ups / pull downs on EXP0 pin for LVL_B_PU7 signal.
  25. //
  26. PlatformPcal9555GpioDisablePull (
  27. GALILEO_GEN2_IOEXP0_7BIT_SLAVE_ADDR, // IO Expander 0.
  28. 15 // P1-7.
  29. );
  30. //
  31. // Make LVL_B_OE7_N an output pin.
  32. //
  33. PlatformPcal9555GpioSetDir (
  34. GALILEO_GEN2_IOEXP0_7BIT_SLAVE_ADDR, // IO Expander 0.
  35. 14, // P1-6.
  36. FALSE
  37. );
  38. //
  39. // Set level of LVL_B_OE7_N to low.
  40. //
  41. PlatformPcal9555GpioSetLevel (
  42. GALILEO_GEN2_IOEXP0_7BIT_SLAVE_ADDR,
  43. 14,
  44. FALSE
  45. );
  46. //
  47. // Make MUX8_SEL an output pin.
  48. //
  49. PlatformPcal9555GpioSetDir (
  50. GALILEO_GEN2_IOEXP1_7BIT_SLAVE_ADDR, // IO Expander 1.
  51. 14, // P1-6.
  52. FALSE
  53. );
  54. //
  55. // Set level of MUX8_SEL to low to route GPIO_SUS<5> to LED.
  56. //
  57. PlatformPcal9555GpioSetLevel (
  58. GALILEO_GEN2_IOEXP1_7BIT_SLAVE_ADDR, // IO Expander 1.
  59. 14, // P1-6.
  60. FALSE
  61. );
  62. }
  63. //
  64. // Routines exported by this source module.
  65. //
  66. /**
  67. Init platform LEDs into known state.
  68. @param PlatformType Executing platform type.
  69. @param I2cBus Pointer to I2c Host controller protocol.
  70. @retval EFI_SUCCESS Operation success.
  71. **/
  72. EFI_STATUS
  73. EFIAPI
  74. PlatformLedInit (
  75. IN CONST EFI_PLATFORM_TYPE Type
  76. )
  77. {
  78. EFI_BOOT_MODE BootMode;
  79. BootMode = GetBootModeHob ();
  80. //
  81. // Init Flash update / recovery LED in OFF state.
  82. //
  83. if (BootMode == BOOT_ON_FLASH_UPDATE || BootMode == BOOT_IN_RECOVERY_MODE) {
  84. if (Type == GalileoGen2) {
  85. PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_GEN2_FLASH_UPDATE_LED_RESUMEWELL_GPIO, FALSE);
  86. GalileoGen2RouteOutFlashUpdateLed ();
  87. } else if (Type == Galileo) {
  88. PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_FLASH_UPDATE_LED_RESUMEWELL_GPIO, FALSE);
  89. } else {
  90. //
  91. // These platforms have no flash update LED.
  92. //
  93. }
  94. }
  95. return EFI_SUCCESS;
  96. }
  97. /**
  98. Turn on or off platform flash update LED.
  99. @param PlatformType Executing platform type.
  100. @param TurnOn If TRUE turn on else turn off.
  101. @retval EFI_SUCCESS Operation success.
  102. **/
  103. EFI_STATUS
  104. EFIAPI
  105. PlatformFlashUpdateLed (
  106. IN CONST EFI_PLATFORM_TYPE Type,
  107. IN CONST BOOLEAN TurnOn
  108. )
  109. {
  110. if (Type == GalileoGen2) {
  111. PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_GEN2_FLASH_UPDATE_LED_RESUMEWELL_GPIO, TurnOn);
  112. } else if (Type == Galileo) {
  113. PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_FLASH_UPDATE_LED_RESUMEWELL_GPIO, TurnOn);
  114. } else {
  115. //
  116. // These platforms have no flash update LED.
  117. //
  118. }
  119. return EFI_SUCCESS;
  120. }