]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mmc: sdhci: convert reset into a library function
authorRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 25 Apr 2014 11:57:12 +0000 (12:57 +0100)
committerChris Ball <chris@printf.net>
Thu, 22 May 2014 11:26:28 +0000 (07:26 -0400)
Rather than having platform_reset_enter/platform_reset_exit methods,
turn the core of the reset handling into a library function which
platforms can call at the appropriate moment in their (new) reset
method.

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 0e4ba0a4cd71b276281ebac68c4dec813c45c497..aca84a6825519d094f0efa2dbc8ad6c4f406742d 100644 (file)
@@ -104,11 +104,13 @@ 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,
+       .reset = sdhci_reset,
 };
 
 static const struct sdhci_ops sdhci_acpi_ops_int = {
        .enable_dma = sdhci_acpi_enable_dma,
        .set_bus_width = sdhci_set_bus_width,
+       .reset = sdhci_reset,
        .hw_reset   = sdhci_acpi_int_hw_reset,
 };
 
index 06cdb8abb25e07fad82a532d9297d0ae35b9fca0..7b97bfab910d3196f66c2264f7454344985a10a2 100644 (file)
@@ -210,6 +210,7 @@ static struct sdhci_ops sdhci_bcm_kona_ops = {
        .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,
+       .reset = sdhci_reset,
        .card_event = sdhci_bcm_kona_card_event,
 };
 
index 7ab69af979b4dd74efe447eba734635e760e31d1..289b1c80d5fc43a2814e5e30c283e65df039db0f 100644 (file)
@@ -134,6 +134,7 @@ static const struct sdhci_ops bcm2835_sdhci_ops = {
        .get_max_clock = sdhci_pltfm_clk_get_max_clock,
        .get_min_clock = bcm2835_sdhci_get_min_clock,
        .set_bus_width = sdhci_set_bus_width,
+       .reset = sdhci_reset,
 };
 
 static const struct sdhci_pltfm_data bcm2835_sdhci_pdata = {
index 5e0cc9c478874e9860ae3ae70e5ce00d78358df8..87af66bb1ea89f2abc6f4b6f2a8e97c7d42fa004 100644 (file)
@@ -83,6 +83,7 @@ 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,
+       .reset          = sdhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_cns3xxx_pdata = {
index 8fc547a7048a6e7f046faf76eb208fade5d12f67..1408cc11d8812307034a258d4d9ab6c19fafc790 100644 (file)
@@ -87,6 +87,7 @@ 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,
+       .reset = sdhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_dove_pdata = {
index 568239d84cbe70de858935439841d354c30259cb..b1d74fa33c5fe1cb2961b68160d99fe4e55fdde5 100644 (file)
@@ -888,6 +888,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
        .get_ro = esdhc_pltfm_get_ro,
        .set_bus_width = esdhc_pltfm_set_bus_width,
        .set_uhs_signaling = esdhc_set_uhs_signaling,
+       .reset = sdhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
index 9bb1dd263a45bb9ccd55e3ad029a4e4fb4d825d4..faef21740584658b8586e815f340146b500a98f0 100644 (file)
@@ -55,6 +55,7 @@ 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,
+       .reset = sdhci_reset,
 };
 
 static struct sdhci_pltfm_data sdhci_arasan_pdata = {
index 86b8326e77c30b9831a6249c5c34ce44edbcdd82..4530f9957f202d8ef0ee83b7a6ae3135f705f682 100644 (file)
@@ -309,6 +309,7 @@ static const struct sdhci_ops sdhci_esdhc_ops = {
 #endif
        .adma_workaround = esdhci_of_adma_workaround,
        .set_bus_width = esdhc_pltfm_set_bus_width,
+       .reset = sdhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {
index 4d5d0015e392f72427fce8dc045ffcc3477ecaaa..fb01958cb18e6127ef7e82c8f2ea60bfa6eb30a7 100644 (file)
@@ -59,6 +59,7 @@ static const struct sdhci_ops sdhci_hlwd_ops = {
        .write_w = sdhci_hlwd_writew,
        .write_b = sdhci_hlwd_writeb,
        .set_bus_width = sdhci_set_bus_width,
+       .reset = sdhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
index 8c4e9c2909b72a6ee586cb2ef8f75a0f5aab3f6b..87f9dd91f68c0727d5db7c096d9248b4089aab76 100644 (file)
@@ -1080,6 +1080,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,
        .set_bus_width  = sdhci_pci_set_bus_width,
+       .reset          = sdhci_reset,
        .hw_reset               = sdhci_pci_hw_reset,
 };
 
index 40b0fe224f9d40baf2b6c7c39712310ab11bcacf..bfbf467b61c7d719475b36d3ab496216c757636b 100644 (file)
@@ -46,6 +46,7 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_clk_get_max_clock);
 
 static const struct sdhci_ops sdhci_pltfm_ops = {
        .set_bus_width = sdhci_set_bus_width,
+       .reset = sdhci_reset,
 };
 
 #ifdef CONFIG_OF
index d24c282e5eb8a498551b57a448d9748d356a0957..2eee0c8b88ebcfe2061d9d1fae38d3e267174a03 100644 (file)
 #define MMC_CARD               0x1000
 #define MMC_WIDTH              0x0100
 
-static void pxav2_set_private_registers(struct sdhci_host *host, u8 mask)
+static void pxav2_reset(struct sdhci_host *host, u8 mask)
 {
        struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
        struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
 
+       sdhci_reset(host, mask);
+
        if (mask == SDHCI_RESET_ALL) {
                u16 tmp = 0;
 
@@ -111,8 +113,8 @@ static void pxav2_mmc_set_bus_width(struct sdhci_host *host, int width)
 
 static const struct sdhci_ops pxav2_sdhci_ops = {
        .get_max_clock = sdhci_pltfm_clk_get_max_clock,
-       .platform_reset_exit = pxav2_set_private_registers,
        .set_bus_width = pxav2_mmc_set_bus_width,
+       .reset         = pxav2_reset,
 };
 
 #ifdef CONFIG_OF
index b06db03b6d810f769286a38ceb5f4ba8f6118484..86564233ae9372b4b9c644159d478ba0842a81bd 100644 (file)
@@ -112,11 +112,13 @@ static int mv_conf_mbus_windows(struct platform_device *pdev,
        return 0;
 }
 
-static void pxav3_set_private_registers(struct sdhci_host *host, u8 mask)
+static void pxav3_reset(struct sdhci_host *host, u8 mask)
 {
        struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
        struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
 
+       sdhci_reset(host, mask);
+
        if (mask == SDHCI_RESET_ALL) {
                /*
                 * tune timing of read data/command when crc error happen
@@ -223,11 +225,11 @@ static int pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
 }
 
 static const struct sdhci_ops pxav3_sdhci_ops = {
-       .platform_reset_exit = pxav3_set_private_registers,
        .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,
+       .reset = pxav3_reset,
 };
 
 static struct sdhci_pltfm_data sdhci_pxav3_pdata = {
index c37a2fe174414eeb8ae511cffbae129d95cae740..155241883751463d14b684783ef0f9fade91dead 100644 (file)
@@ -362,6 +362,7 @@ static struct sdhci_ops sdhci_s3c_ops = {
        .set_clock              = sdhci_s3c_set_clock,
        .get_min_clock          = sdhci_s3c_get_min_clock,
        .set_bus_width          = sdhci_s3c_set_bus_width,
+       .reset                  = sdhci_reset,
 };
 
 static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
index 16fcd48f9556cd3985df3b2af6affd02f234ce60..5d79e10e1ba2c7cf7139c467559ddad4b3090ce3 100644 (file)
@@ -30,6 +30,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,
+       .reset = sdhci_reset,
 };
 
 static struct sdhci_pltfm_data sdhci_sirf_pdata = {
index dc8967b657ed5d565eed86a7b107d00ea20a0b4f..c2a2bedc8813d275362914b37d6e1072566278ce 100644 (file)
@@ -39,6 +39,7 @@ struct spear_sdhci {
 /* sdhci ops */
 static const struct sdhci_ops sdhci_pltfm_ops = {
        .set_bus_width = sdhci_set_bus_width,
+       .reset = sdhci_reset,
 };
 
 #ifdef CONFIG_OF
index feed799b827a8c761fad42fba769c835c2bd4101..7754c0319fdaf35d75fe9ea7905ef4685c649d98 100644 (file)
@@ -108,12 +108,14 @@ static unsigned int tegra_sdhci_get_ro(struct sdhci_host *host)
        return mmc_gpio_get_ro(host->mmc);
 }
 
-static void tegra_sdhci_reset_exit(struct sdhci_host *host, u8 mask)
+static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask)
 {
        struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
        struct sdhci_tegra *tegra_host = pltfm_host->priv;
        const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
 
+       sdhci_reset(host, mask);
+
        if (!(mask & SDHCI_RESET_ALL))
                return;
 
@@ -152,7 +154,7 @@ static const struct sdhci_ops tegra_sdhci_ops = {
        .read_w     = tegra_sdhci_readw,
        .write_l    = tegra_sdhci_writel,
        .set_bus_width = tegra_sdhci_set_bus_width,
-       .platform_reset_exit = tegra_sdhci_reset_exit,
+       .reset      = tegra_sdhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_tegra20_pdata = {
index 15f6c5e08e9d541e3fe4f8634f4230b184d9a823..5e25147e92f77629c3a072efd5d3fd16da3aca66 100644 (file)
@@ -163,17 +163,9 @@ static void sdhci_disable_card_detection(struct sdhci_host *host)
        sdhci_set_card_detection(host, false);
 }
 
-static void sdhci_reset(struct sdhci_host *host, u8 mask)
+void sdhci_reset(struct sdhci_host *host, u8 mask)
 {
        unsigned long timeout;
-       if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
-               if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
-                       SDHCI_CARD_PRESENT))
-                       return;
-       }
-
-       if (host->ops->platform_reset_enter)
-               host->ops->platform_reset_enter(host, mask);
 
        sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET);
 
@@ -198,9 +190,18 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
                timeout--;
                mdelay(1);
        }
+}
+EXPORT_SYMBOL_GPL(sdhci_reset);
+
+static void sdhci_do_reset(struct sdhci_host *host, u8 mask)
+{
+       if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
+               if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
+                       SDHCI_CARD_PRESENT))
+                       return;
+       }
 
-       if (host->ops->platform_reset_exit)
-               host->ops->platform_reset_exit(host, mask);
+       host->ops->reset(host, mask);
 
        if (host->quirks & SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET) {
                sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
@@ -218,9 +219,9 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
 static void sdhci_init(struct sdhci_host *host, int soft)
 {
        if (soft)
-               sdhci_reset(host, SDHCI_RESET_CMD|SDHCI_RESET_DATA);
+               sdhci_do_reset(host, SDHCI_RESET_CMD|SDHCI_RESET_DATA);
        else
-               sdhci_reset(host, SDHCI_RESET_ALL);
+               sdhci_do_reset(host, SDHCI_RESET_ALL);
 
        host->ier = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
                    SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT |
@@ -962,8 +963,8 @@ static void sdhci_finish_data(struct sdhci_host *host)
                 * upon error conditions.
                 */
                if (data->error) {
-                       sdhci_reset(host, SDHCI_RESET_CMD);
-                       sdhci_reset(host, SDHCI_RESET_DATA);
+                       sdhci_do_reset(host, SDHCI_RESET_CMD);
+                       sdhci_do_reset(host, SDHCI_RESET_DATA);
                }
 
                sdhci_send_command(host, data->stop);
@@ -1587,7 +1588,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
         * it on each ios seems to solve the problem.
         */
        if(host->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
-               sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
+               sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
 
        mmiowb();
        spin_unlock_irqrestore(&host->lock, flags);
@@ -2086,8 +2087,8 @@ static void sdhci_card_event(struct mmc_host *mmc)
                pr_err("%s: Resetting controller.\n",
                        mmc_hostname(host->mmc));
 
-               sdhci_reset(host, SDHCI_RESET_CMD);
-               sdhci_reset(host, SDHCI_RESET_DATA);
+               sdhci_do_reset(host, SDHCI_RESET_CMD);
+               sdhci_do_reset(host, SDHCI_RESET_DATA);
 
                host->mrq->cmd->error = -ENOMEDIUM;
                tasklet_schedule(&host->finish_tasklet);
@@ -2155,8 +2156,8 @@ static void sdhci_tasklet_finish(unsigned long param)
 
                /* Spec says we should do both at the same time, but Ricoh
                   controllers do not like that. */
-               sdhci_reset(host, SDHCI_RESET_CMD);
-               sdhci_reset(host, SDHCI_RESET_DATA);
+               sdhci_do_reset(host, SDHCI_RESET_CMD);
+               sdhci_do_reset(host, SDHCI_RESET_DATA);
        }
 
        host->mrq = NULL;
@@ -2791,7 +2792,7 @@ int sdhci_add_host(struct sdhci_host *host)
        if (debug_quirks2)
                host->quirks2 = debug_quirks2;
 
-       sdhci_reset(host, SDHCI_RESET_ALL);
+       sdhci_do_reset(host, SDHCI_RESET_ALL);
 
        host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
        host->version = (host->version & SDHCI_SPEC_VER_MASK)
@@ -3275,7 +3276,7 @@ int sdhci_add_host(struct sdhci_host *host)
 
 #ifdef SDHCI_USE_LEDS_CLASS
 reset:
-       sdhci_reset(host, SDHCI_RESET_ALL);
+       sdhci_do_reset(host, SDHCI_RESET_ALL);
        sdhci_writel(host, 0, SDHCI_INT_ENABLE);
        sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
        free_irq(host->irq, host);
@@ -3317,7 +3318,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 #endif
 
        if (!dead)
-               sdhci_reset(host, SDHCI_RESET_ALL);
+               sdhci_do_reset(host, SDHCI_RESET_ALL);
 
        sdhci_writel(host, 0, SDHCI_INT_ENABLE);
        sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
index 0301f928eb1113036ce2e27832c3523863de301f..7d84cb3b0e004ea2f389166f5772b53c28f4570a 100644 (file)
@@ -285,8 +285,7 @@ struct sdhci_ops {
        void (*platform_send_init_74_clocks)(struct sdhci_host *host,
                                             u8 power_mode);
        unsigned int    (*get_ro)(struct sdhci_host *host);
-       void    (*platform_reset_enter)(struct sdhci_host *host, u8 mask);
-       void    (*platform_reset_exit)(struct sdhci_host *host, u8 mask);
+       void            (*reset)(struct sdhci_host *host, u8 mask);
        int     (*platform_execute_tuning)(struct sdhci_host *host, u32 opcode);
        int     (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs);
        void    (*hw_reset)(struct sdhci_host *host);
@@ -402,6 +401,7 @@ static inline bool sdhci_sdio_irq_enabled(struct sdhci_host *host)
 }
 
 void sdhci_set_bus_width(struct sdhci_host *host, int width);
+void sdhci_reset(struct sdhci_host *host, u8 mask);
 
 #ifdef CONFIG_PM
 extern int sdhci_suspend_host(struct sdhci_host *host);