X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fpci.c;h=2c5ee2a19d87d2912de28c63134f2a2f997d0fd6;hb=550109691ec87a129fd5c5777e1211257ff3c6c9;hp=7993c1a09955af490d10ac846981d3dab8a3bc88;hpb=f2465934b46235287e07473fa4919035ba1a2b68;p=oweals%2Fu-boot.git diff --git a/cmd/pci.c b/cmd/pci.c index 7993c1a099..2c5ee2a19d 100644 --- a/cmd/pci.c +++ b/cmd/pci.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH * Andreas Heppel @@ -5,8 +6,6 @@ * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ /* @@ -150,7 +149,8 @@ int pci_bar_show(struct udevice *dev) if ((!is_64 && size_low) || (is_64 && size)) { size = ~size + 1; printf(" %d %#016llx %#016llx %d %s %s\n", - bar_id, base, size, is_64 ? 64 : 32, + bar_id, (unsigned long long)base, + (unsigned long long)size, is_64 ? 64 : 32, is_io ? "I/O" : "MEM", prefetchable ? "Prefetchable" : ""); } @@ -606,6 +606,47 @@ static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value, return 0; } +#ifdef CONFIG_DM_PCI +static const struct pci_flag_info { + uint flag; + const char *name; +} pci_flag_info[] = { + { PCI_REGION_IO, "io" }, + { PCI_REGION_PREFETCH, "prefetch" }, + { PCI_REGION_SYS_MEMORY, "sysmem" }, + { PCI_REGION_RO, "readonly" }, + { PCI_REGION_IO, "io" }, +}; + +static void pci_show_regions(struct udevice *bus) +{ + struct pci_controller *hose = dev_get_uclass_priv(bus); + const struct pci_region *reg; + int i, j; + + if (!hose) { + printf("Bus '%s' is not a PCI controller\n", bus->name); + return; + } + + printf("# %-16s %-16s %-16s %s\n", "Bus start", "Phys start", "Size", + "Flags"); + for (i = 0, reg = hose->regions; i < hose->region_count; i++, reg++) { + printf("%d %#016llx %#016llx %#016llx ", i, + (unsigned long long)reg->bus_start, + (unsigned long long)reg->phys_start, + (unsigned long long)reg->size); + if (!(reg->flags & PCI_REGION_TYPE)) + printf("mem "); + for (j = 0; j < ARRAY_SIZE(pci_flag_info); j++) { + if (reg->flags & pci_flag_info[j].flag) + printf("%s ", pci_flag_info[j].name); + } + printf("\n"); + } +} +#endif + /* PCI Configuration Space access commands * * Syntax: @@ -652,15 +693,16 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if ((bdf = get_pci_dev(argv[2])) == -1) return 1; break; -#if defined(CONFIG_CMD_PCI_ENUM) || defined(CONFIG_DM_PCI) +#if defined(CONFIG_DM_PCI) case 'e': pci_init(); return 0; #endif + case 'r': /* no break */ default: /* scan bus */ value = 1; /* short listing */ if (argc > 1) { - if (argv[argc-1][0] == 'l') { + if (cmd != 'r' && argv[argc-1][0] == 'l') { value = 0; argc--; } @@ -673,7 +715,10 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("No such bus\n"); return CMD_RET_FAILURE; } - pciinfo(bus, value); + if (cmd == 'r') + pci_show_regions(bus); + else + pciinfo(bus, value); #else pciinfo(busnum, value); #endif @@ -736,7 +781,7 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static char pci_help_text[] = "[bus] [long]\n" " - short or long list of PCI devices on bus 'bus'\n" -#if defined(CONFIG_CMD_PCI_ENUM) || defined(CONFIG_DM_PCI) +#if defined(CONFIG_DM_PCI) "pci enum\n" " - Enumerate PCI buses\n" #endif @@ -745,6 +790,8 @@ static char pci_help_text[] = #ifdef CONFIG_DM_PCI "pci bar b.d.f\n" " - show BARs base and size for device b.d.f'\n" + "pci regions\n" + " - show PCI regions\n" #endif "pci display[.b, .w, .l] b.d.f [address] [# of objects]\n" " - display PCI configuration space (CFG)\n"