summaryrefslogtreecommitdiff
path: root/libdde_linux26/lib/src/arch/l4/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdde_linux26/lib/src/arch/l4/pci.c')
-rw-r--r--libdde_linux26/lib/src/arch/l4/pci.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/libdde_linux26/lib/src/arch/l4/pci.c b/libdde_linux26/lib/src/arch/l4/pci.c
index c393fd3a..b50a7353 100644
--- a/libdde_linux26/lib/src/arch/l4/pci.c
+++ b/libdde_linux26/lib/src/arch/l4/pci.c
@@ -24,10 +24,6 @@ typedef struct l4dde_pci_dev {
/** List of Linux-DDEKit PCIDev mappings */
static LIST_HEAD(pcidev_mappings);
-/** PCI bus */
-static struct pci_bus *pci_bus = NULL;
-static struct pci_bus *pci_bus1 = NULL;
-
static int l4dde26_pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
static int l4dde26_pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
@@ -187,18 +183,21 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
void __init l4dde26_init_pci(void)
{
ddekit_pci_init();
-
- // TODO it's a temporary solution to handle 2 buses.
- // we need to find a way to detect buses.
- pci_bus = pci_create_bus(NULL, 0, &dde_pcibus_ops, NULL);
- Assert(pci_bus);
-
- pci_do_scan_bus(pci_bus);
-
- pci_bus1 = pci_create_bus(NULL, 2, &dde_pcibus_ops, NULL);
- Assert(pci_bus1);
-
- pci_do_scan_bus(pci_bus1);
+ int nr;
+ char found[256] = { };
+ int bus, slot, func;
+
+ for (nr = 0; ; nr++) {
+ if (ddekit_pci_get_device(nr, &bus, &slot, &func) != 0)
+ break;
+ if (!found[bus]) {
+ struct pci_bus *pci_bus = pci_create_bus(NULL, bus, &dde_pcibus_ops, NULL);
+ Assert(pci_bus);
+ pci_do_scan_bus(pci_bus);
+
+ found[bus] = 1;
+ }
+ }
INITIALIZE_INITVAR(dde26_pci);
}