mt2735 5G模块外挂海力士 8G EMMC,启动提示读取数据失败进行分析。
EMMC驱动时钟初始化打印:
[ 3.977929] <1>.(1)[1:swapper/0]mtk-msdc 11230000.mmc: Linked as a consumer to regulator.27
[ 3.979343] <1>.(1)[1:swapper/0]mmc0: CQHCI version 5.10
[ 3.981926] <1>.(1)[1:swapper/0]mtk-msdc 11230000.mmc: init hardware done!
[ 3.984383] <1>.(1)[1:swapper/0]mtk-msdc 11230000.mmc: init hardware done!
[ 3.996084] <1>.(1)[1:swapper/0]mtk-msdc 11230000.mmc: host->mclk:0, ios->clock:400000, host->timing:0,ios->timing:0
[ 3.997531] <2>.(2)[1:swapper/0]mtk-msdc 11230000.mmc: sclk: 399999, timing: 0, hz: 400000
[ 4.015348] <2>.(2)[1:swapper/0]mtk-msdc 11240000.mmc: Got CD GPIO
[ 4.017036] <2>.(2)[1:swapper/0]mtk-msdc 11240000.mmc: Linked as a consumer to regulator.33
[ 4.020145] <2>.(2)[1:swapper/0]mtk-msdc 11240000.mmc: init hardware done!
[ 4.035223] <2>.(2)[1:swapper/0]mtk-msdc 11240000.mmc: host->mclk:0, ios->clock:400000, host->timing:0,ios->timing:0
[ 4.036795] <2>.(2)[1:swapper/0]mtk-msdc 11240000.mmc: sclk: 399999, timing: 0, hz: 400000
[ 4.051228] <2>.(2)[2170:kworker/2:2]mtk-msdc 11240000.mmc: host->mclk:400000, ios->clock:0, host->timing:0,ios->timing:0
[ 4.052635] <2>.(2)[2170:kworker/2:2]mtk-msdc 11240000.mmc: set mclk to 0
[ 4.104750] <2>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: host->mclk:400000, ios->clock:400000, host->timing:0,ios->timing:9
[ 4.106295] <2>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: sclk: 399999, timing: 9, hz: 400000
[ 4.107746] <2>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: host->mclk:400000, ios->clock:200000000, host->timing:9,ios->timing:9
[ 4.109256] <2>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: sclk: 191999939, timing: 9, hz: 200000000
HS200和HS400模式探测打印: HS200和HS400模式都探测成功了。drivers/mmc/host/mediatek/autok.c
[ 4.077168] <0>.(0)[14:kworker/0:1][AUTOK]eMMC HS200 Tune
[ 4.084195] <2>.(0)[14:kworker/0:1][AUTOK]CMD 0 44 OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOOOOO
[ 4.088048] <0>.(0)[14:kworker/0:1][AUTOK]CMD 1 56 OOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
[ 4.094483] <0>.(0)[14:kworker/0:1][AUTOK]Analysis Result: 1T = 74
[ 4.099475] <0>.(0)[14:kworker/0:1][AUTOK]dev status 0x00000900
[ 4.113842] <2>.(0)[14:kworker/0:1][AUTOK]DAT 0 39 OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXXXXXXXXOOOOOOOOOOOOOOOOO
[ 4.123932] <0>.(0)[14:kworker/0:1][AUTOK]DAT 1 55 OOXXXXXXXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
[ 4.125058] <0>.(0)[14:kworker/0:1][AUTOK]Analysis Result: 1T = 74
[ 4.129413] <2>.(0)[14:kworker/0:1][AUTOK]CMD [EDGE:0 CMD_FIFO_EDGE:0 DLY1:7 DLY2:0]
[ 4.139421] <2>.(0)[14:kworker/0:1][AUTOK]DAT [RDAT_EDGE:0 RD_FIFO_EDGE:0 WD_FIFO_EDGE:0]
[ 4.145125] <2>.(0)[14:kworker/0:1][AUTOK]DAT [LATCH_CK:0 DLY1:5 DLY2:0]
[ 4.148244] <2>.(0)[14:kworker/0:1][AUTOK]DS [DLY1:0 DLY2:0 DLY3:0]
[ 4.151185] <2>.(0)[14:kworker/0:1][AUTOK]CLK TX [0]
[ 4.154158] <2>.(0)[14:kworker/0:1][AUTOK]CMD TX [0]
[ 4.154171] <2>.(0)[14:kworker/0:1][AUTOK]DAT TX [D0:0 D1:0 D2:0 D3:0]
[ 4.157110] <2>.(0)[14:kworker/0:1][AUTOK]DAT TX [D4:0 D5:0 D6:0 D7:0]
[ 4.160055] <0>.(0)[14:kworker/0:1][AUTOK][HS200]======Cost:82 ms======
[ 4.187290] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: host->mclk:200000000, ios->clock:200000000, host->timing:9,ios->timing:1
[ 4.188971] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: sclk: 191999939, timing: 1, hz: 200000000
[ 4.193035] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: host->mclk:200000000, ios->clock:52000000, host->timing:1,ios->timing:1
[ 4.194632] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: sclk: 47999984, timing: 1, hz: 52000000
[ 4.198355] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: host->mclk:52000000, ios->clock:52000000, host->timing:1,ios->timing:10
[ 4.200224] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: sclk: 47999984, timing: 10, hz: 52000000
[ 4.203163] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: host->mclk:52000000, ios->clock:200000000, host->timing:10,ios->timing:10
[ 4.205782] <3>.(2)[74:kworker/2:1]mtk-msdc 11230000.mmc: sclk: 191999939, timing: 10, hz: 200000000
[ 4.182371] <2>.(0)[14:kworker/0:1][AUTOK]eMMC HS400 Tune
[ 4.191612] <2>.(0)[14:kworker/0:1][AUTOK]CMD 0 44 OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXXOOOOOOOOOOOOOOOOOO
[ 4.196469] <2>.(0)[14:kworker/0:1][AUTOK]CMD 1 57 OOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
[ 4.200044] <2>.(0)[14:kworker/0:1][AUTOK]Analysis Result: 1T = 76
[ 4.202067] <2>.(0)[14:kworker/0:1][AUTOK]device status 0x00000900
[ 9.431232] <0>.(0)[14:kworker/0:1][AUTOK]DLY1/2 0 0 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[ 9.432691] <0>.(0)[14:kworker/0:1][AUTOK]CMD [EDGE:0 CMD_FIFO_EDGE:0 DLY1:6 DLY2:0]
[ 9.433721] <0>.(0)[14:kworker/0:1][AUTOK]DAT [RDAT_EDGE:0 RD_FIFO_EDGE:0 WD_FIFO_EDGE:0]
[ 9.434782] <0>.(0)[14:kworker/0:1][AUTOK]DAT [LATCH_CK:0 DLY1:0 DLY2:0]
[ 9.435656] <0>.(0)[14:kworker/0:1][AUTOK]DS [DLY1:0 DLY2:0 DLY3:20]
[ 9.436497] <0>.(0)[14:kworker/0:1][AUTOK]CLK TX [0]
[ 9.437161] <0>.(0)[14:kworker/0:1][AUTOK]CMD TX [0]
[ 9.437826] <0>.(0)[14:kworker/0:1][AUTOK]DAT TX [D0:0 D1:0 D2:0 D3:0]
[ 9.438688] <0>.(0)[14:kworker/0:1][AUTOK]DAT TX [D4:0 D5:0 D6:0 D7:0]
[ 9.439571] <0>.(0)[14:kworker/0:1][AUTOK][HS400]======Cost:5251 ms======
识别EMMC成功,海力士8G容量,但在后面读取分区数据信息报数据错误dat_err =-110,开始复位恢复:
[ 9.463002] <2>.(2)[74:kworker/2:1]mmc0: Command Queue Engine enabled
[ 9.463855] <2>.(2)[74:kworker/2:1]mmc0: new HS400 MMC card at address 0001
[ 9.468233] <2>.(2)[74:kworker/2:1]mmcblk0: mmc0:0001 H8G4a2 7.28 GiB
[ 9.468233] <2>.(2)[74:kworker/2:1]mmcblk0: mmc0:0001 H8G4a2 7.28 GiB
[ 9.470576] <2>.(2)[74:kworker/2:1]mmcblk0boot0: mmc0:0001 H8G4a2 partition 1 4.00 MiB
[ 9.470576] <2>.(2)[74:kworker/2:1]mmcblk0boot0: mmc0:0001 H8G4a2 partition 1 4.00 MiB
[ 9.473075] <2>.(2)[74:kworker/2:1]mmcblk0boot1: mmc0:0001 H8G4a2 partition 2 4.00 MiB
[ 9.473075] <2>.(2)[74:kworker/2:1]mmcblk0boot1: mmc0:0001 H8G4a2 partition 2 4.00 MiB
[ 9.474489] <2>.(2)[74:kworker/2:1]mmcblk0rpmb: mmc0:0001 H8G4a2 partition 3 4.00 MiB, chardev (234:0)
[ 9.474489] <2>.(2)[74:kworker/2:1]mmcblk0rpmb: mmc0:0001 H8G4a2 partition 3 4.00 MiB, chardev (234:0)
[ 10.176763] <0>-(0)[0:swapper/0]mtk-msdc 11230000.mmc: msdc_cmdq_irq: DATA TIMEOUT ERR
[ 10.177837] <0>-(0)[0:swapper/0]mtk-msdc 11230000.mmc: cmd_err = 0, dat_err =-110, intsts = 0x10004108
[ 10.179160] <0>.(0)[14:kworker/0:1]mmc0: running CQE recovery
打印“mmc0: cqhci: timeout for tag 10”错误提示和寄存器信息,这里超时时间60秒:#define MMC_ERASE_TIMEOUT_MS (60 * 1000) /* 60 s */
[ 74.716094] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: timeout for tag 10
[ 74.716989] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
[ 74.718161] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Caps: 0x000020b6 | Version: 0x00000510
[ 74.719331] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Config: 0x00001101 | Control: 0x00000000
[ 74.720500] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Int stat: 0x00000000 | Int enab: 0x00000006
[ 74.721670] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Int sig: 0x00000006 | Int Coal: 0x00000000
[ 74.722838] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: TDL base: 0x7f047000 | TDL up32: 0x00000000
[ 74.724006] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Doorbell: 0x00000400 | TCN: 0x00000000
[ 74.725174] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000400
[ 74.726433] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Task clr: 0x00000000 | SSC1: 0x00001000
[ 74.727606] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: SSC2: 0x00000001 | DCMD rsp: 0x00000000
[ 74.728775] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x00000000
[ 74.729943] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Resp idx: 0x0000000d | Resp arg: 0x00000000
[ 74.731108] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: : ===========================================
[ 74.732379] <2>.(2)[2417:kworker/2:3]mmc0: running CQE recovery
最后报“print_req_error: I/O error, dev mmcblk0, sector 0”数据读取失败:
[ 136.157599] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: timeout for tag 10
[ 136.164661] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
[ 136.165832] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Caps: 0x000020b6 | Version: 0x00000510
[ 136.167153] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Config: 0x00001101 | Control: 0x00000000
[ 136.168326] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Int stat: 0x00000000 | Int enab: 0x00000006
[ 136.169495] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Int sig: 0x00000006 | Int Coal: 0x00000000
[ 136.170665] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: TDL base: 0x7f047000 | TDL up32: 0x00000000
[ 136.171834] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Doorbell: 0x00000400 | TCN: 0x00000000
[ 136.173003] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000400
[ 136.174172] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Task clr: 0x00000000 | SSC1: 0x00001000
[ 136.175340] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: SSC2: 0x00000001 | DCMD rsp: 0x00000000
[ 136.176616] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x00000000
[ 136.177788] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: Resp idx: 0x0000000d | Resp arg: 0x00000000
[ 136.178955] <2>.(2)[2230:kworker/2:1H]mmc0: cqhci: : ===========================================
[ 136.180252] <2>.(2)[2417:kworker/2:3]mmc0: running CQE recovery
[ 136.181927] <2>.(2)[2417:kworker/2:3]print_req_error: I/O error, dev mmcblk0, sector 0
[ 136.183029] <2>.(2)[2417:kworker/2:3]Buffer I/O error on dev mmcblk0, logical block 0, async page read
[ 136.891855] <0>-(0)[0:swapper/0]mtk-msdc 11230000.mmc: msdc_cmdq_irq: DATA TIMEOUT ERR
[ 136.892967] <0>-(0)[0:swapper/0]mtk-msdc 11230000.mmc: cmd_err = 0, dat_err =-110, intsts = 0x10004108
[ 136.894396] <0>.(0)[2416:kworker/0:2]mmc0: running CQE recovery
[ 330.716949] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: timeout for tag 12
[ 330.724006] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: ============ CQHCI REGISTER DUMP ===========
[ 330.725177] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Caps: 0x000020b6 | Version: 0x00000510
[ 330.726430] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Config: 0x00001101 | Control: 0x00000000
[ 330.727606] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Int stat: 0x00000000 | Int enab: 0x00000006
[ 330.728776] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Int sig: 0x00000006 | Int Coal: 0x00000000
[ 330.729945] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: TDL base: 0x7f047000 | TDL up32: 0x00000000
[ 330.731114] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Doorbell: 0x00001000 | TCN: 0x00000000
[ 330.732282] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00001000
[ 330.733450] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Task clr: 0x00000000 | SSC1: 0x00001000
[ 330.734619] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: SSC2: 0x00000001 | DCMD rsp: 0x00000000
[ 330.735785] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x00000000
[ 330.737229] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: Resp idx: 0x0000000d | Resp arg: 0x00000000
[ 330.738408] <3>.(3)[2450:kworker/3:1H]mmc0: cqhci: : ===========================================
[ 330.739688] <3>.(3)[4193:kworker/3:5]mmc0: running CQE recovery
严重影响了开机速度和时间,查看emmc启动后模式:
root@auto2735evb-ivt-main:~# cat /sys/kernel/debug/mmc0/ios
clock: 200000000 Hz
actual clock: 191999939 Hz
vdd: 18 (3.0 ~ 3.1 V)
bus mode: 2 (push-pull)
chip select: 0 (don't care)
power mode: 2 (on)
bus width: 3 (8 bits)
timing spec: 10 (mmc HS400)
signal voltage: 1 (1.80 V)
driver type: 0 (driver type B)
检查电路图设计,检查硬件元器件焊接都没有问题,分析EMMC数据手册,5.1版本的EMMC需要接Data Strobe pin引脚来支持HS400模式,而4.5的版本是不需要接这个引脚所以最高只支持到HS200模式;Vcc是器件的电源接3.3V,Vccq是控制部分,决定数据和其他管脚的电平,接1.8V或者3.3V这样就与CPU芯片的管脚进行电平匹配。
电路设计中,由于沿用之前的4.5版本硬件设计导致没有接Data Strobe pin引脚,所以HS400虽然探测成功,但读取数据失败;这样因为EMMC和CPU驱动都支持5.1版本。
Data Strobe pin引脚是H5管脚,需要在下一版硬件接上后进行验证。
只能强制探测到HS200模式,注释探测HS400模式代码:
static int mmc_init_card(struct mmc_host *host, u32 ocr,
struct mmc_card *oldcard)
{
struct mmc_card *card;
int err;
u32 cid[4];
u32 rocr;
WARN_ON(!host->claimed);
......
if (mmc_card_hs200(card)) {
err = mmc_hs200_tuning(card);
if (err)
goto free_card;
// err = mmc_select_hs400(card);
// if (err)
// goto free_card;
} else if (!mmc_card_hs400es(card)) {
/* Select the desired bus width optionally */
err = mmc_select_bus_width(card);
if (err > 0 && mmc_card_hs(card)) {
err = mmc_select_hs_ddr(card);
if (err)
goto free_card;
}
}
[ 4.067441] <3>.(3)[68:kworker/3:1]mtk-msdc 11230000.mmc: host->mclk:400000, ios->clock:400000, host->timing:0,ios->timing:9
[ 4.068901] <3>.(3)[68:kworker/3:1]mtk-msdc 11230000.mmc: sclk: 399999, timing: 9, hz: 400000
[ 4.070330] <3>.(3)[68:kworker/3:1]mtk-msdc 11230000.mmc: host->mclk:400000, ios->clock:200000000, host->timing:9,ios->timing:9
[ 4.071903] <3>.(3)[68:kworker/3:1]mtk-msdc 11230000.mmc: sclk: 191999939, timing: 9, hz: 200000000
[ 4.130445] <3>.(3)[68:kworker/3:1]mmc0: Command Queue Engine enabled
[ 4.131595] <3>.(3)[68:kworker/3:1]mmc0: new HS200 MMC card at address 0001
[ 4.145960] <3>.(3)[68:kworker/3:1]mmcblk0: mmc0:0001 H8G4a2 7.28 GiB
[ 4.148318] <3>.(3)[68:kworker/3:1]mmcblk0boot0: mmc0:0001 H8G4a2 partition 1 4.00 MiB
[ 4.150826] <3>.(3)[68:kworker/3:1]mmcblk0boot1: mmc0:0001 H8G4a2 partition 2 4.00 MiB
[ 4.152472] <3>.(3)[68:kworker/3:1]mmcblk0rpmb: mmc0:0001 H8G4a2 partition 3 4.00 MiB, chardev (234:0)
[ 4.160306] <3>.(3)[68:kworker/3:1] mmcblk0: p1
[ 4.168629] <3>.(3)[68:kworker/3:1]BOOTPROF: 4168.624624:probe: probe=mmc_bus_probe drv=mmcblk(mmc_driver) 34.474692ms
root@auto2735evb-ivt-main:~# cat /sys/kernel/debug/mmc0/ios
clock: 200000000 Hz
actual clock: 191999939 Hz
vdd: 18 (3.0 ~ 3.1 V)
bus mode: 2 (push-pull)
chip select: 0 (don't care)
power mode: 2 (on)
bus width: 3 (8 bits)
timing spec: 9 (mmc HS200)
signal voltage: 1 (1.80 V)
driver type: 0 (driver type B)
root@auto2735evb-ivt-main:~# ls /dev/mmcblk0* -l
brw-rw---- 1 root disk 179, 0 Apr 2 03:55 /dev/mmcblk0
brw-rw---- 1 root disk 179, 8 Apr 2 03:55 /dev/mmcblk0boot0
brw-rw---- 1 root disk 179, 16 Apr 2 03:55 /dev/mmcblk0boot1
brw-rw---- 1 root disk 179, 1 Apr 2 03:55 /dev/mmcblk0p1
crw------- 1 root root 234, 0 Apr 2 03:55 /dev/mmcblk0rpmb
Disk /dev/mmcblk0: 7.3 GiB, 7818182656 bytes, 15269888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd9379130
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 15269887 15267840 7.3G 83 Linux
启动后使用fdisk工具进行分区和读写数据都正常了。