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>
This commit is contained in:
@@ -583,6 +583,20 @@ SdMmcHcCardDetect (
|
||||
UINT16 Data;
|
||||
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
|
||||
//
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user