Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eea94479 authored by Rama Krishna Phani A's avatar Rama Krishna Phani A Committed by Gerrit - the friendly Code Review server
Browse files

msm: pcie: add support for switch latency



Add support for switch latency property to add
additional delay if switch is present.

Change-Id: Ia64a79d5ec51d3abb66cebd0a187349711c96af2
Signed-off-by: default avatarRama Krishna Phani A <rphani@codeaurora.org>
parent 16806c73
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ Optional Properties:
    and assign for each endpoint.
  - qcom,ep-latency: The time (unit: ms) to wait for the PCIe endpoint to become
    stable after power on, before de-assert the PERST to the endpoint.
  - qcom,switch-latency: The time (unit: ms) to wait for the PCIe endpoint's link
    training with switch downstream port after the link between switch upstream
    port and RC is up.
  - qcom,wr-halt-size: With base 2, this exponent determines the size of the
    data that PCIe core will halt on for each write transaction.
  - qcom,cpl-timeout: Completion timeout value. This value specifies the time range
@@ -264,6 +267,7 @@ Example:
		qcom,smmu-exist;
		qcom,smmu-sid-base = <0x1480>;
		qcom,ep-latency = <100>;
		qcom,switch-latency = <100>;
		qcom,wr-halt-size = <0xa>; /* 1KB */
		qcom,cpl-timeout = <0x2>;

+28 −0
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@

#define PERST_PROPAGATION_DELAY_US_MIN	  1000
#define PERST_PROPAGATION_DELAY_US_MAX	  1005
#define SWITCH_DELAY_MAX	  20
#define REFCLK_STABILIZATION_DELAY_US_MIN     1000
#define REFCLK_STABILIZATION_DELAY_US_MAX     1005
#define LINK_UP_TIMEOUT_US_MIN		    5000
@@ -626,6 +627,7 @@ struct msm_pcie_dev_t {
	bool				 ext_ref_clk;
	bool				common_phy;
	uint32_t			   ep_latency;
	uint32_t			switch_latency;
	uint32_t			wr_halt_size;
	uint32_t			cpl_timeout;
	uint32_t			current_bdf;
@@ -1936,6 +1938,8 @@ static void msm_pcie_show_status(struct msm_pcie_dev_t *dev)
		dev->common_phy);
	PCIE_DBG_FS(dev, "ep_latency: %dms\n",
		dev->ep_latency);
	PCIE_DBG_FS(dev, "switch_latency: %dms\n",
		dev->switch_latency);
	PCIE_DBG_FS(dev, "wr_halt_size: 0x%x\n",
		dev->wr_halt_size);
	PCIE_DBG_FS(dev, "cpl_timeout: 0x%x\n",
@@ -4548,6 +4552,16 @@ int msm_pcie_enable(struct msm_pcie_dev_t *dev, u32 options)
		goto link_fail;
	}

	if (dev->switch_latency) {
		PCIE_DBG(dev, "switch_latency: %dms\n",
			dev->switch_latency);
		if (dev->switch_latency <= SWITCH_DELAY_MAX)
			usleep_range(dev->switch_latency * 1000,
				dev->switch_latency * 1000);
		else
			msleep(dev->switch_latency);
	}

	msm_pcie_config_controller(dev);

	if (!dev->msi_gicm_addr)
@@ -6044,6 +6058,20 @@ static int msm_pcie_probe(struct platform_device *pdev)
		PCIE_DBG(&msm_pcie_dev[rc_idx], "RC%d: ep-latency: 0x%x.\n",
			rc_idx, msm_pcie_dev[rc_idx].ep_latency);

	msm_pcie_dev[rc_idx].switch_latency = 0;
	ret = of_property_read_u32((&pdev->dev)->of_node,
					"qcom,switch-latency",
					&msm_pcie_dev[rc_idx].switch_latency);

	if (ret)
		PCIE_DBG(&msm_pcie_dev[rc_idx],
				"RC%d: switch-latency does not exist.\n",
				rc_idx);
	else
		PCIE_DBG(&msm_pcie_dev[rc_idx],
				"RC%d: switch-latency: 0x%x.\n",
				rc_idx, msm_pcie_dev[rc_idx].switch_latency);

	msm_pcie_dev[rc_idx].wr_halt_size = 0;
	ret = of_property_read_u32(pdev->dev.of_node,
				"qcom,wr-halt-size",