Merge branch '2021-07-28-build-improvements'
[platform/kernel/u-boot.git] / drivers / mmc / omap_hsmmc.c
index 5d0cfb2..306ce0f 100644 (file)
@@ -25,6 +25,7 @@
 #include <config.h>
 #include <common.h>
 #include <cpu_func.h>
+#include <log.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <mmc.h>
@@ -33,6 +34,8 @@
 #if defined(CONFIG_OMAP54XX) || defined(CONFIG_OMAP44XX)
 #include <palmas.h>
 #endif
+#include <asm/cache.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/arch/mmc_host_def.h>
 #ifdef CONFIG_OMAP54XX
 #include <asm/arch/mux.h>
 #endif
 #include <dm.h>
+#include <dm/devres.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/err.h>
 #include <power/regulator.h>
 #include <thermal.h>
 
@@ -54,7 +61,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /* simplify defines to OMAP_HSMMC_USE_GPIO */
 #if (defined(CONFIG_OMAP_GPIO) && !defined(CONFIG_SPL_BUILD)) || \
-       (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO_SUPPORT))
+       (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO))
 #define OMAP_HSMMC_USE_GPIO
 #else
 #undef OMAP_HSMMC_USE_GPIO
@@ -169,15 +176,18 @@ static inline struct omap_hsmmc_data *omap_hsmmc_get_data(struct mmc *mmc)
        return (struct omap_hsmmc_data *)mmc->priv;
 #endif
 }
+
+#if defined(CONFIG_OMAP34XX) || defined(CONFIG_IODELAY_RECALIBRATION)
 static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
 {
 #if CONFIG_IS_ENABLED(DM_MMC)
-       struct omap_hsmmc_plat *plat = dev_get_platdata(mmc->dev);
+       struct omap_hsmmc_plat *plat = dev_get_plat(mmc->dev);
        return &plat->cfg;
 #else
        return &((struct omap_hsmmc_data *)mmc->priv)->cfg;
 #endif
 }
+#endif
 
 #if defined(OMAP_HSMMC_USE_GPIO) && !CONFIG_IS_ENABLED(DM_MMC)
 static int omap_mmc_setup_gpio_in(int gpio, const char *label)
@@ -390,7 +400,6 @@ static void omap_hsmmc_set_timing(struct mmc *mmc)
                break;
        case MMC_LEGACY:
        case MMC_HS:
-       case SD_LEGACY:
        case UHS_SDR12:
                val |= AC12_UHSMC_SDR12;
                break;
@@ -835,7 +844,7 @@ static int omap_hsmmc_init_setup(struct mmc *mmc)
        omap_hsmmc_conf_bus_power(mmc, (reg_val & VS33_3V3SUP) ?
                          MMC_SIGNAL_VOLTAGE_330 : MMC_SIGNAL_VOLTAGE_180);
 #else
-       writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V0, &mmc_base->hctl);
+       writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V3, &mmc_base->hctl);
        writel(readl(&mmc_base->capa) | VS33_3V3SUP | VS18_1V8SUP,
                &mmc_base->capa);
 #endif
@@ -1890,9 +1899,9 @@ __weak const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr)
 }
 #endif
 
-static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
+static int omap_hsmmc_of_to_plat(struct udevice *dev)
 {
-       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
+       struct omap_hsmmc_plat *plat = dev_get_plat(dev);
        struct omap_mmc_of_data *of_data = (void *)dev_get_driver_data(dev);
 
        struct mmc_config *cfg = &plat->cfg;
@@ -1903,7 +1912,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
        int node = dev_of_offset(dev);
        int ret;
 
-       plat->base_addr = map_physmem(devfdt_get_addr(dev),
+       plat->base_addr = map_physmem(dev_read_addr(dev),
                                      sizeof(struct hsmmc *),
                                      MAP_NOCACHE);
 
@@ -1925,7 +1934,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
                plat->controller_flags |= of_data->controller_flags;
 
 #ifdef CONFIG_OMAP54XX
-       fixups = platform_fixups_mmc(devfdt_get_addr(dev));
+       fixups = platform_fixups_mmc(dev_read_addr(dev));
        if (fixups) {
                plat->hw_rev = fixups->hw_rev;
                cfg->host_caps &= ~fixups->unsupported_caps;
@@ -1941,14 +1950,14 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
 
 static int omap_hsmmc_bind(struct udevice *dev)
 {
-       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
+       struct omap_hsmmc_plat *plat = dev_get_plat(dev);
        plat->mmc = calloc(1, sizeof(struct mmc));
        return mmc_bind(dev, plat->mmc, &plat->cfg);
 }
 #endif
 static int omap_hsmmc_probe(struct udevice *dev)
 {
-       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
+       struct omap_hsmmc_plat *plat = dev_get_plat(dev);
        struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
        struct omap_hsmmc_data *priv = dev_get_priv(dev);
        struct mmc_config *cfg = &plat->cfg;
@@ -2020,15 +2029,15 @@ U_BOOT_DRIVER(omap_hsmmc) = {
        .id     = UCLASS_MMC,
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
        .of_match = omap_hsmmc_ids,
-       .ofdata_to_platdata = omap_hsmmc_ofdata_to_platdata,
-       .platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat),
+       .of_to_plat = omap_hsmmc_of_to_plat,
+       .plat_auto      = sizeof(struct omap_hsmmc_plat),
 #endif
 #ifdef CONFIG_BLK
        .bind = omap_hsmmc_bind,
 #endif
        .ops = &omap_hsmmc_ops,
        .probe  = omap_hsmmc_probe,
-       .priv_auto_alloc_size = sizeof(struct omap_hsmmc_data),
+       .priv_auto      = sizeof(struct omap_hsmmc_data),
 #if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags  = DM_FLAG_PRE_RELOC,
 #endif