Skip to contentSkip to conversation

Add PCIe support for IPQ8074

PATCH Applied Sivaprakash Murugesan 6 participants 22 messages Jul 5, 2020 – Aug 3, 2020

Subsystems (10)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add PCIe support for IPQ8074

IPQ8074 has two PCIe ports both are based on synopsis designware PCIe controller. while it was assumed that PCIe support for IPQ8074 was already available. PCIe was not functional until now.

This patch series adds support for PCIe ports on IPQ8074.

First PCIe port is of gen2 synposis version is 2_3_2 which has already been enabled. But it had some problems on phy init and needed dt updates.

Second PCIe port is gen3 synopsis version is 2_9_0. This series adds support for this PCIe port while fixing dt nodes.

Patch 1 on this series depends on qcom pcie bindings patch
https://lkml.org/lkml/2020/6/24/162

Sivaprakash Murugesan (9):
dt-bindings: pci: Add ipq8074 gen3 pci compatible
dt-bindings: phy: qcom,qmp: Add dt-binding for ipq8074 gen3 pcie phy
clk: qcom: ipq8074: Add missing bindings for pcie
clk: qcom: ipq8074: Add missing clocks for pcie
phy: qcom-qmp: use correct values for ipq8074 gen2 pcie phy init
phy: qcom-qmp: Add compatible for ipq8074 pcie gen3 qmp phy
pci: dwc: qcom: do phy power on before pcie init
pci: qcom: Add support for ipq8074 pci controller
arm64: dts: ipq8074: Fixup pcie dts nodes

 .../devicetree/bindings/pci/qcom,pcie.yaml         |  47 ++++++
 .../devicetree/bindings/phy/qcom,qmp-phy.yaml      |   1 +
 arch/arm64/boot/dts/qcom/ipq8074-hk01.dts          |   8 +-
 arch/arm64/boot/dts/qcom/ipq8074.dtsi              | 109 ++++++++----
 drivers/clk/qcom/gcc-ipq8074.c                     |  60 +++++++
 drivers/pci/controller/dwc/pcie-qcom.c             | 187 +++++++++++++++++++-
 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h          | 132 +++++++++++++++
 drivers/phy/qualcomm/phy-qcom-qmp.c                | 188 ++++++++++++++++++++-
 drivers/phy/qualcomm/phy-qcom-qmp.h                |   2 +
 include/dt-bindings/clock/qcom,gcc-ipq8074.h       |   4 +
 10 files changed, 683 insertions(+), 55 deletions(-)
 create mode 100644 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/9 dt-bindings: pci: Add ipq8074 gen3 pci compatible

ipq8074 has two PCIe ports while the support for gen2 pcie port is already available add the support for gen3 binding.

---
 .../devicetree/bindings/pci/qcom,pcie.yaml         | 47 ++++++++++++++++++++++
 1 file changed, 47 insertions(+)
Documentation/devicetree/bindings/pci/qcom,pcie.yaml +47 -0
index b119ce4711b4..b5ec45df735e 100644
@@ -22,6 +22,7 @@ properties:
       - qcom,pcie-ipq4019
       - qcom,pcie-ipq8064
       - qcom,pcie-ipq8074
+      - qcom,pcie-ipq8074-gen3
       - qcom,pcie-msm8996
       - qcom,pcie-qcs404
       - qcom,pcie-sdm845
@@ -330,6 +331,52 @@ allOf:
        compatible:
          contains:
            enum:
+             - qcom,pcie-ipq8074-gen3
+   then:
+     properties:
+       clocks:
+         items:
+           - description: sys noc interface clock
+           - description: AXI master clock
+           - description: AXI slave clock
+           - description: AHB clock
+           - description: Auxilary clock
+           - description: AXI slave bridge clock
+           - description: PCIe rchng clock
+       clock-names:
+         items:
+           - const: iface
+           - const: axi_m
+           - const: axi_s
+           - const: ahb
+           - const: aux
+           - const: axi_bridge
+           - const: rchng
+       resets:
+         items:
+           - description: PIPE reset
+           - description: PCIe sleep reset
+           - description: PCIe sticky reset
+           - description: AXI master reset
+           - description: AXI slave reset
+           - description: AHB reset
+           - description: AXI master sticky reset
+           - description: AXI Slave sticky reset
+       reset-names:
+         items:
+           - const: pipe
+           - const: sleep
+           - const: sticky
+           - const: axi_m
+           - const: axi_s
+           - const: ahb
+           - const: axi_m_sticky
+           - const: axi_s_sticky
+ - if:
+     properties:
+       compatible:
+         contains:
+           enum:
              - qcom,pcie-msm8996
    then:
      properties:
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 1/9
#2 lore raw

Re: [PATCH 1/9] dt-bindings: pci: Add ipq8074 gen3 pci compatible

Quoted 10 lines · Sivaprakash Murugesan

ipq8074 has two PCIe ports while the support for gen2 pcie port is already available add the support for gen3 binding.

---
 .../devicetree/bindings/pci/qcom,pcie.yaml         | 47 ++++++++++++++++++++++
 1 file changed, 47 insertions(+)
#3 lore raw

PATCH 2/9 dt-bindings: phy: qcom,qmp: Add dt-binding for ipq8074 gen3 pcie phy

In reply to Sivaprakash Murugesan

ipq8074 has two different phy blocks for two pcie ports, with pcie gen2 compatible already available, specify the pcie phy compatible for gen3 pcie port.

---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml +1 -0
index f80f8896d527..3e8681679f53 100644
@@ -18,6 +18,7 @@ properties:
   compatible:
     enum:
       - qcom,ipq8074-qmp-pcie-phy
+      - qcom,ipq8074-qmp-pcie-gen3-phy
       - qcom,msm8996-qmp-pcie-phy
       - qcom,msm8996-qmp-ufs-phy
       - qcom,msm8996-qmp-usb3-phy
Signature · 1 line
2.7.4
maintainer Acked-by on v1 2/9
#4 lore raw

Re: [PATCH 2/9] dt-bindings: phy: qcom,qmp: Add dt-binding for ipq8074 gen3 pcie phy

Quoted 11 lines · Sivaprakash Murugesan

ipq8074 has two different phy blocks for two pcie ports, with pcie gen2 compatible already available, specify the pcie phy compatible for gen3 pcie port.

---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 1 +
 1 file changed, 1 insertion(+)
#5 lore raw

PATCH 3/9 clk: qcom: ipq8074: Add missing bindings for pcie

In reply to Sivaprakash Murugesan

Add missing clock bindings for pcie port0 of ipq8074.

---
 include/dt-bindings/clock/qcom,gcc-ipq8074.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/clock/qcom,gcc-ipq8074.h +4 -0
index 4de4811a3540..e3e018565add 100644
@@ -362,5 +362,9 @@
 #define GCC_PCIE1_AXI_SLAVE_ARES		128
 #define GCC_PCIE1_AHB_ARES			129
 #define GCC_PCIE1_AXI_MASTER_STICKY_ARES	130
+#define GCC_PCIE0_AXI_SLAVE_STICKY_ARES		131
+#define GCC_PCIE0_AXI_S_BRIDGE_CLK		132
+#define GCC_PCIE0_RCHNG_CLK_SRC			133
+#define GCC_PCIE0_RCHNG_CLK			134
 
 #endif
Signature · 1 line
2.7.4
#7 lore raw

PATCH 4/9 clk: qcom: ipq8074: Add missing clocks for pcie

In reply to Sivaprakash Murugesan

Add missing clocks and resets for pcie port0 of ipq8074 devices.

---
 drivers/clk/qcom/gcc-ipq8074.c | 60 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
drivers/clk/qcom/gcc-ipq8074.c +60 -0
index e01f5f591d1e..443e28cda8ed 100644
@@ -4316,6 +4316,62 @@ static struct clk_branch gcc_gp3_clk = {
 	},
 };
 
+struct freq_tbl ftbl_pcie_rchng_clk_src[] = {
+	F(19200000, P_XO, 1, 0, 0),
+	F(100000000, P_GPLL0, 8, 0, 0),
+	{ }
+};
+
+struct clk_rcg2 pcie0_rchng_clk_src = {
+	.cmd_rcgr = 0x75070,
+	.freq_tbl = ftbl_pcie_rchng_clk_src,
+	.hid_width = 5,
+	.parent_map = gcc_xo_gpll0_map,
+	.clkr.hw.init = &(struct clk_init_data){
+		.name = "pcie0_rchng_clk_src",
+		.parent_hws = (const struct clk_hw *[]) {
+				&gpll0.clkr.hw },
+		.num_parents = 2,
+		.ops = &clk_rcg2_ops,
+	},
+};
+
+static struct clk_branch gcc_pcie0_rchng_clk = {
+	.halt_reg = 0x75070,
+	.halt_bit = 31,
+	.clkr = {
+		.enable_reg = 0x75070,
+		.enable_mask = BIT(1),
+		.hw.init = &(struct clk_init_data){
+			.name = "gcc_pcie0_rchng_clk",
+			.parent_hws = (const struct clk_hw *[]){
+				&pcie0_rchng_clk_src.clkr.hw,
+			},
+			.num_parents = 1,
+			.flags = CLK_SET_RATE_PARENT,
+			.ops = &clk_branch2_ops,
+		},
+	},
+};
+
+static struct clk_branch gcc_pcie0_axi_s_bridge_clk = {
+	.halt_reg = 0x75048,
+	.halt_bit = 31,
+	.clkr = {
+		.enable_reg = 0x75048,
+		.enable_mask = BIT(0),
+		.hw.init = &(struct clk_init_data){
+			.name = "gcc_pcie0_axi_s_bridge_clk",
+			.parent_hws = (const struct clk_hw *[]){
+				&pcie0_axi_clk_src.clkr.hw,
+			},
+			.num_parents = 1,
+			.flags = CLK_SET_RATE_PARENT,
+			.ops = &clk_branch2_ops,
+		},
+	},
+};
+
 static struct clk_hw *gcc_ipq8074_hws[] = {
 	&gpll0_out_main_div2.hw,
 	&gpll6_out_main_div2.hw,
@@ -4551,6 +4607,9 @@ static struct clk_regmap *gcc_ipq8074_clks[] = {
 	[GCC_GP1_CLK] = &gcc_gp1_clk.clkr,
 	[GCC_GP2_CLK] = &gcc_gp2_clk.clkr,
 	[GCC_GP3_CLK] = &gcc_gp3_clk.clkr,
+	[GCC_PCIE0_RCHNG_CLK_SRC] = &pcie0_rchng_clk_src.clkr,
+	[GCC_PCIE0_RCHNG_CLK] = &gcc_pcie0_rchng_clk.clkr,
+	[GCC_PCIE0_AXI_S_BRIDGE_CLK] = &gcc_pcie0_axi_s_bridge_clk.clkr,
 };
 
 static const struct qcom_reset_map gcc_ipq8074_resets[] = {
@@ -4678,6 +4737,7 @@ static const struct qcom_reset_map gcc_ipq8074_resets[] = {
 	[GCC_PCIE0_AXI_SLAVE_ARES] = { 0x75040, 4 },
 	[GCC_PCIE0_AHB_ARES] = { 0x75040, 5 },
 	[GCC_PCIE0_AXI_MASTER_STICKY_ARES] = { 0x75040, 6 },
+	[GCC_PCIE0_AXI_SLAVE_STICKY_ARES] = { 0x75040, 7 },
 	[GCC_PCIE1_PIPE_ARES] = { 0x76040, 0 },
 	[GCC_PCIE1_SLEEP_ARES] = { 0x76040, 1 },
 	[GCC_PCIE1_CORE_STICKY_ARES] = { 0x76040, 2 },
Signature · 1 line
2.7.4
maintainer
#8 lore raw

Re: [PATCH 4/9] clk: qcom: ipq8074: Add missing clocks for pcie

Quoting Sivaprakash Murugesan (2020-07-05 02:17:55)

drivers/clk/qcom/gcc-ipq8074.c static struct clk_branch gcc_gp3_clk = { · line 4319

Quoted 9 lines
drivers/clk/qcom/gcc-ipq8074.c +1 -0
index e01f5f591d1e..443e28cda8ed 100644
@@ -4316,6 +4316,62 @@ static struct clk_branch gcc_gp3_clk = {
        },
 };
 
+struct freq_tbl ftbl_pcie_rchng_clk_src[] = {

static const?

Quoted 5 lines
drivers/clk/qcom/gcc-ipq8074.c +5 -0
+       F(19200000, P_XO, 1, 0, 0),
+       F(100000000, P_GPLL0, 8, 0, 0),
+       { }
+};
+
maintainer Applied
#9 lore raw

Re: [PATCH 4/9] clk: qcom: ipq8074: Add missing clocks for pcie

In reply to Sivaprakash Murugesan

Quoting Sivaprakash Murugesan (2020-07-05 02:17:55)

Quoted 6 lines

Add missing clocks and resets for pcie port0 of ipq8074 devices.

---

Applied to clk-next

#10 lore raw

PATCH 5/9 phy: qcom-qmp: use correct values for ipq8074 gen2 pcie phy init

In reply to Sivaprakash Murugesan

There were some problem in ipq8074 gen2 pcie phy init sequence, fix these to make gen2 pcie port on ipq8074 to work.

Fixes eef243d04b2b6 ("phy: qcom-qmp: Add support for IPQ8074")
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 16 +++++++++-------
 drivers/phy/qualcomm/phy-qcom-qmp.h |  2 ++
 2 files changed, 11 insertions(+), 7 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp.c +9 -7
index e91040af3394..ba277136f52b 100644
@@ -504,8 +504,8 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf),
 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1),
 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0),
-	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0x1f),
-	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x3f),
+	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
+	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f),
 	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6),
 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf),
 	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0),
@@ -531,7 +531,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0),
 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
 	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1),
-	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0xa),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1),
@@ -540,7 +539,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19),
 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19),
-	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x7),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
@@ -548,6 +546,8 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6),
 	QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2),
 	QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12),
+	QMP_PHY_INIT_CFG(QSERDES_TX_EMP_POST1_LVL, 0x36),
+	QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
@@ -558,7 +558,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb),
 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4),
-	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN_HALF, 0x4),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = {
@@ -1673,6 +1672,9 @@ static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
 	.pwrdn_ctrl		= SW_PWRDN,
 };
 
+static const char * const ipq8074_pciephy_clk_l[] = {
+	"aux", "cfg_ahb",
+};
 /* list of resets */
 static const char * const ipq8074_pciephy_reset_l[] = {
 	"phy", "common",
@@ -1690,8 +1692,8 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
 	.rx_tbl_num		= ARRAY_SIZE(ipq8074_pcie_rx_tbl),
 	.pcs_tbl		= ipq8074_pcie_pcs_tbl,
 	.pcs_tbl_num		= ARRAY_SIZE(ipq8074_pcie_pcs_tbl),
-	.clk_list		= NULL,
-	.num_clks		= 0,
+	.clk_list		= ipq8074_pciephy_clk_l,
+	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),
 	.reset_list		= ipq8074_pciephy_reset_l,
 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
 	.vreg_list		= NULL,
drivers/phy/qualcomm/phy-qcom-qmp.h +2 -0
index 6d017a0c0c8d..832b3d098403 100644
@@ -77,6 +77,8 @@
 #define QSERDES_COM_CORECLK_DIV_MODE1			0x1bc
 
 /* Only for QMP V2 PHY - TX registers */
+#define QSERDES_TX_EMP_POST1_LVL			0x018
+#define QSERDES_TX_SLEW_CNTL				0x040
 #define QSERDES_TX_RES_CODE_LANE_OFFSET			0x054
 #define QSERDES_TX_DEBUG_BUS_SEL			0x064
 #define QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN	0x068
Signature · 1 line
2.7.4
maintainer
#11 lore raw

Re: [PATCH 5/9] phy: qcom-qmp: use correct values for ipq8074 gen2 pcie phy init

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag fixing commit: eef243d04b2b ("phy: qcom-qmp: Add support for IPQ8074").

The bot has tested the following trees: v5.7.7, v5.4.50, v4.19.131, v4.14.187.

v5.7.7: Build OK!
v5.4.50: Build OK!
v4.19.131: Build OK!
v4.14.187: Failed to apply! Possible dependencies:
e2248617ec157 ("phy: qcom-qmp: Move register offsets to header file")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#12 lore raw

Re: [PATCH 5/9] phy: qcom-qmp: use correct values for ipq8074 gen2 pcie phy init

In reply to Sivaprakash Murugesan
Quoted 1 line · Sivaprakash Murugesan

There were some problem in ipq8074 gen2 pcie phy init sequence, fix

Can you please describe these problems, it would help review to understand the issues and also for future reference to you

Quoted 72 lines

these to make gen2 pcie port on ipq8074 to work.

Fixes eef243d04b2b6 ("phy: qcom-qmp: Add support for IPQ8074")
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 16 +++++++++-------
 drivers/phy/qualcomm/phy-qcom-qmp.h |  2 ++
 2 files changed, 11 insertions(+), 7 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp.c +7 -5
index e91040af3394..ba277136f52b 100644
@@ -504,8 +504,8 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf),
 	QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1),
 	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0),
-	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0x1f),
-	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x3f),
+	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
+	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f),
 	QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6),
 	QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf),
 	QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0),
@@ -531,7 +531,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0),
 	QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
 	QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1),
-	QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0xa),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1),
@@ -540,7 +539,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f),
 	QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19),
 	QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19),
-	QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x7),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
@@ -548,6 +546,8 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6),
 	QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2),
 	QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12),
+	QMP_PHY_INIT_CFG(QSERDES_TX_EMP_POST1_LVL, 0x36),
+	QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
@@ -558,7 +558,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
 	QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb),
 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
 	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4),
-	QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN_HALF, 0x4),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = {
@@ -1673,6 +1672,9 @@ static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
 	.pwrdn_ctrl		= SW_PWRDN,
 };
 
+static const char * const ipq8074_pciephy_clk_l[] = {
+	"aux", "cfg_ahb",
+};
 /* list of resets */
 static const char * const ipq8074_pciephy_reset_l[] = {
 	"phy", "common",

drivers/phy/qualcomm/phy-qcom-qmp.c static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { · line 1696

Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +2 -2
@@ -1690,8 +1692,8 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
 	.rx_tbl_num		= ARRAY_SIZE(ipq8074_pcie_rx_tbl),
 	.pcs_tbl		= ipq8074_pcie_pcs_tbl,
 	.pcs_tbl_num		= ARRAY_SIZE(ipq8074_pcie_pcs_tbl),
-	.clk_list		= NULL,
-	.num_clks		= 0,
+	.clk_list		= ipq8074_pciephy_clk_l,
+	.num_clks		= ARRAY_SIZE(ipq8074_pciephy_clk_l),

I see patch is modifying some register values and then adding clks, in the absence of proper patch description it is extremely hard to understand what is going on..

Quoted 18 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +0 -0
 	.reset_list		= ipq8074_pciephy_reset_l,
 	.num_resets		= ARRAY_SIZE(ipq8074_pciephy_reset_l),
 	.vreg_list		= NULL,
drivers/phy/qualcomm/phy-qcom-qmp.h +2 -0
index 6d017a0c0c8d..832b3d098403 100644
@@ -77,6 +77,8 @@
 #define QSERDES_COM_CORECLK_DIV_MODE1			0x1bc
 
 /* Only for QMP V2 PHY - TX registers */
+#define QSERDES_TX_EMP_POST1_LVL			0x018
+#define QSERDES_TX_SLEW_CNTL				0x040
 #define QSERDES_TX_RES_CODE_LANE_OFFSET			0x054
 #define QSERDES_TX_DEBUG_BUS_SEL			0x064
 #define QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN	0x068
Signature · 1 line
2.7.4
Signature · 1 line
~Vinod
#13 lore raw

Re: [PATCH 5/9] phy: qcom-qmp: use correct values for ipq8074 gen2 pcie phy init

Quoted 4 lines · Vinod Koul
Quoted 1 line · Sivaprakash Murugesan

There were some problem in ipq8074 gen2 pcie phy init sequence, fix

Can you please describe these problems, it would help review to understand the issues and also for future reference to you

Hi Vinod,

As you mentioned we are updating few register values

and also adding clocks and resets.

the register values are given by the Hardware team and there

is some fine tuning values are provided by Hardware team for the

issues we faced downstream.

Also, few register values are typos for example QSERDES_RX_SIGDET_CNTRL

is a rx register it was wrongly in serdes table.

I will try to mention these details in next patch.

maintainer
#14 lore raw

Re: [PATCH 5/9] phy: qcom-qmp: use correct values for ipq8074 gen2 pcie phy init

Hi Sivaprakash,

Quoted 17 lines · Sivaprakash Murugesan
Quoted 4 lines · Vinod Koul
Quoted 1 line · Sivaprakash Murugesan

There were some problem in ipq8074 gen2 pcie phy init sequence, fix

Can you please describe these problems, it would help review to understand the issues and also for future reference to you

Hi Vinod,

As you mentioned we are updating few register values

and also adding clocks and resets.

the register values are given by the Hardware team and there

is some fine tuning values are provided by Hardware team for the

Quoted 7 lines

issues we faced downstream.

Also, few register values are typos for example QSERDES_RX_SIGDET_CNTRL

is a rx register it was wrongly in serdes table.

I will try to mention these details in next patch.

The right thing to do would be a change per patch explaining the reason. For example, fixing typos in QSERDES_RX_SIGDET_CNTRL, then another to update tuning values based on hw recommendations. Clocks and reset should be different patch

This helps us review each change for what it does and helps you down the line to figure why a line of code was changed

HTH

Signature · 1 line
~Vinod
#15 lore raw

PATCH 6/9 phy: qcom-qmp: Add compatible for ipq8074 pcie gen3 qmp phy

In reply to Sivaprakash Murugesan

ipq8074 has two pcie ports, one gen2 and one gen3 ports. with phy support already available for gen2 pcie ports add support for pcie gen3 port phy.

---
 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h | 137 ++++++++++++++++++++++++
 drivers/phy/qualcomm/phy-qcom-qmp.c       | 172 +++++++++++++++++++++++++++++-
 2 files changed, 307 insertions(+), 2 deletions(-)
 create mode 100644 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +137 -0
new file mode 100644
index 000000000000..bb567673d9b5
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: GPL-2.0*
+ *
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef PHY_QCOM_PCIE_H
+
+/* QMP V2 PCIE PHY - Found in IPQ8074 gen3 port - QSERDES PLL registers */
+#define QSERDES_PLL_BG_TIMER				0x00c
+#define QSERDES_PLL_SSC_PER1				0x01c
+#define QSERDES_PLL_SSC_PER2				0x020
+#define QSERDES_PLL_SSC_STEP_SIZE1_MODE0		0x024
+#define QSERDES_PLL_SSC_STEP_SIZE2_MODE0		0x028
+#define QSERDES_PLL_SSC_STEP_SIZE1_MODE1		0x02c
+#define QSERDES_PLL_SSC_STEP_SIZE2_MODE1		0x030
+#define QSERDES_PLL_BIAS_EN_CLKBUFLR_EN			0x03c
+#define QSERDES_PLL_CLK_ENABLE1				0x040
+#define QSERDES_PLL_SYS_CLK_CTRL			0x044
+#define QSERDES_PLL_SYSCLK_BUF_ENABLE			0x048
+#define QSERDES_PLL_PLL_IVCO				0x050
+#define QSERDES_PLL_LOCK_CMP1_MODE0			0x054
+#define QSERDES_PLL_LOCK_CMP2_MODE0			0x058
+#define QSERDES_PLL_LOCK_CMP1_MODE1			0x060
+#define QSERDES_PLL_LOCK_CMP2_MODE1			0x064
+#define QSERDES_PLL_BG_TRIM				0x074
+#define QSERDES_PLL_CLK_EP_DIV_MODE0			0x078
+#define QSERDES_PLL_CLK_EP_DIV_MODE1			0x07c
+#define QSERDES_PLL_CP_CTRL_MODE0			0x080
+#define QSERDES_PLL_CP_CTRL_MODE1			0x084
+#define QSERDES_PLL_PLL_RCTRL_MODE0			0x088
+#define	QSERDES_PLL_PLL_RCTRL_MODE1			0x08C
+#define QSERDES_PLL_PLL_CCTRL_MODE0			0x090
+#define	QSERDES_PLL_PLL_CCTRL_MODE1			0x094
+#define QSERDES_PLL_BIAS_EN_CTRL_BY_PSM			0x0a4
+#define	QSERDES_PLL_SYSCLK_EN_SEL			0x0a8
+#define QSERDES_PLL_RESETSM_CNTRL			0x0b0
+#define QSERDES_PLL_LOCK_CMP_EN				0x0c4
+#define QSERDES_PLL_DEC_START_MODE0			0x0cc
+#define QSERDES_PLL_DEC_START_MODE1			0x0d0
+#define QSERDES_PLL_DIV_FRAC_START1_MODE0		0x0d8
+#define QSERDES_PLL_DIV_FRAC_START2_MODE0		0x0dc
+#define QSERDES_PLL_DIV_FRAC_START3_MODE0		0x0e0
+#define QSERDES_PLL_DIV_FRAC_START1_MODE1		0x0e4
+#define QSERDES_PLL_DIV_FRAC_START2_MODE1		0x0e8
+#define QSERDES_PLL_DIV_FRAC_START3_MODE1		0x0eC
+#define QSERDES_PLL_INTEGLOOP_GAIN0_MODE0		0x100
+#define QSERDES_PLL_INTEGLOOP_GAIN1_MODE0		0x104
+#define QSERDES_PLL_INTEGLOOP_GAIN0_MODE1		0x108
+#define QSERDES_PLL_INTEGLOOP_GAIN1_MODE1		0x10c
+#define QSERDES_PLL_VCO_TUNE_MAP			0x120
+#define QSERDES_PLL_VCO_TUNE1_MODE0			0x124
+#define QSERDES_PLL_VCO_TUNE2_MODE0			0x128
+#define QSERDES_PLL_VCO_TUNE1_MODE1			0x12c
+#define QSERDES_PLL_VCO_TUNE2_MODE1			0x130
+#define QSERDES_PLL_VCO_TUNE_TIMER1			0x13c
+#define QSERDES_PLL_VCO_TUNE_TIMER2			0x140
+#define QSERDES_PLL_CLK_SELECT				0x16c
+#define QSERDES_PLL_HSCLK_SEL				0x170
+#define QSERDES_PLL_CORECLK_DIV				0x17c
+#define QSERDES_PLL_CORE_CLK_EN				0x184
+#define	QSERDES_PLL_CMN_CONFIG				0x18c
+#define QSERDES_PLL_SVS_MODE_CLK_SEL			0x194
+#define QSERDES_PLL_CORECLK_DIV_MODE1			0x1b4
+
+/* QMP V2 PCIE PHY - Found in IPQ8074 gen3 port - - QSERDES TX registers */
+#define QSERDES_TX0_RES_CODE_LANE_OFFSET_TX		0x03c
+#define QSERDES_TX0_HIGHZ_DRVR_EN			0x058
+#define QSERDES_TX0_LANE_MODE_1				0x084
+#define QSERDES_TX0_RCV_DETECT_LVL_2			0x09c
+
+/* QMP V2 PCIE PHY - Found in IPQ8074 gen3 port - QSERDES RX registers */
+#define QSERDES_RX0_UCDR_FO_GAIN			0x008
+#define QSERDES_RX0_UCDR_SO_GAIN			0x014
+#define QSERDES_RX0_UCDR_SO_SATURATION_AND_ENABLE	0x034
+#define QSERDES_RX0_UCDR_PI_CONTROLS			0x044
+#define QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL2		0x0ec
+#define QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL3		0x0f0
+#define QSERDES_RX0_RX_EQU_ADAPTOR_CNTRL4		0x0f4
+#define QSERDES_RX0_RX_IDAC_TSETTLE_LOW			0x0f8
+#define QSERDES_RX0_RX_IDAC_TSETTLE_HIGH		0x0fc
+#define QSERDES_RX0_RX_EQ_OFFSET_ADAPTOR_CNTRL1		0x110
+#define QSERDES_RX0_RX_OFFSET_ADAPTOR_CNTRL2		0x114
+#define QSERDES_RX0_SIGDET_ENABLES			0x118
+#define QSERDES_RX0_SIGDET_CNTRL			0x11c
+#define QSERDES_RX0_SIGDET_DEGLITCH_CNTRL		0x124
+#define QSERDES_RX0_RX_MODE_00_LOW			0x170
+#define QSERDES_RX0_RX_MODE_00_HIGH			0x174
+#define QSERDES_RX0_RX_MODE_00_HIGH2			0x178
+#define QSERDES_RX0_RX_MODE_00_HIGH3			0x17c
+#define QSERDES_RX0_RX_MODE_00_HIGH4			0x180
+#define QSERDES_RX0_RX_MODE_01_LOW			0x184
+#define QSERDES_RX0_RX_MODE_01_HIGH			0x188
+#define QSERDES_RX0_RX_MODE_01_HIGH2			0x18c
+#define QSERDES_RX0_RX_MODE_01_HIGH3			0x190
+#define QSERDES_RX0_RX_MODE_01_HIGH4			0x194
+#define QSERDES_RX0_RX_MODE_10_LOW			0x198
+#define QSERDES_RX0_RX_MODE_10_HIGH			0x19c
+#define QSERDES_RX0_RX_MODE_10_HIGH2			0x1a0
+#define QSERDES_RX0_RX_MODE_10_HIGH3			0x1a4
+#define QSERDES_RX0_RX_MODE_10_HIGH4			0x1a8
+#define QSERDES_RX0_DFE_EN_TIMER			0x1b4
+
+/* QMP V2 PCIE PHY - Found in IPQ8074 gen3 port - PCS registers */
+
+#define PCS_COM_FLL_CNTRL1				0x098
+#define PCS_COM_FLL_CNTRL2				0x09c
+#define PCS_COM_FLL_CNT_VAL_L				0x0a0
+#define PCS_COM_FLL_CNT_VAL_H_TOL			0x0a4
+#define PCS_COM_FLL_MAN_CODE				0x0a8
+#define PCS_COM_REFGEN_REQ_CONFIG1			0x0dc
+#define PCS_COM_G12S1_TXDEEMPH_M3P5DB			0x16c
+#define PCS_COM_RX_SIGDET_LVL				0x188
+#define PCS_COM_P2U3_WAKEUP_DLY_TIME_AUXCLK_L		0x1a4
+#define PCS_COM_P2U3_WAKEUP_DLY_TIME_AUXCLK_H		0x1a8
+#define PCS_COM_RX_DCC_CAL_CONFIG			0x1d8
+#define PCS_COM_EQ_CONFIG5				0x1ec
+
+/* QMP V2 PCIE PHY - Found in IPQ8074 gen3 port - PCS Misc registers */
+
+#define PCS_PCIE_POWER_STATE_CONFIG2			0x40c
+#define PCS_PCIE_POWER_STATE_CONFIG4			0x414
+#define PCS_PCIE_ENDPOINT_REFCLK_DRIVE			0x41c
+#define PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_L		0x440
+#define PCS_PCIE_L1P1_WAKEUP_DLY_TIME_AUXCLK_H		0x444
+#define PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_L		0x448
+#define PCS_PCIE_L1P2_WAKEUP_DLY_TIME_AUXCLK_H		0x44c
+#define PCS_PCIE_OSC_DTCT_CONFIG2			0x45c
+#define PCS_PCIE_OSC_DTCT_MODE2_CONFIG2			0x478
+#define PCS_PCIE_OSC_DTCT_MODE2_CONFIG4			0x480
+#define PCS_PCIE_OSC_DTCT_MODE2_CONFIG5			0x484
+#define PCS_PCIE_OSC_DTCT_ACTIONS			0x490
+#define PCS_PCIE_EQ_CONFIG1				0x4a0
+#define PCS_PCIE_EQ_CONFIG2				0x4a4
+#define PCS_PCIE_PRESET_P10_PRE				0x4bc
+#define PCS_PCIE_PRESET_P10_POST			0x4e0
+
+#endif
drivers/phy/qualcomm/phy-qcom-qmp.c +170 -2

202 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#16 lore raw

Re: [PATCH 6/9] phy: qcom-qmp: Add compatible for ipq8074 pcie gen3 qmp phy

Quoted 19 lines · Sivaprakash Murugesan

ipq8074 has two pcie ports, one gen2 and one gen3 ports. with phy support already available for gen2 pcie ports add support for pcie gen3 port phy.

---
 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h | 137 ++++++++++++++++++++++++
 drivers/phy/qualcomm/phy-qcom-qmp.c       | 172 +++++++++++++++++++++++++++++-
 2 files changed, 307 insertions(+), 2 deletions(-)
 create mode 100644 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +0 -0
new file mode 100644
index 000000000000..bb567673d9b5

drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h line 1

Quoted 1 line
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +1 -0
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: GPL-2.0*

Trailing * at the end, it would make sense to split the spdx and copyright parts to two single lines

drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) · line 2715

Quoted 12 lines
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +6 -2
@@ -2550,8 +2707,16 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)
 
 	init.ops = &clk_fixed_rate_ops;
 
-	/* controllers using QMP phys use 125MHz pipe clock interface */
-	fixed->fixed_rate = 125000000;
+	/*
+	 * controllers using QMP phys use 125MHz pipe clock interface unless
+	 * other frequency is specified in dts
+	 */
+	ret = of_property_read_u32(np, "clock-output-rate",
+				   (u32 *)&fixed->fixed_rate);

is this cast required?

drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) · line 2719

Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +4 -0
+	if (ret)
+		fixed->fixed_rate = 125000000;
+
+	dev_info(qmp->dev, "fixed freq %lu\n", fixed->fixed_rate);

debug?

Signature · 1 line
~Vinod
#17 lore raw

Re: [PATCH 6/9] phy: qcom-qmp: Add compatible for ipq8074 pcie gen3 qmp phy

Hi Vinod,

Quoted 14 lines · Vinod Koul
Quoted 13 lines · Sivaprakash Murugesan

ipq8074 has two pcie ports, one gen2 and one gen3 ports. with phy support already available for gen2 pcie ports add support for pcie gen3 port phy.

---
  drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h | 137 ++++++++++++++++++++++++
  drivers/phy/qualcomm/phy-qcom-qmp.c       | 172 +++++++++++++++++++++++++++++-
  2 files changed, 307 insertions(+), 2 deletions(-)

create mode 100644 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h

Quoted 9 lines

drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h line 1

Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +1 -0
new file mode 100644
index 000000000000..bb567673d9b5
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: GPL-2.0*

Trailing * at the end, it would make sense to split the spdx and copyright parts to two single lines

ok

Quoted 5 lines
Quoted 5 lines
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +0 -0
@@ -2550,8 +2707,16 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np)
 
  	init.ops = &clk_fixed_rate_ops;
 
Quoted 9 lines

drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) · line 2715

Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +6 -2
-	/* controllers using QMP phys use 125MHz pipe clock interface */
-	fixed->fixed_rate = 125000000;
+	/*
+	 * controllers using QMP phys use 125MHz pipe clock interface unless
+	 * other frequency is specified in dts
+	 */
+	ret = of_property_read_u32(np, "clock-output-rate",
+				   (u32 *)&fixed->fixed_rate);

is this cast required?

without this getting the following error.

./include/linux/of.h:1209:19: note: expected 'u32 * {aka unsigned int *}' but argument is of type 'long unsigned int *'

Quoted 6 lines

drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) · line 2719

Quoted 5 lines
drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h new file +4 -0
+	if (ret)
+		fixed->fixed_rate = 125000000;
+
+	dev_info(qmp->dev, "fixed freq %lu\n", fixed->fixed_rate);

debug?

will remove in next patch.

#18 lore raw

PATCH 7/9 pci: dwc: qcom: do phy power on before pcie init

In reply to Sivaprakash Murugesan

Commit cc1e06f033af ("phy: qcom: qmp: Use power_on/off ops for PCIe") changed phy ops from init/deinit to power on/off, due to this phy enable is getting called after pcie init.

On some platforms like ipq8074 phy should be inited before accessing the pcie register space, otherwise the system would hang.

So move phy_power_on API before pcie init API.

Fixes commit cc1e06f033af ("phy: qcom: qmp: Use power_on/off ops for PCIe")
---
 drivers/pci/controller/dwc/pcie-qcom.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +6 -6
index 138e1a2d21cc..aa52a2124760 100644
@@ -1222,18 +1222,18 @@ static int qcom_pcie_host_init(struct pcie_port *pp)
 
 	qcom_ep_reset_assert(pcie);
 
-	ret = pcie->ops->init(pcie);
+	ret = phy_power_on(pcie->phy);
 	if (ret)
 		return ret;
 
-	ret = phy_power_on(pcie->phy);
+	ret = pcie->ops->init(pcie);
 	if (ret)
-		goto err_deinit;
+		goto err_disable_phy;
 
 	if (pcie->ops->post_init) {
 		ret = pcie->ops->post_init(pcie);
 		if (ret)
-			goto err_disable_phy;
+			goto err_deinit;
 	}
 
 	dw_pcie_setup_rc(pp);
@@ -1252,10 +1252,10 @@ static int qcom_pcie_host_init(struct pcie_port *pp)
 	qcom_ep_reset_assert(pcie);
 	if (pcie->ops->post_deinit)
 		pcie->ops->post_deinit(pcie);
-err_disable_phy:
-	phy_power_off(pcie->phy);
 err_deinit:
 	pcie->ops->deinit(pcie);
+err_disable_phy:
+	phy_power_off(pcie->phy);
 
 	return ret;
 }
Signature · 1 line
2.7.4
#19 lore raw

PATCH 8/9 pci: qcom: Add support for ipq8074 pci controller

In reply to Sivaprakash Murugesan

ipq8074 has one gen2 and one gen3 pcie port, with support for gen2 port is already available add support for pcie gen3 port.

---
 drivers/pci/controller/dwc/pcie-qcom.c | 175 ++++++++++++++++++++++++++++++++-
 1 file changed, 174 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-qcom.c +174 -1
index aa52a2124760..1a6fafdb2642 100644
@@ -39,8 +39,17 @@
 #define L23_CLK_RMV_DIS				BIT(2)
 #define L1_CLK_RMV_DIS				BIT(1)
 
+#define PCIE_ATU_CR1_OUTBOUND_6_GEN3		0xC00
+#define PCIE_ATU_CR2_OUTBOUND_6_GEN3		0xC04
+#define PCIE_ATU_LIMIT_OUTBOUND_6_GEN3		0xC10
+#define PCIE_ATU_CR1_OUTBOUND_7_GEN3		0xE00
+#define PCIE_ATU_CR2_OUTBOUND_7_GEN3		0xE04
+#define PCIE_ATU_LOWER_BASE_OUTBOUND_7_GEN3	0xE08
+#define PCIE_ATU_LIMIT_OUTBOUND_7_GEN3		0xE10
+
 #define PCIE20_COMMAND_STATUS			0x04
 #define CMD_BME_VAL				0x4
+#define BUS_MASTER_EN				0x7
 #define PCIE20_DEVICE_CONTROL2_STATUS2		0x98
 #define PCIE_CAP_CPL_TIMEOUT_DISABLE		0x10
 
@@ -49,6 +58,15 @@
 #define PCIE20_PARF_DBI_BASE_ADDR		0x168
 #define PCIE20_PARF_SLV_ADDR_SPACE_SIZE		0x16C
 #define PCIE20_PARF_MHI_CLOCK_RESET_CTRL	0x174
+
+#define AHB_CLK_EN				BIT(0)
+#define MSTR_AXI_CLK_EN				BIT(1)
+#define BYPASS					BIT(4)
+
+#define PCIE20_LNK_CONTROL2_LINK_STATUS2	0xA0
+#define PCIE_CAP_CURR_DEEMPHASIS		BIT(16)
+#define SPEED_GEN3				0x3
+
 #define PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT	0x178
 #define PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT_V2	0x1A8
 #define PCIE20_PARF_LTSSM			0x1B0
@@ -56,6 +74,9 @@
 #define PCIE20_PARF_BDF_TRANSLATE_CFG		0x24C
 #define PCIE20_PARF_DEVICE_TYPE			0x1000
 
+#define PCIE20_PARF_BDF_TO_SID_TABLE		0x2000
+#define BDF_TO_SID_TABLE_SIZE			0x100
+
 #define PCIE20_ELBI_SYS_CTRL			0x04
 #define PCIE20_ELBI_SYS_CTRL_LT_ENABLE		BIT(0)
 
@@ -83,6 +104,10 @@
 
 #define DEVICE_TYPE_RC				0x4
 
+#define PCIE30_GEN3_RELATED_OFF			0x890
+#define RXEQ_RGRDLESS_RXTS			BIT(13)
+#define GEN3_ZRXDC_NONCOMPL			BIT(0)
+
 #define QCOM_PCIE_2_1_0_MAX_SUPPLY	3
 struct qcom_pcie_resources_2_1_0 {
 	struct clk *iface_clk;
@@ -149,6 +174,11 @@ struct qcom_pcie_resources_2_7_0 {
 	struct clk *pipe_clk;
 };
 
+struct qcom_pcie_resources_2_9_0 {
+	struct clk_bulk_data clks[7];
+	struct reset_control *rst[8];
+};
+
 union qcom_pcie_resources {
 	struct qcom_pcie_resources_1_0_0 v1_0_0;
 	struct qcom_pcie_resources_2_1_0 v2_1_0;
@@ -156,6 +186,7 @@ union qcom_pcie_resources {
 	struct qcom_pcie_resources_2_3_3 v2_3_3;
 	struct qcom_pcie_resources_2_4_0 v2_4_0;
 	struct qcom_pcie_resources_2_7_0 v2_7_0;
+	struct qcom_pcie_resources_2_9_0 v2_9_0;
 };
 
 struct qcom_pcie;
@@ -1207,6 +1238,133 @@ static void qcom_pcie_post_deinit_2_7_0(struct qcom_pcie *pcie)
 	clk_disable_unprepare(res->pipe_clk);
 }
 
+static int qcom_pcie_get_resources_2_9_0(struct qcom_pcie *pcie)
+{
+	struct qcom_pcie_resources_2_9_0 *res = &pcie->res.v2_9_0;
+	struct dw_pcie *pci = pcie->pci;
+	struct device *dev = pci->dev;
+	int ret, i;
+	const char *rst_names[] = { "pipe", "sleep", "sticky", "axi_m",
+				    "axi_s", "ahb", "axi_m_sticky",
+				    "axi_s_sticky" };
+
+	res->clks[0].id = "iface";
+	res->clks[1].id = "axi_m";
+	res->clks[2].id = "axi_s";
+	res->clks[3].id = "ahb";
+	res->clks[4].id = "aux";
+	res->clks[5].id = "axi_bridge";
+	res->clks[6].id = "rchng";
+
+	ret = devm_clk_bulk_get(dev, ARRAY_SIZE(res->clks), res->clks);
+	if (ret < 0)
+		return ret;
+
+	for (i = 0; i < ARRAY_SIZE(rst_names); i++) {
+		res->rst[i] = devm_reset_control_get(dev, rst_names[i]);
+		if (IS_ERR(res->rst[i]))
+			return PTR_ERR(res->rst[i]);
+	}
+
+	return 0;
+}
+
+static int qcom_pcie_init_2_9_0(struct qcom_pcie *pcie)
+{
+	struct qcom_pcie_resources_2_9_0 *res = &pcie->res.v2_9_0;
+	struct dw_pcie *pci = pcie->pci;
+	struct device *dev = pci->dev;
+	int i, ret;
+	u32 val;
+
+	for (i = 0; i < ARRAY_SIZE(res->rst); i++) {
+		ret = reset_control_assert(res->rst[i]);
+		if (ret) {
+			dev_err(dev, "reset #%d assert failed (%d)\n", i, ret);
+			return ret;
+		}
+	}
+
+	usleep_range(2000, 2500);
+
+	for (i = 0; i < ARRAY_SIZE(res->rst); i++) {
+		ret = reset_control_deassert(res->rst[i]);
+		if (ret) {
+			dev_err(dev, "reset #%d deassert failed (%d)\n", i,
+				ret);
+			return ret;
+		}
+	}
+
+	/*
+	 * Don't have a way to see if the reset has completed.
+	 * Wait for some time.
+	 */
+	usleep_range(2000, 2500);
+
+	ret = clk_bulk_prepare_enable(ARRAY_SIZE(res->clks), res->clks);
+	if (ret)
+		return ret;
+
+	/* Parf config */
+	writel(SLV_ADDR_SPACE_SZ,
+	       pcie->parf + PCIE20_v3_PARF_SLV_ADDR_SPACE_SIZE);
+
+	val = readl(pcie->parf + PCIE20_PARF_PHY_CTRL);
+	val &= ~BIT(0);
+	writel(val, pcie->parf + PCIE20_PARF_PHY_CTRL);
+
+	writel(0, pcie->parf + PCIE20_PARF_DBI_BASE_ADDR);
+	writel(DEVICE_TYPE_RC, pcie->parf + PCIE20_PARF_DEVICE_TYPE);
+	writel(BYPASS | MSTR_AXI_CLK_EN | AHB_CLK_EN,
+	       pcie->parf + PCIE20_PARF_MHI_CLOCK_RESET_CTRL);
+
+	writel(RXEQ_RGRDLESS_RXTS | GEN3_ZRXDC_NONCOMPL,
+	       pci->dbi_base + PCIE30_GEN3_RELATED_OFF);
+	writel(MST_WAKEUP_EN | SLV_WAKEUP_EN | MSTR_ACLK_CGC_DIS
+		| SLV_ACLK_CGC_DIS | CORE_CLK_CGC_DIS |
+		AUX_PWR_DET | L23_CLK_RMV_DIS | L1_CLK_RMV_DIS,
+		pcie->parf + PCIE20_PARF_SYS_CTRL);
+	writel(0, pcie->parf + PCIE20_PARF_Q2A_FLUSH);
+
+	/* DBI config */
+	writel(BUS_MASTER_EN, pci->dbi_base + PCIE20_COMMAND_STATUS);
+
+	writel(DBI_RO_WR_EN, pci->dbi_base + PCIE20_MISC_CONTROL_1_REG);
+	writel(PCIE_CAP_LINK1_VAL, pci->dbi_base + PCIE20_CAP_LINK_1);
+
+	/* Configure PCIe link capabilities for ASPM */
+	val = readl(pci->dbi_base + PCIE20_CAP_LINK_CAPABILITIES);
+	val &= ~PCIE20_CAP_ACTIVE_STATE_LINK_PM_SUPPORT;
+	writel(val, pci->dbi_base + PCIE20_CAP_LINK_CAPABILITIES);
+
+	writel(PCIE_CAP_CPL_TIMEOUT_DISABLE, pci->dbi_base +
+		PCIE20_DEVICE_CONTROL2_STATUS2);
+
+	writel(PCIE_CAP_CURR_DEEMPHASIS | SPEED_GEN3,
+	       pci->dbi_base + PCIE20_LNK_CONTROL2_LINK_STATUS2);
+
+	for (i = 0 ; i < BDF_TO_SID_TABLE_SIZE ; i++)
+		writel(0x0, pcie->parf + PCIE20_PARF_BDF_TO_SID_TABLE + (4 * i));
+
+	writel(0x4, pci->atu_base + PCIE_ATU_CR1_OUTBOUND_6_GEN3);
+	writel(0x90000000, pci->atu_base + PCIE_ATU_CR2_OUTBOUND_6_GEN3);
+	writel(0x00107FFFF, pci->atu_base + PCIE_ATU_LIMIT_OUTBOUND_6_GEN3);
+	writel(0x5, pci->atu_base + PCIE_ATU_CR1_OUTBOUND_7_GEN3);
+	writel(0x90000000, pci->atu_base + PCIE_ATU_CR2_OUTBOUND_7_GEN3);
+	writel(0x200000, pci->atu_base + PCIE_ATU_LOWER_BASE_OUTBOUND_7_GEN3);
+	writel(0x7FFFFF, pci->atu_base + PCIE_ATU_LIMIT_OUTBOUND_7_GEN3);
+
+	return 0;
+}
+
+static void qcom_pcie_deinit_2_9_0(struct qcom_pcie *pcie)
+{
+	struct qcom_pcie_resources_2_9_0 *res = &pcie->res.v2_9_0;
+
+	clk_bulk_disable_unprepare(ARRAY_SIZE(res->clks), res->clks);
+}
+
 static int qcom_pcie_link_up(struct dw_pcie *pci)
 {
 	u16 val = readw(pci->dbi_base + PCIE20_CAP + PCI_EXP_LNKSTA);
@@ -1246,7 +1404,6 @@ static int qcom_pcie_host_init(struct pcie_port *pp)
 	ret = qcom_pcie_establish_link(pcie);
 	if (ret)
 		goto err;
-
 	return 0;
 err:
 	qcom_ep_reset_assert(pcie);
@@ -1316,6 +1473,14 @@ static const struct qcom_pcie_ops ops_2_7_0 = {
 	.post_deinit = qcom_pcie_post_deinit_2_7_0,
 };
 
+/* Qcom IP rev.: 2.9.0	Synopsys IP rev.: 5.00a */
+static const struct qcom_pcie_ops ops_2_9_0 = {
+	.get_resources = qcom_pcie_get_resources_2_9_0,
+	.init = qcom_pcie_init_2_9_0,
+	.deinit = qcom_pcie_deinit_2_9_0,
+	.ltssm_enable = qcom_pcie_2_3_2_ltssm_enable,
+};
+
 static const struct dw_pcie_ops dw_pcie_ops = {
 	.link_up = qcom_pcie_link_up,
 };
@@ -1358,6 +1523,13 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 		goto err_pm_runtime_put;
 	}
 
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "atu");
+	pci->atu_base = devm_pci_remap_cfg_resource(dev, res);
+	if (IS_ERR(pci->atu_base) && pcie->ops == &ops_2_9_0) {
+		ret = PTR_ERR(pci->atu_base);
+		goto err_pm_runtime_put;
+	}
+
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "parf");
 	pcie->parf = devm_ioremap_resource(dev, res);
 	if (IS_ERR(pcie->parf)) {
@@ -1432,6 +1604,7 @@ static const struct of_device_id qcom_pcie_match[] = {
 	{ .compatible = "qcom,pcie-ipq4019", .data = &ops_2_4_0 },
 	{ .compatible = "qcom,pcie-qcs404", .data = &ops_2_4_0 },
 	{ .compatible = "qcom,pcie-sdm845", .data = &ops_2_7_0 },
+	{ .compatible = "qcom,pcie-ipq8074-gen3", .data = &ops_2_9_0 },
 	{ }
 };
 
Signature · 1 line
2.7.4
#20 lore raw

PATCH 9/9 arm64: dts: ipq8074: Fixup pcie dts nodes

In reply to Sivaprakash Murugesan

ipq8074 pcie nodes missing several properties which is needed to make them work add these properties.

---
 arch/arm64/boot/dts/qcom/ipq8074-hk01.dts |   8 +--
 arch/arm64/boot/dts/qcom/ipq8074.dtsi     | 109 ++++++++++++++++++++----------
 2 files changed, 78 insertions(+), 39 deletions(-)
arch/arm64/boot/dts/qcom/ipq8074-hk01.dts +4 -4
index 6754cb0638f4..dfb8ad73f134 100644
@@ -52,19 +52,19 @@
 
 &pcie0 {
 	status = "ok";
-	perst-gpio = <&tlmm 61 0x1>;
+	perst-gpio = <&tlmm 58 0x1>;
 };
 
 &pcie1 {
 	status = "ok";
-	perst-gpio = <&tlmm 58 0x1>;
+	perst-gpio = <&tlmm 61 0x1>;
 };
 
-&pcie_phy0 {
+&qmp_pcie_phy0 {
 	status = "ok";
 };
 
-&pcie_phy1 {
+&qmp_pcie_phy1 {
 	status = "ok";
 };
 
arch/arm64/boot/dts/qcom/ipq8074.dtsi +74 -35

175 lines not on this page · raw message

Signature · 1 line
2.7.4
#21 lore raw
In reply to Sivaprakash Murugesan
Quoted 15 lines · Sivaprakash Murugesan

IPQ8074 has two PCIe ports both are based on synopsis designware PCIe controller. while it was assumed that PCIe support for IPQ8074 was already available. PCIe was not functional until now.

This patch series adds support for PCIe ports on IPQ8074.

First PCIe port is of gen2 synposis version is 2_3_2 which has already been enabled. But it had some problems on phy init and needed dt updates.

Second PCIe port is gen3 synopsis version is 2_9_0. This series adds support for this PCIe port while fixing dt nodes.

Patch 1 on this series depends on qcom pcie bindings patch
https://lkml.org/lkml/2020/6/24/162

Quoted 10 lines

Sivaprakash Murugesan (9):
dt-bindings: pci: Add ipq8074 gen3 pci compatible
dt-bindings: phy: qcom,qmp: Add dt-binding for ipq8074 gen3 pcie phy
clk: qcom: ipq8074: Add missing bindings for pcie
clk: qcom: ipq8074: Add missing clocks for pcie
phy: qcom-qmp: use correct values for ipq8074 gen2 pcie phy init
phy: qcom-qmp: Add compatible for ipq8074 pcie gen3 qmp phy
pci: dwc: qcom: do phy power on before pcie init
pci: qcom: Add support for ipq8074 pci controller
arm64: dts: ipq8074: Fixup pcie dts nodes

No comment on the patches themselves, but please update the subject lines so they follow the conventions:

dt-bindings: PCI: qcom: Add ipq8074 PCIe Gen3 support
dt-bindings: phy: qcom,qmp: Add ipq8074 PCIe Gen3 phy
clk: qcom: ipq8074: Add missing bindings for PCIe
clk: qcom: ipq8074: Add missing clocks for PCIe
phy: qcom-qmp: Use correct values for ipq8074 PCIe Gen2 PHY init
PCI: qcom: Do PHY power on before PCIe init
PCI: qcom: Add ipq8074 PCIe controller support
arm64: dts: ipq8074: Fixup PCIe DTS nodes

Also fix the same things in the commit logs, e.g., consistently use "PCIe" instead of "pcie", "Gen2" instead of "gen2", etc. For example:

ipq8074 has two PCIe ports while the support for gen2 pcie port ...

What's the point of using "PCIe" for the first and "pcie" for the second?

You can learn all this by using "git log" and "git log --online".

Quoted 16 lines
 .../devicetree/bindings/pci/qcom,pcie.yaml         |  47 ++++++
 .../devicetree/bindings/phy/qcom,qmp-phy.yaml      |   1 +
 arch/arm64/boot/dts/qcom/ipq8074-hk01.dts          |   8 +-
 arch/arm64/boot/dts/qcom/ipq8074.dtsi              | 109 ++++++++----
 drivers/clk/qcom/gcc-ipq8074.c                     |  60 +++++++
 drivers/pci/controller/dwc/pcie-qcom.c             | 187 +++++++++++++++++++-
 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h          | 132 +++++++++++++++
 drivers/phy/qualcomm/phy-qcom-qmp.c                | 188 ++++++++++++++++++++-
 drivers/phy/qualcomm/phy-qcom-qmp.h                |   2 +
 include/dt-bindings/clock/qcom,gcc-ipq8074.h       |   4 +
 10 files changed, 683 insertions(+), 55 deletions(-)
 create mode 100644 drivers/phy/qualcomm/phy-qcom-pcie3-qmp.h
Signature · 1 line
2.7.4