MdeModulePkg/SdMmcHcDxe: Implement revision 3 of SdMmcOverrideProtocol
https://bugzilla.tianocore.org/show_bug.cgi?id=1882 Implement support for GetOperatingParamters notify phase in SdMmcHcDxe driver. GetOperatingParameters notify phase is signaled before we start card detection and initialization. Code has been updated for both eMMC and SD card controllers to take into consideration those new parameters. Initialization process has been divided into 2 steps. In the first step we bring the link up to the point where we can get card identification data(Extended CSD in eMMC case and SWITCH command response in SD card case). This data is later used along with controller capabilities and operating parameters passed in GetOperatingParameters phase to choose preferred bus settings in GetTargetBusSettings function. Those settings are later on to start bus training to high speeds. If user passes incompatible setting with selected bus timing driver will assume it's standard behavior with respect to that setting. For instance if HS400 has been selected as a target bus timing due to card and controller support bus width setting of 4 and 1 bit won't be respected and 8 bit setting will be chosen instead. Tests on Marvell boards were also performed by Marcin Wojtas <mw@semihalf.com>: https://edk2.groups.io/g/devel/message/42999 Board 1 (out of tree): SD - OK, MMC - OK Board 2: (Armada80x0McBin): SD - OK, MMC - OK Board 3: (Armada70x0Db): SD - problems, MMC - OK Please note that the problem on Armada70x0Db SD devices are introduced by adding new types of SD bus modes, a subsequent patch within edk2-platforms repository will be proposed to address it. (More details can be referred from the above link.) Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Regression-tested-by: Sumit Garg <sumit.garg@linaro.org>
This commit is contained in:
committed by
Hao A Wu
parent
f56cc67f62
commit
adec1f5deb
@@ -28,6 +28,11 @@ EFI_DRIVER_BINDING_PROTOCOL gSdMmcPciHcDriverBinding = {
|
||||
NULL
|
||||
};
|
||||
|
||||
#define SLOT_INIT_TEMPLATE {0, UnknownSlot, 0, 0, 0, \
|
||||
{EDKII_SD_MMC_BUS_WIDTH_IGNORE,\
|
||||
EDKII_SD_MMC_CLOCK_FREQ_IGNORE,\
|
||||
{EDKII_SD_MMC_DRIVER_STRENGTH_IGNORE}}}
|
||||
|
||||
//
|
||||
// Template for SD/MMC host controller private data.
|
||||
//
|
||||
@@ -50,8 +55,12 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate = {
|
||||
// Queue
|
||||
INITIALIZE_LIST_HEAD_VARIABLE (gSdMmcPciHcTemplate.Queue),
|
||||
{ // Slot
|
||||
{0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0},
|
||||
{0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}, {0, UnknownSlot, 0, 0, 0}
|
||||
SLOT_INIT_TEMPLATE,
|
||||
SLOT_INIT_TEMPLATE,
|
||||
SLOT_INIT_TEMPLATE,
|
||||
SLOT_INIT_TEMPLATE,
|
||||
SLOT_INIT_TEMPLATE,
|
||||
SLOT_INIT_TEMPLATE
|
||||
},
|
||||
{ // Capability
|
||||
{0},
|
||||
@@ -328,6 +337,7 @@ SdMmcPciHcEnumerateDevice (
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
Tests to see if this driver supports a given controller. If a child device is provided,
|
||||
it further tests to see if this driver supports creating a handle for the specified child device.
|
||||
@@ -619,7 +629,6 @@ SdMmcPciHcDriverBindingStart (
|
||||
Support64BitDma = TRUE;
|
||||
for (Slot = FirstBar; Slot < (FirstBar + SlotNum); Slot++) {
|
||||
Private->Slot[Slot].Enable = TRUE;
|
||||
|
||||
//
|
||||
// Get SD/MMC Pci Host Controller Version
|
||||
//
|
||||
@@ -635,19 +644,34 @@ SdMmcPciHcDriverBindingStart (
|
||||
|
||||
Private->BaseClkFreq[Slot] = Private->Capability[Slot].BaseClkFreq;
|
||||
|
||||
if (mOverride != NULL && mOverride->Capability != NULL) {
|
||||
Status = mOverride->Capability (
|
||||
Controller,
|
||||
Slot,
|
||||
&Private->Capability[Slot],
|
||||
&Private->BaseClkFreq[Slot]
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: Failed to override capability - %r\n",
|
||||
__FUNCTION__, Status));
|
||||
continue;
|
||||
if (mOverride != NULL) {
|
||||
if (mOverride->Capability != NULL) {
|
||||
Status = mOverride->Capability (
|
||||
Controller,
|
||||
Slot,
|
||||
&Private->Capability[Slot],
|
||||
&Private->BaseClkFreq[Slot]
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: Failed to override capability - %r\n",
|
||||
__FUNCTION__, Status));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (mOverride->NotifyPhase != NULL) {
|
||||
Status = mOverride->NotifyPhase (
|
||||
Controller,
|
||||
Slot,
|
||||
EdkiiSdMmcGetOperatingParam,
|
||||
(VOID*)&Private->Slot[Slot].OperatingParameters
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: Failed to get operating parameters, using defaults\n", __FUNCTION__));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DumpCapabilityReg (Slot, &Private->Capability[Slot]);
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
|
Reference in New Issue
Block a user