mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-27 17:41:34 +00:00
cmd_mmc: add support for device command for selecting mmc device
This patch improves device command for selecting mmc device Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
This commit is contained in:
parent
9abc9ef8fb
commit
869f6bf4de
1 changed files with 56 additions and 5 deletions
|
@ -26,19 +26,70 @@
|
|||
#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");
|
||||
int dev;
|
||||
|
||||
if (argc < 2) {
|
||||
cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "init") == 0) {
|
||||
if (argc == 2) {
|
||||
if (curr_device < 0)
|
||||
dev = 1;
|
||||
else
|
||||
dev = curr_device;
|
||||
} else if (argc == 3) {
|
||||
dev = (int)simple_strtoul(argv[2], NULL, 10);
|
||||
} else {
|
||||
cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mmc_legacy_init(dev) != 0) {
|
||||
puts("No MMC card found\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
curr_device = dev;
|
||||
printf("mmc%d is available\n", curr_device);
|
||||
} else if (strcmp(argv[1], "device") == 0) {
|
||||
if (argc == 2) {
|
||||
if (curr_device < 0) {
|
||||
puts("No MMC device available\n");
|
||||
return 1;
|
||||
}
|
||||
} else if (argc == 3) {
|
||||
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;
|
||||
} else {
|
||||
cmd_usage(cmdtp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("mmc%d is current device\n", curr_device);
|
||||
} else {
|
||||
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",
|
||||
"init [dev] - init MMC sub system\n"
|
||||
"mmc device [dev] - show or set current device\n"
|
||||
);
|
||||
#else /* !CONFIG_GENERIC_MMC */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue