+ int dev;
+
+ if (argc < 2)
+ return cmd_usage(cmdtp);
+
+ 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 {
+ return cmd_usage(cmdtp);
+ }
+
+ 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 {
+ return cmd_usage(cmdtp);
+ }
+
+ printf("mmc%d is current device\n", curr_device);
+ } else {
+ return cmd_usage(cmdtp);