1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2019 IBM Corp.
4 * Eddie James <eajames@linux.ibm.com>
12 #include <linux/err.h>
14 struct aspeed_sdhci_plat {
15 struct mmc_config cfg;
19 static int aspeed_sdhci_probe(struct udevice *dev)
21 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
22 struct aspeed_sdhci_plat *plat = dev_get_plat(dev);
23 struct sdhci_host *host = dev_get_priv(dev);
28 ret = clk_get_by_index(dev, 0, &clk);
32 ret = clk_enable(&clk);
36 host->name = dev->name;
37 host->ioaddr = dev_read_addr_ptr(dev);
39 max_clk = clk_get_rate(&clk);
40 if (IS_ERR_VALUE(max_clk)) {
45 host->max_clk = max_clk;
46 host->mmc = &plat->mmc;
48 host->mmc->priv = host;
49 upriv->mmc = host->mmc;
51 ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
55 ret = sdhci_probe(dev);
68 static int aspeed_sdhci_bind(struct udevice *dev)
70 struct aspeed_sdhci_plat *plat = dev_get_plat(dev);
72 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
75 static const struct udevice_id aspeed_sdhci_ids[] = {
76 { .compatible = "aspeed,ast2400-sdhci" },
77 { .compatible = "aspeed,ast2500-sdhci" },
78 { .compatible = "aspeed,ast2600-sdhci" },
82 U_BOOT_DRIVER(aspeed_sdhci_drv) = {
83 .name = "aspeed_sdhci",
85 .of_match = aspeed_sdhci_ids,
87 .bind = aspeed_sdhci_bind,
88 .probe = aspeed_sdhci_probe,
89 .priv_auto = sizeof(struct sdhci_host),
90 .plat_auto = sizeof(struct aspeed_sdhci_plat),