MLK-14554 PCI: imx: pcie ep board can't boot up
authorRichard Zhu <hongxing.zhu@nxp.com>
Thu, 30 Mar 2017 09:56:55 +0000 (17:56 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:21:48 +0000 (15:21 -0500)
In the imx pcie ep/rc validation system, the mem
resource parser of ep probe is failed on 4.9.
Change the mem resource parser method from 4.1
to 4.9 to fix this failure.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
drivers/pci/host/pci-imx6.c

index 57d880a..d81e2af 100644 (file)
 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
 #include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
 #include <linux/module.h>
-#include <linux/of_gpio.h>
-#include <linux/of_device.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/of_pci.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -1381,21 +1382,30 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
                struct timeval tv1s, tv1e, tv2s, tv2e;
                u32 tv_count1, tv_count2;
                struct device_node *np = pp->dev->of_node;
-               struct of_pci_range range;
-               struct of_pci_range_parser parser;
-               unsigned long restype;
+               LIST_HEAD(res);
+               struct resource_entry *win, *tmp;
+
+               ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res,
+                                                      &pp->io_base);
+               if (ret)
+                       return ret;
 
-               if (of_pci_range_parser_init(&parser, np)) {
+               ret = devm_request_pci_bus_resources(&pdev->dev, &res);
+               if (ret) {
                        dev_err(pp->dev, "missing ranges property\n");
-                       return -EINVAL;
+                       pci_free_resource_list(&res);
+                       return ret;
                }
 
-               /* Get the memory ranges from DT */
-               for_each_of_pci_range(&parser, &range) {
-                       restype = range.flags & IORESOURCE_TYPE_BITS;
-                       if (restype == IORESOURCE_MEM) {
-                               of_pci_range_to_resource(&range, np, pp->mem);
+               /* Get the I/O and memory ranges from DT */
+               resource_list_for_each_entry_safe(win, tmp, &res) {
+                       switch (resource_type(win->res)) {
+                       case IORESOURCE_MEM:
+                               pp->mem = win->res;
                                pp->mem->name = "MEM";
+                               pp->mem_size = resource_size(pp->mem);
+                               pp->mem_bus_addr = pp->mem->start - win->offset;
+                               break;
                        }
                }