]> git.sur5r.net Git - u-boot/blobdiff - drivers/mmc/rockchip_sdhci.c
Merge git://www.denx.de/git/u-boot-marvell
[u-boot] / drivers / mmc / rockchip_sdhci.c
index 023c29be0a7e8aa060deb99ea5011c630b44828c..13588647014c8846cfcacc5f0220e1e7ade8f2d2 100644 (file)
@@ -12,7 +12,9 @@
 #include <libfdt.h>
 #include <malloc.h>
 #include <sdhci.h>
+#include <clk.h>
 
+DECLARE_GLOBAL_DATA_PTR;
 /* 400KHz is max freq for card ID etc. Use that as min */
 #define EMMC_MIN_FREQ  400000
 
@@ -32,16 +34,25 @@ static int arasan_sdhci_probe(struct udevice *dev)
        struct rockchip_sdhc_plat *plat = dev_get_platdata(dev);
        struct rockchip_sdhc *prv = dev_get_priv(dev);
        struct sdhci_host *host = &prv->host;
-       int ret;
-       u32 caps;
+       int max_frequency, ret;
+       struct clk clk;
+
+
+       max_frequency = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                       "max-frequency", 0);
+       ret = clk_get_by_index(dev, 0, &clk);
+       if (!ret) {
+               ret = clk_set_rate(&clk, max_frequency);
+               if (IS_ERR_VALUE(ret))
+                       printf("%s clk set rate fail!\n", __func__);
+       } else {
+               printf("%s fail to get clk\n", __func__);
+       }
 
-       host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
        host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD;
+       host->max_clk = max_frequency;
 
-       caps = sdhci_readl(host, SDHCI_CAPABILITIES);
-       ret = sdhci_setup_cfg(&plat->cfg, dev->name, host->bus_width,
-                       caps, CONFIG_ROCKCHIP_SDHCI_MAX_FREQ, EMMC_MIN_FREQ,
-                       host->version, host->quirks, 0);
+       ret = sdhci_setup_cfg(&plat->cfg, host, 0, EMMC_MIN_FREQ);
 
        host->mmc = &plat->mmc;
        if (ret)
@@ -66,13 +77,8 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
 static int rockchip_sdhci_bind(struct udevice *dev)
 {
        struct rockchip_sdhc_plat *plat = dev_get_platdata(dev);
-       int ret;
-
-       ret = sdhci_bind(dev, &plat->mmc, &plat->cfg);
-       if (ret)
-               return ret;
 
-       return 0;
+       return sdhci_bind(dev, &plat->mmc, &plat->cfg);
 }
 
 static const struct udevice_id arasan_sdhci_ids[] = {