X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fmmc%2Fexynos_dw_mmc.c;h=435ccac59421d93b0d352f93fc4f67e00ae89595;hb=0223462b373b975d970fa86e5e1a7eadd1d41820;hp=283befccfbe6ceca869b4cc51c1df0628570aaa1;hpb=66669fcf809c1e3ff644b12e04e625d3737ffd8e;p=oweals%2Fu-boot.git diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 283befccfb..435ccac594 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -1,21 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2012 SAMSUNG Electronics * Jaehoon Chung - * - * SPDX-License-Identifier: GPL-2.0+ */ #include #include #include -#include +#include #include +#include #include #include #include #include #include -#include #define DWMMC_MAX_CH_NUM 4 #define DWMMC_MAX_FREQ 52000000 @@ -47,8 +46,12 @@ struct dwmci_exynos_priv_data { */ static void exynos_dwmci_clksel(struct dwmci_host *host) { +#ifdef CONFIG_DM_MMC + struct dwmci_exynos_priv_data *priv = + container_of(host, struct dwmci_exynos_priv_data, host); +#else struct dwmci_exynos_priv_data *priv = host->priv; - +#endif dwmci_writel(host, DWMCI_CLKSEL, priv->sdr_timing); } @@ -147,17 +150,11 @@ static int do_dwmci_init(struct dwmci_host *host) } static int exynos_dwmci_get_config(const void *blob, int node, - struct dwmci_host *host) + struct dwmci_host *host, + struct dwmci_exynos_priv_data *priv) { int err = 0; u32 base, timing[3]; - struct dwmci_exynos_priv_data *priv; - - priv = malloc(sizeof(struct dwmci_exynos_priv_data)); - if (!priv) { - error("dwmci_exynos_priv_data malloc fail!\n"); - return -ENOMEM; - } /* Extract device id for each mmc channel */ host->dev_id = pinmux_decode_periph_id(blob, node); @@ -206,14 +203,13 @@ static int exynos_dwmci_get_config(const void *blob, int node, host->bus_hz = fdtdec_get_int(blob, node, "bus_hz", 0); host->div = fdtdec_get_int(blob, node, "div", 0); - host->priv = priv; - return 0; } static int exynos_dwmci_process_node(const void *blob, int node_list[], int count) { + struct dwmci_exynos_priv_data *priv; struct dwmci_host *host; int i, node, err; @@ -222,11 +218,20 @@ static int exynos_dwmci_process_node(const void *blob, if (node <= 0) continue; host = &dwmci_host[i]; - err = exynos_dwmci_get_config(blob, node, host); + + priv = malloc(sizeof(struct dwmci_exynos_priv_data)); + if (!priv) { + pr_err("dwmci_exynos_priv_data malloc fail!\n"); + return -ENOMEM; + } + + err = exynos_dwmci_get_config(blob, node, host, priv); if (err) { printf("%s: failed to decode dev %d\n", __func__, i); + free(priv); return err; } + host->priv = priv; do_dwmci_init(host); } @@ -264,15 +269,15 @@ static int exynos_dwmmc_probe(struct udevice *dev) struct dwmci_host *host = &priv->host; int err; - err = exynos_dwmci_get_config(gd->fdt_blob, dev->of_offset, host); + err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host, + priv); if (err) return err; err = do_dwmci_init(host); if (err) return err; - dwmci_setup_cfg(&plat->cfg, host->name, host->buswidth, host->caps, - DWMMC_MAX_FREQ, DWMMC_MIN_FREQ); + dwmci_setup_cfg(&plat->cfg, host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ); host->mmc = &plat->mmc; host->mmc->priv = &priv->host; host->priv = dev; @@ -284,17 +289,13 @@ static int exynos_dwmmc_probe(struct udevice *dev) static int exynos_dwmmc_bind(struct udevice *dev) { struct exynos_mmc_plat *plat = dev_get_platdata(dev); - int ret; - - ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); - if (ret) - return ret; - return 0; + return dwmci_bind(dev, &plat->mmc, &plat->cfg); } static const struct udevice_id exynos_dwmmc_ids[] = { { .compatible = "samsung,exynos4412-dw-mshc" }, + { .compatible = "samsung,exynos-dwmmc" }, { } };