
When booting U-Boot in crosvm, the virtual machine emulates a PCI cam device, not the PCI-E 'ecam' device normally seen on e.g. QEMU. This PCI device can be supported with only trivial changes to the ecam driver.
Instead of adding a completely new driver which is identical besides the initialization step, add support for the PCI version to the existing driver.
Signed-off-by: Alistair Delva adelva@google.com Cc: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi Cc: Ram Muthiah rammuthiah@google.com --- drivers/pci/pcie_ecam_generic.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pcie_ecam_generic.c b/drivers/pci/pcie_ecam_generic.c index e83e5aff20..c9b55b45a9 100644 --- a/drivers/pci/pcie_ecam_generic.c +++ b/drivers/pci/pcie_ecam_generic.c @@ -14,6 +14,8 @@
#include <asm/io.h>
+#define TYPE_PCI 0x1 + /** * struct generic_ecam_pcie - generic_ecam PCIe controller state * @cfg_base: The base address of memory mapped configuration space @@ -46,9 +48,16 @@ static int pci_generic_ecam_conf_address(const struct udevice *bus, void *addr;
addr = pcie->cfg_base; - addr += (PCI_BUS(bdf) - pcie->first_busno) << 20; - addr += PCI_DEV(bdf) << 15; - addr += PCI_FUNC(bdf) << 12; + + if (dev_get_driver_data(bus) == TYPE_PCI) { + addr += (PCI_BUS(bdf) - pcie->first_busno) << 16; + addr += PCI_DEV(bdf) << 11; + addr += PCI_FUNC(bdf) << 8; + } else { + addr += (PCI_BUS(bdf) - pcie->first_busno) << 20; + addr += PCI_DEV(bdf) << 15; + addr += PCI_FUNC(bdf) << 12; + } addr += offset; *paddress = addr;
@@ -158,7 +167,8 @@ static const struct dm_pci_ops pci_generic_ecam_ops = { };
static const struct udevice_id pci_generic_ecam_ids[] = { - { .compatible = "pci-host-ecam-generic" }, + { .compatible = "pci-host-ecam-generic" /* PCI-E */ }, + { .compatible = "pci-host-cam-generic", .data = TYPE_PCI }, { } };