This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM437x MMC GEL file questions

Team,

Can someone help with AM437x SDMMC?  Customer is trying to verify SDMMC interface using GEL file (excerpt below).  They are not getting successful read when running CMD19/CMD14.

============================================

** cannot successfully send CMD14:

All we wondered is about clarification on how to use that SD_DATA register, which isn't self-explanatory to me. In addition, I couldn't successfully send CMD14 (test read) after issuing CMD19 (test write). It seems I couldn't write to DDIR bit of SD_CMD register while Buffer Write Enable bit of SD_PASTATE[10] is set.

============================================

** how to use SD_DATA register 'mbyteen[] ...'

an expert on MMC controller as I just need some clarification of how to use (read/write) the SD_DATA register as I couldn't fully understand the wording in TRM.

====================================================================

hotmenu eMMC_Bus_Initialization()
{
UWORD32 i;

// /* Set MMC clock freq to 100KHz (might need a different frequency though) */
// WR_MEM_32(MMC1_SYSCTL, RD_MEM_32(MMC1_SYSCTL) | 0xF000); // ref clk = 96Mhz; divider = 600 = 0x258 (then right shift by two)

/* send CMD1 and check commmand complete (CC) bit in SD_STAT */
do
{
MMC_CMD_SEND(1, 0xC0FF8080, RSP_R3);
/* wait 1 ms */
// for (i = 0; i < 100; i= i + 1) {} // It seems the while loop by itself takes 80ms to resend CMD1
} while (RD_MEM_32(MMC1_RSP10) != 0xC0FF8080); // SD_STAT[0] Command Complete bit doesn't seem to work so we check OCR in RSP10 instead.

// GEL_TextOut("CMD1 command sent successfully. Sending CMD2...\n");

/* send CMD2 for CID (R2 response)*/
MMC_CMD_SEND(2,0,RSP_R2); // CID request

/* poll command complete (CC) bit of STAT register */
// while(RD_MEM_32(MMC1_STAT) & 0x1 != 0x1);

if (RD_MEM_32(MMC1_RSP76) >> 16 == 0x7001)
{
GEL_TextOut("Identified: Kingston eMMC BGA Package.\n");
}
else if (RD_MEM_32(MMC1_RSP76) >> 16 == 0x1101)
{
GEL_TextOut("Identified: Toshiba eMMC BGA Package.\n");
}
else if (RD_MEM_32(MMC1_RSP76) >> 16 == 0xFE01)
{
GEL_TextOut("Identified: Micron eMMC BGA Package.\n");
}
else
{
GEL_TextOut("Unknown eMMC device.\n");
}

/* send CMD3 to assign RCA (0x1) */
MMC_CMD_SEND(3,0x10000,RSP_R1); //

/* send CMD9 to ask for Device Specific Data (CSD) */
MMC_CMD_SEND(9, 0x10000, RSP_R2); // R2 response

/* CMD7 select card to enter transfer mode */
MMC_CMD_SEND(7, 0x10000, RSP_R1);

/* CMD8 read EXT_CSD register */
// WR_MEM_32(MMC1_BLK, 0x200); // set block length of 512 bytes (single block)
// MMC_CMD_SEND(8, 0, RSP_R1); // argument = 0, response type = R1, DataPresent=1
// while (RD_MEM_32(MMC1_PSTATE) & 0x800 != 0x800)

/* CMD6 to modify bus width of eMMC to 8 bit*/
MMC_CMD_SEND(6, ((3<<24) | (183<<16) | (2<<8)), RSP_R1B);

/* set DW8 of SD_CON to enable 8 bit mode for host */
WR_MEM_32(MMC1_CON, RD_MEM_32(MMC1_CON) | 0x20);

/* send CMD19 to test write data patern on 8 bit bus */
MMC_CMD_SEND(19, 0, RSP_R1);
while((RD_MEM_32(MMC1_PSTATE) >> 10) & 0x1 == 0);
MMC_CMD_SEND(MMC1_DATA, 0x0000);
while((RD_MEM_32(MMC1_PSTATE) >> 10) & 0x1 == 0);
MMC_CMD_SEND(MMC1_DATA, 0x0000);
while((RD_MEM_32(MMC1_PSTATE) >> 10) & 0x1 == 0);
MMC_CMD_SEND(MMC1_DATA, 0x0000);
while((RD_MEM_32(MMC1_PSTATE) >> 10) & 0x1 == 0);
MMC_CMD_SEND(MMC1_DATA, 0xAA55);

/* send CMD14 to test read data pattern from the eMMC device */
MMC_CMD_SEND(14, 0, RSP_R1);


// GEL_TextOut("Module runs SDIO interface.\n");

}