public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alistair Delva <adelva@google.com>
To: u-boot@lists.denx.de
Cc: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>,
	Ram Muthiah <rammuthiah@google.com>
Subject: [PATCH] RFC: arm: pci: Add PCI cam support to PCI-E ecam driver
Date: Wed, 20 Oct 2021 21:31:34 +0000	[thread overview]
Message-ID: <20211020213134.7534-6-adelva@google.com> (raw)
In-Reply-To: <20211020213134.7534-1-adelva@google.com>

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 },
 	{ }
 };
 
-- 
2.30.2


  parent reply	other threads:[~2021-10-20 21:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20 21:31 [PATCH] x86: chromebook_coral: fix C block comment Alistair Delva
2021-10-20 21:31 ` [PATCH] x86: Fix i8254 ifdef include guard Alistair Delva
2021-10-21 20:18   ` Simon Glass
2021-10-27  3:08   ` Bin Meng
2021-10-27  3:28     ` Bin Meng
2021-10-20 21:31 ` [PATCH] efi_loader: Fix link of EFI apps with ld.lld Alistair Delva
2021-10-20 22:05   ` Heinrich Schuchardt
2021-10-20 21:31 ` [PATCH] arm64: relocate-rela: Add support for ld.lld Alistair Delva
2021-10-25 13:30   ` Tom Rini
2021-10-25 17:46     ` Alistair Delva
2021-10-25 18:17       ` Tom Rini
2021-11-16 19:25   ` Tom Rini
2021-10-20 21:31 ` [PATCH] x86: Fix linking u-boot with ld.lld Alistair Delva
2021-10-21 20:18   ` Simon Glass
2021-10-31 12:57     ` Simon Glass
2021-10-20 21:31 ` Alistair Delva [this message]
2021-11-18 19:15   ` [PATCH] RFC: arm: pci: Add PCI cam support to PCI-E ecam driver Tom Rini
2021-10-21 20:18 ` [PATCH] x86: chromebook_coral: fix C block comment Simon Glass
2021-10-27  3:07 ` Bin Meng
2021-10-27  3:27   ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211020213134.7534-6-adelva@google.com \
    --to=adelva@google.com \
    --cc=rammuthiah@google.com \
    --cc=tuomas.tynkkynen@iki.fi \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox