]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/mmc/host/sdhci.c
mmc: sdhci: convert generic bus width setup to library function
[mirror_ubuntu-zesty-kernel.git] / drivers / mmc / host / sdhci.c
index 8cd20ef0a9cb4f69a85905934c5b2f23b5e2086a..15f6c5e08e9d541e3fe4f8634f4230b184d9a823 100644 (file)
@@ -1413,6 +1413,27 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
        spin_unlock_irqrestore(&host->lock, flags);
 }
 
+void sdhci_set_bus_width(struct sdhci_host *host, int width)
+{
+       u8 ctrl;
+
+       ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+       if (width == MMC_BUS_WIDTH_8) {
+               ctrl &= ~SDHCI_CTRL_4BITBUS;
+               if (host->version >= SDHCI_SPEC_300)
+                       ctrl |= SDHCI_CTRL_8BITBUS;
+       } else {
+               if (host->version >= SDHCI_SPEC_300)
+                       ctrl &= ~SDHCI_CTRL_8BITBUS;
+               if (width == MMC_BUS_WIDTH_4)
+                       ctrl |= SDHCI_CTRL_4BITBUS;
+               else
+                       ctrl &= ~SDHCI_CTRL_4BITBUS;
+       }
+       sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+}
+EXPORT_SYMBOL_GPL(sdhci_set_bus_width);
+
 static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
 {
        unsigned long flags;
@@ -1458,29 +1479,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
        if (host->ops->platform_send_init_74_clocks)
                host->ops->platform_send_init_74_clocks(host, ios->power_mode);
 
-       /*
-        * If your platform has 8-bit width support but is not a v3 controller,
-        * or if it requires special setup code, you should implement that in
-        * platform_bus_width().
-        */
-       if (host->ops->platform_bus_width) {
-               host->ops->platform_bus_width(host, ios->bus_width);
-       } else {
-               ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
-               if (ios->bus_width == MMC_BUS_WIDTH_8) {
-                       ctrl &= ~SDHCI_CTRL_4BITBUS;
-                       if (host->version >= SDHCI_SPEC_300)
-                               ctrl |= SDHCI_CTRL_8BITBUS;
-               } else {
-                       if (host->version >= SDHCI_SPEC_300)
-                               ctrl &= ~SDHCI_CTRL_8BITBUS;
-                       if (ios->bus_width == MMC_BUS_WIDTH_4)
-                               ctrl |= SDHCI_CTRL_4BITBUS;
-                       else
-                               ctrl &= ~SDHCI_CTRL_4BITBUS;
-               }
-               sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
-       }
+       host->ops->set_bus_width(host, ios->bus_width);
 
        ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);