作者
QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118
参考
特性
- Conforms to the SD Host controller standard specification version 3.0, including test
event register support - Compatible with the MMC system specification version 4.5
- Compatible with the SD memory card specification version 3.01, and supports the
high capacity SD memory card - Compatible with the SDIO card specification version 3.0
- Designed to work with SD memory, SDIO, SD combo, MMC, and their variants,
such as mini and micro. - Card bus clock frequency up to 52 MHz
- MMCHC (MMC high capacity) support
- Supports 1- or 4-bit SD and SDIO modes, 1- or 4- or 8-bit MMC modes
- Supports single-block and multi-block read, and write data transfer
- Supports block sizes of 1-2048 bytes
- Supports the mechanical write protect detection. In the case where write protect is
enabled, the host will not initiate any write data command to the card - Supports card detection from SDHC_CD_B
- Supports both synchronous and asynchronous abort
- Supports pause during the data transfer at block gap
- Supports SDIO read wait and suspend resume operations
- Supports Auto CMD12 and Auto CMD23 for multi-block transfer
- Host can initiate command that does not use data lines, while data transfer is in
progress - Allows card to interrupt the host in 1 bit and 4 bit SDIO modes, also supports
interrupt period - Embodies a configurable 128 x 32 bit FIFO for read/write data
- Supports SDMA, ADMA1, and ADMA2 capabilities
- Supports external SD bus voltage selection by register configuration
- Host will send 80 idle SD clock cycles to card, which are needed during card power-
up, if bit INITA in the system control register (SYSCTL) is set - Supports SDIO asynchronous interrupt
- Supports clock divider with finer granularity, that is, with values 1,2,3…1024 or
1,2,4,8…2048 - Supports standard, high and extended capacity card types
- Supports SD UHS-1 speed modes: SDR12, SDR25, DDR50
- Supports MMC high speed and DDR mode
代码
//common\board_r.c
initr_mmc
//drivers\mmc\mmc.c
mmc_initialize
mmc_probe
//arch\powerpc\cpu\mpc85xx\cpu.c line373
cpu_mmc_init
//drivers\mmc\fsl_esdhc.c line864
fsl_esdhc_mmc_init
fsl_esdhc_initialize
fsl_esdhc_cfg_to_priv
fsl_esdhc_init
priv->cfg.ops = &esdhc_ops;
esdhc_ops
定义如下,
static const struct mmc_ops esdhc_ops = {
.send_cmd = esdhc_send_cmd,
.set_ios = esdhc_set_ios,
.init = esdhc_init,
.getcd = esdhc_getcd,
};
执行mmc info
,调用,
//cmd\mmc.c
mmc_init
mmc_start_init
EMMC无法识别
T2080> mmc info
CMD_SEND:0
ARG 0x00000000
MMC_RSP_NONE
CMD_SEND:8
ARG 0x000001AA
RET -110
CMD_SEND:55
ARG 0x00000000
RET -110
CMD_SEND:0
ARG 0x00000000
MMC_RSP_NONE
CMD_SEND:1
ARG 0x00000000
RET -70
Card did not respond to voltage select!
-110
代表超时了,怀疑硬件问题,参考EMMC协议,依次发送命令为,
CMD0[GO_IDLE_STATE]
CMD8/* Test for SD version 2 */
CMD55/* Now try to get the SD card's operating condition */
SD卡未检测到则检测是否有EMMC/* If the command timed out, we check for an MMC card */
CMD0[GO_IDLE_STATE]
CMD1[SEND_OP_COND] #通过busy位(bit31)来判断card的上电复位过程是否完成
正确打印,
zynq-uboot> mmc info
CMD_SEND:0
ARG 0x00000000
MMC_RSP_NONE
CMD_SEND:8
ARG 0x000001AA
MMC_RSP_R1,5,6,7 0x3FF251B0
CMD_SEND:55
ARG 0x00000000
MMC_RSP_R1,5,6,7 0x3FF251B0
CMD_SEND:0
ARG 0x00000000
MMC_RSP_NONE
CMD_SEND:1
ARG 0x00000000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x00FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0x40FF8080
CMD_SEND:1
ARG 0x40300000
MMC_RSP_R3,4 0xC0FF8080
CMD_SEND:2
ARG 0x00000000
MMC_RSP_R2 0x45010044
0x47343030
0x3801A318
0x250D4600
DUMPING DATA
000 - 45 01 00 44
004 - 47 34 30 30
008 - 38 01 A3 18
012 - 25 0D 46 00
CMD_SEND:3
ARG 0x00010000
MMC_RSP_R1,5,6,7 0x00000500
CMD_SEND:9
ARG 0x00010000
MMC_RSP_R2 0xD00F0032
0x8F5903FF
0xFFFFFFEF
0x8A404000
DUMPING DATA
000 - D0 0F 00 32
004 - 8F 59 03 FF
008 - FF FF FF EF
012 - 8A 40 40 00
CMD_SEND:13
ARG 0x00010000
MMC_RSP_R1,5,6,7 0x00000700
CURR STATE:3
CMD_SEND:7
ARG 0x00010000
MMC_RSP_R1,5,6,7 0x00000700
CMD_SEND:8
ARG 0x00000000
MMC_RSP_R1,5,6,7 0x00000900
CMD_SEND:8
ARG 0x00000000
MMC_RSP_R1,5,6,7 0x00000900
CMD_SEND:6
ARG 0x03B90100
MMC_RSP_R1b 0x00000900
CMD_SEND:13
ARG 0x00010000
MMC_RSP_R1,5,6,7 0x00000900
CURR STATE:4
CMD_SEND:8
ARG 0x00000000
MMC_RSP_R1,5,6,7 0x00000900
CMD_SEND:6
ARG 0x03B70100
MMC_RSP_R1b 0x00000800
CMD_SEND:13
ARG 0x00010000
MMC_RSP_R1,5,6,7 0x00000900
CURR STATE:4
CMD_SEND:8
ARG 0x00000000
MMC_RSP_R1,5,6,7 0x00000900
CMD_SEND:16
ARG 0x00000200
MMC_RSP_R1,5,6,7 0x00000900
CMD_SEND:17
ARG 0x00000000
MMC_RSP_R1,5,6,7 0x00000900
Device: zynq_sdhci
Manufacturer ID: 45
OEM: 100
Name: DG400
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.0
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB