1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2015 Linaro
4 * peter.griffin <peter.griffin@linaro.org>
13 #include <asm/global_data.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 struct hi6220_dwmmc_plat {
18 struct mmc_config cfg;
22 struct hi6220_dwmmc_priv_data {
23 struct dwmci_host host;
26 struct hisi_mmc_data {
31 static int hi6220_dwmmc_of_to_plat(struct udevice *dev)
33 struct hi6220_dwmmc_priv_data *priv = dev_get_priv(dev);
34 struct dwmci_host *host = &priv->host;
36 host->name = dev->name;
37 host->ioaddr = dev_read_addr_ptr(dev);
38 host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
41 /* use non-removable property for differentiating SD card and eMMC */
42 if (dev_read_bool(dev, "non-removable"))
52 static int hi6220_dwmmc_probe(struct udevice *dev)
54 struct hi6220_dwmmc_plat *plat = dev_get_plat(dev);
55 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
56 struct hi6220_dwmmc_priv_data *priv = dev_get_priv(dev);
57 struct dwmci_host *host = &priv->host;
58 struct hisi_mmc_data *mmc_data;
60 mmc_data = (struct hisi_mmc_data *)dev_get_driver_data(dev);
62 /* Use default bus speed due to absence of clk driver */
63 host->bus_hz = mmc_data->clock;
65 dwmci_setup_cfg(&plat->cfg, host, host->bus_hz, 400000);
66 host->mmc = &plat->mmc;
68 host->fifo_mode = mmc_data->use_fifo;
69 host->mmc->priv = &priv->host;
70 upriv->mmc = host->mmc;
73 return dwmci_probe(dev);
76 static int hi6220_dwmmc_bind(struct udevice *dev)
78 struct hi6220_dwmmc_plat *plat = dev_get_plat(dev);
81 ret = dwmci_bind(dev, &plat->mmc, &plat->cfg);
88 static const struct hisi_mmc_data hi3660_mmc_data = {
93 static const struct hisi_mmc_data hi6220_mmc_data = {
98 static const struct udevice_id hi6220_dwmmc_ids[] = {
99 { .compatible = "hisilicon,hi6220-dw-mshc",
100 .data = (ulong)&hi6220_mmc_data },
101 { .compatible = "hisilicon,hi3798cv200-dw-mshc",
102 .data = (ulong)&hi6220_mmc_data },
103 { .compatible = "hisilicon,hi3660-dw-mshc",
104 .data = (ulong)&hi3660_mmc_data },
108 U_BOOT_DRIVER(hi6220_dwmmc_drv) = {
109 .name = "hi6220_dwmmc",
111 .of_match = hi6220_dwmmc_ids,
112 .of_to_plat = hi6220_dwmmc_of_to_plat,
113 .ops = &dm_dwmci_ops,
114 .bind = hi6220_dwmmc_bind,
115 .probe = hi6220_dwmmc_probe,
116 .priv_auto = sizeof(struct hi6220_dwmmc_priv_data),
117 .plat_auto = sizeof(struct hi6220_dwmmc_plat),