]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Sd: update the sd detection logic
authorFeng Tian <feng.tian@intel.com>
Thu, 7 Apr 2016 08:28:56 +0000 (16:28 +0800)
committerFeng Tian <feng.tian@intel.com>
Thu, 21 Apr 2016 08:06:59 +0000 (16:06 +0800)
If there is no card presented before power on, there would
have no card change interrupt generated. This is a corner
case which can't be handled by old logic.

The patch is used to move card present detection in the front
of card change interrupt detection.

Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c

index 0a2f034cfca1c32a5790286c8dcfabe6dfac2eb5..59649e1cad4d4864d625bc43df2de01bd2309c5a 100644 (file)
@@ -4,7 +4,7 @@
 \r
   It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use.\r
 \r
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -613,7 +613,9 @@ SdMmcPciHcDriverBindingStart (
     // Check whether there is a SD/MMC card attached\r
     //\r
     Status = SdMmcHcCardDetect (PciIo, Slot, &MediaPresent);\r
-    if ((Status == EFI_MEDIA_CHANGED) && (MediaPresent == FALSE)) {\r
+    if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) {\r
+      continue;\r
+    } else if (MediaPresent == FALSE) {\r
       DEBUG ((EFI_D_ERROR, "SdMmcHcCardDetect: No device attached in Slot[%d]!!!\n", Slot));\r
       continue;\r
     }\r
index d2bd112c14273aafa5966bb72f6c5b132d85bd0c..baa12f44eeacea52453f5c01ea687f665ad72d2d 100644 (file)
@@ -583,6 +583,20 @@ SdMmcHcCardDetect (
   UINT16                    Data;\r
   UINT32                    PresentState;\r
 \r
+  //\r
+  // Check Present State Register to see if there is a card presented.\r
+  //\r
+  Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if ((PresentState & BIT16) != 0) {\r
+    *MediaPresent = TRUE;\r
+  } else {\r
+    *MediaPresent = FALSE;\r
+  }\r
+\r
   //\r
   // Check Normal Interrupt Status Register\r
   //\r
@@ -601,19 +615,6 @@ SdMmcHcCardDetect (
       return Status;\r
     }\r
 \r
-    //\r
-    // Check Present State Register to see if there is a card presented.\r
-    //\r
-    Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    if ((PresentState & BIT16) != 0) {\r
-      *MediaPresent = TRUE;\r
-    } else {\r
-      *MediaPresent = FALSE;\r
-    }\r
     return EFI_MEDIA_CHANGED;\r
   }\r
 \r