PCI: dwc: al: Use pci_ops for child config space accessors
Now that DWC drivers can setup their own pci_ops for the root and child buses, convert the Amazon driver to use the standard pci_ops for child bus config accesses. Link: https://lore.kernel.org/r/20200821035420.380495-6-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Jonathan Chocron <jonnyc@amazon.com> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Cc: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
27e7ed0181
commit
fffbb0ba8e
|
@ -217,14 +217,15 @@ static inline void al_pcie_target_bus_set(struct al_pcie *pcie,
|
|||
reg);
|
||||
}
|
||||
|
||||
static void __iomem *al_pcie_conf_addr_map(struct al_pcie *pcie,
|
||||
unsigned int busnr,
|
||||
unsigned int devfn)
|
||||
static void __iomem *al_pcie_conf_addr_map_bus(struct pci_bus *bus,
|
||||
unsigned int devfn, int where)
|
||||
{
|
||||
struct pcie_port *pp = bus->sysdata;
|
||||
struct al_pcie *pcie = to_al_pcie(to_dw_pcie_from_pp(pp));
|
||||
unsigned int busnr = bus->number;
|
||||
struct al_pcie_target_bus_cfg *target_bus_cfg = &pcie->target_bus_cfg;
|
||||
unsigned int busnr_ecam = busnr & target_bus_cfg->ecam_mask;
|
||||
unsigned int busnr_reg = busnr & target_bus_cfg->reg_mask;
|
||||
struct pcie_port *pp = &pcie->pci->pp;
|
||||
void __iomem *pci_base_addr;
|
||||
|
||||
pci_base_addr = (void __iomem *)((uintptr_t)pp->va_cfg0_base +
|
||||
|
@ -240,52 +241,14 @@ static void __iomem *al_pcie_conf_addr_map(struct al_pcie *pcie,
|
|||
target_bus_cfg->reg_mask);
|
||||
}
|
||||
|
||||
return pci_base_addr;
|
||||
return pci_base_addr + where;
|
||||
}
|
||||
|
||||
static int al_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
|
||||
unsigned int devfn, int where, int size,
|
||||
u32 *val)
|
||||
{
|
||||
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
|
||||
struct al_pcie *pcie = to_al_pcie(pci);
|
||||
unsigned int busnr = bus->number;
|
||||
void __iomem *pci_addr;
|
||||
int rc;
|
||||
|
||||
pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn);
|
||||
|
||||
rc = dw_pcie_read(pci_addr + where, size, val);
|
||||
|
||||
dev_dbg(pci->dev, "%d-byte config read from %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n",
|
||||
size, pci_domain_nr(bus), bus->number,
|
||||
PCI_SLOT(devfn), PCI_FUNC(devfn), where,
|
||||
(pci_addr + where), *val);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int al_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
|
||||
unsigned int devfn, int where, int size,
|
||||
u32 val)
|
||||
{
|
||||
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
|
||||
struct al_pcie *pcie = to_al_pcie(pci);
|
||||
unsigned int busnr = bus->number;
|
||||
void __iomem *pci_addr;
|
||||
int rc;
|
||||
|
||||
pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn);
|
||||
|
||||
rc = dw_pcie_write(pci_addr + where, size, val);
|
||||
|
||||
dev_dbg(pci->dev, "%d-byte config write to %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n",
|
||||
size, pci_domain_nr(bus), bus->number,
|
||||
PCI_SLOT(devfn), PCI_FUNC(devfn), where,
|
||||
(pci_addr + where), val);
|
||||
|
||||
return rc;
|
||||
}
|
||||
static struct pci_ops al_child_pci_ops = {
|
||||
.map_bus = al_pcie_conf_addr_map_bus,
|
||||
.read = pci_generic_config_read,
|
||||
.write = pci_generic_config_write,
|
||||
};
|
||||
|
||||
static void al_pcie_config_prepare(struct al_pcie *pcie)
|
||||
{
|
||||
|
@ -339,6 +302,8 @@ static int al_pcie_host_init(struct pcie_port *pp)
|
|||
struct al_pcie *pcie = to_al_pcie(pci);
|
||||
int rc;
|
||||
|
||||
pp->bridge->child_ops = &al_child_pci_ops;
|
||||
|
||||
rc = al_pcie_rev_id_get(pcie, &pcie->controller_rev_id);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
@ -353,8 +318,6 @@ static int al_pcie_host_init(struct pcie_port *pp)
|
|||
}
|
||||
|
||||
static const struct dw_pcie_host_ops al_pcie_host_ops = {
|
||||
.rd_other_conf = al_pcie_rd_other_conf,
|
||||
.wr_other_conf = al_pcie_wr_other_conf,
|
||||
.host_init = al_pcie_host_init,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue