From f3b9a9bdfa1ae9fdda320df2afe7b2de25a1edc1 Mon Sep 17 00:00:00 2001 From: bigmagic Date: Mon, 24 Feb 2020 22:45:11 +0800 Subject: [PATCH] fix raspi3-32 sdio driver --- bsp/raspberry-pi/raspi3-32/driver/drv_sdio.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bsp/raspberry-pi/raspi3-32/driver/drv_sdio.c b/bsp/raspberry-pi/raspi3-32/driver/drv_sdio.c index c547419ca2..46df0372e9 100644 --- a/bsp/raspberry-pi/raspi3-32/driver/drv_sdio.c +++ b/bsp/raspberry-pi/raspi3-32/driver/drv_sdio.c @@ -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)) { 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)); - return -RT_ETIMEOUT; + //qemu maybe can not use sdcard + //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) { @@ -122,7 +123,9 @@ rt_err_t sd_status(struct sdhci_pdata_t * pdat, unsigned int mask) return -RT_ETIMEOUT; } else if (read32(pdat->virt + EMMC_INTERRUPT) & INT_ERROR_MASK) + { return -RT_ERROR; + } 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); 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) { cmd->datarw = DATA_READ;