| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <timer.h> |
| 5 |
#include <delay.h> |
| 6 |
#include <soc/usb/qmp_usb_phy.h> |
| 7 |
#include <soc/addressmap.h> |
| 8 |
|
| 9 |
|
| 10 |
struct usb3_phy_qserdes_com_reg_layout { |
| 11 |
u32 com_ssc_step_size1_mode1; |
| 12 |
u32 com_ssc_step_size2_mode1; |
| 13 |
u32 com_ssc_step_size3_mode1; |
| 14 |
u32 com_clk_ep_div_mode1; |
| 15 |
u32 com_cp_ctrl_mode1; |
| 16 |
u32 com_pll_rctrl_mode1; |
| 17 |
u32 com_pll_cctrl_mode1; |
| 18 |
u32 com_coreclk_div_mode1; |
| 19 |
u32 com_lock_cmp1_mode1; |
| 20 |
u32 com_lock_cmp2_mode1; |
| 21 |
u32 com_dec_start_mode1; |
| 22 |
u32 com_dec_start_msb_mode1; |
| 23 |
u32 com_div_frac_start1_mode1; |
| 24 |
u32 com_div_frac_start2_mode1; |
| 25 |
u32 com_div_frac_start3_mode1; |
| 26 |
u32 com_hsclk_sel_1; |
| 27 |
u32 com_integloop_gain0_mode1; |
| 28 |
u32 com_integloop_gain1_mode1; |
| 29 |
u32 com_vco_tune1_mode1; |
| 30 |
u32 com_vco_tune2_mode1; |
| 31 |
u32 com_bin_vcocal_cmp_code1_mode1; |
| 32 |
u32 com_bin_vcocal_cmp_code2_mode1; |
| 33 |
u32 com_bin_vcocal_cmp_code1_mode0; |
| 34 |
u32 com_bin_vcocal_cmp_code2_mode0; |
| 35 |
u32 com_ssc_step_size1_mode0; |
| 36 |
u32 com_ssc_step_size2_mode0; |
| 37 |
u32 com_ssc_step_size3_mode0; |
| 38 |
u32 com_clk_ep_div_mode0; |
| 39 |
u32 com_cp_ctrl_mode0; |
| 40 |
u32 com_pll_rctrl_mode0; |
| 41 |
u32 com_pll_cctrl_mode0; |
| 42 |
u32 com_coreclk_div_mode0; |
| 43 |
u32 com_lock_cmp1_mode0; |
| 44 |
u32 com_lock_cmp2_mode0; |
| 45 |
u32 com_dec_start_mode0; |
| 46 |
u32 com_dec_start_msb_mode0; |
| 47 |
u32 com_div_frac_start1_mode0; |
| 48 |
u32 com_div_frac_start2_mode0; |
| 49 |
u32 com_div_frac_start3_mode0; |
| 50 |
u32 com_hsclk_hs_switch_sel_1; |
| 51 |
u32 com_integloop_gain0_mode0; |
| 52 |
u32 com_integloop_gain1_mode0; |
| 53 |
u32 com_vco_tune1_mode0; |
| 54 |
u32 com_vco_tune2_mode0; |
| 55 |
u32 com_atb_sel1; |
| 56 |
u32 com_atb_sel2; |
| 57 |
u32 com_freq_update; |
| 58 |
u32 com_bg_timer; |
| 59 |
u32 com_ssc_en_center; |
| 60 |
u32 com_ssc_adj_per1; |
| 61 |
u32 com_ssc_adj_per2; |
| 62 |
u32 com_ssc_per1; |
| 63 |
u32 com_ssc_per2; |
| 64 |
u8 _reserved1[20]; |
| 65 |
u32 com_sysclk_buf_enable; |
| 66 |
u8 _reserved2[36]; |
| 67 |
u32 com_sysclk_en_sel; |
| 68 |
u8 _reserved3[16]; |
| 69 |
u32 com_lock_cmp_cfg; |
| 70 |
u8 _reserved4[24]; |
| 71 |
u32 com_vco_tune_map; |
| 72 |
u8 _reserved5[44]; |
| 73 |
u32 com_core_clk_en; |
| 74 |
u32 com_cmn_config_1; |
| 75 |
u8 _reserved6[44]; |
| 76 |
u32 com_auto_gain_adj_ctrl_1; |
| 77 |
u32 com_auto_gain_adj_ctrl_2; |
| 78 |
u32 com_auto_gain_adj_ctrl_3; |
| 79 |
u32 com_auto_gain_adj_ctrl_4; |
| 80 |
u32 com_additional_misc; |
| 81 |
}; |
| 82 |
|
| 83 |
check_member(usb3_phy_qserdes_com_reg_layout, com_ssc_step_size1_mode1, 0x00); |
| 84 |
check_member(usb3_phy_qserdes_com_reg_layout, com_sysclk_buf_enable, 0xe8); |
| 85 |
check_member(usb3_phy_qserdes_com_reg_layout, com_sysclk_en_sel, 0x110); |
| 86 |
check_member(usb3_phy_qserdes_com_reg_layout, com_lock_cmp_cfg, 0x124); |
| 87 |
check_member(usb3_phy_qserdes_com_reg_layout, com_integloop_gain0_mode0, 0x0a0); |
| 88 |
check_member(usb3_phy_qserdes_com_reg_layout, com_vco_tune_map, 0x0140); |
| 89 |
check_member(usb3_phy_qserdes_com_reg_layout, com_core_clk_en, 0x170); |
| 90 |
check_member(usb3_phy_qserdes_com_reg_layout, com_auto_gain_adj_ctrl_1, 0x1a4); |
| 91 |
|
| 92 |
|
| 93 |
struct usb3_phy_qserdes_tx_reg_layout { |
| 94 |
u8 _reserved1[52]; |
| 95 |
u32 tx_res_code_lane_tx; |
| 96 |
u32 tx_res_code_lane_rx; |
| 97 |
u32 tx_res_code_lane_offset_tx; |
| 98 |
u32 tx_res_code_lane_offset_rx; |
| 99 |
u8 _reserved2[64]; |
| 100 |
u32 tx_lane_mode_1; |
| 101 |
u32 tx_lane_mode_2; |
| 102 |
u32 tx_lane_mode_3; |
| 103 |
u32 tx_lane_mode_4; |
| 104 |
u32 tx_lane_mode_5; |
| 105 |
u8 _reserved3[12]; |
| 106 |
u32 tx_rcv_detect_lvl_2; |
| 107 |
u8 _reserved4[60]; |
| 108 |
u32 tx_pi_qec_ctrl; |
| 109 |
}; |
| 110 |
check_member(usb3_phy_qserdes_tx_reg_layout, tx_res_code_lane_tx, 0x034); |
| 111 |
check_member(usb3_phy_qserdes_tx_reg_layout, tx_lane_mode_1, 0x084); |
| 112 |
check_member(usb3_phy_qserdes_tx_reg_layout, tx_rcv_detect_lvl_2, 0x0a4); |
| 113 |
check_member(usb3_phy_qserdes_tx_reg_layout, tx_pi_qec_ctrl, 0x0e4); |
| 114 |
|
| 115 |
|
| 116 |
struct usb3_phy_qserdes_rx_reg_layout { |
| 117 |
u8 _reserved1[8]; |
| 118 |
u32 rx_ucdr_fo_gain; |
| 119 |
u8 _reserved2[8]; |
| 120 |
u32 rx_ucdr_so_gain; |
| 121 |
u8 _reserved3[24]; |
| 122 |
u32 rx_ucdr_fastlock_fo_gain; |
| 123 |
u32 rx_ucdr_so_saturation_and_enable; |
| 124 |
u32 rx_ucdr_fo_to_so_delay; |
| 125 |
u32 rx_ucdr_fastlock_count_low; |
| 126 |
u32 rx_ucdr_fastlock_count_high; |
| 127 |
u32 rx_ucdr_pi_controls; |
| 128 |
u32 rx_ucdr_pi_ctrl2; |
| 129 |
u32 rx_ucdr_sb2_thresh1; |
| 130 |
u32 rx_ucdr_sb2_thresh2; |
| 131 |
u32 rx_ucdr_sb2_gain1; |
| 132 |
u32 rx_ucdr_sb2_gain2; |
| 133 |
u32 rx_aux_control; |
| 134 |
u32 rx_aux_data_tcoarse_tfine; |
| 135 |
u8 _reserved4[112]; |
| 136 |
u32 rx_vga_cal_cntrl1; |
| 137 |
u32 rx_vga_cal_cntrl2; |
| 138 |
u32 rx_gm_cal; |
| 139 |
u8 _reserved5[12]; |
| 140 |
u32 rx_rx_equ_adaptor_cntrl2; |
| 141 |
u32 rx_rx_equ_adaptor_cntrl3; |
| 142 |
u32 rx_rx_equ_adaptor_cntrl4; |
| 143 |
u32 rx_rx_idac_tsettle_low; |
| 144 |
u32 rx_rx_idac_tsettle_high; |
| 145 |
u8 _reserved6[16]; |
| 146 |
u32 rx_rx_eq_offset_adaptor_cntrl1; |
| 147 |
u32 rx_rx_offset_adaptor_cntrl2; |
| 148 |
u32 rx_sigdet_enables; |
| 149 |
u32 rx_sigdet_cntrl; |
| 150 |
u32 rx_sigdet_lvl; |
| 151 |
u32 rx_sigdet_deglitch_cntrl; |
| 152 |
u8 _reserved7[52]; |
| 153 |
u32 rx_rx_mode_00_low; |
| 154 |
u32 rx_rx_mode_00_high; |
| 155 |
u32 rx_rx_mode_00_high2; |
| 156 |
u32 rx_rx_mode_00_high3; |
| 157 |
u32 rx_rx_mode_00_high4; |
| 158 |
u32 rx_rx_mode_01_low; |
| 159 |
u32 rx_rx_mode_01_high; |
| 160 |
u32 rx_rx_mode_01_high2; |
| 161 |
u32 rx_rx_mode_01_high3; |
| 162 |
u32 rx_rx_mode_01_high4; |
| 163 |
u32 rx_rx_mode_10_low; |
| 164 |
u32 rx_rx_mode_10_high; |
| 165 |
u32 rx_rx_mode_10_high2; |
| 166 |
u32 rx_rx_mode_10_high3; |
| 167 |
u32 rx_rx_mode_10_high4; |
| 168 |
u8 _reserved8[8]; |
| 169 |
u32 rx_dfe_en_timer; |
| 170 |
u32 rx_dfe_ctle_post_cal_offset; |
| 171 |
u32 rx_dcc_ctrl1; |
| 172 |
u32 rx_dcc_ctrl2; |
| 173 |
u32 rx_vth_code; |
| 174 |
u8 _reserved9[48]; |
| 175 |
u32 rx_sigdet_cal_ctrl1; |
| 176 |
u8 _reserved10[16]; |
| 177 |
u32 rx_sigdet_cal_trim; |
| 178 |
}; |
| 179 |
|
| 180 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_ucdr_so_gain, 0x014); |
| 181 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_ucdr_fastlock_fo_gain, 0x030); |
| 182 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_vga_cal_cntrl1, 0x0d4); |
| 183 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_rx_equ_adaptor_cntrl2, 0x0ec); |
| 184 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_rx_equ_adaptor_cntrl3, 0x0f0); |
| 185 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_rx_equ_adaptor_cntrl4, 0x0f4); |
| 186 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_rx_eq_offset_adaptor_cntrl1, 0x110); |
| 187 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_sigdet_cntrl, 0x11c); |
| 188 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_00_low, 0x15c); |
| 189 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_dfe_en_timer, 0x1a0); |
| 190 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_dcc_ctrl1, 0x1a8); |
| 191 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_vth_code, 0x1b0); |
| 192 |
check_member(usb3_phy_qserdes_rx_reg_layout, rx_sigdet_cal_trim, 0x1f8); |
| 193 |
|
| 194 |
|
| 195 |
struct usb3_phy_pcs_reg_layout { |
| 196 |
u32 pcs_sw_reset; |
| 197 |
u8 _reserved1[16]; |
| 198 |
u32 pcs_pcs_status1; |
| 199 |
u8 _reserved2[40]; |
| 200 |
u32 pcs_power_down_control; |
| 201 |
u32 pcs_start_control; |
| 202 |
u8 _reserved3[124]; |
| 203 |
u32 pcs_lock_detect_config1; |
| 204 |
u32 pcs_lock_detect_config2; |
| 205 |
u32 pcs_lock_detect_config3; |
| 206 |
u8 _reserved4[8]; |
| 207 |
u32 pcs_lock_detect_config6; |
| 208 |
u32 pcs_refgen_req_config1; |
| 209 |
u8 _reserved5[168]; |
| 210 |
u32 pcs_rx_sigdet_lvl; |
| 211 |
u8 _reserved6[4]; |
| 212 |
u32 pcs_rcvr_dtct_dly_p1u2_l; |
| 213 |
u32 pcs_rcvr_dtct_dly_p1u2_h; |
| 214 |
u8 _reserved7[24]; |
| 215 |
u32 pcs_cdr_reset_time; |
| 216 |
u8 _reserved8[12]; |
| 217 |
u32 pcs_align_detect_config1; |
| 218 |
u32 pcs_align_detect_config2; |
| 219 |
u8 _reserved9[8]; |
| 220 |
u32 pcs_pcs_tx_rx_config; |
| 221 |
u8 _reserved10[8]; |
| 222 |
u32 pcs_eq_config1; |
| 223 |
u8 _reserved11[12]; |
| 224 |
u32 pcs_eq_config5; |
| 225 |
}; |
| 226 |
|
| 227 |
check_member(usb3_phy_pcs_reg_layout, pcs_pcs_status1, 0x014); |
| 228 |
check_member(usb3_phy_pcs_reg_layout, pcs_power_down_control, 0x040); |
| 229 |
check_member(usb3_phy_pcs_reg_layout, pcs_lock_detect_config1, 0x0c4); |
| 230 |
check_member(usb3_phy_pcs_reg_layout, pcs_lock_detect_config6, 0x0d8); |
| 231 |
check_member(usb3_phy_pcs_reg_layout, pcs_rx_sigdet_lvl, 0x188); |
| 232 |
check_member(usb3_phy_pcs_reg_layout, pcs_cdr_reset_time, 0x1b0); |
| 233 |
check_member(usb3_phy_pcs_reg_layout, pcs_align_detect_config1, 0x1c0); |
| 234 |
check_member(usb3_phy_pcs_reg_layout, pcs_pcs_tx_rx_config, 0x1d0); |
| 235 |
check_member(usb3_phy_pcs_reg_layout, pcs_eq_config1, 0x1dc); |
| 236 |
check_member(usb3_phy_pcs_reg_layout, pcs_eq_config5, 0x1ec); |
| 237 |
|
| 238 |
|
| 239 |
struct usb3_phy_pcs_usb3_reg_layout { |
| 240 |
u32 reserved[6]; |
| 241 |
u32 pcs_usb3_lfps_det_high_count_val; |
| 242 |
u32 reserved1[8]; |
| 243 |
u32 pcs_usb3_rxeqtraining_dfe_time_s2; |
| 244 |
u32 pcs_usb3_rcvr_dtct_dly_u3_l; |
| 245 |
u32 pcs_usb3_rcvr_dtct_dly_u3_h; |
| 246 |
}; |
| 247 |
|
| 248 |
|
| 249 |
static const qmp_phy_init_tbl_t qmp_v4_usb3_serdes_tbl[] = { |
| 250 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_ssc_step_size1_mode1), 0xc0}, |
| 251 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_ssc_step_size2_mode1), 0x01}, |
| 252 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_cp_ctrl_mode1), 0x02}, |
| 253 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_pll_rctrl_mode1), 0x16}, |
| 254 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_pll_cctrl_mode1), 0x36}, |
| 255 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_coreclk_div_mode1), 0x04}, |
| 256 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_lock_cmp1_mode1), 0x16}, |
| 257 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_lock_cmp2_mode1), 0x41}, |
| 258 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_dec_start_mode1), 0x41}, |
| 259 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_div_frac_start1_mode1), 0x55}, |
| 260 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_div_frac_start2_mode1), 0x75}, |
| 261 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_div_frac_start3_mode1), 0x01}, |
| 262 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_hsclk_sel_1), 0x01}, |
| 263 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_vco_tune1_mode1), 0x25}, |
| 264 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_vco_tune2_mode1), 0x02}, |
| 265 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_bin_vcocal_cmp_code1_mode1), 0x5c}, |
| 266 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_bin_vcocal_cmp_code2_mode1), 0x0f}, |
| 267 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_bin_vcocal_cmp_code1_mode0), 0x5c}, |
| 268 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_bin_vcocal_cmp_code2_mode0), 0x0f}, |
| 269 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_ssc_step_size1_mode0), 0xc0}, |
| 270 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_ssc_step_size2_mode0), 0x01}, |
| 271 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_cp_ctrl_mode0), 0x02}, |
| 272 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_pll_rctrl_mode0), 0x16}, |
| 273 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_pll_cctrl_mode0), 0x36}, |
| 274 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_lock_cmp1_mode0), 0x08}, |
| 275 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_lock_cmp2_mode0), 0x1a}, |
| 276 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_dec_start_mode0), 0x41}, |
| 277 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_div_frac_start1_mode0), 0x55}, |
| 278 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_div_frac_start2_mode0), 0x75}, |
| 279 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_div_frac_start3_mode0), 0x01}, |
| 280 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_vco_tune1_mode0), 0x25}, |
| 281 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_vco_tune2_mode0), 0x02}, |
| 282 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_bg_timer), 0x0a}, |
| 283 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_ssc_en_center), 0x01}, |
| 284 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_ssc_per1), 0x62}, |
| 285 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_ssc_per2), 0x02}, |
| 286 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_sysclk_buf_enable), 0x0a}, |
| 287 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_sysclk_en_sel), 0x1a}, |
| 288 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_lock_cmp_cfg), 0x14}, |
| 289 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_vco_tune_map), 0x04}, |
| 290 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_core_clk_en), 0x20}, |
| 291 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_cmn_config_1), 0x16}, |
| 292 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_auto_gain_adj_ctrl_1), 0xb6}, |
| 293 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_auto_gain_adj_ctrl_2), 0x4b}, |
| 294 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_auto_gain_adj_ctrl_3), 0x37}, |
| 295 |
{(u32)offsetof(struct usb3_phy_qserdes_com_reg_layout, com_additional_misc), 0x0c}, |
| 296 |
}; |
| 297 |
|
| 298 |
static const qmp_phy_init_tbl_t qmp_v4_usb3_tx_tbl[] = { |
| 299 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_res_code_lane_tx), 0x00}, |
| 300 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_res_code_lane_rx), 0x00}, |
| 301 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_res_code_lane_offset_tx), 0x1f}, |
| 302 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_res_code_lane_offset_rx), 0x09}, |
| 303 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_lane_mode_1), 0xf5}, |
| 304 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_lane_mode_3), 0x3f}, |
| 305 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_lane_mode_4), 0x3f}, |
| 306 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_lane_mode_5), 0x5f}, |
| 307 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_rcv_detect_lvl_2), 0x12}, |
| 308 |
{(u32)offsetof(struct usb3_phy_qserdes_tx_reg_layout, tx_pi_qec_ctrl), 0x21}, |
| 309 |
}; |
| 310 |
|
| 311 |
static const qmp_phy_init_tbl_t qmp_v4_usb3_rx_tbl[] = { |
| 312 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_fo_gain), 0x0a}, |
| 313 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_so_gain), 0x06}, |
| 314 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_fastlock_fo_gain), 0x2f}, |
| 315 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_so_saturation_and_enable), 0x7f}, |
| 316 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_fastlock_count_low), 0xff}, |
| 317 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_fastlock_count_high), 0x0f}, |
| 318 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_pi_controls), 0x99}, |
| 319 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_sb2_thresh1), 0x08}, |
| 320 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_sb2_thresh2), 0x08}, |
| 321 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_sb2_gain1), 0x00}, |
| 322 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_ucdr_sb2_gain2), 0x0a}, |
| 323 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_aux_data_tcoarse_tfine), 0xa0}, |
| 324 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_vga_cal_cntrl1), 0x54}, |
| 325 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_vga_cal_cntrl2), 0x0f}, |
| 326 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_gm_cal), 0x13}, |
| 327 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_equ_adaptor_cntrl2), 0x0f}, |
| 328 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_equ_adaptor_cntrl3), 0x4a}, |
| 329 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_equ_adaptor_cntrl4), 0x0a}, |
| 330 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_idac_tsettle_low), 0x07}, |
| 331 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_idac_tsettle_high), 0x00}, |
| 332 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_eq_offset_adaptor_cntrl1), 0x47}, |
| 333 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_sigdet_cntrl), 0x04}, |
| 334 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_sigdet_deglitch_cntrl), 0x0e}, |
| 335 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_00_low), 0x3f}, |
| 336 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_00_high), 0xbf}, |
| 337 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_00_high2), 0xff}, |
| 338 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_00_high3), 0xdf}, |
| 339 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_00_high4), 0xed}, |
| 340 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_01_low), 0xdc}, |
| 341 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_01_high), 0x5c}, |
| 342 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_01_high2), 0x9c}, |
| 343 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_01_high3), 0x1d}, |
| 344 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_rx_mode_01_high4), 0x09}, |
| 345 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_dfe_en_timer), 0x04}, |
| 346 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_dfe_ctle_post_cal_offset), 0x38}, |
| 347 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_dcc_ctrl1), 0x0c}, |
| 348 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_vth_code), 0x10}, |
| 349 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_sigdet_cal_ctrl1), 0x14}, |
| 350 |
{(u32)offsetof(struct usb3_phy_qserdes_rx_reg_layout, rx_sigdet_cal_trim), 0x08}, |
| 351 |
}; |
| 352 |
|
| 353 |
static const qmp_phy_init_tbl_t qmp_v4_usb3_pcs_tbl[] = { |
| 354 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_lock_detect_config1), 0xc4}, |
| 355 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_lock_detect_config2), 0x89}, |
| 356 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_lock_detect_config3), 0x20}, |
| 357 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_lock_detect_config6), 0x13}, |
| 358 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_refgen_req_config1), 0x21}, |
| 359 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_rx_sigdet_lvl), 0xaa}, |
| 360 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_rcvr_dtct_dly_p1u2_l), 0xe7}, |
| 361 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_rcvr_dtct_dly_p1u2_h), 0x03}, |
| 362 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_cdr_reset_time), 0x0a}, |
| 363 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_align_detect_config1), 0x88}, |
| 364 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_align_detect_config2), 0x13}, |
| 365 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_pcs_tx_rx_config), 0x0c}, |
| 366 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_eq_config1), 0x4b}, |
| 367 |
{(u32)offsetof(struct usb3_phy_pcs_reg_layout, pcs_eq_config5), 0x10}, |
| 368 |
}; |
| 369 |
|
| 370 |
static const qmp_phy_init_tbl_t qmp_v4_usb3_pcs_usb3_tbl[] = { |
| 371 |
{(u32)offsetof(struct usb3_phy_pcs_usb3_reg_layout, pcs_usb3_lfps_det_high_count_val), 0xf8}, |
| 372 |
{(u32)offsetof(struct usb3_phy_pcs_usb3_reg_layout, pcs_usb3_rxeqtraining_dfe_time_s2), 0x07}, |
| 373 |
{(u32)offsetof(struct usb3_phy_pcs_usb3_reg_layout, pcs_usb3_rcvr_dtct_dly_u3_l), 0x40}, |
| 374 |
{(u32)offsetof(struct usb3_phy_pcs_usb3_reg_layout, pcs_usb3_rcvr_dtct_dly_u3_h), 0x00}, |
| 375 |
}; |
| 376 |
|
| 377 |
|
| 378 |
static const struct ss_usb_phy_reg qmp_phy_instances[] = { |
| 379 |
{ |
| 380 |
.com_base = (void *)QMP_PHY_MP0_QSERDES_COM_REG_BASE, |
| 381 |
.tx_base = (void *)QMP_PHY_MP0_QSERDES_TX_REG_BASE, |
| 382 |
.rx_base = (void *)QMP_PHY_MP0_QSERDES_RX_REG_BASE, |
| 383 |
.pcs_base = (void *)QMP_PHY_MP0_PCS_REG_BASE, |
| 384 |
.pcs_usb3_base = (void *)QMP_PHY_MP0_PCS_USB3_REG_BASE, |
| 385 |
.name = "MP0", |
| 386 |
.serdes_tbl = qmp_v4_usb3_serdes_tbl, |
| 387 |
.serdes_tbl_num = ARRAY_SIZE(qmp_v4_usb3_serdes_tbl), |
| 388 |
.tx_tbl = qmp_v4_usb3_tx_tbl, |
| 389 |
.tx_tbl_num = ARRAY_SIZE(qmp_v4_usb3_tx_tbl), |
| 390 |
.rx_tbl = qmp_v4_usb3_rx_tbl, |
| 391 |
.rx_tbl_num = ARRAY_SIZE(qmp_v4_usb3_rx_tbl), |
| 392 |
.pcs_tbl = qmp_v4_usb3_pcs_tbl, |
| 393 |
.pcs_tbl_num = ARRAY_SIZE(qmp_v4_usb3_pcs_tbl), |
| 394 |
.pcs_usb3_tbl = qmp_v4_usb3_pcs_usb3_tbl, |
| 395 |
.pcs_usb3_tbl_num = ARRAY_SIZE(qmp_v4_usb3_pcs_usb3_tbl), |
| 396 |
}, |
| 397 |
{ |
| 398 |
.com_base = (void *)QMP_PHY_MP1_QSERDES_COM_REG_BASE, |
| 399 |
.tx_base = (void *)QMP_PHY_MP1_QSERDES_TX_REG_BASE, |
| 400 |
.rx_base = (void *)QMP_PHY_MP1_QSERDES_RX_REG_BASE, |
| 401 |
.pcs_base = (void *)QMP_PHY_MP1_PCS_REG_BASE, |
| 402 |
.pcs_usb3_base = (void *)QMP_PHY_MP1_PCS_USB3_REG_BASE, |
| 403 |
.name = "MP1", |
| 404 |
.serdes_tbl = qmp_v4_usb3_serdes_tbl, |
| 405 |
.serdes_tbl_num = ARRAY_SIZE(qmp_v4_usb3_serdes_tbl), |
| 406 |
.tx_tbl = qmp_v4_usb3_tx_tbl, |
| 407 |
.tx_tbl_num = ARRAY_SIZE(qmp_v4_usb3_tx_tbl), |
| 408 |
.rx_tbl = qmp_v4_usb3_rx_tbl, |
| 409 |
.rx_tbl_num = ARRAY_SIZE(qmp_v4_usb3_rx_tbl), |
| 410 |
.pcs_tbl = qmp_v4_usb3_pcs_tbl, |
| 411 |
.pcs_tbl_num = ARRAY_SIZE(qmp_v4_usb3_pcs_tbl), |
| 412 |
.pcs_usb3_tbl = qmp_v4_usb3_pcs_usb3_tbl, |
| 413 |
.pcs_usb3_tbl_num = ARRAY_SIZE(qmp_v4_usb3_pcs_usb3_tbl), |
| 414 |
}, |
| 415 |
}; |
| 416 |
|
| 417 |
|
| 418 |
static void qcom_qmp_phy_configure(void *base_addr, const qmp_phy_init_tbl_t tbl[], unsigned int num) |
| 419 |
{ |
| 420 |
int i; |
| 421 |
const qmp_phy_init_tbl_t *t = tbl; |
| 422 |
|
| 423 |
if (!t) |
| 424 |
return; |
| 425 |
|
| 426 |
for (i = 0; i < num; i++, t++) |
| 427 |
write32((void *)((unsigned long)base_addr + t->offset), t->val); |
| 428 |
} |
| 429 |
|
| 430 |
|
| 431 |
static bool ss_qmp_phy_init_common(const struct ss_usb_phy_reg *ss_phy_reg) |
| 432 |
{ |
| 433 |
bool ret = true; |
| 434 |
|
| 435 |
struct usb3_phy_pcs_reg_layout *current_pcs_reg = (struct usb3_phy_pcs_reg_layout *)ss_phy_reg->pcs_base; |
| 436 |
|
| 437 |
printk(BIOS_DEBUG, "QMP PHY %s init\n", ss_phy_reg->name); |
| 438 |
|
| 439 |
|
| 440 |
write32(¤t_pcs_reg->pcs_power_down_control, 0x01); |
| 441 |
|
| 442 |
|
| 443 |
qcom_qmp_phy_configure(ss_phy_reg->com_base, ss_phy_reg->serdes_tbl, |
| 444 |
ss_phy_reg->serdes_tbl_num); |
| 445 |
|
| 446 |
|
| 447 |
qcom_qmp_phy_configure(ss_phy_reg->pcs_base, ss_phy_reg->pcs_tbl, |
| 448 |
ss_phy_reg->pcs_tbl_num); |
| 449 |
qcom_qmp_phy_configure(ss_phy_reg->tx_base, ss_phy_reg->tx_tbl, |
| 450 |
ss_phy_reg->tx_tbl_num); |
| 451 |
qcom_qmp_phy_configure(ss_phy_reg->rx_base, ss_phy_reg->rx_tbl, |
| 452 |
ss_phy_reg->rx_tbl_num); |
| 453 |
qcom_qmp_phy_configure(ss_phy_reg->pcs_usb3_base, ss_phy_reg->pcs_usb3_tbl, |
| 454 |
ss_phy_reg->pcs_usb3_tbl_num); |
| 455 |
|
| 456 |
udelay(100); |
| 457 |
|
| 458 |
|
| 459 |
write32(¤t_pcs_reg->pcs_sw_reset, 0x00); |
| 460 |
|
| 461 |
write32(¤t_pcs_reg->pcs_start_control, 0x03); |
| 462 |
|
| 463 |
udelay(100); |
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
long lock_us = wait_us(10000, |
| 470 |
!(read32(¤t_pcs_reg->pcs_pcs_status1)& |
| 471 |
USB3_PCS_PHYSTATUS)); |
| 472 |
if (!lock_us) { |
| 473 |
ret = false; |
| 474 |
printk(BIOS_ERR, "QMP PHY %s PLL LOCK failed after %ldus\n", |
| 475 |
ss_phy_reg->name, lock_us); |
| 476 |
} else { |
| 477 |
printk(BIOS_DEBUG, "QMP PHY %s initialized and locked in %ldus\n", |
| 478 |
ss_phy_reg->name, lock_us); |
| 479 |
} |
| 480 |
return ret; |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
bool ss_qmp_phy_init(u32 phy_idx) |
| 488 |
{ |
| 489 |
bool ret = true; |
| 490 |
|
| 491 |
|
| 492 |
if (phy_idx >= ARRAY_SIZE(qmp_phy_instances)) { |
| 493 |
printk(BIOS_ERR, "Invalid PHY index provided: %u\n", phy_idx); |
| 494 |
return false; |
| 495 |
} |
| 496 |
|
| 497 |
if (!ss_qmp_phy_init_common(&qmp_phy_instances[phy_idx])) { |
| 498 |
ret = false; |
| 499 |
} |
| 500 |
return ret; |
| 501 |
} |