aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2015-10-08 15:54:16 -0400
committerBjorn Helgaas <bhelgaas@google.com>2015-10-09 19:18:35 -0400
commitf6225c3a0c1f2ef908244c31b91d62066360ce1d (patch)
treeb0728bcd16ae1e87c8c5dd8bd9268da13e4944b5
parent47ddb949029f9517a773e67b0e5eaf80ef596dad (diff)
PCI: generic: Fix address window calculation for non-zero starting bus
Make the offset from the beginning of the "reg" property be from the starting bus number, rather than zero. Hoist the invariant size calculation out of the mapping for loop. Update host-generic-pci.txt to clarify the semantics of the "reg" property with respect to non-zero starting bus numbers. Signed-off-by: David Daney <david.daney@cavium.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Rob Herring <robh@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/pci/host-generic-pci.txt5
-rw-r--r--drivers/pci/host/pci-host-generic.c4
2 files changed, 5 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
index cf3e205e0b7e..3f1d3fca62bb 100644
--- a/Documentation/devicetree/bindings/pci/host-generic-pci.txt
+++ b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
@@ -34,8 +34,9 @@ Properties of the host controller node:
34- #size-cells : Must be 2. 34- #size-cells : Must be 2.
35 35
36- reg : The Configuration Space base address and size, as accessed 36- reg : The Configuration Space base address and size, as accessed
37 from the parent bus. 37 from the parent bus. The base address corresponds to
38 38 the first bus in the "bus-range" property. If no
39 "bus-range" is specified, this will be bus 0 (the default).
39 40
40Properties of the /chosen node: 41Properties of the /chosen node:
41 42
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
index 895c0e39ca3b..5434c90db243 100644
--- a/drivers/pci/host/pci-host-generic.c
+++ b/drivers/pci/host/pci-host-generic.c
@@ -169,6 +169,7 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
169 struct resource *bus_range; 169 struct resource *bus_range;
170 struct device *dev = pci->host.dev.parent; 170 struct device *dev = pci->host.dev.parent;
171 struct device_node *np = dev->of_node; 171 struct device_node *np = dev->of_node;
172 u32 sz = 1 << pci->cfg.ops->bus_shift;
172 173
173 err = of_address_to_resource(np, 0, &pci->cfg.res); 174 err = of_address_to_resource(np, 0, &pci->cfg.res);
174 if (err) { 175 if (err) {
@@ -196,10 +197,9 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
196 bus_range = pci->cfg.bus_range; 197 bus_range = pci->cfg.bus_range;
197 for (busn = bus_range->start; busn <= bus_range->end; ++busn) { 198 for (busn = bus_range->start; busn <= bus_range->end; ++busn) {
198 u32 idx = busn - bus_range->start; 199 u32 idx = busn - bus_range->start;
199 u32 sz = 1 << pci->cfg.ops->bus_shift;
200 200
201 pci->cfg.win[idx] = devm_ioremap(dev, 201 pci->cfg.win[idx] = devm_ioremap(dev,
202 pci->cfg.res.start + busn * sz, 202 pci->cfg.res.start + idx * sz,
203 sz); 203 sz);
204 if (!pci->cfg.win[idx]) 204 if (!pci->cfg.win[idx])
205 return -ENOMEM; 205 return -ENOMEM;