* [U-Boot] [PATCH] mmc: hi6220_dw_mmc: add driver model support
@ 2018-12-17 9:02 Shawn Guo
2019-01-14 9:19 ` Shawn Guo
2019-01-16 1:40 ` [U-Boot] " Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Shawn Guo @ 2018-12-17 9:02 UTC (permalink / raw)
To: u-boot
As requested by driver model migration plan, it adds driver model
support, i.e. CONFIG_DM_MMC, for hi6220_dw_mmc driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/mmc/hi6220_dw_mmc.c | 83 +++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/drivers/mmc/hi6220_dw_mmc.c b/drivers/mmc/hi6220_dw_mmc.c
index ce395d53c942..e0de92418274 100644
--- a/drivers/mmc/hi6220_dw_mmc.c
+++ b/drivers/mmc/hi6220_dw_mmc.c
@@ -23,11 +23,13 @@ static int hi6220_dwmci_core_init(struct dwmci_host *host, int index)
host->dev_index = index;
+#ifndef CONFIG_BLK
/* Add the mmc channel to be registered with mmc core */
if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) {
printf("DWMMC%d registration failed\n", index);
return -1;
}
+#endif
return 0;
}
@@ -53,3 +55,84 @@ int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width)
return hi6220_dwmci_core_init(host, index);
}
+
+#ifdef CONFIG_DM_MMC
+#include <dm.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+struct hi6220_mmc_plat {
+ struct mmc_config cfg;
+ struct mmc mmc;
+};
+
+struct hi6220_dwmmc_priv {
+ struct dwmci_host host;
+ int fifo_depth;
+};
+
+static int hi6220_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+ struct hi6220_dwmmc_priv *priv = dev_get_priv(dev);
+ struct dwmci_host *host = &priv->host;
+ int ret;
+
+ host->priv = dev;
+ host->name = dev->name;
+ host->ioaddr = dev_read_addr_ptr(dev);
+ host->bus_hz = MMC0_DEFAULT_FREQ;
+ host->buswidth = dev_read_u32_default(dev, "bus-width", 4);
+ priv->fifo_depth = dev_read_u32_default(dev, "fifo-depth", 0);
+
+ ret = dev_read_alias_seq(dev, &host->dev_index);
+ if (ret < 0) {
+ debug("%s: failed to get alias: %d\n", __func__, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int hi6220_dwmmc_probe(struct udevice *dev)
+{
+ struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+ struct hi6220_dwmmc_priv *priv = dev_get_priv(dev);
+ struct hi6220_mmc_plat *plat = dev_get_platdata(dev);
+ struct dwmci_host *host = &priv->host;
+
+ host->fifoth_val = MSIZE(0x2) |
+ RX_WMARK(priv->fifo_depth / 2 - 1) |
+ TX_WMARK(priv->fifo_depth / 2);
+
+ dwmci_setup_cfg(&plat->cfg, host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ);
+ host->mmc = &plat->mmc;
+ host->mmc->priv = &priv->host;
+ host->priv = dev;
+ upriv->mmc = host->mmc;
+
+ return dwmci_probe(dev);
+}
+
+static int hi6220_dwmmc_bind(struct udevice *dev)
+{
+ struct hi6220_mmc_plat *plat = dev_get_platdata(dev);
+
+ return dwmci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id hi6220_dwmmc_ids[] = {
+ { .compatible = "hisilicon,hi3798cv200-dw-mshc" },
+ { }
+};
+
+U_BOOT_DRIVER(hi6220_dwmmc_drv) = {
+ .name = "hi6220_dwmmc",
+ .id = UCLASS_MMC,
+ .of_match = hi6220_dwmmc_ids,
+ .ofdata_to_platdata = hi6220_dwmmc_ofdata_to_platdata,
+ .bind = hi6220_dwmmc_bind,
+ .ops = &dm_dwmci_ops,
+ .probe = hi6220_dwmmc_probe,
+ .priv_auto_alloc_size = sizeof(struct hi6220_dwmmc_priv),
+ .platdata_auto_alloc_size = sizeof(struct hi6220_mmc_plat),
+};
+#endif
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] mmc: hi6220_dw_mmc: add driver model support
2018-12-17 9:02 [U-Boot] [PATCH] mmc: hi6220_dw_mmc: add driver model support Shawn Guo
@ 2019-01-14 9:19 ` Shawn Guo
2019-01-16 1:40 ` [U-Boot] " Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2019-01-14 9:19 UTC (permalink / raw)
To: u-boot
On Mon, Dec 17, 2018 at 05:02:31PM +0800, Shawn Guo wrote:
> As requested by driver model migration plan, it adds driver model
> support, i.e. CONFIG_DM_MMC, for hi6220_dw_mmc driver.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Hi Jaehoon,
Any comment on this patch?
Shawn
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] mmc: hi6220_dw_mmc: add driver model support
2018-12-17 9:02 [U-Boot] [PATCH] mmc: hi6220_dw_mmc: add driver model support Shawn Guo
2019-01-14 9:19 ` Shawn Guo
@ 2019-01-16 1:40 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2019-01-16 1:40 UTC (permalink / raw)
To: u-boot
On Mon, Dec 17, 2018 at 05:02:31PM +0800, Shawn Guo wrote:
> As requested by driver model migration plan, it adds driver model
> support, i.e. CONFIG_DM_MMC, for hi6220_dw_mmc driver.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> drivers/mmc/hi6220_dw_mmc.c | 83 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 83 insertions(+)
This seems to be, or have been duplicated by
https://patchwork.ozlabs.org/project/uboot/list/?series=83670 and as
that series includes some other hikey changes I'm picking it up there.
Sorry/thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190115/0d444ce8/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-16 1:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-17 9:02 [U-Boot] [PATCH] mmc: hi6220_dw_mmc: add driver model support Shawn Guo
2019-01-14 9:19 ` Shawn Guo
2019-01-16 1:40 ` [U-Boot] " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox