mirror of
https://github.com/u-boot/u-boot.git
synced 2024-12-05 10:33:42 +08:00
MVEBUMMC : Speed up access time
Get about 40x faster access on SHEEVAPLUG MMC Fix some SD type compatibility Changes in v3: - fix the HW_STATE (from linux mvsdio) - review delays and timeouts Changes in v2: - increase number of loops - remove initial delay Changes in v1: - review all loops, delays and timeouts Signed-off-by: Gérald Kerma <drEagle@doukki.net> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
This commit is contained in:
parent
2591fbdba3
commit
28d27b79e3
@ -23,6 +23,8 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||||||
|
|
||||||
#define MVEBU_TARGET_DRAM 0
|
#define MVEBU_TARGET_DRAM 0
|
||||||
|
|
||||||
|
#define TIMEOUT_DELAY 5*CONFIG_SYS_HZ /* wait 5 seconds */
|
||||||
|
|
||||||
static void mvebu_mmc_write(u32 offs, u32 val)
|
static void mvebu_mmc_write(u32 offs, u32 val)
|
||||||
{
|
{
|
||||||
writel(val, CONFIG_SYS_MMC_BASE + (offs));
|
writel(val, CONFIG_SYS_MMC_BASE + (offs));
|
||||||
@ -63,7 +65,7 @@ static int mvebu_mmc_setup_data(struct mmc_data *data)
|
|||||||
static int mvebu_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
|
static int mvebu_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
|
||||||
struct mmc_data *data)
|
struct mmc_data *data)
|
||||||
{
|
{
|
||||||
int timeout = 10;
|
ulong start;
|
||||||
ushort waittype = 0;
|
ushort waittype = 0;
|
||||||
ushort resptype = 0;
|
ushort resptype = 0;
|
||||||
ushort xfertype = 0;
|
ushort xfertype = 0;
|
||||||
@ -72,19 +74,33 @@ static int mvebu_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
|
|||||||
debug("cmdidx [0x%x] resp_type[0x%x] cmdarg[0x%x]\n",
|
debug("cmdidx [0x%x] resp_type[0x%x] cmdarg[0x%x]\n",
|
||||||
cmd->cmdidx, cmd->resp_type, cmd->cmdarg);
|
cmd->cmdidx, cmd->resp_type, cmd->cmdarg);
|
||||||
|
|
||||||
udelay(10*1000);
|
|
||||||
|
|
||||||
debug("%s: cmd %d (hw state 0x%04x)\n", DRIVER_NAME,
|
debug("%s: cmd %d (hw state 0x%04x)\n", DRIVER_NAME,
|
||||||
cmd->cmdidx, mvebu_mmc_read(SDIO_HW_STATE));
|
cmd->cmdidx, mvebu_mmc_read(SDIO_HW_STATE));
|
||||||
|
|
||||||
/* Checking if card is busy */
|
/*
|
||||||
while ((mvebu_mmc_read(SDIO_HW_STATE) & CARD_BUSY)) {
|
* Hardware weirdness. The FIFO_EMPTY bit of the HW_STATE
|
||||||
if (timeout == 0) {
|
* register is sometimes not set before a while when some
|
||||||
printf("%s: card busy!\n", DRIVER_NAME);
|
* "unusual" data block sizes are used (such as with the SWITCH
|
||||||
return -1;
|
* command), even despite the fact that the XFER_DONE interrupt
|
||||||
}
|
* was raised. And if another data transfer starts before
|
||||||
timeout--;
|
* this bit comes to good sense (which eventually happens by
|
||||||
udelay(1000);
|
* itself) then the new transfer simply fails with a timeout.
|
||||||
|
*/
|
||||||
|
if (!(mvebu_mmc_read(SDIO_HW_STATE) & CMD_FIFO_EMPTY)) {
|
||||||
|
ushort hw_state, count = 0;
|
||||||
|
|
||||||
|
start = get_timer(0);
|
||||||
|
do {
|
||||||
|
hw_state = mvebu_mmc_read(SDIO_HW_STATE);
|
||||||
|
if ((get_timer(0) - start) > TIMEOUT_DELAY) {
|
||||||
|
printf("%s : FIFO_EMPTY bit missing\n",
|
||||||
|
DRIVER_NAME);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
} while (!(hw_state & CMD_FIFO_EMPTY));
|
||||||
|
debug("%s *** wait for FIFO_EMPTY bit (hw=0x%04x, count=%d, jiffies=%ld)\n",
|
||||||
|
DRIVER_NAME, hw_state, count, (get_timer(0) - (start)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up for a data transfer if we have one */
|
/* Set up for a data transfer if we have one */
|
||||||
@ -147,8 +163,7 @@ static int mvebu_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
|
|||||||
mvebu_mmc_write(SDIO_NOR_INTR_EN, SDIO_POLL_MASK);
|
mvebu_mmc_write(SDIO_NOR_INTR_EN, SDIO_POLL_MASK);
|
||||||
mvebu_mmc_write(SDIO_ERR_INTR_EN, SDIO_POLL_MASK);
|
mvebu_mmc_write(SDIO_ERR_INTR_EN, SDIO_POLL_MASK);
|
||||||
|
|
||||||
/* Waiting for completion */
|
start = get_timer(0);
|
||||||
timeout = 1000000;
|
|
||||||
|
|
||||||
while (!((mvebu_mmc_read(SDIO_NOR_INTR_STATUS)) & waittype)) {
|
while (!((mvebu_mmc_read(SDIO_NOR_INTR_STATUS)) & waittype)) {
|
||||||
if (mvebu_mmc_read(SDIO_NOR_INTR_STATUS) & SDIO_NOR_ERROR) {
|
if (mvebu_mmc_read(SDIO_NOR_INTR_STATUS) & SDIO_NOR_ERROR) {
|
||||||
@ -161,13 +176,12 @@ static int mvebu_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
|
|||||||
return COMM_ERR;
|
return COMM_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout--;
|
if ((get_timer(0) - start) > TIMEOUT_DELAY) {
|
||||||
udelay(1);
|
debug("%s: command timed out\n", DRIVER_NAME);
|
||||||
if (timeout <= 0) {
|
|
||||||
printf("%s: command timed out\n", DRIVER_NAME);
|
|
||||||
return TIMEOUT;
|
return TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mvebu_mmc_read(SDIO_ERR_INTR_STATUS) &
|
if (mvebu_mmc_read(SDIO_ERR_INTR_STATUS) &
|
||||||
(SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT))
|
(SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT))
|
||||||
return TIMEOUT;
|
return TIMEOUT;
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
#define CMD_INHIBIT (1 << 0)
|
#define CMD_INHIBIT (1 << 0)
|
||||||
#define CMD_TXACTIVE (1 << 8)
|
#define CMD_TXACTIVE (1 << 8)
|
||||||
#define CMD_RXACTIVE (1 << 9)
|
#define CMD_RXACTIVE (1 << 9)
|
||||||
|
#define CMD_FIFO_EMPTY (1 << 13)
|
||||||
#define CMD_AUTOCMD12ACTIVE (1 << 14)
|
#define CMD_AUTOCMD12ACTIVE (1 << 14)
|
||||||
#define CMD_BUS_BUSY (CMD_AUTOCMD12ACTIVE | \
|
#define CMD_BUS_BUSY (CMD_AUTOCMD12ACTIVE | \
|
||||||
CMD_RXACTIVE | \
|
CMD_RXACTIVE | \
|
||||||
|
Loading…
Reference in New Issue
Block a user