2 * (C) Copyright 2013 - 2015 Xilinx, Inc.
4 * Xilinx Zynq SD Host Controller Interface
6 * SPDX-License-Identifier: GPL-2.0+
17 DECLARE_GLOBAL_DATA_PTR;
19 struct arasan_sdhci_plat {
20 struct mmc_config cfg;
25 static int arasan_sdhci_probe(struct udevice *dev)
27 struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
28 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
29 struct sdhci_host *host = dev_get_priv(dev);
34 ret = clk_get_by_index(dev, 0, &clk);
36 dev_err(dev, "failed to get clock\n");
40 clock = clk_get_rate(&clk);
41 if (IS_ERR_VALUE(clock)) {
42 dev_err(dev, "failed to get rate\n");
45 debug("%s: CLK %ld\n", __func__, clock);
47 ret = clk_enable(&clk);
48 if (ret && ret != -ENOSYS) {
49 dev_err(dev, "failed to enable clock\n");
53 host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
54 SDHCI_QUIRK_BROKEN_R1B;
56 #ifdef CONFIG_ZYNQ_HISPD_BROKEN
57 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
60 host->max_clk = clock;
62 ret = sdhci_setup_cfg(&plat->cfg, host, plat->f_max,
63 CONFIG_ZYNQ_SDHCI_MIN_FREQ);
64 host->mmc = &plat->mmc;
67 host->mmc->priv = host;
69 upriv->mmc = host->mmc;
71 return sdhci_probe(dev);
74 static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
76 struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
77 struct sdhci_host *host = dev_get_priv(dev);
79 host->name = dev->name;
80 host->ioaddr = (void *)devfdt_get_addr(dev);
82 plat->f_max = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
83 "max-frequency", CONFIG_ZYNQ_SDHCI_MAX_FREQ);
88 static int arasan_sdhci_bind(struct udevice *dev)
90 struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
92 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
95 static const struct udevice_id arasan_sdhci_ids[] = {
96 { .compatible = "arasan,sdhci-8.9a" },
100 U_BOOT_DRIVER(arasan_sdhci_drv) = {
101 .name = "arasan_sdhci",
103 .of_match = arasan_sdhci_ids,
104 .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
106 .bind = arasan_sdhci_bind,
107 .probe = arasan_sdhci_probe,
108 .priv_auto_alloc_size = sizeof(struct sdhci_host),
109 .platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat),