diff options
author | Alistair Delva <adelva@google.com> | 2021-10-20 21:31:34 +0000 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-11-17 17:09:47 -0500 |
commit | 4f2e2280862aabb22cbdb39d37d524702aa57bcc (patch) | |
tree | 6892dfb44847ee967cb497d64d9a0c270109db77 /drivers | |
parent | e3cdc2cbb1b1a773b98bd39885c9be6b809375fb (diff) | |
download | u-boot-4f2e2280862aabb22cbdb39d37d524702aa57bcc.zip u-boot-4f2e2280862aabb22cbdb39d37d524702aa57bcc.tar.gz u-boot-4f2e2280862aabb22cbdb39d37d524702aa57bcc.tar.bz2 |
RFC: arm: pci: Add PCI cam support to PCI-E ecam driver
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/pcie_ecam_generic.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/pci/pcie_ecam_generic.c b/drivers/pci/pcie_ecam_generic.c index 09b6fc1..1a9f9ae 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,8 +48,14 @@ static int pci_generic_ecam_conf_address(const struct udevice *bus, void *addr; addr = pcie->cfg_base; - addr += PCIE_ECAM_OFFSET(PCI_BUS(bdf) - pcie->first_busno, - PCI_DEV(bdf), PCI_FUNC(bdf), offset); + + if (dev_get_driver_data(bus) == TYPE_PCI) { + addr += ((PCI_BUS(bdf) - pcie->first_busno) << 16) | + (PCI_DEV(bdf) << 11) | (PCI_FUNC(bdf) << 8) | offset; + } else { + addr += PCIE_ECAM_OFFSET(PCI_BUS(bdf) - pcie->first_busno, + PCI_DEV(bdf), PCI_FUNC(bdf), offset); + } *paddress = addr; return 0; @@ -156,7 +164,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 }, { } }; |