mmc: hi6220_dw_mmc: add driver model support
PATCH 1/1 mmc: hi6220_dw_mmc: add driver model support
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 <[email protected]>
--- drivers/mmc/hi6220_dw_mmc.c | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
drivers/mmc/hi6220_dw_mmc.c +83 -0
@@ -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
Signature · 1 line
2.18.0
PATCH 1/1 mmc: hi6220_dw_mmc: add driver model support
Quoted 4 lines · Shawn Guo
As requested by driver model migration plan, it adds driver model support, i.e.
CONFIG_DM_MMC, forhi6220_dw_mmcdriver.Signed-off-by Shawn Guo <[email protected]>
Hi Jaehoon,
Any comment on this patch?
Shawn
Quoted 7 lines · Shawn Guo
As requested by driver model migration plan, it adds driver model support, i.e.
CONFIG_DM_MMC, forhi6220_dw_mmcdriver.Signed-off-by Shawn Guo <[email protected]>--- 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!
Signature · 8 lines
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>