summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorFeng Tian <feng.tian@intel.com>2016-05-03 09:49:47 +0800
committerFeng Tian <feng.tian@intel.com>2016-05-06 16:10:00 +0800
commit8c983d3e06da799e623a9f46fcaa207455482091 (patch)
treee0f732a70300114c5ce5169d390e4da0db420d96 /MdeModulePkg
parente7e89b0861fa561c2c13eee3271655c100b3abb9 (diff)
downloadedk2-8c983d3e06da799e623a9f46fcaa207455482091.zip
edk2-8c983d3e06da799e623a9f46fcaa207455482091.tar.gz
edk2-8c983d3e06da799e623a9f46fcaa207455482091.tar.bz2
MdeModulePkg/SdMmcPciHcDxe: Error handling enhance on tuning procedure
Enhance the code to reset tuning circuit when tuning error case happens. Cc: Wu, Hao A <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian <feng.tian@intel.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c22
-rw-r--r--MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c19
-rw-r--r--MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c18
-rw-r--r--MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c18
4 files changed, 56 insertions, 21 deletions
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
index 443f93f..0796df3 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
@@ -1,7 +1,7 @@
/** @file
This file provides some helper functions which are specific for EMMC device.
- 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
@@ -540,17 +540,25 @@ EmmcTuningClkForHs200 (
return Status;
}
- if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ if ((HostCtrl2 & (BIT6 | BIT7)) == 0) {
break;
}
+
+ if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ return EFI_SUCCESS;
+ }
} while (++Retry < 40);
- if (Retry == 40) {
- Status = EFI_TIMEOUT;
- DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block exceeds 40 times\n"));
+ DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
+ //
+ // Abort the tuning procedure and reset the tuning circuit.
+ //
+ HostCtrl2 = (UINT8)~(BIT6 | BIT7);
+ Status = SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
-
- return Status;
+ return EFI_DEVICE_ERROR;
}
/**
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
index b2a0857..b4e2c58 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
@@ -787,17 +787,24 @@ SdCardTuningClock (
return Status;
}
- if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ if ((HostCtrl2 & (BIT6 | BIT7)) == 0) {
break;
}
+ if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ return EFI_SUCCESS;
+ }
} while (++Retry < 40);
- if (Retry == 40) {
- Status = EFI_TIMEOUT;
- DEBUG ((EFI_D_ERROR, "SdCardTuningClock: Send tuning block exceeds 40 times\n"));
+ DEBUG ((EFI_D_ERROR, "SdCardTuningClock: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
+ //
+ // Abort the tuning procedure and reset the tuning circuit.
+ //
+ HostCtrl2 = (UINT8)~(BIT6 | BIT7);
+ Status = SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
-
- return Status;
+ return EFI_DEVICE_ERROR;
}
/**
diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c
index 3ffc477..e23d03c 100644
--- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c
+++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c
@@ -2305,15 +2305,25 @@ EmmcPeimTuningClkForHs200 (
return Status;
}
- if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ if ((HostCtrl2 & (BIT6 | BIT7)) == 0) {
break;
}
+
+ if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ return EFI_SUCCESS;
+ }
} while (++Retry < 40);
- if (Retry == 40) {
- Status = EFI_TIMEOUT;
+ DEBUG ((EFI_D_ERROR, "EmmcPeimTuningClkForHs200: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
+ //
+ // Abort the tuning procedure and reset the tuning circuit.
+ //
+ HostCtrl2 = (UINT8)~(BIT6 | BIT7);
+ Status = EmmcPeimHcAndMmio (Slot->EmmcHcBase + EMMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
- return Status;
+ return EFI_DEVICE_ERROR;
}
/**
diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c
index 3f327f8..bb6df8f 100644
--- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c
+++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c
@@ -2523,15 +2523,25 @@ SdPeimTuningClock (
return Status;
}
- if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ if ((HostCtrl2 & (BIT6 | BIT7)) == 0) {
break;
}
+
+ if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
+ return EFI_SUCCESS;
+ }
} while (++Retry < 40);
- if (Retry == 40) {
- Status = EFI_TIMEOUT;
+ DEBUG ((EFI_D_ERROR, "SdPeimTuningClock: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
+ //
+ // Abort the tuning procedure and reset the tuning circuit.
+ //
+ HostCtrl2 = (UINT8)~(BIT6 | BIT7);
+ Status = SdPeimHcAndMmio (Slot->SdHcBase + SD_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
- return Status;
+ return EFI_DEVICE_ERROR;
}
/**