9
0
Fork 0

mci: mmci: Fix read FIFO handling

According to the Linux kernel and the qemu code, the MMCIFIFOCNT contains
the remaining number of words to read, excluding those that are already in
the FIFO. So the current number of bytes in the FIFO is
host_remain - (readl(base + MMCIFIFOCNT) << 2).

Also writing to MMCIDATACTRL will reset the read counter. As a result,
MCI_DATABLOCKEND is never set and read_bytes() waits forever.

With this change, SD-Card support on qemu vexpress works correctly.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Michael Olbrich 2016-09-02 10:50:37 +02:00 committed by Sascha Hauer
parent a1109d78dd
commit faf2ec64e7
1 changed files with 1 additions and 2 deletions

View File

@ -212,7 +212,7 @@ static u64 mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int host
struct variant_data *variant = host->variant;
do {
int count = readl(base + MMCIFIFOCNT) << 2;
int count = host_remain - (readl(base + MMCIFIFOCNT) << 2);
if (count > host_remain)
count = host_remain;
@ -264,7 +264,6 @@ static int read_bytes(struct mci_host *mci, char *dest, unsigned int blkcount, u
dev_dbg(host->hw_dev, "read_bytes: blkcount=%u blksize=%u\n", blkcount, blksize);
do {
mmci_writel(host, MMCIDATACTRL, mmci_readl(host, MMCIDATACTRL));
len = mmci_pio_read(host, dest, xfercount);
xfercount -= len;
dest += len;