mmc: pic32_sdhci: move the code to pic32_sdhci.c
authorJaehoon Chung <jh80.chung@samsung.com>
Fri, 30 Dec 2016 06:30:14 +0000 (15:30 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Wed, 11 Jan 2017 10:40:11 +0000 (19:40 +0900)
This code is used for only pic32_sdhci controller.
To remove the "#ifdef", moves to pic32_sdhci.c.
And use the get_cd callback function.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/mmc/pic32_sdhci.c
drivers/mmc/sdhci.c

index 2abf943bdb9d31c8e5e26f68b892c1cf7cf19afd..8d528de8b6629a638c77b3e552bdb5ef51c4fad9 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static int pci32_sdhci_get_cd(struct sdhci_host *host)
+{
+       /* PIC32 SDHCI CD errata:
+        * - set CD_TEST and clear CD_TEST_INS bit
+        */
+       sdhci_writeb(host, SDHCI_CTRL_CD_TEST, SDHCI_HOST_CONTROL);
+
+       return 0;
+}
+
+static const struct sdhci_ops pic32_sdhci_ops = {
+       .get_cd = pci32_sdhci_get_cd,
+};
+
 static int pic32_sdhci_probe(struct udevice *dev)
 {
        struct sdhci_host *host = dev_get_priv(dev);
@@ -33,6 +47,7 @@ static int pic32_sdhci_probe(struct udevice *dev)
        host->quirks    = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_NO_CD;
        host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
                                        "bus-width", 4);
+       host->ops = &pic32_sdhci_ops;
 
        ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
                                   "clock-freq-min-max", f_min_max, 2);
index c512a4c190fab88362e41a082ae0210d374b8a02..230416a9f15aa6a857fbcfc29b7f0bca65dcb1ce 100644 (file)
@@ -485,12 +485,8 @@ static int sdhci_init(struct mmc *mmc)
        sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
        if (host->quirks & SDHCI_QUIRK_NO_CD) {
-#if defined(CONFIG_PIC32_SDHCI)
-               /* PIC32 SDHCI CD errata:
-                * - set CD_TEST and clear CD_TEST_INS bit
-                */
-               sdhci_writeb(host, SDHCI_CTRL_CD_TEST, SDHCI_HOST_CONTROL);
-#endif
+               if (host->ops->get_cd)
+                       host->ops->get_cd(host);
        }
 
        /* Enable only interrupts served by the SD controller */