Commit d76ef053 authored by Minda Chen's avatar Minda Chen Committed by Bjorn Helgaas

PCI: plda: Pass pci_host_bridge to plda_pcie_setup_iomems()

plda_pcie_setup_iomems() needs the bridge->windows list from struct
pci_host_bridge and is currently used only by pcie-microchip-host.c.  This
driver uses pci_host_common_probe(), which sets a pci_host_bridge as the
drvdata, so plda_pcie_setup_iomems() used platform_get_drvdata() to find
the pci_host_bridge.

But we also want to use plda_pcie_setup_iomems() in the new pcie-starfive.c
driver, which does not use pci_host_common_probe() and will have struct
starfive_jh7110_pcie as its drvdata, so pass the pci_host_bridge directly
to plda_pcie_setup_iomems() so it doesn't need platform_get_drvdata() to
find it.

Link: https://lore.kernel.org/linux-pci/20240328091835.14797-9-minda.chen@starfivetech.comSigned-off-by: default avatarMinda Chen <minda.chen@starfivetech.com>
Signed-off-by: default avatarKrzysztof Wilczyński <kwilczynski@kernel.org>
[bhelgaas: commit log, reorder to where this is needed]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
parent 76c91139
...@@ -616,6 +616,7 @@ static int mc_platform_init(struct pci_config_window *cfg) ...@@ -616,6 +616,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
{ {
struct device *dev = cfg->parent; struct device *dev = cfg->parent;
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct pci_host_bridge *bridge = platform_get_drvdata(pdev);
void __iomem *bridge_base_addr = void __iomem *bridge_base_addr =
port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
int ret; int ret;
...@@ -629,7 +630,7 @@ static int mc_platform_init(struct pci_config_window *cfg) ...@@ -629,7 +630,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
mc_pcie_enable_msi(port, cfg->win); mc_pcie_enable_msi(port, cfg->win);
/* Configure non-config space outbound ranges */ /* Configure non-config space outbound ranges */
ret = plda_pcie_setup_iomems(pdev, &port->plda); ret = plda_pcie_setup_iomems(bridge, &port->plda);
if (ret) if (ret)
return ret; return ret;
......
...@@ -533,11 +533,10 @@ void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, ...@@ -533,11 +533,10 @@ void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index,
} }
EXPORT_SYMBOL_GPL(plda_pcie_setup_window); EXPORT_SYMBOL_GPL(plda_pcie_setup_window);
int plda_pcie_setup_iomems(struct platform_device *pdev, int plda_pcie_setup_iomems(struct pci_host_bridge *bridge,
struct plda_pcie_rp *port) struct plda_pcie_rp *port)
{ {
void __iomem *bridge_base_addr = port->bridge_addr; void __iomem *bridge_base_addr = port->bridge_addr;
struct pci_host_bridge *bridge = platform_get_drvdata(pdev);
struct resource_entry *entry; struct resource_entry *entry;
u64 pci_addr; u64 pci_addr;
u32 index = 1; u32 index = 1;
......
...@@ -190,7 +190,7 @@ int plda_init_interrupts(struct platform_device *pdev, ...@@ -190,7 +190,7 @@ int plda_init_interrupts(struct platform_device *pdev,
void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index,
phys_addr_t axi_addr, phys_addr_t pci_addr, phys_addr_t axi_addr, phys_addr_t pci_addr,
size_t size); size_t size);
int plda_pcie_setup_iomems(struct platform_device *pdev, int plda_pcie_setup_iomems(struct pci_host_bridge *bridge,
struct plda_pcie_rp *port); struct plda_pcie_rp *port);
int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops, int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops,
const struct plda_event *plda_event); const struct plda_event *plda_event);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment