diff options
author | Feng Tian <feng.tian@intel.com> | 2016-04-07 16:28:56 +0800 |
---|---|---|
committer | Feng Tian <feng.tian@intel.com> | 2016-04-21 16:06:59 +0800 |
commit | 2e9107b87ed1350e2abe0bb777ef913a72eaff4a (patch) | |
tree | bbc0997c15f39275edf79e681810e9d087719bd0 | |
parent | b9953b65062015054821aaa631498b8fbd32e781 (diff) | |
download | edk2-platforms-2e9107b87ed1350e2abe0bb777ef913a72eaff4a.tar.xz |
MdeModulePkg/Sd: update the sd detection logic
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>
-rw-r--r-- | MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 6 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 27 |
2 files changed, 18 insertions, 15 deletions
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c index 0a2f034cfc..59649e1cad 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c @@ -4,7 +4,7 @@ It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use.
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -613,7 +613,9 @@ SdMmcPciHcDriverBindingStart ( // Check whether there is a SD/MMC card attached
//
Status = SdMmcHcCardDetect (PciIo, Slot, &MediaPresent);
- if ((Status == EFI_MEDIA_CHANGED) && (MediaPresent == FALSE)) {
+ if (EFI_ERROR (Status) && (Status != EFI_MEDIA_CHANGED)) {
+ continue;
+ } else if (MediaPresent == FALSE) {
DEBUG ((EFI_D_ERROR, "SdMmcHcCardDetect: No device attached in Slot[%d]!!!\n", Slot));
continue;
}
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index d2bd112c14..baa12f44ee 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -584,6 +584,20 @@ SdMmcHcCardDetect ( UINT32 PresentState;
//
+ // Check Present State Register to see if there is a card presented.
+ //
+ Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if ((PresentState & BIT16) != 0) {
+ *MediaPresent = TRUE;
+ } else {
+ *MediaPresent = FALSE;
+ }
+
+ //
// Check Normal Interrupt Status Register
//
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_NOR_INT_STS, TRUE, sizeof (Data), &Data);
@@ -601,19 +615,6 @@ SdMmcHcCardDetect ( return Status;
}
- //
- // Check Present State Register to see if there is a card presented.
- //
- Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((PresentState & BIT16) != 0) {
- *MediaPresent = TRUE;
- } else {
- *MediaPresent = FALSE;
- }
return EFI_MEDIA_CHANGED;
}
|