24
24
#define EUSB2_FORCE_VAL_5 0xeD
25
25
#define V_CLK_19P2M_EN BIT(6)
26
26
27
+ #define EUSB2_TUNE_USB2_CROSSOVER 0x50
27
28
#define EUSB2_TUNE_IUSB2 0x51
29
+ #define EUSB2_TUNE_RES_FSDIF 0x52
30
+ #define EUSB2_TUNE_HSDISC 0x53
28
31
#define EUSB2_TUNE_SQUELCH_U 0x54
32
+ #define EUSB2_TUNE_USB2_SLEW 0x55
33
+ #define EUSB2_TUNE_USB2_EQU 0x56
29
34
#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
30
39
31
40
#define QCOM_EUSB2_REPEATER_INIT_CFG (r , v ) \
32
41
{ \
35
44
}
36
45
37
46
enum 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 ,
38
51
F_TUNE_USB2_PREEM ,
52
+ F_TUNE_USB2_EQU ,
53
+ F_TUNE_USB2_SLEW ,
39
54
F_TUNE_SQUELCH_U ,
55
+ F_TUNE_HSDISC ,
56
+ F_TUNE_RES_FSDIF ,
40
57
F_TUNE_IUSB2 ,
58
+ F_TUNE_USB2_CROSSOVER ,
41
59
F_NUM_TUNE_FIELDS ,
42
60
43
61
F_FORCE_VAL_5 = F_NUM_TUNE_FIELDS ,
@@ -50,9 +68,18 @@ enum reg_fields {
50
68
};
51
69
52
70
static 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 ),
53
75
[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 ),
54
78
[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 ),
55
81
[F_TUNE_IUSB2 ] = REG_FIELD (EUSB2_TUNE_IUSB2 , 0 , 3 ),
82
+ [F_TUNE_USB2_CROSSOVER ] = REG_FIELD (EUSB2_TUNE_USB2_CROSSOVER , 0 , 2 ),
56
83
57
84
[F_FORCE_VAL_5 ] = REG_FIELD (EUSB2_FORCE_VAL_5 , 0 , 7 ),
58
85
[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] = {
62
89
[F_RPTR_STATUS ] = REG_FIELD (EUSB2_RPTR_STATUS , 0 , 7 ),
63
90
};
64
91
65
- struct eusb2_repeater_init_tbl {
66
- unsigned int reg ;
67
- unsigned int val ;
68
- };
69
-
70
92
struct eusb2_repeater_cfg {
71
- const struct eusb2_repeater_init_tbl * init_tbl ;
93
+ const u32 * init_tbl ;
72
94
int init_tbl_num ;
73
95
const char * const * vreg_list ;
74
96
int num_vregs ;
@@ -87,10 +109,10 @@ static const char * const pm8550b_vreg_l[] = {
87
109
"vdd18" , "vdd3" ,
88
110
};
89
111
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 ,
94
116
};
95
117
96
118
static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = {
@@ -118,8 +140,9 @@ static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr)
118
140
119
141
static int eusb2_repeater_init (struct phy * phy )
120
142
{
143
+ struct reg_field * regfields = eusb2_repeater_tune_reg_fields ;
121
144
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 ;
123
146
u32 val ;
124
147
int ret ;
125
148
int i ;
@@ -130,9 +153,16 @@ static int eusb2_repeater_init(struct phy *phy)
130
153
131
154
regmap_field_update_bits (rptr -> regs [F_EN_CTL1 ], EUSB2_RPTR_EN , EUSB2_RPTR_EN );
132
155
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
+ }
136
166
137
167
ret = regmap_field_read_poll_timeout (rptr -> regs [F_RPTR_STATUS ],
138
168
val , val & RPTR_OK , 10 , 5 );
0 commit comments