TianoCore EDK2 master
Loading...
Searching...
No Matches
SdMmcPciHci.c File Reference
#include "SdMmcPciHcDxe.h"

Go to the source code of this file.

Functions

VOID DumpCapabilityReg (IN UINT8 Slot, IN SD_MMC_HC_SLOT_CAP *Capability)
 
EFI_STATUS EFIAPI SdMmcHcGetSlotInfo (IN EFI_PCI_IO_PROTOCOL *PciIo, OUT UINT8 *FirstBar, OUT UINT8 *SlotNum)
 
EFI_STATUS EFIAPI SdMmcHcRwMmio (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN BOOLEAN Read, IN UINT8 Count, IN OUT VOID *Data)
 
EFI_STATUS EFIAPI SdMmcHcOrMmio (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN VOID *OrData)
 
EFI_STATUS EFIAPI SdMmcHcAndMmio (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN VOID *AndData)
 
EFI_STATUS EFIAPI SdMmcHcCheckMmioSet (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN UINT64 MaskValue, IN UINT64 TestValue)
 
EFI_STATUS EFIAPI SdMmcHcWaitMmioSet (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN UINT64 MaskValue, IN UINT64 TestValue, IN UINT64 Timeout)
 
EFI_STATUS SdMmcHcGetControllerVersion (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT UINT16 *Version)
 
EFI_STATUS SdMmcHcReset (IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot)
 
EFI_STATUS SdMmcHcEnableInterrupt (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
 
EFI_STATUS SdMmcHcGetCapability (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT SD_MMC_HC_SLOT_CAP *Capability)
 
EFI_STATUS SdMmcHcGetMaxCurrent (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT UINT64 *MaxCurrent)
 
EFI_STATUS SdMmcHcCardDetect (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, OUT BOOLEAN *MediaPresent)
 
EFI_STATUS SdMmcHcStopClock (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
 
EFI_STATUS SdMmcHcStartSdClock (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
 
EFI_STATUS SdMmcHcClockSupply (IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot, IN SD_MMC_BUS_MODE BusTiming, IN BOOLEAN FirstTimeSetup, IN UINT64 ClockFreq)
 
EFI_STATUS SdMmcHcPowerControl (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN UINT8 PowerCtrl)
 
EFI_STATUS SdMmcHcSetBusWidth (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN UINT16 BusWidth)
 
EFI_STATUS SdMmcHcInitV4Enhancements (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_HC_SLOT_CAP Capability, IN UINT16 ControllerVer)
 
EFI_STATUS SdMmcHcInitPowerVoltage (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_HC_SLOT_CAP Capability)
 
EFI_STATUS SdMmcHcInitTimeoutCtrl (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
 
EFI_STATUS SdMmcHcInitHost (IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot)
 
EFI_STATUS SdMmcHcUhsSignaling (IN EFI_HANDLE ControllerHandle, IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_BUS_MODE Timing)
 
EFI_STATUS SdMmcSetDriverStrength (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 SlotIndex, IN SD_DRIVER_STRENGTH_TYPE DriverStrength)
 
EFI_STATUS SdMmcHcLedOnOff (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN BOOLEAN On)
 
EFI_STATUS BuildAdmaDescTable (IN SD_MMC_HC_TRB *Trb, IN UINT16 ControllerVer)
 
VOID SdMmcPrintPacket (IN UINT32 DebugLevel, IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet)
 
VOID SdMmcPrintTrb (IN UINT32 DebugLevel, IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcSetupMemoryForDmaTransfer (IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot, IN SD_MMC_HC_TRB *Trb)
 
SD_MMC_HC_TRBSdMmcCreateTrb (IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot, IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet, IN EFI_EVENT Event)
 
VOID SdMmcFreeTrb (IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcCheckTrbEnv (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcWaitTrbEnv (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcExecTrb (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcSoftwareReset (IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot, IN UINT16 ErrIntStatus)
 
EFI_STATUS SdMmcCheckAndRecoverErrors (IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot, IN UINT16 IntStatus)
 
EFI_STATUS SdMmcGetResponse (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcCheckCommandComplete (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb, IN UINT16 IntStatus)
 
EFI_STATUS SdMmcTransferDataWithPio (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb, IN UINT16 IntStatus)
 
EFI_STATUS SdMmcUpdateSdmaAddress (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcCheckDataTransfer (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb, IN UINT16 IntStatus)
 
EFI_STATUS SdMmcCheckTrbResult (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
 
EFI_STATUS SdMmcWaitTrbResult (IN SD_MMC_HC_PRIVATE_DATA *Private, IN SD_MMC_HC_TRB *Trb)
 

Detailed Description

This driver is used to manage SD/MMC PCI host controllers which are compliance with SD Host Controller Simplified Specification version 3.00 plus the 64-bit System Addressing support in SD Host Controller Simplified Specification version 4.20.

It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use.

Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SdMmcPciHci.c.

Function Documentation

◆ BuildAdmaDescTable()

EFI_STATUS BuildAdmaDescTable ( IN SD_MMC_HC_TRB Trb,
IN UINT16  ControllerVer 
)

Build ADMA descriptor table for transfer.

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

Parameters
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.
[in]ControllerVerThe version of host controller.
Return values
EFI_SUCCESSThe ADMA descriptor table is created successfully.
OthersThe ADMA descriptor table isn't created successfully.

Definition at line 1467 of file SdMmcPciHci.c.

◆ DumpCapabilityReg()

VOID DumpCapabilityReg ( IN UINT8  Slot,
IN SD_MMC_HC_SLOT_CAP Capability 
)

Dump the content of SD/MMC host controller's Capability Register.

Parameters
[in]SlotThe slot number of the SD card to send the command to.
[in]CapabilityThe buffer to store the capability data.

Definition at line 25 of file SdMmcPciHci.c.

◆ SdMmcCheckAndRecoverErrors()

EFI_STATUS SdMmcCheckAndRecoverErrors ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN UINT8  Slot,
IN UINT16  IntStatus 
)

Checks the error status in error status register and issues appropriate software reset as described in SD specification section 3.10.

Parameters
[in]PrivatePointer to driver private data.
[in]SlotIndex of the slot for device.
[in]IntStatusNormal interrupt status mask.
Return values
EFI_CRC_ERRORCRC error happened during CMD execution.
EFI_SUCCESSNo error reported.
OthersSome other error happened.

Definition at line 2410 of file SdMmcPciHci.c.

◆ SdMmcCheckCommandComplete()

EFI_STATUS SdMmcCheckCommandComplete ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb,
IN UINT16  IntStatus 
)

Checks if the command completed. If the command completed it gets the response and records the command completion in the TRB.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.
[in]IntStatusSnapshot of the normal interrupt status register.
Return values
EFI_SUCCESSCommand completed successfully.
EFI_NOT_READYCommand completion still pending.
OthersCommand failed to complete.

Definition at line 2535 of file SdMmcPciHci.c.

◆ SdMmcCheckDataTransfer()

EFI_STATUS SdMmcCheckDataTransfer ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb,
IN UINT16  IntStatus 
)

Checks if the data transfer completed and performs any actions neccessary to continue the data transfer such as SDMA system address fixup or PIO data transfer.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.
[in]IntStatusSnapshot of the normal interrupt status register.
Return values
EFI_SUCCESSData transfer completed successfully.
EFI_NOT_READYData transfer completion still pending.
OthersData transfer failed to complete.

Definition at line 2734 of file SdMmcPciHci.c.

◆ SdMmcCheckTrbEnv()

EFI_STATUS SdMmcCheckTrbEnv ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb 
)

Check if the env is ready for execute specified TRB.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_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 2021 of file SdMmcPciHci.c.

◆ SdMmcCheckTrbResult()

EFI_STATUS SdMmcCheckTrbResult ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb 
)

Check the TRB execution result.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_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 2798 of file SdMmcPciHci.c.

◆ SdMmcCreateTrb()

SD_MMC_HC_TRB * SdMmcCreateTrb ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN UINT8  Slot,
IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet,
IN EFI_EVENT  Event 
)

Create a new TRB for the SD/MMC cmd request.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]PacketA pointer to the SD command data structure.
[in]EventIf Event is NULL, blocking I/O is performed. If Event is not NULL, then nonblocking I/O is performed, and Event will be signaled when the Packet completes.
Returns
Created Trb or NULL.

Definition at line 1848 of file SdMmcPciHci.c.

◆ SdMmcExecTrb()

EFI_STATUS SdMmcExecTrb ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb 
)

Execute the specified TRB.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_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 2127 of file SdMmcPciHci.c.

◆ SdMmcFreeTrb()

VOID SdMmcFreeTrb ( IN SD_MMC_HC_TRB Trb)

Free the resource used by the TRB.

Parameters
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.

Definition at line 1959 of file SdMmcPciHci.c.

◆ SdMmcGetResponse()

EFI_STATUS SdMmcGetResponse ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb 
)

Reads the response data into the TRB buffer. This function assumes that caller made sure that command has completed.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.
Return values
EFI_SUCCESSResponse read successfully.
OthersFailed to get response.

Definition at line 2486 of file SdMmcPciHci.c.

◆ SdMmcHcAndMmio()

EFI_STATUS EFIAPI SdMmcHcAndMmio ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  BarIndex,
IN UINT32  Offset,
IN UINT8  Count,
IN VOID *  AndData 
)

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]BarIndexThe BAR index of the standard PCI Configuration header to use as the base address for the memory operation to perform.
[in]OffsetThe offset within the selected BAR to start the memory operation.
[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 PciIo or AndData is NULL or the Count is not valid.
EFI_SUCCESSThe AND operation succeeds.
OthersThe AND operation fails.

Definition at line 283 of file SdMmcPciHci.c.

◆ SdMmcHcCardDetect()

EFI_STATUS SdMmcHcCardDetect ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
OUT BOOLEAN *  MediaPresent 
)

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

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[out]MediaPresentThe pointer to the media present boolean value.
Return values
EFI_SUCCESSThere is no media change happened.
EFI_MEDIA_CHANGEDThere is media change happened.
OthersThe detection fails.

Definition at line 678 of file SdMmcPciHci.c.

◆ SdMmcHcCheckMmioSet()

EFI_STATUS EFIAPI SdMmcHcCheckMmioSet ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  BarIndex,
IN UINT32  Offset,
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]PciIoThe PCI IO protocol instance.
[in]BarIndexThe BAR index of the standard PCI Configuration header to use as the base address for the memory operation to perform.
[in]OffsetThe offset within the selected BAR to start the memory operation.
[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 339 of file SdMmcPciHci.c.

◆ SdMmcHcClockSupply()

EFI_STATUS SdMmcHcClockSupply ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN UINT8  Slot,
IN SD_MMC_BUS_MODE  BusTiming,
IN BOOLEAN  FirstTimeSetup,
IN UINT64  ClockFreq 
)

SD/MMC card clock supply.

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

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]BusTimingBusTiming at which the frequency change is done.
[in]FirstTimeSetupFlag to indicate whether the clock is being setup for the first time.
[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 815 of file SdMmcPciHci.c.

◆ SdMmcHcEnableInterrupt()

EFI_STATUS SdMmcHcEnableInterrupt ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot 
)

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe operation executes successfully.
OthersThe operation fails.

Definition at line 580 of file SdMmcPciHci.c.

◆ SdMmcHcGetCapability()

EFI_STATUS SdMmcHcGetCapability ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
OUT SD_MMC_HC_SLOT_CAP Capability 
)

Get the capability data from the specified slot.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[out]CapabilityThe buffer to store the capability data.
Return values
EFI_SUCCESSThe operation executes successfully.
OthersThe operation fails.

Definition at line 618 of file SdMmcPciHci.c.

◆ SdMmcHcGetControllerVersion()

EFI_STATUS SdMmcHcGetControllerVersion ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
OUT UINT16 *  Version 
)

Get the controller version information from the specified slot.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[out]VersionThe buffer to store the version information.
Return values
EFI_SUCCESSThe operation executes successfully.
OthersThe operation fails.

Definition at line 448 of file SdMmcPciHci.c.

◆ SdMmcHcGetMaxCurrent()

EFI_STATUS SdMmcHcGetMaxCurrent ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
OUT UINT64 *  MaxCurrent 
)

Get the maximum current capability data from the specified slot.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[out]MaxCurrentThe buffer to store the maximum current capability data.
Return values
EFI_SUCCESSThe operation executes successfully.
OthersThe operation fails.

Definition at line 649 of file SdMmcPciHci.c.

◆ SdMmcHcGetSlotInfo()

EFI_STATUS EFIAPI SdMmcHcGetSlotInfo ( IN EFI_PCI_IO_PROTOCOL PciIo,
OUT UINT8 *  FirstBar,
OUT UINT8 *  SlotNum 
)

Read SlotInfo register from SD/MMC host controller pci config space.

Parameters
[in]PciIoThe PCI IO protocol instance.
[out]FirstBarThe buffer to store the first BAR value.
[out]SlotNumThe buffer to store the supported slot number.
Return values
EFI_SUCCESSThe operation succeeds.
OthersThe operation fails.

Definition at line 92 of file SdMmcPciHci.c.

◆ SdMmcHcInitHost()

EFI_STATUS SdMmcHcInitHost ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN UINT8  Slot 
)

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

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe host controller is initialized successfully.
OthersThe host controller isn't initialized successfully.

Definition at line 1213 of file SdMmcPciHci.c.

◆ SdMmcHcInitPowerVoltage()

EFI_STATUS SdMmcHcInitPowerVoltage ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
IN SD_MMC_HC_SLOT_CAP  Capability 
)

Supply SD/MMC card with maximum voltage at initialization.

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]CapabilityThe capability of the slot.
Return values
EFI_SUCCESSThe voltage is supplied successfully.
OthersThe voltage isn't supplied successfully.

Definition at line 1127 of file SdMmcPciHci.c.

◆ SdMmcHcInitTimeoutCtrl()

EFI_STATUS SdMmcHcInitTimeoutCtrl ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot 
)

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]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe timeout control register is configured successfully.
OthersThe timeout control register isn't configured successfully.

Definition at line 1187 of file SdMmcPciHci.c.

◆ SdMmcHcInitV4Enhancements()

EFI_STATUS SdMmcHcInitV4Enhancements ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
IN SD_MMC_HC_SLOT_CAP  Capability,
IN UINT16  ControllerVer 
)

Configure V4 controller enhancements at initialization.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]CapabilityThe capability of the slot.
[in]ControllerVerThe version of host controller.
Return values
EFI_SUCCESSThe clock is supplied successfully.

Definition at line 1061 of file SdMmcPciHci.c.

◆ SdMmcHcLedOnOff()

EFI_STATUS SdMmcHcLedOnOff ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
IN BOOLEAN  On 
)

Turn on/off LED.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[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 1434 of file SdMmcPciHci.c.

◆ SdMmcHcOrMmio()

EFI_STATUS EFIAPI SdMmcHcOrMmio ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  BarIndex,
IN UINT32  Offset,
IN UINT8  Count,
IN VOID *  OrData 
)

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]BarIndexThe BAR index of the standard PCI Configuration header to use as the base address for the memory operation to perform.
[in]OffsetThe offset within the selected BAR to start the memory operation.
[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 PciIo or OrData is NULL or the Count is not valid.
EFI_SUCCESSThe OR operation succeeds.
OthersThe OR operation fails.

Definition at line 225 of file SdMmcPciHci.c.

◆ SdMmcHcPowerControl()

EFI_STATUS SdMmcHcPowerControl ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
IN UINT8  PowerCtrl 
)

SD/MMC bus power control.

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]PowerCtrlThe value setting to the power control register.
Return values
TRUEThere is a SD/MMC card attached.
FALSEThere is no a SD/MMC card attached.

Definition at line 971 of file SdMmcPciHci.c.

◆ SdMmcHcReset()

EFI_STATUS SdMmcHcReset ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN UINT8  Slot 
)

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

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSThe software reset executes successfully.
OthersThe software reset fails.

Definition at line 477 of file SdMmcPciHci.c.

◆ SdMmcHcRwMmio()

EFI_STATUS EFIAPI SdMmcHcRwMmio ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  BarIndex,
IN UINT32  Offset,
IN BOOLEAN  Read,
IN UINT8  Count,
IN OUT VOID *  Data 
)

Read/Write specified SD/MMC host controller mmio register.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]BarIndexThe BAR index of the standard PCI Configuration header to use as the base address for the memory operation to perform.
[in]OffsetThe offset within the selected BAR to start the memory operation.
[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 PciIo or Data is NULL or the Count is not valid.
EFI_SUCCESSThe read/write operation succeeds.
OthersThe read/write operation fails.

Definition at line 143 of file SdMmcPciHci.c.

◆ SdMmcHcSetBusWidth()

EFI_STATUS SdMmcHcSetBusWidth ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
IN UINT16  BusWidth 
)

Set the SD/MMC bus width.

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]BusWidthThe bus width used by the SD/MMC 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 1011 of file SdMmcPciHci.c.

◆ SdMmcHcStartSdClock()

EFI_STATUS SdMmcHcStartSdClock ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot 
)

Start the SD clock.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number.
Return values
EFI_SUCCESSSucceeded to start the SD clock.
OthersFailed to start the SD clock.

Definition at line 785 of file SdMmcPciHci.c.

◆ SdMmcHcStopClock()

EFI_STATUS SdMmcHcStopClock ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot 
)

Stop SD/MMC card clock.

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

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
Return values
EFI_SUCCESSSucceed to stop SD/MMC clock.
OthersFail to stop SD/MMC clock.

Definition at line 739 of file SdMmcPciHci.c.

◆ SdMmcHcUhsSignaling()

EFI_STATUS SdMmcHcUhsSignaling ( IN EFI_HANDLE  ControllerHandle,
IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  Slot,
IN SD_MMC_BUS_MODE  Timing 
)

Set SD Host Controler control 2 registry according to selected speed.

Parameters
[in]ControllerHandleThe handle of the controller.
[in]PciIoThe PCI IO protocol instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]TimingThe timing to select.
Return values
EFI_SUCCESSThe timing is set successfully.
OthersThe timing isn't set successfully.

Definition at line 1310 of file SdMmcPciHci.c.

◆ SdMmcHcWaitMmioSet()

EFI_STATUS EFIAPI SdMmcHcWaitMmioSet ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  BarIndex,
IN UINT32  Offset,
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]PciIoThe PCI IO protocol instance.
[in]BarIndexThe BAR index of the standard PCI Configuration header to use as the base address for the memory operation to perform.
[in]OffsetThe offset within the selected BAR to start the memory operation.
[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 393 of file SdMmcPciHci.c.

◆ SdMmcPrintPacket()

VOID SdMmcPrintPacket ( IN UINT32  DebugLevel,
IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet 
)

Prints the contents of the command packet to the debug port.

Parameters
[in]DebugLevelDebug level at which the packet should be printed.
[in]PacketPointer to packet to print.

Definition at line 1701 of file SdMmcPciHci.c.

◆ SdMmcPrintTrb()

VOID SdMmcPrintTrb ( IN UINT32  DebugLevel,
IN SD_MMC_HC_TRB Trb 
)

Prints the contents of the TRB to the debug port.

Parameters
[in]DebugLevelDebug level at which the TRB should be printed.
[in]TrbPointer to the TRB structure.

Definition at line 1742 of file SdMmcPciHci.c.

◆ SdMmcSetDriverStrength()

EFI_STATUS SdMmcSetDriverStrength ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT8  SlotIndex,
IN SD_DRIVER_STRENGTH_TYPE  DriverStrength 
)

Set driver strength in host controller.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]SlotIndexThe slot index of the card.
[in]DriverStrengthDriverStrength to set in the controller.
Return values
EFI_SUCCESSDriver strength programmed successfully.
OthersFailed to set driver strength.

Definition at line 1399 of file SdMmcPciHci.c.

◆ SdMmcSetupMemoryForDmaTransfer()

EFI_STATUS SdMmcSetupMemoryForDmaTransfer ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN UINT8  Slot,
IN SD_MMC_HC_TRB Trb 
)

Sets up host memory to allow DMA transfer.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]SlotThe slot number of the SD card to send the command to.
[in]PacketA pointer to the SD command data structure.
Return values
EFI_SUCCESSMemory has been mapped for DMA transfer.
OthersMemory has not been mapped.

Definition at line 1788 of file SdMmcPciHci.c.

◆ SdMmcSoftwareReset()

EFI_STATUS SdMmcSoftwareReset ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN UINT8  Slot,
IN UINT16  ErrIntStatus 
)

Performs SW reset based on passed error status mask.

Parameters
[in]PrivatePointer to driver private data.
[in]SlotIndex of the slot to reset.
[in]ErrIntStatusError interrupt status mask.
Return values
EFI_SUCCESSSoftware reset performed successfully.
OtherSoftware reset failed.

Definition at line 2349 of file SdMmcPciHci.c.

◆ SdMmcTransferDataWithPio()

EFI_STATUS SdMmcTransferDataWithPio ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb,
IN UINT16  IntStatus 
)

Transfers data from card using PIO method.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.
[in]IntStatusSnapshot of the normal interrupt status register.
Return values
EFI_SUCCESSPIO transfer completed successfully.
EFI_NOT_READYPIO transfer completion still pending.
OthersPIO transfer failed to complete.

Definition at line 2582 of file SdMmcPciHci.c.

◆ SdMmcUpdateSdmaAddress()

EFI_STATUS SdMmcUpdateSdmaAddress ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb 
)

Update the SDMA address on the SDMA buffer boundary interrupt.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.
Return values
EFI_SUCCESSUpdated SDMA buffer address.
OthersFailed to update SDMA buffer address.

Definition at line 2682 of file SdMmcPciHci.c.

◆ SdMmcWaitTrbEnv()

EFI_STATUS SdMmcWaitTrbEnv ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb 
)

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

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_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 2075 of file SdMmcPciHci.c.

◆ SdMmcWaitTrbResult()

EFI_STATUS SdMmcWaitTrbResult ( IN SD_MMC_HC_PRIVATE_DATA Private,
IN SD_MMC_HC_TRB Trb 
)

Wait for the TRB execution result.

Parameters
[in]PrivateA pointer to the SD_MMC_HC_PRIVATE_DATA instance.
[in]TrbThe pointer to the SD_MMC_HC_TRB instance.
Return values
EFI_SUCCESSThe TRB is executed successfully.
OthersSome erros happen when executing this request.

Definition at line 2888 of file SdMmcPciHci.c.