Skip to content

Commit 4dd964d

Browse files
kishonbjorn-helgaas
authored andcommitted
PCI: designware: Look for configuration space in 'reg', not 'ranges'
The configuration address space has so far been specified in *ranges*, however it should be specified in *reg* making it a platform MEM resource. Hence used 'platform_get_resource_*' API to get configuration address space in the designware driver. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Mohit Kumar <mohit.kumar@st.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Cc: Marek Vasut <marex@denx.de> Cc: Arnd Bergmann <arnd@arndb.de>
1 parent 7171511 commit 4dd964d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎Documentation/devicetree/bindings/pci/designware-pcie.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Required properties:
44
- compatible: should contain "snps,dw-pcie" to identify the core.
5+
- reg: Should contain the configuration address space.
6+
- reg-names: Must be "config" for the PCIe configuration space.
7+
(The old way of getting the configuration address space from "ranges"
8+
is deprecated and should be avoided.)
59
- #address-cells: set to <3>
610
- #size-cells: set to <2>
711
- device_type: set to "pci"

‎drivers/pci/host/pcie-designware.c‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/of_pci.h>
2121
#include <linux/pci.h>
2222
#include <linux/pci_regs.h>
23+
#include <linux/platform_device.h>
2324
#include <linux/types.h>
2425

2526
#include "pcie-designware.h"
@@ -396,11 +397,23 @@ static const struct irq_domain_ops msi_domain_ops = {
396397
int __init dw_pcie_host_init(struct pcie_port *pp)
397398
{
398399
struct device_node *np = pp->dev->of_node;
400+
struct platform_device *pdev = to_platform_device(pp->dev);
399401
struct of_pci_range range;
400402
struct of_pci_range_parser parser;
403+
struct resource *cfg_res;
401404
u32 val;
402405
int i;
403406

407+
cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config");
408+
if (cfg_res) {
409+
pp->config.cfg0_size = resource_size(cfg_res)/2;
410+
pp->config.cfg1_size = resource_size(cfg_res)/2;
411+
pp->cfg0_base = cfg_res->start;
412+
pp->cfg1_base = cfg_res->start + pp->config.cfg0_size;
413+
} else {
414+
dev_err(pp->dev, "missing *config* reg space\n");
415+
}
416+
404417
if (of_pci_range_parser_init(&parser, np)) {
405418
dev_err(pp->dev, "missing ranges property\n");
406419
return -EINVAL;
@@ -433,6 +446,8 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
433446
of_pci_range_to_resource(&range, np, &pp->cfg);
434447
pp->config.cfg0_size = resource_size(&pp->cfg)/2;
435448
pp->config.cfg1_size = resource_size(&pp->cfg)/2;
449+
pp->cfg0_base = pp->cfg.start;
450+
pp->cfg1_base = pp->cfg.start + pp->config.cfg0_size;
436451
}
437452
}
438453

@@ -445,8 +460,6 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
445460
}
446461
}
447462

448-
pp->cfg0_base = pp->cfg.start;
449-
pp->cfg1_base = pp->cfg.start + pp->config.cfg0_size;
450463
pp->mem_base = pp->mem.start;
451464

452465
pp->va_cfg0_base = devm_ioremap(pp->dev, pp->cfg0_base,

0 commit comments

Comments
 (0)