]> Git Repo - J-u-boot.git/blame - drivers/mmc/hi6220_dw_mmc.c
Merge tag 'xilinx-for-v2024.07-rc1' of https://source.denx.de/u-boot/custodians/u...
[J-u-boot.git] / drivers / mmc / hi6220_dw_mmc.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
447da58b
PG
2/*
3 * (C) Copyright 2015 Linaro
4 * peter.griffin <[email protected]>
447da58b
PG
5 */
6
7#include <common.h>
6240e64f 8#include <dm.h>
447da58b 9#include <dwmmc.h>
6240e64f
MS
10#include <errno.h>
11#include <fdtdec.h>
447da58b 12#include <malloc.h>
401d1c4f 13#include <asm/global_data.h>
447da58b 14
6240e64f 15DECLARE_GLOBAL_DATA_PTR;
447da58b 16
6240e64f
MS
17struct hi6220_dwmmc_plat {
18 struct mmc_config cfg;
19 struct mmc mmc;
20};
447da58b 21
6240e64f
MS
22struct hi6220_dwmmc_priv_data {
23 struct dwmci_host host;
24};
447da58b 25
122537e1
MS
26struct hisi_mmc_data {
27 unsigned int clock;
28 bool use_fifo;
29};
30
d1998a9f 31static int hi6220_dwmmc_of_to_plat(struct udevice *dev)
447da58b 32{
6240e64f
MS
33 struct hi6220_dwmmc_priv_data *priv = dev_get_priv(dev);
34 struct dwmci_host *host = &priv->host;
447da58b 35
6240e64f 36 host->name = dev->name;
8613c8d8 37 host->ioaddr = dev_read_addr_ptr(dev);
6240e64f
MS
38 host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
39 "bus-width", 4);
40
41 /* use non-removable property for differentiating SD card and eMMC */
42 if (dev_read_bool(dev, "non-removable"))
43 host->dev_index = 0;
44 else
45 host->dev_index = 1;
46
47 host->priv = priv;
447da58b 48
447da58b
PG
49 return 0;
50}
51
6240e64f 52static int hi6220_dwmmc_probe(struct udevice *dev)
447da58b 53{
c69cda25 54 struct hi6220_dwmmc_plat *plat = dev_get_plat(dev);
6240e64f
MS
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;
122537e1
MS
58 struct hisi_mmc_data *mmc_data;
59
60 mmc_data = (struct hisi_mmc_data *)dev_get_driver_data(dev);
447da58b 61
6240e64f 62 /* Use default bus speed due to absence of clk driver */
122537e1 63 host->bus_hz = mmc_data->clock;
447da58b 64
6240e64f
MS
65 dwmci_setup_cfg(&plat->cfg, host, host->bus_hz, 400000);
66 host->mmc = &plat->mmc;
447da58b 67
122537e1 68 host->fifo_mode = mmc_data->use_fifo;
6240e64f
MS
69 host->mmc->priv = &priv->host;
70 upriv->mmc = host->mmc;
71 host->mmc->dev = dev;
72
73 return dwmci_probe(dev);
447da58b 74}
6240e64f
MS
75
76static int hi6220_dwmmc_bind(struct udevice *dev)
77{
c69cda25 78 struct hi6220_dwmmc_plat *plat = dev_get_plat(dev);
6240e64f
MS
79 int ret;
80
81 ret = dwmci_bind(dev, &plat->mmc, &plat->cfg);
82 if (ret)
83 return ret;
84
85 return 0;
86}
87
122537e1
MS
88static const struct hisi_mmc_data hi3660_mmc_data = {
89 .clock = 3200000,
90 .use_fifo = true,
91};
92
93static const struct hisi_mmc_data hi6220_mmc_data = {
94 .clock = 50000000,
95 .use_fifo = false,
96};
97
6240e64f 98static const struct udevice_id hi6220_dwmmc_ids[] = {
122537e1
MS
99 { .compatible = "hisilicon,hi6220-dw-mshc",
100 .data = (ulong)&hi6220_mmc_data },
101 { .compatible = "hisilicon,hi3798cv200-dw-mshc",
102 .data = (ulong)&hi6220_mmc_data },
8a5dc814
YX
103 { .compatible = "hisilicon,hi3798mv200-dw-mshc",
104 .data = (ulong)&hi6220_mmc_data },
122537e1
MS
105 { .compatible = "hisilicon,hi3660-dw-mshc",
106 .data = (ulong)&hi3660_mmc_data },
6240e64f
MS
107 { }
108};
109
110U_BOOT_DRIVER(hi6220_dwmmc_drv) = {
111 .name = "hi6220_dwmmc",
112 .id = UCLASS_MMC,
113 .of_match = hi6220_dwmmc_ids,
d1998a9f 114 .of_to_plat = hi6220_dwmmc_of_to_plat,
6240e64f
MS
115 .ops = &dm_dwmci_ops,
116 .bind = hi6220_dwmmc_bind,
117 .probe = hi6220_dwmmc_probe,
41575d8e 118 .priv_auto = sizeof(struct hi6220_dwmmc_priv_data),
caa4daa2 119 .plat_auto = sizeof(struct hi6220_dwmmc_plat),
6240e64f 120};
This page took 0.360846 seconds and 4 git commands to generate.