TianoCore EDK2 master
|
#include "SdMmcPciHcDxe.h"
Go to the source code of this file.
This file provides some helper functions which are specific for EMMC device.
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file EmmcDevice.c.
EFI_STATUS EmmcCheckSwitchStatus | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN UINT16 | Rca | ||
) |
Check the SWITCH operation status.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number on which command should be sent. |
[in] | Rca | The relative device address. |
EFI_SUCCESS | The SWITCH finished siccessfully. |
others | The SWITCH failed. |
Definition at line 574 of file EmmcDevice.c.
EFI_STATUS EmmcGetAllCid | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot | ||
) |
Broadcast command ALL_SEND_CID to the bus to ask all the EMMC devices to send the data of their CID registers.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[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. |
Definition at line 120 of file EmmcDevice.c.
EFI_STATUS EmmcGetCsd | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN UINT16 | Rca, | ||
OUT EMMC_CSD * | Csd | ||
) |
Send command SEND_CSD to the EMMC device to get the data of the CSD register.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[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. |
Definition at line 210 of file EmmcDevice.c.
EFI_STATUS EmmcGetExtCsd | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
OUT EMMC_EXT_CSD * | ExtCsd | ||
) |
Send command SEND_EXT_CSD to the EMMC device to get the data of the EXT_CSD register.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[out] | ExtCsd | The buffer to store the content of the EXT_CSD register. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 303 of file EmmcDevice.c.
EFI_STATUS EmmcGetOcr | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN OUT UINT32 * | Argument | ||
) |
Send command SEND_OP_COND to the EMMC device to get the data of the OCR register.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in,out] | Argument | On input, the argument of SEND_OP_COND is to send to the device. On output, the argument is the value of OCR register. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 71 of file EmmcDevice.c.
VOID EmmcGetTargetBusMode | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | SlotIndex, | ||
IN EMMC_EXT_CSD * | ExtCsd, | ||
OUT SD_MMC_BUS_SETTINGS * | BusMode | ||
) |
Get the target settings for the bus mode.
[in] | Private | Pointer to controller private data |
[in] | SlotIndex | Index of the slot in the controller |
[in] | ExtCsd | Pointer to card's extended CSD |
[out] | BusMode | Target configuration of the bus |
Definition at line 1208 of file EmmcDevice.c.
SD_MMC_BUS_MODE EmmcGetTargetBusTiming | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | SlotIndex, | ||
IN EMMC_EXT_CSD * | ExtCsd | ||
) |
Get the target bus timing to set on the link. This function will try to select highest bus timing supported by card, controller and the driver.
[in] | Private | Pointer to controller private data |
[in] | SlotIndex | Index of the slot in the controller |
[in] | ExtCsd | Pointer to the card's extended CSD |
Definition at line 1030 of file EmmcDevice.c.
UINT8 EmmcGetTargetBusWidth | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | SlotIndex, | ||
IN EMMC_EXT_CSD * | ExtCsd, | ||
IN SD_MMC_BUS_MODE | BusTiming | ||
) |
Get the target bus width to be set on the bus.
[in] | Private | Pointer to controller private data |
[in] | SlotIndex | Index of the slot in the controller |
[in] | ExtCsd | Pointer to card's extended CSD |
[in] | BusTiming | Bus timing set on the bus |
Definition at line 1095 of file EmmcDevice.c.
UINT32 EmmcGetTargetClockFreq | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | SlotIndex, | ||
IN EMMC_EXT_CSD * | ExtCsd, | ||
IN SD_MMC_BUS_MODE | BusTiming | ||
) |
Get the target clock frequency to be set on the bus.
[in] | Private | Pointer to controller private data |
[in] | SlotIndex | Index of the slot in the controller |
[in] | ExtCsd | Pointer to card's extended CSD |
[in] | BusTiming | Bus timing to be set on the bus |
Definition at line 1133 of file EmmcDevice.c.
EDKII_SD_MMC_DRIVER_STRENGTH EmmcGetTargetDriverStrength | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | SlotIndex, | ||
IN EMMC_EXT_CSD * | ExtCsd, | ||
IN SD_MMC_BUS_MODE | BusTiming | ||
) |
Get the driver strength to be set on bus.
[in] | Private | Pointer to controller private data |
[in] | SlotIndex | Index of the slot in the controller |
[in] | ExtCsd | Pointer to card's extended CSD |
[in] | BusTiming | Bus timing set on the bus |
Definition at line 1177 of file EmmcDevice.c.
EFI_STATUS EmmcIdentification | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | Slot | ||
) |
Execute EMMC device identification procedure.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.
[in] | Private | A pointer to the SD_MMC_HC_PRIVATE_DATA instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | There is a EMMC card. |
Others | There is not a EMMC card. |
Definition at line 1318 of file EmmcDevice.c.
BOOLEAN EmmcIsBusTimingSupported | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | SlotIndex, | ||
IN EMMC_EXT_CSD * | ExtCsd, | ||
IN SD_MMC_BUS_MODE | BusTiming | ||
) |
Check if passed BusTiming is supported in both controller and card.
[in] | Private | Pointer to controller private data |
[in] | SlotIndex | Index of the slot in the controller |
[in] | ExtCsd | Pointer to the card's extended CSD |
[in] | BusTiming | Bus timing to check |
TRUE | Both card and controller support given BusTiming |
FALSE | Card or controller doesn't support given BusTiming |
Definition at line 967 of file EmmcDevice.c.
BOOLEAN EmmcIsBusWidthSupported | ( | IN SD_MMC_HC_PRIVATE_DATA * | Private, |
IN UINT8 | SlotIndex, | ||
IN SD_MMC_BUS_MODE | BusTiming, | ||
IN UINT16 | BusWidth | ||
) |
Check if the passed bus width is supported by controller and card.
[in] | Private | Pointer to controller private data |
[in] | SlotIndex | Index of the slot in the controller |
[in] | BusTiming | Bus timing set on the link |
[in] | BusWidth | Bus width to check |
TRUE | Passed bus width is supported in current bus configuration |
FALSE | Passed bus width is not supported in current bus configuration |
Definition at line 1066 of file EmmcDevice.c.
EFI_STATUS EmmcReset | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot | ||
) |
Send command GO_IDLE_STATE (CMD0 with argument of 0x00000000) to the device to make it go to Idle State.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
EFI_SUCCESS | The EMMC device is reset correctly. |
Others | The device reset fails. |
Definition at line 26 of file EmmcDevice.c.
EFI_STATUS EmmcSelect | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN UINT16 | Rca | ||
) |
Send command SELECT_DESELECT_CARD to the EMMC device to select/deselect it.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[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. |
Definition at line 260 of file EmmcDevice.c.
EFI_STATUS EmmcSendStatus | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN UINT16 | Rca, | ||
OUT UINT32 * | DevStatus | ||
) |
Send command SEND_STATUS to the addressed EMMC device to get its status register.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[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. |
Definition at line 399 of file EmmcDevice.c.
EFI_STATUS EmmcSendTuningBlk | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN UINT8 | BusWidth | ||
) |
Send command SEND_TUNING_BLOCK to the EMMC device for HS200 optimal sampling point detection.
It may be sent up to 40 times until the host finishes the tuning procedure.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | BusWidth | The bus width to work. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 449 of file EmmcDevice.c.
EFI_STATUS EmmcSetBusMode | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, | ||
IN UINT8 | Slot, | ||
IN UINT16 | Rca | ||
) |
Switch the high speed timing according to request.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details.
[in] | PciIo | A pointer to the EFI_PCI_IO_PROTOCOL instance. |
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 1237 of file EmmcDevice.c.
EFI_STATUS EmmcSetRca | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN UINT16 | Rca | ||
) |
Send command SET_RELATIVE_ADDR to the EMMC device to assign a Relative device Address (RCA).
Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 163 of file EmmcDevice.c.
EFI_STATUS EmmcSwitch | ( | IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, |
IN UINT8 | Slot, | ||
IN UINT8 | Access, | ||
IN UINT8 | Index, | ||
IN UINT8 | Value, | ||
IN UINT8 | CmdSet | ||
) |
Send command SWITCH to the EMMC device to switch the mode of operation of the selected Device or modifies the EXT_CSD registers.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.10.4 for details.
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Access | The access mode of SWTICH command. |
[in] | Index | The offset of the field to be access. |
[in] | Value | The value to be set to the specified field of EXT_CSD register. |
[in] | CmdSet | The value of CmdSet field of EXT_CSD register. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 352 of file EmmcDevice.c.
EFI_STATUS EmmcSwitchBusTiming | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, | ||
IN UINT8 | Slot, | ||
IN UINT16 | Rca, | ||
IN EDKII_SD_MMC_DRIVER_STRENGTH | DriverStrength, | ||
IN SD_MMC_BUS_MODE | BusTiming, | ||
IN UINT32 | ClockFreq | ||
) |
Switch the bus timing and clock frequency.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6 and SD Host Controller Simplified Spec 3.0 Figure 3-3 for details.
[in] | PciIo | A pointer to the EFI_PCI_IO_PROTOCOL instance. |
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
[in] | DriverStrength | Driver strength to set for speed modes that support it. |
[in] | BusTiming | The bus mode timing indicator. |
[in] | ClockFreq | The max clock frequency to be set, the unit is MHz. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 687 of file EmmcDevice.c.
EFI_STATUS EmmcSwitchBusWidth | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, | ||
IN UINT8 | Slot, | ||
IN UINT16 | Rca, | ||
IN BOOLEAN | IsDdr, | ||
IN UINT8 | BusWidth | ||
) |
Switch the bus width to specified width.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.9 and SD Host Controller Simplified Spec 3.0 Figure 3-7 for details.
[in] | PciIo | A pointer to the EFI_PCI_IO_PROTOCOL instance. |
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
[in] | IsDdr | If TRUE, use dual data rate data simpling method. Otherwise use single data rate data simpling method. |
[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. |
Definition at line 619 of file EmmcDevice.c.
EFI_STATUS EmmcSwitchToHighSpeed | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, | ||
IN UINT8 | Slot, | ||
IN UINT16 | Rca, | ||
IN SD_MMC_BUS_SETTINGS * | BusMode | ||
) |
Switch to the High Speed timing according to request.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details.
[in] | PciIo | A pointer to the EFI_PCI_IO_PROTOCOL instance. |
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
[in] | BusMode | Pointer to SD_MMC_BUS_SETTINGS structure containing bus settings. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 813 of file EmmcDevice.c.
EFI_STATUS EmmcSwitchToHS200 | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, | ||
IN UINT8 | Slot, | ||
IN UINT16 | Rca, | ||
IN SD_MMC_BUS_SETTINGS * | BusMode | ||
) |
Switch to the HS200 timing. This function assumes that eMMC bus is still in legacy mode.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details.
[in] | PciIo | A pointer to the EFI_PCI_IO_PROTOCOL instance. |
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
[in] | BusMode | Pointer to SD_MMC_BUS_SETTINGS structure containing bus settings. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 861 of file EmmcDevice.c.
EFI_STATUS EmmcSwitchToHS400 | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, | ||
IN UINT8 | Slot, | ||
IN UINT16 | Rca, | ||
IN SD_MMC_BUS_SETTINGS * | BusMode | ||
) |
Switch to the HS400 timing. This function assumes that eMMC bus is still in legacy mode.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details.
[in] | PciIo | A pointer to the EFI_PCI_IO_PROTOCOL instance. |
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | Rca | The relative device address to be assigned. |
[in] | BusMode | Pointer to SD_MMC_BUS_SETTINGS structure containing bus settings. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 909 of file EmmcDevice.c.
EFI_STATUS EmmcTuningClkForHs200 | ( | IN EFI_PCI_IO_PROTOCOL * | PciIo, |
IN EFI_SD_MMC_PASS_THRU_PROTOCOL * | PassThru, | ||
IN UINT8 | Slot, | ||
IN UINT8 | BusWidth | ||
) |
Tunning the clock to get HS200 optimal sampling point.
Command SEND_TUNING_BLOCK may be sent up to 40 times until the host finishes the tuning procedure.
Refer to EMMC Electrical Standard Spec 5.1 Section 6.6.8 and SD Host Controller Simplified Spec 3.0 Figure 2-29 for details.
[in] | PciIo | A pointer to the EFI_PCI_IO_PROTOCOL instance. |
[in] | PassThru | A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. |
[in] | Slot | The slot number of the SD card to send the command to. |
[in] | BusWidth | The bus width to work. |
EFI_SUCCESS | The operation is done correctly. |
Others | The operation fails. |
Definition at line 505 of file EmmcDevice.c.