]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mmc: meson-mx-sdhc: Fix manual RX FIFO flushing
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Sun, 17 May 2020 22:29:06 +0000 (00:29 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 28 May 2020 09:22:15 +0000 (11:22 +0200)
For Meson8 and Meson8b SoCs the vendor driver follows the following
pattern:
- for eMMC and SD cards in .set_pdma it sets:
  pdma->rxfifo_manual_flush = 1;
- for SDIO cards in .set_pdma it sets:
  pdma->rxfifo_manual_flush = 0;
- before syncing the DMA read buffer is sets:
  pdma->rxfifo_manual_flush |= 0x02;

Set the second bit of MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH without
clearing the first bit before syncing the DMA read buffer. This fixes a
problem where Meson8 and Meson8b SoCs would read random garbage from SD
cards. It is not clear why it worked for eMMC cards. This manifested in
the following errors when plugging in an SD card:
  unrecognised SCR structure version <random number>

Cc: Thomas Graichen <thomas.graichen@gmail.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20200517222907.1277787-1-martin.blumenstingl@googlemail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/meson-mx-sdhc-mmc.c

index 5c00958d77541901636e28f24c629bee4142e9fb..53e3f6a4245a69a29e9f696c30f691d46c6c0d0e 100644 (file)
@@ -586,10 +586,17 @@ static irqreturn_t meson_mx_sdhc_irq_thread(int irq, void *irq_data)
                    cmd->data->flags & MMC_DATA_READ) {
                        meson_mx_sdhc_wait_cmd_ready(host->mmc);
 
+                       /*
+                        * If MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH was
+                        * previously 0x1 then it has to be set to 0x3. If it
+                        * was 0x0 before then it has to be set to 0x2. Without
+                        * this reading SD cards sometimes transfers garbage,
+                        * which results in cards not being detected due to:
+                        *   unrecognised SCR structure version <random number>
+                        */
                        val = FIELD_PREP(MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH,
                                         2);
-                       regmap_update_bits(host->regmap, MESON_SDHC_PDMA,
-                                          MESON_SDHC_PDMA_RXFIFO_MANUAL_FLUSH,
+                       regmap_update_bits(host->regmap, MESON_SDHC_PDMA, val,
                                           val);
                }