mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
pci: Add a command to show PCI regions
Add 'pci regions' which lists the I/O and memory regions accessible from the PCI controller. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
b2aa889411
commit
b997a73ee6
49
cmd/pci.c
49
cmd/pci.c
|
@ -606,6 +606,47 @@ static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value,
|
||||||
return 0;
|
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
|
/* PCI Configuration Space access commands
|
||||||
*
|
*
|
||||||
* Syntax:
|
* Syntax:
|
||||||
|
@ -657,10 +698,11 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
pci_init();
|
pci_init();
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
case 'r': /* no break */
|
||||||
default: /* scan bus */
|
default: /* scan bus */
|
||||||
value = 1; /* short listing */
|
value = 1; /* short listing */
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (argv[argc-1][0] == 'l') {
|
if (cmd != 'r' && argv[argc-1][0] == 'l') {
|
||||||
value = 0;
|
value = 0;
|
||||||
argc--;
|
argc--;
|
||||||
}
|
}
|
||||||
|
@ -673,6 +715,9 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
printf("No such bus\n");
|
printf("No such bus\n");
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (cmd == 'r')
|
||||||
|
pci_show_regions(bus);
|
||||||
|
else
|
||||||
pciinfo(bus, value);
|
pciinfo(bus, value);
|
||||||
#else
|
#else
|
||||||
pciinfo(busnum, value);
|
pciinfo(busnum, value);
|
||||||
|
@ -745,6 +790,8 @@ static char pci_help_text[] =
|
||||||
#ifdef CONFIG_DM_PCI
|
#ifdef CONFIG_DM_PCI
|
||||||
"pci bar b.d.f\n"
|
"pci bar b.d.f\n"
|
||||||
" - show BARs base and size for device b.d.f'\n"
|
" - show BARs base and size for device b.d.f'\n"
|
||||||
|
"pci regions\n"
|
||||||
|
" - show PCI regions\n"
|
||||||
#endif
|
#endif
|
||||||
"pci display[.b, .w, .l] b.d.f [address] [# of objects]\n"
|
"pci display[.b, .w, .l] b.d.f [address] [# of objects]\n"
|
||||||
" - display PCI configuration space (CFG)\n"
|
" - display PCI configuration space (CFG)\n"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user