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: Christian Lütke-Stetzkamp <christian@lkamp.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Christian Lütke-Stetzkamp 2018-06-16 16:14:54 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель 41015d06e6
Коммит e327df5e88
1 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -177,12 +177,14 @@ static void msdc_reset_hw(struct msdc_host *host)
writel(val, MSDC_INT); \
} while (0)
#define msdc_clr_fifo() \
do { \
int retry = 3, cnt = 1000; \
sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR); \
msdc_retry(readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR, retry, cnt); \
} while (0)
static void msdc_clr_fifo(struct msdc_host *host)
{
void __iomem *base = host->base;
sdr_set_bits(MSDC_FIFOCS, MSDC_FIFOCS_CLR);
while (readl(MSDC_FIFOCS) & MSDC_FIFOCS_CLR)
cpu_relax();
}
#define msdc_irq_save(val) \
do { \
@ -554,7 +556,7 @@ static void msdc_abort_data(struct msdc_host *host)
ERR_MSG("Need to Abort.");
msdc_reset_hw(host);
msdc_clr_fifo();
msdc_clr_fifo(host);
msdc_clr_int();
// need to check FIFO count 0 ?
@ -945,7 +947,7 @@ static unsigned int msdc_command_resp(struct msdc_host *host,
} else {
/* do basic: reset*/
msdc_reset_hw(host);
msdc_clr_fifo();
msdc_clr_fifo(host);
msdc_clr_int();
}
cmd->error = msdc_tune_cmdrsp(host, cmd);
@ -1131,7 +1133,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)
}
writel(data->blocks, SDC_BLK_NUM);
//msdc_clr_fifo(); /* no need */
//msdc_clr_fifo(host); /* no need */
msdc_dma_on(); /* enable DMA mode first!! */
init_completion(&host->xfer_done);
@ -1165,7 +1167,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)
data->error = -ETIMEDOUT;
msdc_reset_hw(host);
msdc_clr_fifo();
msdc_clr_fifo(host);
msdc_clr_int();
}
spin_lock(&host->lock);
@ -1868,7 +1870,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
if (intsts & datsts) {
/* do basic reset, or stop command will sdc_busy */
msdc_reset_hw(host);
msdc_clr_fifo();
msdc_clr_fifo(host);
msdc_clr_int();
if (intsts & MSDC_INT_DATTMO) {
@ -1917,7 +1919,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
IRQ_MSG("XXX CMD<%d> MSDC_INT_CMDTMO", cmd->opcode);
cmd->error = -ETIMEDOUT;
msdc_reset_hw(host);
msdc_clr_fifo();
msdc_clr_fifo(host);
msdc_clr_int();
}
complete(&host->cmd_done);
@ -2029,7 +2031,7 @@ static void msdc_init_hw(struct msdc_host *host)
/* Reset */
msdc_reset_hw(host);
msdc_clr_fifo();
msdc_clr_fifo(host);
/* Disable card detection */
sdr_clr_bits(MSDC_PS, MSDC_PS_CDEN);