]> git.proxmox.com Git - mirror_edk2.git/blobdiff - QuarkPlatformPkg/Platform/Pei/PlatformInit/PlatformEarlyInit.c
QuarkPlatformPkg/PlatformInit: Fix recovery detection issues
[mirror_edk2.git] / QuarkPlatformPkg / Platform / Pei / PlatformInit / PlatformEarlyInit.c
index 756cc4a7a33337e0d50600c972588fbcd6ffe256..0f71b1fda21d9e18bfd688d568bf372474170f03 100644 (file)
@@ -200,7 +200,8 @@ SetLanControllerMacAddr (
 **/\r
 EFI_STATUS\r
 EarlyPlatformConfigGpioExpanders (\r
-  IN CONST EFI_PLATFORM_TYPE              PlatformType\r
+  IN CONST EFI_PLATFORM_TYPE              PlatformType,\r
+  EFI_BOOT_MODE                           BootMode\r
   )\r
 {\r
   EFI_STATUS              Status;\r
@@ -266,6 +267,30 @@ EarlyPlatformConfigGpioExpanders (
       GALILEO_GEN2_IOEXP2_7BIT_SLAVE_ADDR,  // IO Expander 2.\r
       15                                    // P1-7.\r
       );\r
+\r
+    if (BootMode != BOOT_IN_RECOVERY_MODE) {\r
+      //\r
+      // Read state of Reset Button - EXP2.P1_7\r
+      // This GPIO is pulled high when the button is not pressed\r
+      // This GPIO reads low when button is pressed\r
+      //\r
+      if (!PlatformPcal9555GpioGetState (\r
+             GALILEO_GEN2_IOEXP2_7BIT_SLAVE_ADDR,  // IO Expander 2\r
+             15                                    // P1-7\r
+             )) {\r
+        DEBUG ((EFI_D_INFO, "  Force Recovery mode and reset\n"));\r
+\r
+        //\r
+        // Set 'B_CFG_STICKY_RW_FORCE_RECOVERY' sticky bit so we know we need to do a recovery following warm reset\r
+        //\r
+        QNCAltPortWrite (\r
+          QUARK_SCSS_SOC_UNIT_SB_PORT_ID,\r
+          QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW,\r
+          QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW) | B_CFG_STICKY_RW_FORCE_RECOVERY\r
+          );\r
+        ResetWarm();\r
+      }\r
+    }\r
   }\r
 \r
   //\r
@@ -393,6 +418,40 @@ EarlyPlatformConfigGpioExpanders (
       &Buffer\r
       );\r
     ASSERT_EFI_ERROR (Status);\r
+\r
+    if (BootMode != BOOT_IN_RECOVERY_MODE) {\r
+      //\r
+      // Read state of RESET_N_SHLD (GPORT5_BIT0)\r
+      //\r
+      Buffer[1] = 5;\r
+      Length = 1;\r
+      ReadLength = 1;\r
+      Status = I2cReadMultipleByte (\r
+                 I2CSlaveAddress,\r
+                 EfiI2CSevenBitAddrMode,\r
+                 &Length,\r
+                 &ReadLength,\r
+                 &Buffer[1]\r
+                 );\r
+      ASSERT_EFI_ERROR (Status);\r
+\r
+      //\r
+      // Return the state of GPORT5_BIT0\r
+      //\r
+      if ((Buffer[1] & BIT0) == 0) {\r
+        DEBUG ((EFI_D_INFO, "  Force Recovery mode and reset\n"));\r
+\r
+        //\r
+        // Set 'B_CFG_STICKY_RW_FORCE_RECOVERY' sticky bit so we know we need to do a recovery following warm reset\r
+        //\r
+        QNCAltPortWrite (\r
+          QUARK_SCSS_SOC_UNIT_SB_PORT_ID,\r
+          QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW,\r
+          QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW) | B_CFG_STICKY_RW_FORCE_RECOVERY\r
+          );\r
+        ResetWarm();\r
+      }\r
+    }\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -514,7 +573,7 @@ PeiInitPlatform (
   //\r
   //\r
   DEBUG ((EFI_D_INFO, "EarlyPlatformConfigGpioExpanders ()\n"));\r
-  EarlyPlatformConfigGpioExpanders (PlatformType);\r
+  EarlyPlatformConfigGpioExpanders (PlatformType, BootMode);\r
 \r
   //\r
   // Now that all of the pre-permanent memory activities have\r
@@ -791,8 +850,8 @@ EarlyPlatformInit (
   //\r
   if (CheckForResetDueToErrors (TRUE)) {\r
     if(FeaturePcdGet (WaitIfResetDueToError)) {\r
-      DEBUG ((EFI_D_ERROR, "Press any key to continue.\n"));\r
-      PlatformDebugPortGetChar8 ();\r
+      DEBUG ((EFI_D_ERROR, "Wait 10 seconds.\n"));\r
+      MicroSecondDelay(10000000);\r
     }\r
   }\r
 \r