diff options
author | Minda Chen <minda.chen@starfivetech.com> | 2023-07-26 05:00:28 +0300 |
---|---|---|
committer | Minda Chen <minda.chen@starfivetech.com> | 2023-07-26 08:31:45 +0300 |
commit | 2a3dedd340edeab3fe6573a2d78f198df5e7d13f (patch) | |
tree | d773be31b5bf95941343db6fd31aa2edf7d72cf4 | |
parent | 1ed1ed24eb0792ffa206b20db00bf9c9dbbc37ff (diff) | |
download | u-boot-2a3dedd340edeab3fe6573a2d78f198df5e7d13f.tar.xz |
pci: Getw correct config addr to support multi PCI
subtract the root bus number to get the correct
config addr.
Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
-rw-r--r-- | drivers/pci/pcie_starfive.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/pci/pcie_starfive.c b/drivers/pci/pcie_starfive.c index 991c9c199f..d31d8b6e3a 100644 --- a/drivers/pci/pcie_starfive.c +++ b/drivers/pci/pcie_starfive.c @@ -110,9 +110,9 @@ static int starfive_pcie_addr_valid(pci_dev_t bdf, int first_busno) return 1; } -static int starfive_pcie_off_conf(pci_dev_t bdf, uint offset) +static int starfive_pcie_off_conf(pci_dev_t bdf, uint offset, int first_busno) { - unsigned int bus = PCI_BUS(bdf); + unsigned int bus = PCI_BUS(bdf) - first_busno; unsigned int dev = PCI_DEV(bdf); unsigned int func = PCI_FUNC(bdf); @@ -120,10 +120,10 @@ static int starfive_pcie_off_conf(pci_dev_t bdf, uint offset) (func << ECAM_FUNC_SHIFT) | (offset & ~0x3); } -static bool plda_pcie_hide_rc_bar(pci_dev_t bdf, int offset) +static bool plda_pcie_hide_rc_bar(pci_dev_t bdf, int offset, int first_busno) { - if ((PCI_BUS(bdf) == 0) && - (offset == PCI_BASE_ADDRESS_0 || offset == PCI_BASE_ADDRESS_1)) + if ((PCI_BUS(bdf) == first_busno) && + (offset == PCI_BASE_ADDRESS_0 || offset == PCI_BASE_ADDRESS_1)) return true; return false; @@ -136,7 +136,7 @@ static int starfive_pcie_config_read(const struct udevice *udev, pci_dev_t bdf, void __iomem *addr; ulong value; struct starfive_pcie *priv = dev_get_priv(udev); - int where = starfive_pcie_off_conf(bdf, offset); + int where = starfive_pcie_off_conf(bdf, offset, priv->first_busno); if (!starfive_pcie_addr_valid(bdf, priv->first_busno)) { pr_debug("Out of range\n"); @@ -168,9 +168,9 @@ int starfive_pcie_config_write(struct udevice *udev, pci_dev_t bdf, void __iomem *addr; ulong old; struct starfive_pcie *priv = dev_get_priv(udev); - int where = starfive_pcie_off_conf(bdf, offset); + int where = starfive_pcie_off_conf(bdf, offset, priv->first_busno); - if (plda_pcie_hide_rc_bar(bdf, offset)) + if (plda_pcie_hide_rc_bar(bdf, offset, priv->first_busno)) return -1; if (!starfive_pcie_addr_valid(bdf, priv->first_busno)) { |