/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. */
EFI_STATUS SdPeimVoltageCheck(IN SD_PEIM_HC_SLOT *Slot, IN UINT8 SupplyVoltage, IN UINT8 CheckPattern)
/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details. */
EFI_STATUS SdPeimVoltageCheck(IN SD_PEIM_HC_SLOT *Slot, IN UINT8 SupplyVoltage, IN UINT8 CheckPattern)
{
  SD_COMMAND_BLOCK   SdCmdBlk;
  SD_STATUS_BLOCK    SdStatusBlk;
  SD_COMMAND_PACKET  Packet;
  EFI_STATUS         Status;
  ZeroMem (&SdCmdBlk, sizeof (SdCmdBlk));
  ZeroMem (&SdStatusBlk, sizeof (SdStatusBlk));
  ZeroMem (&Packet, sizeof (Packet));
  Packet.SdCmdBlk    = &SdCmdBlk;
  Packet.SdStatusBlk = &SdStatusBlk;
  Packet.Timeout     = SD_TIMEOUT;
  SdCmdBlk.CommandIndex    = SD_SEND_IF_COND;
  SdCmdBlk.CommandType     = SdCommandTypeBcr;
  SdCmdBlk.ResponseType    = SdResponseTypeR7;
  SdCmdBlk.CommandArgument = (SupplyVoltage << 8) | CheckPattern;
  Status = SdPeimExecCmd (Slot, &Packet);
  if (!EFI_ERROR (Status)) {
    if (SdStatusBlk.Resp0 != SdCmdBlk.CommandArgument) {
      return EFI_DEVICE_ERROR;
    }
  }
  return Status;
}