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

Go to the source code of this file.

Data Structures

struct  OCR
 
struct  SCR
 
struct  CID
 
struct  CSD
 
struct  ECSD
 
struct  CARD_INFO
 
struct  _MMC_HOST_INSTANCE
 

Macros

#define MMC_TRACE(txt)   DEBUG((DEBUG_BLKIO, "MMC: " txt "\n"))
 
#define MMC_IOBLOCKS_READ   0
 
#define MMC_IOBLOCKS_WRITE   1
 
#define MMC_OCR_POWERUP   0x80000000
 
#define MMC_OCR_ACCESS_MASK   0x3 /* bit[30-29] */
 
#define MMC_OCR_ACCESS_BYTE   0x1 /* bit[29] */
 
#define MMC_OCR_ACCESS_SECTOR   0x2 /* bit[30] */
 
#define MMC_CSD_GET_CCC(Response)   (Response[2] >> 20)
 
#define MMC_CSD_GET_TRANSPEED(Response)   (Response[3] & 0xFF)
 
#define MMC_CSD_GET_READBLLEN(Response)   ((Response[2] >> 16) & 0xF)
 
#define MMC_CSD_GET_WRITEBLLEN(Response)   ((Response[0] >> 22) & 0xF)
 
#define MMC_CSD_GET_FILEFORMAT(Response)   ((Response[0] >> 10) & 0x3)
 
#define MMC_CSD_GET_FILEFORMATGRP(Response)   ((Response[0] >> 15) & 0x1)
 
#define MMC_CSD_GET_DEVICESIZE(csd)   (((Response[1] >> 30) & 0x3) | ((Response[2] & 0x3FF) << 2))
 
#define HC_MMC_CSD_GET_DEVICESIZE(Response)   ((Response[1] >> 16) | ((Response[2] & 0x40) << 16));
 
#define MMC_CSD_GET_DEVICESIZEMULT(csd)   ((Response[1] >> 15) & 0x7)
 
#define MMC_R0_READY_FOR_DATA   (1 << 8)
 
#define MMC_R0_CURRENTSTATE(Response)   ((Response[0] >> 9) & 0xF)
 
#define MMC_R0_STATE_IDLE   0
 
#define MMC_R0_STATE_READY   1
 
#define MMC_R0_STATE_IDENT   2
 
#define MMC_R0_STATE_STDBY   3
 
#define MMC_R0_STATE_TRAN   4
 
#define MMC_R0_STATE_DATA   5
 
#define EMMC_CMD6_ARG_ACCESS(x)   (((x) & 0x3) << 24)
 
#define EMMC_CMD6_ARG_INDEX(x)   (((x) & 0xFF) << 16)
 
#define EMMC_CMD6_ARG_VALUE(x)   (((x) & 0xFF) << 8)
 
#define EMMC_CMD6_ARG_CMD_SET(x)   (((x) & 0x7) << 0)
 
#define SWITCH_CMD_DATA_LENGTH   64
 
#define SD_HIGH_SPEED_SUPPORTED   0x20000
 
#define SD_DEFAULT_SPEED   25000000
 
#define SD_HIGH_SPEED   50000000
 
#define SWITCH_CMD_SUCCESS_MASK   0x0f000000
 
#define SD_CARD_CAPACITY   0x00000002
 
#define BUSWIDTH_4   4
 
#define MMC_HOST_INSTANCE_SIGNATURE   SIGNATURE_32('m', 'm', 'c', 'h')
 
#define MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS(a)   CR (a, MMC_HOST_INSTANCE, BlockIo, MMC_HOST_INSTANCE_SIGNATURE)
 
#define MMC_HOST_INSTANCE_FROM_LINK(a)   CR (a, MMC_HOST_INSTANCE, Link, MMC_HOST_INSTANCE_SIGNATURE)
 

Typedefs

typedef struct _MMC_HOST_INSTANCE MMC_HOST_INSTANCE
 

Enumerations

enum  CARD_TYPE {
  UNKNOWN_CARD , MMC_CARD , MMC_CARD_HIGH , EMMC_CARD ,
  SD_CARD , SD_CARD_2 , SD_CARD_2_HIGH
}
 

Functions

EFI_STATUS EFIAPI MmcGetDriverName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
EFI_STATUS EFIAPI MmcGetControllerName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
EFI_STATUS EFIAPI MmcReset (IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
 
EFI_STATUS EFIAPI MmcReadBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI MmcWriteBlocks (IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI MmcFlushBlocks (IN EFI_BLOCK_IO_PROTOCOL *This)
 
EFI_STATUS MmcNotifyState (IN MMC_HOST_INSTANCE *MmcHostInstance, IN MMC_STATE State)
 
EFI_STATUS InitializeMmcDevice (IN MMC_HOST_INSTANCE *MmcHost)
 
VOID EFIAPI CheckCardsCallback (IN EFI_EVENT Event, IN VOID *Context)
 
VOID PrintCSD (IN UINT32 *Csd)
 
VOID PrintRCA (IN UINT32 Rca)
 
VOID PrintOCR (IN UINT32 Ocr)
 
VOID PrintResponseR1 (IN UINT32 Response)
 
VOID PrintCID (IN UINT32 *Cid)
 

Variables

EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName
 
EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2
 
EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2
 
LIST_ENTRY mMmcHostPool
 

Detailed Description

Main Header file for the MMC DXE driver

Copyright (c) 2011-2015, ARM Limited. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Mmc.h.

Macro Definition Documentation

◆ BUSWIDTH_4

#define BUSWIDTH_4   4

Definition at line 69 of file Mmc.h.

◆ EMMC_CMD6_ARG_ACCESS

#define EMMC_CMD6_ARG_ACCESS (   x)    (((x) & 0x3) << 24)

Definition at line 56 of file Mmc.h.

◆ EMMC_CMD6_ARG_CMD_SET

#define EMMC_CMD6_ARG_CMD_SET (   x)    (((x) & 0x7) << 0)

Definition at line 59 of file Mmc.h.

◆ EMMC_CMD6_ARG_INDEX

#define EMMC_CMD6_ARG_INDEX (   x)    (((x) & 0xFF) << 16)

Definition at line 57 of file Mmc.h.

◆ EMMC_CMD6_ARG_VALUE

#define EMMC_CMD6_ARG_VALUE (   x)    (((x) & 0xFF) << 8)

Definition at line 58 of file Mmc.h.

◆ HC_MMC_CSD_GET_DEVICESIZE

#define HC_MMC_CSD_GET_DEVICESIZE (   Response)    ((Response[1] >> 16) | ((Response[2] & 0x40) << 16));

Definition at line 42 of file Mmc.h.

◆ MMC_CSD_GET_CCC

#define MMC_CSD_GET_CCC (   Response)    (Response[2] >> 20)

Definition at line 35 of file Mmc.h.

◆ MMC_CSD_GET_DEVICESIZE

#define MMC_CSD_GET_DEVICESIZE (   csd)    (((Response[1] >> 30) & 0x3) | ((Response[2] & 0x3FF) << 2))

Definition at line 41 of file Mmc.h.

◆ MMC_CSD_GET_DEVICESIZEMULT

#define MMC_CSD_GET_DEVICESIZEMULT (   csd)    ((Response[1] >> 15) & 0x7)

Definition at line 43 of file Mmc.h.

◆ MMC_CSD_GET_FILEFORMAT

#define MMC_CSD_GET_FILEFORMAT (   Response)    ((Response[0] >> 10) & 0x3)

Definition at line 39 of file Mmc.h.

◆ MMC_CSD_GET_FILEFORMATGRP

#define MMC_CSD_GET_FILEFORMATGRP (   Response)    ((Response[0] >> 15) & 0x1)

Definition at line 40 of file Mmc.h.

◆ MMC_CSD_GET_READBLLEN

#define MMC_CSD_GET_READBLLEN (   Response)    ((Response[2] >> 16) & 0xF)

Definition at line 37 of file Mmc.h.

◆ MMC_CSD_GET_TRANSPEED

#define MMC_CSD_GET_TRANSPEED (   Response)    (Response[3] & 0xFF)

Definition at line 36 of file Mmc.h.

◆ MMC_CSD_GET_WRITEBLLEN

#define MMC_CSD_GET_WRITEBLLEN (   Response)    ((Response[0] >> 22) & 0xF)

Definition at line 38 of file Mmc.h.

◆ MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS

#define MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (   a)    CR (a, MMC_HOST_INSTANCE, BlockIo, MMC_HOST_INSTANCE_SIGNATURE)

Definition at line 344 of file Mmc.h.

◆ MMC_HOST_INSTANCE_FROM_LINK

#define MMC_HOST_INSTANCE_FROM_LINK (   a)    CR (a, MMC_HOST_INSTANCE, Link, MMC_HOST_INSTANCE_SIGNATURE)

Definition at line 345 of file Mmc.h.

◆ MMC_HOST_INSTANCE_SIGNATURE

#define MMC_HOST_INSTANCE_SIGNATURE   SIGNATURE_32('m', 'm', 'c', 'h')

Definition at line 343 of file Mmc.h.

◆ MMC_IOBLOCKS_READ

#define MMC_IOBLOCKS_READ   0

Definition at line 26 of file Mmc.h.

◆ MMC_IOBLOCKS_WRITE

#define MMC_IOBLOCKS_WRITE   1

Definition at line 27 of file Mmc.h.

◆ MMC_OCR_ACCESS_BYTE

#define MMC_OCR_ACCESS_BYTE   0x1 /* bit[29] */

Definition at line 32 of file Mmc.h.

◆ MMC_OCR_ACCESS_MASK

#define MMC_OCR_ACCESS_MASK   0x3 /* bit[30-29] */

Definition at line 31 of file Mmc.h.

◆ MMC_OCR_ACCESS_SECTOR

#define MMC_OCR_ACCESS_SECTOR   0x2 /* bit[30] */

Definition at line 33 of file Mmc.h.

◆ MMC_OCR_POWERUP

#define MMC_OCR_POWERUP   0x80000000

Definition at line 29 of file Mmc.h.

◆ MMC_R0_CURRENTSTATE

#define MMC_R0_CURRENTSTATE (   Response)    ((Response[0] >> 9) & 0xF)

Definition at line 47 of file Mmc.h.

◆ MMC_R0_READY_FOR_DATA

#define MMC_R0_READY_FOR_DATA   (1 << 8)

Definition at line 45 of file Mmc.h.

◆ MMC_R0_STATE_DATA

#define MMC_R0_STATE_DATA   5

Definition at line 54 of file Mmc.h.

◆ MMC_R0_STATE_IDENT

#define MMC_R0_STATE_IDENT   2

Definition at line 51 of file Mmc.h.

◆ MMC_R0_STATE_IDLE

#define MMC_R0_STATE_IDLE   0

Definition at line 49 of file Mmc.h.

◆ MMC_R0_STATE_READY

#define MMC_R0_STATE_READY   1

Definition at line 50 of file Mmc.h.

◆ MMC_R0_STATE_STDBY

#define MMC_R0_STATE_STDBY   3

Definition at line 52 of file Mmc.h.

◆ MMC_R0_STATE_TRAN

#define MMC_R0_STATE_TRAN   4

Definition at line 53 of file Mmc.h.

◆ MMC_TRACE

#define MMC_TRACE (   txt)    DEBUG((DEBUG_BLKIO, "MMC: " txt "\n"))

Definition at line 24 of file Mmc.h.

◆ SD_CARD_CAPACITY

#define SD_CARD_CAPACITY   0x00000002

Definition at line 67 of file Mmc.h.

◆ SD_DEFAULT_SPEED

#define SD_DEFAULT_SPEED   25000000

Definition at line 63 of file Mmc.h.

◆ SD_HIGH_SPEED

#define SD_HIGH_SPEED   50000000

Definition at line 64 of file Mmc.h.

◆ SD_HIGH_SPEED_SUPPORTED

#define SD_HIGH_SPEED_SUPPORTED   0x20000

Definition at line 62 of file Mmc.h.

◆ SWITCH_CMD_DATA_LENGTH

#define SWITCH_CMD_DATA_LENGTH   64

Definition at line 61 of file Mmc.h.

◆ SWITCH_CMD_SUCCESS_MASK

#define SWITCH_CMD_SUCCESS_MASK   0x0f000000

Definition at line 65 of file Mmc.h.

Enumeration Type Documentation

◆ CARD_TYPE

enum CARD_TYPE

Definition at line 71 of file Mmc.h.

Function Documentation

◆ CheckCardsCallback()

VOID EFIAPI CheckCardsCallback ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Definition at line 360 of file Mmc.c.

◆ InitializeMmcDevice()

EFI_STATUS InitializeMmcDevice ( IN MMC_HOST_INSTANCE MmcHost)

Definition at line 785 of file MmcIdentification.c.

◆ MmcFlushBlocks()

EFI_STATUS EFIAPI MmcFlushBlocks ( IN EFI_BLOCK_IO_PROTOCOL This)

Flushes all modified data to a physical block device.

Parameters
ThisIndicates a pointer to the calling context.
Return values
EFI_SUCCESSAll outstanding data were written correctly to the device.
EFI_DEVICE_ERRORThe device reported an error while attempting to write data.
EFI_NO_MEDIAThere is no media in the device.

Definition at line 400 of file MmcBlockIo.c.

◆ MmcGetControllerName()

EFI_STATUS EFIAPI MmcGetControllerName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_HANDLE ChildHandle  OPTIONAL,
IN CHAR8 *  Language,
OUT CHAR16 **  ControllerName 
)

Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver.

This function retrieves the user readable name of the controller specified by ControllerHandle and ChildHandle in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the controller name is returned in ControllerName, and EFI_SUCCESS is returned. If the driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle, then EFI_UNSUPPORTED is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
ThisA pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandleThe handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned.
ChildHandleThe handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to retrieve the name of the bus controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller.
LanguageA pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
ControllerNameA pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by Language from the point of view of the driver specified by This.
Return values
EFI_SUCCESSThe Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName.
EFI_INVALID_PARAMETERControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETERChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERControllerName is NULL.
EFI_UNSUPPORTEDThe driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 147 of file ComponentName.c.

◆ MmcGetDriverName()

EFI_STATUS EFIAPI MmcGetDriverName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN CHAR8 *  Language,
OUT CHAR16 **  DriverName 
)

Retrieves a Unicode string that is the user readable name of the driver.

This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
ThisA pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
LanguageA pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
DriverNameA pointer to the Unicode string to return. This Unicode string is the name of the driver specified by This in the language specified by Language.
Return values
EFI_SUCCESSThe Unicode string for the Driver specified by This and the language specified by Language was returned in DriverName.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERDriverName is NULL.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 72 of file ComponentName.c.

◆ MmcNotifyState()

EFI_STATUS MmcNotifyState ( IN MMC_HOST_INSTANCE MmcHostInstance,
IN MMC_STATE  State 
)

Definition at line 14 of file MmcBlockIo.c.

◆ MmcReadBlocks()

EFI_STATUS EFIAPI MmcReadBlocks ( IN EFI_BLOCK_IO_PROTOCOL This,
IN UINT32  MediaId,
IN EFI_LBA  Lba,
IN UINTN  BufferSize,
OUT VOID *  Buffer 
)

Reads the requested number of blocks from the device.

This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). It reads the requested number of blocks from the device. All the blocks are read, or an error is returned.

Parameters
ThisIndicates a pointer to the calling context.
MediaIdThe media ID that the read request is for.
LbaThe starting logical block address to read from on the device.
BufferSizeThe size of the Buffer in bytes. This must be a multiple of the intrinsic block size of the device.
BufferA pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer.
Return values
EFI_SUCCESSThe data was read correctly from the device.
EFI_DEVICE_ERRORThe device reported an error while attempting to perform the read operation.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHANGEDThe MediaId is not for the current media.
EFI_BAD_BUFFER_SIZEThe BufferSize parameter is not a multiple of the intrinsic block size of the device.
EFI_INVALID_PARAMETERThe read request contains LBAs that are not valid, or the buffer is not on proper alignment.

Definition at line 374 of file MmcBlockIo.c.

◆ MmcReset()

EFI_STATUS EFIAPI MmcReset ( IN EFI_BLOCK_IO_PROTOCOL This,
IN BOOLEAN  ExtendedVerification 
)

Reset the block device.

This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). It resets the block device hardware. ExtendedVerification is ignored in this implementation.

Parameters
ThisIndicates a pointer to the calling context.
ExtendedVerificationIndicates that the driver may perform a more exhaustive verification operation of the device during reset.
Return values
EFI_SUCCESSThe block device was reset.
EFI_DEVICE_ERRORThe block device is not functioning correctly and could not be reset.

Definition at line 61 of file MmcBlockIo.c.

◆ MmcWriteBlocks()

EFI_STATUS EFIAPI MmcWriteBlocks ( IN EFI_BLOCK_IO_PROTOCOL This,
IN UINT32  MediaId,
IN EFI_LBA  Lba,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Writes a specified number of blocks to the device.

This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). It writes a specified number of blocks to the device. All blocks are written, or an error is returned.

Parameters
ThisIndicates a pointer to the calling context.
MediaIdThe media ID that the write request is for.
LbaThe starting logical block address to be written.
BufferSizeThe size of the Buffer in bytes. This must be a multiple of the intrinsic block size of the device.
BufferPointer to the source buffer for the data.
Return values
EFI_SUCCESSThe data were written correctly to the device.
EFI_WRITE_PROTECTEDThe device cannot be written to.
EFI_NO_MEDIAThere is no media in the device.
EFI_MEDIA_CHANGEDThe MediaId is not for the current media.
EFI_DEVICE_ERRORThe device reported an error while attempting to perform the write operation.
EFI_BAD_BUFFER_SIZEThe BufferSize parameter is not a multiple of the intrinsic block size of the device.
EFI_INVALID_PARAMETERThe write request contains LBAs that are not valid, or the buffer is not on proper alignment.

Definition at line 387 of file MmcBlockIo.c.

◆ PrintCID()

VOID PrintCID ( IN UINT32 *  Cid)

Definition at line 21 of file MmcDebug.c.

◆ PrintCSD()

VOID PrintCSD ( IN UINT32 *  Csd)

Definition at line 34 of file MmcDebug.c.

◆ PrintOCR()

VOID PrintOCR ( IN UINT32  Ocr)

Definition at line 80 of file MmcDebug.c.

◆ PrintRCA()

VOID PrintRCA ( IN UINT32  Rca)

Definition at line 70 of file MmcDebug.c.

◆ PrintResponseR1()

VOID PrintResponseR1 ( IN UINT32  Response)

Definition at line 124 of file MmcDebug.c.

Variable Documentation

◆ gMmcComponentName

EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName
extern

Definition at line 15 of file ComponentName.c.

◆ gMmcComponentName2

EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2
extern

Definition at line 24 of file ComponentName.c.

◆ gMmcDriverDiagnostics2

EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2
extern

Definition at line 256 of file Diagnostics.c.

◆ mMmcHostPool

LIST_ENTRY mMmcHostPool
extern

Definition at line 37 of file Mmc.c.