]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mmc: sdhci: convert generic bus width setup to library function
authorRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 25 Apr 2014 11:57:07 +0000 (12:57 +0100)
committerChris Ball <chris@printf.net>
Thu, 22 May 2014 11:26:27 +0000 (07:26 -0400)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Markus Pargmann <mpa@pengutronix.de>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
19 files changed:
drivers/mmc/host/sdhci-acpi.c
drivers/mmc/host/sdhci-bcm-kona.c
drivers/mmc/host/sdhci-bcm2835.c
drivers/mmc/host/sdhci-cns3xxx.c
drivers/mmc/host/sdhci-dove.c
drivers/mmc/host/sdhci-esdhc-imx.c
drivers/mmc/host/sdhci-of-arasan.c
drivers/mmc/host/sdhci-of-esdhc.c
drivers/mmc/host/sdhci-of-hlwd.c
drivers/mmc/host/sdhci-pci.c
drivers/mmc/host/sdhci-pltfm.c
drivers/mmc/host/sdhci-pxav2.c
drivers/mmc/host/sdhci-pxav3.c
drivers/mmc/host/sdhci-s3c.c
drivers/mmc/host/sdhci-sirf.c
drivers/mmc/host/sdhci-spear.c
drivers/mmc/host/sdhci-tegra.c
drivers/mmc/host/sdhci.c
drivers/mmc/host/sdhci.h

index ebb3f392b5894f6af8705604a38476b4e0048aa3..0e4ba0a4cd71b276281ebac68c4dec813c45c497 100644 (file)
@@ -103,10 +103,12 @@ static void sdhci_acpi_int_hw_reset(struct sdhci_host *host)
 
 static const struct sdhci_ops sdhci_acpi_ops_dflt = {
        .enable_dma = sdhci_acpi_enable_dma,
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 static const struct sdhci_ops sdhci_acpi_ops_int = {
        .enable_dma = sdhci_acpi_enable_dma,
+       .set_bus_width = sdhci_set_bus_width,
        .hw_reset   = sdhci_acpi_int_hw_reset,
 };
 
index 6f166e63b8172fd5484796584cb36c8291410aeb..06cdb8abb25e07fad82a532d9297d0ae35b9fca0 100644 (file)
@@ -209,6 +209,7 @@ static struct sdhci_ops sdhci_bcm_kona_ops = {
        .get_max_clock = sdhci_bcm_kona_get_max_clk,
        .get_timeout_clock = sdhci_bcm_kona_get_timeout_clock,
        .platform_send_init_74_clocks = sdhci_bcm_kona_init_74_clocks,
+       .set_bus_width = sdhci_set_bus_width,
        .card_event = sdhci_bcm_kona_card_event,
 };
 
index f6d8d67c545f882678ea40bca4f2525a77bf28bf..7ab69af979b4dd74efe447eba734635e760e31d1 100644 (file)
@@ -133,6 +133,7 @@ static const struct sdhci_ops bcm2835_sdhci_ops = {
        .read_b = bcm2835_sdhci_readb,
        .get_max_clock = sdhci_pltfm_clk_get_max_clock,
        .get_min_clock = bcm2835_sdhci_get_min_clock,
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 static const struct sdhci_pltfm_data bcm2835_sdhci_pdata = {
index f2cc26633cb2442bc67e1d46bb52ab044be02598..5e0cc9c478874e9860ae3ae70e5ce00d78358df8 100644 (file)
@@ -82,6 +82,7 @@ out:
 static const struct sdhci_ops sdhci_cns3xxx_ops = {
        .get_max_clock  = sdhci_cns3xxx_get_max_clk,
        .set_clock      = sdhci_cns3xxx_set_clock,
+       .set_bus_width  = sdhci_set_bus_width,
 };
 
 static const struct sdhci_pltfm_data sdhci_cns3xxx_pdata = {
index 736d7a2eb7ec454a0bde08de0ae9bc3ba0b006e0..8fc547a7048a6e7f046faf76eb208fade5d12f67 100644 (file)
@@ -86,6 +86,7 @@ static u32 sdhci_dove_readl(struct sdhci_host *host, int reg)
 static const struct sdhci_ops sdhci_dove_ops = {
        .read_w = sdhci_dove_readw,
        .read_l = sdhci_dove_readl,
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 static const struct sdhci_pltfm_data sdhci_dove_pdata = {
index b0b4eea8d232b9235d9edd41ab98d319e501db44..568239d84cbe70de858935439841d354c30259cb 100644 (file)
@@ -668,7 +668,7 @@ static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
        return -ENOSYS;
 }
 
-static int esdhc_pltfm_bus_width(struct sdhci_host *host, int width)
+static void esdhc_pltfm_set_bus_width(struct sdhci_host *host, int width)
 {
        u32 ctrl;
 
@@ -686,8 +686,6 @@ static int esdhc_pltfm_bus_width(struct sdhci_host *host, int width)
 
        esdhc_clrset_le(host, ESDHC_CTRL_BUSWIDTH_MASK, ctrl,
                        SDHCI_HOST_CONTROL);
-
-       return 0;
 }
 
 static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
@@ -888,7 +886,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
        .get_max_clock = esdhc_pltfm_get_max_clock,
        .get_min_clock = esdhc_pltfm_get_min_clock,
        .get_ro = esdhc_pltfm_get_ro,
-       .platform_bus_width = esdhc_pltfm_bus_width,
+       .set_bus_width = esdhc_pltfm_set_bus_width,
        .set_uhs_signaling = esdhc_set_uhs_signaling,
 };
 
index f7c7cf62437d5d359c4b216d5c0bd6e8af91a5b1..9bb1dd263a45bb9ccd55e3ad029a4e4fb4d825d4 100644 (file)
@@ -54,6 +54,7 @@ static unsigned int sdhci_arasan_get_timeout_clock(struct sdhci_host *host)
 static struct sdhci_ops sdhci_arasan_ops = {
        .get_max_clock = sdhci_pltfm_clk_get_max_clock,
        .get_timeout_clock = sdhci_arasan_get_timeout_clock,
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 static struct sdhci_pltfm_data sdhci_arasan_pdata = {
index 0b249970b1197fcc92af6e63184c72cf7c406286..86b8326e77c30b9831a6249c5c34ce44edbcdd82 100644 (file)
@@ -269,7 +269,7 @@ static void esdhc_of_platform_init(struct sdhci_host *host)
                host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
 }
 
-static int esdhc_pltfm_bus_width(struct sdhci_host *host, int width)
+static void esdhc_pltfm_set_bus_width(struct sdhci_host *host, int width)
 {
        u32 ctrl;
 
@@ -289,8 +289,6 @@ static int esdhc_pltfm_bus_width(struct sdhci_host *host, int width)
 
        clrsetbits_be32(host->ioaddr + SDHCI_HOST_CONTROL,
                        ESDHC_CTRL_BUSWIDTH_MASK, ctrl);
-
-       return 0;
 }
 
 static const struct sdhci_ops sdhci_esdhc_ops = {
@@ -310,7 +308,7 @@ static const struct sdhci_ops sdhci_esdhc_ops = {
        .platform_resume = esdhc_of_resume,
 #endif
        .adma_workaround = esdhci_of_adma_workaround,
-       .platform_bus_width = esdhc_pltfm_bus_width,
+       .set_bus_width = esdhc_pltfm_set_bus_width,
 };
 
 static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {
index 57c514a81ca558777474c699a2cac27fcc265ec9..4d5d0015e392f72427fce8dc045ffcc3477ecaaa 100644 (file)
@@ -58,6 +58,7 @@ static const struct sdhci_ops sdhci_hlwd_ops = {
        .write_l = sdhci_hlwd_writel,
        .write_w = sdhci_hlwd_writew,
        .write_b = sdhci_hlwd_writeb,
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
index fdc612120362000be42b145240acd96a306695de..8c4e9c2909b72a6ee586cb2ef8f75a0f5aab3f6b 100644 (file)
@@ -1031,7 +1031,7 @@ static int sdhci_pci_enable_dma(struct sdhci_host *host)
        return 0;
 }
 
-static int sdhci_pci_bus_width(struct sdhci_host *host, int width)
+static void sdhci_pci_set_bus_width(struct sdhci_host *host, int width)
 {
        u8 ctrl;
 
@@ -1052,8 +1052,6 @@ static int sdhci_pci_bus_width(struct sdhci_host *host, int width)
        }
 
        sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
-
-       return 0;
 }
 
 static void sdhci_pci_gpio_hw_reset(struct sdhci_host *host)
@@ -1081,7 +1079,7 @@ static void sdhci_pci_hw_reset(struct sdhci_host *host)
 
 static const struct sdhci_ops sdhci_pci_ops = {
        .enable_dma     = sdhci_pci_enable_dma,
-       .platform_bus_width     = sdhci_pci_bus_width,
+       .set_bus_width  = sdhci_pci_set_bus_width,
        .hw_reset               = sdhci_pci_hw_reset,
 };
 
index bef250e954188c3feb5d6d0889c1c32ef620de39..40b0fe224f9d40baf2b6c7c39712310ab11bcacf 100644 (file)
@@ -45,6 +45,7 @@ unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host)
 EXPORT_SYMBOL_GPL(sdhci_pltfm_clk_get_max_clock);
 
 static const struct sdhci_ops sdhci_pltfm_ops = {
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 #ifdef CONFIG_OF
index d51e061ec576a666cb2fa19edf77725ef0905cdf..d24c282e5eb8a498551b57a448d9748d356a0957 100644 (file)
@@ -88,7 +88,7 @@ static void pxav2_set_private_registers(struct sdhci_host *host, u8 mask)
        }
 }
 
-static int pxav2_mmc_set_width(struct sdhci_host *host, int width)
+static void pxav2_mmc_set_bus_width(struct sdhci_host *host, int width)
 {
        u8 ctrl;
        u16 tmp;
@@ -107,14 +107,12 @@ static int pxav2_mmc_set_width(struct sdhci_host *host, int width)
        }
        writew(tmp, host->ioaddr + SD_CE_ATA_2);
        writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
-
-       return 0;
 }
 
 static const struct sdhci_ops pxav2_sdhci_ops = {
        .get_max_clock = sdhci_pltfm_clk_get_max_clock,
        .platform_reset_exit = pxav2_set_private_registers,
-       .platform_bus_width = pxav2_mmc_set_width,
+       .set_bus_width = pxav2_mmc_set_bus_width,
 };
 
 #ifdef CONFIG_OF
index 2fd73b38c303da0d57a592c82e227e800e6c2b60..b06db03b6d810f769286a38ceb5f4ba8f6118484 100644 (file)
@@ -227,6 +227,7 @@ static const struct sdhci_ops pxav3_sdhci_ops = {
        .set_uhs_signaling = pxav3_set_uhs_signaling,
        .platform_send_init_74_clocks = pxav3_gen_init_74_clocks,
        .get_max_clock = sdhci_pltfm_clk_get_max_clock,
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 static struct sdhci_pltfm_data sdhci_pxav3_pdata = {
index c12301e90d167460a8bb1387a146f85d52353c90..c37a2fe174414eeb8ae511cffbae129d95cae740 100644 (file)
@@ -326,14 +326,14 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
 }
 
 /**
- * sdhci_s3c_platform_bus_width - support 8bit buswidth
+ * sdhci_s3c_set_bus_width - support 8bit buswidth
  * @host: The SDHCI host being queried
  * @width: MMC_BUS_WIDTH_ macro for the bus width being requested
  *
  * We have 8-bit width support but is not a v3 controller.
  * So we add platform_bus_width() and support 8bit width.
  */
-static int sdhci_s3c_platform_bus_width(struct sdhci_host *host, int width)
+static void sdhci_s3c_set_bus_width(struct sdhci_host *host, int width)
 {
        u8 ctrl;
 
@@ -355,15 +355,13 @@ static int sdhci_s3c_platform_bus_width(struct sdhci_host *host, int width)
        }
 
        sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
-
-       return 0;
 }
 
 static struct sdhci_ops sdhci_s3c_ops = {
        .get_max_clock          = sdhci_s3c_get_max_clk,
        .set_clock              = sdhci_s3c_set_clock,
        .get_min_clock          = sdhci_s3c_get_min_clock,
-       .platform_bus_width     = sdhci_s3c_platform_bus_width,
+       .set_bus_width          = sdhci_s3c_set_bus_width,
 };
 
 static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
index 696122c1b468b315968128fb5a414fee21c740bd..16fcd48f9556cd3985df3b2af6affd02f234ce60 100644 (file)
@@ -29,6 +29,7 @@ static unsigned int sdhci_sirf_get_max_clk(struct sdhci_host *host)
 
 static struct sdhci_ops sdhci_sirf_ops = {
        .get_max_clock  = sdhci_sirf_get_max_clk,
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 static struct sdhci_pltfm_data sdhci_sirf_pdata = {
index 0316dec3f0060e5ad7a8d83a35421018e210811c..dc8967b657ed5d565eed86a7b107d00ea20a0b4f 100644 (file)
@@ -38,7 +38,7 @@ struct spear_sdhci {
 
 /* sdhci ops */
 static const struct sdhci_ops sdhci_pltfm_ops = {
-       /* Nothing to do for now. */
+       .set_bus_width = sdhci_set_bus_width,
 };
 
 #ifdef CONFIG_OF
index a835898a68dd3be47fcbb720a9e83c5da3701458..feed799b827a8c761fad42fba769c835c2bd4101 100644 (file)
@@ -127,7 +127,7 @@ static void tegra_sdhci_reset_exit(struct sdhci_host *host, u8 mask)
        }
 }
 
-static int tegra_sdhci_buswidth(struct sdhci_host *host, int bus_width)
+static void tegra_sdhci_set_bus_width(struct sdhci_host *host, int bus_width)
 {
        u32 ctrl;
 
@@ -144,7 +144,6 @@ static int tegra_sdhci_buswidth(struct sdhci_host *host, int bus_width)
                        ctrl &= ~SDHCI_CTRL_4BITBUS;
        }
        sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
-       return 0;
 }
 
 static const struct sdhci_ops tegra_sdhci_ops = {
@@ -152,7 +151,7 @@ static const struct sdhci_ops tegra_sdhci_ops = {
        .read_l     = tegra_sdhci_readl,
        .read_w     = tegra_sdhci_readw,
        .write_l    = tegra_sdhci_writel,
-       .platform_bus_width = tegra_sdhci_buswidth,
+       .set_bus_width = tegra_sdhci_set_bus_width,
        .platform_reset_exit = tegra_sdhci_reset_exit,
 };
 
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);
 
index fc6f81d2f377f5d4500d3ddfc20e6fed5a62a641..0301f928eb1113036ce2e27832c3523863de301f 100644 (file)
@@ -281,8 +281,7 @@ struct sdhci_ops {
        unsigned int    (*get_max_clock)(struct sdhci_host *host);
        unsigned int    (*get_min_clock)(struct sdhci_host *host);
        unsigned int    (*get_timeout_clock)(struct sdhci_host *host);
-       int             (*platform_bus_width)(struct sdhci_host *host,
-                                              int width);
+       void            (*set_bus_width)(struct sdhci_host *host, int width);
        void (*platform_send_init_74_clocks)(struct sdhci_host *host,
                                             u8 power_mode);
        unsigned int    (*get_ro)(struct sdhci_host *host);
@@ -402,6 +401,8 @@ static inline bool sdhci_sdio_irq_enabled(struct sdhci_host *host)
        return !!(host->flags & SDHCI_SDIO_IRQ_ENABLED);
 }
 
+void sdhci_set_bus_width(struct sdhci_host *host, int width);
+
 #ifdef CONFIG_PM
 extern int sdhci_suspend_host(struct sdhci_host *host);
 extern int sdhci_resume_host(struct sdhci_host *host);