mirror of https://github.com/acidanthera/audk.git
EmbeddedPkg/MmcDxe: Add 'This' pointer attribute to protocol function
This attribute allows the EFI_MMC_HOST_PROTOCOL interface to manage multiple instances in one driver. EmbeddedPkg/MmcDxe: Add Revision attribute to the EFI_MMC_HOST_PROTOCOL Note: The ARM PL180 and Omap35xx MMC host drivers has been updated. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12255 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
66f47f9fc0
commit
16d88c2d20
|
@ -46,7 +46,7 @@ MciInitialize (
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
MciIsCardPresent (
|
MciIsCardPresent (
|
||||||
VOID
|
IN EFI_MMC_HOST_PROTOCOL *This
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 1);
|
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 1);
|
||||||
|
@ -54,7 +54,7 @@ MciIsCardPresent (
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
MciIsReadOnly (
|
MciIsReadOnly (
|
||||||
VOID
|
IN EFI_MMC_HOST_PROTOCOL *This
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 2);
|
return (MmioRead32(FixedPcdGet32(PcdPL180SysMciRegAddress)) & 2);
|
||||||
|
@ -92,20 +92,21 @@ MciPrepareDataPath (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Set Data Length & Data Timer
|
// Set Data Length & Data Timer
|
||||||
MmioWrite32(MCI_DATA_TIMER_REG,0xFFFFFFF);
|
MmioWrite32 (MCI_DATA_TIMER_REG,0xFFFFFFF);
|
||||||
MmioWrite32(MCI_DATA_LENGTH_REG,MMCI0_BLOCKLEN);
|
MmioWrite32 (MCI_DATA_LENGTH_REG,MMCI0_BLOCKLEN);
|
||||||
|
|
||||||
#ifndef USE_STREAM
|
#ifndef USE_STREAM
|
||||||
//Note: we are using a hardcoded BlockLen (=512). If we decide to use a variable size, we could
|
//Note: we are using a hardcoded BlockLen (=512). If we decide to use a variable size, we could
|
||||||
// compute the pow2 of BlockLen with the above function GetPow2BlockLen()
|
// compute the pow2 of BlockLen with the above function GetPow2BlockLen()
|
||||||
MmioWrite32(MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | (MMCI0_POW2_BLOCKLEN << 4));
|
MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | (MMCI0_POW2_BLOCKLEN << 4));
|
||||||
#else
|
#else
|
||||||
MmioWrite32(MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | MCI_DATACTL_STREAM_TRANS);
|
MmioWrite32 (MCI_DATA_CTL_REG, MCI_DATACTL_ENABLE | MCI_DATACTL_DMA_ENABLE | TransferDirection | MCI_DATACTL_STREAM_TRANS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MciSendCommand (
|
MciSendCommand (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN MMC_CMD MmcCmd,
|
IN MMC_CMD MmcCmd,
|
||||||
IN UINT32 Argument
|
IN UINT32 Argument
|
||||||
)
|
)
|
||||||
|
@ -190,7 +191,7 @@ MciSendCommand (
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
//Disable Command Path
|
// Disable Command Path
|
||||||
CmdCtrlReg = MmioRead32(MCI_COMMAND_REG);
|
CmdCtrlReg = MmioRead32(MCI_COMMAND_REG);
|
||||||
MmioWrite32(MCI_COMMAND_REG, (CmdCtrlReg & ~MCI_CPSM_ENABLED));
|
MmioWrite32(MCI_COMMAND_REG, (CmdCtrlReg & ~MCI_CPSM_ENABLED));
|
||||||
return RetVal;
|
return RetVal;
|
||||||
|
@ -198,6 +199,7 @@ Exit:
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MciReceiveResponse (
|
MciReceiveResponse (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN MMC_RESPONSE_TYPE Type,
|
IN MMC_RESPONSE_TYPE Type,
|
||||||
IN UINT32* Buffer
|
IN UINT32* Buffer
|
||||||
)
|
)
|
||||||
|
@ -223,6 +225,7 @@ MciReceiveResponse (
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MciReadBlockData (
|
MciReadBlockData (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN EFI_LBA Lba,
|
IN EFI_LBA Lba,
|
||||||
IN UINTN Length,
|
IN UINTN Length,
|
||||||
IN UINT32* Buffer
|
IN UINT32* Buffer
|
||||||
|
@ -298,6 +301,7 @@ MciReadBlockData (
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MciWriteBlockData (
|
MciWriteBlockData (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN EFI_LBA Lba,
|
IN EFI_LBA Lba,
|
||||||
IN UINTN Length,
|
IN UINTN Length,
|
||||||
IN UINT32* Buffer
|
IN UINT32* Buffer
|
||||||
|
@ -396,6 +400,7 @@ Exit:
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MciNotifyState (
|
MciNotifyState (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN MMC_STATE State
|
IN MMC_STATE State
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -490,6 +495,7 @@ EFI_GUID mPL180MciDevicePathGuid = EFI_CALLER_ID_GUID;
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MciBuildDevicePath (
|
MciBuildDevicePath (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -503,6 +509,7 @@ MciBuildDevicePath (
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_MMC_HOST_PROTOCOL gMciHost = {
|
EFI_MMC_HOST_PROTOCOL gMciHost = {
|
||||||
|
MMC_HOST_PROTOCOL_REVISION,
|
||||||
MciIsCardPresent,
|
MciIsCardPresent,
|
||||||
MciIsReadOnly,
|
MciIsReadOnly,
|
||||||
MciBuildDevicePath,
|
MciBuildDevicePath,
|
||||||
|
|
|
@ -78,23 +78,59 @@ typedef enum _MMC_STATE {
|
||||||
MmcDisconnectState,
|
MmcDisconnectState,
|
||||||
} MMC_STATE;
|
} MMC_STATE;
|
||||||
|
|
||||||
typedef BOOLEAN (*MMC_ISCARDPRESENT)();
|
///
|
||||||
|
/// Forward declaration for EFI_MMC_HOST_PROTOCOL
|
||||||
|
///
|
||||||
|
typedef struct _EFI_MMC_HOST_PROTOCOL EFI_MMC_HOST_PROTOCOL;
|
||||||
|
|
||||||
typedef BOOLEAN (*MMC_ISREADONLY)();
|
typedef BOOLEAN (EFIAPI *MMC_ISCARDPRESENT) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This
|
||||||
|
);
|
||||||
|
|
||||||
typedef EFI_STATUS (*MMC_BUILDDEVICEPATH)(EFI_DEVICE_PATH_PROTOCOL **DevicePath);
|
typedef BOOLEAN (EFIAPI *MMC_ISREADONLY) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This
|
||||||
|
);
|
||||||
|
|
||||||
typedef EFI_STATUS (*MMC_NOTIFYSTATE)(MMC_STATE State);
|
typedef EFI_STATUS (EFIAPI *MMC_BUILDDEVICEPATH) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
|
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
||||||
|
);
|
||||||
|
|
||||||
typedef EFI_STATUS (*MMC_SENDCOMMAND)(MMC_CMD Cmd, UINT32 Argument);
|
typedef EFI_STATUS (EFIAPI *MMC_NOTIFYSTATE) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
|
IN MMC_STATE State
|
||||||
|
);
|
||||||
|
|
||||||
typedef EFI_STATUS (*MMC_RECEIVERESPONSE)(MMC_RESPONSE_TYPE Type, UINT32* Buffer);
|
typedef EFI_STATUS (EFIAPI *MMC_SENDCOMMAND) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
|
IN MMC_CMD Cmd,
|
||||||
|
IN UINT32 Argument
|
||||||
|
);
|
||||||
|
|
||||||
typedef EFI_STATUS (*MMC_READBLOCKDATA)(EFI_LBA Lba, UINTN Length, UINT32* Buffer);
|
typedef EFI_STATUS (EFIAPI *MMC_RECEIVERESPONSE) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
|
IN MMC_RESPONSE_TYPE Type,
|
||||||
|
IN UINT32 *Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef EFI_STATUS (EFIAPI *MMC_READBLOCKDATA) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
|
IN EFI_LBA Lba,
|
||||||
|
IN UINTN Length,
|
||||||
|
OUT UINT32 *Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef EFI_STATUS (EFIAPI *MMC_WRITEBLOCKDATA) (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
|
IN EFI_LBA Lba,
|
||||||
|
IN UINTN Length,
|
||||||
|
IN UINT32 *Buffer
|
||||||
|
);
|
||||||
|
|
||||||
typedef EFI_STATUS (*MMC_WRITEBLOCKDATA)(EFI_LBA Lba, UINTN Length, UINT32* Buffer);
|
|
||||||
|
|
||||||
typedef struct _EFI_MMC_HOST_PROTOCOL {
|
typedef struct _EFI_MMC_HOST_PROTOCOL {
|
||||||
|
|
||||||
|
UINT32 Revision;
|
||||||
MMC_ISCARDPRESENT IsCardPresent;
|
MMC_ISCARDPRESENT IsCardPresent;
|
||||||
MMC_ISREADONLY IsReadOnly;
|
MMC_ISREADONLY IsReadOnly;
|
||||||
MMC_BUILDDEVICEPATH BuildDevicePath;
|
MMC_BUILDDEVICEPATH BuildDevicePath;
|
||||||
|
@ -106,8 +142,11 @@ typedef struct _EFI_MMC_HOST_PROTOCOL {
|
||||||
|
|
||||||
MMC_READBLOCKDATA ReadBlockData;
|
MMC_READBLOCKDATA ReadBlockData;
|
||||||
MMC_WRITEBLOCKDATA WriteBlockData;
|
MMC_WRITEBLOCKDATA WriteBlockData;
|
||||||
|
|
||||||
} EFI_MMC_HOST_PROTOCOL;
|
} EFI_MMC_HOST_PROTOCOL;
|
||||||
|
|
||||||
|
#define MMC_HOST_PROTOCOL_REVISION 0x00010001 // 1.1
|
||||||
|
|
||||||
extern EFI_GUID gEfiMmcHostProtocolGuid;
|
extern EFI_GUID gEfiMmcHostProtocolGuid;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -116,7 +116,7 @@ MMC_HOST_INSTANCE* CreateMmcHostInstance (
|
||||||
MmcHostInstance->MmcHost = MmcHost;
|
MmcHostInstance->MmcHost = MmcHost;
|
||||||
|
|
||||||
// Create DevicePath for the new MMC Host
|
// Create DevicePath for the new MMC Host
|
||||||
Status = MmcHost->BuildDevicePath(&NewDevicePathNode);
|
Status = MmcHost->BuildDevicePath (MmcHost, &NewDevicePathNode);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto FREE_MEDIA;
|
goto FREE_MEDIA;
|
||||||
}
|
}
|
||||||
|
@ -364,13 +364,13 @@ CheckCardsCallback (
|
||||||
MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
|
MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
|
||||||
ASSERT(MmcHostInstance != NULL);
|
ASSERT(MmcHostInstance != NULL);
|
||||||
|
|
||||||
if (MmcHostInstance->MmcHost->IsCardPresent() == !MmcHostInstance->Initialized) {
|
if (MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost) == !MmcHostInstance->Initialized) {
|
||||||
MmcHostInstance->State = MmcHwInitializationState;
|
MmcHostInstance->State = MmcHwInitializationState;
|
||||||
MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized;
|
MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized;
|
||||||
MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
|
MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
|
||||||
|
|
||||||
if(MmcHostInstance->BlockIo.Media->MediaPresent) {
|
if (MmcHostInstance->BlockIo.Media->MediaPresent) {
|
||||||
InitializeMmcDevice(MmcHostInstance);
|
InitializeMmcDevice (MmcHostInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->ReinstallProtocolInterface (
|
Status = gBS->ReinstallProtocolInterface (
|
||||||
|
|
|
@ -288,7 +288,7 @@ MmcFlushBlocks (
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This
|
IN EFI_BLOCK_IO_PROTOCOL *This
|
||||||
);
|
);
|
||||||
|
|
||||||
EFI_STATUS InitializeMmcDevice(
|
EFI_STATUS InitializeMmcDevice (
|
||||||
IN MMC_HOST_INSTANCE *MmcHost
|
IN MMC_HOST_INSTANCE *MmcHost
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ MmcNotifyState (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MmcHostInstance->State = State;
|
MmcHostInstance->State = State;
|
||||||
return MmcHostInstance->MmcHost->NotifyState(State);
|
return MmcHostInstance->MmcHost->NotifyState (MmcHostInstance->MmcHost, State);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -169,14 +169,14 @@ MmcGetCardStatus(
|
||||||
if(MmcHostInstance->State != MmcHwInitializationState){
|
if(MmcHostInstance->State != MmcHwInitializationState){
|
||||||
//Get the Status of the card.
|
//Get the Status of the card.
|
||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Status = MmcHost->SendCommand(MMC_CMD13, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status));
|
DEBUG((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Read Response
|
//Read Response
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
|
||||||
PrintResponseR1(Response[0]);
|
PrintResponseR1(Response[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ MmcIdentificationMode (
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Note: Could even be used in all cases. But it looks this command could put the state machine into inactive for some cards
|
//Note: Could even be used in all cases. But it looks this command could put the state machine into inactive for some cards
|
||||||
Status = MmcHost->SendCommand(MMC_CMD0, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -228,7 +228,7 @@ MmcIdentificationMode (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we using SDIO ?
|
// Are we using SDIO ?
|
||||||
Status = MmcHost->SendCommand(MMC_CMD5, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
|
@ -236,11 +236,11 @@ MmcIdentificationMode (
|
||||||
|
|
||||||
// Check which kind of card we are using. Ver2.00 or later SD Memory Card (PL180 is SD v1.1)
|
// Check which kind of card we are using. Ver2.00 or later SD Memory Card (PL180 is SD v1.1)
|
||||||
CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0);
|
CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0);
|
||||||
Status = MmcHost->SendCommand(MMC_CMD8, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n"));
|
DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n"));
|
||||||
IsHCS = TRUE;
|
IsHCS = TRUE;
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R7,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7,Response);
|
||||||
PrintResponseR1(Response[0]);
|
PrintResponseR1(Response[0]);
|
||||||
//check if it is valid response
|
//check if it is valid response
|
||||||
if(Response[0] != CmdArg){
|
if(Response[0] != CmdArg){
|
||||||
|
@ -255,7 +255,7 @@ MmcIdentificationMode (
|
||||||
Timeout = MAX_RETRY_COUNT;
|
Timeout = MAX_RETRY_COUNT;
|
||||||
while (Timeout > 0) {
|
while (Timeout > 0) {
|
||||||
// SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command
|
// SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command
|
||||||
Status = MmcHost->SendCommand(MMC_CMD55, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, 0);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
DEBUG ((EFI_D_INFO, "Card should be SD\n"));
|
DEBUG ((EFI_D_INFO, "Card should be SD\n"));
|
||||||
if (IsHCS) {
|
if (IsHCS) {
|
||||||
|
@ -269,18 +269,18 @@ MmcIdentificationMode (
|
||||||
if (IsHCS) {
|
if (IsHCS) {
|
||||||
CmdArg |= BIT30;
|
CmdArg |= BIT30;
|
||||||
}
|
}
|
||||||
Status = MmcHost->SendCommand(MMC_ACMD41, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_OCR,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR,Response);
|
||||||
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((EFI_D_INFO, "Card should be MMC\n"));
|
DEBUG ((EFI_D_INFO, "Card should be MMC\n"));
|
||||||
MmcHostInstance->CardInfo.CardType = MMC_CARD;
|
MmcHostInstance->CardInfo.CardType = MMC_CARD;
|
||||||
|
|
||||||
Status = MmcHost->SendCommand(MMC_CMD1, 0x800000);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_OCR,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR,Response);
|
||||||
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,12 +315,12 @@ MmcIdentificationMode (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcHost->SendCommand(MMC_CMD2, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD2, 0);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_CID,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID,Response);
|
||||||
PrintCID(Response);
|
PrintCID(Response);
|
||||||
|
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcIdentificationState);
|
Status = MmcNotifyState (MmcHostInstance, MmcIdentificationState);
|
||||||
|
@ -335,13 +335,13 @@ MmcIdentificationMode (
|
||||||
// The status returned for this CMD3 will be 2 - identification
|
// The status returned for this CMD3 will be 2 - identification
|
||||||
//
|
//
|
||||||
CmdArg = 1;
|
CmdArg = 1;
|
||||||
Status = MmcHost->SendCommand(MMC_CMD3, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_RCA,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_RCA,Response);
|
||||||
PrintRCA(Response[0]);
|
PrintRCA(Response[0]);
|
||||||
|
|
||||||
// For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
|
// For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
|
||||||
|
@ -360,7 +360,7 @@ MmcIdentificationMode (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS InitializeMmcDevice(
|
EFI_STATUS InitializeMmcDevice (
|
||||||
IN MMC_HOST_INSTANCE *MmcHostInstance
|
IN MMC_HOST_INSTANCE *MmcHostInstance
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -376,13 +376,13 @@ EFI_STATUS InitializeMmcDevice(
|
||||||
|
|
||||||
//Send a command to get Card specific data
|
//Send a command to get Card specific data
|
||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Status = MmcHost->SendCommand(MMC_CMD9, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
//Read Response
|
//Read Response
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_CSD,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD,Response);
|
||||||
PrintCSD(Response);
|
PrintCSD(Response);
|
||||||
|
|
||||||
if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
|
if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
|
||||||
|
@ -403,12 +403,12 @@ EFI_STATUS InitializeMmcDevice(
|
||||||
|
|
||||||
MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1);
|
MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1);
|
||||||
MmcHostInstance->BlockIo.Media->BlockSize = BlockSize;
|
MmcHostInstance->BlockIo.Media->BlockSize = BlockSize;
|
||||||
MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly();
|
MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly (MmcHost);
|
||||||
MmcHostInstance->BlockIo.Media->MediaPresent = TRUE;
|
MmcHostInstance->BlockIo.Media->MediaPresent = TRUE;
|
||||||
MmcHostInstance->BlockIo.Media->MediaId++;
|
MmcHostInstance->BlockIo.Media->MediaId++;
|
||||||
|
|
||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Status = MmcHost->SendCommand(MMC_CMD7, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -421,7 +421,7 @@ EFI_STATUS InitializeMmcDevice(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Block Length
|
// Set Block Length
|
||||||
Status = MmcHost->SendCommand(MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",MmcHostInstance->BlockIo.Media->BlockSize, Status));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",MmcHostInstance->BlockIo.Media->BlockSize, Status));
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -429,7 +429,7 @@ EFI_STATUS InitializeMmcDevice(
|
||||||
|
|
||||||
// Block Count (not used). Could return an error for SD card
|
// Block Count (not used). Could return an error for SD card
|
||||||
if (MmcHostInstance->CardInfo.CardType == MMC_CARD) {
|
if (MmcHostInstance->CardInfo.CardType == MMC_CARD) {
|
||||||
MmcHost->SendCommand(MMC_CMD23, BlockCount);
|
MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -452,7 +452,7 @@ MmcReset (
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a card is not present then clear all media settings
|
// If a card is not present then clear all media settings
|
||||||
if (!MmcHostInstance->MmcHost->IsCardPresent()) {
|
if (!MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost)) {
|
||||||
MmcHostInstance->BlockIo.Media->MediaPresent = FALSE;
|
MmcHostInstance->BlockIo.Media->MediaPresent = FALSE;
|
||||||
MmcHostInstance->BlockIo.Media->LastBlock = 0;
|
MmcHostInstance->BlockIo.Media->LastBlock = 0;
|
||||||
MmcHostInstance->BlockIo.Media->BlockSize = 512; // Should be zero but there is a bug in DiskIo
|
MmcHostInstance->BlockIo.Media->BlockSize = 512; // Should be zero but there is a bug in DiskIo
|
||||||
|
@ -474,7 +474,7 @@ MmcDetectCard (
|
||||||
EFI_MMC_HOST_PROTOCOL *MmcHost
|
EFI_MMC_HOST_PROTOCOL *MmcHost
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!MmcHost->IsCardPresent()) {
|
if (!MmcHost->IsCardPresent (MmcHost)) {
|
||||||
return EFI_NO_MEDIA;
|
return EFI_NO_MEDIA;
|
||||||
} else {
|
} else {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
@ -544,9 +544,9 @@ MmcIoBlocks (
|
||||||
Response[0] = 0;
|
Response[0] = 0;
|
||||||
Timeout = 20;
|
Timeout = 20;
|
||||||
while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
|
while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
|
||||||
Status = MmcHost->SendCommand(MMC_CMD13, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ MmcIoBlocks (
|
||||||
//TODO: Should we support write stream (MMC_CMD20)
|
//TODO: Should we support write stream (MMC_CMD20)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Status = MmcHost->SendCommand(Cmd, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD%d): Error %r\n",Cmd, Status));
|
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD%d): Error %r\n",Cmd, Status));
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -586,7 +586,7 @@ MmcIoBlocks (
|
||||||
if (Transfer == MMC_IOBLOCKS_READ) {
|
if (Transfer == MMC_IOBLOCKS_READ) {
|
||||||
#ifndef USE_STREAM
|
#ifndef USE_STREAM
|
||||||
// Read one block of Data
|
// Read one block of Data
|
||||||
Status = MmcHost->ReadBlockData(Lba,This->Media->BlockSize,Buffer);
|
Status = MmcHost->ReadBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Read Block Data and Status = %r\n", Status));
|
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Read Block Data and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -603,7 +603,7 @@ MmcIoBlocks (
|
||||||
} else {
|
} else {
|
||||||
#ifndef USE_STREAM
|
#ifndef USE_STREAM
|
||||||
// Write one block of Data
|
// Write one block of Data
|
||||||
Status = MmcHost->WriteBlockData(Lba,This->Media->BlockSize,Buffer);
|
Status = MmcHost->WriteBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Write Block Data and Status = %r\n", Status));
|
DEBUG((EFI_D_BLKIO, "MmcIdentificationMode(): Error Write Block Data and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -615,9 +615,9 @@ MmcIoBlocks (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command 12 - Stop transmission (ends read)
|
// Command 12 - Stop transmission (ends read)
|
||||||
Status = MmcHost->SendCommand(MMC_CMD12, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1b,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b,Response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command 13 - Read status and wait for programming to complete (return to tran)
|
// Command 13 - Read status and wait for programming to complete (return to tran)
|
||||||
|
@ -625,9 +625,9 @@ MmcIoBlocks (
|
||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Response[0] = 0;
|
Response[0] = 0;
|
||||||
while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
|
while(!(Response[0] & MMC_R0_READY_FOR_DATA) && (MMC_R0_CURRENTSTATE(Response) != MMC_R0_STATE_TRAN) && Timeout--) {
|
||||||
Status = MmcHost->SendCommand(MMC_CMD13, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
MmcHost->ReceiveResponse(MMC_RESPONSE_TYPE_R1,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
|
||||||
}
|
}
|
||||||
NanoSecondDelay(100);
|
NanoSecondDelay(100);
|
||||||
Timeout--;
|
Timeout--;
|
||||||
|
|
|
@ -280,7 +280,7 @@ InitializeMMCHS (
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
MMCIsCardPresent (
|
MMCIsCardPresent (
|
||||||
VOID
|
IN EFI_MMC_HOST_PROTOCOL *This
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
@ -299,7 +299,7 @@ MMCIsCardPresent (
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
MMCIsReadOnly (
|
MMCIsReadOnly (
|
||||||
VOID
|
IN EFI_MMC_HOST_PROTOCOL *This
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* Note:
|
/* Note:
|
||||||
|
@ -318,6 +318,7 @@ EFI_GUID mPL180MciDevicePathGuid = EFI_CALLER_ID_GUID;
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MMCBuildDevicePath (
|
MMCBuildDevicePath (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -331,6 +332,7 @@ MMCBuildDevicePath (
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MMCSendCommand (
|
MMCSendCommand (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN MMC_CMD MmcCmd,
|
IN MMC_CMD MmcCmd,
|
||||||
IN UINT32 Argument
|
IN UINT32 Argument
|
||||||
)
|
)
|
||||||
|
@ -403,6 +405,7 @@ MMCSendCommand (
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MMCNotifyState (
|
MMCNotifyState (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN MMC_STATE State
|
IN MMC_STATE State
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -526,6 +529,7 @@ MMCNotifyState (
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MMCReceiveResponse (
|
MMCReceiveResponse (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN MMC_RESPONSE_TYPE Type,
|
IN MMC_RESPONSE_TYPE Type,
|
||||||
IN UINT32* Buffer
|
IN UINT32* Buffer
|
||||||
)
|
)
|
||||||
|
@ -554,6 +558,7 @@ MMCReceiveResponse (
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MMCReadBlockData (
|
MMCReadBlockData (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN EFI_LBA Lba,
|
IN EFI_LBA Lba,
|
||||||
IN UINTN Length,
|
IN UINTN Length,
|
||||||
IN UINT32* Buffer
|
IN UINT32* Buffer
|
||||||
|
@ -595,6 +600,7 @@ MMCReadBlockData (
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
MMCWriteBlockData (
|
MMCWriteBlockData (
|
||||||
|
IN EFI_MMC_HOST_PROTOCOL *This,
|
||||||
IN EFI_LBA Lba,
|
IN EFI_LBA Lba,
|
||||||
IN UINTN Length,
|
IN UINTN Length,
|
||||||
IN UINT32* Buffer
|
IN UINT32* Buffer
|
||||||
|
@ -635,6 +641,7 @@ MMCWriteBlockData (
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_MMC_HOST_PROTOCOL gMMCHost = {
|
EFI_MMC_HOST_PROTOCOL gMMCHost = {
|
||||||
|
MMC_HOST_PROTOCOL_REVISION,
|
||||||
MMCIsCardPresent,
|
MMCIsCardPresent,
|
||||||
MMCIsReadOnly,
|
MMCIsReadOnly,
|
||||||
MMCBuildDevicePath,
|
MMCBuildDevicePath,
|
||||||
|
|
Loading…
Reference in New Issue