X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EmbeddedPkg%2FUniversal%2FMmcDxe%2FMmc.h;h=f4e0aa0366938bd6cc94b4d64399ee5b50a1d813;hp=44ad585bbafca2fe74182f20fdb1ed847cdb5a3c;hb=36bec33a999388c460e32413e5e9ddf554d2ec78;hpb=ce73d60afbf3832732f4a718497e004d6c983541 diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h index 44ad585bba..f4e0aa0366 100644 --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h @@ -1,15 +1,15 @@ /** @file Main Header file for the MMC DXE driver - Copyright (c) 2011, ARM Limited. All rights reserved. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php + Copyright (c) 2011-2015, ARM Limited. All rights reserved. - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ @@ -24,6 +24,8 @@ #include #include +#include +#include #define MMC_TRACE(txt) DEBUG((EFI_D_BLKIO, "MMC: " txt "\n")) @@ -32,14 +34,17 @@ #define MMC_OCR_POWERUP 0x80000000 -#define MMC_CSD_GET_CCC(Response) (Response[1] >> 20) -#define MMC_CSD_GET_TRANSPEED(Response) (Response[0] & 0xFF) -#define MMC_CSD_GET_READBLLEN(Response) ((Response[1] >> 16) & 0xF) -#define MMC_CSD_GET_WRITEBLLEN(Response) ((Response[3] >> 22) & 0xF) -#define MMC_CSD_GET_FILEFORMAT(Response) ((Response[3] >> 10) & 0x3) -#define MMC_CSD_GET_FILEFORMATGRP(Response) ((Response[3] >> 15) & 0x1) -#define MMC_CSD_GET_DEVICESIZE(csd) (((Response[2] >> 30) & 0x3) | ((Response[1] & 0x3FF) << 2)) -#define MMC_CSD_GET_DEVICESIZEMULT(csd) ((Response[2] >> 15) & 0x7) +#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) @@ -54,19 +59,20 @@ typedef enum { UNKNOWN_CARD, MMC_CARD, //MMC card MMC_CARD_HIGH, //MMC Card with High capacity + EMMC_CARD, //eMMC 4.41 card SD_CARD, //SD 1.1 card SD_CARD_2, //SD 2.0 or above standard card SD_CARD_2_HIGH //SD 2.0 or above high capacity card } CARD_TYPE; typedef struct { - UINT32 Reserved0: 7; // 0 + UINT32 Reserved0: 7; // 0 UINT32 V170_V195: 1; // 1.70V - 1.95V UINT32 V200_V260: 7; // 2.00V - 2.60V UINT32 V270_V360: 9; // 2.70V - 3.60V UINT32 RESERVED_1: 5; // Reserved - UINT32 AccessMode: 2; // 00b (byte mode), 10b (sector mode) - UINT32 Busy: 1; // This bit is set to LOW if the card has not finished the power up routine + UINT32 AccessMode: 2; // 00b (byte mode), 10b (sector mode) + UINT32 PowerUp: 1; // This bit is set to LOW if the card has not finished the power up routine } OCR; typedef struct { @@ -91,14 +97,14 @@ typedef struct { UINT8 PERM_WRITE_PROTECT: 1; // Permanent write protection [13:13] UINT8 COPY: 1; // Copy flag (OTP) [14:14] UINT8 FILE_FORMAT_GRP: 1; // File format group [15:15] - + UINT16 RESERVED_2: 5; // Reserved [20:16] UINT16 WRITE_BL_PARTIAL: 1; // Partial blocks for write allowed [21:21] UINT16 WRITE_BL_LEN: 4; // Max. write data block length [25:22] UINT16 R2W_FACTOR: 3; // Write speed factor [28:26] UINT16 RESERVED_3: 2; // Reserved [30:29] UINT16 WP_GRP_ENABLE: 1; // Write protect group enable [31:31] - + UINT32 WP_GRP_SIZE: 7; // Write protect group size [38:32] UINT32 SECTOR_SIZE: 7; // Erase sector size [45:39] UINT32 ERASE_BLK_EN: 1; // Erase single block enable [46:46] @@ -108,7 +114,7 @@ typedef struct { UINT32 VDD_R_CURR_MAX: 3; // Max. read current @ VDD max [58:56] UINT32 VDD_R_CURR_MIN: 3; // Max. read current @ VDD min [61:59] UINT32 C_SIZELow2: 2; // Device size [63:62] - + UINT32 C_SIZEHigh10: 10;// Device size [73:64] UINT32 RESERVED_4: 2; // Reserved [75:74] UINT32 DSR_IMP: 1; // DSR implemented [76:76] @@ -121,7 +127,7 @@ typedef struct { UINT8 TRAN_SPEED ; // Max. bus clock frequency [103:96] UINT8 NSAC ; // Data read access-time 2 in CLK cycles (NSAC*100) [111:104] UINT8 TAAC ; // Data read access-time 1 [119:112] - + UINT8 RESERVED_5: 6; // Reserved [125:120] UINT8 CSD_STRUCTURE: 2; // CSD structure [127:126] } CSD; @@ -132,6 +138,7 @@ typedef struct { OCR OCRData; CID CIDData; CSD CSDData; + UINT32 ECSD[128]; // MMC V4 extended card specific } CARD_INFO; typedef struct _MMC_HOST_INSTANCE { @@ -144,6 +151,8 @@ typedef struct _MMC_HOST_INSTANCE { EFI_BLOCK_IO_PROTOCOL BlockIo; CARD_INFO CardInfo; EFI_MMC_HOST_PROTOCOL *MmcHost; + + BOOLEAN Initialized; } MMC_HOST_INSTANCE; #define MMC_HOST_INSTANCE_SIGNATURE SIGNATURE_32('m', 'm', 'c', 'h') @@ -179,7 +188,7 @@ extern LIST_ENTRY mMmcHostPool; /** Reset the block device. - This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). + This function implements EFI_BLOCK_IO_PROTOCOL.Reset(). It resets the block device hardware. ExtendedVerification is ignored in this implementation. @@ -201,7 +210,7 @@ MmcReset ( /** Reads the requested number of blocks from the device. - This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks(). + 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. @@ -235,7 +244,7 @@ MmcReadBlocks ( /** Writes a specified number of blocks to the device. - This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks(). + 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. @@ -283,4 +292,47 @@ 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 + ); + #endif