Skip to content

Commit

Permalink
nuumio: dts/pcie: add configurable delay before pcie bus scan
Browse files Browse the repository at this point in the history
Default delay in dts is 1000ms. To change it in kernel cmdline use:

  pcie_rockchip_host.pcie_rk_bus_scan_delay=1000
  • Loading branch information
nuumio committed Apr 14, 2020
1 parent 4006231 commit b5ce971
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@
pinctrl-0 = <&pcie_perst>;
vpcie12v-supply = <&vcc12v_dcin>;
vpcie3v3-supply = <&vcc3v3_pcie>;
bus-scan-delay-ms = <1000>;
status = "okay";
};

Expand Down
17 changes: 17 additions & 0 deletions drivers/pci/controller/pcie-rockchip-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_pci.h>
Expand All @@ -39,6 +40,9 @@
#include "../pci.h"
#include "pcie-rockchip.h"

static int bus_scan_delay = -1;
module_param_named(pcie_rk_bus_scan_delay, bus_scan_delay, int, S_IRUGO);

static void rockchip_pcie_enable_bw_int(struct rockchip_pcie *rockchip)
{
u32 status;
Expand Down Expand Up @@ -953,6 +957,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
struct pci_host_bridge *bridge;
struct resource *bus_res;
int err;
u32 delay = 0;

if (!dev->of_node)
return -ENODEV;
Expand Down Expand Up @@ -1015,6 +1020,18 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
bridge->map_irq = of_irq_parse_and_map_pci;
bridge->swizzle_irq = pci_common_swizzle;

/* Prefer command-line param over device tree */
if (bus_scan_delay > 0) {
delay = bus_scan_delay;
dev_info(dev, "wait %u ms (from command-line) before bus scan\n", delay);
} else if (rockchip->bus_scan_delay > 0 && bus_scan_delay < 0) {
delay = rockchip->bus_scan_delay;
dev_info(dev, "wait %u ms (from device tree) before bus scan\n", delay);
}
if (delay > 0) {
msleep(delay);
}

err = pci_scan_root_bus_bridge(bridge);
if (err < 0)
goto err_remove_irq_domain;
Expand Down
8 changes: 8 additions & 0 deletions drivers/pci/controller/pcie-rockchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
return PTR_ERR(rockchip->clk_pcie_pm);
}

err = of_property_read_u32(node, "bus-scan-delay-ms", &rockchip->bus_scan_delay);
if (err) {
dev_info(dev, "no bus-scan-delay-ms in device tree, default 0 ms\n");
rockchip->bus_scan_delay = 0;
} else {
dev_info(dev, "bus-scan-delay-ms in device tree is %u ms\n", rockchip->bus_scan_delay);
}

return 0;
}
EXPORT_SYMBOL_GPL(rockchip_pcie_parse_dt);
Expand Down
1 change: 1 addition & 0 deletions drivers/pci/controller/pcie-rockchip.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ struct rockchip_pcie {
phys_addr_t msg_bus_addr;
bool is_rc;
struct resource *mem_res;
u32 bus_scan_delay;
};

static u32 rockchip_pcie_read(struct rockchip_pcie *rockchip, u32 reg)
Expand Down

0 comments on commit b5ce971

Please sign in to comment.