Blame view
common/cmd_usb.c
16.4 KB
e887afc9d Initial revision |
1 2 3 4 5 6 7 |
/* * (C) Copyright 2001 * Denis Peter, MPL AG Switzerland * * Most of this source has been derived from the Linux USB * project. * |
1a4596601 Add GPL-2.0+ SPDX... |
8 |
* SPDX-License-Identifier: GPL-2.0+ |
e887afc9d Initial revision |
9 10 11 12 |
*/ #include <common.h> #include <command.h> |
414eec35e Fix problems with... |
13 |
#include <asm/byteorder.h> |
b2fb47f18 USB: Use (get|put... |
14 |
#include <asm/unaligned.h> |
735dd97b1 [PATCH 1_4] Merge... |
15 |
#include <part.h> |
e887afc9d Initial revision |
16 |
#include <usb.h> |
e887afc9d Initial revision |
17 |
|
1968e615d Cleanup USB and p... |
18 |
#ifdef CONFIG_USB_STORAGE |
d0ff51ba5 Code cleanup: fix... |
19 |
static int usb_stor_curr_dev = -1; /* current device */ |
1968e615d Cleanup USB and p... |
20 |
#endif |
89d48367e Add USB host ethe... |
21 22 23 |
#ifdef CONFIG_USB_HOST_ETHER static int usb_ether_curr_dev = -1; /* current ethernet device */ #endif |
e887afc9d Initial revision |
24 |
|
a2663ea4f * Patches by Davi... |
25 |
/* some display routines (info command) */ |
088f1b199 common/cmd_*.c: s... |
26 |
static char *usb_get_class_desc(unsigned char dclass) |
e887afc9d Initial revision |
27 |
{ |
de39f8c19 USB style patch, ... |
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
switch (dclass) { case USB_CLASS_PER_INTERFACE: return "See Interface"; case USB_CLASS_AUDIO: return "Audio"; case USB_CLASS_COMM: return "Communication"; case USB_CLASS_HID: return "Human Interface"; case USB_CLASS_PRINTER: return "Printer"; case USB_CLASS_MASS_STORAGE: return "Mass Storage"; case USB_CLASS_HUB: return "Hub"; case USB_CLASS_DATA: return "CDC Data"; case USB_CLASS_VENDOR_SPEC: return "Vendor specific"; default: return ""; |
e887afc9d Initial revision |
49 50 |
} } |
088f1b199 common/cmd_*.c: s... |
51 52 |
static void usb_display_class_sub(unsigned char dclass, unsigned char subclass, unsigned char proto) |
e887afc9d Initial revision |
53 |
{ |
de39f8c19 USB style patch, ... |
54 55 56 57 58 59 60 61 62 |
switch (dclass) { case USB_CLASS_PER_INTERFACE: printf("See Interface"); break; case USB_CLASS_HID: printf("Human Interface, Subclass: "); switch (subclass) { case USB_SUB_HID_NONE: printf("None"); |
e887afc9d Initial revision |
63 |
break; |
de39f8c19 USB style patch, ... |
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
case USB_SUB_HID_BOOT: printf("Boot "); switch (proto) { case USB_PROT_HID_NONE: printf("None"); break; case USB_PROT_HID_KEYBOARD: printf("Keyboard"); break; case USB_PROT_HID_MOUSE: printf("Mouse"); break; default: printf("reserved"); break; |
e887afc9d Initial revision |
79 80 |
} break; |
de39f8c19 USB style patch, ... |
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
default: printf("reserved"); break; } break; case USB_CLASS_MASS_STORAGE: printf("Mass Storage, "); switch (subclass) { case US_SC_RBC: printf("RBC "); break; case US_SC_8020: printf("SFF-8020i (ATAPI)"); break; case US_SC_QIC: printf("QIC-157 (Tape)"); break; case US_SC_UFI: printf("UFI"); break; case US_SC_8070: printf("SFF-8070"); break; case US_SC_SCSI: printf("Transp. SCSI"); break; default: printf("reserved"); break; } printf(", "); switch (proto) { case US_PR_CB: printf("Command/Bulk"); break; case US_PR_CBI: printf("Command/Bulk/Int"); break; case US_PR_BULK: printf("Bulk only"); |
e887afc9d Initial revision |
121 122 |
break; default: |
de39f8c19 USB style patch, ... |
123 124 125 126 127 128 129 |
printf("reserved"); break; } break; default: printf("%s", usb_get_class_desc(dclass)); break; |
e887afc9d Initial revision |
130 131 |
} } |
088f1b199 common/cmd_*.c: s... |
132 |
static void usb_display_string(struct usb_device *dev, int index) |
e887afc9d Initial revision |
133 |
{ |
f57661394 USB: Align buffer... |
134 |
ALLOC_CACHE_ALIGN_BUFFER(char, buffer, 256); |
de39f8c19 USB style patch, ... |
135 136 137 |
if (index != 0) { if (usb_string(dev, index, &buffer[0], 256) > 0) printf("String: \"%s\"", buffer); |
e887afc9d Initial revision |
138 139 |
} } |
088f1b199 common/cmd_*.c: s... |
140 |
static void usb_display_desc(struct usb_device *dev) |
e887afc9d Initial revision |
141 |
{ |
de39f8c19 USB style patch, ... |
142 143 144 |
if (dev->descriptor.bDescriptorType == USB_DT_DEVICE) { printf("%d: %s, USB Revision %x.%x ", dev->devnum, |
8f8bd565f USB Consolidate d... |
145 |
usb_get_class_desc(dev->config.if_desc[0].desc.bInterfaceClass), |
de39f8c19 USB style patch, ... |
146 147 148 149 150 151 152 153 |
(dev->descriptor.bcdUSB>>8) & 0xff, dev->descriptor.bcdUSB & 0xff); if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial)) printf(" - %s %s %s ", dev->mf, dev->prod, dev->serial); |
e887afc9d Initial revision |
154 155 |
if (dev->descriptor.bDeviceClass) { printf(" - Class: "); |
de39f8c19 USB style patch, ... |
156 157 158 |
usb_display_class_sub(dev->descriptor.bDeviceClass, dev->descriptor.bDeviceSubClass, dev->descriptor.bDeviceProtocol); |
e887afc9d Initial revision |
159 160 |
printf(" "); |
de39f8c19 USB style patch, ... |
161 162 163 164 |
} else { printf(" - Class: (from Interface) %s ", usb_get_class_desc( |
8f8bd565f USB Consolidate d... |
165 |
dev->config.if_desc[0].desc.bInterfaceClass)); |
e887afc9d Initial revision |
166 |
} |
de39f8c19 USB style patch, ... |
167 168 169 170 171 172 173 174 175 |
printf(" - PacketSize: %d Configurations: %d ", dev->descriptor.bMaxPacketSize0, dev->descriptor.bNumConfigurations); printf(" - Vendor: 0x%04x Product 0x%04x Version %d.%d ", dev->descriptor.idVendor, dev->descriptor.idProduct, (dev->descriptor.bcdDevice>>8) & 0xff, dev->descriptor.bcdDevice & 0xff); |
e887afc9d Initial revision |
176 177 178 |
} } |
c60795f41 usb: use linux/us... |
179 |
static void usb_display_conf_desc(struct usb_config_descriptor *config, |
088f1b199 common/cmd_*.c: s... |
180 |
struct usb_device *dev) |
e887afc9d Initial revision |
181 |
{ |
de39f8c19 USB style patch, ... |
182 183 184 185 186 187 |
printf(" Configuration: %d ", config->bConfigurationValue); printf(" - Interfaces: %d %s%s%dmA ", config->bNumInterfaces, (config->bmAttributes & 0x40) ? "Self Powered " : "Bus Powered ", (config->bmAttributes & 0x20) ? "Remote Wakeup " : "", |
8f8bd565f USB Consolidate d... |
188 |
config->bMaxPower*2); |
e887afc9d Initial revision |
189 190 |
if (config->iConfiguration) { printf(" - "); |
de39f8c19 USB style patch, ... |
191 |
usb_display_string(dev, config->iConfiguration); |
e887afc9d Initial revision |
192 193 194 195 |
printf(" "); } } |
088f1b199 common/cmd_*.c: s... |
196 197 |
static void usb_display_if_desc(struct usb_interface_descriptor *ifdesc, struct usb_device *dev) |
e887afc9d Initial revision |
198 |
{ |
de39f8c19 USB style patch, ... |
199 200 201 202 203 |
printf(" Interface: %d ", ifdesc->bInterfaceNumber); printf(" - Alternate Setting %d, Endpoints: %d ", ifdesc->bAlternateSetting, ifdesc->bNumEndpoints); |
e887afc9d Initial revision |
204 |
printf(" - Class "); |
de39f8c19 USB style patch, ... |
205 206 |
usb_display_class_sub(ifdesc->bInterfaceClass, ifdesc->bInterfaceSubClass, ifdesc->bInterfaceProtocol); |
e887afc9d Initial revision |
207 208 209 210 |
printf(" "); if (ifdesc->iInterface) { printf(" - "); |
de39f8c19 USB style patch, ... |
211 |
usb_display_string(dev, ifdesc->iInterface); |
e887afc9d Initial revision |
212 213 214 215 |
printf(" "); } } |
088f1b199 common/cmd_*.c: s... |
216 |
static void usb_display_ep_desc(struct usb_endpoint_descriptor *epdesc) |
e887afc9d Initial revision |
217 |
{ |
de39f8c19 USB style patch, ... |
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
printf(" - Endpoint %d %s ", epdesc->bEndpointAddress & 0xf, (epdesc->bEndpointAddress & 0x80) ? "In" : "Out"); switch ((epdesc->bmAttributes & 0x03)) { case 0: printf("Control"); break; case 1: printf("Isochronous"); break; case 2: printf("Bulk"); break; case 3: printf("Interrupt"); break; |
e887afc9d Initial revision |
233 |
} |
b2fb47f18 USB: Use (get|put... |
234 |
printf(" MaxPacket %d", get_unaligned(&epdesc->wMaxPacketSize)); |
de39f8c19 USB style patch, ... |
235 236 |
if ((epdesc->bmAttributes & 0x03) == 0x3) printf(" Interval %dms", epdesc->bInterval); |
e887afc9d Initial revision |
237 238 239 240 241 |
printf(" "); } /* main routine to diasplay the configs, interfaces and endpoints */ |
088f1b199 common/cmd_*.c: s... |
242 |
static void usb_display_config(struct usb_device *dev) |
e887afc9d Initial revision |
243 |
{ |
8f8bd565f USB Consolidate d... |
244 245 |
struct usb_config *config; struct usb_interface *ifdesc; |
e887afc9d Initial revision |
246 |
struct usb_endpoint_descriptor *epdesc; |
de39f8c19 USB style patch, ... |
247 248 249 |
int i, ii; config = &dev->config; |
8f8bd565f USB Consolidate d... |
250 |
usb_display_conf_desc(&config->desc, dev); |
de39f8c19 USB style patch, ... |
251 252 |
for (i = 0; i < config->no_of_if; i++) { ifdesc = &config->if_desc[i]; |
8f8bd565f USB Consolidate d... |
253 |
usb_display_if_desc(&ifdesc->desc, dev); |
de39f8c19 USB style patch, ... |
254 255 |
for (ii = 0; ii < ifdesc->no_of_ep; ii++) { epdesc = &ifdesc->ep_desc[ii]; |
e887afc9d Initial revision |
256 257 258 259 260 261 |
usb_display_ep_desc(epdesc); } } printf(" "); } |
7d9aa8fd8 usb: Add new comm... |
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
static struct usb_device *usb_find_device(int devnum) { struct usb_device *dev; int d; for (d = 0; d < USB_MAX_DEVICE; d++) { dev = usb_get_dev_index(d); if (dev == NULL) return NULL; if (dev->devnum == devnum) return dev; } return NULL; } |
f1c1f5402 USB: Add high-spe... |
277 278 |
static inline char *portspeed(int speed) { |
6497c6670 USB: SS: Add supp... |
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
char *speed_str; switch (speed) { case USB_SPEED_SUPER: speed_str = "5 Gb/s"; break; case USB_SPEED_HIGH: speed_str = "480 Mb/s"; break; case USB_SPEED_LOW: speed_str = "1.5 Mb/s"; break; default: speed_str = "12 Mb/s"; break; } return speed_str; |
f1c1f5402 USB: Add high-spe... |
297 |
} |
e887afc9d Initial revision |
298 |
/* shows the device tree recursively */ |
088f1b199 common/cmd_*.c: s... |
299 |
static void usb_show_tree_graph(struct usb_device *dev, char *pre) |
e887afc9d Initial revision |
300 |
{ |
de39f8c19 USB style patch, ... |
301 |
int i, index; |
10f4dd784 common/cmd_usb.c:... |
302 |
int has_child, last_child; |
e887afc9d Initial revision |
303 |
|
de39f8c19 USB style patch, ... |
304 305 |
index = strlen(pre); printf(" %s", pre); |
e887afc9d Initial revision |
306 |
/* check if the device has connected children */ |
de39f8c19 USB style patch, ... |
307 308 309 310 |
has_child = 0; for (i = 0; i < dev->maxchild; i++) { if (dev->children[i] != NULL) has_child = 1; |
e887afc9d Initial revision |
311 312 |
} /* check if we are the last one */ |
de39f8c19 USB style patch, ... |
313 314 315 |
last_child = 1; if (dev->parent != NULL) { for (i = 0; i < dev->parent->maxchild; i++) { |
e887afc9d Initial revision |
316 |
/* search for children */ |
de39f8c19 USB style patch, ... |
317 318 319 320 |
if (dev->parent->children[i] == dev) { /* found our pointer, see if we have a * little sister */ |
de39f8c19 USB style patch, ... |
321 322 |
while (i++ < dev->parent->maxchild) { if (dev->parent->children[i] != NULL) { |
e887afc9d Initial revision |
323 |
/* found a sister */ |
de39f8c19 USB style patch, ... |
324 |
last_child = 0; |
e887afc9d Initial revision |
325 326 327 328 329 330 331 |
break; } /* if */ } /* while */ } /* device found */ } /* for all children of the parent */ printf("\b+-"); /* correct last child */ |
de39f8c19 USB style patch, ... |
332 333 |
if (last_child) pre[index-1] = ' '; |
e887afc9d Initial revision |
334 335 336 |
} /* if not root hub */ else printf(" "); |
de39f8c19 USB style patch, ... |
337 338 339 340 341 342 |
printf("%d ", dev->devnum); pre[index++] = ' '; pre[index++] = has_child ? '|' : ' '; pre[index] = 0; printf(" %s (%s, %dmA) ", usb_get_class_desc( |
8f8bd565f USB Consolidate d... |
343 |
dev->config.if_desc[0].desc.bInterfaceClass), |
f1c1f5402 USB: Add high-spe... |
344 |
portspeed(dev->speed), |
8f8bd565f USB Consolidate d... |
345 |
dev->config.desc.bMaxPower * 2); |
de39f8c19 USB style patch, ... |
346 347 348 349 350 351 352 353 354 355 |
if (strlen(dev->mf) || strlen(dev->prod) || strlen(dev->serial)) printf(" %s %s %s %s ", pre, dev->mf, dev->prod, dev->serial); printf(" %s ", pre); if (dev->maxchild > 0) { for (i = 0; i < dev->maxchild; i++) { if (dev->children[i] != NULL) { usb_show_tree_graph(dev->children[i], pre); pre[index] = 0; |
e887afc9d Initial revision |
356 357 358 359 360 361 |
} } } } /* main routine for the tree command */ |
088f1b199 common/cmd_*.c: s... |
362 |
static void usb_show_tree(struct usb_device *dev) |
e887afc9d Initial revision |
363 364 |
{ char preamble[32]; |
de39f8c19 USB style patch, ... |
365 366 |
memset(preamble, 0, 32); usb_show_tree_graph(dev, &preamble[0]); |
e887afc9d Initial revision |
367 |
} |
7d9aa8fd8 usb: Add new comm... |
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
static int usb_test(struct usb_device *dev, int port, char* arg) { int mode; if (port > dev->maxchild) { printf("Device is no hub or does not have %d ports. ", port); return 1; } switch (arg[0]) { case 'J': case 'j': printf("Setting Test_J mode"); mode = USB_TEST_MODE_J; break; case 'K': case 'k': printf("Setting Test_K mode"); mode = USB_TEST_MODE_K; break; case 'S': case 's': printf("Setting Test_SE0_NAK mode"); mode = USB_TEST_MODE_SE0_NAK; break; case 'P': case 'p': printf("Setting Test_Packet mode"); mode = USB_TEST_MODE_PACKET; break; case 'F': case 'f': printf("Setting Test_Force_Enable mode"); mode = USB_TEST_MODE_FORCE_ENABLE; break; default: printf("Unrecognized test mode: %s Available modes: " "J, K, S[E0_NAK], P[acket], F[orce_Enable] ", arg); return 1; } if (port) printf(" on downstream facing port %d... ", port); else printf(" on upstream facing port... "); if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_FEATURE, port ? USB_RT_PORT : USB_RECIP_DEVICE, port ? USB_PORT_FEAT_TEST : USB_FEAT_TEST, (mode << 8) | port, NULL, 0, USB_CNTL_TIMEOUT) == -1) { printf("Error during SET_FEATURE. "); return 1; } else { printf("Test mode successfully set. Use 'usb start' " "to return to normal operation. "); return 0; } } |
e887afc9d Initial revision |
434 |
|
e887afc9d Initial revision |
435 436 437 438 |
/****************************************************************************** * usb boot command intepreter. Derived from diskboot */ #ifdef CONFIG_USB_STORAGE |
088f1b199 common/cmd_*.c: s... |
439 |
static int do_usbboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
e887afc9d Initial revision |
440 |
{ |
7405a1331 combine block dev... |
441 |
return common_diskboot(cmdtp, "usb", argc, argv); |
e887afc9d Initial revision |
442 443 |
} #endif /* CONFIG_USB_STORAGE */ |
8a8a2257e usb: kbd: Allow "... |
444 |
static int do_usb_stop_keyboard(int force) |
6e78c74f6 usb: kbd: On a "u... |
445 446 |
{ #ifdef CONFIG_USB_KEYBOARD |
8a8a2257e usb: kbd: Allow "... |
447 |
if (usb_kbd_deregister(force) != 0) { |
6e78c74f6 usb: kbd: On a "u... |
448 449 450 451 452 453 454 |
printf("USB not stopped: usbkbd still using USB "); return 1; } #endif return 0; } |
e887afc9d Initial revision |
455 |
|
de39f8c19 USB style patch, ... |
456 |
/****************************************************************************** |
e887afc9d Initial revision |
457 458 |
* usb command intepreter */ |
088f1b199 common/cmd_*.c: s... |
459 |
static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
e887afc9d Initial revision |
460 461 462 463 |
{ int i; struct usb_device *dev = NULL; |
e51aae382 Prevent USB comma... |
464 |
extern char usb_started; |
1968e615d Cleanup USB and p... |
465 |
#ifdef CONFIG_USB_STORAGE |
e887afc9d Initial revision |
466 |
block_dev_desc_t *stor_dev; |
1968e615d Cleanup USB and p... |
467 |
#endif |
e887afc9d Initial revision |
468 |
|
47e26b1bf cmd_usage(): simp... |
469 |
if (argc < 2) |
4c12eeb8b Convert cmd_usage... |
470 |
return CMD_RET_USAGE; |
65d342541 cmd_usb.c: show c... |
471 |
|
9c998aa83 Fix low-level OHC... |
472 |
if ((strncmp(argv[1], "reset", 5) == 0) || |
de39f8c19 USB style patch, ... |
473 |
(strncmp(argv[1], "start", 5) == 0)) { |
573f14fe4 bootstage: Plumb ... |
474 |
bootstage_mark_name(BOOTSTAGE_ID_USB_START, "usb_start"); |
8a8a2257e usb: kbd: Allow "... |
475 |
if (do_usb_stop_keyboard(1) != 0) |
6e78c74f6 usb: kbd: On a "u... |
476 |
return 1; |
e887afc9d Initial revision |
477 478 479 |
usb_stop(); printf("(Re)start USB... "); |
93c2582fe usb: add support ... |
480 |
if (usb_init() >= 0) { |
9c998aa83 Fix low-level OHC... |
481 |
#ifdef CONFIG_USB_STORAGE |
89d48367e Add USB host ethe... |
482 |
/* try to recognize storage devices immediately */ |
53677ef18 Big white-space c... |
483 |
usb_stor_curr_dev = usb_stor_scan(1); |
9c998aa83 Fix low-level OHC... |
484 |
#endif |
89d48367e Add USB host ethe... |
485 486 487 488 |
#ifdef CONFIG_USB_HOST_ETHER /* try to recognize ethernet devices immediately */ usb_ether_curr_dev = usb_host_eth_scan(1); #endif |
93c2582fe usb: add support ... |
489 490 491 |
#ifdef CONFIG_USB_KEYBOARD drv_usb_kbd_init(); #endif |
89d48367e Add USB host ethe... |
492 |
} |
e887afc9d Initial revision |
493 494 |
return 0; } |
de39f8c19 USB style patch, ... |
495 |
if (strncmp(argv[1], "stop", 4) == 0) { |
6e78c74f6 usb: kbd: On a "u... |
496 |
if (argc != 2) |
de39f8c19 USB style patch, ... |
497 |
console_assign(stdin, "serial"); |
8a8a2257e usb: kbd: Allow "... |
498 |
if (do_usb_stop_keyboard(0) != 0) |
6e78c74f6 usb: kbd: On a "u... |
499 |
return 1; |
e887afc9d Initial revision |
500 501 502 503 504 |
printf("stopping USB.. "); usb_stop(); return 0; } |
e51aae382 Prevent USB comma... |
505 506 507 508 509 |
if (!usb_started) { printf("USB is stopped. Please issue 'usb start' first. "); return 1; } |
de39f8c19 USB style patch, ... |
510 |
if (strncmp(argv[1], "tree", 4) == 0) { |
93c2582fe usb: add support ... |
511 512 513 514 515 516 517 518 519 |
puts("USB device tree: "); for (i = 0; i < USB_MAX_DEVICE; i++) { dev = usb_get_dev_index(i); if (dev == NULL) break; if (dev->parent == NULL) usb_show_tree(dev); } |
e887afc9d Initial revision |
520 521 |
return 0; } |
de39f8c19 USB style patch, ... |
522 |
if (strncmp(argv[1], "inf", 3) == 0) { |
e887afc9d Initial revision |
523 |
int d; |
de39f8c19 USB style patch, ... |
524 525 526 527 |
if (argc == 2) { for (d = 0; d < USB_MAX_DEVICE; d++) { dev = usb_get_dev_index(d); if (dev == NULL) |
e887afc9d Initial revision |
528 529 530 531 532 |
break; usb_display_desc(dev); usb_display_config(dev); } return 0; |
de39f8c19 USB style patch, ... |
533 |
} else { |
7d9aa8fd8 usb: Add new comm... |
534 |
i = simple_strtoul(argv[2], NULL, 10); |
de39f8c19 USB style patch, ... |
535 536 |
printf("config for device %d ", i); |
7d9aa8fd8 usb: Add new comm... |
537 |
dev = usb_find_device(i); |
de39f8c19 USB style patch, ... |
538 |
if (dev == NULL) { |
6052cbab4 Fix misc spelling... |
539 540 |
printf("*** No device available *** "); |
e887afc9d Initial revision |
541 |
return 0; |
de39f8c19 USB style patch, ... |
542 |
} else { |
e887afc9d Initial revision |
543 544 545 546 547 548 |
usb_display_desc(dev); usb_display_config(dev); } } return 0; } |
7d9aa8fd8 usb: Add new comm... |
549 550 551 552 553 554 555 556 557 558 559 560 561 |
if (strncmp(argv[1], "test", 4) == 0) { if (argc < 5) return CMD_RET_USAGE; i = simple_strtoul(argv[2], NULL, 10); dev = usb_find_device(i); if (dev == NULL) { printf("Device %d does not exist. ", i); return 1; } i = simple_strtoul(argv[3], NULL, 10); return usb_test(dev, i, argv[4]); } |
e887afc9d Initial revision |
562 |
#ifdef CONFIG_USB_STORAGE |
de39f8c19 USB style patch, ... |
563 |
if (strncmp(argv[1], "stor", 4) == 0) |
f6b44e0e4 USB Storage, add ... |
564 |
return usb_stor_info(); |
9c998aa83 Fix low-level OHC... |
565 |
|
de39f8c19 USB style patch, ... |
566 |
if (strncmp(argv[1], "part", 4) == 0) { |
d4b5f3fa0 Fix "usb part" co... |
567 |
int devno, ok = 0; |
de39f8c19 USB style patch, ... |
568 |
if (argc == 2) { |
aaad108b8 USB storage count |
569 |
for (devno = 0; ; ++devno) { |
de39f8c19 USB style patch, ... |
570 |
stor_dev = usb_stor_get_dev(devno); |
aaad108b8 USB storage count |
571 572 |
if (stor_dev == NULL) break; |
de39f8c19 USB style patch, ... |
573 |
if (stor_dev->type != DEV_TYPE_UNKNOWN) { |
d4b5f3fa0 Fix "usb part" co... |
574 575 576 577 |
ok++; if (devno) printf(" "); |
060f28532 cmd_usb.c: print ... |
578 579 |
debug("print_part of %x ", devno); |
d4b5f3fa0 Fix "usb part" co... |
580 581 582 |
print_part(stor_dev); } } |
de39f8c19 USB style patch, ... |
583 584 585 |
} else { devno = simple_strtoul(argv[2], NULL, 16); stor_dev = usb_stor_get_dev(devno); |
aaad108b8 USB storage count |
586 587 |
if (stor_dev != NULL && stor_dev->type != DEV_TYPE_UNKNOWN) { |
e887afc9d Initial revision |
588 |
ok++; |
060f28532 cmd_usb.c: print ... |
589 590 |
debug("print_part of %x ", devno); |
e887afc9d Initial revision |
591 592 593 594 595 596 597 598 599 600 601 |
print_part(stor_dev); } } if (!ok) { printf(" no USB devices available "); return 1; } return 0; } |
de39f8c19 USB style patch, ... |
602 603 |
if (strcmp(argv[1], "read") == 0) { if (usb_stor_curr_dev < 0) { |
e887afc9d Initial revision |
604 605 606 607 |
printf("no current device selected "); return 1; } |
de39f8c19 USB style patch, ... |
608 |
if (argc == 5) { |
e887afc9d Initial revision |
609 610 611 612 |
unsigned long addr = simple_strtoul(argv[2], NULL, 16); unsigned long blk = simple_strtoul(argv[3], NULL, 16); unsigned long cnt = simple_strtoul(argv[4], NULL, 16); unsigned long n; |
de39f8c19 USB style patch, ... |
613 614 615 616 617 618 619 620 621 622 |
printf(" USB read: device %d block # %ld, count %ld" " ... ", usb_stor_curr_dev, blk, cnt); stor_dev = usb_stor_get_dev(usb_stor_curr_dev); n = stor_dev->block_read(usb_stor_curr_dev, blk, cnt, (ulong *)addr); printf("%ld blocks read: %s ", n, (n == cnt) ? "OK" : "ERROR"); if (n == cnt) |
e887afc9d Initial revision |
623 624 625 626 |
return 0; return 1; } } |
127e10842 usb: write comman... |
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
if (strcmp(argv[1], "write") == 0) { if (usb_stor_curr_dev < 0) { printf("no current device selected "); return 1; } if (argc == 5) { unsigned long addr = simple_strtoul(argv[2], NULL, 16); unsigned long blk = simple_strtoul(argv[3], NULL, 16); unsigned long cnt = simple_strtoul(argv[4], NULL, 16); unsigned long n; printf(" USB write: device %d block # %ld, count %ld" " ... ", usb_stor_curr_dev, blk, cnt); stor_dev = usb_stor_get_dev(usb_stor_curr_dev); n = stor_dev->block_write(usb_stor_curr_dev, blk, cnt, (ulong *)addr); printf("%ld blocks write: %s ", n, (n == cnt) ? "OK" : "ERROR"); if (n == cnt) return 0; return 1; } } |
9c998aa83 Fix low-level OHC... |
652 653 |
if (strncmp(argv[1], "dev", 3) == 0) { if (argc == 3) { |
e887afc9d Initial revision |
654 |
int dev = (int)simple_strtoul(argv[2], NULL, 10); |
de39f8c19 USB style patch, ... |
655 656 |
printf(" USB device %d: ", dev); |
aaad108b8 USB storage count |
657 658 |
stor_dev = usb_stor_get_dev(dev); if (stor_dev == NULL) { |
e887afc9d Initial revision |
659 660 661 662 |
printf("unknown device "); return 1; } |
de39f8c19 USB style patch, ... |
663 664 |
printf(" Device %d: ", dev); |
e887afc9d Initial revision |
665 |
dev_print(stor_dev); |
de39f8c19 USB style patch, ... |
666 |
if (stor_dev->type == DEV_TYPE_UNKNOWN) |
e887afc9d Initial revision |
667 |
return 1; |
e887afc9d Initial revision |
668 669 670 671 |
usb_stor_curr_dev = dev; printf("... is now current device "); return 0; |
de39f8c19 USB style patch, ... |
672 673 674 675 |
} else { printf(" USB device %d: ", usb_stor_curr_dev); stor_dev = usb_stor_get_dev(usb_stor_curr_dev); |
e887afc9d Initial revision |
676 |
dev_print(stor_dev); |
de39f8c19 USB style patch, ... |
677 |
if (stor_dev->type == DEV_TYPE_UNKNOWN) |
e887afc9d Initial revision |
678 |
return 1; |
e887afc9d Initial revision |
679 680 681 682 683 |
return 0; } return 0; } #endif /* CONFIG_USB_STORAGE */ |
4c12eeb8b Convert cmd_usage... |
684 |
return CMD_RET_USAGE; |
e887afc9d Initial revision |
685 |
} |
0d4983930 Patch by Kenneth ... |
686 687 |
U_BOOT_CMD( usb, 5, 1, do_usb, |
2fb2604d5 Command usage cle... |
688 |
"USB sub-system", |
1af9f9633 usb: add help for... |
689 690 691 692 |
"start - start (scan) USB controller " "usb reset - reset (rescan) USB controller " |
b3813a221 cosmetic: remove ... |
693 694 695 696 |
"usb stop [f] - stop USB [f]=force stop " "usb tree - show USB device tree " |
5cf91d6bd * Modify KUP4X bo... |
697 698 |
"usb info [dev] - show available USB devices " |
7d9aa8fd8 usb: Add new comm... |
699 700 701 702 703 704 705 |
"usb test [dev] [port] [mode] - set USB 2.0 test mode " " (specify port 0 to indicate the device's upstream port) " " Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable] " #ifdef CONFIG_USB_STORAGE |
b3813a221 cosmetic: remove ... |
706 707 |
"usb storage - show details of USB storage devices " |
342717f72 * Fix baudrate ca... |
708 709 |
"usb dev [dev] - show or set current USB storage device " |
de39f8c19 USB style patch, ... |
710 |
"usb part [dev] - print partition table of one or all USB storage" |
7d9aa8fd8 usb: Add new comm... |
711 712 |
" devices " |
5cf91d6bd * Modify KUP4X bo... |
713 714 |
"usb read addr blk# cnt - read `cnt' blocks starting at block `blk#' " |
842404ea0 Fixed clobbered o... |
715 716 |
" to memory address `addr' " |
127e10842 usb: write comman... |
717 718 719 |
"usb write addr blk# cnt - write `cnt' blocks starting at block `blk#' " " from memory address `addr'" |
7d9aa8fd8 usb: Add new comm... |
720 |
#endif /* CONFIG_USB_STORAGE */ |
8bde7f776 * Code cleanup: |
721 |
); |
7d9aa8fd8 usb: Add new comm... |
722 |
#ifdef CONFIG_USB_STORAGE |
0d4983930 Patch by Kenneth ... |
723 724 |
U_BOOT_CMD( usbboot, 3, 1, do_usbboot, |
2fb2604d5 Command usage cle... |
725 |
"boot from USB device", |
a89c33db9 General help mess... |
726 |
"loadAddr dev:part" |
8bde7f776 * Code cleanup: |
727 |
); |
7d9aa8fd8 usb: Add new comm... |
728 |
#endif /* CONFIG_USB_STORAGE */ |