This makes the read/write functions more generic, allowing them to be
used from other places.

Signed-off-by: Mark Tomlinson <mark.tomlin...@alliedtelesis.co.nz>
---
 drivers/pci/controller/pcie-iproc.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/controller/pcie-iproc.c 
b/drivers/pci/controller/pcie-iproc.c
index 8c7f875acf7f..2c836eede42c 100644
--- a/drivers/pci/controller/pcie-iproc.c
+++ b/drivers/pci/controller/pcie-iproc.c
@@ -660,13 +660,13 @@ static void __iomem *iproc_pcie_bus_map_cfg_bus(struct 
pci_bus *bus,
                                      where);
 }
 
-static int iproc_pci_raw_config_read32(struct iproc_pcie *pcie,
+static int iproc_pci_raw_config_read32(struct iproc_pcie *pcie, int busno,
                                       unsigned int devfn, int where,
                                       int size, u32 *val)
 {
        void __iomem *addr;
 
-       addr = iproc_pcie_map_cfg_bus(pcie, 0, devfn, where & ~0x3);
+       addr = iproc_pcie_map_cfg_bus(pcie, busno, devfn, where & ~0x3);
        if (!addr) {
                *val = ~0;
                return PCIBIOS_DEVICE_NOT_FOUND;
@@ -680,14 +680,14 @@ static int iproc_pci_raw_config_read32(struct iproc_pcie 
*pcie,
        return PCIBIOS_SUCCESSFUL;
 }
 
-static int iproc_pci_raw_config_write32(struct iproc_pcie *pcie,
+static int iproc_pci_raw_config_write32(struct iproc_pcie *pcie, int busno,
                                        unsigned int devfn, int where,
                                        int size, u32 val)
 {
        void __iomem *addr;
        u32 mask, tmp;
 
-       addr = iproc_pcie_map_cfg_bus(pcie, 0, devfn, where & ~0x3);
+       addr = iproc_pcie_map_cfg_bus(pcie, busno, devfn, where & ~0x3);
        if (!addr)
                return PCIBIOS_DEVICE_NOT_FOUND;
 
@@ -793,7 +793,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie)
        }
 
        /* make sure we are not in EP mode */
-       iproc_pci_raw_config_read32(pcie, 0, PCI_HEADER_TYPE, 1, &hdr_type);
+       iproc_pci_raw_config_read32(pcie, 0, 0, PCI_HEADER_TYPE, 1, &hdr_type);
        if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) {
                dev_err(dev, "in EP mode, hdr=%#02x\n", hdr_type);
                return -EFAULT;
@@ -803,15 +803,16 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie)
 #define PCI_BRIDGE_CTRL_REG_OFFSET     0x43c
 #define PCI_CLASS_BRIDGE_MASK          0xffff00
 #define PCI_CLASS_BRIDGE_SHIFT         8
-       iproc_pci_raw_config_read32(pcie, 0, PCI_BRIDGE_CTRL_REG_OFFSET,
+       iproc_pci_raw_config_read32(pcie, 0, 0, PCI_BRIDGE_CTRL_REG_OFFSET,
                                    4, &class);
        class &= ~PCI_CLASS_BRIDGE_MASK;
        class |= (PCI_CLASS_BRIDGE_PCI << PCI_CLASS_BRIDGE_SHIFT);
-       iproc_pci_raw_config_write32(pcie, 0, PCI_BRIDGE_CTRL_REG_OFFSET,
+       iproc_pci_raw_config_write32(pcie, 0, 0, PCI_BRIDGE_CTRL_REG_OFFSET,
                                     4, class);
 
        /* check link status to see if link is active */
-       iproc_pci_raw_config_read32(pcie, 0, IPROC_PCI_EXP_CAP + PCI_EXP_LNKSTA,
+       iproc_pci_raw_config_read32(pcie, 0, 0,
+                                   IPROC_PCI_EXP_CAP + PCI_EXP_LNKSTA,
                                    2, &link_status);
        if (link_status & PCI_EXP_LNKSTA_NLW)
                link_is_active = true;
@@ -821,19 +822,19 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie)
 #define PCI_TARGET_LINK_SPEED_MASK     0xf
 #define PCI_TARGET_LINK_SPEED_GEN2     0x2
 #define PCI_TARGET_LINK_SPEED_GEN1     0x1
-               iproc_pci_raw_config_read32(pcie, 0,
+               iproc_pci_raw_config_read32(pcie, 0, 0,
                                            IPROC_PCI_EXP_CAP + PCI_EXP_LNKCTL2,
                                            4, &link_ctrl);
                if ((link_ctrl & PCI_TARGET_LINK_SPEED_MASK) ==
                    PCI_TARGET_LINK_SPEED_GEN2) {
                        link_ctrl &= ~PCI_TARGET_LINK_SPEED_MASK;
                        link_ctrl |= PCI_TARGET_LINK_SPEED_GEN1;
-                       iproc_pci_raw_config_write32(pcie, 0,
+                       iproc_pci_raw_config_write32(pcie, 0, 0,
                                        IPROC_PCI_EXP_CAP + PCI_EXP_LNKCTL2,
                                        4, link_ctrl);
                        msleep(100);
 
-                       iproc_pci_raw_config_read32(pcie, 0,
+                       iproc_pci_raw_config_read32(pcie, 0, 0,
                                        IPROC_PCI_EXP_CAP + PCI_EXP_LNKSTA,
                                        2, &link_status);
                        if (link_status & PCI_EXP_LNKSTA_NLW)
-- 
2.28.0

Reply via email to