TianoCore EDK2 master
|
#include "SdBlockIoPei.h"
Go to the source code of this file.
Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file SdHci.c.
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.
[in] | Trb | The pointer to the SD_TRB instance. |
EFI_SUCCESS | The ADMA descriptor table is created successfully. |
Others | The ADMA descriptor table isn't created successfully. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | VoltageWindow | The supply voltage window. |
[in] | S18r | The boolean to show if it should switch to 1.8v. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
EFI_STATUS SdPeimCheckTrbEnv | ( | IN UINTN | Bar, |
IN SD_TRB * | Trb | ||
) |
Check if the env is ready for execute specified TRB.
[in] | Bar | The mmio base address of the slot to be accessed. |
[in] | Trb | The pointer to the SD_TRB instance. |
EFI_SUCCESS | The env is ready for TRB execution. |
EFI_NOT_READY | The env is not ready for TRB execution. |
Others | Some erros happen. |
EFI_STATUS SdPeimCheckTrbResult | ( | IN UINTN | Bar, |
IN SD_TRB * | Trb | ||
) |
Check the TRB execution result.
[in] | Bar | The mmio base address of the slot to be accessed. |
[in] | Trb | The pointer to the SD_TRB instance. |
EFI_SUCCESS | The TRB is executed successfully. |
EFI_NOT_READY | The TRB is not completed for execution. |
Others | Some erros happen when executing this request. |
SD_TRB * SdPeimCreateTrb | ( | IN SD_PEIM_HC_SLOT * | Slot, |
IN SD_COMMAND_PACKET * | Packet | ||
) |
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.
[in] | Slot | The slot number of the Sd card to send the command to. |
[in,out] | Packet | A pointer to the SD command data structure. |
EFI_SUCCESS | The SD Command Packet was sent by the host. |
EFI_DEVICE_ERROR | A device error occurred while attempting to send the SD command Packet. |
EFI_INVALID_PARAMETER | Packet, Slot, or the contents of the Packet is invalid. |
EFI_INVALID_PARAMETER | Packet defines a data command but both InDataBuffer and OutDataBuffer are NULL. |
EFI_NO_MEDIA | SD Device not present in the Slot. |
EFI_UNSUPPORTED | The command described by the SD Command Packet is not supported by the host controller. |
EFI_BAD_BUFFER_SIZE | The InTransferLength or OutTransferLength exceeds the limit supported by SD card ( i.e. if the number of bytes exceed the Last LBA). |
EFI_STATUS SdPeimExecTrb | ( | IN UINTN | Bar, |
IN SD_TRB * | Trb | ||
) |
Execute the specified TRB.
[in] | Bar | The mmio base address of the slot to be accessed. |
[in] | Trb | The pointer to the SD_TRB instance. |
EFI_SUCCESS | The TRB is sent to host controller successfully. |
Others | Some erros happen when sending this request to the host controller. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address of selected device. |
[out] | Csd | The 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. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Address | The address of the mmio register to be read/written. |
[in] | Count | The width of the mmio register in bytes. Must be 1, 2 , 4 or 8 bytes. |
[in] | AndData | The 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. |
EFI_INVALID_PARAMETER | The Address or the AndData or the Count is not valid. |
EFI_SUCCESS | The AND operation succeeds. |
Others | The AND operation fails. |
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.
[in] | Bar | The mmio base address of the slot to be accessed. |
EFI_SUCCESS | There is a SD card attached. |
EFI_NO_MEDIA | There is not a SD card attached. |
Others | The detection fails. |
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.
[in] | Address | The address of the mmio register to be checked. |
[in] | Count | The width of the mmio register in bytes. Must be 1, 2, 4 or 8 bytes. |
[in] | MaskValue | The mask value of memory. |
[in] | TestValue | The test value of memory. |
EFI_NOT_READY | The MMIO register hasn't set to the expected value. |
EFI_SUCCESS | The MMIO register has expected value. |
Others | The MMIO operation fails. |
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.
[in] | Bar | The mmio base address of the slot to be accessed. |
[in] | ClockFreq | The max clock frequency to be set. The unit is KHz. |
EFI_SUCCESS | The clock is supplied successfully. |
Others | The clock isn't supplied successfully. |
EFI_STATUS SdPeimHcEnableInterrupt | ( | IN UINTN | Bar | ) |
EFI_STATUS SdPeimHcGetCapability | ( | IN UINTN | Bar, |
OUT SD_HC_SLOT_CAP * | Capability | ||
) |
Get the capability data from the specified slot.
[in] | Bar | The mmio base address of the slot to be accessed. |
[out] | Capability | The buffer to store the capability data. |
EFI_SUCCESS | The operation executes successfully. |
Others | The operation fails. |
EFI_STATUS SdPeimHcInitClockFreq | ( | IN UINTN | Bar | ) |
EFI_STATUS SdPeimHcInitHost | ( | IN UINTN | Bar | ) |
Initial SD host controller with lowest clock frequency, max power and max timeout value at initialization.
[in] | Bar | The mmio base address of the slot to be accessed. |
EFI_SUCCESS | The host controller is initialized successfully. |
Others | The host controller isn't initialized successfully. |
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.
[in] | Bar | The mmio base address of the slot to be accessed. |
EFI_SUCCESS | The voltage is supplied successfully. |
Others | The voltage isn't supplied successfully. |
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.
[in] | Bar | The mmio base address of the slot to be accessed. |
EFI_SUCCESS | The timeout control register is configured successfully. |
Others | The timeout control register isn't configured successfully. |
EFI_STATUS SdPeimHcLedOnOff | ( | IN UINTN | Bar, |
IN BOOLEAN | On | ||
) |
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.
[in] | Address | The address of the mmio register to be read/written. |
[in] | Count | The width of the mmio register in bytes. Must be 1, 2 , 4 or 8 bytes. |
[in] | OrData | The 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. |
EFI_INVALID_PARAMETER | The Address or the OrData or the Count is not valid. |
EFI_SUCCESS | The OR operation succeeds. |
Others | The OR operation fails. |
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.
[in] | Bar | The mmio base address of the slot to be accessed. |
[in] | PowerCtrl | The value setting to the power control register. |
TRUE | There is a SD card attached. |
FALSE | There is no a SD card attached. |
EFI_STATUS SdPeimHcReset | ( | IN UINTN | Bar | ) |
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.
[in] | Address | The address of the mmio register to be read/written. |
[in] | Read | A boolean to indicate it's read or write operation. |
[in] | Count | The width of the mmio register in bytes. Must be 1, 2 , 4 or 8 bytes. |
[in,out] | Data | For 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. |
EFI_INVALID_PARAMETER | The Address or the Data or the Count is not valid. |
EFI_SUCCESS | The read/write operation succeeds. |
Others | The read/write operation fails. |
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.
[in] | Bar | The mmio base address of the slot to be accessed. |
[in] | BusWidth | The bus width used by the SD device, it must be 1, 4 or 8. |
EFI_SUCCESS | The bus width is set successfully. |
Others | The bus width isn't set successfully. |
EFI_STATUS SdPeimHcStopClock | ( | IN UINTN | Bar | ) |
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.
[in] | Address | The address of the mmio register to wait. |
[in] | Count | The width of the mmio register in bytes. Must be 1, 2, 4 or 8 bytes. |
[in] | MaskValue | The mask value of memory. |
[in] | TestValue | The test value of memory. |
[in] | Timeout | The time out value for wait memory set, uses 1 microsecond as a unit. |
EFI_TIMEOUT | The MMIO register hasn't expected value in timeout range. |
EFI_SUCCESS | The MMIO register has expected value. |
Others | The MMIO operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | There is a SD card. |
Others | There is not a SD card. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | The SD device is reset correctly. |
Others | The device reset fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Lba | The logical block address of starting access. |
[in] | BlockSize | The block size of specified SD device partition. |
[in] | Buffer | The pointer to the transfer buffer. |
[in] | BufferSize | The size of transfer buffer. |
[in] | IsRead | Boolean to show the operation direction. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Lba | The logical block address of starting access. |
[in] | BlockSize | The block size of specified SD device partition. |
[in] | Buffer | The pointer to the transfer buffer. |
[in] | BufferSize | The size of transfer buffer. |
[in] | IsRead | Boolean to show the operation direction. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address of selected device. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address of addressed device. |
[in] | VoltageWindow | The supply voltage window. |
[in] | S18r | The boolean to show if it should switch to 1.8v. |
[in] | Xpc | The boolean to show if it should provide 0.36w power control. |
[in] | Hcs | The boolean to show if it support host capacity info. |
[out] | Ocr | The buffer to store returned OCR register value. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address of addressed device. |
[out] | DevStatus | The returned device status. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
[in] | S18a | The boolean to show if it's a UHS-I SD card. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address of addressed device. |
[in] | BusWidth | The bus width to be set, it could be 1 or 4. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[out] | Rca | The relative device address to be assigned. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | AccessMode | The value for access mode group. |
[in] | CommandSystem | The value for command set group. |
[in] | DriveStrength | The value for drive length group. |
[in] | PowerLimit | The value for power limit group. |
[in] | Mode | Switch or check function. |
[out] | SwitchResp | The return switch function status. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
[in] | BusWidth | The bus width to be set, it could be 4 or 8. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | SupplyVoltage | The supplied voltage by the host. |
[in] | CheckPattern | The check pattern to be sent to the device. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
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.
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
EFI_STATUS SdPeimWaitTrbEnv | ( | IN UINTN | Bar, |
IN SD_TRB * | Trb | ||
) |
Wait for the env to be ready for execute specified TRB.
[in] | Bar | The mmio base address of the slot to be accessed. |
[in] | Trb | The pointer to the SD_TRB instance. |
EFI_SUCCESS | The env is ready for TRB execution. |
EFI_TIMEOUT | The env is not ready for TRB execution in time. |
Others | Some erros happen. |
EFI_STATUS SdPeimWaitTrbResult | ( | IN UINTN | Bar, |
IN SD_TRB * | Trb | ||
) |