1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2014 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
10 #include <linux/libfdt.h>
14 struct sandbox_pci_priv {
18 int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn,
19 struct udevice **emulp)
24 ret = pci_bus_find_devfn(bus, find_devfn, &dev);
26 debug("%s: Could not find emulator for dev %x\n", __func__,
31 ret = device_find_first_child(dev, emulp);
35 return *emulp ? 0 : -ENODEV;
38 static int sandbox_pci_emul_post_probe(struct udevice *dev)
40 struct sandbox_pci_priv *priv = dev->uclass->priv;
43 sandbox_set_enable_pci_map(true);
48 static int sandbox_pci_emul_pre_remove(struct udevice *dev)
50 struct sandbox_pci_priv *priv = dev->uclass->priv;
53 sandbox_set_enable_pci_map(priv->dev_count > 0);
58 UCLASS_DRIVER(pci_emul) = {
59 .id = UCLASS_PCI_EMUL,
61 .post_probe = sandbox_pci_emul_post_probe,
62 .pre_remove = sandbox_pci_emul_pre_remove,
63 .priv_auto_alloc_size = sizeof(struct sandbox_pci_priv),