MdeModulePkg/SdMmcPciHcDxe: Add function to start SD clock

In SD card voltage switch flow we used to redo the
entire internal clock setup after voltage switch.
Since internal clock has already been setup this
is wasting time on polling the internal clock stable.
This commit changes it to only start the SD clock.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Marcin Wojtas <mw@semihalf.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>

Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
Tested-by: Marcin Wojtas <mw@semihalf.com>
Tested-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Albecki, Mateusz 2019-12-21 01:13:12 +08:00 committed by mergify[bot]
parent 49accdedf9
commit f68cb23c14
3 changed files with 47 additions and 12 deletions

View File

@ -1327,13 +1327,10 @@ SdCardIdentification (
goto Error; goto Error;
} }
// Status = SdMmcHcStartSdClock (PciIo, Slot);
// Restart the clock with first time parameters. if (EFI_ERROR (Status)) {
// NOTE: it is not required to actually restart the clock goto Error;
// and go through internal clock setup again. Some time }
// could be saved if we simply started the SD clock.
//
SdMmcHcClockSupply (Private, Slot, 0, TRUE, 400);
gBS->Stall (1000); gBS->Stall (1000);

View File

@ -758,6 +758,30 @@ SdMmcHcStopClock (
return Status; return Status;
} }
/**
Start the SD clock.
@param[in] PciIo The PCI IO protocol instance.
@param[in] Slot The slot number.
@retval EFI_SUCCESS Succeeded to start the SD clock.
@rtval Others Failed to start the SD clock.
**/
EFI_STATUS
SdMmcHcStartSdClock (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT8 Slot
)
{
UINT16 ClockCtrl;
//
// Set SD Clock Enable in the Clock Control register to 1
//
ClockCtrl = BIT2;
return SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof (ClockCtrl), &ClockCtrl);
}
/** /**
SD/MMC card clock supply. SD/MMC card clock supply.
@ -879,11 +903,10 @@ SdMmcHcClockSupply (
return Status; return Status;
} }
// Status = SdMmcHcStartSdClock (PciIo, Slot);
// Set SD Clock Enable in the Clock Control register to 1 if (EFI_ERROR (Status)) {
// return Status;
ClockCtrl = BIT2; }
Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof (ClockCtrl), &ClockCtrl);
// //
// We don't notify the platform on first time setup to avoid changing // We don't notify the platform on first time setup to avoid changing

View File

@ -478,6 +478,21 @@ SdMmcHcStopClock (
IN UINT8 Slot IN UINT8 Slot
); );
/**
Start the SD clock.
@param[in] PciIo The PCI IO protocol instance.
@param[in] Slot The slot number.
@retval EFI_SUCCESS Succeeded to start the SD clock.
@rtval Others Failed to start the SD clock.
**/
EFI_STATUS
SdMmcHcStartSdClock (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT8 Slot
);
/** /**
SD/MMC bus power control. SD/MMC bus power control.