2 * (C) Copyright 2016 Fuzhou Rockchip Electronics Co., Ltd
4 * Rockchip SD Host Controller Interface
6 * SPDX-License-Identifier: GPL-2.0+
17 DECLARE_GLOBAL_DATA_PTR;
18 /* 400KHz is max freq for card ID etc. Use that as min */
19 #define EMMC_MIN_FREQ 400000
21 struct rockchip_sdhc_plat {
22 struct mmc_config cfg;
26 struct rockchip_sdhc {
27 struct sdhci_host host;
31 static int arasan_sdhci_probe(struct udevice *dev)
33 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
34 struct rockchip_sdhc_plat *plat = dev_get_platdata(dev);
35 struct rockchip_sdhc *prv = dev_get_priv(dev);
36 struct sdhci_host *host = &prv->host;
37 int max_frequency, ret;
41 max_frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
43 ret = clk_get_by_index(dev, 0, &clk);
45 ret = clk_set_rate(&clk, max_frequency);
46 if (IS_ERR_VALUE(ret))
47 printf("%s clk set rate fail!\n", __func__);
49 printf("%s fail to get clk\n", __func__);
52 host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD;
53 host->max_clk = max_frequency;
55 ret = sdhci_setup_cfg(&plat->cfg, host, 0, EMMC_MIN_FREQ);
57 host->mmc = &plat->mmc;
60 host->mmc->priv = &prv->host;
62 upriv->mmc = host->mmc;
64 return sdhci_probe(dev);
67 static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
69 struct sdhci_host *host = dev_get_priv(dev);
71 host->name = dev->name;
72 host->ioaddr = dev_get_addr_ptr(dev);
77 static int rockchip_sdhci_bind(struct udevice *dev)
79 struct rockchip_sdhc_plat *plat = dev_get_platdata(dev);
81 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
84 static const struct udevice_id arasan_sdhci_ids[] = {
85 { .compatible = "arasan,sdhci-5.1" },
89 U_BOOT_DRIVER(arasan_sdhci_drv) = {
90 .name = "arasan_sdhci",
92 .of_match = arasan_sdhci_ids,
93 .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
95 .bind = rockchip_sdhci_bind,
96 .probe = arasan_sdhci_probe,
97 .priv_auto_alloc_size = sizeof(struct rockchip_sdhc),
98 .platdata_auto_alloc_size = sizeof(struct rockchip_sdhc_plat),