[U-Boot] [PATCH 3/4] drivers: omap_hsmmc: move the mmc_config to platdata when DM_MMC is used

Jaehoon Chung jh80.chung at samsung.com
Thu Mar 30 04:35:55 UTC 2017


On 03/23/2017 12:00 AM, Jean-Jacques Hiblot wrote:
> This is a preparation work for the support of CONFIG_BLK.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>

Applied on u-boot-mmc. Thanks!

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/omap_hsmmc.c | 27 ++++++++++++++++++++++-----
>  1 file changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
> index d985ac7..104129f 100644
> --- a/drivers/mmc/omap_hsmmc.c
> +++ b/drivers/mmc/omap_hsmmc.c
> @@ -56,9 +56,15 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define SYSCTL_SRC	(1 << 25)
>  #define SYSCTL_SRD	(1 << 26)
>  
> +struct omap_hsmmc_plat {
> +	struct mmc_config cfg;
> +};
> +
>  struct omap_hsmmc_data {
>  	struct hsmmc *base_addr;
> +#ifndef CONFIG_DM_MMC
>  	struct mmc_config cfg;
> +#endif
>  #ifdef OMAP_HSMMC_USE_GPIO
>  #ifdef CONFIG_DM_MMC
>  	struct gpio_desc cd_gpio;	/* Change Detect GPIO */
> @@ -86,6 +92,15 @@ static inline struct omap_hsmmc_data *omap_hsmmc_get_data(struct mmc *mmc)
>  	return (struct omap_hsmmc_data *)mmc->priv;
>  #endif
>  }
> +static inline struct mmc_config *omap_hsmmc_get_cfg(struct mmc *mmc)
> +{
> +#ifdef CONFIG_DM_MMC
> +	struct omap_hsmmc_plat *plat = dev_get_platdata(mmc->dev);
> +	return &plat->cfg;
> +#else
> +	return &((struct omap_hsmmc_data *)mmc->priv)->cfg;
> +#endif
> +}
>  
>   #if defined(OMAP_HSMMC_USE_GPIO) && !defined(CONFIG_DM_MMC)
>  static int omap_mmc_setup_gpio_in(int gpio, const char *label)
> @@ -111,6 +126,7 @@ static int omap_mmc_setup_gpio_in(int gpio, const char *label)
>  static unsigned char mmc_board_init(struct mmc *mmc)
>  {
>  #if defined(CONFIG_OMAP34XX)
> +	struct mmc_config *cfg = omap_hsmmc_get_cfg(mmc);
>  	t2_t *t2_base = (t2_t *)T2_BASE;
>  	struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
>  	u32 pbias_lite;
> @@ -151,7 +167,7 @@ static unsigned char mmc_board_init(struct mmc *mmc)
>  		&t2_base->devconf1);
>  
>  	/* Change from default of 52MHz to 26MHz if necessary */
> -	if (!(mmc->cfg->host_caps & MMC_MODE_HS_52MHz))
> +	if (!(cfg->host_caps & MMC_MODE_HS_52MHz))
>  		writel(readl(&t2_base->ctl_prog_io1) & ~CTLPROGIO1SPEEDCTRL,
>  			&t2_base->ctl_prog_io1);
>  
> @@ -759,14 +775,14 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,
>  static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
>  {
>  	struct omap_hsmmc_data *priv = dev_get_priv(dev);
> +	struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
> +	struct mmc_config *cfg = &plat->cfg;
>  	const void *fdt = gd->fdt_blob;
>  	int node = dev_of_offset(dev);
> -	struct mmc_config *cfg;
>  	int val;
>  
>  	priv->base_addr = map_physmem(dev_get_addr(dev), sizeof(struct hsmmc *),
>  				      MAP_NOCACHE);
> -	cfg = &priv->cfg;
>  
>  	cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
>  	val = fdtdec_get_int(fdt, node, "bus-width", -1);
> @@ -800,12 +816,12 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
>  
>  static int omap_hsmmc_probe(struct udevice *dev)
>  {
> +	struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
>  	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
>  	struct omap_hsmmc_data *priv = dev_get_priv(dev);
> -	struct mmc_config *cfg;
> +	struct mmc_config *cfg = &plat->cfg;
>  	struct mmc *mmc;
>  
> -	cfg = &priv->cfg;
>  	cfg->name = "OMAP SD/MMC";
>  	cfg->ops = &omap_hsmmc_ops;
>  
> @@ -838,5 +854,6 @@ U_BOOT_DRIVER(omap_hsmmc) = {
>  	.ofdata_to_platdata = omap_hsmmc_ofdata_to_platdata,
>  	.probe	= omap_hsmmc_probe,
>  	.priv_auto_alloc_size = sizeof(struct omap_hsmmc_data),
> +	.platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat),
>  };
>  #endif
> 



More information about the U-Boot mailing list