]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
dm: mmc: dwmmc: Support CONFIG_BLK
authorSimon Glass <sjg@chromium.org>
Sat, 14 May 2016 20:03:07 +0000 (14:03 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 27 May 2016 16:23:09 +0000 (10:23 -0600)
Add support for using driver model for block devices in this driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/mmc/dw_mmc.c
include/dwmmc.h

index 7329f40d345b53560da6d19465b7aab0eed3345f..74a2663c8bf976f27b6cce2a5fe2f863cf54b8da 100644 (file)
@@ -454,27 +454,40 @@ static const struct mmc_ops dwmci_ops = {
        .init           = dwmci_init,
 };
 
-int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
+void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
+                    uint caps, u32 max_clk, u32 min_clk)
 {
-       host->cfg.name = host->name;
-       host->cfg.ops = &dwmci_ops;
-       host->cfg.f_min = min_clk;
-       host->cfg.f_max = max_clk;
+       cfg->name = name;
+       cfg->ops = &dwmci_ops;
+       cfg->f_min = min_clk;
+       cfg->f_max = max_clk;
 
-       host->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
+       cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
 
-       host->cfg.host_caps = host->caps;
+       cfg->host_caps = caps;
 
-       if (host->buswidth == 8) {
-               host->cfg.host_caps |= MMC_MODE_8BIT;
-               host->cfg.host_caps &= ~MMC_MODE_4BIT;
+       if (buswidth == 8) {
+               cfg->host_caps |= MMC_MODE_8BIT;
+               cfg->host_caps &= ~MMC_MODE_4BIT;
        } else {
-               host->cfg.host_caps |= MMC_MODE_4BIT;
-               host->cfg.host_caps &= ~MMC_MODE_8BIT;
+               cfg->host_caps |= MMC_MODE_4BIT;
+               cfg->host_caps &= ~MMC_MODE_8BIT;
        }
-       host->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz;
+       cfg->host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz;
+
+       cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
+}
 
-       host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
+#ifdef CONFIG_BLK
+int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg)
+{
+       return mmc_bind(dev, mmc, cfg);
+}
+#else
+int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
+{
+       dwmci_setup_cfg(&host->cfg, host->name, host->buswidth, host->caps,
+                       max_clk, min_clk);
 
        host->mmc = mmc_create(&host->cfg, host);
        if (host->mmc == NULL)
@@ -482,3 +495,4 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
 
        return 0;
 }
+#endif
index 05b0817fe1e1834b10bef69f892bd3fdc3d083c6..335af51fdf42e72f4e19058cfdff4a1f29dfe520 100644 (file)
@@ -180,8 +180,9 @@ struct dwmci_host {
         * @freq:       Frequency the host is trying to achieve
         */
        unsigned int (*get_mmc_clk)(struct dwmci_host *host, uint freq);
-
+#ifndef CONFIG_BLK
        struct mmc_config cfg;
+#endif
 
        /* use fifo mode to read and write data */
        bool fifo_mode;
@@ -223,5 +224,9 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg)
        return readb(host->ioaddr + reg);
 }
 
+void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,
+                    uint caps, u32 max_clk, u32 min_clk);
+int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg);
+
 int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk);
 #endif /* __DWMMC_HW_H */