]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mmc: tmio: move MFD variant reset to a platform hook
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 10 Oct 2018 03:51:31 +0000 (12:51 +0900)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 15 Oct 2018 12:39:45 +0000 (14:39 +0200)
CTL_RESET_SDIO register is specific to the TMIO MFD (tmio_mmc.c).

Add a new hook host->reset() for performing a platform-specific
reset sequence, and move CTL_RESET_SDIO over there.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/tmio_mmc.c
drivers/mmc/host/tmio_mmc.h
drivers/mmc/host/tmio_mmc_core.c

index 29bda8224ae7a47f4d6861f89f70a0f51032db31..651e325238e6fc71c9d0c0d6336d94ac5dae02a6 100644 (file)
@@ -70,6 +70,22 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
        tmio_mmc_clk_start(host);
 }
 
+static void tmio_mmc_reset(struct tmio_mmc_host *host)
+{
+       /* FIXME - should we set stop clock reg here */
+       sd_ctrl_write16(host, CTL_RESET_SD, 0x0000);
+       sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000);
+       usleep_range(10000, 11000);
+       sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
+       sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001);
+       usleep_range(10000, 11000);
+
+       if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
+               sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
+               sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
+       }
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int tmio_mmc_suspend(struct device *dev)
 {
@@ -148,6 +164,7 @@ static int tmio_mmc_probe(struct platform_device *pdev)
        /* SD control register space size is 0x200, 0x400 for bus_shift=1 */
        host->bus_shift = resource_size(res) >> 10;
        host->set_clock = tmio_mmc_set_clock;
+       host->reset = tmio_mmc_reset;
 
        host->mmc->f_max = pdata->hclk;
        host->mmc->f_min = pdata->hclk / 512;
index a9972dc60c6fbb8ce621e08e0f38e13dcebcd22d..1a23a3d14bd6d88070e6575089bd33d9e0ab20b4 100644 (file)
@@ -172,6 +172,7 @@ struct tmio_mmc_host {
        int (*multi_io_quirk)(struct mmc_card *card,
                              unsigned int direction, int blk_size);
        int (*write16_hook)(struct tmio_mmc_host *host, int addr);
+       void (*reset)(struct tmio_mmc_host *host);
        void (*hw_reset)(struct tmio_mmc_host *host);
        void (*prepare_tuning)(struct tmio_mmc_host *host, unsigned long tap);
        bool (*check_scc_error)(struct tmio_mmc_host *host);
index f05c3a622f090cd6142fd61def7437ce487fd406..40fa0a88208d52b2778401476aec5668528f8f73 100644 (file)
@@ -161,19 +161,14 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host)
 {
        /* FIXME - should we set stop clock reg here */
        sd_ctrl_write16(host, CTL_RESET_SD, 0x0000);
-       if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG)
-               sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000);
        usleep_range(10000, 11000);
        sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
-       if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG)
-               sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001);
        usleep_range(10000, 11000);
 
        if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
                sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
                sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
        }
-
 }
 
 static void tmio_mmc_reset_work(struct work_struct *work)
@@ -214,7 +209,7 @@ static void tmio_mmc_reset_work(struct work_struct *work)
 
        spin_unlock_irqrestore(&host->lock, flags);
 
-       tmio_mmc_reset(host);
+       host->reset(host);
 
        /* Ready for new calls */
        host->mrq = NULL;
@@ -1209,6 +1204,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
                                  mmc->caps & MMC_CAP_NEEDS_POLL ||
                                  !mmc_card_is_removable(mmc));
 
+       if (!_host->reset)
+               _host->reset = tmio_mmc_reset;
+
        /*
         * On Gen2+, eMMC with NONREMOVABLE currently fails because native
         * hotplug gets disabled. It seems RuntimePM related yet we need further
@@ -1230,7 +1228,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
                _host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
 
        _host->set_clock(_host, 0);
-       tmio_mmc_reset(_host);
+       _host->reset(_host);
 
        _host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
        tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
@@ -1330,7 +1328,7 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
 {
        struct tmio_mmc_host *host = dev_get_drvdata(dev);
 
-       tmio_mmc_reset(host);
+       host->reset(host);
        tmio_mmc_clk_enable(host);
 
        if (host->clk_cache)