* [U-Boot] [PATCH v2] pci: Add a command to show PCI regions
@ 2017-04-08 19:10 Simon Glass
2017-04-14 21:09 ` [U-Boot] [U-Boot,v2] " Tom Rini
0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2017-04-08 19:10 UTC (permalink / raw)
To: u-boot
Add 'pci regions' which lists the I/O and memory regions accessible from
the PCI controller.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Fix build warning when CONFIG_DM_PCI is not enabled
cmd/pci.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)
diff --git a/cmd/pci.c b/cmd/pci.c
index 7993c1a099..41b4fffcf9 100644
--- a/cmd/pci.c
+++ b/cmd/pci.c
@@ -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:
@@ -657,10 +698,11 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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
@@ -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"
--
2.12.2.715.g7642488e1d-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [U-Boot,v2] pci: Add a command to show PCI regions
2017-04-08 19:10 [U-Boot] [PATCH v2] pci: Add a command to show PCI regions Simon Glass
@ 2017-04-14 21:09 ` Tom Rini
0 siblings, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-04-14 21:09 UTC (permalink / raw)
To: u-boot
On Sat, Apr 08, 2017 at 01:10:06PM -0600, Simon Glass wrote:
> Add 'pci regions' which lists the I/O and memory regions accessible from
> the PCI controller.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170414/0db663e5/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] pci: Add a command to show PCI regions
@ 2017-04-02 18:27 Simon Glass
0 siblings, 0 replies; 3+ messages in thread
From: Simon Glass @ 2017-04-02 18:27 UTC (permalink / raw)
To: u-boot
Add 'pci regions' which lists the I/O and memory regions accessible from
the PCI controller.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Drop duplicate PCI_REGION_IO line
cmd/pci.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/cmd/pci.c b/cmd/pci.c
index 7993c1a099..59c7c54040 100644
--- a/cmd/pci.c
+++ b/cmd/pci.c
@@ -606,6 +606,44 @@ static int pci_cfg_modify(pci_dev_t bdf, ulong addr, ulong size, ulong value,
return 0;
}
+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" },
+};
+
+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");
+ }
+}
+
/* PCI Configuration Space access commands
*
* Syntax:
@@ -657,10 +695,11 @@ static int do_pci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
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 +712,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
@@ -745,6 +787,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"
--
2.12.2.564.g063fe858b8-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-14 21:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-08 19:10 [U-Boot] [PATCH v2] pci: Add a command to show PCI regions Simon Glass
2017-04-14 21:09 ` [U-Boot] [U-Boot,v2] " Tom Rini
-- strict thread matches above, loose matches on Subject: below --
2017-04-02 18:27 [U-Boot] [PATCH v2] " Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.