[U-Boot] [PATCH] drivers: MMC: initialize MMC devices using the device model

Simon Glass sjg at chromium.org
Sun Aug 23 23:22:25 CEST 2015


Hi Andre,

On 28 July 2015 at 11:19, Andre Przywara <andre.przywara at arm.com> wrote:
> So far every MMC driver is relying on a board specific init routine,
> but as the Rockchip MMC driver is the first MMC device model user,
> it requires a generic DM MMC init routine.
>
> Add that to the MMC init path to enable the Rockchip driver.
>
> Signed-off-by: Andre Przywara <andre.przywara at arm.com>
> ---
> Hi Simon,
>
> this goes on top of your rockchip-working branch in the u-boot-dm
> repo.
> Not fully satisfied with this one, but the best I could come up with
> without reading the whole of the device model code ;-)
> This makes the SD card visible to U-Boot on my RK3288 dev board, I
> can see partitions and load files from it. It gives me information
> about the eMMC as well, but I haven't tested this so far except for
> that mmc info.
>
> Cheers,
> Andre.
>
>  drivers/mmc/mmc.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Thanks for the patch and sorry for ignoring it so long. I'm finally
getting close to getting the rockchip patches applied.

See also this one:

http://patchwork.ozlabs.org/patch/507840/

>
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index da47037..52e82b5 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -17,6 +17,7 @@
>  #include <linux/list.h>
>  #include <div64.h>
>  #include "mmc_private.h"
> +#include <dm.h>
>
>  static struct list_head mmc_devices;
>  static int cur_dev_num = -1;
> @@ -1765,7 +1766,13 @@ int mmc_initialize(bd_t *bis)
>         INIT_LIST_HEAD (&mmc_devices);
>         cur_dev_num = 0;
>
> -#ifndef CONFIG_DM_MMC
> +#ifdef CONFIG_DM_MMC
> +       struct udevice *udev;
> +
> +       for (;;cur_dev_num++)
> +               if (uclass_get_device(UCLASS_MMC, cur_dev_num, &udev))
> +                       break;

Do you have to increase cur_dev_num? I thought it might happen
automatically when a device is probed and calls mmc_create().

Do you think it would work if instead we changed get_mmc_num() to do this?

With driver model we are trying to make it so that devices a probed
when they are used, not before. I.e. mmc_initialize() should ideally
be a nop.

> +#else
>         if (board_mmc_init(bis) < 0)
>                 cpu_mmc_init(bis);
>  #endif
> --
> 2.3.5
>

Regards,
Simon


More information about the U-Boot mailing list