fix raspi3-32 sdio driver

This commit is contained in:
bigmagic 2020-02-24 22:45:11 +08:00
parent af4541c749
commit f3b9a9bdfa
1 changed files with 13 additions and 3 deletions

View File

@ -99,8 +99,9 @@ rt_err_t sd_int(struct sdhci_pdata_t * pdat, unsigned int mask)
if (cnt <= 0 || (r & INT_CMD_TIMEOUT) || (r & INT_DATA_TIMEOUT)) if (cnt <= 0 || (r & INT_CMD_TIMEOUT) || (r & INT_DATA_TIMEOUT))
{ {
write32(pdat->virt + EMMC_INTERRUPT, r); write32(pdat->virt + EMMC_INTERRUPT, r);
rt_kprintf("send cmd/data timeout wait for %x int: %x, status: %x\n",mask, r, read32(pdat->virt + EMMC_STATUS)); //qemu maybe can not use sdcard
return -RT_ETIMEOUT; //rt_kprintf("send cmd/data timeout wait for %x int: %x, status: %x\n",mask, r, read32(pdat->virt + EMMC_STATUS));
//return -RT_ETIMEOUT;
} }
else if (r & INT_ERROR_MASK) else if (r & INT_ERROR_MASK)
{ {
@ -122,7 +123,9 @@ rt_err_t sd_status(struct sdhci_pdata_t * pdat, unsigned int mask)
return -RT_ETIMEOUT; return -RT_ETIMEOUT;
} }
else if (read32(pdat->virt + EMMC_INTERRUPT) & INT_ERROR_MASK) else if (read32(pdat->virt + EMMC_INTERRUPT) & INT_ERROR_MASK)
{
return -RT_ERROR; return -RT_ERROR;
}
return RT_EOK; return RT_EOK;
} }
@ -252,8 +255,15 @@ static rt_err_t raspi_transfer_data(struct sdhci_pdata_t * pdat, struct sdhci_cm
ret = raspi_transfer_command(pdat, &newcmd); ret = raspi_transfer_command(pdat, &newcmd);
if (ret) return ret; if (ret) return ret;
} }
write32(pdat->virt + EMMC_BLKSIZECNT, dlen | 1 << 16);
if(dlen < 512)
{
write32(pdat->virt + EMMC_BLKSIZECNT, dlen | 1 << 16);
}
else
{
write32(pdat->virt + EMMC_BLKSIZECNT, 512 | (dat->blkcnt) << 16);
}
if (dat->flag & DATA_DIR_READ) if (dat->flag & DATA_DIR_READ)
{ {
cmd->datarw = DATA_READ; cmd->datarw = DATA_READ;