cmd_usb.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. /*
  2. * (C) Copyright 2001
  3. * Denis Peter, MPL AG Switzerland
  4. *
  5. * Most of this source has been derived from the Linux USB
  6. * project.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. *
  26. */
  27. #include <common.h>
  28. #include <command.h>
  29. #include <asm/byteorder.h>
  30. #include <part.h>
  31. #include <usb.h>
  32. #ifdef CONFIG_USB_STORAGE
  33. static int usb_stor_curr_dev = -1; /* current device */
  34. #endif
  35. /* some display routines (info command) */
  36. char *usb_get_class_desc(unsigned char dclass)
  37. {
  38. switch (dclass) {
  39. case USB_CLASS_PER_INTERFACE:
  40. return "See Interface";
  41. case USB_CLASS_AUDIO:
  42. return "Audio";
  43. case USB_CLASS_COMM:
  44. return "Communication";
  45. case USB_CLASS_HID:
  46. return "Human Interface";
  47. case USB_CLASS_PRINTER:
  48. return "Printer";
  49. case USB_CLASS_MASS_STORAGE:
  50. return "Mass Storage";
  51. case USB_CLASS_HUB:
  52. return "Hub";
  53. case USB_CLASS_DATA:
  54. return "CDC Data";
  55. case USB_CLASS_VENDOR_SPEC:
  56. return "Vendor specific";
  57. default:
  58. return "";
  59. }
  60. }
  61. void usb_display_class_sub(unsigned char dclass, unsigned char subclass,
  62. unsigned char proto)
  63. {
  64. switch (dclass) {
  65. case USB_CLASS_PER_INTERFACE:
  66. printf("See Interface");
  67. break;
  68. case USB_CLASS_HID:
  69. printf("Human Interface, Subclass: ");
  70. switch (subclass) {
  71. case USB_SUB_HID_NONE:
  72. printf("None");
  73. break;
  74. case USB_SUB_HID_BOOT:
  75. printf("Boot ");
  76. switch (proto) {
  77. case USB_PROT_HID_NONE:
  78. printf("None");
  79. break;
  80. case USB_PROT_HID_KEYBOARD:
  81. printf("Keyboard");
  82. break;
  83. case USB_PROT_HID_MOUSE:
  84. printf("Mouse");
  85. break;
  86. default:
  87. printf("reserved");
  88. break;
  89. }
  90. break;
  91. default:
  92. printf("reserved");
  93. break;
  94. }
  95. break;
  96. case USB_CLASS_MASS_STORAGE:
  97. printf("Mass Storage, ");
  98. switch (subclass) {
  99. case US_SC_RBC:
  100. printf("RBC ");
  101. break;
  102. case US_SC_8020:
  103. printf("SFF-8020i (ATAPI)");
  104. break;
  105. case US_SC_QIC:
  106. printf("QIC-157 (Tape)");
  107. break;
  108. case US_SC_UFI:
  109. printf("UFI");
  110. break;
  111. case US_SC_8070:
  112. printf("SFF-8070");
  113. break;
  114. case US_SC_SCSI:
  115. printf("Transp. SCSI");
  116. break;
  117. default:
  118. printf("reserved");
  119. break;
  120. }
  121. printf(", ");
  122. switch (proto) {
  123. case US_PR_CB:
  124. printf("Command/Bulk");
  125. break;
  126. case US_PR_CBI:
  127. printf("Command/Bulk/Int");
  128. break;
  129. case US_PR_BULK:
  130. printf("Bulk only");
  131. break;
  132. default:
  133. printf("reserved");
  134. break;
  135. }
  136. break;
  137. default:
  138. printf("%s", usb_get_class_desc(dclass));
  139. break;
  140. }
  141. }
  142. void usb_display_string(struct usb_device *dev, int index)
  143. {
  144. char buffer[256];
  145. if (index != 0) {
  146. if (usb_string(dev, index, &buffer[0], 256) > 0)
  147. printf("String: \"%s\"", buffer);
  148. }
  149. }
  150. void usb_display_desc(struct usb_device *dev)
  151. {
  152. if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) {
  153. printf("%d: %s, USB Revision %x.%x\n", dev->devnum,
  154. usb_get_class_desc(dev->config.if_desc[0].bInterfaceClass),
  155. (dev->descriptor.bcdUSB>>8) & 0xff,
  156. dev->descriptor.bcdUSB & 0xff);
  157. if (strlen(dev->mf) || strlen(dev->prod) ||
  158. strlen(dev->serial))
  159. printf(" - %s %s %s\n", dev->mf, dev->prod,
  160. dev->serial);
  161. if (dev->descriptor.bDeviceClass) {
  162. printf(" - Class: ");
  163. usb_display_class_sub(dev->descriptor.bDeviceClass,
  164. dev->descriptor.bDeviceSubClass,
  165. dev->descriptor.bDeviceProtocol);
  166. printf("\n");
  167. } else {
  168. printf(" - Class: (from Interface) %s\n",
  169. usb_get_class_desc(
  170. dev->config.if_desc[0].bInterfaceClass));
  171. }
  172. printf(" - PacketSize: %d Configurations: %d\n",
  173. dev->descriptor.bMaxPacketSize0,
  174. dev->descriptor.bNumConfigurations);
  175. printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d\n",
  176. dev->descriptor.idVendor, dev->descriptor.idProduct,
  177. (dev->descriptor.bcdDevice>>8) & 0xff,
  178. dev->descriptor.bcdDevice & 0xff);
  179. }
  180. }
  181. void usb_display_conf_desc(struct usb_config_descriptor *config,
  182. struct usb_device *dev)
  183. {
  184. printf(" Configuration: %d\n", config->bConfigurationValue);
  185. printf(" - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
  186. (config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ",
  187. (config->bmAttributes & 0x20) ? "Remote Wakeup " : "",
  188. config->MaxPower*2);
  189. if (config->iConfiguration) {
  190. printf(" - ");
  191. usb_display_string(dev, config->iConfiguration);
  192. printf("\n");
  193. }
  194. }
  195. void usb_display_if_desc(struct usb_interface_descriptor *ifdesc,
  196. struct usb_device *dev)
  197. {
  198. printf(" Interface: %d\n", ifdesc->bInterfaceNumber);
  199. printf(" - Alternate Setting %d, Endpoints: %d\n",
  200. ifdesc->bAlternateSetting, ifdesc->bNumEndpoints);
  201. printf(" - Class ");
  202. usb_display_class_sub(ifdesc->bInterfaceClass,
  203. ifdesc->bInterfaceSubClass, ifdesc->bInterfaceProtocol);
  204. printf("\n");
  205. if (ifdesc->iInterface) {
  206. printf(" - ");
  207. usb_display_string(dev, ifdesc->iInterface);
  208. printf("\n");
  209. }
  210. }
  211. void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc)
  212. {
  213. printf(" - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf,
  214. (epdesc->bEndpointAddress & 0x80) ? "In" : "Out");
  215. switch ((epdesc->bmAttributes & 0x03)) {
  216. case 0:
  217. printf("Control");
  218. break;
  219. case 1:
  220. printf("Isochronous");
  221. break;
  222. case 2:
  223. printf("Bulk");
  224. break;
  225. case 3:
  226. printf("Interrupt");
  227. break;
  228. }
  229. printf(" MaxPacket %d", epdesc->wMaxPacketSize);
  230. if ((epdesc->bmAttributes & 0x03) == 0x3)
  231. printf(" Interval %dms", epdesc->bInterval);
  232. printf("\n");
  233. }
  234. /* main routine to diasplay the configs, interfaces and endpoints */
  235. void usb_display_config(struct usb_device *dev)
  236. {
  237. struct usb_config_descriptor *config;
  238. struct usb_interface_descriptor *ifdesc;
  239. struct usb_endpoint_descriptor *epdesc;
  240. int i, ii;
  241. config = &dev->config;
  242. usb_display_conf_desc(config, dev);
  243. for (i = 0; i < config->no_of_if; i++) {
  244. ifdesc = &config->if_desc[i];
  245. usb_display_if_desc(ifdesc, dev);
  246. for (ii = 0; ii < ifdesc->no_of_ep; ii++) {
  247. epdesc = &ifdesc->ep_desc[ii];
  248. usb_display_ep_desc(epdesc);
  249. }
  250. }
  251. printf("\n");
  252. }
  253. /* shows the device tree recursively */
  254. void usb_show_tree_graph(struct usb_device *dev, char *pre)
  255. {
  256. int i, index;
  257. int has_child, last_child, port;
  258. index = strlen(pre);
  259. printf(" %s", pre);
  260. /* check if the device has connected children */
  261. has_child = 0;
  262. for (i = 0; i < dev->maxchild; i++) {
  263. if (dev->children[i] != NULL)
  264. has_child = 1;
  265. }
  266. /* check if we are the last one */
  267. last_child = 1;
  268. if (dev->parent != NULL) {
  269. for (i = 0; i < dev->parent->maxchild; i++) {
  270. /* search for children */
  271. if (dev->parent->children[i] == dev) {
  272. /* found our pointer, see if we have a
  273. * little sister
  274. */
  275. port = i;
  276. while (i++ < dev->parent->maxchild) {
  277. if (dev->parent->children[i] != NULL) {
  278. /* found a sister */
  279. last_child = 0;
  280. break;
  281. } /* if */
  282. } /* while */
  283. } /* device found */
  284. } /* for all children of the parent */
  285. printf("\b+-");
  286. /* correct last child */
  287. if (last_child)
  288. pre[index-1] = ' ';
  289. } /* if not root hub */
  290. else
  291. printf(" ");
  292. printf("%d ", dev->devnum);
  293. pre[index++] = ' ';
  294. pre[index++] = has_child ? '|' : ' ';
  295. pre[index] = 0;
  296. printf(" %s (%s, %dmA)\n", usb_get_class_desc(
  297. dev->config.if_desc[0].bInterfaceClass),
  298. dev->slow ? "1.5MBit/s" : "12MBit/s",
  299. dev->config.MaxPower * 2);
  300. if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial))
  301. printf(" %s %s %s %s\n", pre, dev->mf, dev->prod, dev->serial);
  302. printf(" %s\n", pre);
  303. if (dev->maxchild > 0) {
  304. for (i = 0; i < dev->maxchild; i++) {
  305. if (dev->children[i] != NULL) {
  306. usb_show_tree_graph(dev->children[i], pre);
  307. pre[index] = 0;
  308. }
  309. }
  310. }
  311. }
  312. /* main routine for the tree command */
  313. void usb_show_tree(struct usb_device *dev)
  314. {
  315. char preamble[32];
  316. memset(preamble, 0, 32);
  317. usb_show_tree_graph(dev, &preamble[0]);
  318. }
  319. /******************************************************************************
  320. * usb boot command intepreter. Derived from diskboot
  321. */
  322. #ifdef CONFIG_USB_STORAGE
  323. int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  324. {
  325. char *boot_device = NULL;
  326. char *ep;
  327. int dev, part = 1, rcode;
  328. ulong addr, cnt;
  329. disk_partition_t info;
  330. image_header_t *hdr;
  331. block_dev_desc_t *stor_dev;
  332. #if defined(CONFIG_FIT)
  333. const void *fit_hdr = NULL;
  334. #endif
  335. switch (argc) {
  336. case 1:
  337. addr = CONFIG_SYS_LOAD_ADDR;
  338. boot_device = getenv("bootdevice");
  339. break;
  340. case 2:
  341. addr = simple_strtoul(argv[1], NULL, 16);
  342. boot_device = getenv("bootdevice");
  343. break;
  344. case 3:
  345. addr = simple_strtoul(argv[1], NULL, 16);
  346. boot_device = argv[2];
  347. break;
  348. default:
  349. cmd_usage(cmdtp);
  350. return 1;
  351. }
  352. if (!boot_device) {
  353. puts("\n** No boot device **\n");
  354. return 1;
  355. }
  356. dev = simple_strtoul(boot_device, &ep, 16);
  357. stor_dev = usb_stor_get_dev(dev);
  358. if (stor_dev->type == DEV_TYPE_UNKNOWN) {
  359. printf("\n** Device %d not available\n", dev);
  360. return 1;
  361. }
  362. if (stor_dev->block_read == NULL) {
  363. printf("storage device not initialized. Use usb scan\n");
  364. return 1;
  365. }
  366. if (*ep) {
  367. if (*ep != ':') {
  368. puts("\n** Invalid boot device, use `dev[:part]' **\n");
  369. return 1;
  370. }
  371. part = simple_strtoul(++ep, NULL, 16);
  372. }
  373. if (get_partition_info(stor_dev, part, &info)) {
  374. /* try to boot raw .... */
  375. strncpy((char *)&info.type[0], BOOT_PART_TYPE,
  376. sizeof(BOOT_PART_TYPE));
  377. strncpy((char *)&info.name[0], "Raw", 4);
  378. info.start = 0;
  379. info.blksz = 0x200;
  380. info.size = 2880;
  381. printf("error reading partinfo...try to boot raw\n");
  382. }
  383. if ((strncmp((char *)info.type, BOOT_PART_TYPE,
  384. sizeof(info.type)) != 0) &&
  385. (strncmp((char *)info.type, BOOT_PART_COMP,
  386. sizeof(info.type)) != 0)) {
  387. printf("\n** Invalid partition type \"%.32s\""
  388. " (expect \"" BOOT_PART_TYPE "\")\n",
  389. info.type);
  390. return 1;
  391. }
  392. printf("\nLoading from USB device %d, partition %d: "
  393. "Name: %.32s Type: %.32s\n",
  394. dev, part, info.name, info.type);
  395. debug("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
  396. info.start, info.size, info.blksz);
  397. if (stor_dev->block_read(dev, info.start, 1, (ulong *)addr) != 1) {
  398. printf("** Read error on %d:%d\n", dev, part);
  399. return 1;
  400. }
  401. switch (genimg_get_format((void *)addr)) {
  402. case IMAGE_FORMAT_LEGACY:
  403. hdr = (image_header_t *)addr;
  404. if (!image_check_hcrc(hdr)) {
  405. puts("\n** Bad Header Checksum **\n");
  406. return 1;
  407. }
  408. image_print_contents(hdr);
  409. cnt = image_get_image_size(hdr);
  410. break;
  411. #if defined(CONFIG_FIT)
  412. case IMAGE_FORMAT_FIT:
  413. fit_hdr = (const void *)addr;
  414. puts("Fit image detected...\n");
  415. cnt = fit_get_size(fit_hdr);
  416. break;
  417. #endif
  418. default:
  419. puts("** Unknown image type\n");
  420. return 1;
  421. }
  422. cnt += info.blksz - 1;
  423. cnt /= info.blksz;
  424. cnt -= 1;
  425. if (stor_dev->block_read(dev, info.start+1, cnt,
  426. (ulong *)(addr+info.blksz)) != cnt) {
  427. printf("\n** Read error on %d:%d\n", dev, part);
  428. return 1;
  429. }
  430. #if defined(CONFIG_FIT)
  431. /* This cannot be done earlier, we need complete FIT image in RAM
  432. * first
  433. */
  434. if (genimg_get_format((void *)addr) == IMAGE_FORMAT_FIT) {
  435. if (!fit_check_format(fit_hdr)) {
  436. puts("** Bad FIT image format\n");
  437. return 1;
  438. }
  439. fit_print_contents(fit_hdr);
  440. }
  441. #endif
  442. /* Loading ok, update default load address */
  443. load_addr = addr;
  444. flush_cache(addr, (cnt+1)*info.blksz);
  445. /* Check if we should attempt an auto-start */
  446. if (((ep = getenv("autostart")) != NULL) && (strcmp(ep, "yes") == 0)) {
  447. char *local_args[2];
  448. extern int do_bootm(cmd_tbl_t *, int, int, char *[]);
  449. local_args[0] = argv[0];
  450. local_args[1] = NULL;
  451. printf("Automatic boot of image at addr 0x%08lX ...\n", addr);
  452. rcode = do_bootm(cmdtp, 0, 1, local_args);
  453. return rcode;
  454. }
  455. return 0;
  456. }
  457. #endif /* CONFIG_USB_STORAGE */
  458. /******************************************************************************
  459. * usb command intepreter
  460. */
  461. int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  462. {
  463. int i;
  464. struct usb_device *dev = NULL;
  465. extern char usb_started;
  466. #ifdef CONFIG_USB_STORAGE
  467. block_dev_desc_t *stor_dev;
  468. #endif
  469. if ((strncmp(argv[1], "reset", 5) == 0) ||
  470. (strncmp(argv[1], "start", 5) == 0)) {
  471. usb_stop();
  472. printf("(Re)start USB...\n");
  473. i = usb_init();
  474. #ifdef CONFIG_USB_STORAGE
  475. /* try to recognize storage devices immediately */
  476. if (i >= 0)
  477. usb_stor_curr_dev = usb_stor_scan(1);
  478. #endif
  479. return 0;
  480. }
  481. if (strncmp(argv[1], "stop", 4) == 0) {
  482. #ifdef CONFIG_USB_KEYBOARD
  483. if (argc == 2) {
  484. if (usb_kbd_deregister() != 0) {
  485. printf("USB not stopped: usbkbd still"
  486. " using USB\n");
  487. return 1;
  488. }
  489. } else {
  490. /* forced stop, switch console in to serial */
  491. console_assign(stdin, "serial");
  492. usb_kbd_deregister();
  493. }
  494. #endif
  495. printf("stopping USB..\n");
  496. usb_stop();
  497. return 0;
  498. }
  499. if (!usb_started) {
  500. printf("USB is stopped. Please issue 'usb start' first.\n");
  501. return 1;
  502. }
  503. if (strncmp(argv[1], "tree", 4) == 0) {
  504. printf("\nDevice Tree:\n");
  505. usb_show_tree(usb_get_dev_index(0));
  506. return 0;
  507. }
  508. if (strncmp(argv[1], "inf", 3) == 0) {
  509. int d;
  510. if (argc == 2) {
  511. for (d = 0; d < USB_MAX_DEVICE; d++) {
  512. dev = usb_get_dev_index(d);
  513. if (dev == NULL)
  514. break;
  515. usb_display_desc(dev);
  516. usb_display_config(dev);
  517. }
  518. return 0;
  519. } else {
  520. int d;
  521. i = simple_strtoul(argv[2], NULL, 16);
  522. printf("config for device %d\n", i);
  523. for (d = 0; d < USB_MAX_DEVICE; d++) {
  524. dev = usb_get_dev_index(d);
  525. if (dev == NULL)
  526. break;
  527. if (dev->devnum == i)
  528. break;
  529. }
  530. if (dev == NULL) {
  531. printf("*** NO Device avaiable ***\n");
  532. return 0;
  533. } else {
  534. usb_display_desc(dev);
  535. usb_display_config(dev);
  536. }
  537. }
  538. return 0;
  539. }
  540. #ifdef CONFIG_USB_STORAGE
  541. if (strncmp(argv[1], "stor", 4) == 0)
  542. return usb_stor_info();
  543. if (strncmp(argv[1], "part", 4) == 0) {
  544. int devno, ok = 0;
  545. if (argc == 2) {
  546. for (devno = 0; devno < USB_MAX_STOR_DEV; ++devno) {
  547. stor_dev = usb_stor_get_dev(devno);
  548. if (stor_dev->type != DEV_TYPE_UNKNOWN) {
  549. ok++;
  550. if (devno)
  551. printf("\n");
  552. printf("print_part of %x\n", devno);
  553. print_part(stor_dev);
  554. }
  555. }
  556. } else {
  557. devno = simple_strtoul(argv[2], NULL, 16);
  558. stor_dev = usb_stor_get_dev(devno);
  559. if (stor_dev->type != DEV_TYPE_UNKNOWN) {
  560. ok++;
  561. printf("print_part of %x\n", devno);
  562. print_part(stor_dev);
  563. }
  564. }
  565. if (!ok) {
  566. printf("\nno USB devices available\n");
  567. return 1;
  568. }
  569. return 0;
  570. }
  571. if (strcmp(argv[1], "read") == 0) {
  572. if (usb_stor_curr_dev < 0) {
  573. printf("no current device selected\n");
  574. return 1;
  575. }
  576. if (argc == 5) {
  577. unsigned long addr = simple_strtoul(argv[2], NULL, 16);
  578. unsigned long blk = simple_strtoul(argv[3], NULL, 16);
  579. unsigned long cnt = simple_strtoul(argv[4], NULL, 16);
  580. unsigned long n;
  581. printf("\nUSB read: device %d block # %ld, count %ld"
  582. " ... ", usb_stor_curr_dev, blk, cnt);
  583. stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
  584. n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt,
  585. (ulong *)addr);
  586. printf("%ld blocks read: %s\n", n,
  587. (n == cnt) ? "OK" : "ERROR");
  588. if (n == cnt)
  589. return 0;
  590. return 1;
  591. }
  592. }
  593. if (strncmp(argv[1], "dev", 3) == 0) {
  594. if (argc == 3) {
  595. int dev = (int)simple_strtoul(argv[2], NULL, 10);
  596. printf("\nUSB device %d: ", dev);
  597. if (dev >= USB_MAX_STOR_DEV) {
  598. printf("unknown device\n");
  599. return 1;
  600. }
  601. printf("\n Device %d: ", dev);
  602. stor_dev = usb_stor_get_dev(dev);
  603. dev_print(stor_dev);
  604. if (stor_dev->type == DEV_TYPE_UNKNOWN)
  605. return 1;
  606. usb_stor_curr_dev = dev;
  607. printf("... is now current device\n");
  608. return 0;
  609. } else {
  610. printf("\nUSB device %d: ", usb_stor_curr_dev);
  611. stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
  612. dev_print(stor_dev);
  613. if (stor_dev->type == DEV_TYPE_UNKNOWN)
  614. return 1;
  615. return 0;
  616. }
  617. return 0;
  618. }
  619. #endif /* CONFIG_USB_STORAGE */
  620. cmd_usage(cmdtp);
  621. return 1;
  622. }
  623. #ifdef CONFIG_USB_STORAGE
  624. U_BOOT_CMD(
  625. usb, 5, 1, do_usb,
  626. "usb - USB sub-system\n",
  627. "reset - reset (rescan) USB controller\n"
  628. "usb stop [f] - stop USB [f]=force stop\n"
  629. "usb tree - show USB device tree\n"
  630. "usb info [dev] - show available USB devices\n"
  631. "usb storage - show details of USB storage devices\n"
  632. "usb dev [dev] - show or set current USB storage device\n"
  633. "usb part [dev] - print partition table of one or all USB storage"
  634. " devices\n"
  635. "usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
  636. " to memory address `addr'\n"
  637. );
  638. U_BOOT_CMD(
  639. usbboot, 3, 1, do_usbboot,
  640. "usbboot - boot from USB device\n",
  641. "loadAddr dev:part\n"
  642. );
  643. #else
  644. U_BOOT_CMD(
  645. usb, 5, 1, do_usb,
  646. "usb - USB sub-system\n",
  647. "reset - reset (rescan) USB controller\n"
  648. "usb tree - show USB device tree\n"
  649. "usb info [dev] - show available USB devices\n"
  650. );
  651. #endif