1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2015 Linaro
4 * peter.griffin <peter.griffin@linaro.org>
14 DECLARE_GLOBAL_DATA_PTR;
16 struct hi6220_dwmmc_plat {
17 struct mmc_config cfg;
21 struct hi6220_dwmmc_priv_data {
22 struct dwmci_host host;
25 static int hi6220_dwmmc_ofdata_to_platdata(struct udevice *dev)
27 struct hi6220_dwmmc_priv_data *priv = dev_get_priv(dev);
28 struct dwmci_host *host = &priv->host;
30 host->name = dev->name;
31 host->ioaddr = (void *)devfdt_get_addr(dev);
32 host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
35 /* use non-removable property for differentiating SD card and eMMC */
36 if (dev_read_bool(dev, "non-removable"))
46 static int hi6220_dwmmc_probe(struct udevice *dev)
48 struct hi6220_dwmmc_plat *plat = dev_get_platdata(dev);
49 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
50 struct hi6220_dwmmc_priv_data *priv = dev_get_priv(dev);
51 struct dwmci_host *host = &priv->host;
53 /* Use default bus speed due to absence of clk driver */
54 host->bus_hz = 50000000;
56 dwmci_setup_cfg(&plat->cfg, host, host->bus_hz, 400000);
57 host->mmc = &plat->mmc;
59 host->mmc->priv = &priv->host;
60 upriv->mmc = host->mmc;
63 return dwmci_probe(dev);
66 static int hi6220_dwmmc_bind(struct udevice *dev)
68 struct hi6220_dwmmc_plat *plat = dev_get_platdata(dev);
71 ret = dwmci_bind(dev, &plat->mmc, &plat->cfg);
78 static const struct udevice_id hi6220_dwmmc_ids[] = {
79 { .compatible = "hisilicon,hi6220-dw-mshc" },
83 U_BOOT_DRIVER(hi6220_dwmmc_drv) = {
84 .name = "hi6220_dwmmc",
86 .of_match = hi6220_dwmmc_ids,
87 .ofdata_to_platdata = hi6220_dwmmc_ofdata_to_platdata,
89 .bind = hi6220_dwmmc_bind,
90 .probe = hi6220_dwmmc_probe,
91 .priv_auto_alloc_size = sizeof(struct hi6220_dwmmc_priv_data),
92 .platdata_auto_alloc_size = sizeof(struct hi6220_dwmmc_plat),