Difference between revisions of "Unit MMC"

From Ultibo.org
Jump to: navigation, search
Line 1,012: Line 1,012:
 
| <code>MMC_CSD_CRC = 36;</code>
 
| <code>MMC_CSD_CRC = 36;</code>
 
| &nbsp;
 
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''MMC CSD structure value constants''' <code> MMC_CSD_STRUCT_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MMC_CSD_STRUCT_VER_1_0 = 0;</code>
 +
| Valid for system specification 1.0 - 1.2
 +
|-
 +
| <code>MMC_CSD_STRUCT_VER_1_? = ?;</code>
 +
| Valid for system specification 1.4 - 2.2
 +
|-
 +
| <code>MMC_CSD_STRUCT_VER_1_2 = 2;</code>
 +
| Valid for system specification 3.? - 3.2 - 3.3? - 4.0 - 4.?
 +
|-
 +
| <code>MMC_CSD_STRUCT_EXT_CSD = 3;</code>
 +
| Version is coded in CSD_STRUCTURE in EXT_CSD
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''MMC CSD spec version value constants''' <code> MMC_CSD_SPEC_VER_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>MMC_CSD_SPEC_VER_0 = 0;</code>
 +
| Implements system specification 1.0 - 1.2
 +
|-
 +
| <code>MMC_CSD_SPEC_VER_1 = ?;</code>
 +
| Implements system specification 1.4
 +
|-
 +
| <code>MMC_CSD_SPEC_VER_2 = 2;</code>
 +
| Implements system specification 2.0 - 2.2
 +
|-
 +
| <code>MMC_CSD_SPEC_VER_3 = 3;</code>
 +
| Implements system specification 3.? - 3.2 - 3.3?
 +
|-
 +
| <code>MMC_CSD_SPEC_VER_4 = 4;</code>
 +
| Implements system specification 4.0 - 4.?
 
|-
 
|-
 
|}
 
|}

Revision as of 03:58, 28 November 2016

Return to Unit Reference


Description


This unit implements the standards based part of the SD/MMC specification including the standard SDHCI interfaces.

For each platform a SDHCI module needs to be provided that implements the platform specific parts of the SDHCI interface.

This is similar in model to USB and other interfaces in Ultibo, where the generic interface unit requires a platform specific module to register with it in order to communicate with platform specific devices.

The SD/MMC interfaces are 2 tier (ie Host and Device) whereas the USB interface is 3 tier (Host, Device and Driver).

Constants



MMC specific constants MMC_*
MMC_NAME_PREFIX = 'MMC'; Name prefix for MMC Devices
 
MMC_STATUS_TIMER_INTERVAL = 1000;  
 
MMC_DEFAULT_BLOCKSIZE = 512;  
MMC_DEFAULT_BLOCKSHIFT = 9;  


MMC device type constants MMC_TYPE_*
MMC_TYPE_NONE = 0;  
MMC_TYPE_MMC = 1;  
MMC_TYPE_SD = 2;  
MMC_TYPE_SDIO = 3;  
MMC_TYPE_SD_COMBO = 4;  
 
MMC_TYPE_MAX = 4;  


MMC device state constants MMC_STATE_*
MMC_STATE_EJECTED = 0;  
MMC_STATE_INSERTED = 1;  
 
MMC_STATE_MAX = 1;  


MMC device flag constants MMC_FLAG_*
MMC_FLAG_NONE = $00000000;  
MMC_FLAG_CARD_PRESENT = $00000001;  
MMC_FLAG_WRITE_PROTECT = $00000002;  
MMC_FLAG_HIGH_CAPACITY = $00000004; High Capacity (SDHC)
MMC_FLAG_EXT_CAPACITY = $00000008; Extended Capacity (SDXC)
MMC_FLAG_UHS_I = $00000010; Ultra High Speed (UHS-I)
MMC_FLAG_UHS_II = $00000020; Ultra High Speed (UHS-II)
MMC_FLAG_BLOCK_ADDRESSED = $00000040; Block Addressed (SDHC/SDXC and others)
MMC_FLAG_DDR_MODE = $00000080;  


MMC/SD status code constants MMC_STATUS_*
MMC_STATUS_SUCCESS = 0; Function successful
MMC_STATUS_TIMEOUT = 1; The operation timed out
MMC_STATUS_NO_MEDIA = 2; No media present in device
MMC_STATUS_HARDWARE_ERROR = 3; Hardware error of some form occurred
MMC_STATUS_INVALID_DATA = 4; Invalid data was received
MMC_STATUS_INVALID_PARAMETER = 5; An invalid parameter was passed to the function
MMC_STATUS_INVALID_SEQUENCE = 6; Invalid sequence encountered
MMC_STATUS_OUT_OF_MEMORY = 7; No memory available for operation
MMC_STATUS_UNSUPPORTED_REQUEST = 8; The request is unsupported
MMC_STATUS_NOT_PROCESSED = 9; The MMC transfer has not yet been processed


MMC/SD version constants SD_VERSION_*, MMC_VERSION_*
SD_VERSION_SD = $00020000;  
SD_VERSION_1_0 = (SD_VERSION_SD or $0100);  
SD_VERSION_1_10 = (SD_VERSION_SD or $010a);  
SD_VERSION_2 = (SD_VERSION_SD or $0200);  
SD_VERSION_3 = (SD_VERSION_SD or $0300);  
SD_VERSION_4 = (SD_VERSION_SD or $0400);  
 
MMC_VERSION_MMC = $00010000;  
MMC_VERSION_1_2 = (MMC_VERSION_MMC or $0102);  
MMC_VERSION_1_4 = (MMC_VERSION_MMC or $0104);  
MMC_VERSION_2_2 = (MMC_VERSION_MMC or $0202);  
MMC_VERSION_3 = (MMC_VERSION_MMC or $0300);  
MMC_VERSION_4 = (MMC_VERSION_MMC or $0400);  
MMC_VERSION_4_1 = (MMC_VERSION_MMC or $0401);  
MMC_VERSION_4_2 = (MMC_VERSION_MMC or $0402);  
MMC_VERSION_4_3 = (MMC_VERSION_MMC or $0403);  
MMC_VERSION_4_41 = (MMC_VERSION_MMC or $0429);  
MMC_VERSION_4_5 = (MMC_VERSION_MMC or $0405);  
MMC_VERSION_5_0 = (MMC_VERSION_MMC or $0500);  
MMC_VERSION_UNKNOWN = (MMC_VERSION_MMC);  


MMC/SD mode constants MMC_MODE_*
MMC_MODE_HS = (1 shl 0);  
MMC_MODE_HS_52MHz = (1 shl 1);  
MMC_MODE_4BIT = (1 shl 2);  
MMC_MODE_8BIT = (1 shl 3);  
MMC_MODE_SPI = (1 shl 4);  
MMC_MODE_HC = (1 shl 5);  
MMC_MODE_DDR_52MHz = (1 shl 6);  


MMC/SD direction constants MMC_DATA_*
MMC_DATA_READ = 1;  
MMC_DATA_WRITE = 2;  


MMC/SD bus width constants MMC_BUS_WIDTH_*
MMC_BUS_WIDTH_1 = 0;  
MMC_BUS_WIDTH_4 = 2;  
MMC_BUS_WIDTH_8 = 3;  


MMC bus speed (Hz) constants MMC_BUS_SPEED_*
MMC_BUS_SPEED_DEFAULT = 0;  
MMC_BUS_SPEED_HS26 = 26000000;  
MMC_BUS_SPEED_HS52 = 52000000;  
MMC_BUS_SPEED_DDR = 52000000;  
MMC_BUS_SPEED_HS200 = 200000000;  


MMC command constants MMC_CMD_*
From: /include/linux/mmc/mmc.h
 
Class 1
MMC_CMD_GO_IDLE_STATE = 0;  
MMC_CMD_SEND_OP_COND = 1;  
MMC_CMD_ALL_SEND_CID = 2;  
MMC_CMD_SET_RELATIVE_ADDR = 3;  
MMC_CMD_SET_DSR = 4;  
MMC_CMD_SLEEP_AWAKE = 5;  
MMC_CMD_SWITCH = 6;  
MMC_CMD_SELECT_CARD = 7;  
MMC_CMD_SEND_EXT_CSD = 8;  
MMC_CMD_SEND_CSD = 9;  
MMC_CMD_SEND_CID = 10;  
MMC_CMD_READ_DAT_UNTIL_STOP = 11;  
MMC_CMD_STOP_TRANSMISSION = 12;  
MMC_CMD_SEND_STATUS = 13;  
MMC_CMD_BUS_TEST_R = 14;  
MMC_CMD_GO_INACTIVE_STATE = 15;  
MMC_CMD_BUS_TEST_W = 19;  
MMC_CMD_SPI_READ_OCR = 58;  
MMC_CMD_SPI_CRC_ON_OFF = 59;  
 
Class 2
MMC_CMD_SET_BLOCKLEN = 16;  
MMC_CMD_READ_SINGLE_BLOCK = 17;  
MMC_CMD_READ_MULTIPLE_BLOCK = 18;  
MMC_CMD_SEND_TUNING_BLOCK = 19;  
MMC_CMD_SEND_TUNING_BLOCK_HS200 = 21;  
 
Class 3
MMC_CMD_WRITE_DAT_UNTIL_STOP = 20;  
 
Class 4
MMC_CMD_SET_BLOCK_COUNT = 23;  
MMC_CMD_WRITE_SINGLE_BLOCK = 24;  
MMC_CMD_WRITE_MULTIPLE_BLOCK = 25;  
MMC_CMD_PROGRAM_CID = 26;  
MMC_CMD_PROGRAM_CSD = 27;  
 
Class 6
MMC_CMD_SET_WRITE_PROT = 28;  
MMC_CMD_CLR_WRITE_PROT = 29;  
MMC_CMD_SEND_WRITE_PROT = 30;  
 
Class 5
MMC_CMD_ERASE_GROUP_START = 35;  
MMC_CMD_ERASE_GROUP_END = 36;  
MMC_CMD_ERASE = 38;  
 
Class 9
MMC_CMD_FAST_IO = 39;  
MMC_CMD_GO_IRQ_STATE = 40;  
 
Class 7
MMC_CMD_LOCK_UNLOCK = 42;  
 
Class 8
MMC_CMD_APP_CMD = 55;  
MMC_CMD_GEN_CMD = 56;  
MMC_CMD_RES_MAN = 62;  
 
MMC_CMD62_ARG1 = $EFAC62EC;  
MMC_CMD62_ARG2 = $00CBAEA7;  


MMC response type constants MMC_RSP_*
From: /include/linux/mmc/mmc.h
 
Native
MMC_RSP_PRESENT = (1 shl 0);  
MMC_RSP_136 = (1 shl 1); 136 bit response
MMC_RSP_CRC = (1 shl 2); Expect valid crc
MMC_RSP_BUSY = (1 shl 3); Card may send busy
MMC_RSP_OPCODE = (1 shl 4); Response contains opcode
These are the native response types, and correspond to valid bit patterns of the above flags. One additional valid pattern is all zeros, which means we don't expect a response.
MMC_RSP_NONE = (0);  
MMC_RSP_R1 = (MMC_RSP_PRESENT or MMC_RSP_CRC or MMC_RSP_OPCODE);  
MMC_RSP_R1B = (MMC_RSP_PRESENT or MMC_RSP_CRC or MMC_RSP_OPCODE or MMC_RSP_BUSY);  
MMC_RSP_R2 = (MMC_RSP_PRESENT or MMC_RSP_136 or MMC_RSP_CRC);  
MMC_RSP_R3 = (MMC_RSP_PRESENT);  
MMC_RSP_R4 = (MMC_RSP_PRESENT);  
MMC_RSP_R5 = (MMC_RSP_PRESENT or MMC_RSP_CRC or MMC_RSP_OPCODE);  
MMC_RSP_R6 = (MMC_RSP_PRESENT or MMC_RSP_CRC or MMC_RSP_OPCODE);  
MMC_RSP_R7 = (MMC_RSP_PRESENT or MMC_RSP_CRC or MMC_RSP_OPCODE);  
 
SPI
MMC_RSP_SPI_S1 = (1 shl 7); One status byte
MMC_RSP_SPI_S2 = (1 shl 8); Second byte
MMC_RSP_SPI_B4 = (1 shl 9); Four data bytes
MMC_RSP_SPI_BUSY = (1 shl 10); Card may send busy
These are the SPI response types for MMC, SD, and SDIO cards. Commands return R1, with maybe more info. Zero is an error type, callers must always provide the appropriate MMC_RSP_SPI_Rx flags.
MMC_RSP_SPI_R1 = (MMC_RSP_SPI_S1);  
MMC_RSP_SPI_R1B = (MMC_RSP_SPI_S1 or MMC_RSP_SPI_BUSY);  
MMC_RSP_SPI_R2 = (MMC_RSP_SPI_S1 or MMC_RSP_SPI_S2);  
MMC_RSP_SPI_R3 = (MMC_RSP_SPI_S1 or MMC_RSP_SPI_B4);  
MMC_RSP_SPI_R4 = (MMC_RSP_SPI_S1 or MMC_RSP_SPI_B4);  
MMC_RSP_SPI_R5 = (MMC_RSP_SPI_S1 or MMC_RSP_SPI_S2);  
MMC_RSP_SPI_R7 = (MMC_RSP_SPI_S1 or MMC_RSP_SPI_B4);  


MMC response value constants MMC_RSP_R1_*, MMC_RSP_R2_*
R1 - MMC status in R1, for native mode (SPI bits are different)
MMC_RSP_R1_OUT_OF_RANGE = (1 shl 31);  
MMC_RSP_R1_ADDRESS_ERROR = (1 shl 30);  
MMC_RSP_R1_BLOCK_LEN_ERROR = (1 shl 29);  
MMC_RSP_R1_ERASE_SEQ_ERROR = (1 shl 28);  
MMC_RSP_R1_ERASE_PARAM = (1 shl 27);  
MMC_RSP_R1_WP_VIOLATION = (1 shl 26);  
MMC_RSP_R1_CARD_IS_LOCKED = (1 shl 25);  
MMC_RSP_R1_LOCK_UNLOCK_FAILED = (1 shl 24);  
MMC_RSP_R1_COM_CRC_ERROR = (1 shl 23);  
MMC_RSP_R1_ILLEGAL_COMMAND = (1 shl 22);  
MMC_RSP_R1_CARD_ECC_FAILED = (1 shl 21);  
MMC_RSP_R1_CC_ERROR = (1 shl 20);  
MMC_RSP_R1_ERROR = (1 shl 19);  
MMC_RSP_R1_UNDERRUN = (1 shl 18);  
MMC_RSP_R1_OVERRUN = (1 shl 17);  
MMC_RSP_R1_CID_CSD_OVERWRITE = (1 shl 16);  
MMC_RSP_R1_WP_ERASE_SKIP = (1 shl 15);  
MMC_RSP_R1_CARD_ECC_DISABLED = (1 shl 14);  
MMC_RSP_R1_ERASE_RESET = (1 shl 13);  
MMC_RSP_R1_READY_FOR_DATA = (1 shl 8);  
MMC_RSP_R1_SWITCH_ERROR = (1 shl 7);  
MMC_RSP_R1_EXCEPTION_EVENT = (1 shl 6);  
MMC_RSP_R1_APP_CMD = (1 shl 5);  
MMC_RSP_R1_AKE_SEQ_ERROR = (1 shl 3);  
 
R1 SPI - MMC/SD in SPI mode reports R1 status always, and R2 for SEND_STATUS. R1 is the low order byte, R2 is the next highest byte, when present.
MMC_RSP_R1_SPI_IDLE = (1 shl 0);  
MMC_RSP_R1_SPI_ERASE_RESET = (1 shl 1);  
MMC_RSP_R1_SPI_ILLEGAL_COMMAND = (1 shl 2);  
MMC_RSP_R1_SPI_COM_CRC = (1 shl 3);  
MMC_RSP_R1_SPI_ERASE_SEQ = (1 shl 4);  
MMC_RSP_R1_SPI_ADDRESS = (1 shl 5);  
MMC_RSP_R1_SPI_PARAMETER = (1 shl 6);  
R1 bit 7 is always zero
 
R2 SPI - See above
MMC_RSP_R2_SPI_CARD_LOCKED = (1 shl 8);  
MMC_RSP_R2_SPI_WP_ERASE_SKIP = (1 shl 9); Or lock/unlock fail
MMC_RSP_R2_SPI_LOCK_UNLOCK_FAIL = MMC_RSP_R2_SPI_WP_ERASE_SKIP;  
MMC_RSP_R2_SPI_ERROR = (1 shl 10);  
MMC_RSP_R2_SPI_CC_ERROR = (1 shl 11);  
MMC_RSP_R2_SPI_CARD_ECC_ERROR = (1 shl 12);  
MMC_RSP_R2_SPI_WP_VIOLATION = (1 shl 13);  
MMC_RSP_R2_SPI_ERASE_PARAM = (1 shl 14);  
MMC_RSP_R2_SPI_OUT_OF_RANGE = (1 shl 15); Or CSD overwrite
MMC_RSP_R2_SPI_CSD_OVERWRITE = MMC_RSP_R2_SPI_OUT_OF_RANGE;  


MMC operation condition register (OCR) value constants MMC_OCR_*
See: Section 5.1 of SD Physical Layer Simplified Specification V4.10
 
MMC_OCR_BUSY = $80000000; Busy Status - 0 = Initializing / 1 = Initialization Complete
MMC_OCR_HCS = $40000000; Card Capacity Status - 0 = SDSC / 1 = SDHC or SDXC
MMC_OCR_UHS_II = $20000000; UHS-II Card Status - 0 = Non UHS-II Card / 1 = UHS-II Card
MMC_OCR_S18A = $01000000; Switching to 1.8V Accepted - 0 = Continue current voltage signaling / 1 = Ready for switching signal voltage
MMC_OCR_VOLTAGE_MASK = $007FFF80;  
MMC_OCR_ACCESS_MODE = $60000000;  


MMC card status register (CSR) value constants MMC_CARD_STATUS_*
See: Section 4.10.1 of SD Physical Layer Simplified Specification Version 4.10
Note: These map to the Native mode R1 response values
 
MMC_CARD_STATUS_MASK = not($0206BF7F);  
MMC_CARD_STATUS_ERROR = (1 shl 19);  
MMC_CARD_STATUS_CURRENT_STATE = ($0F shl 9); See MMC_CURRENT_STATE_ definitions below
MMC_CARD_STATUS_READY_FOR_DATA = (1 shl 8);  
MMC_CARD_STATUS_SWITCH_ERROR = (1 shl 7);  


MMC current state value constants MMC_CURRENT_STATE_*
From Card Status Register or R1 Response
 
MMC_CURRENT_STATE_IDLE = (0 shl 9);  
MMC_CURRENT_STATE_READY = (1 shl 9);  
MMC_CURRENT_STATE_IDENT = (2 shl 9);  
MMC_CURRENT_STATE_STBY = (3 shl 9);  
MMC_CURRENT_STATE_TRAN = (4 shl 9);  
MMC_CURRENT_STATE_DATA = (5 shl 9);  
MMC_CURRENT_STATE_RCV = (6 shl 9);  
MMC_CURRENT_STATE_PRG = (7 shl 9);  
MMC_CURRENT_STATE_DIS = (8 shl 9);  


MMC card identification data (CID) value constants MMC_CID_*
See: Section 5.2 of SD Physical Layer Simplified Specification Version 4.10
 
MMC CID Fields
MMC_CID_MID = 1; Manufacturer ID
MMC_CID_OID = 2; OEM/Application ID
MMC_CID_PNM0 = 3; Product name (Byte 0)
MMC_CID_PNM1 = 4; Product name (Byte 1)
MMC_CID_PNM2 = 5; Product name (Byte 2)
MMC_CID_PNM3 = 6; Product name (Byte 3)
MMC_CID_PNM4 = 7; Product name (Byte 4)
MMC_CID_PNM5 = 8; Product name (Byte 5)
MMC_CID_PNM6 = 9; Product name (Byte 6)
MMC_CID_PRV = 10; Product revision
MMC_CID_HRV = 11; Hardware revision
MMC_CID_FRV = 12; Firmware revision
MMC_CID_PSN = 13; Product serial number
MMC_CID_MDT_YEAR = 14; Manufacturing year
MMC_CID_MDT_MONTH = 15; Manufacturing month
MMC_CID_CRC = 16; CRC


MMC card specific data (CSD) value constants MMC_CSD_*
See: Section 5.3 of SD Physical Layer Simplified Specification Version 4.10
 
MMC CSD Fields
MMC_CSD_STRUCTURE = 1;  
MMC_CSD_SPECVER = 2; MMC/eMMC Only
MMC_CSD_TAAC_UNIT = 3;  
MMC_CSD_TAAC_VALUE = 4;  
MMC_CSD_NSAC = 5;  
MMC_CSD_TRAN_SPEED_UNIT = 6;  
MMC_CSD_TRAN_SPEED_VALUE = 37;  
MMC_CSD_CCC = 7;  
MMC_CSD_READ_BL_LEN = 8;  
MMC_CSD_READ_BL_PARTIAL = 9;  
MMC_CSD_WRITE_BLK_MISALIGN = 10;  
MMC_CSD_READ_BLK_MISALIGN = 11;  
MMC_CSD_DSR_IMP = 12;  
MMC_CSD_C_SIZE = 13;  
MMC_CSD_VDD_R_CURR_MIN = 14;  
MMC_CSD_VDD_R_CURR_MAX = 15;  
MMC_CSD_VDD_W_CURR_MIN = 16;  
MMC_CSD_VDD_W_CURR_MAX = 17;  
MMC_CSD_C_SIZE_MULT = 18;  
MMC_CSD_ERASE_BLK_EN = 19; SD Specification
MMC_CSD_SECTOR_SIZE = 20; MMC/eMMC Specification / SD Specification
MMC_CSD_ERASE_GRP_SIZE = 21; MMC/eMMC Specification
MMC_CSD_ERASE_GRP_MULT = 22; MMC/eMMC Specification
MMC_CSD_WP_GRP_SIZE = 23;  
MMC_CSD_WP_GRP_ENABLE = 24;  
MMC_CSD_DEFAULT_ECC = 25; MMC/eMMC Only
MMC_CSD_R2W_FACTOR = 26;  
MMC_CSD_WRITE_BL_LEN = 27;  
MMC_CSD_WRITE_BL_PARTIAL = 28;  
MMC_CSD_CONTENT_PROT_APP = 29; MMC/eMMC Only
MMC_CSD_FILE_FORMAT_GRP = 30;  
MMC_CSD_COPY = 31;  
MMC_CSD_PERM_WRITE_PROTECT = 32;  
MMC_CSD_TMP_WRITE_PROTECT = 33;  
MMC_CSD_FILE_FORMAT = 34;  
MMC_CSD_ECC = 35; MMC/eMMC Only
MMC_CSD_CRC = 36;  


MMC CSD structure value constants MMC_CSD_STRUCT_*
MMC_CSD_STRUCT_VER_1_0 = 0; Valid for system specification 1.0 - 1.2
MMC_CSD_STRUCT_VER_1_? = ?; Valid for system specification 1.4 - 2.2
MMC_CSD_STRUCT_VER_1_2 = 2; Valid for system specification 3.? - 3.2 - 3.3? - 4.0 - 4.?
MMC_CSD_STRUCT_EXT_CSD = 3; Version is coded in CSD_STRUCTURE in EXT_CSD


MMC CSD spec version value constants MMC_CSD_SPEC_VER_*
MMC_CSD_SPEC_VER_0 = 0; Implements system specification 1.0 - 1.2
MMC_CSD_SPEC_VER_1 = ?; Implements system specification 1.4
MMC_CSD_SPEC_VER_2 = 2; Implements system specification 2.0 - 2.2
MMC_CSD_SPEC_VER_3 = 3; Implements system specification 3.? - 3.2 - 3.3?
MMC_CSD_SPEC_VER_4 = 4; Implements system specification 4.0 - 4.?


Type definitions


To be documented

Public variables


To be documented

Function declarations



Initialization functions

procedure MMCInit;
Description: To be documented
Note None documented


function MMCStart:LongWord;
Description: To be documented
Note None documented


function MMCStop:LongWord;
Description: To be documented
Note None documented


procedure MMCAsyncStart(SDHCI:PSDHCIHost);
Description: To be documented
Note None documented


MMC functions

function MMCDeviceReadBlocks(MMC:PMMCDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
Description: To be documented
Note None documented


function MMCDeviceWriteBlocks(MMC:PMMCDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
Description: To be documented
Note None documented


function MMCDeviceEraseBlocks(MMC:PMMCDevice; const Start,Count:Int64):LongWord;
Description: To be documented
Note None documented


function MMCDeviceGoIdle(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSetClock(MMC:PMMCDevice; Clock:LongWord):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSetBusWidth(MMC:PMMCDevice; Width:LongWord):LongWord;
Description: To be documented
Reference Section 3.4 of SD Host Controller Simplified Specification V3.0 partA2_300.pdf


function MMCDeviceSetBlockLength(MMC:PMMCDevice; Length:LongWord):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSetBlockCount(MMC:PMMCDevice; Count:LongWord; Relative:Boolean):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSetDriverStage(MMC:PMMCDevice; DriverStage:LongWord):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSelectCard(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceDeselectCard(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSwitch(MMC:PMMCDevice; Setting,Index,Value:Byte):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSendCardStatus(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSendOperationCondition(MMC:PMMCDevice; Probe:Boolean):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSendCardSpecific(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceDecodeCardSpecific(MMC:PMMCDevice):LongWord;
Description: Given a 128-bit response, decode to our card CSD structure
Note None documented


function MMCDeviceSendCardIdentification(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSendAllCardIdentification(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceDecodeCardIdentification(MMC:PMMCDevice):LongWord;
Description: Given a 128-bit response, decode to our card CID structure
Note None documented


function MMCDeviceGetExtendedCardSpecific(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSendExtendedCardSpecific(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceDecodeExtendedCardSpecific(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSetRelativeAddress(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSPISetCRC(MMC:PMMCDevice; Enable:Boolean):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSPIReadOperationCondition(MMC:PMMCDevice; HighCapacity:Boolean):LongWord;
Description: To be documented
Note None documented


function MMCDeviceInsert(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceRemove(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceInitialize(MMC:PMMCDevice):LongWord;
Description: To be documented
Reference Section 3.6 of SD Host Controller Simplified Specification V3.0 partA2_300.pdf


function MMCDeviceDeinitialize(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceGetCardDetect(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceGetWriteProtect(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSendCommand(MMC:PMMCDevice; Command:PMMCCommand):LongWord;
Description: To be documented
Note None documented


function MMCDeviceSetIOS(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function MMCDeviceCreate:PMMCDevice;
Description: Create a new MMC entry
Return Pointer to new MMC entry or nil if MMC could not be created


function MMCDeviceCreateEx(Size:LongWord):PMMCDevice;
Description: Create a new MMC entry
Size Size in bytes to allocate for new MMC (Including the MMC entry)
Return Pointer to new MMC entry or nil if MMC could not be created


function MMCDeviceDestroy(MMC:PMMCDevice):LongWord;
Description: Destroy an existing MMC entry
Note None documented


function MMCDeviceRegister(MMC:PMMCDevice):LongWord;
Description: Register a new MMC in the MMC table
Note None documented


function MMCDeviceDeregister(MMC:PMMCDevice):LongWord;
Description: Deregister a MMC ?rom the MMC table
Note None documented


function MMCDeviceFind(MMCId:LongWord):PMMCDevice;
Description: To be documented
Note None documented


function MMCDeviceFindByName(const Name:String):PMMCDevice; inline;
Description: To be documented
Note None documented


function MMCDeviceFindByDescription(const Description:String):PMMCDevice; inline;
Description: To be documented
Note None documented


function MMCDeviceEnumerate(Callback:TMMCEnumerate; Data:Pointer):LongWord;
Description: To be documented
Note None documented


function MMCDeviceNotification(MMC:PMMCDevice; Callback:TMMCNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented
Note None documented


SD functions

function SDDeviceSwitch(MMC:PMMCDevice; Mode,Group:Integer; Value:Byte; Buffer:Pointer):LongWord;
Description: To be documented
Buffer Buffer must point to a 64 byte buffer for Switch Status information
Note See 4.3.10 of SD Physical Layer Simplified Specification V4.10


function SDDeviceSwitchHighspeed(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceSetBusSpeed(MMC:PMMCDevice; Speed:LongWord):LongWord;
Description: To be documented
Note None documented


function SDDeviceSetBusWidth(MMC:PMMCDevice; Width:LongWord):LongWord;
Description: To be documented
Note See Table 4-30 in Section 4.7.4 of SD Physical Layer Simplified Specification V4.10


function SDDeviceSendInterfaceCondition(MMC:PMMCDevice):LongWord;
Description: To be documented
Note See 4.3.13 of SD Physical Layer Simplified Specification V4.10. CMD8 (SEND_IF_COND) must be invoked to support SD 2.0 cards. The card must be in Idle State before issuing this command. This command will fail harmlessly for SD 1.0 cards.


function SDDeviceSendOperationCondition(MMC:PMMCDevice; Probe:Boolean):LongWord;
Description: To be documented
Note See 4.2.3.1 of SD Physical Layer Simplified Specification V4.10


function SDDeviceGetCardSpecific(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceDecodeCardSpecific(MMC:PMMCDevice):LongWord;
Description: Given a 128-bit response, decode to our card CSD structure
Note None documented


function SDDeviceGetCardIdentification(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceDecodeCardIdentification(MMC:PMMCDevice):LongWord;
Description: Given a 128-bit response, decode to our card CID structure
Note None documented


function SDDeviceSendSDStatus(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceDecodeSDStatus(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceSendSDSwitch(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceDecodeSDSwitch(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceSendSDConfiguration(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceDecodeSDConfiguration(MMC:PMMCDevice):LongWord;
Description: Given a 64-bit response, decode to our card SCR structure
Note None documented


function SDDeviceSendRelativeAddress(MMC:PMMCDevice):LongWord;
Description: To be documented
Note None documented


function SDDeviceSendApplicationCommand(MMC:PMMCDevice; Command:PMMCCommand):LongWord;
Description: To be documented
Note None documented


SDIO functions

function SDIODeviceReset(MMC:PMMCDevice):LongWord;
Description: To be documented
Note See SDIO Simplified Specification V2.0, 4.4 Reset for SDIO


function SDIODeviceSendOperationCondition(MMC:PMMCDevice; Probe:Boolean):LongWord;
Description: To be documented
Note None documented


function SDIODeviceReadWriteDirect(MMC:PMMCDevice; Write:Boolean; Operation,Address:LongWord; Input:Byte; Output:PByte):LongWord;
Description: To be documented
Note None documented


function SDIODeviceReadWriteExtended(MMC:PMMCDevice; Write:Boolean; Operation,Address:LongWord; Increment:Boolean; Buffer:Pointer; BlockCount,BlockSize:LongWord):LongWord;
Description: To be documented
Note None documented


SDHCI functions

function SDHCIHostReset(SDHCI:PSDHCIHost; Mask:Byte):LongWord;
Description: To be documented
Reference Section 3.3 of SD Host Controller Simplified Specification V3.0 partA2_300.pdf


function SDHCIHostSetPower(SDHCI:PSDHCIHost; Power:Word):LongWord;
Description: To be documented
Reference Section 3.3 of SD Host Controller Simplified Specification V3.0 partA2_300.pdf


function SDHCIHostSetClock(SDHCI:PSDHCIHost; Clock:LongWord):LongWord;
Description: To be documented
Reference Section 3.2 of SD Host Controller Simplified Specification V3.0 partA2_300.pdf


function SDHCIHostTransferPIO(SDHCI:PSDHCIHost):LongWord;
Description: To be documented
Note None documented


function SDHCIHostTransferDMA(SDHCI:PSDHCIHost):LongWord;
Description: To be documented
Note None documented


function SDHCIHostFinishCommand(SDHCI:PSDHCIHost):LongWord;
Description: Called by Interrupt Command handler when an SDHCI_INT_RESPONSE is received
Note None documented


function SDHCIHostFinishData(SDHCI:PSDHCIHost):LongWord;
Description: Called by Interrupt Data handler when data is received
Note None documented


function SDHCIHostCommandInterrupt(SDHCI:PSDHCIHost; InterruptMask:LongWord; var ReturnMask:LongWord):LongWord;
Description: To be documented
Note None documented


function SDHCIHostDataInterrupt(SDHCI:PSDHCIHost; InterruptMask:LongWord):LongWord;
Description: To be documented
Note None documented


function SDHCIHostStart(SDHCI:PSDHCIHost):LongWord;
Description: To be documented
Note None documented


function SDHCIHostStop(SDHCI:PSDHCIHost):LongWord;
Description: To be documented
Note None documented


function SDHCIHostReadByte(SDHCI:PSDHCIHost; Reg:LongWord):Byte; inline;
Description: To be documented
Note None documented


function SDHCIHostReadWord(SDHCI:PSDHCIHost; Reg:LongWord):Word; inline;
Description: To be documented
Note None documented


function SDHCIHostReadLong(SDHCI:PSDHCIHost; Reg:LongWord):LongWord; inline;
Description: To be documented
Note None documented


procedure SDHCIHostWriteByte(SDHCI:PSDHCIHost; Reg:LongWord; Value:Byte); inline;
Description: To be documented
Note None documented


procedure SDHCIHostWriteWord(SDHCI:PSDHCIHost; Reg:LongWord; Value:Word); inline;
Description: To be documented
Note None documented


procedure SDHCIHostWriteLong(SDHCI:PSDHCIHost; Reg:LongWord; Value:LongWord); inline;
Description: To be documented
Note None documented


function SDHCIHostSetClockDivider(SDHCI:PSDHCIHost; Index:Integer; Divider:LongWord):LongWord;
Description: To be documented
Note None documented


function SDHCIHostSetControlRegister(SDHCI:PSDHCIHost):LongWord;
Description: To be documented
Note None documented


function SDHCIHostCreate:PSDHCIHost;
Description: Create a new SDHCI entry
Return Pointer to new SDHCI entry or nil if SDHCI could not be created


function SDHCIHostCreateEx(Size:LongWord):PSDHCIHost;
Description: Create a new SDHCI entry
Size Size in bytes to allocate for new SDHCI (Including the SDHCI entry)
Return Pointer to new SDHCI entry or nil if SDHCI could not be created


function SDHCIHostDestroy(SDHCI:PSDHCIHost):LongWord;
Description: Destroy an existing SDHCI entry
Note None documented


function SDHCIHostRegister(SDHCI:PSDHCIHost):LongWord;
Description: Register a new SDHCI in the SDHCI table
Note None documented


function SDHCIHostDeregister(SDHCI:PSDHCIHost):LongWord;
Description: Deregister a SDHCI ?rom the SDHCI table
Note None documented


function SDHCIHostFind(SDHCIId:LongWord):PSDHCIHost;
Description: To be documented
Note None documented


function SDHCIHostEnumerate(Callback:TSDHCIEnumerate; Data:Pointer):LongWord;
Description: To be documented
Note None documented


function SDHCIHostNotification(SDHCI:PSDHCIHost; Callback:TSDHCINotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented
Note None documented


MMC helper functions

function MMCGetCount:LongWord; inline;
Description: Get the current MMC count
Note None documented


function MMCDeviceCheck(MMC:PMMCDevice):PMMCDevice;
Description: Check if the supplied MMC is in the MMC table
Note None documented


function MMCIsSD(MMC:PMMCDevice):Boolean;
Description: To be documented
Note None documented


function MMCGetCIDValue(MMC:PMMCDevice; Version,Value:LongWord):LongWord;
Description: Extract a CID field value ?rom the 128 bit Card Identification register
Note None documented


function MMCGetCSDValue(MMC:PMMCDevice; Value:LongWord):LongWord;
Description: Extract a CSD field value ?rom the 128 bit Card Specific register
Note None documented


function MMCGetExtendedCSDValue(MMC:PMMCDevice; Value:LongWord):LongWord;
Description: Extract an Extended CSD field value ?rom the 512 byte Extended Card Specific register
Note None documented


function MMCExtractBits(Buffer:Pointer; Start,Size:LongWord):LongWord;
Description: To be documented
Start Start is the starting bit to extract
Size Size is the number of bits to extract
Note Start is the LSB so to extract 8 bits ?rom 127 to 120 then Start would be 120 and Size would be 8


function MMCExtractBitsEx(Buffer:Pointer; Length,Start,Size:LongWord):LongWord;
Description: To be documented
Length Length is the size of the buffer in LongWords
Start Start is the starting bit to extract
Size Size is the number of bits to extract
Note Start is the LSB so to extract 8 bits ?rom 127 to 120 then Start would be 120 and Size would be 8. For a 128 bit buffer (16 bytes) Length would be 4. For a 512 bit buffer (64 bytes) Length would be 16.


function MMCIsMultiCommand(Command:Word):Boolean;
Description: To be documented
Note None documented


function MMCStatusToString(Status:LongWord):String;
Description: Translates an MMC status code into a string describing it
Note None documented


function MMCDeviceTypeToString(MMCType:LongWord):String;
Description: To be documented
Note None documented


function MMCDeviceStateToString(MMCState:LongWord):String;
Description: To be documented
Note None documented


procedure MMCLog(Level:LongWord; MMC:PMMCDevice; const AText:String);
Description: To be documented
Note None documented


procedure MMCLogInfo(MMC:PMMCDevice; const AText:String);
Description: To be documented
Note None documented


procedure MMCLogError(MMC:PMMCDevice; const AText:String);
Description: To be documented
Note None documented


procedure MMCLogDebug(MMC:PMMCDevice; const AText:String);
Description: To be documented
Note None documented


SD helper functions

function SDGetMaxClock(MMC:PMMCDevice):LongWord;
Description: Determine the Maximum Clock (DTR) for the current card
Note None documented


function SDGetCIDValue(MMC:PMMCDevice; Value:LongWord):LongWord;
Description: Extract a CID field value ?rom the 128 bit Card Identification register
Note None documented


function SDGetCSDValue(MMC:PMMCDevice; Version,Value:LongWord):LongWord;
Description: Extract a CSD field value ?rom the 128 bit Card Specific register
Note None documented


function SDGetSCRValue(MMC:PMMCDevice; Value:LongWord):LongWord;
Description: Extract an SCR field value ?rom the 64 bit SD Configuration register
Note None documented


function SDGetSSRValue(MMC:PMMCDevice; Value:LongWord):LongWord;
Description: Extract an SCR field value ?rom the 512 bit SD Status register
Note None documented


function SDGetSwitchValue(MMC:PMMCDevice; Value:LongWord):LongWord;
Description: Extract a Switch field value ?rom the 512 bit SD Switch status
Note None documented


SDHCI helper functions

function SDHCIGetCount:LongWord; inline;
Description: Get the current SDHCI count
Note None documented


function SDHCIHostCheck(SDHCI:PSDHCIHost):PSDHCIHost;
Description: Check if the supplied SDHCI is in the SDHCI table
Note None documented


function SDHCIIsSPI(SDHCI:PSDHCIHost):Boolean;
Description: To be documented
Note None documented


function SDHCIGetVersion(SDHCI:PSDHCIHost):Word;
Description: To be documented
Note None documented


function SDHCIGetCommand(Command:Word):Word;
Description: To be documented
Note None documented


function SDHCIMakeCommand(Command,Flags:Word):Word;
Description: To be documented
Note None documented


function SDHCIMakeBlockSize(DMA,BlockSize:Word):Word;
Description: To be documented
Note None documented


function SDHCIDeviceTypeToString(SDHCIType:LongWord):String;
Description: To be documented
Note None documented


function SDHCIDeviceStateToString(SDHCIState:LongWord):String;
Description: To be documented
Note None documented


MMC storage functions

function MMCStorageDeviceRead(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
Description: To be documented
Note None documented


function MMCStorageDeviceWrite(Storage:PStorageDevice; const Start,Count:Int64; Buffer:Pointer):LongWord;
Description: To be documented
Note None documented


function MMCStorageDeviceErase(Storage:PStorageDevice; const Start,Count:Int64):LongWord;
Description: To be documented
Note None documented


function MMCStorageDeviceControl(Storage:PStorageDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
Description: To be documented
Note None documented


Return to Unit Reference