TianoCore EDK2 master
Loading...
Searching...
No Matches
SdHci.c File Reference
#include "SdBlockIoPei.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI SdPeimHcRwMmio (IN UINTN Address, IN BOOLEAN Read, IN UINT8 Count, IN OUT VOID *Data)
 
EFI_STATUS EFIAPI SdPeimHcOrMmio (IN UINTN Address, IN UINT8 Count, IN VOID *OrData)
 
EFI_STATUS EFIAPI SdPeimHcAndMmio (IN UINTN Address, IN UINT8 Count, IN VOID *AndData)
 
EFI_STATUS EFIAPI SdPeimHcCheckMmioSet (IN UINTN Address, IN UINT8 Count, IN UINT64 MaskValue, IN UINT64 TestValue)
 
EFI_STATUS EFIAPI SdPeimHcWaitMmioSet (IN UINTN Address, IN UINT8 Count, IN UINT64 MaskValue, IN UINT64 TestValue, IN UINT64 Timeout)
 
EFI_STATUS SdPeimHcReset (IN UINTN Bar)
 
EFI_STATUS SdPeimHcEnableInterrupt (IN UINTN Bar)
 
EFI_STATUS SdPeimHcGetCapability (IN UINTN Bar, OUT SD_HC_SLOT_CAP *Capability)
 
EFI_STATUS SdPeimHcCardDetect (IN UINTN Bar)
 
EFI_STATUS SdPeimHcStopClock (IN UINTN Bar)
 
EFI_STATUS SdPeimHcClockSupply (IN UINTN Bar, IN UINT64 ClockFreq)
 
EFI_STATUS SdPeimHcPowerControl (IN UINTN Bar, IN UINT8 PowerCtrl)
 
EFI_STATUS SdPeimHcSetBusWidth (IN UINTN Bar, IN UINT16 BusWidth)
 
EFI_STATUS SdPeimHcInitClockFreq (IN UINTN Bar)
 
EFI_STATUS SdPeimHcInitPowerVoltage (IN UINTN Bar)
 
EFI_STATUS SdPeimHcInitTimeoutCtrl (IN UINTN Bar)
 
EFI_STATUS SdPeimHcInitHost (IN UINTN Bar)
 
EFI_STATUS SdPeimHcLedOnOff (IN UINTN Bar, IN BOOLEAN On)
 
EFI_STATUS BuildAdmaDescTable (IN SD_TRB *Trb)
 
SD_TRBSdPeimCreateTrb (IN SD_PEIM_HC_SLOT *Slot, IN SD_COMMAND_PACKET *Packet)
 
VOID SdPeimFreeTrb (IN SD_TRB *Trb)
 
EFI_STATUS SdPeimCheckTrbEnv (IN UINTN Bar, IN SD_TRB *Trb)
 
EFI_STATUS SdPeimWaitTrbEnv (IN UINTN Bar, IN SD_TRB *Trb)
 
EFI_STATUS SdPeimExecTrb (IN UINTN Bar, IN SD_TRB *Trb)
 
EFI_STATUS SdPeimCheckTrbResult (IN UINTN Bar, IN SD_TRB *Trb)
 
EFI_STATUS SdPeimWaitTrbResult (IN UINTN Bar, IN SD_TRB *Trb)
 
EFI_STATUS EFIAPI SdPeimExecCmd (IN SD_PEIM_HC_SLOT *Slot, IN OUT SD_COMMAND_PACKET *Packet)
 
EFI_STATUS SdPeimReset (IN SD_PEIM_HC_SLOT *Slot)
 
EFI_STATUS SdPeimVoltageCheck (IN SD_PEIM_HC_SLOT *Slot, IN UINT8 SupplyVoltage, IN UINT8 CheckPattern)
 
EFI_STATUS SdioSendOpCond (IN SD_PEIM_HC_SLOT *Slot, IN UINT32 VoltageWindow, IN BOOLEAN S18r)
 
EFI_STATUS SdPeimSendOpCond (IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN UINT32 VoltageWindow, IN BOOLEAN S18r, IN BOOLEAN Xpc, IN BOOLEAN Hcs, OUT UINT32 *Ocr)
 
EFI_STATUS SdPeimAllSendCid (IN SD_PEIM_HC_SLOT *Slot)
 
EFI_STATUS SdPeimSetRca (IN SD_PEIM_HC_SLOT *Slot, OUT UINT16 *Rca)
 
EFI_STATUS SdPeimGetCsd (IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, OUT SD_CSD *Csd)
 
EFI_STATUS SdPeimSelect (IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca)
 
EFI_STATUS SdPeimVoltageSwitch (IN SD_PEIM_HC_SLOT *Slot)
 
EFI_STATUS SdPeimSetBusWidth (IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN UINT8 BusWidth)
 
EFI_STATUS SdPeimSwitch (IN SD_PEIM_HC_SLOT *Slot, IN UINT8 AccessMode, IN UINT8 CommandSystem, IN UINT8 DriveStrength, IN UINT8 PowerLimit, IN BOOLEAN Mode, OUT UINT8 *SwitchResp)
 
EFI_STATUS SdPeimSendStatus (IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, OUT UINT32 *DevStatus)
 
EFI_STATUS SdPeimRwSingleBlock (IN SD_PEIM_HC_SLOT *Slot, IN EFI_LBA Lba, IN UINT32 BlockSize, IN VOID *Buffer, IN UINTN BufferSize, IN BOOLEAN IsRead)
 
EFI_STATUS SdPeimRwMultiBlocks (IN SD_PEIM_HC_SLOT *Slot, IN EFI_LBA Lba, IN UINT32 BlockSize, IN VOID *Buffer, IN UINTN BufferSize, IN BOOLEAN IsRead)
 
EFI_STATUS SdPeimSendTuningBlk (IN SD_PEIM_HC_SLOT *Slot)
 
EFI_STATUS SdPeimTuningClock (IN SD_PEIM_HC_SLOT *Slot)
 
EFI_STATUS SdPeimSwitchBusWidth (IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN UINT8 BusWidth)
 
EFI_STATUS SdPeimSetBusMode (IN SD_PEIM_HC_SLOT *Slot, IN UINT16 Rca, IN BOOLEAN S18a)
 
EFI_STATUS SdPeimIdentification (IN SD_PEIM_HC_SLOT *Slot)
 

Detailed Description

Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SdHci.c.

Function Documentation

◆ BuildAdmaDescTable()

EFI_STATUS BuildAdmaDescTable ( IN SD_TRB Trb)

Build ADMA descriptor table for transfer.

Refer to SD Host Controller Simplified spec 3.0 Section 1.13 for details.

Parameters
[in]TrbThe pointer to the SD_TRB instance.
Return values
EFI_SUCCESSThe ADMA descriptor table is created successfully.
OthersThe ADMA descriptor table isn't created successfully.

Definition at line 930 of file SdHci.c.

◆ SdioSendOpCond()

EFI_STATUS SdioSendOpCond ( IN SD_PEIM_HC_SLOT Slot,
IN UINT32  VoltageWindow,
IN BOOLEAN  S18r 
)

Send command SDIO_SEND_OP_COND to the device to see whether it is SDIO device.

Refer to SDIO Simplified Spec 3 Section 3.2 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]VoltageWindowThe supply voltage window.
[in]S18rThe boolean to show if it should switch to 1.8v.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 1853 of file SdHci.c.

◆ SdPeimAllSendCid()

EFI_STATUS SdPeimAllSendCid ( IN SD_PEIM_HC_SLOT Slot)

Broadcast command ALL_SEND_CID to the bus to ask all the SD devices to send the data of their CID registers.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 1974 of file SdHci.c.

◆ SdPeimCheckTrbEnv()

EFI_STATUS SdPeimCheckTrbEnv ( IN UINTN  Bar,
IN SD_TRB Trb 
)

Check if the env is ready for execute specified TRB.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]TrbThe pointer to the SD_TRB instance.
Return values
EFI_SUCCESSThe env is ready for TRB execution.
EFI_NOT_READYThe env is not ready for TRB execution.
OthersSome erros happen.

Definition at line 1130 of file SdHci.c.

◆ SdPeimCheckTrbResult()

EFI_STATUS SdPeimCheckTrbResult ( IN UINTN  Bar,
IN SD_TRB Trb 
)

Check the TRB execution result.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]TrbThe pointer to the SD_TRB instance.
Return values
EFI_SUCCESSThe TRB is executed successfully.
EFI_NOT_READYThe TRB is not completed for execution.
OthersSome erros happen when executing this request.

Definition at line 1410 of file SdHci.c.

◆ SdPeimCreateTrb()

SD_TRB * SdPeimCreateTrb ( IN SD_PEIM_HC_SLOT Slot,
IN SD_COMMAND_PACKET Packet 
)

Create a new TRB for the SD cmd request.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]PacketA pointer to the SD command data structure.
Returns
Created Trb or NULL.

Definition at line 1003 of file SdHci.c.

◆ SdPeimExecCmd()

EFI_STATUS EFIAPI SdPeimExecCmd ( IN SD_PEIM_HC_SLOT Slot,
IN OUT SD_COMMAND_PACKET Packet 
)

Sends SD command to an SD card that is attached to the SD controller.

If Packet is successfully sent to the SD card, then EFI_SUCCESS is returned.

If a device error occurs while sending the Packet, then EFI_DEVICE_ERROR is returned.

If Slot is not in a valid range for the SD controller, then EFI_INVALID_PARAMETER is returned.

If Packet defines a data command but both InDataBuffer and OutDataBuffer are NULL, EFI_INVALID_PARAMETER is returned.

Parameters
[in]SlotThe slot number of the Sd card to send the command to.
[in,out]PacketA pointer to the SD command data structure.
Return values
EFI_SUCCESSThe SD Command Packet was sent by the host.
EFI_DEVICE_ERRORA device error occurred while attempting to send the SD command Packet.
EFI_INVALID_PARAMETERPacket, Slot, or the contents of the Packet is invalid.
EFI_INVALID_PARAMETERPacket defines a data command but both InDataBuffer and OutDataBuffer are NULL.
EFI_NO_MEDIASD Device not present in the Slot.
EFI_UNSUPPORTEDThe command described by the SD Command Packet is not supported by the host controller.
EFI_BAD_BUFFER_SIZEThe InTransferLength or OutTransferLength exceeds the limit supported by SD card ( i.e. if the number of bytes exceed the Last LBA).

Definition at line 1701 of file SdHci.c.

◆ SdPeimExecTrb()

EFI_STATUS SdPeimExecTrb ( IN UINTN  Bar,
IN SD_TRB Trb 
)

Execute the specified TRB.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]TrbThe pointer to the SD_TRB instance.
Return values
EFI_SUCCESSThe TRB is sent to host controller successfully.
OthersSome erros happen when sending this request to the host controller.

Definition at line 1232 of file SdHci.c.

◆ SdPeimFreeTrb()

VOID SdPeimFreeTrb ( IN SD_TRB Trb)

Free the resource used by the TRB.

Parameters
[in]TrbThe pointer to the SD_TRB instance.

Definition at line 1099 of file SdHci.c.

◆ SdPeimGetCsd()

EFI_STATUS SdPeimGetCsd ( IN SD_PEIM_HC_SLOT Slot,
IN UINT16  Rca,
OUT SD_CSD Csd 
)

Send command SEND_CSD to the SD device to get the data of the CSD register.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]RcaThe relative device address of selected device.
[out]CsdThe buffer to store the content of the CSD register. Note the caller should ignore the lowest byte of this buffer as the content of this byte is meaningless even if the operation succeeds.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2062 of file SdHci.c.

◆ SdPeimHcAndMmio()

EFI_STATUS EFIAPI SdPeimHcAndMmio ( IN UINTN  Address,
IN UINT8  Count,
IN VOID *  AndData 
)

Do AND operation with the value of the specified SD host controller mmio register.

Parameters
[in]AddressThe address of the mmio register to be read/written.
[in]CountThe width of the mmio register in bytes. Must be 1, 2 , 4 or 8 bytes.
[in]AndDataThe pointer to the data used to do AND operation. The caller is responsible for having ownership of the data buffer and ensuring its size not less than Count bytes.
Return values
EFI_INVALID_PARAMETERThe Address or the AndData or the Count is not valid.
EFI_SUCCESSThe AND operation succeeds.
OthersThe AND operation fails.

Definition at line 155 of file SdHci.c.

◆ SdPeimHcCardDetect()

EFI_STATUS SdPeimHcCardDetect ( IN UINTN  Bar)

Detect whether there is a SD card attached at the specified SD host controller slot.

Refer to SD Host Controller Simplified spec 3.0 Section 3.1 for details.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSThere is a SD card attached.
EFI_NO_MEDIAThere is not a SD card attached.
OthersThe detection fails.

Definition at line 414 of file SdHci.c.

◆ SdPeimHcCheckMmioSet()

EFI_STATUS EFIAPI SdPeimHcCheckMmioSet ( IN UINTN  Address,
IN UINT8  Count,
IN UINT64  MaskValue,
IN UINT64  TestValue 
)

Wait for the value of the specified MMIO register set to the test value.

Parameters
[in]AddressThe address of the mmio register to be checked.
[in]CountThe width of the mmio register in bytes. Must be 1, 2, 4 or 8 bytes.
[in]MaskValueThe mask value of memory.
[in]TestValueThe test value of memory.
Return values
EFI_NOT_READYThe MMIO register hasn't set to the expected value.
EFI_SUCCESSThe MMIO register has expected value.
OthersThe MMIO operation fails.

Definition at line 204 of file SdHci.c.

◆ SdPeimHcClockSupply()

EFI_STATUS SdPeimHcClockSupply ( IN UINTN  Bar,
IN UINT64  ClockFreq 
)

SD card clock supply.

Refer to SD Host Controller Simplified spec 3.0 Section 3.2.1 for details.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]ClockFreqThe max clock frequency to be set. The unit is KHz.
Return values
EFI_SUCCESSThe clock is supplied successfully.
OthersThe clock isn't supplied successfully.

Definition at line 514 of file SdHci.c.

◆ SdPeimHcEnableInterrupt()

EFI_STATUS SdPeimHcEnableInterrupt ( IN UINTN  Bar)

Set all interrupt status bits in Normal and Error Interrupt Status Enable register.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSThe operation executes successfully.
OthersThe operation fails.

Definition at line 346 of file SdHci.c.

◆ SdPeimHcGetCapability()

EFI_STATUS SdPeimHcGetCapability ( IN UINTN  Bar,
OUT SD_HC_SLOT_CAP Capability 
)

Get the capability data from the specified slot.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[out]CapabilityThe buffer to store the capability data.
Return values
EFI_SUCCESSThe operation executes successfully.
OthersThe operation fails.

Definition at line 382 of file SdHci.c.

◆ SdPeimHcInitClockFreq()

EFI_STATUS SdPeimHcInitClockFreq ( IN UINTN  Bar)

Supply SD card with lowest clock frequency at initialization.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSThe clock is supplied successfully.
OthersThe clock isn't supplied successfully.

Definition at line 734 of file SdHci.c.

◆ SdPeimHcInitHost()

EFI_STATUS SdPeimHcInitHost ( IN UINTN  Bar)

Initial SD host controller with lowest clock frequency, max power and max timeout value at initialization.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSThe host controller is initialized successfully.
OthersThe host controller isn't initialized successfully.

Definition at line 868 of file SdHci.c.

◆ SdPeimHcInitPowerVoltage()

EFI_STATUS SdPeimHcInitPowerVoltage ( IN UINTN  Bar)

Supply SD card with maximum voltage at initialization.

Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSThe voltage is supplied successfully.
OthersThe voltage isn't supplied successfully.

Definition at line 777 of file SdHci.c.

◆ SdPeimHcInitTimeoutCtrl()

EFI_STATUS SdPeimHcInitTimeoutCtrl ( IN UINTN  Bar)

Initialize the Timeout Control register with most conservative value at initialization.

Refer to SD Host Controller Simplified spec 3.0 Section 2.2.15 for details.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSThe timeout control register is configured successfully.
OthersThe timeout control register isn't configured successfully.

Definition at line 844 of file SdHci.c.

◆ SdPeimHcLedOnOff()

EFI_STATUS SdPeimHcLedOnOff ( IN UINTN  Bar,
IN BOOLEAN  On 
)

Turn on/off LED.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]OnThe boolean to turn on/off LED.
Return values
EFI_SUCCESSThe LED is turned on/off successfully.
OthersThe LED isn't turned on/off successfully.

Definition at line 899 of file SdHci.c.

◆ SdPeimHcOrMmio()

EFI_STATUS EFIAPI SdPeimHcOrMmio ( IN UINTN  Address,
IN UINT8  Count,
IN VOID *  OrData 
)

Do OR operation with the value of the specified SD host controller mmio register.

Parameters
[in]AddressThe address of the mmio register to be read/written.
[in]CountThe width of the mmio register in bytes. Must be 1, 2 , 4 or 8 bytes.
[in]OrDataThe pointer to the data used to do OR operation. The caller is responsible for having ownership of the data buffer and ensuring its size not less than Count bytes.
Return values
EFI_INVALID_PARAMETERThe Address or the OrData or the Count is not valid.
EFI_SUCCESSThe OR operation succeeds.
OthersThe OR operation fails.

Definition at line 104 of file SdHci.c.

◆ SdPeimHcPowerControl()

EFI_STATUS SdPeimHcPowerControl ( IN UINTN  Bar,
IN UINT8  PowerCtrl 
)

SD bus power control.

Refer to SD Host Controller Simplified spec 3.0 Section 3.3 for details.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]PowerCtrlThe value setting to the power control register.
Return values
TRUEThere is a SD card attached.
FALSEThere is no a SD card attached.

Definition at line 649 of file SdHci.c.

◆ SdPeimHcReset()

EFI_STATUS SdPeimHcReset ( IN UINTN  Bar)

Software reset the specified SD host controller and enable all interrupts.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSThe software reset executes successfully.
OthersThe software reset fails.

Definition at line 300 of file SdHci.c.

◆ SdPeimHcRwMmio()

EFI_STATUS EFIAPI SdPeimHcRwMmio ( IN UINTN  Address,
IN BOOLEAN  Read,
IN UINT8  Count,
IN OUT VOID *  Data 
)

Read/Write specified SD host controller mmio register.

Parameters
[in]AddressThe address of the mmio register to be read/written.
[in]ReadA boolean to indicate it's read or write operation.
[in]CountThe width of the mmio register in bytes. Must be 1, 2 , 4 or 8 bytes.
[in,out]DataFor read operations, the destination buffer to store the results. For write operations, the source buffer to write data from. The caller is responsible for having ownership of the data buffer and ensuring its size not less than Count bytes.
Return values
EFI_INVALID_PARAMETERThe Address or the Data or the Count is not valid.
EFI_SUCCESSThe read/write operation succeeds.
OthersThe read/write operation fails.

Definition at line 30 of file SdHci.c.

◆ SdPeimHcSetBusWidth()

EFI_STATUS SdPeimHcSetBusWidth ( IN UINTN  Bar,
IN UINT16  BusWidth 
)

Set the SD bus width.

Refer to SD Host Controller Simplified spec 3.0 Section 3.4 for details.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]BusWidthThe bus width used by the SD device, it must be 1, 4 or 8.
Return values
EFI_SUCCESSThe bus width is set successfully.
OthersThe bus width isn't set successfully.

Definition at line 687 of file SdHci.c.

◆ SdPeimHcStopClock()

EFI_STATUS SdPeimHcStopClock ( IN UINTN  Bar)

Stop SD card clock.

Refer to SD Host Controller Simplified spec 3.0 Section 3.2.2 for details.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
Return values
EFI_SUCCESSSucceed to stop SD clock.
OthersFail to stop SD clock.

Definition at line 468 of file SdHci.c.

◆ SdPeimHcWaitMmioSet()

EFI_STATUS EFIAPI SdPeimHcWaitMmioSet ( IN UINTN  Address,
IN UINT8  Count,
IN UINT64  MaskValue,
IN UINT64  TestValue,
IN UINT64  Timeout 
)

Wait for the value of the specified MMIO register set to the test value.

Parameters
[in]AddressThe address of the mmio register to wait.
[in]CountThe width of the mmio register in bytes. Must be 1, 2, 4 or 8 bytes.
[in]MaskValueThe mask value of memory.
[in]TestValueThe test value of memory.
[in]TimeoutThe time out value for wait memory set, uses 1 microsecond as a unit.
Return values
EFI_TIMEOUTThe MMIO register hasn't expected value in timeout range.
EFI_SUCCESSThe MMIO register has expected value.
OthersThe MMIO operation fails.

Definition at line 251 of file SdHci.c.

◆ SdPeimIdentification()

EFI_STATUS SdPeimIdentification ( IN SD_PEIM_HC_SLOT Slot)

Execute SD device identification procedure.

Refer to SD Physical Layer Simplified Spec 4.1 Section 3.6 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThere is a SD card.
OthersThere is not a SD card.

Definition at line 2803 of file SdHci.c.

◆ SdPeimReset()

EFI_STATUS SdPeimReset ( IN SD_PEIM_HC_SLOT Slot)

Send command GO_IDLE_STATE to the device to make it go to Idle State.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe SD device is reset correctly.
OthersThe device reset fails.

Definition at line 1763 of file SdHci.c.

◆ SdPeimRwMultiBlocks()

EFI_STATUS SdPeimRwMultiBlocks ( IN SD_PEIM_HC_SLOT Slot,
IN EFI_LBA  Lba,
IN UINT32  BlockSize,
IN VOID *  Buffer,
IN UINTN  BufferSize,
IN BOOLEAN  IsRead 
)

Send command READ_MULTIPLE_BLOCK/WRITE_MULTIPLE_BLOCK to the addressed SD device to read/write the specified number of blocks.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]LbaThe logical block address of starting access.
[in]BlockSizeThe block size of specified SD device partition.
[in]BufferThe pointer to the transfer buffer.
[in]BufferSizeThe size of transfer buffer.
[in]IsReadBoolean to show the operation direction.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2435 of file SdHci.c.

◆ SdPeimRwSingleBlock()

EFI_STATUS SdPeimRwSingleBlock ( IN SD_PEIM_HC_SLOT Slot,
IN EFI_LBA  Lba,
IN UINT32  BlockSize,
IN VOID *  Buffer,
IN UINTN  BufferSize,
IN BOOLEAN  IsRead 
)

Send command READ_SINGLE_BLOCK/WRITE_SINGLE_BLOCK to the addressed SD device to read/write the specified number of blocks.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]LbaThe logical block address of starting access.
[in]BlockSizeThe block size of specified SD device partition.
[in]BufferThe pointer to the transfer buffer.
[in]BufferSizeThe size of transfer buffer.
[in]IsReadBoolean to show the operation direction.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2362 of file SdHci.c.

◆ SdPeimSelect()

EFI_STATUS SdPeimSelect ( IN SD_PEIM_HC_SLOT Slot,
IN UINT16  Rca 
)

Send command SELECT_DESELECT_CARD to the SD device to select/deselect it.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]RcaThe relative device address of selected device.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2110 of file SdHci.c.

◆ SdPeimSendOpCond()

EFI_STATUS SdPeimSendOpCond ( IN SD_PEIM_HC_SLOT Slot,
IN UINT16  Rca,
IN UINT32  VoltageWindow,
IN BOOLEAN  S18r,
IN BOOLEAN  Xpc,
IN BOOLEAN  Hcs,
OUT UINT32 *  Ocr 
)

Send command SD_SEND_OP_COND to the device to see whether it is SDIO device.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]RcaThe relative device address of addressed device.
[in]VoltageWindowThe supply voltage window.
[in]S18rThe boolean to show if it should switch to 1.8v.
[in]XpcThe boolean to show if it should provide 0.36w power control.
[in]HcsThe boolean to show if it support host capacity info.
[out]OcrThe buffer to store returned OCR register value.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 1905 of file SdHci.c.

◆ SdPeimSendStatus()

EFI_STATUS SdPeimSendStatus ( IN SD_PEIM_HC_SLOT Slot,
IN UINT16  Rca,
OUT UINT32 *  DevStatus 
)

Send command SEND_STATUS to the addressed SD device to get its status register.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]RcaThe relative device address of addressed device.
[out]DevStatusThe returned device status.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2312 of file SdHci.c.

◆ SdPeimSendTuningBlk()

EFI_STATUS SdPeimSendTuningBlk ( IN SD_PEIM_HC_SLOT Slot)

Send command SEND_TUNING_BLOCK to the SD device for SDR104/SDR50 optimal sampling point detection.

It may be sent up to 40 times until the host finishes the tuning procedure.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2505 of file SdHci.c.

◆ SdPeimSetBusMode()

EFI_STATUS SdPeimSetBusMode ( IN SD_PEIM_HC_SLOT Slot,
IN UINT16  Rca,
IN BOOLEAN  S18a 
)

Switch the high speed timing according to request.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 and SD Host Controller Simplified Spec 3.0 section Figure 2-29 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]RcaThe relative device address to be assigned.
[in]S18aThe boolean to show if it's a UHS-I SD card.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2667 of file SdHci.c.

◆ SdPeimSetBusWidth()

EFI_STATUS SdPeimSetBusWidth ( IN SD_PEIM_HC_SLOT Slot,
IN UINT16  Rca,
IN UINT8  BusWidth 
)

Send command SET_BUS_WIDTH to the SD device to set the bus width.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]RcaThe relative device address of addressed device.
[in]BusWidthThe bus width to be set, it could be 1 or 4.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2191 of file SdHci.c.

◆ SdPeimSetRca()

EFI_STATUS SdPeimSetRca ( IN SD_PEIM_HC_SLOT Slot,
OUT UINT16 *  Rca 
)

Send command SET_RELATIVE_ADDR to the SD device to assign a Relative device Address (RCA).

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[out]RcaThe relative device address to be assigned.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2015 of file SdHci.c.

◆ SdPeimSwitch()

EFI_STATUS SdPeimSwitch ( IN SD_PEIM_HC_SLOT Slot,
IN UINT8  AccessMode,
IN UINT8  CommandSystem,
IN UINT8  DriveStrength,
IN UINT8  PowerLimit,
IN BOOLEAN  Mode,
OUT UINT8 *  SwitchResp 
)

Send command SWITCH_FUNC to the SD device to check switchable function or switch card function.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]AccessModeThe value for access mode group.
[in]CommandSystemThe value for command set group.
[in]DriveStrengthThe value for drive length group.
[in]PowerLimitThe value for power limit group.
[in]ModeSwitch or check function.
[out]SwitchRespThe return switch function status.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2258 of file SdHci.c.

◆ SdPeimSwitchBusWidth()

EFI_STATUS SdPeimSwitchBusWidth ( IN SD_PEIM_HC_SLOT Slot,
IN UINT16  Rca,
IN UINT8  BusWidth 
)

Switch the bus width to specified width.

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.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]RcaThe relative device address to be assigned.
[in]BusWidthThe bus width to be set, it could be 4 or 8.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2621 of file SdHci.c.

◆ SdPeimTuningClock()

EFI_STATUS SdPeimTuningClock ( IN SD_PEIM_HC_SLOT Slot)

Tuning the sampling point of SDR104 or SDR50 bus speed mode.

Command SD_SEND_TUNING_BLOCK may be sent up to 40 times until the host finishes the tuning procedure.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2552 of file SdHci.c.

◆ SdPeimVoltageCheck()

EFI_STATUS SdPeimVoltageCheck ( IN SD_PEIM_HC_SLOT Slot,
IN UINT8  SupplyVoltage,
IN UINT8  CheckPattern 
)

Send command SEND_IF_COND to the device to inquiry the SD Memory Card interface condition.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]SupplyVoltageThe supplied voltage by the host.
[in]CheckPatternThe check pattern to be sent to the device.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 1805 of file SdHci.c.

◆ SdPeimVoltageSwitch()

EFI_STATUS SdPeimVoltageSwitch ( IN SD_PEIM_HC_SLOT Slot)

Send command VOLTAGE_SWITCH to the SD device to switch the voltage of the device.

Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe operation is done correctly.
OthersThe operation fails.

Definition at line 2150 of file SdHci.c.

◆ SdPeimWaitTrbEnv()

EFI_STATUS SdPeimWaitTrbEnv ( IN UINTN  Bar,
IN SD_TRB Trb 
)

Wait for the env to be ready for execute specified TRB.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]TrbThe pointer to the SD_TRB instance.
Return values
EFI_SUCCESSThe env is ready for TRB execution.
EFI_TIMEOUTThe env is not ready for TRB execution in time.
OthersSome erros happen.

Definition at line 1180 of file SdHci.c.

◆ SdPeimWaitTrbResult()

EFI_STATUS SdPeimWaitTrbResult ( IN UINTN  Bar,
IN SD_TRB Trb 
)

Wait for the TRB execution result.

Parameters
[in]BarThe mmio base address of the slot to be accessed.
[in]TrbThe pointer to the SD_TRB instance.
Return values
EFI_SUCCESSThe TRB is executed successfully.
OthersSome erros happen when executing this request.

Definition at line 1628 of file SdHci.c.