UNSTUFF_BITS宏定义分析(RGB:185 225 221)
0x1234567 0x89ABCDEF 0x1234567 0x89ABCDEF
,得到UNSTUFF_BITS(resp, 8, 4) = 0xD
CONFIG_MMC_DEBUG = y
echo 8 > /proc/sys/kernel/printk
[ 177.022399] mmc1: starting CMD9 arg e6240000 flags 00000007
[ 177.028015] set_mmc_cken: ON
[ 177.031616] PXAMCI: irq 00000004 stat 00002140
[ 177.036041] mmc1: req done (CMD9): 0: 400e0032 5b590000 edc87f80 0a40403f
resp[0]表示最高位
resp中不包含(start bit/transmission bit/command index)
[ 177.185485] mmc1: starting CMD55 arg e6240000 flags 00000095 (R1 - 32bit(card status) + 8bit)
[ 177.191192] set_mmc_cken: ON
[ 177.194061] PXAMCI: irq 00000004 stat 00002140
[ 177.198516] mmc1: req done (CMD55): 0: 00000920 5b590000 edc87f80 0a404037(红色有效,后面无效)
static void sdhci_finish_command(struct sdhci_host *host)
{
int i;
BUG_ON(host->cmd == NULL);
if (host->cmd->flags & MMC_RSP_PRESENT) {
if (host->cmd->flags & MMC_RSP_136) { //SPEC的128位数据中包含了CRC,但是eSDHCI控制器会自动移除CRC校验,所以需要以为来使resp符合SPEC
/* CRC is stripped so we need to do some shifting. */
for (i = 0;i < 4;i++) {
host->cmd->resp[i] = readl(host->ioaddr +
SDHCI_RESPONSE + (3-i)*4) << 8;
if (i != 3)
host->cmd->resp[i] |=
readb(host->ioaddr +
SDHCI_RESPONSE + (3-i)*4-1);
}
} else {
host->cmd->resp[0] = readl(host->ioaddr + SDHCI_RESPONSE); //这个不包含CRC
}
}
host->cmd->error = 0;
if (host->data && host->data_early)
sdhci_finish_data(host);
if (!host->cmd->data)
tasklet_schedule(&host->finish_tasklet);
host->cmd = NULL;
}