/* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */
EFI_STATUS SdMmcHcInitPowerVoltage(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_HC_SLOT_CAP Capability)
/* Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details. */
EFI_STATUS SdMmcHcInitPowerVoltage(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_HC_SLOT_CAP Capability)
{
  EFI_STATUS  Status;
  UINT8       MaxVoltage;
  UINT8       HostCtrl2;
  if (Capability.Voltage33 != 0) {
    MaxVoltage = 0x0E;
  } else if (Capability.Voltage30 != 0) {
    MaxVoltage = 0x0C;
  } else if (Capability.Voltage18 != 0) {
    MaxVoltage = 0x0A;
    HostCtrl2  = BIT3;
    Status     = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
    gBS->Stall (5000);
    if (EFI_ERROR (Status)) {
      return Status;
    }
  } else {
    ASSERT (FALSE);
    return EFI_DEVICE_ERROR;
  }
  Status = SdMmcHcPowerControl (PciIo, Slot, MaxVoltage);
  return Status;
}