phy: qcom: Updates for USB PHYs on SDM845
v2 cover phy: qcom: Updates for USB PHYs on SDM845
SDM845 has two USB instances each with QUSB2 and QMP PHYs. One of the QMP PHY is USB-DP (DisplayPort) combo PHY where as other one is single lane UNI-PHY (without DP support). Changes are related to PHY configuration for electrical parameters tuning to improve eye-diagram and some fixes.
Changes since v1:
- Updated qusb2 compatibility name as per comment from Vivek.
Manu Gautam (6):
phy: qcom-qmp: Enable pipe_clk before checking USB3 PHY_STATUS
phy: qcom-qusb2: Fix crash if nvmem cell not specified
dt-bindings: phy-qcom-qmp: Update bindings for sdm845
phy: qcom-qmp: Add QMP V3 USB3 UNI PHY support for sdm845
dt-bindings: phy-qcom-usb2: Update bindings for sdm845
phy: qcom-qusb2: Add QUSB2 PHYs support for sdm845
.../devicetree/bindings/phy/qcom-qmp-phy.txt | 4 +- .../devicetree/bindings/phy/qcom-qusb2-phy.txt | 4 +- drivers/phy/qualcomm/phy-qcom-qmp.c | 166 +++++++++++++++++++++ drivers/phy/qualcomm/phy-qcom-qmp.h | 5 + drivers/phy/qualcomm/phy-qcom-qusb2.c | 43 ++++++ 5 files changed, 220 insertions(+), 2 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/6 phy: qcom-qmp: Enable pipe_clk before checking USB3 PHY_STATUS
QMP PHY for USB mode requires pipe_clk for calibration and PLL lock to take place. This lock is output from PHY to GCC clock_ctl and then fed back to QMP PHY and is output from PHY only after PHY is reset and initialized, hence it can't be enabled too early in initialization sequence.
--- drivers/phy/qualcomm/phy-qcom-qmp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp.c +18 -0
@@ -797,8 +797,13 @@ static int qcom_qmp_phy_poweron(struct phy *phy) {struct qmp_phy *qphy =phy_get_drvdata (phy);struct qcom_qmp *qmp = qphy->qmp; +const struct qmp_phy_cfg *cfg = qmp->cfg;int ret; +/* Not needed for USB3 PHY as pipe_clk is enabled from phy_init */ +if (cfg->type ==PHY_TYPE_USB3 ) +return 0 ; + ret =clk_prepare_enable (qphy->pipe_clk);if (ret)dev_err (qmp->dev,"pipe_clk enable failed, err=%d\n" , ret);
@@ -1008,6 +1013,19 @@ static int qcom_qmp_phy_init(struct phy *phy) status = pcs + cfg->regs[QPHY_PCS_READY_STATUS ]; mask = cfg->mask_pcs_ready; +/* USB3 PHY requires pipe_clk for PLL lock and calibration */ +if (cfg->type ==PHY_TYPE_USB3 ) { + ret =clk_prepare_enable (qphy->pipe_clk); +if (ret) +dev_err (qmp->dev,"pipe_clk enable err=%d\n" , ret); +/* +* Ignore this error as pipe_clk might take some time to get +* enabled. In any case following check for PHY PLL lock would +* timeout below if there is a fatal error and clock is not fed +* to PHY +*/ + } + ret =readl_poll_timeout (status, val, !(val & mask),1 ,PHY_INIT_COMPLETE_TIMEOUT );if (ret) {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 2/6 phy: qcom-qusb2: Fix crash if nvmem cell not specified
In reply to Manu GautamDriver currently crashes due to NULL pointer deference while updating PHY tune register if nvmem cell is NULL. Since, fused value for Tune1/2 register is optional, we'd rather bail out.
--- drivers/phy/qualcomm/phy-qcom-qusb2.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/phy/qualcomm/phy-qcom-qusb2.c +4 -0
@@ -315,6 +315,10 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy)const struct qusb2_phy_cfg *cfg = qphy->cfg;u8 *val; +/* efuse register is optional */ +if (!qphy->cell) +return ; +/* * Read efuse register having TUNE2/1 parameter's high nibble. * If efuse register shows value as 0x0, or if we fail to find
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 3/6 dt-bindings: phy-qcom-qmp: Update bindings for sdm845
In reply to Manu GautamUpdate compatible strings for USB3 PHYs on SDM845. One is QMPv3 DisplayPort-USB combo PHY and other one is USB UNI PHY which is single lane USB3 PHY without DP capability.
--- Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt +3 -1
@@ -9,7 +9,9 @@ Required properties: "qcom,ipq8074-qmp-pcie-phy" for PCIe phy on IPQ8074 "qcom,msm8996-qmp-pcie-phy" for 14nm PCIe phy on msm8996, "qcom,msm8996-qmp-usb3-phy" for 14nm USB3 phy on msm8996, - "qcom,qmp-v3-usb3-phy" for USB3 QMP V3 phy. + "qcom,qmp-v3-usb3-phy" for USB3 QMP V3 phy, + "qcom,sdm845-qmp-usb3-phy" for USB3 QMP V3 phy on sdm845, + "qcom,sdm845-qmp-usb3-uni-phy" for USB3 QMP V3 UNI phy on sdm845. - reg: offset and length of register set for PHY's common serdes block.
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 4/6 phy: qcom-qmp: Add QMP V3 USB3 UNI PHY support for sdm845
In reply to Manu GautamQMP V3 UNI PHY is a single lane USB3 PHY without support for DisplayPort (DP).
Main difference from DP combo QMPv3 PHY is that UNI PHY doesn't have dual RX/TX lanes and no separate DP_COM block for configuration related to type-c or DP. While at it, fix has_pwrdn_delay attribute for USB-DP PHY configuration.
--- drivers/phy/qualcomm/phy-qcom-qmp.c | 148 ++++++++++++++++++++++++++++++++++++ drivers/phy/qualcomm/phy-qcom-qmp.h | 5 ++ 2 files changed, 153 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp.c +148 -0
@@ -490,6 +490,118 @@ enum qphy_reg_layout { QMP_PHY_INIT_CFG(QPHY_V3_PCS_RXEQTRAINING_RUN_TIME, 0x13), }; +static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V3_COM_PLL_IVCO ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SYSCLK_EN_SEL ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_CLK_SELECT ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SYS_CLK_CTRL ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_RESETSM_CNTRL2 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_CMN_CONFIG ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SVS_MODE_CLK_SEL ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_HSCLK_SEL ,0x80 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_DEC_START_MODE0 ,0x82 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_DIV_FRAC_START1_MODE0 ,0xab ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_DIV_FRAC_START2_MODE0 ,0xea ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_DIV_FRAC_START3_MODE0 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_CP_CTRL_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_PLL_RCTRL_MODE0 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_PLL_CCTRL_MODE0 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_VCO_TUNE2_MODE0 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_VCO_TUNE1_MODE0 ,0xc9 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_CORECLK_DIV_MODE0 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_LOCK_CMP3_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_LOCK_CMP2_MODE0 ,0x34 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_LOCK_CMP1_MODE0 ,0x15 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_LOCK_CMP_EN ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_CORE_CLK_EN ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_LOCK_CMP_CFG ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_VCO_TUNE_MAP ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SYSCLK_BUF_ENABLE ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SSC_EN_CENTER ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SSC_PER1 ,0x31 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SSC_PER2 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SSC_ADJ_PER1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SSC_ADJ_PER2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SSC_STEP_SIZE1 ,0x85 ), +QMP_PHY_INIT_CFG (QSERDES_V3_COM_SSC_STEP_SIZE2 ,0x07 ), +}; + +static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_tx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V3_TX_HIGHZ_DRVR_EN ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V3_TX_RCV_DETECT_LVL_2 ,0x12 ), +QMP_PHY_INIT_CFG (QSERDES_V3_TX_LANE_MODE_1 ,0xc6 ), +QMP_PHY_INIT_CFG (QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX ,0x06 ), +}; + +static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_rx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V3_RX_VGA_CAL_CNTRL2 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_RX_MODE_00 ,0x50 ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN ,0x0b ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2 ,0x0e ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3 ,0x4e ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4 ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 ,0x77 ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2 ,0x80 ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_SIGDET_CNTRL ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL ,0x1c ), +QMP_PHY_INIT_CFG (QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE ,0x75 ), +}; + +static const struct qmp_phy_init_tbl qmp_v3_usb3_uniphy_pcs_tbl[] = { +/* FLL settings */ +QMP_PHY_INIT_CFG (QPHY_V3_PCS_FLL_CNTRL2 ,0x83 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_FLL_CNT_VAL_L ,0x09 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_FLL_CNT_VAL_H_TOL ,0xa2 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_FLL_MAN_CODE ,0x40 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_FLL_CNTRL1 ,0x02 ), + +/* Lock Det settings */ +QMP_PHY_INIT_CFG (QPHY_V3_PCS_LOCK_DETECT_CONFIG1 ,0xd1 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_LOCK_DETECT_CONFIG2 ,0x1f ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_LOCK_DETECT_CONFIG3 ,0x47 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_POWER_STATE_CONFIG2 ,0x1b ), + +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RX_SIGDET_LVL ,0xba ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXMGN_V0 ,0x9f ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXMGN_V1 ,0x9f ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXMGN_V2 ,0xb5 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXMGN_V3 ,0x4c ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXMGN_V4 ,0x64 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXMGN_LS ,0x6a ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M6DB_V0 ,0x15 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0 ,0x0d ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M6DB_V1 ,0x15 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M3P5DB_V1 ,0x0d ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M6DB_V2 ,0x15 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M3P5DB_V2 ,0x0d ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M6DB_V3 ,0x15 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M3P5DB_V3 ,0x1d ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M6DB_V4 ,0x15 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M3P5DB_V4 ,0x0d ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M6DB_LS ,0x15 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TXDEEMPH_M3P5DB_LS ,0x0d ), + +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RATE_SLEW_CNTRL ,0x02 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK ,0x04 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_TSYNC_RSYNC_TIME ,0x44 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK ,0x04 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_L ,0xe7 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RCVR_DTCT_DLY_P1U2_H ,0x03 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RCVR_DTCT_DLY_U3_L ,0x40 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RCVR_DTCT_DLY_U3_H ,0x00 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME ,0x75 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK ,0x86 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_RXEQTRAINING_RUN_TIME ,0x13 ), + +QMP_PHY_INIT_CFG (QPHY_V3_PCS_REFGEN_REQ_CONFIG1 ,0x21 ), +QMP_PHY_INIT_CFG (QPHY_V3_PCS_REFGEN_REQ_CONFIG2 ,0x60 ), +}; + +/* struct qmp_phy_cfg - per-PHY initialization config */ struct qmp_phy_cfg {/* phy-type - PCIE/UFS/USB */
@@ -766,6 +878,7 @@ static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val) .pwrdn_ctrl = SW_PWRDN, .mask_pcs_ready = PHYSTATUS, + .has_pwrdn_delay = true, .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX,
@@ -774,6 +887,35 @@ static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val) .rx_b_lane_offset = 0x400, }; +static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { + .type =PHY_TYPE_USB3 , + .nlanes =1 , + + .serdes_tbl = qmp_v3_usb3_uniphy_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (qmp_v3_usb3_uniphy_serdes_tbl), + .tx_tbl = qmp_v3_usb3_uniphy_tx_tbl, + .tx_tbl_num =ARRAY_SIZE (qmp_v3_usb3_uniphy_tx_tbl), + .rx_tbl = qmp_v3_usb3_uniphy_rx_tbl, + .rx_tbl_num =ARRAY_SIZE (qmp_v3_usb3_uniphy_rx_tbl), + .pcs_tbl = qmp_v3_usb3_uniphy_pcs_tbl, + .pcs_tbl_num =ARRAY_SIZE (qmp_v3_usb3_uniphy_pcs_tbl), + .clk_list = qmp_v3_phy_clk_l, + .num_clks =ARRAY_SIZE (qmp_v3_phy_clk_l), + .reset_list = msm8996_usb3phy_reset_l, + .num_resets =ARRAY_SIZE (msm8996_usb3phy_reset_l), + .vreg_list = msm8996_phy_vreg_l, + .num_vregs =ARRAY_SIZE (msm8996_phy_vreg_l), + .regs = qmp_v3_usb3phy_regs_layout, + + .start_ctrl =SERDES_START |PCS_START , + .pwrdn_ctrl =SW_PWRDN , + .mask_pcs_ready =PHYSTATUS , + + .has_pwrdn_delay = true, + .pwrdn_delay_min =POWER_DOWN_DELAY_US_MIN , + .pwrdn_delay_max =POWER_DOWN_DELAY_US_MAX , +}; + static void qcom_qmp_phy_configure(void __iomem *base, const unsigned int *regs, const struct qmp_phy_init_tbl tbl[],
@@ -1401,6 +1543,12 @@ int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id) }, { .compatible = "qcom,qmp-v3-usb3-phy", .data = &qmp_v3_usb3phy_cfg, + }, { + .compatible = "qcom,sdm845-qmp-usb3-phy", + .data = &qmp_v3_usb3phy_cfg, + }, { + .compatible = "qcom,sdm845-qmp-usb3-uni-phy", + .data = &qmp_v3_usb3_uniphy_cfg, }, { }, };
drivers/phy/qualcomm/phy-qcom-qmp.h +5 -0
@@ -214,6 +214,8 @@#define QSERDES_V3_RX_UCDR_FASTLOCK_FO_GAIN 0x030#define QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE 0x034#define QSERDES_V3_RX_RX_TERM_BW 0x07c +#define QSERDES_V3_RX_VGA_CAL_CNTRL1 0x0bc +#define QSERDES_V3_RX_VGA_CAL_CNTRL2 0x0c0#define QSERDES_V3_RX_RX_EQ_GAIN2_LSB 0x0c8#define QSERDES_V3_RX_RX_EQ_GAIN2_MSB 0x0cc#define QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2 0x0d4
@@ -227,6 +229,7 @@#define QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL 0x10c#define QSERDES_V3_RX_RX_BAND 0x110#define QSERDES_V3_RX_RX_INTERFACE_MODE 0x11c +#define QSERDES_V3_RX_RX_MODE_00 0x164/* Only for QMP V3 PHY - PCS registers */ #define QPHY_V3_PCS_POWER_DOWN_CONTROL 0x004
@@ -273,6 +276,8 @@#define QPHY_V3_PCS_FLL_CNT_VAL_H_TOL 0x0d0#define QPHY_V3_PCS_FLL_MAN_CODE 0x0d4#define QPHY_V3_PCS_RX_SIGDET_LVL 0x1d8 +#define QPHY_V3_PCS_REFGEN_REQ_CONFIG1 0x20c +#define QPHY_V3_PCS_REFGEN_REQ_CONFIG2 0x210/* Only for QMP V3 PHY - PCS_MISC registers */ #define QPHY_V3_PCS_MISC_CLAMP_ENABLE 0x0c
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 5/6 dt-bindings: phy-qcom-usb2: Update bindings for sdm845
In reply to Manu GautamUpdate compatible strings for USB2 PHYs on sdm845. There are two QUSB2 PHYs present on sdm845. Few PHY registers programming is different for these PHYs related to electrical parameters, otherwise both are same.
--- Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt +3 -1
@@ -6,7 +6,9 @@ QUSB2 controller supports LS/FS/HS usb connectivity on Qualcomm chipsets. Required properties: - compatible: compatible list, contains "qcom,msm8996-qusb2-phy" for 14nm PHY on msm8996, - "qcom,qusb2-v2-phy" for QUSB2 V2 PHY. + "qcom,qusb2-v2-phy" for QUSB2 V2 PHY, + "qcom,sdm845-qusb2-phy-1" for primary PHY on sdm845, + "qcom,sdm845-qusb2-phy-2" for secondary PHY on sdm845. - reg: offset and length of the PHY register set. - #phy-cells: must be 0.
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 6/6 phy: qcom-qusb2: Add QUSB2 PHYs support for sdm845
In reply to Manu GautamThere are two QUSB2 PHYs present on sdm845. Update PHY registers programming for both the PHYs related to electrical parameters to improve eye diagram.
--- drivers/phy/qualcomm/phy-qcom-qusb2.c | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/phy/qualcomm/phy-qcom-qusb2.c +39 -0
@@ -174,6 +174,27 @@ enum qusb2phy_reg_layout { QUSB2_PHY_INIT_CFG(QUSB2PHY_CHG_CTRL2, 0x0), }; +static const struct qusb2_phy_init_tbl sdm845_init_tbl_1[] = { +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_ANALOG_CONTROLS_TWO ,0x03 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_CLOCK_INVERTERS ,0x7c ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_CMODE ,0x80 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_LOCK_DELAY ,0x0a ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_DIGITAL_TIMERS_TWO ,0x19 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_BIAS_CONTROL_1 ,0x40 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PLL_BIAS_CONTROL_2 ,0x20 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_PWR_CTRL2 ,0x21 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_IMP_CTRL1 ,0x8 ), +QUSB2_PHY_INIT_CFG (QUSB2PHY_IMP_CTRL2 ,0x58 ), + +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE1 ,0x45 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE2 ,0x29 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE3 ,0xca ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE4 ,0x04 ), +QUSB2_PHY_INIT_CFG_L (QUSB2PHY_PORT_TUNE5 ,0x03 ), + +QUSB2_PHY_INIT_CFG (QUSB2PHY_CHG_CTRL2 ,0x0 ), +}; +struct qusb2_phy_cfg {const struct qusb2_phy_init_tbl *tbl;/* number of entries in the table */
@@ -220,6 +241,18 @@ struct qusb2_phy_cfg { .autoresume_en = BIT(0), }; +static const struct qusb2_phy_cfg sdm845_phy_cfg_1 = { + .tbl = sdm845_init_tbl_1, + .tbl_num =ARRAY_SIZE (sdm845_init_tbl_1), + .regs = qusb2_v2_regs_layout, + + .disable_ctrl = (PWR_CTRL1_VREF_SUPPLY_TRIM |PWR_CTRL1_CLAMP_N_EN | +POWER_DOWN ), + .mask_core_ready =CORE_READY_STATUS , + .has_pll_override = true, + .autoresume_en =BIT (0 ), +}; +static const char *const qusb2_phy_vreg_names[] = {"vdda-pll" ,"vdda-phy-dpdm" , };
@@ -649,6 +682,12 @@ static int qusb2_phy_exit(struct phy *phy) }, { .compatible = "qcom,qusb2-v2-phy", .data = &qusb2_v2_phy_cfg, + }, { + .compatible = "qcom,sdm845-qusb2-phy-1", + .data = &sdm845_phy_cfg_1, + }, { + .compatible = "qcom,sdm845-qusb2-phy-2", + .data = &qusb2_v2_phy_cfg, }, { }, };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 1/6] phy: qcom-qmp: Enable pipe_clk before checking USB3 PHY_STATUS
In reply to Manu GautamQuoting Manu Gautam (2018-03-22 01:50:41)
Quoted 2 lines
QMP PHY for USB mode requires
pipe_clkfor calibration and PLL lock to take place. This lock is output from PHY to GCCclock_ctland then
s/lock/clock/
Quoted 14 lines
fed back to QMP PHY and is output from PHY only after PHY is reset and initialized, hence it can't be enabled too early in initialization sequence.
Signed-off-by Manu Gautam <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/phy/qualcomm/phy-qcom-qmp.c +0
-0
drivers/phy/qualcomm/phy-qcom-qmp.c static int qcom_qmp_phy_poweron(struct phy *phy) · line 805
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +4
-0@@ -797,8 +797,13 @@ static int qcom_qmp_phy_poweron(struct phy *phy) {struct qmp_phy *qphy =phy_get_drvdata (phy);struct qcom_qmp *qmp = qphy->qmp; +const struct qmp_phy_cfg *cfg = qmp->cfg;int ret; +/* Not needed for USB3 PHY as pipe_clk is enabled from phy_init */ +if (cfg->type ==PHY_TYPE_USB3 ) +return 0 ;
Would be nice to not even assign phy_poweron when the PHY is USB3 type.
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +3
-0+ ret =clk_prepare_enable (qphy->pipe_clk);if (ret)dev_err (qmp->dev,"pipe_clk enable failed, err=%d\n" , ret);@@ -1008,6 +1013,19 @@ static int qcom_qmp_phy_init(struct phy *phy) status = pcs + cfg->regs[QPHY_PCS_READY_STATUS ]; mask = cfg->mask_pcs_ready; +/* USB3 PHY requires pipe_clk for PLL lock and calibration */ +if (cfg->type ==PHY_TYPE_USB3 ) {
drivers/phy/qualcomm/phy-qcom-qmp.c static int qcom_qmp_phy_init(struct phy *phy) · line 1027
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +10
-0+ ret =clk_prepare_enable (qphy->pipe_clk); +if (ret) +dev_err (qmp->dev,"pipe_clk enable err=%d\n" , ret); +/* +* Ignore this error as pipe_clk might take some time to get +* enabled. In any case following check for PHY PLL lock would +* timeout below if there is a fatal error and clock is not fed +* to PHY +*/ +
This is odd. If clk_enable() fails then we don't keep parent clks (or the clk that's being operated on) up refcounted and enabled. How is that going to work?
Re: [PATCH v2 1/6] phy: qcom-qmp: Enable pipe_clk before checking USB3 PHY_STATUS
Hi Stephen,
Quoted 4 lines · Stephen Boyd
Quoting Manu Gautam (2018-03-22 01:50:41)
Quoted 2 lines
QMP PHY for USB mode requires
pipe_clkfor calibration and PLL lock to take place. This lock is output from PHY to GCCclock_ctland thens/lock/clock/
Yes, will fix typo.
Quoted 20 lines
Quoted 20 lines
fed back to QMP PHY and is output from PHY only after PHY is reset and initialized, hence it can't be enabled too early in initialization sequence.
Signed-off-by Manu Gautam <[email protected]>--- drivers/phy/qualcomm/phy-qcom-qmp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/phy/qualcomm/phy-qcom-qmp.c +1
-0@@ -797,8 +797,13 @@ static int qcom_qmp_phy_poweron(struct phy *phy) {struct qmp_phy *qphy =phy_get_drvdata (phy);struct qcom_qmp *qmp = qphy->qmp; +const struct qmp_phy_cfg *cfg = qmp->cfg;int ret;
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-qmp.c static int qcom_qmp_phy_poweron(struct phy *phy) · line 805
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +3
-0+/* Not needed for USB3 PHY as pipe_clk is enabled from phy_init */ +if (cfg->type ==PHY_TYPE_USB3 ) +return 0 ;Would be nice to not even assign
phy_poweronwhen the PHY is USB3 type.
Yes, that should be better.
Quoted 9 lines
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +1
-0+ ret =clk_prepare_enable (qphy->pipe_clk);if (ret)dev_err (qmp->dev,"pipe_clk enable failed, err=%d\n" , ret);@@ -1008,6 +1013,19 @@ static int qcom_qmp_phy_init(struct phy *phy) status = pcs + cfg->regs[QPHY_PCS_READY_STATUS ]; mask = cfg->mask_pcs_ready;
Quoted 15 lines
drivers/phy/qualcomm/phy-qcom-qmp.c static int qcom_qmp_phy_init(struct phy *phy) · line 1028
Quoted 12 lines
drivers/phy/qualcomm/phy-qcom-qmp.c +12
-0+/* USB3 PHY requires pipe_clk for PLL lock and calibration */ +if (cfg->type ==PHY_TYPE_USB3 ) { + ret =clk_prepare_enable (qphy->pipe_clk); +if (ret) +dev_err (qmp->dev,"pipe_clk enable err=%d\n" , ret); +/* +* Ignore this error as pipe_clk might take some time to get +* enabled. In any case following check for PHY PLL lock would +* timeout below if there is a fatal error and clock is not fed +* to PHY +*/ +This is odd. If
clk_enable()fails then we don't keep parent clks (or the clk that's being operated on) up refcounted and enabled. How is that going to work?
I agree. My intent was to ignore only halt_check errors from clock driver. In any case this condition (to ignore clk_enable error) should probably be handled in clock driver. And I see that clock driver is already using halt_check as BRANCH_HALT_DELAY, so I don't need to worry about that in phy driver.
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project