/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 and SD Host Controller Simplified Spec 3.0 section Figure 3-7 for details. */
EFI_STATUS SdPeimSwitchBusWidth(IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN UINT8 BusWidth)
/* Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 and SD Host Controller Simplified Spec 3.0 section Figure 3-7 for details. */
EFI_STATUS SdPeimSwitchBusWidth(IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN UINT8 BusWidth)
{
  EFI_STATUS  Status;
  UINT32      DevStatus;
  Status = SdPeimSetBusWidth (Slot, Rca, BusWidth);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  Status = SdPeimSendStatus (Slot, Rca, &DevStatus);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  if ((DevStatus >> 16) != 0) {
    return EFI_DEVICE_ERROR;
  }
  Status = SdPeimHcSetBusWidth (Slot->SdHcBase, BusWidth);
  return Status;
}