2424#define EUSB2_FORCE_VAL_5 0xeD
2525#define V_CLK_19P2M_EN BIT(6)
2626
27+ #define EUSB2_TUNE_USB2_CROSSOVER 0x50
2728#define EUSB2_TUNE_IUSB2 0x51
29+ #define EUSB2_TUNE_RES_FSDIF 0x52
30+ #define EUSB2_TUNE_HSDISC 0x53
2831#define EUSB2_TUNE_SQUELCH_U 0x54
32+ #define EUSB2_TUNE_USB2_SLEW 0x55
33+ #define EUSB2_TUNE_USB2_EQU 0x56
2934#define EUSB2_TUNE_USB2_PREEM 0x57
35+ #define EUSB2_TUNE_USB2_HS_COMP_CUR 0x58
36+ #define EUSB2_TUNE_EUSB_SLEW 0x59
37+ #define EUSB2_TUNE_EUSB_EQU 0x5A
38+ #define EUSB2_TUNE_EUSB_HS_COMP_CUR 0x5B
3039
3140#define QCOM_EUSB2_REPEATER_INIT_CFG (r , v ) \
3241 { \
3544 }
3645
3746enum reg_fields {
47+ F_TUNE_EUSB_HS_COMP_CUR ,
48+ F_TUNE_EUSB_EQU ,
49+ F_TUNE_EUSB_SLEW ,
50+ F_TUNE_USB2_HS_COMP_CUR ,
3851 F_TUNE_USB2_PREEM ,
52+ F_TUNE_USB2_EQU ,
53+ F_TUNE_USB2_SLEW ,
3954 F_TUNE_SQUELCH_U ,
55+ F_TUNE_HSDISC ,
56+ F_TUNE_RES_FSDIF ,
4057 F_TUNE_IUSB2 ,
58+ F_TUNE_USB2_CROSSOVER ,
4159 F_NUM_TUNE_FIELDS ,
4260
4361 F_FORCE_VAL_5 = F_NUM_TUNE_FIELDS ,
@@ -50,9 +68,18 @@ enum reg_fields {
5068};
5169
5270static struct reg_field eusb2_repeater_tune_reg_fields [F_NUM_FIELDS ] = {
71+ [F_TUNE_EUSB_HS_COMP_CUR ] = REG_FIELD (EUSB2_TUNE_EUSB_HS_COMP_CUR , 0 , 1 ),
72+ [F_TUNE_EUSB_EQU ] = REG_FIELD (EUSB2_TUNE_EUSB_EQU , 0 , 1 ),
73+ [F_TUNE_EUSB_SLEW ] = REG_FIELD (EUSB2_TUNE_EUSB_SLEW , 0 , 1 ),
74+ [F_TUNE_USB2_HS_COMP_CUR ] = REG_FIELD (EUSB2_TUNE_USB2_HS_COMP_CUR , 0 , 1 ),
5375 [F_TUNE_USB2_PREEM ] = REG_FIELD (EUSB2_TUNE_USB2_PREEM , 0 , 2 ),
76+ [F_TUNE_USB2_EQU ] = REG_FIELD (EUSB2_TUNE_USB2_EQU , 0 , 1 ),
77+ [F_TUNE_USB2_SLEW ] = REG_FIELD (EUSB2_TUNE_USB2_SLEW , 0 , 1 ),
5478 [F_TUNE_SQUELCH_U ] = REG_FIELD (EUSB2_TUNE_SQUELCH_U , 0 , 2 ),
79+ [F_TUNE_HSDISC ] = REG_FIELD (EUSB2_TUNE_HSDISC , 0 , 2 ),
80+ [F_TUNE_RES_FSDIF ] = REG_FIELD (EUSB2_TUNE_RES_FSDIF , 0 , 2 ),
5581 [F_TUNE_IUSB2 ] = REG_FIELD (EUSB2_TUNE_IUSB2 , 0 , 3 ),
82+ [F_TUNE_USB2_CROSSOVER ] = REG_FIELD (EUSB2_TUNE_USB2_CROSSOVER , 0 , 2 ),
5683
5784 [F_FORCE_VAL_5 ] = REG_FIELD (EUSB2_FORCE_VAL_5 , 0 , 7 ),
5885 [F_FORCE_EN_5 ] = REG_FIELD (EUSB2_FORCE_EN_5 , 0 , 7 ),
@@ -62,13 +89,8 @@ static struct reg_field eusb2_repeater_tune_reg_fields[F_NUM_FIELDS] = {
6289 [F_RPTR_STATUS ] = REG_FIELD (EUSB2_RPTR_STATUS , 0 , 7 ),
6390};
6491
65- struct eusb2_repeater_init_tbl {
66- unsigned int reg ;
67- unsigned int val ;
68- };
69-
7092struct eusb2_repeater_cfg {
71- const struct eusb2_repeater_init_tbl * init_tbl ;
93+ const u32 * init_tbl ;
7294 int init_tbl_num ;
7395 const char * const * vreg_list ;
7496 int num_vregs ;
@@ -87,10 +109,10 @@ static const char * const pm8550b_vreg_l[] = {
87109 "vdd18" , "vdd3" ,
88110};
89111
90- static const struct eusb2_repeater_init_tbl pm8550b_init_tbl [] = {
91- QCOM_EUSB2_REPEATER_INIT_CFG ( F_TUNE_IUSB2 , 0x8 ) ,
92- QCOM_EUSB2_REPEATER_INIT_CFG ( F_TUNE_SQUELCH_U , 0x3 ) ,
93- QCOM_EUSB2_REPEATER_INIT_CFG ( F_TUNE_USB2_PREEM , 0x5 ) ,
112+ static const u32 pm8550b_init_tbl [F_NUM_TUNE_FIELDS ] = {
113+ [ F_TUNE_IUSB2 ] = 0x8 ,
114+ [ F_TUNE_SQUELCH_U ] = 0x3 ,
115+ [ F_TUNE_USB2_PREEM ] = 0x5 ,
94116};
95117
96118static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = {
@@ -118,8 +140,9 @@ static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr)
118140
119141static int eusb2_repeater_init (struct phy * phy )
120142{
143+ struct reg_field * regfields = eusb2_repeater_tune_reg_fields ;
121144 struct eusb2_repeater * rptr = phy_get_drvdata (phy );
122- const struct eusb2_repeater_init_tbl * init_tbl = rptr -> cfg -> init_tbl ;
145+ const u32 * init_tbl = rptr -> cfg -> init_tbl ;
123146 u32 val ;
124147 int ret ;
125148 int i ;
@@ -130,9 +153,16 @@ static int eusb2_repeater_init(struct phy *phy)
130153
131154 regmap_field_update_bits (rptr -> regs [F_EN_CTL1 ], EUSB2_RPTR_EN , EUSB2_RPTR_EN );
132155
133- for (i = 0 ; i < rptr -> cfg -> init_tbl_num ; i ++ )
134- regmap_field_update_bits (rptr -> regs [init_tbl [i ].reg ],
135- init_tbl [i ].val , init_tbl [i ].val );
156+ for (i = 0 ; i < F_NUM_TUNE_FIELDS ; i ++ ) {
157+ if (init_tbl [i ]) {
158+ regmap_field_update_bits (rptr -> regs [i ], init_tbl [i ], init_tbl [i ]);
159+ } else {
160+ /* Write 0 if there's no value set */
161+ u32 mask = GENMASK (regfields [i ].msb , regfields [i ].lsb );
162+
163+ regmap_field_update_bits (rptr -> regs [i ], mask , 0 );
164+ }
165+ }
136166
137167 ret = regmap_field_read_poll_timeout (rptr -> regs [F_RPTR_STATUS ],
138168 val , val & RPTR_OK , 10 , 5 );
0 commit comments