Add support for USB phys in IPQ9650
v6 cover Add support for USB phys in IPQ9650
This series
- Adds dt-bindings and driver changes for the high speed and super speed phys in IPQ9650.
- IPQ9650 specific init tables to QMP super speed phy driver.
- The Femto high speed phy driver is refactored to accomodate differences in the init sequences between SoCs first and then support for IPQ9650 is included.
---
Changes in v6:
- #include <linux/bitfield.h> in drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c to avoid build breaks in other (non arm64) architectures
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Use FIELD_PREP_CONST to define FSEL_24MHZ
- Change commit subject to 'Fix order of arguments to qcom_snps_hsphy_write_mask'
- Use data->{pre,post}_tuning in qcom_snps_hsphy_init() instead of a temporary local variable
- Pick R-b from Dmitry for two patches
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Rebase to top of tree
- Split 4th patch 'phy: qcom: snps-femto-v2: Move PHY init registers to config tables' as follows:
phy: qcom: snps-femto-v2: Fix qcom_snps_hsphy_write_mask argument mixup
phy: qcom: snps-femto-v2: Move PHY init registers to config tables
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- No code changes
- Rebase to top of tree
- Pick two R-b tags
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Pick one R-b from Krzysztof
- Use qcom,ipq9650-usb-hs-phy directly instead of adding a 6nm compatible and falling back to it
- Change pre/post to pre_tuning/post_tuning
- Use array count instead of terminating entries
- Fix value/mask mixup in 2 places
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Varadarajan Narayanan (6):
dt-bindings: phy: qcom,qmp-usb: Add IPQ9650 USB3 PHY
dt-bindings: phy: qcom,usb-snps-femto-v2: Add IPQ9650 compatible
phy: qcom: qmp-usb: Add IPQ9650 USB3 PHY configuration
phy: qcom: snps-femto-v2: Fix order of arguments to qcom_snps_hsphy_write_mask
phy: qcom: snps-femto-v2: Move PHY init registers to config tables
phy: qcom: snps-femto-v2: Add IPQ9650 support
.../phy/qcom,sc8280xp-qmp-usb3-uni-phy.yaml | 2 + .../bindings/phy/qcom,usb-snps-femto-v2.yaml | 2 + drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 118 +++++++++++++ drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 194 ++++++++++++++++----- 4 files changed, 269 insertions(+), 47 deletions(-)
---
base-commit: ed06cc88c5e644da0f1ef397a836c7b1c10f41ac
change-id: 20260820-phy-664ed5ec0292
Best regards,
Signature · 1 line
Varadarajan Narayanan <[email protected]>
PATCH v6 1/6 dt-bindings: phy: qcom,qmp-usb: Add IPQ9650 USB3 PHY
Document the Qualcomm IPQ9650 USB3 QMP PHY compatible.
Use a standalone compatible because the IPQ9650 PHY has register configuration data that differs from the currently supported SoCs and should not fall back to an existing definition.
--- .../devicetree/bindings/phy/qcom,sc8280xp-qmp-usb3-uni-phy.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-usb3-uni-phy.yaml +2 -0
@@ -23,6 +23,7 @@ properties: - qcom,ipq6018-qmp-usb3-phy - qcom,ipq8074-qmp-usb3-phy - qcom,ipq9574-qmp-usb3-phy + - qcom,ipq9650-qmp-usb3-phy - qcom,msm8996-qmp-usb3-phy - qcom,qcs8300-qmp-usb3-uni-phy - qcom,qdu1000-qmp-usb3-uni-phy
@@ -102,6 +103,7 @@ allOf: - qcom,ipq6018-qmp-usb3-phy - qcom,ipq8074-qmp-usb3-phy - qcom,ipq9574-qmp-usb3-phy + - qcom,ipq9650-qmp-usb3-phy - qcom,msm8996-qmp-usb3-phy - qcom,sdx55-qmp-usb3-uni-phy - qcom,sdx65-qmp-usb3-uni-phy
Signature · 1 line
2.34.1
PATCH v6 2/6 dt-bindings: phy: qcom,usb-snps-femto-v2: Add IPQ9650 compatible
In reply to Varadarajan NarayananAdd qcom,ipq9650-usb-hs-phy to the list of supported compatibles. Unlike the existing SoCs, IPQ9650 does not share a generic "qcom,usb-snps-hs-*nm-phy" fallback, since it requires its own tuning/override sequence, so list it as a standalone entry.
--- Documentation/devicetree/bindings/phy/qcom,usb-snps-femto-v2.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/phy/qcom,usb-snps-femto-v2.yaml +2 -0
@@ -15,6 +15,8 @@ description: | properties: compatible: oneOf: + - enum: + - qcom,ipq9650-usb-hs-phy - items: - enum: - qcom,sa8775p-usb-hs-phy
Signature · 1 line
2.34.1
PATCH v6 3/6 phy: qcom: qmp-usb: Add IPQ9650 USB3 PHY configuration
In reply to Varadarajan NarayananAdd the USB3 QMP PHY configuration for IPQ9650, including the SoC-specific init tables and compatible data.
IPQ9650 uses settings that do not match any existing supported SoC, so add a dedicated configuration to allow the driver to support it.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 118 ++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +118 -0
@@ -400,6 +400,101 @@ static const struct qmp_phy_init_tbl ipq8074_usb3_pcs_tbl[] = { QMP_PHY_INIT_CFG(QPHY_V3_PCS_TXDEEMPH_M3P5DB_V0, 0x0f), }; +static const struct qmp_phy_init_tbl ipq9650_usb3_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_IVCO ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_EN_CENTER ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_PER1 ,0x7d ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_PER2 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE1_MODE0 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SSC_STEP_SIZE2_MODE0 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SYSCLK_BUF_ENABLE ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CMN_IPTRIM ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_CP_CTRL_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_RCTRL_MODE0 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_PLL_CCTRL_MODE0 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_SYSCLK_EN_SEL ,0x1a ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BG_TIMER ,0x0b ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP_EN ,0x42 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP1_MODE0 ,0xd4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_LOCK_CMP2_MODE0 ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DEC_START_MODE0 ,0x68 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START1_MODE0 ,0xab ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START2_MODE0 ,0xaa ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_DIV_FRAC_START3_MODE0 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE_MAP ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE1_MODE0 ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_VCO_TUNE2_MODE0 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_HSCLK_SEL ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0xa2 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V4_COM_BIN_VCOCAL_HSCLK_SEL ,0x01 ), +}; + +static const struct qmp_phy_init_tbl ipq9650_usb3_tx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_LANE_MODE_1 ,0xb5 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_LANE_MODE_2 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_RCV_DETECT_LVL_2 ,0x12 ), +QMP_PHY_INIT_CFG (QSERDES_V4_TX_PI_QEC_CTRL ,0x00 ), +}; + +static const struct qmp_phy_init_tbl ipq9650_usb3_rx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_FO_GAIN ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SO_GAIN ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_FASTLOCK_FO_GAIN ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SO_SATURATION_AND_ENABLE ,0x7f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_LOW ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_FASTLOCK_COUNT_HIGH ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_PI_CONTROLS ,0x99 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SB2_THRESH1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SB2_THRESH2 ,0x08 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SB2_GAIN1 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_UCDR_SB2_GAIN2 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_VGA_CAL_CNTRL1 ,0x54 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_VGA_CAL_CNTRL2 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_GM_CAL ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL2 ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL3 ,0x4a ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQU_ADAPTOR_CNTRL4 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_IDAC_TSETTLE_LOW ,0xc0 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_IDAC_TSETTLE_HIGH ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 ,0x47 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_OFFSET_ADAPTOR_CNTRL2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_CNTRL ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_SIGDET_DEGLITCH_CNTRL ,0x0e ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_LOW ,0xe4 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH ,0x64 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH2 ,0xf6 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH3 ,0x89 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_RX_MODE_01_HIGH4 ,0x35 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_DFE_EN_TIMER ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_DFE_CTLE_POST_CAL_OFFSET ,0x38 ), +QMP_PHY_INIT_CFG (QSERDES_V4_RX_DCC_CTRL1 ,0x0c ), +}; + +static const struct qmp_phy_init_tbl ipq9650_usb3_pcs_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RATE_SLEW_CNTRL1 ,0x03 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_LOCK_DETECT_CONFIG1 ,0xd0 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_LOCK_DETECT_CONFIG2 ,0x07 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_LOCK_DETECT_CONFIG3 ,0x20 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_LOCK_DETECT_CONFIG6 ,0x13 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_REFGEN_REQ_CONFIG1 ,0x21 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RX_SIGDET_LVL ,0xaa ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_L ,0xe7 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_RCVR_DTCT_DLY_P1U2_H ,0x03 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_PCS_TX_RX_CONFIG ,0x0c ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_FLL_CNTRL2 ,0x83 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_FLL_CNTRL1 ,0x02 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_FLL_CNT_VAL_L ,0x09 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_FLL_CNT_VAL_H_TOL ,0xa2 ), +QMP_PHY_INIT_CFG (QPHY_V4_PCS_FLL_MAN_CODE ,0x40 ), +}; + +static const struct qmp_phy_init_tbl ipq9650_usb3_pcs_usb_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V4_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL ,0xf8 ), +}; +static const struct qmp_phy_init_tbl msm8996_usb3_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V2_COM_SYSCLK_EN_SEL ,0x14 ),QMP_PHY_INIT_CFG (QSERDES_V2_COM_BIAS_EN_CLKBUFLR_EN ,0x08 ),
@@ -1572,6 +1667,26 @@ static const struct qmp_phy_cfg ipq9574_usb3phy_cfg = { .regs = qmp_v3_usb3phy_regs_layout, }; +static const struct qmp_phy_cfg ipq9650_usb3phy_cfg = { + .offsets = &qmp_usb_offsets_v4, + + .serdes_tbl = ipq9650_usb3_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (ipq9650_usb3_serdes_tbl), + .tx_tbl = ipq9650_usb3_tx_tbl, + .tx_tbl_num =ARRAY_SIZE (ipq9650_usb3_tx_tbl), + .rx_tbl = ipq9650_usb3_rx_tbl, + .rx_tbl_num =ARRAY_SIZE (ipq9650_usb3_rx_tbl), + .pcs_tbl = ipq9650_usb3_pcs_tbl, + .pcs_tbl_num =ARRAY_SIZE (ipq9650_usb3_pcs_tbl), + .pcs_usb_tbl = ipq9650_usb3_pcs_usb_tbl, + .pcs_usb_tbl_num =ARRAY_SIZE (ipq9650_usb3_pcs_usb_tbl), + .vreg_list = qmp_phy_vreg_l, + .num_vregs =ARRAY_SIZE (qmp_phy_vreg_l), + .regs = qmp_v4_usb3phy_regs_layout, + + .has_pwrdn_delay = true, +}; +static const struct qmp_phy_cfg msm8996_usb3phy_cfg = { .offsets = &qmp_usb_offsets_v3_msm8996,
@@ -2459,6 +2574,9 @@ static const struct of_device_id qmp_usb_of_match_table[] = { }, { .compatible = "qcom,ipq9574-qmp-usb3-phy", .data = &ipq9574_usb3phy_cfg, + }, { + .compatible = "qcom,ipq9650-qmp-usb3-phy", + .data = &ipq9650_usb3phy_cfg, }, { .compatible = "qcom,msm8996-qmp-usb3-phy", .data = &msm8996_usb3phy_cfg,
Signature · 1 line
2.34.1
PATCH v6 4/6 phy: qcom: snps-femto-v2: Fix order of arguments to qcom_snps_hsphy_write_mask
In reply to Varadarajan NarayananFix the register bit field mask & value argument order while programming USB2_PHY_USB_PHY_REFCLK_CTRL in qcom_snps_hsphy_init() and USB2_AUTO_RESUME in qcom_snps_hsphy_suspend().
--- drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c +2 -2
@@ -193,7 +193,7 @@ static int qcom_snps_hsphy_suspend(struct qcom_snps_hsphy *hsphy)usleep_range (500 ,1000 );qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_HS_PHY_CTRL2 , -0 ,USB2_AUTO_RESUME ); +USB2_AUTO_RESUME ,0 ); }return 0 ;
@@ -426,7 +426,7 @@ static int qcom_snps_hsphy_init(struct phy *phy)USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 , PLLBTUNE, PLLBTUNE);qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_REFCLK_CTRL , -REFCLK_SEL_DEFAULT ,REFCLK_SEL_MASK ); +REFCLK_SEL_MASK ,REFCLK_SEL_DEFAULT );qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 ,VBUSVLDEXTSEL0 ,VBUSVLDEXTSEL0 );
Signature · 1 line
2.34.1
Re: [PATCH v6 4/6] phy: qcom: snps-femto-v2: Fix order of arguments to qcom_snps_hsphy_write_mask
Quoted 9 lines · Varadarajan Narayanan
Fix the register bit field mask & value argument order while programming
USB2_PHY_USB_PHY_REFCLK_CTRLinqcom_snps_hsphy_init()andUSB2_AUTO_RESUMEinqcom_snps_hsphy_suspend().Fixes 51e8114f80d07 ("phy: qcom-snps: Add SNPS USB PHY driver for QCOM based SOCs")Fixes 0d75f508a9d56 ("phy: qcom-snps: Add runtime suspend and resume handlers")Reviewed-by Dmitry Baryshkov <[email protected]>Signed-off-by Varadarajan Narayanan <[email protected]>---
Konrad
PATCH v6 5/6 phy: qcom: snps-femto-v2: Move PHY init registers to config tables
In reply to Varadarajan NarayananThe driver currently programs the common PHY register sequence directly in qcom_snps_hsphy_init(), with the fixed register writes split around the override parameter handling. This makes it hard to support SoCs that need a different sequence or different values.
Move the fixed pre- and post-override register programming into per- compatible configuration tables, and keep the 7 nm override parameters in the same match-data structure. This allows the driver to share the common sequence while adding SoC-specific sequences for future platforms such as IPQ9650.
--- drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 129 +++++++++++++++++--------- 1 file changed, 83 insertions(+), 46 deletions(-)
drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c +83 -46
@@ -104,6 +104,20 @@ struct phy_override_seq {u8 mask; }; +struct phy_reg_config { +u32 offset; +u32 mask; +u32 val; +}; + +struct phy_config_data { +const struct phy_reg_config *pre_tuning; +const struct override_param_map *override; +const struct phy_reg_config *post_tuning; +const u32 num_pre_tuning; +const u32 num_post_tuning; +}; +#define NUM_HSPHY_TUNING_PARAMS (9)/**
@@ -383,13 +397,39 @@ static const struct override_param_map sc7280_snps_7nm_phy[] = { {}, }; +static const struct phy_reg_config hs_5nm_phy_pre_tuning[] = { + {USB2_PHY_USB_PHY_CFG0 ,UTMI_PHY_CMN_CTRL_OVERRIDE_EN ,UTMI_PHY_CMN_CTRL_OVERRIDE_EN }, + {USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR ,POR }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,FSEL_MASK ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 ,PLLBTUNE ,PLLBTUNE }, + {USB2_PHY_USB_PHY_REFCLK_CTRL ,REFCLK_SEL_MASK ,REFCLK_SEL_DEFAULT }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 ,VBUSVLDEXTSEL0 ,VBUSVLDEXTSEL0 }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL1 ,VBUSVLDEXT0 ,VBUSVLDEXT0 }, +}; + +static const struct phy_reg_config hs_5nm_phy_post_tuning[] = { + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2 ,VREGBYPASS ,VREGBYPASS }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL2 ,USB2_SUSPEND_N_SEL |USB2_SUSPEND_N , +USB2_SUSPEND_N_SEL |USB2_SUSPEND_N }, + {USB2_PHY_USB_PHY_UTMI_CTRL0 ,SLEEPM ,SLEEPM }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,SIDDQ ,0 }, + {USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL2 ,USB2_SUSPEND_N_SEL ,0 }, + {USB2_PHY_USB_PHY_CFG0 ,UTMI_PHY_CMN_CTRL_OVERRIDE_EN ,0 }, +}; +static int qcom_snps_hsphy_init (struct phy *phy) {struct qcom_snps_hsphy *hsphy =phy_get_drvdata (phy); +const struct phy_config_data *data;int ret, i;dev_vdbg (&phy->dev,"%s(): Initializing SNPS HS phy\n" , __func__); + data =of_device_get_match_data (hsphy->dev); +if (!data) +return -ENODEV ; + ret =regulator_bulk_enable (ARRAY_SIZE (hsphy->vregs), hsphy->vregs);if (ret)return ret;
@@ -414,24 +454,11 @@ static int qcom_snps_hsphy_init(struct phy *phy) goto disable_clks; } -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_CFG0 , -UTMI_PHY_CMN_CTRL_OVERRIDE_EN , -UTMI_PHY_CMN_CTRL_OVERRIDE_EN ); -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_UTMI_CTRL5 , -POR ,POR ); -qcom_snps_hsphy_write_mask (hsphy->base, -USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 , -FSEL_MASK ,0 ); -qcom_snps_hsphy_write_mask (hsphy->base, -USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 , -PLLBTUNE ,PLLBTUNE ); -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_REFCLK_CTRL , -REFCLK_SEL_MASK ,REFCLK_SEL_DEFAULT ); -qcom_snps_hsphy_write_mask (hsphy->base, -USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 , -VBUSVLDEXTSEL0 ,VBUSVLDEXTSEL0 ); -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_HS_PHY_CTRL1 , -VBUSVLDEXT0 ,VBUSVLDEXT0 ); +for (i =0 ; i < data->num_pre_tuning; i++) +qcom_snps_hsphy_write_mask (hsphy->base, + data->pre_tuning[i].offset, + data->pre_tuning[i].mask, + data->pre_tuning[i].val);for (i =0 ; i <ARRAY_SIZE (hsphy->update_seq_cfg); i++) {if (hsphy->update_seq_cfg[i].need_update)
@@ -441,28 +468,11 @@ static int qcom_snps_hsphy_init(struct phy *phy) hsphy->update_seq_cfg[i].value); } -qcom_snps_hsphy_write_mask (hsphy->base, -USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2 , -VREGBYPASS ,VREGBYPASS ); - -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_HS_PHY_CTRL2 , -USB2_SUSPEND_N_SEL |USB2_SUSPEND_N , -USB2_SUSPEND_N_SEL |USB2_SUSPEND_N ); - -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_UTMI_CTRL0 , -SLEEPM ,SLEEPM ); - -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 , -SIDDQ ,0 ); - -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_UTMI_CTRL5 , -POR ,0 ); - -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_HS_PHY_CTRL2 , -USB2_SUSPEND_N_SEL ,0 ); - -qcom_snps_hsphy_write_mask (hsphy->base,USB2_PHY_USB_PHY_CFG0 , -UTMI_PHY_CMN_CTRL_OVERRIDE_EN ,0 ); +for (i =0 ; i < data->num_post_tuning; i++) +qcom_snps_hsphy_write_mask (hsphy->base, + data->post_tuning[i].offset, + data->post_tuning[i].mask, + data->post_tuning[i].val); hsphy->phy_initialized = true;
@@ -495,14 +505,38 @@ static const struct phy_ops qcom_snps_hsphy_gen_ops = { .owner = THIS_MODULE, }; +static const struct phy_config_data hs_5nm_phy = { + .pre_tuning = hs_5nm_phy_pre_tuning, + .num_pre_tuning =ARRAY_SIZE (hs_5nm_phy_pre_tuning), + .post_tuning = hs_5nm_phy_post_tuning, + .num_post_tuning =ARRAY_SIZE (hs_5nm_phy_post_tuning), +}; + +static const struct phy_config_data hs_7nm_phy = { + .pre_tuning = hs_5nm_phy_pre_tuning, + .num_pre_tuning =ARRAY_SIZE (hs_5nm_phy_pre_tuning), + .override = sc7280_snps_7nm_phy, + .post_tuning = hs_5nm_phy_post_tuning, + .num_post_tuning =ARRAY_SIZE (hs_5nm_phy_post_tuning), +}; +static const struct of_device_id qcom_snps_hsphy_of_match_table[] = { - { .compatible ="qcom,sm8150-usb-hs-phy" , }, - { .compatible ="qcom,usb-snps-hs-5nm-phy" , }, + { + .compatible ="qcom,sm8150-usb-hs-phy" , + .data = &hs_5nm_phy, + }, + { + .compatible ="qcom,usb-snps-hs-5nm-phy" , + .data = &hs_5nm_phy, + }, { .compatible ="qcom,usb-snps-hs-7nm-phy" , - .data = &sc7280_snps_7nm_phy, + .data = &hs_7nm_phy, + }, + { + .compatible ="qcom,usb-snps-femto-v2-phy" , + .data = &hs_5nm_phy, }, - { .compatible ="qcom,usb-snps-femto-v2-phy" , }, { } };MODULE_DEVICE_TABLE (of, qcom_snps_hsphy_of_match_table);
@@ -541,11 +575,14 @@ static void qcom_snps_hsphy_read_override_param_seq(struct device *dev)s32 val;int ret, i;struct qcom_snps_hsphy *hsphy; -const struct override_param_map *cfg =of_device_get_match_data (dev); +const struct phy_config_data *data =of_device_get_match_data (dev); +const struct override_param_map *cfg; -if (!cfg) +if (!data || !data->override)return ; + cfg = data->override; + hsphy =dev_get_drvdata (dev);for (i =0 ; cfg[i].prop_name !=NULL ; i++) {
Signature · 1 line
2.34.1
Re: [PATCH v6 5/6] phy: qcom: snps-femto-v2: Move PHY init registers to config tables
Quoted 5 lines · Varadarajan Narayanan
The driver currently programs the common PHY register sequence directly in
qcom_snps_hsphy_init(), with the fixed register writes split around the override parameter handling. This makes it hard to support SoCs that need a different sequence or different values.
Quoted 8 lines
Move the fixed pre- and post-override register programming into per- compatible configuration tables, and keep the 7 nm override parameters in the same match-data structure. This allows the driver to share the common sequence while adding SoC-specific sequences for future platforms such as IPQ9650.
Signed-off-by Varadarajan Narayanan <[email protected]>---
Konrad
PATCH v6 6/6 phy: qcom: snps-femto-v2: Add IPQ9650 support
In reply to Varadarajan NarayananAdd the 6 nm SNPS femto USB2 PHY configuration needed by IPQ9650. The PHYs on this SoC require a dedicated init sequence and override parameters before they can be enabled.
--- drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c +63 -0
@@ -3,6 +3,7 @@* Copyright (c) 2020, The Linux Foundation. All rights reserved. */ +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/err.h>
@@ -29,12 +30,15 @@#define USB2_PHY_USB_PHY_UTMI_CTRL5 (0x50)#define POR BIT(1) +#define ATERESET BIT(0)#define USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 (0x54)#define SIDDQ BIT(2)#define RETENABLEN BIT(3)#define FSEL_MASK GENMASK(6, 4)#define FSEL_DEFAULT (0x3 << 4) +#define FSEL_24MHZ FIELD_PREP_CONST(FSEL_MASK, 2) +#define VATESTENB_MASK GENMASK(1, 0)#define USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 (0x58)#define VBUSVLDEXTSEL0 BIT(4)
@@ -57,6 +61,13 @@#define USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X3 (0x78)#define PARAM_OVRD_MASK 0xFF +#define USB2_PHY_USB_PHY_HS_PHY_TEST0 0x80 +#define TESTDATAIN_MASK GENMASK(7, 0) + +#define USB2_PHY_USB_PHY_HS_PHY_TEST1 0x84 +#define TESTDATAOUTSEL BIT(4) +#define TESTCLK BIT(6) +#define USB2_PHY_USB_PHY_CFG0 (0x94)#define UTMI_PHY_DATAPATH_CTRL_OVERRIDE_EN BIT(0)#define UTMI_PHY_CMN_CTRL_OVERRIDE_EN BIT(1)
@@ -78,6 +89,9 @@#define LS_FS_OUTPUT_IMPEDANCE_MASK GENMASK(3, 0) +#define USB2_PHY_USB_PHY_FSEL_SEL 0xb8 +#define FSEL_SEL BIT(0) +static const char *const qcom_snps_hsphy_vreg_names[] = {"vdda-pll" ,"vdda33" ,"vdda18" , };
@@ -330,6 +344,17 @@ static const struct override_param ls_fs_output_impedance_sc7280[] = { { 1310, 0 }, }; +static const struct override_param_map ipq9650_snps_6nm_phy[] = { + { + "qcom,pre-emphasis-amplitude-bp", + preemphasis_amplitude_sc7280, + ARRAY_SIZE(preemphasis_amplitude_sc7280), + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X1, + PREEMPHASIS_AMPLITUDE_MASK, + }, + {}, +}; + static const struct override_param_map sc7280_snps_7nm_phy[] = { { "qcom,hs-disconnect-bp",
@@ -418,6 +443,32 @@ static const struct phy_reg_config hs_5nm_phy_post_tuning[] = { { USB2_PHY_USB_PHY_CFG0, UTMI_PHY_CMN_CTRL_OVERRIDE_EN, 0 }, }; +static const struct phy_reg_config hs_6nm_phy_pre_tuning[] = { + {USB2_PHY_USB_PHY_CFG0 ,UTMI_PHY_CMN_CTRL_OVERRIDE_EN ,UTMI_PHY_CMN_CTRL_OVERRIDE_EN }, + {USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR ,POR }, + {USB2_PHY_USB_PHY_FSEL_SEL ,FSEL_SEL ,FSEL_SEL }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,FSEL_MASK ,FSEL_24MHZ }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 ,PLLBTUNE ,PLLBTUNE }, + {USB2_PHY_USB_PHY_REFCLK_CTRL ,REFCLK_SEL_MASK ,REFCLK_SEL_DEFAULT }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1 ,VBUSVLDEXTSEL0 ,VBUSVLDEXTSEL0 }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL1 ,VBUSVLDEXT0 ,VBUSVLDEXT0 }, +}; + +static const struct phy_reg_config hs_6nm_phy_post_tuning[] = { + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2 ,VREGBYPASS ,VREGBYPASS }, + {USB2_PHY_USB_PHY_UTMI_CTRL5 ,ATERESET ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_TEST1 ,TESTDATAOUTSEL ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_TEST1 ,TESTCLK ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0 ,VATESTENB_MASK ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_TEST0 ,TESTDATAIN_MASK ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL2 ,USB2_SUSPEND_N_SEL |USB2_SUSPEND_N , +USB2_SUSPEND_N_SEL |USB2_SUSPEND_N }, + {USB2_PHY_USB_PHY_UTMI_CTRL0 ,SLEEPM ,SLEEPM }, + {USB2_PHY_USB_PHY_UTMI_CTRL5 ,POR ,0 }, + {USB2_PHY_USB_PHY_HS_PHY_CTRL2 ,USB2_SUSPEND_N_SEL ,0 }, + {USB2_PHY_USB_PHY_CFG0 ,UTMI_PHY_CMN_CTRL_OVERRIDE_EN ,0 }, +}; +static int qcom_snps_hsphy_init (struct phy *phy) {struct qcom_snps_hsphy *hsphy =phy_get_drvdata (phy);
@@ -512,6 +563,14 @@ static const struct phy_config_data hs_5nm_phy = { .num_post_tuning = ARRAY_SIZE(hs_5nm_phy_post_tuning), }; +static const struct phy_config_data hs_6nm_phy = { + .pre_tuning = hs_6nm_phy_pre_tuning, + .num_pre_tuning =ARRAY_SIZE (hs_6nm_phy_pre_tuning), + .override = ipq9650_snps_6nm_phy, + .post_tuning = hs_6nm_phy_post_tuning, + .num_post_tuning =ARRAY_SIZE (hs_6nm_phy_post_tuning), +}; +static const struct phy_config_data hs_7nm_phy = { .pre_tuning = hs_5nm_phy_pre_tuning, .num_pre_tuning =ARRAY_SIZE (hs_5nm_phy_pre_tuning),
@@ -529,6 +588,10 @@ static const struct of_device_id qcom_snps_hsphy_of_match_table[] = { .compatible = "qcom,usb-snps-hs-5nm-phy", .data = &hs_5nm_phy, }, + { + .compatible = "qcom,ipq9650-usb-hs-phy", + .data = &hs_6nm_phy, + }, { .compatible = "qcom,usb-snps-hs-7nm-phy", .data = &hs_7nm_phy,
Signature · 1 line
2.34.1
Re: [PATCH v6 6/6] phy: qcom: snps-femto-v2: Add IPQ9650 support
Quoted 6 lines · Varadarajan Narayanan
Add the 6 nm SNPS femto USB2 PHY configuration needed by IPQ9650. The PHYs on this SoC require a dedicated init sequence and override parameters before they can be enabled.
Signed-off-by Varadarajan Narayanan <[email protected]>---
Konrad
Quoted 9 lines · Varadarajan Narayanan
This series
- Adds dt-bindings and driver changes for the high speed and super speed phys in IPQ9650.
- IPQ9650 specific init tables to QMP super speed phy driver.
- The Femto high speed phy driver is refactored to accomodate differences in the init sequences between SoCs first and then support for IPQ9650 is included.Signed-off-by Varadarajan Narayanan <[email protected]>
- Mani
Quoted 9 lines · Varadarajan Narayanan
This series
- Adds dt-bindings and driver changes for the high speed and super speed phys in IPQ9650.
- IPQ9650 specific init tables to QMP super speed phy driver.
- The Femto high speed phy driver is refactored to accomodate differences in the init sequences between SoCs first and then support for IPQ9650 is included.[...]
Applied, thanks!
[1/6] dt-bindings: phy: qcom,qmp-usb: Add IPQ9650 USB3 PHY
commit: 883412a4d4fb3267851de3d5d534980d65251ffd
[2/6] dt-bindings: phy: qcom,usb-snps-femto-v2: Add IPQ9650 compatible
commit: f899f404be9a178b3df15edaa2b33a20dd99ae18
[3/6] phy: qcom: qmp-usb: Add IPQ9650 USB3 PHY configuration
commit: a8361bb39e2502aa9edaed126f01e02cd57c45ef
[4/6] phy: qcom: snps-femto-v2: Fix order of arguments to qcom_snps_hsphy_write_mask
commit: 029a4a78d07a4b133777cff2acc404ad858f3aef
[5/6] phy: qcom: snps-femto-v2: Move PHY init registers to config tables
commit: 8238577c08eadbf38313d0240551c12582884014
[6/6] phy: qcom: snps-femto-v2: Add IPQ9650 support
commit: bd2ef9cf141344e31caa50dd3ef46772df7d9b66Best regards,
Signature · 1 line
~Vinod