phy: qcom: qmp-combo: rework register access
Subsystems (2)
cover phy: qcom: qmp-combo: rework register access
The patch at [1], which added another function just to have v4 vs v6 register address difference prompted me to take a look at the combo PHY driver. We already have mechanism, register layout descriptions, for coping with register address differences, which I ignored while adding v4 support. It looks like nowadays this has exploded somehow, resulting inseveral almost-identicatical functions.
Forcibly use regs layout for all version-specific registers used in DP PHY programming. As a result, this allows us to drop several very similar functions. And also while doing this cleanup I spotted a typo, which resulted in a patch 1, fixing bias0_en programming for sc8280 and sm8550 PHYs.
Dmitry Baryshkov (7):
phy: qcom: qmp-combo: correct bias0_en programming
phy: qcom: qmp-combo: reuse register layouts for more registers
phy: qcom: qmp-combo: reuse register layouts for even more registers
phy: qcom: qmp-combo: reuse register layouts for some more registers
phy: qcom: qmp-combo: drop similar functions
phy: qcom: qmp-combo: drop qmp_v6_dp_aux_init()
phy: qcom: qmp-combo: extract common function to setup clocks
drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 408 +++++++----------- .../qualcomm/phy-qcom-qmp-qserdes-txrx-v6.h | 5 + drivers/phy/qualcomm/phy-qcom-qmp.h | 2 + 3 files changed, 174 insertions(+), 241 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/7 phy: qcom: qmp-combo: correct bias0_en programming
It seems the commit a2e927b0e50d ("phy: qcom-qmp-combo: Add sc8280xp USB/DP combo phys") contained a typo for selecting bias0_en values. First, bias0_en and bias1_en are expected to be symmetrical, and then the vendor driver also uses flipped : 0x3E : 0x15 statement for bias0_en. Correct bias0_en programming to follow this.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +2 -2
@@ -2322,7 +2322,7 @@ static int qmp_v5_configure_dp_phy(struct qmp_combo *qmp)return ret;if (dp_opts->lanes ==1 ) { - bias0_en = reverse ?0x3e :0x1a ; + bias0_en = reverse ?0x3e :0x15 ; drvr0_en = reverse ?0x13 :0x10 ; bias1_en = reverse ?0x15 :0x3e ; drvr1_en = reverse ?0x10 :0x13 ;
@@ -2382,7 +2382,7 @@ static int qmp_v6_configure_dp_phy(struct qmp_combo *qmp)return ret;if (dp_opts->lanes ==1 ) { - bias0_en = reverse ?0x3e :0x1a ; + bias0_en = reverse ?0x3e :0x15 ; drvr0_en = reverse ?0x13 :0x10 ; bias1_en = reverse ?0x15 :0x3e ; drvr1_en = reverse ?0x10 :0x13 ;
Signature · 1 line
2.39.2
PATCH 2/7 phy: qcom: qmp-combo: reuse register layouts for more registers
In reply to Dmitry BaryshkovInstead of passing additional registers to qmp_v456_configure_dp_phy(), reuse qphy_reg_layout and add those registers to register layout maps.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 100 ++++++++++++++-------- 1 file changed, 64 insertions(+), 36 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +64 -36
@@ -106,6 +106,13 @@ enum qphy_reg_layout {QPHY_PCS_AUTONOMOUS_MODE_CTRL ,QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR ,QPHY_PCS_POWER_DOWN_CONTROL , + +QPHY_COM_RESETSM_CNTRL , +QPHY_COM_C_READY_STATUS , +QPHY_COM_CMN_STATUS , + +QPHY_DP_PHY_STATUS , +/* Keep last to ensure regs_layout arrays are properly initialized */ QPHY_LAYOUT_SIZE };
@@ -117,9 +124,15 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V3_PCS_POWER_DOWN_CONTROL, [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V3_PCS_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V3_PCS_LFPS_RXTERM_IRQ_CLEAR, + + [QPHY_COM_RESETSM_CNTRL] = QSERDES_V3_COM_RESETSM_CNTRL, + [QPHY_COM_C_READY_STATUS] = QSERDES_V3_COM_C_READY_STATUS, + [QPHY_COM_CMN_STATUS] = QSERDES_V3_COM_CMN_STATUS, + + [QPHY_DP_PHY_STATUS] = QSERDES_V3_DP_PHY_STATUS, }; -static const unsigned int qmp_v4_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = { +static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = { [QPHY_SW_RESET ] =QPHY_V4_PCS_SW_RESET , [QPHY_START_CTRL ] =QPHY_V4_PCS_START_CONTROL , [QPHY_PCS_STATUS ] =QPHY_V4_PCS_PCS_STATUS1 ,
@@ -128,6 +141,29 @@ static const unsigned int qmp_v4_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {/* In PCS_USB */ [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V4_PCS_USB3_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V4_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR, + + [QPHY_COM_RESETSM_CNTRL] = QSERDES_V4_COM_RESETSM_CNTRL, + [QPHY_COM_C_READY_STATUS] = QSERDES_V4_COM_C_READY_STATUS, + [QPHY_COM_CMN_STATUS] = QSERDES_V4_COM_CMN_STATUS, + + [QPHY_DP_PHY_STATUS] = QSERDES_V4_DP_PHY_STATUS, +}; + +static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = { + [QPHY_SW_RESET ] =QPHY_V5_PCS_SW_RESET , + [QPHY_START_CTRL ] =QPHY_V5_PCS_START_CONTROL , + [QPHY_PCS_STATUS ] =QPHY_V5_PCS_PCS_STATUS1 , + [QPHY_PCS_POWER_DOWN_CONTROL ] =QPHY_V5_PCS_POWER_DOWN_CONTROL , + +/* In PCS_USB */ + [QPHY_PCS_AUTONOMOUS_MODE_CTRL ] =QPHY_V5_PCS_USB3_AUTONOMOUS_MODE_CTRL , + [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR ] =QPHY_V5_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR , + + [QPHY_COM_RESETSM_CNTRL ] =QSERDES_V6_COM_RESETSM_CNTRL , + [QPHY_COM_C_READY_STATUS ] =QSERDES_V6_COM_C_READY_STATUS , + [QPHY_COM_CMN_STATUS ] =QSERDES_V6_COM_CMN_STATUS , + + [QPHY_DP_PHY_STATUS ] =QSERDES_V6_DP_PHY_STATUS , };static const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = {
@@ -1564,7 +1600,7 @@ static const struct qmp_phy_cfg sc8180x_usb3dpphy_cfg = { .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), - .regs = qmp_v4_usb3phy_regs_layout, + .regs = qmp_v45_usb3phy_regs_layout, .pcs_usb_offset = 0x300, .has_pwrdn_delay = true,
@@ -1612,7 +1648,7 @@ static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = { .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), - .regs = qmp_v4_usb3phy_regs_layout, + .regs = qmp_v45_usb3phy_regs_layout, };static const struct qmp_phy_cfg sm6350_usb3dpphy_cfg = {
@@ -1702,7 +1738,7 @@ static const struct qmp_phy_cfg sm8250_usb3dpphy_cfg = { .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), - .regs = qmp_v4_usb3phy_regs_layout, + .regs = qmp_v45_usb3phy_regs_layout, .pcs_usb_offset = 0x300, .has_pwrdn_delay = true,
@@ -1752,7 +1788,7 @@ static const struct qmp_phy_cfg sm8350_usb3dpphy_cfg = { .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), - .regs = qmp_v4_usb3phy_regs_layout, + .regs = qmp_v45_usb3phy_regs_layout, .has_pwrdn_delay = true, };
@@ -1795,7 +1831,7 @@ static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = { .configure_dp_phy = qmp_v6_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, - .regs = qmp_v4_usb3phy_regs_layout, + .regs = qmp_v6_usb3phy_regs_layout, .clk_list = qmp_v4_phy_clk_l, .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), .reset_list = msm8996_usb3phy_reset_l,
@@ -1994,6 +2030,7 @@ static bool qmp_combo_configure_dp_mode(struct qmp_combo *qmp)static int qmp_v3_configure_dp_phy (struct qmp_combo *qmp) {const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; +const struct qmp_phy_cfg *cfg = qmp->cfg;u32 phy_vco_div, status;unsigned long pixel_freq;
@@ -2034,9 +2071,9 @@ static int qmp_v3_configure_dp_phy(struct qmp_combo *qmp)writel (0x01 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );writel (0x09 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); -writel (0x20 , qmp->dp_serdes +QSERDES_V3_COM_RESETSM_CNTRL ); +writel (0x20 , qmp->dp_serdes + cfg->regs[QPHY_COM_RESETSM_CNTRL ]); - if (readl_poll_timeout(qmp->dp_serdes + QSERDES_V3_COM_C_READY_STATUS, + if (readl_poll_timeout(qmp->dp_serdes + cfg->regs[QPHY_COM_C_READY_STATUS], status, ((status & BIT(0)) > 0), 500,
@@ -2045,7 +2082,7 @@ static int qmp_v3_configure_dp_phy(struct qmp_combo *qmp)writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); - if (readl_poll_timeout(qmp->dp_dp_phy + QSERDES_V3_DP_PHY_STATUS, + if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS], status, ((status & BIT(1)) > 0), 500,
@@ -2056,7 +2093,7 @@ static int qmp_v3_configure_dp_phy(struct qmp_combo *qmp)udelay (2000 );writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); - return readl_poll_timeout(qmp->dp_dp_phy + QSERDES_V3_DP_PHY_STATUS, + return readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS], status, ((status & BIT(1)) > 0), 500,
@@ -2148,13 +2185,10 @@ static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp) QSERDES_V4_TX_TX_EMP_POST1_LVL); } -static int qmp_v456_configure_dp_phy (struct qmp_combo *qmp, -unsigned int com_resetm_ctrl_reg, -unsigned int com_c_ready_status_reg, -unsigned int com_cmn_status_reg, -unsigned int dp_phy_status_reg) +static int qmp_v456_configure_dp_phy (struct qmp_combo *qmp) {const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; +const struct qmp_phy_cfg *cfg = qmp->cfg;u32 phy_vco_div, status;unsigned long pixel_freq;
@@ -2199,23 +2233,23 @@ static int qmp_v456_configure_dp_phy(struct qmp_combo *qmp,writel (0x01 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );writel (0x09 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); -writel (0x20 , qmp->dp_serdes + com_resetm_ctrl_reg); +writel (0x20 , qmp->dp_serdes + cfg->regs[QPHY_COM_RESETSM_CNTRL ]); -if (readl_poll_timeout (qmp->dp_serdes + com_c_ready_status_reg, +if (readl_poll_timeout (qmp->dp_serdes + cfg->regs[QPHY_COM_C_READY_STATUS ], status, ((status &BIT (0 )) >0 ),500 ,10000 ))return -ETIMEDOUT ; -if (readl_poll_timeout (qmp->dp_serdes + com_cmn_status_reg, +if (readl_poll_timeout (qmp->dp_serdes + cfg->regs[QPHY_COM_CMN_STATUS ], status, ((status &BIT (0 )) >0 ),500 ,10000 ))return -ETIMEDOUT ; - if (readl_poll_timeout(qmp->dp_serdes + com_cmn_status_reg, + if (readl_poll_timeout(qmp->dp_serdes + cfg->regs[QPHY_COM_CMN_STATUS], status, ((status & BIT(1)) > 0), 500,
@@ -2224,14 +2258,14 @@ static int qmp_v456_configure_dp_phy(struct qmp_combo *qmp,writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); -if (readl_poll_timeout (qmp->dp_dp_phy + dp_phy_status_reg, +if (readl_poll_timeout (qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS ], status, ((status &BIT (0 )) >0 ),500 ,10000 ))return -ETIMEDOUT ; - if (readl_poll_timeout(qmp->dp_dp_phy + dp_phy_status_reg, + if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS], status, ((status & BIT(1)) > 0), 500,
@@ -2243,16 +2277,14 @@ static int qmp_v456_configure_dp_phy(struct qmp_combo *qmp,static int qmp_v4_configure_dp_phy (struct qmp_combo *qmp) { +const struct qmp_phy_cfg *cfg = qmp->cfg;bool reverse = (qmp->orientation ==TYPEC_ORIENTATION_REVERSE );const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;u32 bias0_en, drvr0_en, bias1_en, drvr1_en;u32 status;int ret; - ret =qmp_v456_configure_dp_phy (qmp,QSERDES_V4_COM_RESETSM_CNTRL , -QSERDES_V4_COM_C_READY_STATUS , -QSERDES_V4_COM_CMN_STATUS , -QSERDES_V4_DP_PHY_STATUS ); + ret =qmp_v456_configure_dp_phy (qmp);if (ret <0 )return ret;
@@ -2287,7 +2319,7 @@ static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp)udelay (2000 );writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); - if (readl_poll_timeout(qmp->dp_dp_phy + QSERDES_V4_DP_PHY_STATUS, + if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS], status, ((status & BIT(1)) > 0), 500,
@@ -2308,16 +2340,14 @@ static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp)static int qmp_v5_configure_dp_phy (struct qmp_combo *qmp) { +const struct qmp_phy_cfg *cfg = qmp->cfg;bool reverse = (qmp->orientation ==TYPEC_ORIENTATION_REVERSE );const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;u32 bias0_en, drvr0_en, bias1_en, drvr1_en;u32 status;int ret; - ret =qmp_v456_configure_dp_phy (qmp,QSERDES_V4_COM_RESETSM_CNTRL , -QSERDES_V4_COM_C_READY_STATUS , -QSERDES_V4_COM_CMN_STATUS , -QSERDES_V4_DP_PHY_STATUS ); + ret =qmp_v456_configure_dp_phy (qmp);if (ret <0 )return ret;
@@ -2347,7 +2377,7 @@ static int qmp_v5_configure_dp_phy(struct qmp_combo *qmp)udelay (2000 );writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); - if (readl_poll_timeout(qmp->dp_dp_phy + QSERDES_V4_DP_PHY_STATUS, + if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS], status, ((status & BIT(1)) > 0), 500,
@@ -2368,16 +2398,14 @@ static int qmp_v5_configure_dp_phy(struct qmp_combo *qmp)static int qmp_v6_configure_dp_phy (struct qmp_combo *qmp) { +const struct qmp_phy_cfg *cfg = qmp->cfg;bool reverse = (qmp->orientation ==TYPEC_ORIENTATION_REVERSE );const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;u32 bias0_en, drvr0_en, bias1_en, drvr1_en;u32 status;int ret; - ret =qmp_v456_configure_dp_phy (qmp,QSERDES_V6_COM_RESETSM_CNTRL , -QSERDES_V6_COM_C_READY_STATUS , -QSERDES_V6_COM_CMN_STATUS , -QSERDES_V6_DP_PHY_STATUS ); + ret =qmp_v456_configure_dp_phy (qmp);if (ret <0 )return ret;
@@ -2407,7 +2435,7 @@ static int qmp_v6_configure_dp_phy(struct qmp_combo *qmp)udelay (2000 );writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); - if (readl_poll_timeout(qmp->dp_dp_phy + QSERDES_V6_DP_PHY_STATUS, + if (readl_poll_timeout(qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS], status, ((status & BIT(1)) > 0), 500,
Signature · 1 line
2.39.2
PATCH 3/7 phy: qcom: qmp-combo: reuse register layouts for even more registers
In reply to Dmitry BaryshkovInstead of passing additional registers to qmp_combo_configure_dp_swing(), reuse qphy_reg_layout and add those registers to register layout maps.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 104 ++++++++++++------ .../qualcomm/phy-qcom-qmp-qserdes-txrx-v6.h | 3 + drivers/phy/qualcomm/phy-qcom-qmp.h | 2 + 3 files changed, 76 insertions(+), 33 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +71 -33
@@ -113,6 +113,10 @@ enum qphy_reg_layout {QPHY_DP_PHY_STATUS , +QPHY_TX_TX_POL_INV , +QPHY_TX_TX_DRV_LVL , +QPHY_TX_TX_EMP_POST1_LVL , +/* Keep last to ensure regs_layout arrays are properly initialized */ QPHY_LAYOUT_SIZE };
@@ -130,6 +134,10 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_COM_CMN_STATUS] = QSERDES_V3_COM_CMN_STATUS, [QPHY_DP_PHY_STATUS] = QSERDES_V3_DP_PHY_STATUS, + + [QPHY_TX_TX_POL_INV] = QSERDES_V3_TX_TX_POL_INV, + [QPHY_TX_TX_DRV_LVL] = QSERDES_V3_TX_TX_DRV_LVL, + [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V3_TX_TX_EMP_POST1_LVL, };static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = {
@@ -147,6 +155,31 @@ static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_COM_CMN_STATUS] = QSERDES_V4_COM_CMN_STATUS, [QPHY_DP_PHY_STATUS] = QSERDES_V4_DP_PHY_STATUS, + + [QPHY_TX_TX_POL_INV] = QSERDES_V4_TX_TX_POL_INV, + [QPHY_TX_TX_DRV_LVL] = QSERDES_V4_TX_TX_DRV_LVL, + [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V4_TX_TX_EMP_POST1_LVL, +}; + +static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = { + [QPHY_SW_RESET ] =QPHY_V5_PCS_SW_RESET , + [QPHY_START_CTRL ] =QPHY_V5_PCS_START_CONTROL , + [QPHY_PCS_STATUS ] =QPHY_V5_PCS_PCS_STATUS1 , + [QPHY_PCS_POWER_DOWN_CONTROL ] =QPHY_V5_PCS_POWER_DOWN_CONTROL , + +/* In PCS_USB */ + [QPHY_PCS_AUTONOMOUS_MODE_CTRL ] =QPHY_V5_PCS_USB3_AUTONOMOUS_MODE_CTRL , + [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR ] =QPHY_V5_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR , + + [QPHY_COM_RESETSM_CNTRL ] =QSERDES_V5_COM_RESETSM_CNTRL , + [QPHY_COM_C_READY_STATUS ] =QSERDES_V5_COM_C_READY_STATUS , + [QPHY_COM_CMN_STATUS ] =QSERDES_V5_COM_CMN_STATUS , + + [QPHY_DP_PHY_STATUS ] =QSERDES_V5_DP_PHY_STATUS , + + [QPHY_TX_TX_POL_INV ] =QSERDES_V5_5NM_TX_TX_POL_INV , + [QPHY_TX_TX_DRV_LVL ] =QSERDES_V5_5NM_TX_TX_DRV_LVL , + [QPHY_TX_TX_EMP_POST1_LVL ] =QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL , };static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = {
@@ -164,6 +197,10 @@ static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_COM_CMN_STATUS] = QSERDES_V6_COM_CMN_STATUS, [QPHY_DP_PHY_STATUS] = QSERDES_V6_DP_PHY_STATUS, + + [QPHY_TX_TX_POL_INV] = QSERDES_V6_TX_TX_POL_INV, + [QPHY_TX_TX_DRV_LVL] = QSERDES_V6_TX_TX_DRV_LVL, + [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V6_TX_TX_EMP_POST1_LVL, };static const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = {
@@ -1648,7 +1685,7 @@ static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = { .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), - .regs = qmp_v45_usb3phy_regs_layout, + .regs = qmp_v5_5nm_usb3phy_regs_layout, };static const struct qmp_phy_cfg sm6350_usb3dpphy_cfg = {
@@ -1942,8 +1979,7 @@ static void qmp_v3_dp_aux_init(struct qmp_combo *qmp) qmp->dp_dp_phy + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK); } -static int qmp_combo_configure_dp_swing (struct qmp_combo *qmp, -unsigned int drv_lvl_reg,unsigned int emp_post_reg) +static int qmp_combo_configure_dp_swing (struct qmp_combo *qmp) {const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -1972,10 +2008,10 @@ static int qmp_combo_configure_dp_swing(struct qmp_combo *qmp, voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN; pre_emphasis_cfg |= DP_PHY_TXn_TX_EMP_POST1_LVL_MUX_EN; -writel (voltage_swing_cfg, qmp->dp_tx + drv_lvl_reg); -writel (pre_emphasis_cfg, qmp->dp_tx + emp_post_reg); -writel (voltage_swing_cfg, qmp->dp_tx2 + drv_lvl_reg); -writel (pre_emphasis_cfg, qmp->dp_tx2 + emp_post_reg); +writel (voltage_swing_cfg, qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); +writel (pre_emphasis_cfg, qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); +writel (voltage_swing_cfg, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); +writel (pre_emphasis_cfg, qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]);return 0 ; }
@@ -1985,8 +2021,7 @@ static void qmp_v3_configure_dp_tx(struct qmp_combo *qmp)const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;u32 bias_en, drvr_en; -if (qmp_combo_configure_dp_swing (qmp,QSERDES_V3_TX_TX_DRV_LVL , -QSERDES_V3_TX_TX_EMP_POST1_LVL ) <0 ) +if (qmp_combo_configure_dp_swing (qmp) <0 )return ;if (dp_opts->lanes ==1 ) {
@@ -2174,15 +2209,16 @@ static void qmp_v6_dp_aux_init(struct qmp_combo *qmp)static void qmp_v4_configure_dp_tx (struct qmp_combo *qmp) { +const struct qmp_phy_cfg *cfg = qmp->cfg; +/* Program default values before writing proper values */ -writel (0x27 , qmp->dp_tx +QSERDES_V4_TX_TX_DRV_LVL ); -writel (0x27 , qmp->dp_tx2 +QSERDES_V4_TX_TX_DRV_LVL ); +writel (0x27 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); +writel (0x27 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); -writel (0x20 , qmp->dp_tx +QSERDES_V4_TX_TX_EMP_POST1_LVL ); -writel (0x20 , qmp->dp_tx2 +QSERDES_V4_TX_TX_EMP_POST1_LVL ); +writel (0x20 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); +writel (0x20 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); -qmp_combo_configure_dp_swing (qmp,QSERDES_V4_TX_TX_DRV_LVL , -QSERDES_V4_TX_TX_EMP_POST1_LVL ); +qmp_combo_configure_dp_swing (qmp); }static int qmp_v456_configure_dp_phy (struct qmp_combo *qmp)
@@ -2326,14 +2362,16 @@ static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp) 10000))return -ETIMEDOUT ; -writel (0x0a , qmp->dp_tx +QSERDES_V4_TX_TX_POL_INV ); -writel (0x0a , qmp->dp_tx2 +QSERDES_V4_TX_TX_POL_INV ); +writel (0x0a , qmp->dp_tx + cfg->regs[QPHY_TX_TX_POL_INV ]); +writel (0x0a , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_POL_INV ]); -writel (0x27 , qmp->dp_tx +QSERDES_V4_TX_TX_DRV_LVL ); -writel (0x27 , qmp->dp_tx2 +QSERDES_V4_TX_TX_DRV_LVL ); +writel (0x27 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); +writel (0x27 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); -writel (0x20 , qmp->dp_tx +QSERDES_V4_TX_TX_EMP_POST1_LVL ); -writel (0x20 , qmp->dp_tx2 +QSERDES_V4_TX_TX_EMP_POST1_LVL ); +writel (0x20 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); +writel (0x20 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); + +return 0 ;return 0 ; }
@@ -2384,14 +2422,14 @@ static int qmp_v5_configure_dp_phy(struct qmp_combo *qmp) 10000))return -ETIMEDOUT ; -writel (0x0a , qmp->dp_tx +QSERDES_V5_5NM_TX_TX_POL_INV ); -writel (0x0a , qmp->dp_tx2 +QSERDES_V5_5NM_TX_TX_POL_INV ); +writel (0x0a , qmp->dp_tx + cfg->regs[QPHY_TX_TX_POL_INV ]); +writel (0x0a , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_POL_INV ]); -writel (0x27 , qmp->dp_tx +QSERDES_V5_5NM_TX_TX_DRV_LVL ); -writel (0x27 , qmp->dp_tx2 +QSERDES_V5_5NM_TX_TX_DRV_LVL ); +writel (0x27 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); +writel (0x27 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); -writel (0x20 , qmp->dp_tx +QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL ); -writel (0x20 , qmp->dp_tx2 +QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL ); +writel (0x20 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); +writel (0x20 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]);return 0 ; }
@@ -2442,14 +2480,14 @@ static int qmp_v6_configure_dp_phy(struct qmp_combo *qmp) 10000))return -ETIMEDOUT ; -writel (0x0a , qmp->dp_tx +QSERDES_V4_TX_TX_POL_INV ); -writel (0x0a , qmp->dp_tx2 +QSERDES_V4_TX_TX_POL_INV ); +writel (0x0a , qmp->dp_tx + cfg->regs[QPHY_TX_TX_POL_INV ]); +writel (0x0a , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_POL_INV ]); -writel (0x27 , qmp->dp_tx +QSERDES_V4_TX_TX_DRV_LVL ); -writel (0x27 , qmp->dp_tx2 +QSERDES_V4_TX_TX_DRV_LVL ); +writel (0x27 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); +writel (0x27 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); -writel (0x20 , qmp->dp_tx +QSERDES_V4_TX_TX_EMP_POST1_LVL ); -writel (0x20 , qmp->dp_tx2 +QSERDES_V4_TX_TX_EMP_POST1_LVL ); +writel (0x20 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); +writel (0x20 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]);return 0 ; }
drivers/phy/qualcomm/phy-qcom-qmp-qserdes-txrx-v6.h +3 -0
@@ -7,6 +7,8 @@#define QCOM_PHY_QMP_QSERDES_TXRX_USB_V6_H_ #define QSERDES_V6_TX_CLKBUF_ENABLE 0x08 +#define QSERDES_V6_TX_TX_EMP_POST1_LVL 0x0c +#define QSERDES_V6_TX_TX_DRV_LVL 0x14#define QSERDES_V6_TX_RESET_TSYNC_EN 0x1c#define QSERDES_V6_TX_PRE_STALL_LDO_BOOST_EN 0x20#define QSERDES_V6_TX_TX_BAND 0x24
@@ -15,6 +17,7 @@#define QSERDES_V6_TX_RES_CODE_LANE_RX 0x38#define QSERDES_V6_TX_RES_CODE_LANE_OFFSET_TX 0x3c#define QSERDES_V6_TX_RES_CODE_LANE_OFFSET_RX 0x40 +#define QSERDES_V6_TX_TX_POL_INV 0x5c#define QSERDES_V6_TX_PARRATE_REC_DETECT_IDLE_EN 0x60#define QSERDES_V6_TX_BIST_PATTERN7 0x7c#define QSERDES_V6_TX_LANE_MODE_1 0x84
drivers/phy/qualcomm/phy-qcom-qmp.h +2 -0
@@ -134,6 +134,8 @@#define QPHY_V4_PCS_MISC_TYPEC_STATUS 0x10#define QPHY_V4_PCS_MISC_PLACEHOLDER_STATUS 0x14 +#define QSERDES_V5_DP_PHY_STATUS 0x0dc +/* Only for QMP V6 PHY - DP PHY registers */ #define QSERDES_V6_DP_PHY_AUX_INTERRUPT_STATUS 0x0e0#define QSERDES_V6_DP_PHY_STATUS 0x0e4
Signature · 1 line
2.39.2
PATCH 4/7 phy: qcom: qmp-combo: reuse register layouts for some more registers
In reply to Dmitry BaryshkovUse register layout for TX_HIGHZ_DRVR_EN and TX_TRANSCEIVER_BIAS_EN registers. This will allow us to unify qmp_v[456]_configure_dp_phy() functions in the next commit.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 34 ++++++++++++------- .../qualcomm/phy-qcom-qmp-qserdes-txrx-v6.h | 2 ++ 2 files changed, 24 insertions(+), 12 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +22 -12
@@ -116,6 +116,8 @@ enum qphy_reg_layout {QPHY_TX_TX_POL_INV ,QPHY_TX_TX_DRV_LVL ,QPHY_TX_TX_EMP_POST1_LVL , +QPHY_TX_HIGHZ_DRVR_EN , +QPHY_TX_TRANSCEIVER_BIAS_EN ,/* Keep last to ensure regs_layout arrays are properly initialized */ QPHY_LAYOUT_SIZE
@@ -138,6 +140,8 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_TX_TX_POL_INV] = QSERDES_V3_TX_TX_POL_INV, [QPHY_TX_TX_DRV_LVL] = QSERDES_V3_TX_TX_DRV_LVL, [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V3_TX_TX_EMP_POST1_LVL, + [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V3_TX_HIGHZ_DRVR_EN, + [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V3_TX_TRANSCEIVER_BIAS_EN, };static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = {
@@ -159,6 +163,8 @@ static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_TX_TX_POL_INV] = QSERDES_V4_TX_TX_POL_INV, [QPHY_TX_TX_DRV_LVL] = QSERDES_V4_TX_TX_DRV_LVL, [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V4_TX_TX_EMP_POST1_LVL, + [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V4_TX_HIGHZ_DRVR_EN, + [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V4_TX_TRANSCEIVER_BIAS_EN, };static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = {
@@ -180,6 +186,8 @@ static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_TX_TX_POL_INV] = QSERDES_V5_5NM_TX_TX_POL_INV, [QPHY_TX_TX_DRV_LVL] = QSERDES_V5_5NM_TX_TX_DRV_LVL, [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL, + [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V5_5NM_TX_HIGHZ_DRVR_EN, + [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN, };static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = {
@@ -201,6 +209,8 @@ static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_TX_TX_POL_INV] = QSERDES_V6_TX_TX_POL_INV, [QPHY_TX_TX_DRV_LVL] = QSERDES_V6_TX_TX_DRV_LVL, [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V6_TX_TX_EMP_POST1_LVL, + [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V6_TX_HIGHZ_DRVR_EN, + [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V6_TX_TRANSCEIVER_BIAS_EN, };static const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = {
@@ -2346,10 +2356,10 @@ static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp) drvr1_en =0x10 ; } -writel (drvr0_en, qmp->dp_tx +QSERDES_V4_TX_HIGHZ_DRVR_EN ); -writel (bias0_en, qmp->dp_tx +QSERDES_V4_TX_TRANSCEIVER_BIAS_EN ); -writel (drvr1_en, qmp->dp_tx2 +QSERDES_V4_TX_HIGHZ_DRVR_EN ); -writel (bias1_en, qmp->dp_tx2 +QSERDES_V4_TX_TRANSCEIVER_BIAS_EN ); +writel (drvr0_en, qmp->dp_tx + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias0_en, qmp->dp_tx + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); +writel (drvr1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]);writel (0x18 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );udelay (2000 );
@@ -2406,10 +2416,10 @@ static int qmp_v5_configure_dp_phy(struct qmp_combo *qmp) drvr1_en =0x10 ; } -writel (drvr0_en, qmp->dp_tx +QSERDES_V5_5NM_TX_HIGHZ_DRVR_EN ); -writel (bias0_en, qmp->dp_tx +QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN ); -writel (drvr1_en, qmp->dp_tx2 +QSERDES_V5_5NM_TX_HIGHZ_DRVR_EN ); -writel (bias1_en, qmp->dp_tx2 +QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN ); +writel (drvr0_en, qmp->dp_tx + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias0_en, qmp->dp_tx + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); +writel (drvr1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]);writel (0x18 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );udelay (2000 );
@@ -2464,10 +2474,10 @@ static int qmp_v6_configure_dp_phy(struct qmp_combo *qmp) drvr1_en =0x10 ; } -writel (drvr0_en, qmp->dp_tx +QSERDES_V4_TX_HIGHZ_DRVR_EN ); -writel (bias0_en, qmp->dp_tx +QSERDES_V4_TX_TRANSCEIVER_BIAS_EN ); -writel (drvr1_en, qmp->dp_tx2 +QSERDES_V4_TX_HIGHZ_DRVR_EN ); -writel (bias1_en, qmp->dp_tx2 +QSERDES_V4_TX_TRANSCEIVER_BIAS_EN ); +writel (drvr0_en, qmp->dp_tx + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias0_en, qmp->dp_tx + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); +writel (drvr1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]);writel (0x18 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );udelay (2000 );
drivers/phy/qualcomm/phy-qcom-qmp-qserdes-txrx-v6.h +2 -0
@@ -17,6 +17,8 @@#define QSERDES_V6_TX_RES_CODE_LANE_RX 0x38#define QSERDES_V6_TX_RES_CODE_LANE_OFFSET_TX 0x3c#define QSERDES_V6_TX_RES_CODE_LANE_OFFSET_RX 0x40 +#define QSERDES_V6_TX_TRANSCEIVER_BIAS_EN 0x54 +#define QSERDES_V6_TX_HIGHZ_DRVR_EN 0x58#define QSERDES_V6_TX_TX_POL_INV 0x5c#define QSERDES_V6_TX_PARRATE_REC_DETECT_IDLE_EN 0x60#define QSERDES_V6_TX_BIST_PATTERN7 0x7c
Signature · 1 line
2.39.2
PATCH 5/7 phy: qcom: qmp-combo: drop similar functions
In reply to Dmitry BaryshkovThe functions qmp_v5_configure_dp_phy() and qmp_v6_configure_dp_phy() are now copies of qmp_v4_configure_dp_phy(). Drop them and use the v4 function in all the cases.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 123 +--------------------- 1 file changed, 2 insertions(+), 121 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +2 -121
@@ -1433,10 +1433,7 @@ static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp);static int qmp_v4_configure_dp_phy (struct qmp_combo *qmp);static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp); -static int qmp_v5_configure_dp_phy (struct qmp_combo *qmp); -static void qmp_v6_dp_aux_init (struct qmp_combo *qmp); -static int qmp_v6_configure_dp_phy (struct qmp_combo *qmp);static inline void qphy_setbits (void __iomem *base,u32 offset,u32 val) {
@@ -1686,7 +1683,7 @@ static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, - .configure_dp_phy = qmp_v5_configure_dp_phy, + .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .clk_list = qmp_v4_phy_clk_l,
@@ -1875,7 +1872,7 @@ static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = { .dp_aux_init = qmp_v6_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, - .configure_dp_phy = qmp_v6_configure_dp_phy, + .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout,
@@ -2386,122 +2383,6 @@ static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp)return 0 ; } -static int qmp_v5_configure_dp_phy (struct qmp_combo *qmp) -{ -const struct qmp_phy_cfg *cfg = qmp->cfg; -bool reverse = (qmp->orientation ==TYPEC_ORIENTATION_REVERSE ); -const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; -u32 bias0_en, drvr0_en, bias1_en, drvr1_en; -u32 status; -int ret; - - ret =qmp_v456_configure_dp_phy (qmp); -if (ret <0 ) -return ret; - -if (dp_opts->lanes ==1 ) { - bias0_en = reverse ?0x3e :0x15 ; - drvr0_en = reverse ?0x13 :0x10 ; - bias1_en = reverse ?0x15 :0x3e ; - drvr1_en = reverse ?0x10 :0x13 ; - }else if (dp_opts->lanes ==2 ) { - bias0_en = reverse ?0x3f :0x15 ; - drvr0_en =0x10 ; - bias1_en = reverse ?0x15 :0x3f ; - drvr1_en =0x10 ; - }else { - bias0_en =0x3f ; - bias1_en =0x3f ; - drvr0_en =0x10 ; - drvr1_en =0x10 ; - } - -writel (drvr0_en, qmp->dp_tx + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); -writel (bias0_en, qmp->dp_tx + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); -writel (drvr1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); -writel (bias1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); - -writel (0x18 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); -udelay (2000 ); -writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); - -if (readl_poll_timeout (qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS ], - status, - ((status &BIT (1 )) >0 ), -500 , -10000 )) -return -ETIMEDOUT ; - -writel (0x0a , qmp->dp_tx + cfg->regs[QPHY_TX_TX_POL_INV ]); -writel (0x0a , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_POL_INV ]); - -writel (0x27 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); -writel (0x27 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); - -writel (0x20 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); -writel (0x20 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); - -return 0 ; -} - -static int qmp_v6_configure_dp_phy (struct qmp_combo *qmp) -{ -const struct qmp_phy_cfg *cfg = qmp->cfg; -bool reverse = (qmp->orientation ==TYPEC_ORIENTATION_REVERSE ); -const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; -u32 bias0_en, drvr0_en, bias1_en, drvr1_en; -u32 status; -int ret; - - ret =qmp_v456_configure_dp_phy (qmp); -if (ret <0 ) -return ret; - -if (dp_opts->lanes ==1 ) { - bias0_en = reverse ?0x3e :0x15 ; - drvr0_en = reverse ?0x13 :0x10 ; - bias1_en = reverse ?0x15 :0x3e ; - drvr1_en = reverse ?0x10 :0x13 ; - }else if (dp_opts->lanes ==2 ) { - bias0_en = reverse ?0x3f :0x15 ; - drvr0_en =0x10 ; - bias1_en = reverse ?0x15 :0x3f ; - drvr1_en =0x10 ; - }else { - bias0_en =0x3f ; - bias1_en =0x3f ; - drvr0_en =0x10 ; - drvr1_en =0x10 ; - } - -writel (drvr0_en, qmp->dp_tx + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); -writel (bias0_en, qmp->dp_tx + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); -writel (drvr1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); -writel (bias1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); - -writel (0x18 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); -udelay (2000 ); -writel (0x19 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); - -if (readl_poll_timeout (qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS ], - status, - ((status &BIT (1 )) >0 ), -500 , -10000 )) -return -ETIMEDOUT ; - -writel (0x0a , qmp->dp_tx + cfg->regs[QPHY_TX_TX_POL_INV ]); -writel (0x0a , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_POL_INV ]); - -writel (0x27 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); -writel (0x27 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); - -writel (0x20 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); -writel (0x20 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); - -return 0 ; -} -/* * We need to calibrate the aux setting here as many times * as the caller tries
Signature · 1 line
2.39.2
PATCH 6/7 phy: qcom: qmp-combo: drop qmp_v6_dp_aux_init()
In reply to Dmitry BaryshkovThe only difference between qmp_v6_dp_aux_init() and qmp_v4_dp_aux_init() is the address of COM_BIAS_EN_CLKBUFLR_EN register. Move it to register layout and drop the duplicate function.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 44 +++++++---------------- 1 file changed, 12 insertions(+), 32 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +12 -32
@@ -110,6 +110,7 @@ enum qphy_reg_layout {QPHY_COM_RESETSM_CNTRL ,QPHY_COM_C_READY_STATUS ,QPHY_COM_CMN_STATUS , +QPHY_COM_BIAS_EN_CLKBUFLR_EN , QPHY_DP_PHY_STATUS,
@@ -134,6 +135,7 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_COM_RESETSM_CNTRL] = QSERDES_V3_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V3_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V3_COM_CMN_STATUS, + [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, [QPHY_DP_PHY_STATUS] = QSERDES_V3_DP_PHY_STATUS,
@@ -157,6 +159,7 @@ static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_COM_RESETSM_CNTRL] = QSERDES_V4_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V4_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V4_COM_CMN_STATUS, + [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, [QPHY_DP_PHY_STATUS] = QSERDES_V4_DP_PHY_STATUS,
@@ -180,6 +183,7 @@ static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_COM_RESETSM_CNTRL] = QSERDES_V5_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V5_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V5_COM_CMN_STATUS, + [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN, [QPHY_DP_PHY_STATUS] = QSERDES_V5_DP_PHY_STATUS,
@@ -203,6 +207,7 @@ static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_COM_RESETSM_CNTRL] = QSERDES_V6_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V6_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V6_COM_CMN_STATUS, + [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN, [QPHY_DP_PHY_STATUS] = QSERDES_V6_DP_PHY_STATUS,
@@ -1433,8 +1438,6 @@ static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp);static int qmp_v4_configure_dp_phy (struct qmp_combo *qmp);static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp); -static void qmp_v6_dp_aux_init (struct qmp_combo *qmp); -static inline void qphy_setbits (void __iomem *base,u32 offset,u32 val) {u32 reg;
@@ -1870,7 +1873,7 @@ static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = { .swing_hbr3_hbr2 = &qmp_dp_v5_voltage_swing_hbr3_hbr2, .pre_emphasis_hbr3_hbr2 = &qmp_dp_v5_pre_emphasis_hbr3_hbr2, - .dp_aux_init = qmp_v6_dp_aux_init, + .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -1945,6 +1948,8 @@ static int qmp_combo_dp_serdes_init(struct qmp_combo *qmp)static void qmp_v3_dp_aux_init (struct qmp_combo *qmp) { +const struct qmp_phy_cfg *cfg = qmp->cfg; +writel (DP_PHY_PD_CTL_PWRDN |DP_PHY_PD_CTL_AUX_PWRDN |DP_PHY_PD_CTL_PLL_PWRDN |DP_PHY_PD_CTL_DP_CLAMP_EN , qmp->dp_dp_phy +QSERDES_DP_PHY_PD_CTL );
@@ -1952,7 +1957,7 @@ static void qmp_v3_dp_aux_init(struct qmp_combo *qmp)/* Turn on BIAS current for PHY/PLL */ writel (QSERDES_V3_COM_BIAS_EN |QSERDES_V3_COM_BIAS_EN_MUX |QSERDES_V3_COM_CLKBUF_L_EN |QSERDES_V3_COM_EN_SYSCLK_TX_SEL , - qmp->dp_serdes +QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN ); + qmp->dp_serdes + cfg->regs[QPHY_COM_BIAS_EN_CLKBUFLR_EN ]);writel (DP_PHY_PD_CTL_PSR_PWRDN , qmp->dp_dp_phy +QSERDES_DP_PHY_PD_CTL );
@@ -1966,7 +1971,7 @@ static void qmp_v3_dp_aux_init(struct qmp_combo *qmp)QSERDES_V3_COM_BIAS_EN_MUX |QSERDES_V3_COM_CLKBUF_R_EN |QSERDES_V3_COM_CLKBUF_L_EN |QSERDES_V3_COM_EN_SYSCLK_TX_SEL |QSERDES_V3_COM_CLKBUF_RX_DRIVE_L , - qmp->dp_serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN); + qmp->dp_serdes + cfg->regs[QPHY_COM_BIAS_EN_CLKBUFLR_EN]);writel (0x00 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG0 );writel (0x13 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG1 );
@@ -2162,39 +2167,14 @@ static int qmp_v3_calibrate_dp_phy(struct qmp_combo *qmp)static void qmp_v4_dp_aux_init (struct qmp_combo *qmp) { -writel (DP_PHY_PD_CTL_PWRDN |DP_PHY_PD_CTL_PSR_PWRDN |DP_PHY_PD_CTL_AUX_PWRDN | -DP_PHY_PD_CTL_PLL_PWRDN |DP_PHY_PD_CTL_DP_CLAMP_EN , - qmp->dp_dp_phy +QSERDES_DP_PHY_PD_CTL ); - -/* Turn on BIAS current for PHY/PLL */ -writel (0x17 , qmp->dp_serdes +QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN ); - -writel (0x00 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG0 ); -writel (0x13 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG1 ); -writel (0xa4 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG2 ); -writel (0x00 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG3 ); -writel (0x0a , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG4 ); -writel (0x26 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG5 ); -writel (0x0a , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG6 ); -writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 ); -writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 ); -writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); - qmp->dp_aux_cfg =0 ; - -writel (PHY_AUX_STOP_ERR_MASK |PHY_AUX_DEC_ERR_MASK | -PHY_AUX_SYNC_ERR_MASK |PHY_AUX_ALIGN_ERR_MASK | -PHY_AUX_REQ_ERR_MASK , - qmp->dp_dp_phy +QSERDES_V4_DP_PHY_AUX_INTERRUPT_MASK ); -} +const struct qmp_phy_cfg *cfg = qmp->cfg; -static void qmp_v6_dp_aux_init (struct qmp_combo *qmp) -{writel (DP_PHY_PD_CTL_PWRDN |DP_PHY_PD_CTL_PSR_PWRDN |DP_PHY_PD_CTL_AUX_PWRDN |DP_PHY_PD_CTL_PLL_PWRDN |DP_PHY_PD_CTL_DP_CLAMP_EN , qmp->dp_dp_phy +QSERDES_DP_PHY_PD_CTL );/* Turn on BIAS current for PHY/PLL */ -writel (0x17 , qmp->dp_serdes +QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN ); +writel (0x17 , qmp->dp_serdes + cfg->regs[QPHY_COM_BIAS_EN_CLKBUFLR_EN ]);writel (0x00 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG0 );writel (0x13 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG1 );
Signature · 1 line
2.39.2
PATCH 7/7 phy: qcom: qmp-combo: extract common function to setup clocks
In reply to Dmitry BaryshkovExtact qmp_combo_configure_dp_clocks(), a common function to setup PHY clocks depending on the selected link rate.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 63 ++++++++++------------- 1 file changed, 26 insertions(+), 37 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +26 -37
@@ -2074,18 +2074,12 @@ static bool qmp_combo_configure_dp_mode(struct qmp_combo *qmp)return reverse; } -static int qmp_v3_configure_dp_phy (struct qmp_combo *qmp) +static int qmp_combo_configure_dp_clocks (struct qmp_combo *qmp) {const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; -const struct qmp_phy_cfg *cfg = qmp->cfg; -u32 phy_vco_div, status; +u32 phy_vco_div;unsigned long pixel_freq; -qmp_combo_configure_dp_mode (qmp); - -writel (0x05 , qmp->dp_dp_phy +QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL ); -writel (0x05 , qmp->dp_dp_phy +QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL ); -switch (dp_opts->link_rate) {case 1620 : phy_vco_div =0x1 ;
@@ -2107,11 +2101,29 @@ static int qmp_v3_configure_dp_phy(struct qmp_combo *qmp)/* Other link rates aren't supported */ return -EINVAL ; } -writel (phy_vco_div, qmp->dp_dp_phy +QSERDES_V3_DP_PHY_VCO_DIV ); +writel (phy_vco_div, qmp->dp_dp_phy +QSERDES_V4_DP_PHY_VCO_DIV );clk_set_rate (qmp->dp_link_hw.clk, dp_opts->link_rate *100000 );clk_set_rate (qmp->dp_pixel_hw.clk, pixel_freq); +return 0 ; +} + +static int qmp_v3_configure_dp_phy (struct qmp_combo *qmp) +{ +const struct qmp_phy_cfg *cfg = qmp->cfg; +u32 status; +int ret; + +qmp_combo_configure_dp_mode (qmp); + +writel (0x05 , qmp->dp_dp_phy +QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL ); +writel (0x05 , qmp->dp_dp_phy +QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL ); + + ret =qmp_combo_configure_dp_clocks (qmp); +if (ret) +return ret; +writel (0x04 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG2 );writel (0x01 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );writel (0x05 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );
@@ -2210,10 +2222,9 @@ static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp)static int qmp_v456_configure_dp_phy (struct qmp_combo *qmp) { -const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;const struct qmp_phy_cfg *cfg = qmp->cfg; -u32 phy_vco_div, status; -unsigned long pixel_freq; +u32 status; +int ret;writel (0x0f , qmp->dp_dp_phy +QSERDES_V4_DP_PHY_CFG_1 );
@@ -2225,31 +2236,9 @@ static int qmp_v456_configure_dp_phy(struct qmp_combo *qmp)writel (0x05 , qmp->dp_dp_phy +QSERDES_V4_DP_PHY_TX0_TX1_LANE_CTL );writel (0x05 , qmp->dp_dp_phy +QSERDES_V4_DP_PHY_TX2_TX3_LANE_CTL ); -switch (dp_opts->link_rate) { -case 1620 : - phy_vco_div =0x1 ; - pixel_freq =1620000000UL /2 ; -break ; -case 2700 : - phy_vco_div =0x1 ; - pixel_freq =2700000000UL /2 ; -break ; -case 5400 : - phy_vco_div =0x2 ; - pixel_freq =5400000000UL /4 ; -break ; -case 8100 : - phy_vco_div =0x0 ; - pixel_freq =8100000000UL /6 ; -break ; -default : -/* Other link rates aren't supported */ -return -EINVAL ; - } -writel (phy_vco_div, qmp->dp_dp_phy +QSERDES_V4_DP_PHY_VCO_DIV ); - -clk_set_rate (qmp->dp_link_hw.clk, dp_opts->link_rate *100000 ); -clk_set_rate (qmp->dp_pixel_hw.clk, pixel_freq); + ret =qmp_combo_configure_dp_clocks (qmp); +if (ret) +return ret;writel (0x01 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );writel (0x05 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG );
Signature · 1 line
2.39.2