device: Introduce pcidev_on_root() and friends
Semantics of dev_find_slot() are ill in the sense that it only works after device enumeration has completed in ramstage. Plan is to declare it as deprecated. Introduce pcidev_on_root() and pcidev_path_on_root() functions to replace cases where this was called with static argument bus == 0. New implementation only walks the root bus of the PCI tree, while old one walked the entire linked list of devices. Introduce pcidev_path_behind() to replace cases where argument bus != 0. The required parent node is typically one of the PCIe root functions that you locate using pcidev_on_root() above. New forms are safe to use with early devicetree and before PCI bus numbers have been assigned. Change-Id: Ie20598d48b4cf6e35e45fc90804bad4728437fc6 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/26447 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
This commit is contained in:
parent
e3682b6c1c
commit
ad7674ed00
|
@ -22,6 +22,7 @@
|
||||||
#include <device/device.h>
|
#include <device/device.h>
|
||||||
#include <device/path.h>
|
#include <device/path.h>
|
||||||
#include <device/pci.h>
|
#include <device/pci.h>
|
||||||
|
#include <device/pci_def.h>
|
||||||
#include <device/resource.h>
|
#include <device/resource.h>
|
||||||
|
|
||||||
/** Linked list of ALL devices */
|
/** Linked list of ALL devices */
|
||||||
|
@ -172,6 +173,31 @@ DEVTREE_CONST struct device *find_dev_path(
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEVTREE_CONST struct device *pcidev_path_behind(
|
||||||
|
const struct bus *parent, pci_devfn_t devfn)
|
||||||
|
{
|
||||||
|
const struct device_path path = {
|
||||||
|
.type = DEVICE_PATH_PCI,
|
||||||
|
.pci.devfn = devfn,
|
||||||
|
};
|
||||||
|
return find_dev_path(parent, &path);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEVTREE_CONST struct device *pcidev_path_on_root(pci_devfn_t devfn)
|
||||||
|
{
|
||||||
|
DEVTREE_CONST struct device *pci_domain;
|
||||||
|
|
||||||
|
pci_domain = dev_find_path(NULL, DEVICE_PATH_DOMAIN);
|
||||||
|
if (!pci_domain)
|
||||||
|
return NULL;
|
||||||
|
return pcidev_path_behind(pci_domain->link_list, devfn);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn)
|
||||||
|
{
|
||||||
|
return pcidev_path_on_root(PCI_DEVFN(dev, fn));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an SMBus bus and a device number, find the device structure.
|
* Given an SMBus bus and a device number, find the device structure.
|
||||||
*
|
*
|
||||||
|
|
|
@ -276,6 +276,11 @@ DEVTREE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device);
|
||||||
DEVTREE_CONST struct device *dev_bus_each_child(const struct bus *parent,
|
DEVTREE_CONST struct device *dev_bus_each_child(const struct bus *parent,
|
||||||
DEVTREE_CONST struct device *prev_child);
|
DEVTREE_CONST struct device *prev_child);
|
||||||
|
|
||||||
|
DEVTREE_CONST struct device *pcidev_path_behind(const struct bus *parent,
|
||||||
|
pci_devfn_t devfn);
|
||||||
|
DEVTREE_CONST struct device *pcidev_path_on_root(pci_devfn_t devfn);
|
||||||
|
DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn);
|
||||||
|
|
||||||
void scan_smbus(struct device *bus);
|
void scan_smbus(struct device *bus);
|
||||||
void scan_generic_bus(struct device *bus);
|
void scan_generic_bus(struct device *bus);
|
||||||
void scan_static_bus(struct device *bus);
|
void scan_static_bus(struct device *bus);
|
||||||
|
|
Loading…
Reference in New Issue