[U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device

Dirk Behme dirk.behme at googlemail.com
Sat Mar 28 08:14:02 CET 2009


Minkyu Kang wrote:
> This patch improves device command for selecting mmc device

We should add Andy to CC, as it seems that he is the new MMC maintainer :)

Andy: Would be quite nice if you could comment on Minkyu's changes. 
See [1], [2] and [3] for the history, too.

Dirk

[1] http://lists.denx.de/pipermail/u-boot/2009-March/049660.html

[2] http://lists.denx.de/pipermail/u-boot/2009-March/049694.html

[3] http://lists.denx.de/pipermail/u-boot/2009-March/049707.html

> Signed-off-by: Minkyu Kang <mk7.kang at samsung.com>
> ---
>  common/cmd_mmc.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 64 insertions(+), 5 deletions(-)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 16c919b..2557892 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -26,20 +26,79 @@
>  #include <mmc.h>
>  
>  #ifndef CONFIG_GENERIC_MMC
> +int curr_device = -1;
> +
>  int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>  {
> -	if (mmc_legacy_init (1) != 0) {
> -		printf ("No MMC card found\n");
> +	switch (argc) {
> +	case 0:
> +	case 1:
> +		cmd_usage(cmdtp);
> +		return 1;
> +	case 2:
> +		if (strncmp(argv[1], "init", 4) == 0) {
> +			if (curr_device < 0)
> +				curr_device = 1;
> +
> +			if (mmc_legacy_init(curr_device) != 0) {
> +				printf("No MMC card found\n");
> +				return 1;
> +			}
> +
> +			printf("mmc%d is available\n", curr_device);
> +			return 0;
> +		} else if (strncmp(argv[1], "dev", 3) == 0) {
> +			if (curr_device < 0) {
> +				printf("no MMC devices available\n");
> +				return 1;
> +			}
> +
> +			printf("mmc%d is current device\n", curr_device);
> +			return 0;
> +		}
> +
> +		cmd_usage(cmdtp);
> +		return 1;
> +	case 3:
> +		if (strncmp(argv[1], "init", 4) == 0) {
> +			int dev = (int)simple_strtoul(argv[2], NULL, 10);
> +
> +			if (mmc_legacy_init(dev) != 0) {
> +				printf("No MMC card found\n");
> +				return 1;
> +			}
> +
> +			curr_device = dev;
> +
> +			printf("mmc%d is available\n", curr_device);
> +			return 0;
> +		} else if (strncmp(argv[1], "dev", 3) == 0) {
> +			int dev = (int)simple_strtoul(argv[2], NULL, 10);
> +
> +#ifdef CONFIG_SYS_MMC_SET_DEV
> +			if (mmc_set_dev(dev) != 0)
> +				return 1;
> +#endif
> +
> +			curr_device = dev;
> +
> +			printf("mmc%d is now current device\n", curr_device);
> +			return 0;
> +		}
> +
> +		cmd_usage(cmdtp);
>  		return 1;
>  	}
>  	return 0;
>  }
>  
>  U_BOOT_CMD(
> -	mmcinit,	1,	0,	do_mmc,
> -	"init mmc card",
> -	NULL
> +	mmc,	3,	1,	do_mmc,
> +	"MMC sub-system",
> +	"mmc init [dev] - init MMC sub system\n"
> +	"mmc device [dev] - show or set current device\n"
>  );
> +
>  #else /* !CONFIG_GENERIC_MMC */
> 



More information about the U-Boot mailing list