1 /** @file 2 Platform helper LED routines. 3 4 Copyright (c) 2013-2015 Intel Corporation. 5 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #include <PiDxe.h> 17 18 #include "CommonHeader.h" 19 20 // 21 // Routines defined in other source modules of this component. 22 // 23 24 // 25 // Routines local to this source module. 26 // 27 28 VOID 29 GalileoGen2RouteOutFlashUpdateLed ( 30 VOID 31 ) 32 { 33 // 34 // For GpioNums below values 0 to 7 are for Port0 ie P0-0 - P0-7 and 35 // values 8 to 15 are for Port1 ie P1-0 - P1-7. 36 // 37 38 // 39 // Disable Pull-ups / pull downs on EXP0 pin for LVL_B_PU7 signal. 40 // 41 PlatformPcal9555GpioDisablePull ( 42 GALILEO_GEN2_IOEXP0_7BIT_SLAVE_ADDR, // IO Expander 0. 43 15 // P1-7. 44 ); 45 46 // 47 // Make LVL_B_OE7_N an output pin. 48 // 49 PlatformPcal9555GpioSetDir ( 50 GALILEO_GEN2_IOEXP0_7BIT_SLAVE_ADDR, // IO Expander 0. 51 14, // P1-6. 52 FALSE 53 ); 54 55 // 56 // Set level of LVL_B_OE7_N to low. 57 // 58 PlatformPcal9555GpioSetLevel ( 59 GALILEO_GEN2_IOEXP0_7BIT_SLAVE_ADDR, 60 14, 61 FALSE 62 ); 63 64 // 65 // Make MUX8_SEL an output pin. 66 // 67 PlatformPcal9555GpioSetDir ( 68 GALILEO_GEN2_IOEXP1_7BIT_SLAVE_ADDR, // IO Expander 1. 69 14, // P1-6. 70 FALSE 71 ); 72 73 // 74 // Set level of MUX8_SEL to low to route GPIO_SUS<5> to LED. 75 // 76 PlatformPcal9555GpioSetLevel ( 77 GALILEO_GEN2_IOEXP1_7BIT_SLAVE_ADDR, // IO Expander 1. 78 14, // P1-6. 79 FALSE 80 ); 81 } 82 83 // 84 // Routines exported by this source module. 85 // 86 87 /** 88 Init platform LEDs into known state. 89 90 @param PlatformType Executing platform type. 91 @param I2cBus Pointer to I2c Host controller protocol. 92 93 @retval EFI_SUCCESS Operation success. 94 95 **/ 96 EFI_STATUS 97 EFIAPI 98 PlatformLedInit ( 99 IN CONST EFI_PLATFORM_TYPE Type 100 ) 101 { 102 EFI_BOOT_MODE BootMode; 103 104 BootMode = GetBootModeHob (); 105 106 // 107 // Init Flash update / recovery LED in OFF state. 108 // 109 if (BootMode == BOOT_ON_FLASH_UPDATE || BootMode == BOOT_IN_RECOVERY_MODE) { 110 if (Type == GalileoGen2) { 111 PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_GEN2_FLASH_UPDATE_LED_RESUMEWELL_GPIO, FALSE); 112 GalileoGen2RouteOutFlashUpdateLed (); 113 } else if (Type == Galileo) { 114 PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_FLASH_UPDATE_LED_RESUMEWELL_GPIO, FALSE); 115 } else { 116 // 117 // These platforms have no flash update LED. 118 // 119 } 120 } 121 122 return EFI_SUCCESS; 123 } 124 125 /** 126 Turn on or off platform flash update LED. 127 128 @param PlatformType Executing platform type. 129 @param TurnOn If TRUE turn on else turn off. 130 131 @retval EFI_SUCCESS Operation success. 132 133 **/ 134 EFI_STATUS 135 EFIAPI 136 PlatformFlashUpdateLed ( 137 IN CONST EFI_PLATFORM_TYPE Type, 138 IN CONST BOOLEAN TurnOn 139 ) 140 { 141 if (Type == GalileoGen2) { 142 PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_GEN2_FLASH_UPDATE_LED_RESUMEWELL_GPIO, TurnOn); 143 } else if (Type == Galileo) { 144 PlatformLegacyGpioSetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL, GALILEO_FLASH_UPDATE_LED_RESUMEWELL_GPIO, TurnOn); 145 } else { 146 // 147 // These platforms have no flash update LED. 148 // 149 } 150 151 return EFI_SUCCESS; 152 } 153