Commit 6176a5f3 authored by Rob Herring's avatar Rob Herring Committed by Lorenzo Pieralisi

PCI: rcar: Use pci_is_root_bus() to check if bus is root bus

Use pci_is_root_bus() rather than tracking the root bus number to
determine if the bus is the root bus or not. This removes storing
duplicated data as well as the need for the host bridge driver to have
to care about the bus numbers in most cases.

Link: https://lore.kernel.org/r/20200722022514.1283916-11-robh@kernel.orgSigned-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-renesas-soc@vger.kernel.org
parent d84c572d
...@@ -54,7 +54,6 @@ struct rcar_pcie_host { ...@@ -54,7 +54,6 @@ struct rcar_pcie_host {
struct phy *phy; struct phy *phy;
void __iomem *base; void __iomem *base;
struct list_head resources; struct list_head resources;
int root_bus_nr;
struct clk *bus_clk; struct clk *bus_clk;
struct rcar_msi msi; struct rcar_msi msi;
int (*phy_init_fn)(struct rcar_pcie_host *host); int (*phy_init_fn)(struct rcar_pcie_host *host);
...@@ -100,22 +99,14 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host, ...@@ -100,22 +99,14 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host,
if (dev != 0) if (dev != 0)
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
if (access_type == RCAR_PCI_ACCESS_READ) { if (access_type == RCAR_PCI_ACCESS_READ)
*data = rcar_pci_read_reg(pcie, PCICONF(index)); *data = rcar_pci_read_reg(pcie, PCICONF(index));
} else { else
/* Keep an eye out for changes to the root bus number */
if (pci_is_root_bus(bus) && (reg == PCI_PRIMARY_BUS))
host->root_bus_nr = *data & 0xff;
rcar_pci_write_reg(pcie, *data, PCICONF(index)); rcar_pci_write_reg(pcie, *data, PCICONF(index));
}
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
if (host->root_bus_nr < 0)
return PCIBIOS_DEVICE_NOT_FOUND;
/* Clear errors */ /* Clear errors */
rcar_pci_write_reg(pcie, rcar_pci_read_reg(pcie, PCIEERRFR), PCIEERRFR); rcar_pci_write_reg(pcie, rcar_pci_read_reg(pcie, PCIEERRFR), PCIEERRFR);
...@@ -124,7 +115,7 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host, ...@@ -124,7 +115,7 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host,
PCIE_CONF_DEV(dev) | PCIE_CONF_FUNC(func) | reg, PCIECAR); PCIE_CONF_DEV(dev) | PCIE_CONF_FUNC(func) | reg, PCIECAR);
/* Enable the configuration access */ /* Enable the configuration access */
if (bus->parent->number == host->root_bus_nr) if (pci_is_root_bus(bus->parent))
rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE0, PCIECCTLR); rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE0, PCIECCTLR);
else else
rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE1, PCIECCTLR); rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE1, PCIECCTLR);
...@@ -215,6 +206,7 @@ static struct pci_ops rcar_pcie_ops = { ...@@ -215,6 +206,7 @@ static struct pci_ops rcar_pcie_ops = {
static int rcar_pcie_setup(struct list_head *resource, static int rcar_pcie_setup(struct list_head *resource,
struct rcar_pcie_host *host) struct rcar_pcie_host *host)
{ {
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(host);
struct resource_entry *win; struct resource_entry *win;
int i = 0; int i = 0;
...@@ -232,7 +224,7 @@ static int rcar_pcie_setup(struct list_head *resource, ...@@ -232,7 +224,7 @@ static int rcar_pcie_setup(struct list_head *resource,
i++; i++;
break; break;
case IORESOURCE_BUS: case IORESOURCE_BUS:
host->root_bus_nr = res->start; bridge->busnr = res->start;
break; break;
default: default:
continue; continue;
...@@ -338,7 +330,6 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host) ...@@ -338,7 +330,6 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host)
pci_add_flags(PCI_REASSIGN_ALL_BUS); pci_add_flags(PCI_REASSIGN_ALL_BUS);
bridge->sysdata = host; bridge->sysdata = host;
bridge->busnr = host->root_bus_nr;
bridge->ops = &rcar_pcie_ops; bridge->ops = &rcar_pcie_ops;
bridge->map_irq = of_irq_parse_and_map_pci; bridge->map_irq = of_irq_parse_and_map_pci;
bridge->swizzle_irq = pci_common_swizzle; bridge->swizzle_irq = pci_common_swizzle;
......
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