Introduce QCS615 hardware-specific configuration for DP PHY mode,
including register offsets, initialization tables, voltage swing
and pre-emphasis settings, and regulator definitions.

Signed-off-by: Xiangxu Yin <[email protected]>
---
 drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 148 +++++++++++++++++++++++++++++++
 1 file changed, 148 insertions(+)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c 
b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
index 
bc0eaa7dba9cb84b54c7c5a264aac613f888cb99..aefcc520ee0bb3dd116e58222e5e035d1d750714
 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c
@@ -28,6 +28,9 @@
 #include "phy-qcom-qmp.h"
 #include "phy-qcom-qmp-pcs-misc-v3.h"
 
+#include "phy-qcom-qmp-dp-phy.h"
+#include "phy-qcom-qmp-dp-phy-v3.h"
+
 #define PHY_INIT_COMPLETE_TIMEOUT              10000
 #define SW_PORTSELECT_VAL                      BIT(0)
 #define SW_PORTSELECT_MUX                      BIT(1)
@@ -286,6 +289,86 @@ static const struct qmp_phy_init_tbl 
qcm2290_usb3_pcs_tbl[] = {
        QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x88),
 };
 
+static const struct qmp_phy_init_tbl qcs615_qmp_dp_serdes_tbl[] = {
+       QMP_PHY_INIT_CFG(QSERDES_COM_SVS_MODE_CLK_SEL, 0x01),
+       QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x37),
+       QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_SYS_CLK_CTRL, 0x06),
+       QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x3f),
+       QMP_PHY_INIT_CFG(QSERDES_COM_CLK_ENABLE1, 0x0e),
+       QMP_PHY_INIT_CFG(QSERDES_COM_BG_CTRL, 0x0f),
+       QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_BUF_ENABLE, 0x06),
+       QMP_PHY_INIT_CFG(QSERDES_COM_CLK_SELECT, 0x30),
+       QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0x0f),
+       QMP_PHY_INIT_CFG(QSERDES_COM_PLL_CCTRL_MODE0, 0x28),
+       QMP_PHY_INIT_CFG(QSERDES_COM_PLL_RCTRL_MODE0, 0x16),
+       QMP_PHY_INIT_CFG(QSERDES_COM_CP_CTRL_MODE0, 0x0b),
+       QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x40),
+       QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_BG_TIMER, 0x08),
+       QMP_PHY_INIT_CFG(QSERDES_COM_CORECLK_DIV, 0x05),
+       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE1_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE2_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_CORE_CLK_EN, 0x0f),
+       QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x02),
+};
+
+static const struct qmp_phy_init_tbl qcs615_qmp_dp_serdes_tbl_rbr[] = {
+       QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x2c),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x69),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x80),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x07),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0xbf),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x21),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0xc6),
+};
+
+static const struct qmp_phy_init_tbl qcs615_qmp_dp_serdes_tbl_hbr[] = {
+       QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x24),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x69),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x80),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x07),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x3f),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x38),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0xc4),
+};
+
+static const struct qmp_phy_init_tbl qcs615_qmp_dp_serdes_tbl_hbr2[] = {
+       QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x20),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DEC_START_MODE0, 0x8c),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START1_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START2_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_COM_DIV_FRAC_START3_MODE0, 0x0a),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP1_MODE0, 0x7f),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP2_MODE0, 0x70),
+       QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP3_MODE0, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0xc4),
+};
+
+static const struct qmp_phy_init_tbl qcs615_qmp_dp_tx_tbl[] = {
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_TRANSCEIVER_BIAS_EN, 0x1a),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_VMODE_CTRL1, 0x40),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_INTERFACE_SELECT, 0x3d),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_CLKBUF_ENABLE, 0x0f),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_RESET_TSYNC_EN, 0x03),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_TRAN_DRVR_EMP_EN, 0x03),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_INTERFACE_MODE, 0x00),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_EMP_POST1_LVL, 0x2b),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_DRV_LVL, 0x2f),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_TX_BAND, 0x4),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x12),
+       QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_RX, 0x12),
+};
+
 enum qmp_phy_usbc_type {
        QMP_PHY_USBC_USB,
        QMP_PHY_USBC_DP,
@@ -469,11 +552,20 @@ static const char * const usb3phy_reset_l[] = {
        "phy_phy", "phy",
 };
 
+static const char * const dpphy_reset_l[] = {
+       "phy",
+};
+
 /* list of regulators */
 static const char * const qmp_phy_usb_vreg_l[] = {
        "vdda-phy", "vdda-pll",
 };
 
+static struct qmp_regulator_data qmp_phy_dp_vreg_l[] = {
+       { .name = "vdda-phy", .enable_load = 21800 },
+       { .name = "vdda-pll", .enable_load = 36000 },
+};
+
 static const struct qmp_usbc_usb_offsets qmp_usbc_usb_offsets_v3_qcm2290 = {
        .serdes         = 0x0,
        .pcs            = 0xc00,
@@ -484,6 +576,27 @@ static const struct qmp_usbc_usb_offsets 
qmp_usbc_usb_offsets_v3_qcm2290 = {
        .rx2            = 0x800,
 };
 
+static const struct qmp_usbc_dp_offsets qmp_usbc_dp_offsets_qcs615 = {
+       .dp_serdes      = 0x0c00,
+       .dp_txa         = 0x0400,
+       .dp_txb         = 0x0800,
+       .dp_phy         = 0x0000,
+};
+
+static const u8 qmp_dp_pre_emphasis_hbr2_rbr[4][4] = {
+       {0x00, 0x0b, 0x12, 0xff},
+       {0x00, 0x0a, 0x12, 0xff},
+       {0x00, 0x0c, 0xff, 0xff},
+       {0xff, 0xff, 0xff, 0xff}
+};
+
+static const u8 qmp_dp_voltage_swing_hbr2_rbr[4][4] = {
+       {0x07, 0x0f, 0x14, 0xff},
+       {0x11, 0x1d, 0x1f, 0xff},
+       {0x18, 0x1f, 0xff, 0xff},
+       {0xff, 0xff, 0xff, 0xff}
+};
+
 static const struct qmp_phy_usb_cfg msm8998_usb3phy_cfg = {
        .offsets                = &qmp_usbc_usb_offsets_v3_qcm2290,
 
@@ -532,6 +645,28 @@ static const struct qmp_phy_usb_cfg sdm660_usb3phy_cfg = {
        .regs                   = qmp_v3_usb3phy_regs_layout_qcm2290,
 };
 
+static const struct qmp_phy_dp_cfg qcs615_dpphy_cfg = {
+       .offsets                = &qmp_usbc_dp_offsets_qcs615,
+
+       .dp_serdes_tbl          = qcs615_qmp_dp_serdes_tbl,
+       .dp_serdes_tbl_num      = ARRAY_SIZE(qcs615_qmp_dp_serdes_tbl),
+       .dp_tx_tbl              = qcs615_qmp_dp_tx_tbl,
+       .dp_tx_tbl_num          = ARRAY_SIZE(qcs615_qmp_dp_tx_tbl),
+
+       .serdes_tbl_rbr         = qcs615_qmp_dp_serdes_tbl_rbr,
+       .serdes_tbl_rbr_num     = ARRAY_SIZE(qcs615_qmp_dp_serdes_tbl_rbr),
+       .serdes_tbl_hbr         = qcs615_qmp_dp_serdes_tbl_hbr,
+       .serdes_tbl_hbr_num     = ARRAY_SIZE(qcs615_qmp_dp_serdes_tbl_hbr),
+       .serdes_tbl_hbr2        = qcs615_qmp_dp_serdes_tbl_hbr2,
+       .serdes_tbl_hbr2_num    = ARRAY_SIZE(qcs615_qmp_dp_serdes_tbl_hbr2),
+
+       .swing_tbl              = &qmp_dp_voltage_swing_hbr2_rbr,
+       .pre_emphasis_tbl       = &qmp_dp_pre_emphasis_hbr2_rbr,
+
+       .vreg_list              = qmp_phy_dp_vreg_l,
+       .num_vregs              = ARRAY_SIZE(qmp_phy_dp_vreg_l),
+};
+
 static const struct qmp_phy_cfg msm8998_phy_usb3_cfg = {
        .type = QMP_PHY_USBC_USB,
        .cfg = &msm8998_usb3phy_cfg,
@@ -565,6 +700,10 @@ static int qmp_usbc_generic_init(struct phy *phy)
 
                num_vregs = cfg->num_vregs;
                reg_pwr_dn = cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL];
+       } else {
+               struct qmp_phy_dp_cfg *cfg = to_dp_cfg(qmp);
+
+               num_vregs = cfg->num_vregs;
        }
 
        ret = regulator_bulk_enable(num_vregs, qmp->vregs);
@@ -599,6 +738,9 @@ static int qmp_usbc_generic_init(struct phy *phy)
 
                qphy_setbits(layout->pcs, reg_pwr_dn, SW_PWRDN);
                writel(val, layout->pcs_misc);
+       } else {
+               if (qmp->tcsr_map && qmp->dp_phy_mode_reg)
+                       regmap_write(qmp->tcsr_map, qmp->dp_phy_mode_reg, 1);
        }
 
        return 0;
@@ -624,6 +766,12 @@ static int qmp_usbc_generic_exit(struct phy *phy)
                struct qmp_phy_usb_cfg *cfg = to_usb_cfg(qmp);
 
                num_vregs = cfg->num_vregs;
+       } else {
+               struct qmp_phy_dp_cfg *cfg = to_dp_cfg(qmp);
+
+               num_vregs = cfg->num_vregs;
+               if (qmp->tcsr_map && qmp->dp_phy_mode_reg)
+                       regmap_write(qmp->tcsr_map, qmp->dp_phy_mode_reg, 0);
        }
        regulator_bulk_disable(num_vregs, qmp->vregs);
 

-- 
2.34.1

Reply via email to