[RFC 2/7] mmc: fsl_esdhc_imx: add ofdata_to_platdata support

Simon Glass sjg at chromium.org
Mon Apr 6 05:42:56 CEST 2020


Hi Walter

On Sun, 29 Mar 2020 at 21:32, Walter Lozano <walter.lozano at collabora.com> wrote:
>

All of these commits need a commit message please.

> Signed-off-by: Walter Lozano <walter.lozano at collabora.com>
> ---
>  drivers/mmc/fsl_esdhc_imx.c | 71 ++++++++++++++++++++++---------------
>  1 file changed, 42 insertions(+), 29 deletions(-)
>

Reviewed-by: SImon Glass <sjg at chromium.org>

> diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
> index 761a4b46e9..049a1b6ea8 100644
> --- a/drivers/mmc/fsl_esdhc_imx.c
> +++ b/drivers/mmc/fsl_esdhc_imx.c
> @@ -1379,41 +1379,20 @@ __weak void init_clk_usdhc(u32 index)
>  {
>  }
>
> -static int fsl_esdhc_probe(struct udevice *dev)
> -{
> -       struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
> -       struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
> -       struct fsl_esdhc_priv *priv = dev_get_priv(dev);
> +static int fsl_esdhc_ofdata_to_platdata(struct udevice *dev){
> +
>  #if !CONFIG_IS_ENABLED(OF_PLATDATA)
> -       const void *fdt = gd->fdt_blob;
> -       int node = dev_of_offset(dev);
> -       fdt_addr_t addr;
> -#else
> -       struct dtd_fsl_imx6q_usdhc *dtplat = &plat->dtplat;
> -#endif
> -       struct esdhc_soc_data *data =
> -               (struct esdhc_soc_data *)dev_get_driver_data(dev);
> +       struct fsl_esdhc_priv *priv = dev_get_priv(dev);
>  #if CONFIG_IS_ENABLED(DM_REGULATOR)
>         struct udevice *vqmmc_dev;
> +       int ret;
>  #endif
> +       const void *fdt = gd->fdt_blob;
> +       int node = dev_of_offset(dev);
> +
> +       fdt_addr_t addr;
>         unsigned int val;
> -       struct mmc *mmc;
> -#if !CONFIG_IS_ENABLED(BLK)
> -       struct blk_desc *bdesc;
> -#endif
> -       int ret;
>
> -#if CONFIG_IS_ENABLED(OF_PLATDATA)
> -       priv->esdhc_regs = map_sysmem(dtplat->reg[0], dtplat->reg[1]);
> -       val = plat->dtplat.bus_width;
> -       if (val == 8)
> -               priv->bus_width = 8;
> -       else if (val == 4)
> -               priv->bus_width = 4;
> -       else
> -               priv->bus_width = 1;
> -       priv->non_removable = 1;
> -#else
>         addr = dev_read_addr(dev);
>         if (addr == FDT_ADDR_T_NONE)
>                 return -EINVAL;
> @@ -1483,8 +1462,40 @@ static int fsl_esdhc_probe(struct udevice *dev)
>         }
>  #endif
>  #endif
> +       return 0;
> +}
> +
> +static int fsl_esdhc_probe(struct udevice *dev)
> +{
> +       struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
> +       struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
> +       struct fsl_esdhc_priv *priv = dev_get_priv(dev);
> +       struct esdhc_soc_data *data =
> +               (struct esdhc_soc_data *)dev_get_driver_data(dev);
> +       struct mmc *mmc;
> +#if !CONFIG_IS_ENABLED(BLK)

Should not need to support !BLK now. The migration date has passed.

> +       struct blk_desc *bdesc;
> +#endif
> +       int ret;
> +
> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
> +       struct dtd_fsl_imx6q_usdhc *dtplat = &plat->dtplat;
> +       unsigned int val;
> +
> +       priv->esdhc_regs = map_sysmem(dtplat->reg[0], dtplat->reg[1]);
> +       val = plat->dtplat.bus_width;
> +       if (val == 8)
> +               priv->bus_width = 8;
> +       else if (val == 4)
> +               priv->bus_width = 4;
> +       else
> +               priv->bus_width = 1;
> +       priv->non_removable = 1;
> +#endif
> +
>         if (data)
>                 priv->flags = data->flags;
> +
>         /*
>          * TODO:
>          * Because lack of clk driver, if SDHC clk is not enabled,
> @@ -1664,6 +1675,7 @@ U_BOOT_DRIVER(fsl_esdhc) = {
>         .name   = "fsl-esdhc-mmc",
>         .id     = UCLASS_MMC,
>         .of_match = fsl_esdhc_ids,
> +       .ofdata_to_platdata = fsl_esdhc_ofdata_to_platdata,
>         .ops    = &fsl_esdhc_ops,
>  #if CONFIG_IS_ENABLED(BLK)
>         .bind   = fsl_esdhc_bind,
> @@ -1677,6 +1689,7 @@ U_BOOT_DRIVER(fsl_esdhc) = {
>  U_BOOT_DRIVER(fsl_usdhc) = {
>         .name   = "fsl_imx6q_usdhc",
>         .id     = UCLASS_MMC,
> +       .ofdata_to_platdata = fsl_esdhc_ofdata_to_platdata,
>         .ops    = &fsl_esdhc_ops,
>  #if CONFIG_IS_ENABLED(BLK)
>         .bind   = fsl_esdhc_bind,
> --
> 2.20.1
>

Regards,
Simon


More information about the U-Boot mailing list