mmc: mmci: expand startbiterr to irqmask and error check
authorLudovic Barre <ludovic.barre@st.com>
Mon, 8 Oct 2018 12:08:44 +0000 (14:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Nov 2019 07:20:43 +0000 (08:20 +0100)
[ Upstream commit daf9713c5ef8c3ffb0bdf7de11b53b2b2756c4f1 ]

All variants don't pretend to have a startbiterr.
-While data error check, if status register return an error
(like  MCI_DATACRCFAIL) we must avoid to check MCI_STARTBITERR
(if not desired).
-expand start_err to MCI_IRQENABLE to avoid to set this bit by default.

Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mmc/host/mmci.c
drivers/mmc/host/mmci.h

index eb1a65c..fa6268c 100644 (file)
@@ -895,14 +895,18 @@ static void
 mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
              unsigned int status)
 {
+       unsigned int status_err;
+
        /* Make sure we have data to handle */
        if (!data)
                return;
 
        /* First check for errors */
-       if (status & (MCI_DATACRCFAIL | MCI_DATATIMEOUT |
-                     host->variant->start_err |
-                     MCI_TXUNDERRUN | MCI_RXOVERRUN)) {
+       status_err = status & (host->variant->start_err |
+                              MCI_DATACRCFAIL | MCI_DATATIMEOUT |
+                              MCI_TXUNDERRUN | MCI_RXOVERRUN);
+
+       if (status_err) {
                u32 remain, success;
 
                /* Terminate the DMA transfer */
@@ -922,18 +926,18 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
                success = data->blksz * data->blocks - remain;
 
                dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ, status 0x%08x at 0x%08x\n",
-                       status, success);
-               if (status & MCI_DATACRCFAIL) {
+                       status_err, success);
+               if (status_err & MCI_DATACRCFAIL) {
                        /* Last block was not successful */
                        success -= 1;
                        data->error = -EILSEQ;
-               } else if (status & MCI_DATATIMEOUT) {
+               } else if (status_err & MCI_DATATIMEOUT) {
                        data->error = -ETIMEDOUT;
-               } else if (status & MCI_STARTBITERR) {
+               } else if (status_err & MCI_STARTBITERR) {
                        data->error = -ECOMM;
-               } else if (status & MCI_TXUNDERRUN) {
+               } else if (status_err & MCI_TXUNDERRUN) {
                        data->error = -EIO;
-               } else if (status & MCI_RXOVERRUN) {
+               } else if (status_err & MCI_RXOVERRUN) {
                        if (success > host->variant->fifosize)
                                success -= host->variant->fifosize;
                        else
@@ -1790,7 +1794,7 @@ static int mmci_probe(struct amba_device *dev,
                        goto clk_disable;
        }
 
-       writel(MCI_IRQENABLE, host->base + MMCIMASK0);
+       writel(MCI_IRQENABLE | variant->start_err, host->base + MMCIMASK0);
 
        amba_set_drvdata(dev, mmc);
 
@@ -1877,7 +1881,8 @@ static void mmci_restore(struct mmci_host *host)
                writel(host->datactrl_reg, host->base + MMCIDATACTRL);
                writel(host->pwr_reg, host->base + MMCIPOWER);
        }
-       writel(MCI_IRQENABLE, host->base + MMCIMASK0);
+       writel(MCI_IRQENABLE | host->variant->start_err,
+              host->base + MMCIMASK0);
        mmci_reg_delay(host);
 
        spin_unlock_irqrestore(&host->lock, flags);
index 517591d..613d37a 100644 (file)
 #define MMCIFIFO               0x080 /* to 0x0bc */
 
 #define MCI_IRQENABLE  \
-       (MCI_CMDCRCFAILMASK|MCI_DATACRCFAILMASK|MCI_CMDTIMEOUTMASK|     \
-       MCI_DATATIMEOUTMASK|MCI_TXUNDERRUNMASK|MCI_RXOVERRUNMASK|       \
-       MCI_CMDRESPENDMASK|MCI_CMDSENTMASK|MCI_STARTBITERRMASK)
+       (MCI_CMDCRCFAILMASK | MCI_DATACRCFAILMASK | MCI_CMDTIMEOUTMASK | \
+       MCI_DATATIMEOUTMASK | MCI_TXUNDERRUNMASK | MCI_RXOVERRUNMASK |  \
+       MCI_CMDRESPENDMASK | MCI_CMDSENTMASK)
 
 /* These interrupts are directed to IRQ1 when two IRQ lines are available */
 #define MCI_IRQ1MASK \