Commit e327df5e authored by Christian Lütke-Stetzkamp's avatar Christian Lütke-Stetzkamp Committed by Greg Kroah-Hartman

staging: mt7621-mmc: Make msdc_clr_fifo a function and relax cpu

In the current code, msdc_clr_fifo is a macro and just busy waits for
a limited amount of time for the fifo clear to finish. That is not
correct, the programming manual hits, that the user should wait until
the bit is cleared by hardware and not a limited amount of time.

So the code is changed to a function, that also relaxes the cpu while
busy waiting.
Signed-off-by: default avatarChristian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 41015d06
...@@ -177,12 +177,14 @@ static void msdc_reset_hw(struct msdc_host *host) ...@@ -177,12 +177,14 @@ static void msdc_reset_hw(struct msdc_host *host)
writel(val, MSDC_INT); \ writel(val, MSDC_INT); \
} while (0) } while (0)
#define msdc_clr_fifo() \ static void msdc_clr_fifo(struct msdc_host *host)
do { \ {
int retry = 3, cnt = 1000; \ void __iomem *base = host->base;
sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \
msdc_retry(readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \ sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR);
} while (0) while (readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR)
cpu_relax();
}
#define msdc_irq_save(val) \ #define msdc_irq_save(val) \
do { \ do { \
...@@ -554,7 +556,7 @@ static void msdc_abort_data(struct msdc_host *host) ...@@ -554,7 +556,7 @@ static void msdc_abort_data(struct msdc_host *host)
ERR_MSG("Need to Abort."); ERR_MSG("Need to Abort.");
msdc_reset_hw(host); msdc_reset_hw(host);
msdc_clr_fifo(); msdc_clr_fifo(host);
msdc_clr_int(); msdc_clr_int();
// need to check FIFO count 0 ? // need to check FIFO count 0 ?
...@@ -945,7 +947,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host, ...@@ -945,7 +947,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host,
} else { } else {
/* do basic: reset*/ /* do basic: reset*/
msdc_reset_hw(host); msdc_reset_hw(host);
msdc_clr_fifo(); msdc_clr_fifo(host);
msdc_clr_int(); msdc_clr_int();
} }
cmd->error = msdc_tune_cmdrsp(host, cmd); cmd->error = msdc_tune_cmdrsp(host, cmd);
...@@ -1131,7 +1133,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -1131,7 +1133,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)
} }
writel(data->blocks, SDC_BLK_NUM); writel(data->blocks, SDC_BLK_NUM);
//msdc_clr_fifo(); /* no need */ //msdc_clr_fifo(host); /* no need */
msdc_dma_on(); /* enable DMA mode first!! */ msdc_dma_on(); /* enable DMA mode first!! */
init_completion(&host->xfer_done); init_completion(&host->xfer_done);
...@@ -1165,7 +1167,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -1165,7 +1167,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)
data->error = -ETIMEDOUT; data->error = -ETIMEDOUT;
msdc_reset_hw(host); msdc_reset_hw(host);
msdc_clr_fifo(); msdc_clr_fifo(host);
msdc_clr_int(); msdc_clr_int();
} }
spin_lock(&host->lock); spin_lock(&host->lock);
...@@ -1868,7 +1870,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) ...@@ -1868,7 +1870,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
if (intsts & datsts) { if (intsts & datsts) {
/* do basic reset, or stop command will sdc_busy */ /* do basic reset, or stop command will sdc_busy */
msdc_reset_hw(host); msdc_reset_hw(host);
msdc_clr_fifo(); msdc_clr_fifo(host);
msdc_clr_int(); msdc_clr_int();
if (intsts & MSDC_INT_DATTMO) { if (intsts & MSDC_INT_DATTMO) {
...@@ -1917,7 +1919,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) ...@@ -1917,7 +1919,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
IRQ_MSG("XXX CMD<%d> MSDC_INT_CMDTMO", cmd->opcode); IRQ_MSG("XXX CMD<%d> MSDC_INT_CMDTMO", cmd->opcode);
cmd->error = -ETIMEDOUT; cmd->error = -ETIMEDOUT;
msdc_reset_hw(host); msdc_reset_hw(host);
msdc_clr_fifo(); msdc_clr_fifo(host);
msdc_clr_int(); msdc_clr_int();
} }
complete(&host->cmd_done); complete(&host->cmd_done);
...@@ -2029,7 +2031,7 @@ static void msdc_init_hw(struct msdc_host *host) ...@@ -2029,7 +2031,7 @@ static void msdc_init_hw(struct msdc_host *host)
/* Reset */ /* Reset */
msdc_reset_hw(host); msdc_reset_hw(host);
msdc_clr_fifo(); msdc_clr_fifo(host);
/* Disable card detection */ /* Disable card detection */
sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN); sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment