diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2018-08-03 11:14:45 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-08-08 14:49:31 +0300 |
commit | 4345998ae9dfad7ba0beb54ad4322134557504a9 (patch) | |
tree | bb4e8d49af00eb5cc0028ff9efa73dc2f0b61207 /drivers/pci/pci-emul-uclass.c | |
parent | ed698aa7dee0fd078b4eb2fc54e64cfeaa68061a (diff) | |
download | u-boot-4345998ae9dfad7ba0beb54ad4322134557504a9.tar.xz |
pci: sandbox: Support dynamically binding device driver
At present all emulated sandbox pci devices must be present in the
device tree in order to be used. The real world pci uclass driver
supports pci device driver matching, and we should add such support
on sandbox too.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/pci/pci-emul-uclass.c')
-rw-r--r-- | drivers/pci/pci-emul-uclass.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/pci/pci-emul-uclass.c b/drivers/pci/pci-emul-uclass.c index 8570a5da20..e9d2f49793 100644 --- a/drivers/pci/pci-emul-uclass.c +++ b/drivers/pci/pci-emul-uclass.c @@ -16,21 +16,27 @@ struct sandbox_pci_priv { }; int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn, - struct udevice **emulp) + struct udevice **containerp, struct udevice **emulp) { struct udevice *dev; int ret; + *containerp = NULL; ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(find_devfn), &dev); if (ret) { debug("%s: Could not find emulator for dev %x\n", __func__, find_devfn); return ret; } + *containerp = dev; - ret = device_find_first_child(dev, emulp); - if (ret) - return ret; + if (device_get_uclass_id(dev) == UCLASS_PCI_GENERIC) { + ret = device_find_first_child(dev, emulp); + if (ret) + return ret; + } else { + *emulp = dev; + } return *emulp ? 0 : -ENODEV; } |