TianoCore EDK2 master
Loading...
Searching...
No Matches
SdHci.h File Reference

Go to the source code of this file.

Data Structures

struct  _SD_COMMAND_BLOCK
 
struct  _SD_STATUS_BLOCK
 
struct  _SD_COMMAND_PACKET
 
struct  SD_HC_ADMA_DESC_LINE
 
struct  SD_HC_SLOT_CAP
 

Macros

#define SD_HC_SDMA_ADDR   0x00
 
#define SD_HC_ARG2   0x00
 
#define SD_HC_BLK_SIZE   0x04
 
#define SD_HC_BLK_COUNT   0x06
 
#define SD_HC_ARG1   0x08
 
#define SD_HC_TRANS_MOD   0x0C
 
#define SD_HC_COMMAND   0x0E
 
#define SD_HC_RESPONSE   0x10
 
#define SD_HC_BUF_DAT_PORT   0x20
 
#define SD_HC_PRESENT_STATE   0x24
 
#define SD_HC_HOST_CTRL1   0x28
 
#define SD_HC_POWER_CTRL   0x29
 
#define SD_HC_BLK_GAP_CTRL   0x2A
 
#define SD_HC_WAKEUP_CTRL   0x2B
 
#define SD_HC_CLOCK_CTRL   0x2C
 
#define SD_HC_TIMEOUT_CTRL   0x2E
 
#define SD_HC_SW_RST   0x2F
 
#define SD_HC_NOR_INT_STS   0x30
 
#define SD_HC_ERR_INT_STS   0x32
 
#define SD_HC_NOR_INT_STS_EN   0x34
 
#define SD_HC_ERR_INT_STS_EN   0x36
 
#define SD_HC_NOR_INT_SIG_EN   0x38
 
#define SD_HC_ERR_INT_SIG_EN   0x3A
 
#define SD_HC_AUTO_CMD_ERR_STS   0x3C
 
#define SD_HC_HOST_CTRL2   0x3E
 
#define SD_HC_CAP   0x40
 
#define SD_HC_MAX_CURRENT_CAP   0x48
 
#define SD_HC_FORCE_EVT_AUTO_CMD   0x50
 
#define SD_HC_FORCE_EVT_ERR_INT   0x52
 
#define SD_HC_ADMA_ERR_STS   0x54
 
#define SD_HC_ADMA_SYS_ADDR   0x58
 
#define SD_HC_PRESET_VAL   0x60
 
#define SD_HC_SHARED_BUS_CTRL   0xE0
 
#define SD_HC_SLOT_INT_STS   0xFC
 
#define SD_HC_CTRL_VER   0xFE
 
#define ADMA_MAX_DATA_PER_LINE   0x10000
 
#define SD_SDMA_BOUNDARY   512 * 1024
 
#define SD_SDMA_ROUND_UP(x, n)   (((x) + n) & ~(n - 1))
 

Typedefs

typedef struct _SD_COMMAND_BLOCK SD_COMMAND_BLOCK
 
typedef struct _SD_STATUS_BLOCK SD_STATUS_BLOCK
 
typedef struct _SD_COMMAND_PACKET SD_COMMAND_PACKET
 

Enumerations

enum  SD_HC_TRANSFER_MODE { SdNoData , SdPioMode , SdSdmaMode , SdAdmaMode }
 
enum  SD_COMMAND_TYPE { SdCommandTypeBc , SdCommandTypeBcr , SdCommandTypeAc , SdCommandTypeAdtc }
 
enum  SD_RESPONSE_TYPE {
  SdResponseTypeR1 , SdResponseTypeR1b , SdResponseTypeR2 , SdResponseTypeR3 ,
  SdResponseTypeR4 , SdResponseTypeR5 , SdResponseTypeR5b , SdResponseTypeR6 ,
  SdResponseTypeR7
}
 

Functions

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 SdPeimHcInitHost (IN UINTN Bar)
 
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 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 SdPeimIdentification (IN SD_PEIM_HC_SLOT *Slot)
 
VOID SdPeimFreeTrb (IN SD_TRB *Trb)
 

Detailed Description

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

Definition in file SdHci.h.

Macro Definition Documentation

◆ ADMA_MAX_DATA_PER_LINE

#define ADMA_MAX_DATA_PER_LINE   0x10000

Definition at line 64 of file SdHci.h.

◆ SD_HC_ADMA_ERR_STS

#define SD_HC_ADMA_ERR_STS   0x54

Definition at line 43 of file SdHci.h.

◆ SD_HC_ADMA_SYS_ADDR

#define SD_HC_ADMA_SYS_ADDR   0x58

Definition at line 44 of file SdHci.h.

◆ SD_HC_ARG1

#define SD_HC_ARG1   0x08

Definition at line 18 of file SdHci.h.

◆ SD_HC_ARG2

#define SD_HC_ARG2   0x00

Definition at line 15 of file SdHci.h.

◆ SD_HC_AUTO_CMD_ERR_STS

#define SD_HC_AUTO_CMD_ERR_STS   0x3C

Definition at line 37 of file SdHci.h.

◆ SD_HC_BLK_COUNT

#define SD_HC_BLK_COUNT   0x06

Definition at line 17 of file SdHci.h.

◆ SD_HC_BLK_GAP_CTRL

#define SD_HC_BLK_GAP_CTRL   0x2A

Definition at line 26 of file SdHci.h.

◆ SD_HC_BLK_SIZE

#define SD_HC_BLK_SIZE   0x04

Definition at line 16 of file SdHci.h.

◆ SD_HC_BUF_DAT_PORT

#define SD_HC_BUF_DAT_PORT   0x20

Definition at line 22 of file SdHci.h.

◆ SD_HC_CAP

#define SD_HC_CAP   0x40

Definition at line 39 of file SdHci.h.

◆ SD_HC_CLOCK_CTRL

#define SD_HC_CLOCK_CTRL   0x2C

Definition at line 28 of file SdHci.h.

◆ SD_HC_COMMAND

#define SD_HC_COMMAND   0x0E

Definition at line 20 of file SdHci.h.

◆ SD_HC_CTRL_VER

#define SD_HC_CTRL_VER   0xFE

Definition at line 48 of file SdHci.h.

◆ SD_HC_ERR_INT_SIG_EN

#define SD_HC_ERR_INT_SIG_EN   0x3A

Definition at line 36 of file SdHci.h.

◆ SD_HC_ERR_INT_STS

#define SD_HC_ERR_INT_STS   0x32

Definition at line 32 of file SdHci.h.

◆ SD_HC_ERR_INT_STS_EN

#define SD_HC_ERR_INT_STS_EN   0x36

Definition at line 34 of file SdHci.h.

◆ SD_HC_FORCE_EVT_AUTO_CMD

#define SD_HC_FORCE_EVT_AUTO_CMD   0x50

Definition at line 41 of file SdHci.h.

◆ SD_HC_FORCE_EVT_ERR_INT

#define SD_HC_FORCE_EVT_ERR_INT   0x52

Definition at line 42 of file SdHci.h.

◆ SD_HC_HOST_CTRL1

#define SD_HC_HOST_CTRL1   0x28

Definition at line 24 of file SdHci.h.

◆ SD_HC_HOST_CTRL2

#define SD_HC_HOST_CTRL2   0x3E

Definition at line 38 of file SdHci.h.

◆ SD_HC_MAX_CURRENT_CAP

#define SD_HC_MAX_CURRENT_CAP   0x48

Definition at line 40 of file SdHci.h.

◆ SD_HC_NOR_INT_SIG_EN

#define SD_HC_NOR_INT_SIG_EN   0x38

Definition at line 35 of file SdHci.h.

◆ SD_HC_NOR_INT_STS

#define SD_HC_NOR_INT_STS   0x30

Definition at line 31 of file SdHci.h.

◆ SD_HC_NOR_INT_STS_EN

#define SD_HC_NOR_INT_STS_EN   0x34

Definition at line 33 of file SdHci.h.

◆ SD_HC_POWER_CTRL

#define SD_HC_POWER_CTRL   0x29

Definition at line 25 of file SdHci.h.

◆ SD_HC_PRESENT_STATE

#define SD_HC_PRESENT_STATE   0x24

Definition at line 23 of file SdHci.h.

◆ SD_HC_PRESET_VAL

#define SD_HC_PRESET_VAL   0x60

Definition at line 45 of file SdHci.h.

◆ SD_HC_RESPONSE

#define SD_HC_RESPONSE   0x10

Definition at line 21 of file SdHci.h.

◆ SD_HC_SDMA_ADDR

#define SD_HC_SDMA_ADDR   0x00

Definition at line 14 of file SdHci.h.

◆ SD_HC_SHARED_BUS_CTRL

#define SD_HC_SHARED_BUS_CTRL   0xE0

Definition at line 46 of file SdHci.h.

◆ SD_HC_SLOT_INT_STS

#define SD_HC_SLOT_INT_STS   0xFC

Definition at line 47 of file SdHci.h.

◆ SD_HC_SW_RST

#define SD_HC_SW_RST   0x2F

Definition at line 30 of file SdHci.h.

◆ SD_HC_TIMEOUT_CTRL

#define SD_HC_TIMEOUT_CTRL   0x2E

Definition at line 29 of file SdHci.h.

◆ SD_HC_TRANS_MOD

#define SD_HC_TRANS_MOD   0x0C

Definition at line 19 of file SdHci.h.

◆ SD_HC_WAKEUP_CTRL

#define SD_HC_WAKEUP_CTRL   0x2B

Definition at line 27 of file SdHci.h.

◆ SD_SDMA_BOUNDARY

#define SD_SDMA_BOUNDARY   512 * 1024

Definition at line 65 of file SdHci.h.

◆ SD_SDMA_ROUND_UP

#define SD_SDMA_ROUND_UP (   x,
 
)    (((x) + n) & ~(n - 1))

Definition at line 66 of file SdHci.h.

Enumeration Type Documentation

◆ SD_COMMAND_TYPE

enum SD_COMMAND_TYPE

Definition at line 68 of file SdHci.h.

◆ SD_HC_TRANSFER_MODE

enum SD_HC_TRANSFER_MODE

Definition at line 54 of file SdHci.h.

◆ SD_RESPONSE_TYPE

enum SD_RESPONSE_TYPE

Definition at line 75 of file SdHci.h.

Function Documentation

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ SdPeimIdentification()

EFI_STATUS SdPeimIdentification ( IN SD_PEIM_HC_SLOT Slot)

Execute SD device identification procedure.

Refer to SD Electrical Standard Spec 5.1 Section 6.4 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.

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.

◆ 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 Electrical Standard Spec 5.1 Section 6.10.4 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.

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.

◆ 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.