mmc: omap_hsmmc: move the mmc_config to platdata when DM_MMC is used
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Wed, 22 Mar 2017 15:00:33 +0000 (16:00 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 30 Mar 2017 05:19:51 +0000 (14:19 +0900)
This is a preparation work for the support of CONFIG_BLK.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
drivers/mmc/omap_hsmmc.c

index d985ac7b144edd1f3e4d29f2e2cbb98a4fea293c..104129f4cddf94e2f03beb44fdfb8d0668365366 100644 (file)
@@ -56,9 +56,15 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SYSCTL_SRC     (1 << 25)
 #define SYSCTL_SRD     (1 << 26)
 
+struct omap_hsmmc_plat {
+       struct mmc_config cfg;
+};
+
 struct omap_hsmmc_data {
        struct hsmmc *base_addr;
+#ifndef CONFIG_DM_MMC
        struct mmc_config cfg;
+#endif
 #ifdef OMAP_HSMMC_USE_GPIO
 #ifdef CONFIG_DM_MMC
        struct gpio_desc cd_gpio;       /* Change Detect GPIO */
@@ -85,6 +91,15 @@ static inline struct omap_hsmmc_data *omap_hsmmc_get_data(struct mmc *mmc)
 #else
        return (struct omap_hsmmc_data *)mmc->priv;
 #endif
+}
+static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
+{
+#ifdef CONFIG_DM_MMC
+       struct omap_hsmmc_plat *plat = dev_get_platdata(mmc->dev);
+       return &plat->cfg;
+#else
+       return &((struct omap_hsmmc_data *)mmc->priv)->cfg;
+#endif
 }
 
  #if defined(OMAP_HSMMC_USE_GPIO) && !defined(CONFIG_DM_MMC)
@@ -111,6 +126,7 @@ static int omap_mmc_setup_gpio_in(int gpio, const char *label)
 static unsigned char mmc_board_init(struct mmc *mmc)
 {
 #if defined(CONFIG_OMAP34XX)
+       struct mmc_config *cfg = omap_hsmmc_get_cfg(mmc);
        t2_t *t2_base = (t2_t *)T2_BASE;
        struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
        u32 pbias_lite;
@@ -151,7 +167,7 @@ static unsigned char mmc_board_init(struct mmc *mmc)
                &t2_base->devconf1);
 
        /* Change from default of 52MHz to 26MHz if necessary */
-       if (!(mmc->cfg->host_caps & MMC_MODE_HS_52MHz))
+       if (!(cfg->host_caps & MMC_MODE_HS_52MHz))
                writel(readl(&t2_base->ctl_prog_io1) & ~CTLPROGIO1SPEEDCTRL,
                        &t2_base->ctl_prog_io1);
 
@@ -759,14 +775,14 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,
 static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
 {
        struct omap_hsmmc_data *priv = dev_get_priv(dev);
+       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
+       struct mmc_config *cfg = &plat->cfg;
        const void *fdt = gd->fdt_blob;
        int node = dev_of_offset(dev);
-       struct mmc_config *cfg;
        int val;
 
        priv->base_addr = map_physmem(dev_get_addr(dev), sizeof(struct hsmmc *),
                                      MAP_NOCACHE);
-       cfg = &priv->cfg;
 
        cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
        val = fdtdec_get_int(fdt, node, "bus-width", -1);
@@ -800,12 +816,12 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
 
 static int omap_hsmmc_probe(struct udevice *dev)
 {
+       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
        struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
        struct omap_hsmmc_data *priv = dev_get_priv(dev);
-       struct mmc_config *cfg;
+       struct mmc_config *cfg = &plat->cfg;
        struct mmc *mmc;
 
-       cfg = &priv->cfg;
        cfg->name = "OMAP SD/MMC";
        cfg->ops = &omap_hsmmc_ops;
 
@@ -838,5 +854,6 @@ U_BOOT_DRIVER(omap_hsmmc) = {
        .ofdata_to_platdata = omap_hsmmc_ofdata_to_platdata,
        .probe  = omap_hsmmc_probe,
        .priv_auto_alloc_size = sizeof(struct omap_hsmmc_data),
+       .platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat),
 };
 #endif