| .. | .. |
|---|
| 47 | 47 | return pci_byte_size(size) * 2; |
|---|
| 48 | 48 | } |
|---|
| 49 | 49 | |
|---|
| 50 | | -#ifdef CONFIG_DM_PCI |
|---|
| 51 | 50 | static void pci_show_regs(struct udevice *dev, struct pci_reg_info *regs) |
|---|
| 52 | 51 | { |
|---|
| 53 | 52 | for (; regs->name; regs++) { |
|---|
| .. | .. |
|---|
| 59 | 58 | pci_field_width(regs->size), val); |
|---|
| 60 | 59 | } |
|---|
| 61 | 60 | } |
|---|
| 62 | | -#else |
|---|
| 63 | | -static unsigned long pci_read_config(pci_dev_t dev, int offset, |
|---|
| 64 | | - enum pci_size_t size) |
|---|
| 65 | | -{ |
|---|
| 66 | | - u32 val32; |
|---|
| 67 | | - u16 val16; |
|---|
| 68 | | - u8 val8; |
|---|
| 69 | 61 | |
|---|
| 70 | | - switch (size) { |
|---|
| 71 | | - case PCI_SIZE_8: |
|---|
| 72 | | - pci_read_config_byte(dev, offset, &val8); |
|---|
| 73 | | - return val8; |
|---|
| 74 | | - case PCI_SIZE_16: |
|---|
| 75 | | - pci_read_config_word(dev, offset, &val16); |
|---|
| 76 | | - return val16; |
|---|
| 77 | | - case PCI_SIZE_32: |
|---|
| 78 | | - default: |
|---|
| 79 | | - pci_read_config_dword(dev, offset, &val32); |
|---|
| 80 | | - return val32; |
|---|
| 81 | | - } |
|---|
| 82 | | -} |
|---|
| 83 | | - |
|---|
| 84 | | -static void pci_show_regs(pci_dev_t dev, struct pci_reg_info *regs) |
|---|
| 85 | | -{ |
|---|
| 86 | | - for (; regs->name; regs++) { |
|---|
| 87 | | - printf(" %s =%*s%#.*lx\n", regs->name, |
|---|
| 88 | | - (int)(28 - strlen(regs->name)), "", |
|---|
| 89 | | - pci_field_width(regs->size), |
|---|
| 90 | | - pci_read_config(dev, regs->offset, regs->size)); |
|---|
| 91 | | - } |
|---|
| 92 | | -} |
|---|
| 93 | | -#endif |
|---|
| 94 | | - |
|---|
| 95 | | -#ifdef CONFIG_DM_PCI |
|---|
| 96 | | -int pci_bar_show(struct udevice *dev) |
|---|
| 62 | +static int pci_bar_show(struct udevice *dev) |
|---|
| 97 | 63 | { |
|---|
| 98 | 64 | u8 header_type; |
|---|
| 99 | 65 | int bar_cnt, bar_id, mem_type; |
|---|
| .. | .. |
|---|
| 105 | 71 | int prefetchable; |
|---|
| 106 | 72 | |
|---|
| 107 | 73 | dm_pci_read_config8(dev, PCI_HEADER_TYPE, &header_type); |
|---|
| 74 | + header_type &= 0x7f; |
|---|
| 108 | 75 | |
|---|
| 109 | 76 | if (header_type == PCI_HEADER_TYPE_CARDBUS) { |
|---|
| 110 | 77 | printf("CardBus doesn't support BARs\n"); |
|---|
| 78 | + return -ENOSYS; |
|---|
| 79 | + } else if (header_type != PCI_HEADER_TYPE_NORMAL && |
|---|
| 80 | + header_type != PCI_HEADER_TYPE_BRIDGE) { |
|---|
| 81 | + printf("unknown header type\n"); |
|---|
| 111 | 82 | return -ENOSYS; |
|---|
| 112 | 83 | } |
|---|
| 113 | 84 | |
|---|
| .. | .. |
|---|
| 149 | 120 | |
|---|
| 150 | 121 | if ((!is_64 && size_low) || (is_64 && size)) { |
|---|
| 151 | 122 | size = ~size + 1; |
|---|
| 152 | | - printf(" %d %#016llx %#016llx %d %s %s\n", |
|---|
| 123 | + printf(" %d %#018llx %#018llx %d %s %s\n", |
|---|
| 153 | 124 | bar_id, (unsigned long long)base, |
|---|
| 154 | 125 | (unsigned long long)size, is_64 ? 64 : 32, |
|---|
| 155 | 126 | is_io ? "I/O" : "MEM", |
|---|
| .. | .. |
|---|
| 162 | 133 | |
|---|
| 163 | 134 | return 0; |
|---|
| 164 | 135 | } |
|---|
| 165 | | -#endif |
|---|
| 166 | 136 | |
|---|
| 167 | 137 | static struct pci_reg_info regs_start[] = { |
|---|
| 168 | 138 | { "vendor ID", PCI_SIZE_16, PCI_VENDOR_ID }, |
|---|
| .. | .. |
|---|
| 258 | 228 | * |
|---|
| 259 | 229 | * @dev: Bus+Device+Function number |
|---|
| 260 | 230 | */ |
|---|
| 261 | | -#ifdef CONFIG_DM_PCI |
|---|
| 262 | | -void pci_header_show(struct udevice *dev) |
|---|
| 263 | | -#else |
|---|
| 264 | | -void pci_header_show(pci_dev_t dev) |
|---|
| 265 | | -#endif |
|---|
| 231 | +static void pci_header_show(struct udevice *dev) |
|---|
| 266 | 232 | { |
|---|
| 267 | | -#ifdef CONFIG_DM_PCI |
|---|
| 268 | 233 | unsigned long class, header_type; |
|---|
| 269 | 234 | |
|---|
| 270 | 235 | dm_pci_read_config(dev, PCI_CLASS_CODE, &class, PCI_SIZE_8); |
|---|
| 271 | 236 | dm_pci_read_config(dev, PCI_HEADER_TYPE, &header_type, PCI_SIZE_8); |
|---|
| 272 | | -#else |
|---|
| 273 | | - u8 class, header_type; |
|---|
| 274 | | - |
|---|
| 275 | | - pci_read_config_byte(dev, PCI_CLASS_CODE, &class); |
|---|
| 276 | | - pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type); |
|---|
| 277 | | -#endif |
|---|
| 278 | 237 | pci_show_regs(dev, regs_start); |
|---|
| 279 | 238 | printf(" class code = 0x%.2x (%s)\n", (int)class, |
|---|
| 280 | 239 | pci_class_str(class)); |
|---|
| 281 | 240 | pci_show_regs(dev, regs_rest); |
|---|
| 282 | 241 | |
|---|
| 283 | | - switch (header_type & 0x03) { |
|---|
| 242 | + switch (header_type & 0x7f) { |
|---|
| 284 | 243 | case PCI_HEADER_TYPE_NORMAL: /* "normal" PCI device */ |
|---|
| 285 | 244 | pci_show_regs(dev, regs_normal); |
|---|
| 286 | 245 | break; |
|---|
| .. | .. |
|---|
| 297 | 256 | } |
|---|
| 298 | 257 | } |
|---|
| 299 | 258 | |
|---|
| 300 | | -void pciinfo_header(int busnum, bool short_listing) |
|---|
| 259 | +static void pciinfo_header(bool short_listing) |
|---|
| 301 | 260 | { |
|---|
| 302 | | - printf("Scanning PCI devices on bus %d\n", busnum); |
|---|
| 303 | | - |
|---|
| 304 | 261 | if (short_listing) { |
|---|
| 305 | 262 | printf("BusDevFun VendorId DeviceId Device Class Sub-Class\n"); |
|---|
| 306 | 263 | printf("_____________________________________________________________\n"); |
|---|
| 307 | 264 | } |
|---|
| 308 | 265 | } |
|---|
| 309 | 266 | |
|---|
| 310 | | -#ifdef CONFIG_DM_PCI |
|---|
| 311 | 267 | /** |
|---|
| 312 | 268 | * pci_header_show_brief() - Show the short-form PCI device header |
|---|
| 313 | 269 | * |
|---|
| .. | .. |
|---|
| 330 | 286 | pci_class_str(class), subclass); |
|---|
| 331 | 287 | } |
|---|
| 332 | 288 | |
|---|
| 333 | | -static void pciinfo(struct udevice *bus, bool short_listing) |
|---|
| 289 | +static void pciinfo(struct udevice *bus, bool short_listing, bool multi) |
|---|
| 334 | 290 | { |
|---|
| 335 | 291 | struct udevice *dev; |
|---|
| 336 | 292 | |
|---|
| 337 | | - pciinfo_header(bus->seq, short_listing); |
|---|
| 293 | + if (!multi) |
|---|
| 294 | + printf("Scanning PCI devices on bus %d\n", bus->seq); |
|---|
| 295 | + |
|---|
| 296 | + if (!multi || bus->seq == 0) |
|---|
| 297 | + pciinfo_header(short_listing); |
|---|
| 338 | 298 | |
|---|
| 339 | 299 | for (device_find_first_child(bus, &dev); |
|---|
| 340 | 300 | dev; |
|---|
| .. | .. |
|---|
| 353 | 313 | } |
|---|
| 354 | 314 | } |
|---|
| 355 | 315 | } |
|---|
| 356 | | - |
|---|
| 357 | | -#else |
|---|
| 358 | | - |
|---|
| 359 | | -/** |
|---|
| 360 | | - * pci_header_show_brief() - Show the short-form PCI device header |
|---|
| 361 | | - * |
|---|
| 362 | | - * Reads and prints the header of the specified PCI device in short form. |
|---|
| 363 | | - * |
|---|
| 364 | | - * @dev: Bus+Device+Function number |
|---|
| 365 | | - */ |
|---|
| 366 | | -void pci_header_show_brief(pci_dev_t dev) |
|---|
| 367 | | -{ |
|---|
| 368 | | - u16 vendor, device; |
|---|
| 369 | | - u8 class, subclass; |
|---|
| 370 | | - |
|---|
| 371 | | - pci_read_config_word(dev, PCI_VENDOR_ID, &vendor); |
|---|
| 372 | | - pci_read_config_word(dev, PCI_DEVICE_ID, &device); |
|---|
| 373 | | - pci_read_config_byte(dev, PCI_CLASS_CODE, &class); |
|---|
| 374 | | - pci_read_config_byte(dev, PCI_CLASS_SUB_CODE, &subclass); |
|---|
| 375 | | - |
|---|
| 376 | | - printf("0x%.4x 0x%.4x %-23s 0x%.2x\n", |
|---|
| 377 | | - vendor, device, |
|---|
| 378 | | - pci_class_str(class), subclass); |
|---|
| 379 | | -} |
|---|
| 380 | | - |
|---|
| 381 | | -/** |
|---|
| 382 | | - * pciinfo() - Show a list of devices on the PCI bus |
|---|
| 383 | | - * |
|---|
| 384 | | - * Show information about devices on PCI bus. Depending on @short_pci_listing |
|---|
| 385 | | - * the output will be more or less exhaustive. |
|---|
| 386 | | - * |
|---|
| 387 | | - * @bus_num: The number of the bus to be scanned |
|---|
| 388 | | - * @short_pci_listing: true to use short form, showing only a brief header |
|---|
| 389 | | - * for each device |
|---|
| 390 | | - */ |
|---|
| 391 | | -void pciinfo(int bus_num, int short_pci_listing) |
|---|
| 392 | | -{ |
|---|
| 393 | | - struct pci_controller *hose = pci_bus_to_hose(bus_num); |
|---|
| 394 | | - int device; |
|---|
| 395 | | - int function; |
|---|
| 396 | | - unsigned char header_type; |
|---|
| 397 | | - unsigned short vendor_id; |
|---|
| 398 | | - pci_dev_t dev; |
|---|
| 399 | | - int ret; |
|---|
| 400 | | - |
|---|
| 401 | | - if (!hose) |
|---|
| 402 | | - return; |
|---|
| 403 | | - |
|---|
| 404 | | - pciinfo_header(bus_num, short_pci_listing); |
|---|
| 405 | | - |
|---|
| 406 | | - for (device = 0; device < PCI_MAX_PCI_DEVICES; device++) { |
|---|
| 407 | | - header_type = 0; |
|---|
| 408 | | - vendor_id = 0; |
|---|
| 409 | | - for (function = 0; function < PCI_MAX_PCI_FUNCTIONS; |
|---|
| 410 | | - function++) { |
|---|
| 411 | | - /* |
|---|
| 412 | | - * If this is not a multi-function device, we skip |
|---|
| 413 | | - * the rest. |
|---|
| 414 | | - */ |
|---|
| 415 | | - if (function && !(header_type & 0x80)) |
|---|
| 416 | | - break; |
|---|
| 417 | | - |
|---|
| 418 | | - dev = PCI_BDF(bus_num, device, function); |
|---|
| 419 | | - |
|---|
| 420 | | - if (pci_skip_dev(hose, dev)) |
|---|
| 421 | | - continue; |
|---|
| 422 | | - |
|---|
| 423 | | - ret = pci_read_config_word(dev, PCI_VENDOR_ID, |
|---|
| 424 | | - &vendor_id); |
|---|
| 425 | | - if (ret) |
|---|
| 426 | | - goto error; |
|---|
| 427 | | - if ((vendor_id == 0xFFFF) || (vendor_id == 0x0000)) |
|---|
| 428 | | - continue; |
|---|
| 429 | | - |
|---|
| 430 | | - if (!function) { |
|---|
| 431 | | - pci_read_config_byte(dev, PCI_HEADER_TYPE, |
|---|
| 432 | | - &header_type); |
|---|
| 433 | | - } |
|---|
| 434 | | - |
|---|
| 435 | | - if (short_pci_listing) { |
|---|
| 436 | | - printf("%02x.%02x.%02x ", bus_num, device, |
|---|
| 437 | | - function); |
|---|
| 438 | | - pci_header_show_brief(dev); |
|---|
| 439 | | - } else { |
|---|
| 440 | | - printf("\nFound PCI device %02x.%02x.%02x:\n", |
|---|
| 441 | | - bus_num, device, function); |
|---|
| 442 | | - pci_header_show(dev); |
|---|
| 443 | | - } |
|---|
| 444 | | - } |
|---|
| 445 | | - } |
|---|
| 446 | | - |
|---|
| 447 | | - return; |
|---|
| 448 | | -error: |
|---|
| 449 | | - printf("Cannot read bus configuration: %d\n", ret); |
|---|
| 450 | | -} |
|---|
| 451 | | -#endif |
|---|
| 452 | 316 | |
|---|
| 453 | 317 | /** |
|---|
| 454 | 318 | * get_pci_dev() - Convert the "bus.device.function" identifier into a number |
|---|
| .. | .. |
|---|
| 481 | 345 | return PCI_BDF(bdfs[0], bdfs[1], bdfs[2]); |
|---|
| 482 | 346 | } |
|---|
| 483 | 347 | |
|---|
| 484 | | -#ifdef CONFIG_DM_PCI |
|---|
| 485 | 348 | static int pci_cfg_display(struct udevice *dev, ulong addr, |
|---|
| 486 | 349 | enum pci_size_t size, ulong length) |
|---|
| 487 | | -#else |
|---|
| 488 | | -static int pci_cfg_display(pci_dev_t bdf, ulong addr, enum pci_size_t size, |
|---|
| 489 | | - ulong length) |
|---|
| 490 | | -#endif |
|---|
| 491 | 350 | { |
|---|
| 492 | 351 | #define DISP_LINE_LEN 16 |
|---|
| 493 | 352 | ulong i, nbytes, linebytes; |
|---|
| .. | .. |
|---|
| 508 | 367 | for (i = 0; i < linebytes; i += byte_size) { |
|---|
| 509 | 368 | unsigned long val; |
|---|
| 510 | 369 | |
|---|
| 511 | | -#ifdef CONFIG_DM_PCI |
|---|
| 512 | 370 | dm_pci_read_config(dev, addr, &val, size); |
|---|
| 513 | | -#else |
|---|
| 514 | | - val = pci_read_config(bdf, addr, size); |
|---|
| 515 | | -#endif |
|---|
| 516 | 371 | printf(" %0*lx", pci_field_width(size), val); |
|---|
| 517 | 372 | addr += byte_size; |
|---|
| 518 | 373 | } |
|---|
| .. | .. |
|---|
| 527 | 382 | return (rc); |
|---|
| 528 | 383 | } |
|---|
| 529 | 384 | |
|---|
| 530 | | -#ifndef CONFIG_DM_PCI |
|---|
| 531 | | -static int pci_cfg_write (pci_dev_t bdf, ulong addr, ulong size, ulong value) |
|---|
| 532 | | -{ |
|---|
| 533 | | - if (size == 4) { |
|---|
| 534 | | - pci_write_config_dword(bdf, addr, value); |
|---|
| 535 | | - } |
|---|
| 536 | | - else if (size == 2) { |
|---|
| 537 | | - ushort val = value & 0xffff; |
|---|
| 538 | | - pci_write_config_word(bdf, addr, val); |
|---|
| 539 | | - } |
|---|
| 540 | | - else { |
|---|
| 541 | | - u_char val = value & 0xff; |
|---|
| 542 | | - pci_write_config_byte(bdf, addr, val); |
|---|
| 543 | | - } |
|---|
| 544 | | - return 0; |
|---|
| 545 | | -} |
|---|
| 546 | | -#endif |
|---|
| 547 | | - |
|---|
| 548 | | -#ifdef CONFIG_DM_PCI |
|---|
| 549 | 385 | static int pci_cfg_modify(struct udevice *dev, ulong addr, ulong size, |
|---|
| 550 | 386 | ulong value, int incrflag) |
|---|
| 551 | | -#else |
|---|
| 552 | | -static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value, |
|---|
| 553 | | - int incrflag) |
|---|
| 554 | | -#endif |
|---|
| 555 | 387 | { |
|---|
| 556 | 388 | ulong i; |
|---|
| 557 | 389 | int nbytes; |
|---|
| .. | .. |
|---|
| 562 | 394 | */ |
|---|
| 563 | 395 | do { |
|---|
| 564 | 396 | printf("%08lx:", addr); |
|---|
| 565 | | -#ifdef CONFIG_DM_PCI |
|---|
| 566 | 397 | dm_pci_read_config(dev, addr, &val, size); |
|---|
| 567 | | -#else |
|---|
| 568 | | - val = pci_read_config(bdf, addr, size); |
|---|
| 569 | | -#endif |
|---|
| 570 | 398 | printf(" %0*lx", pci_field_width(size), val); |
|---|
| 571 | 399 | |
|---|
| 572 | 400 | nbytes = cli_readline(" ? "); |
|---|
| .. | .. |
|---|
| 593 | 421 | /* good enough to not time out |
|---|
| 594 | 422 | */ |
|---|
| 595 | 423 | bootretry_reset_cmd_timeout(); |
|---|
| 596 | | -#ifdef CONFIG_DM_PCI |
|---|
| 597 | 424 | dm_pci_write_config(dev, addr, i, size); |
|---|
| 598 | | -#else |
|---|
| 599 | | - pci_cfg_write(bdf, addr, size, i); |
|---|
| 600 | | -#endif |
|---|
| 601 | 425 | if (incrflag) |
|---|
| 602 | 426 | addr += size; |
|---|
| 603 | 427 | } |
|---|
| .. | .. |
|---|
| 607 | 431 | return 0; |
|---|
| 608 | 432 | } |
|---|
| 609 | 433 | |
|---|
| 610 | | -#ifdef CONFIG_DM_PCI |
|---|
| 611 | 434 | static const struct pci_flag_info { |
|---|
| 612 | 435 | uint flag; |
|---|
| 613 | 436 | const char *name; |
|---|
| .. | .. |
|---|
| 621 | 444 | |
|---|
| 622 | 445 | static void pci_show_regions(struct udevice *bus) |
|---|
| 623 | 446 | { |
|---|
| 624 | | - struct pci_controller *hose = dev_get_uclass_priv(bus); |
|---|
| 447 | + struct pci_controller *hose = dev_get_uclass_priv(pci_get_controller(bus)); |
|---|
| 625 | 448 | const struct pci_region *reg; |
|---|
| 626 | 449 | int i, j; |
|---|
| 627 | 450 | |
|---|
| .. | .. |
|---|
| 630 | 453 | return; |
|---|
| 631 | 454 | } |
|---|
| 632 | 455 | |
|---|
| 633 | | - printf("# %-16s %-16s %-16s %s\n", "Bus start", "Phys start", "Size", |
|---|
| 456 | + printf("Buses %02x-%02x\n", hose->first_busno, hose->last_busno); |
|---|
| 457 | + printf("# %-18s %-18s %-18s %s\n", "Bus start", "Phys start", "Size", |
|---|
| 634 | 458 | "Flags"); |
|---|
| 635 | 459 | for (i = 0, reg = hose->regions; i < hose->region_count; i++, reg++) { |
|---|
| 636 | | - printf("%d %#016llx %#016llx %#016llx ", i, |
|---|
| 460 | + printf("%d %#018llx %#018llx %#018llx ", i, |
|---|
| 637 | 461 | (unsigned long long)reg->bus_start, |
|---|
| 638 | 462 | (unsigned long long)reg->phys_start, |
|---|
| 639 | 463 | (unsigned long long)reg->size); |
|---|
| .. | .. |
|---|
| 646 | 470 | printf("\n"); |
|---|
| 647 | 471 | } |
|---|
| 648 | 472 | } |
|---|
| 649 | | -#endif |
|---|
| 650 | 473 | |
|---|
| 651 | 474 | /* PCI Configuration Space access commands |
|---|
| 652 | 475 | * |
|---|
| .. | .. |
|---|
| 660 | 483 | { |
|---|
| 661 | 484 | ulong addr = 0, value = 0, cmd_size = 0; |
|---|
| 662 | 485 | enum pci_size_t size = PCI_SIZE_32; |
|---|
| 663 | | -#ifdef CONFIG_DM_PCI |
|---|
| 664 | 486 | struct udevice *dev, *bus; |
|---|
| 665 | | -#else |
|---|
| 666 | | - pci_dev_t dev; |
|---|
| 667 | | -#endif |
|---|
| 668 | | - int busnum = 0; |
|---|
| 487 | + int busnum = -1; |
|---|
| 669 | 488 | pci_dev_t bdf = 0; |
|---|
| 670 | 489 | char cmd = 's'; |
|---|
| 671 | 490 | int ret = 0; |
|---|
| 491 | + char *endp; |
|---|
| 672 | 492 | |
|---|
| 673 | 493 | if (argc > 1) |
|---|
| 674 | 494 | cmd = argv[1][0]; |
|---|
| .. | .. |
|---|
| 686 | 506 | if (argc > 4) |
|---|
| 687 | 507 | value = simple_strtoul(argv[4], NULL, 16); |
|---|
| 688 | 508 | case 'h': /* header */ |
|---|
| 689 | | -#ifdef CONFIG_DM_PCI |
|---|
| 690 | 509 | case 'b': /* bars */ |
|---|
| 691 | | -#endif |
|---|
| 692 | 510 | if (argc < 3) |
|---|
| 693 | 511 | goto usage; |
|---|
| 694 | 512 | if ((bdf = get_pci_dev(argv[2])) == -1) |
|---|
| 695 | 513 | return 1; |
|---|
| 696 | 514 | break; |
|---|
| 697 | | -#if defined(CONFIG_DM_PCI) |
|---|
| 698 | 515 | case 'e': |
|---|
| 699 | 516 | pci_init(); |
|---|
| 700 | 517 | return 0; |
|---|
| 701 | | -#endif |
|---|
| 702 | 518 | case 'r': /* no break */ |
|---|
| 703 | 519 | default: /* scan bus */ |
|---|
| 704 | 520 | value = 1; /* short listing */ |
|---|
| .. | .. |
|---|
| 707 | 523 | value = 0; |
|---|
| 708 | 524 | argc--; |
|---|
| 709 | 525 | } |
|---|
| 710 | | - if (argc > 1) |
|---|
| 711 | | - busnum = simple_strtoul(argv[1], NULL, 16); |
|---|
| 526 | + if (argc > 2 || (argc > 1 && cmd != 'r' && argv[1][0] != 's')) { |
|---|
| 527 | + if (argv[argc - 1][0] != '*') { |
|---|
| 528 | + busnum = simple_strtoul(argv[argc - 1], &endp, 16); |
|---|
| 529 | + if (*endp) |
|---|
| 530 | + goto usage; |
|---|
| 531 | + } |
|---|
| 532 | + argc--; |
|---|
| 533 | + } |
|---|
| 534 | + if (cmd == 'r' && argc > 2) |
|---|
| 535 | + goto usage; |
|---|
| 536 | + else if (cmd != 'r' && (argc > 2 || (argc == 2 && argv[1][0] != 's'))) |
|---|
| 537 | + goto usage; |
|---|
| 712 | 538 | } |
|---|
| 713 | | -#ifdef CONFIG_DM_PCI |
|---|
| 539 | + if (busnum == -1) { |
|---|
| 540 | + if (cmd != 'r') { |
|---|
| 541 | + for (busnum = 0; |
|---|
| 542 | + uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus) == 0; |
|---|
| 543 | + busnum++) |
|---|
| 544 | + pciinfo(bus, value, true); |
|---|
| 545 | + } else { |
|---|
| 546 | + for (busnum = 0; |
|---|
| 547 | + uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus) == 0; |
|---|
| 548 | + busnum++) { |
|---|
| 549 | + /* Regions are controller specific so skip non-root buses */ |
|---|
| 550 | + if (device_is_on_pci_bus(bus)) |
|---|
| 551 | + continue; |
|---|
| 552 | + pci_show_regions(bus); |
|---|
| 553 | + } |
|---|
| 554 | + } |
|---|
| 555 | + return 0; |
|---|
| 556 | + } |
|---|
| 714 | 557 | ret = uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus); |
|---|
| 715 | 558 | if (ret) { |
|---|
| 716 | 559 | printf("No such bus\n"); |
|---|
| .. | .. |
|---|
| 719 | 562 | if (cmd == 'r') |
|---|
| 720 | 563 | pci_show_regions(bus); |
|---|
| 721 | 564 | else |
|---|
| 722 | | - pciinfo(bus, value); |
|---|
| 723 | | -#else |
|---|
| 724 | | - pciinfo(busnum, value); |
|---|
| 725 | | -#endif |
|---|
| 565 | + pciinfo(bus, value, false); |
|---|
| 726 | 566 | return 0; |
|---|
| 727 | 567 | } |
|---|
| 728 | 568 | |
|---|
| 729 | | -#ifdef CONFIG_DM_PCI |
|---|
| 730 | 569 | ret = dm_pci_bus_find_bdf(bdf, &dev); |
|---|
| 731 | 570 | if (ret) { |
|---|
| 732 | 571 | printf("No such device\n"); |
|---|
| 733 | 572 | return CMD_RET_FAILURE; |
|---|
| 734 | 573 | } |
|---|
| 735 | | -#else |
|---|
| 736 | | - dev = bdf; |
|---|
| 737 | | -#endif |
|---|
| 738 | 574 | |
|---|
| 739 | 575 | switch (argv[1][0]) { |
|---|
| 740 | 576 | case 'h': /* header */ |
|---|
| .. | .. |
|---|
| 755 | 591 | case 'w': /* write */ |
|---|
| 756 | 592 | if (argc < 5) |
|---|
| 757 | 593 | goto usage; |
|---|
| 758 | | -#ifdef CONFIG_DM_PCI |
|---|
| 759 | 594 | ret = dm_pci_write_config(dev, addr, value, size); |
|---|
| 760 | | -#else |
|---|
| 761 | | - ret = pci_cfg_write(dev, addr, size, value); |
|---|
| 762 | | -#endif |
|---|
| 763 | 595 | break; |
|---|
| 764 | | -#ifdef CONFIG_DM_PCI |
|---|
| 765 | | - |
|---|
| 766 | 596 | case 'b': /* bars */ |
|---|
| 767 | 597 | return pci_bar_show(dev); |
|---|
| 768 | | -#endif |
|---|
| 769 | 598 | default: |
|---|
| 770 | 599 | ret = CMD_RET_USAGE; |
|---|
| 771 | 600 | break; |
|---|
| .. | .. |
|---|
| 780 | 609 | |
|---|
| 781 | 610 | #ifdef CONFIG_SYS_LONGHELP |
|---|
| 782 | 611 | static char pci_help_text[] = |
|---|
| 783 | | - "[bus] [long]\n" |
|---|
| 612 | + "[bus|*] [long]\n" |
|---|
| 784 | 613 | " - short or long list of PCI devices on bus 'bus'\n" |
|---|
| 785 | | -#if defined(CONFIG_DM_PCI) |
|---|
| 786 | 614 | "pci enum\n" |
|---|
| 787 | 615 | " - Enumerate PCI buses\n" |
|---|
| 788 | | -#endif |
|---|
| 789 | 616 | "pci header b.d.f\n" |
|---|
| 790 | 617 | " - show header of PCI device 'bus.device.function'\n" |
|---|
| 791 | | -#ifdef CONFIG_DM_PCI |
|---|
| 792 | 618 | "pci bar b.d.f\n" |
|---|
| 793 | 619 | " - show BARs base and size for device b.d.f'\n" |
|---|
| 794 | | - "pci regions\n" |
|---|
| 620 | + "pci regions [bus|*]\n" |
|---|
| 795 | 621 | " - show PCI regions\n" |
|---|
| 796 | | -#endif |
|---|
| 797 | 622 | "pci display[.b, .w, .l] b.d.f [address] [# of objects]\n" |
|---|
| 798 | 623 | " - display PCI configuration space (CFG)\n" |
|---|
| 799 | 624 | "pci next[.b, .w, .l] b.d.f address\n" |
|---|