pcengines/apuX: Replace use of dev_find_slot()

Find the NIC device based on the PCIe root port function.

Change-Id: Ia8c6e115c9b836ee60862427dfc9d46ca3dd1b69
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34003
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Michał Żygowski <michal.zygowski@3mdeb.com>
This commit is contained in:
Kyösti Mälkki
2019-07-03 10:49:44 +03:00
parent 367497486d
commit dace2498ec
2 changed files with 15 additions and 16 deletions

View File

@ -206,17 +206,23 @@ static void mainboard_enable(struct device *dev)
const char *smbios_mainboard_serial_number(void) const char *smbios_mainboard_serial_number(void)
{ {
static char serial[10]; static char serial[10];
struct device *nic_dev; struct device *dev;
uintptr_t bar18; uintptr_t bar18;
u32 mac_addr = 0; u32 mac_addr = 0;
int i; int i;
nic_dev = dev_find_slot(1, PCI_DEVFN(0, 0)); /* Already initialized. */
if ((serial[0] != 0) || !nic_dev) if (serial[0] != 0)
return serial;
dev = pcidev_on_root(4, 0);
if (dev)
dev = pcidev_path_behind(dev->link_list, PCI_DEVFN(0, 0));
if (!dev)
return serial; return serial;
/* Read in the last 3 bytes of NIC's MAC address. */ /* Read in the last 3 bytes of NIC's MAC address. */
bar18 = pci_read_config32(nic_dev, 0x18); bar18 = pci_read_config32(dev, 0x18);
bar18 &= 0xFFFFFC00; bar18 &= 0xFFFFFC00;
for (i = 3; i < 6; i++) { for (i = 3; i < 6; i++) {
mac_addr <<= 8; mac_addr <<= 8;

View File

@ -197,22 +197,15 @@ const char *smbios_mainboard_serial_number(void)
struct device *dev; struct device *dev;
uintptr_t bar10; uintptr_t bar10;
u32 mac_addr = 0; u32 mac_addr = 0;
u32 bus_no;
int i; int i;
/* /* Already initialized. */
* In case we have PCIe module connected to mPCIe2 slot, BDF 1:0.0 may if (serial[0] != 0)
* not be a NIC, because mPCIe2 slot is routed to the very first PCIe
* bridge and the first NIC is connected to the second PCIe bridge.
* Read secondary bus number from the PCIe bridge where the first NIC is
* connected.
*/
dev = pcidev_on_root(2, 2);
if ((serial[0] != 0) || !dev)
return serial; return serial;
bus_no = dev->link_list->secondary; dev = pcidev_on_root(2, 2);
dev = dev_find_slot(bus_no, PCI_DEVFN(0, 0)); if (dev)
dev = pcidev_path_behind(dev->link_list, PCI_DEVFN(0, 0));
if (!dev) if (!dev)
return serial; return serial;