2 * (C) Copyright 2013 - 2015 Xilinx, Inc.
4 * Xilinx Zynq SD Host Controller Interface
6 * SPDX-License-Identifier: GPL-2.0+
17 #ifndef CONFIG_ZYNQ_SDHCI_MIN_FREQ
18 # define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0
21 struct arasan_sdhci_plat {
22 struct mmc_config cfg;
26 static int arasan_sdhci_probe(struct udevice *dev)
28 struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
29 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
30 struct sdhci_host *host = dev_get_priv(dev);
35 ret = clk_get_by_index(dev, 0, &clk);
37 dev_err(dev, "failed to get clock\n");
41 clock = clk_get_rate(&clk);
42 if (IS_ERR_VALUE(clock)) {
43 dev_err(dev, "failed to get rate\n");
46 debug("%s: CLK %ld\n", __func__, clock);
48 ret = clk_enable(&clk);
49 if (ret && ret != -ENOSYS) {
50 dev_err(dev, "failed to enable clock\n");
54 host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
55 SDHCI_QUIRK_BROKEN_R1B;
57 #ifdef CONFIG_ZYNQ_HISPD_BROKEN
58 host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
61 host->max_clk = clock;
63 ret = sdhci_setup_cfg(&plat->cfg, host, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
64 CONFIG_ZYNQ_SDHCI_MIN_FREQ);
65 host->mmc = &plat->mmc;
68 host->mmc->priv = host;
70 upriv->mmc = host->mmc;
72 return sdhci_probe(dev);
75 static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
77 struct sdhci_host *host = dev_get_priv(dev);
79 host->name = dev->name;
80 host->ioaddr = (void *)dev_get_addr(dev);
85 static int arasan_sdhci_bind(struct udevice *dev)
87 struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
89 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
92 static const struct udevice_id arasan_sdhci_ids[] = {
93 { .compatible = "arasan,sdhci-8.9a" },
97 U_BOOT_DRIVER(arasan_sdhci_drv) = {
98 .name = "arasan_sdhci",
100 .of_match = arasan_sdhci_ids,
101 .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
103 .bind = arasan_sdhci_bind,
104 .probe = arasan_sdhci_probe,
105 .priv_auto_alloc_size = sizeof(struct sdhci_host),
106 .platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat),