public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device (resend)
@ 2009-03-30  5:55 Minkyu Kang
  2009-04-04 21:07 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Minkyu Kang @ 2009-03-30  5:55 UTC (permalink / raw)
  To: u-boot

This patch improves device command for selecting mmc device

Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
---
 common/cmd_mmc.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 16c919b..fb99899 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -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 */
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device (resend)
  2009-03-30  5:55 [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device (resend) Minkyu Kang
@ 2009-04-04 21:07 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2009-04-04 21:07 UTC (permalink / raw)
  To: u-boot

Dear Minkyu Kang,

In message <49D05EE7.9010402@samsung.com> you wrote:
> This patch improves device command for selecting mmc device
> 
> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
> ---
>  common/cmd_mmc.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 56 insertions(+), 5 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Any excuse will serve a tyrant."                             - Aesop

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-04 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-30  5:55 [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device (resend) Minkyu Kang
2009-04-04 21:07 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox