mmc: esdhc: Workaround for data crc error on p1010rdb
authorJerry Huang <Chang-Ming.Huang@freescale.com>
Tue, 14 Feb 2012 06:05:37 +0000 (14:05 +0800)
committerChris Ball <cjb@laptop.org>
Sun, 25 Mar 2012 23:33:45 +0000 (19:33 -0400)
SD card read was failing (data crc error) on some cards at
maximum possible frequency on P1010 (CCB frequency set to 400MHz).
Some clock deviations are also observed at this frequency.
Hence reduced the mmc clock freq.

Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
Singed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/sdhci-of-esdhc.c

index 2ef52f47def843b250051a1dd5df54c9b05ea30b..f8eb1fb0c9219283c9624f3f0a8adde251bcd5e9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Freescale eSDHC controller driver.
  *
- * Copyright (c) 2007, 2010 Freescale Semiconductor, Inc.
+ * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  *
  * Authors: Xiaobo Xie <X.Xie@freescale.com>
@@ -14,6 +14,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/of.h>
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/mmc/host.h>
@@ -114,6 +115,20 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host)
        return pltfm_host->clock / 256 / 16;
 }
 
+static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+       /* Workaround to reduce the clock frequency for p1010 esdhc */
+       if (of_find_compatible_node(NULL, NULL, "fsl,p1010-esdhc")) {
+               if (clock > 20000000)
+                       clock -= 5000000;
+               if (clock > 40000000)
+                       clock -= 5000000;
+       }
+
+       /* Set the clock */
+       esdhc_set_clock(host, clock);
+}
+
 #ifdef CONFIG_PM
 static u32 esdhc_proctl;
 static void esdhc_of_suspend(struct sdhci_host *host)
@@ -135,7 +150,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
        .write_l = sdhci_be32bs_writel,
        .write_w = esdhc_writew,
        .write_b = esdhc_writeb,
-       .set_clock = esdhc_set_clock,
+       .set_clock = esdhc_of_set_clock,
        .enable_dma = esdhc_of_enable_dma,
        .get_max_clock = esdhc_of_get_max_clock,
        .get_min_clock = esdhc_of_get_min_clock,