/** * pciinfo() - Show a list of devices on the PCI bus * * Show information about devices on PCI bus. Depending on @short_pci_listing * the output will be more or less exhaustive. * * @bus_num: The number of the bus to be scanned * @short_pci_listing: true to use short form, showing only a brief header * for each device */ void pciinfo(int bus_num, int short_pci_listing) { struct pci_controller *hose = pci_bus_to_hose(bus_num); int device; int function; unsigned char header_type; unsigned short vendor_id; pci_dev_t dev; int ret; if (!hose) return; pciinfo_header(bus_num, short_pci_listing); for (device = 0; device < PCI_MAX_PCI_DEVICES; device++) { header_type = 0; vendor_id = 0; for (function = 0; function < PCI_MAX_PCI_FUNCTIONS; function++) { /* * If this is not a multi-function device, we skip * the rest. */ if (function && !(header_type & 0x80)) break; dev = PCI_BDF(bus_num, device, function); if (pci_skip_dev(hose, dev)) continue; ret = pci_read_config_word(dev, PCI_VENDOR_ID, &vendor_id); if (ret) goto error; if ((vendor_id == 0xFFFF) || (vendor_id == 0x0000)) continue; if (!function) { pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type); } if (short_pci_listing) { printf("%02x.%02x.%02x ", bus_num, device, function); pci_header_show_brief(dev); } else { printf("\nFound PCI device %02x.%02x.%02x:\n", bus_num, device, function); pci_header_show(dev); } } } return; error: printf("Cannot read bus configuration: %d\n", ret); }
/* * Subroutine: pciinfo * * Description: Show information about devices on PCI bus. * Depending on the define CONFIG_SYS_SHORT_PCI_LISTING * the output will be more or less exhaustive. * * Inputs: bus_no the number of the bus to be scanned. * * Return: None * */ void pciinfo(u32 BusNum) { int Device; int Function; unsigned char HeaderType; unsigned short VendorID; pci_dev_t dev; int ShortPCIListing; printf("Scanning PCI devices on bus %d\r\n", BusNum); ShortPCIListing = 0; if (ShortPCIListing) { printf("BusDevFun VendorId DeviceId Device Class Sub-Class\r\n"); printf("_____________________________________________________________\r\n"); } for (Device = 0; Device < PCI_MAX_PCI_DEVICES; Device++) { HeaderType = 0; VendorID = 0; for (Function = 0; Function < PCI_MAX_PCI_FUNCTIONS; Function++) { /* * If this is not a multi-function device, we skip the rest. */ if (Function && !(HeaderType & 0x80)) break; dev = PCI_BDF(BusNum, Device, Function); pci_read_config_word(dev, PCI_VENDOR_ID, &VendorID); if ((VendorID == 0xFFFF) || (VendorID == 0x0000)) continue; if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType); if (ShortPCIListing) { printf("%02x %02x %02x ", BusNum, Device, Function); pci_header_show_brief(dev); } else { printf("\nFound PCI device %02x %02x %02x:\r\n", BusNum, Device, Function); pci_header_show(dev); } } } }
static void pciinfo(struct udevice *bus, bool short_listing) { struct udevice *dev; pciinfo_header(bus->seq, short_listing); for (device_find_first_child(bus, &dev); dev; device_find_next_child(&dev)) { struct pci_child_platdata *pplat; pplat = dev_get_parent_platdata(dev); if (short_listing) { printf("%02x.%02x.%02x ", bus->seq, PCI_DEV(pplat->devfn), PCI_FUNC(pplat->devfn)); pci_header_show_brief(dev); } else { printf("\nFound PCI device %02x.%02x.%02x:\n", bus->seq, PCI_DEV(pplat->devfn), PCI_FUNC(pplat->devfn)); pci_header_show(dev); } } }
/* * Subroutine: pciinfo * * Description: Show information about devices on PCI bus. * Depending on the define CONFIG_SYS_SHORT_PCI_LISTING * the output will be more or less exhaustive. * * Inputs: bus_no the number of the bus to be scanned. * * Return: None * */ void pciinfo(int BusNum, int ShortPCIListing) { struct pci_controller *hose = pci_bus_to_hose(BusNum); int Device; int Function; unsigned char HeaderType; unsigned short VendorID; pci_dev_t dev; int ret; if (!hose) return; printf("Scanning PCI devices on bus %d\n", BusNum); if (ShortPCIListing) { printf("BusDevFun VendorId DeviceId Device Class Sub-Class\n"); printf("_____________________________________________________________\n"); } for (Device = 0; Device < PCI_MAX_PCI_DEVICES; Device++) { HeaderType = 0; VendorID = 0; for (Function = 0; Function < PCI_MAX_PCI_FUNCTIONS; Function++) { /* * If this is not a multi-function device, we skip the rest. */ if (Function && !(HeaderType & 0x80)) break; dev = PCI_BDF(BusNum, Device, Function); if (pci_skip_dev(hose, dev)) continue; ret = pci_read_config_word(dev, PCI_VENDOR_ID, &VendorID); if (ret) goto error; if ((VendorID == 0xFFFF) || (VendorID == 0x0000)) continue; if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType); if (ShortPCIListing) { printf("%02x.%02x.%02x ", BusNum, Device, Function); pci_header_show_brief(dev); } else { printf("\nFound PCI device %02x.%02x.%02x:\n", BusNum, Device, Function); pci_header_show(dev); } } } return; error: printf("Cannot read bus configuration: %d\n", ret); }