blob: 91aed89d07e752a7ac8c7a476a823f9b27f1d9e5 [file] [log] [blame]
Channagoud Kadabi1f24f8a2015-02-11 15:43:10 -08001/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Channagoud Kadabiaab99d42014-02-04 15:45:56 -08002
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -070029#include <sys/types.h>
Channagoud Kadabiaab99d42014-02-04 15:45:56 -080030#include <stdint.h>
31#include <platform/clock.h>
32#include <platform/iomap.h>
33#include <qmp_phy.h>
34#include <reg.h>
35#include <bits.h>
Channagoud Kadabia39da8b2014-04-03 15:34:43 -070036#include <clock.h>
37#include <debug.h>
Veera Sundaram Sankaran00181512014-12-09 11:23:39 -080038#include <qtimer.h>
Channagoud Kadabie35356f2015-08-05 18:06:38 -070039#include <platform.h>
Channagoud Kadabia39da8b2014-04-03 15:34:43 -070040
41#define HS_PHY_COMMON_CTRL 0xEC
42#define USE_CORECLK BIT(14)
43#define PLLBTUNE BIT(15)
44#define FSEL (0x7 << 4)
45#define DIS_RETENTION BIT(18)
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -070046#define QMP_PHY_MAX_TIMEOUT 1000
47#define PHYSTATUS BIT(6)
Channagoud Kadabiaab99d42014-02-04 15:45:56 -080048
Channagoud Kadabi1f24f8a2015-02-11 15:43:10 -080049static bool hsonly_mode;
50
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -070051/* Override values for QMP 2.0 V1 devices */
52struct qmp_reg qmp_override_pll_rev2[] =
53{
54 {0x124, 0x1C}, /* USB3PHY_QSERDES_COM_VCO_TUNE_CTRL */
55 {0x12C, 0x3F}, /* USB3PHY_QSERDES_COM_VCO_TUNE1_MODE0 */
56 {0x130, 0x01}, /* USB3PHY_QSERDES_COM_VCO_TUNE2_MODE0 */
57 {0x6c4, 0x13}, /* USB3_PHY_FLL_CNTRL2 */
58};
59
60/* QMP settings for 2.0 QMP V2 HW */
61struct qmp_reg qmp_settings_rev2[] =
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080062{
63 {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */
64 {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */
65 {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080066 {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */
67 {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */
Channagoud Kadabie35356f2015-08-05 18:06:38 -070068 {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -070069 {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */
70 {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */
71 {0x3C, 0x04}, /* QSERDES_COM_SYS_CLK_CTRL */
72
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -070073 /* PLL & Loop filter settings */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080074 {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */
75 {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */
76 {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */
77 {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */
78 {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */
79 {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */
80 {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */
81 {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -070082 {0x124, 0x00}, /* QSERDES_COM_VCO_TUNE_CTRL */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080083 {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */
84 {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */
85 {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080086 {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080087 {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -070088 {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080089 {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */
90 {0xc, 0x0a}, /* QSERDES_COM_BG_TIMER */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -070091
92 /* SSC settings */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -080093 {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */
94 {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */
95 {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */
96 {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */
97 {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */
98 {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */
99 {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700100
101 /* Rx Settings */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800102 {0x440, 0x0b}, /* QSERDES_RX_UCDR_FASTLOCK_FO_GAIN */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700103 {0x41C, 0x04}, /* QSERDES_RX_UCDR_SO_GAIN */
104 {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */
105 {0x4dc, 0x4c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */
106 {0x4e0, 0xbb}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800107 {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
108 {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700109 {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800110 {0x518, 0x1b}, /* QSERDES_RX_SIGDET_LVL */
111 {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700112
113 /* Tx settings */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800114 {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */
115 {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700116 {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */
117
118 /* FLL settings */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800119 {0x6c4, 0x03}, /* USB3_PHY_FLL_CNTRL2 */
120 {0x6c0, 0x02}, /* USB3_PHY_FLL_CNTRL1 */
121 {0x6c8, 0x09}, /* USB3_PHY_FLL_CNT_VAL_L */
122 {0x6cc, 0x42}, /* USB3_PHY_FLL_CNT_VAL_H_TOL */
123 {0x6d0, 0x85}, /* USB3_PHY_FLL_MAN_CODE */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700124
125 /* Lock Det Settings */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800126 {0x680, 0xd1}, /* USB3_PHY_LOCK_DETECT_CONFIG1 */
127 {0x684, 0x1f}, /* USB3_PHY_LOCK_DETECT_CONFIG2 */
128 {0x688, 0x47}, /* USB3_PHY_LOCK_DETECT_CONFIG3 */
129 {0x664, 0x08}, /* USB3_PHY_POWER_STATE_CONFIG2 */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800130 {0x608, 0x03}, /* USB3_PHY_START_CONTROL */
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700131 {0x600, 0x00}, /* USB3_PHY_SW_RESET */
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800132};
133
Channagoud Kadabie35356f2015-08-05 18:06:38 -0700134#if PLATFORM_USE_QMP_MISC
135struct qmp_reg qmp_misc_settings_rev2[] =
136{
137 {0x178, 0x01}, /* QSERDES_COM_HSCLK_SEL */
138 {0xC4, 0x15}, /* USB3PHY_QSERDES_COM_RESCODE_DIV_NUM */
139 {0x1B8, 0x1F}, /* QSERDES_COM_CMN_MISC2 */
140};
141#endif
142
Channagoud Kadabi0b13ba52014-05-12 18:08:33 -0700143__WEAK uint32_t target_override_pll()
144{
145 return 0;
146}
147
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800148__WEAK uint32_t platform_get_qmp_rev()
149{
150 return 0x10000000;
151}
152
153/* USB3.0 QMP phy reset */
154static void qmp_phy_qmp_reset(void)
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800155{
Channagoud Kadabia39da8b2014-04-03 15:34:43 -0700156 int ret = 0;
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800157 uint32_t val;
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -0700158 bool phy_com_reset = false;
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800159
Channagoud Kadabia39da8b2014-04-03 15:34:43 -0700160 struct clk *usb2b_clk = NULL;
161 struct clk *usb_pipe_clk = NULL;
162 struct clk *phy_com_clk = NULL;
163 struct clk *phy_clk = NULL;
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800164
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -0700165 /* Look if phy com clock is present */
166 phy_com_clk = clk_get("usb30_phy_com_reset");
167 if (phy_com_clk)
168 phy_com_reset = true;
169
Channagoud Kadabia39da8b2014-04-03 15:34:43 -0700170 usb2b_clk = clk_get("usb2b_phy_sleep_clk");
171 ASSERT(usb2b_clk);
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800172
Channagoud Kadabia39da8b2014-04-03 15:34:43 -0700173 phy_clk = clk_get("usb30_phy_reset");
174 ASSERT(phy_clk);
175
176 usb_pipe_clk = clk_get("usb30_pipe_clk");
177 ASSERT(usb_pipe_clk);
178
179 /* ASSERT */
180 ret = clk_reset(usb2b_clk, CLK_RESET_ASSERT);
181 if (ret)
182 {
183 dprintf(CRITICAL, "Failed to assert usb2b_phy_clk\n");
184 return;
185 }
186
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -0700187 if (phy_com_reset)
Channagoud Kadabia39da8b2014-04-03 15:34:43 -0700188 {
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -0700189 ret = clk_reset(phy_com_clk, CLK_RESET_ASSERT);
190 if (ret)
191 {
192 dprintf(CRITICAL, "Failed to assert phy_com_clk\n");
193 goto deassert_usb2b_clk;
194 }
Channagoud Kadabia39da8b2014-04-03 15:34:43 -0700195 }
196
197 ret = clk_reset(phy_clk, CLK_RESET_ASSERT);
198 if (ret)
199 {
200 dprintf(CRITICAL, "Failed to assert phy_clk\n");
201 goto deassert_phy_com_clk;
202 }
203
204 ret = clk_reset(usb_pipe_clk, CLK_RESET_ASSERT);
205 if (ret)
206 {
207 dprintf(CRITICAL, "Failed to assert usb_pipe_clk\n");
208 goto deassert_phy_clk;
209 }
210
211 udelay(100);
212
213 /* DEASSERT */
214 ret = clk_reset(usb_pipe_clk, CLK_RESET_DEASSERT);
215 if (ret)
216 dprintf(CRITICAL, "Failed to deassert usb_pipe_clk\n");
217
218deassert_phy_clk:
219 ret = clk_reset(phy_clk, CLK_RESET_DEASSERT);
220 if (ret)
221 dprintf(CRITICAL, "Failed to deassert phy_clk\n");
222
223deassert_phy_com_clk:
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -0700224 if (phy_com_reset)
225 {
226 ret = clk_reset(phy_com_clk, CLK_RESET_DEASSERT);
227 if (ret)
228 dprintf(CRITICAL, "Failed to deassert phy_com_clk\n");
229 }
Channagoud Kadabia39da8b2014-04-03 15:34:43 -0700230
231deassert_usb2b_clk:
232 ret = clk_reset(usb2b_clk, CLK_RESET_DEASSERT);
233 if (ret)
234 dprintf(CRITICAL, "Failed to deassert usb2b_phy_clk\n");
235
236 /* Override the phy common control values */
237 val = readl(MSM_USB30_QSCRATCH_BASE + HS_PHY_COMMON_CTRL);
238 val |= USE_CORECLK | PLLBTUNE;
239 val &= ~FSEL;
240 val &= ~DIS_RETENTION;
241 writel(val, MSM_USB30_QSCRATCH_BASE + HS_PHY_COMMON_CTRL);
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800242}
243
Channagoud Kadabic4b752c2014-12-22 12:06:27 -0800244/* USB3.0 QMP phy reset */
245void usb30_qmp_phy_reset(void)
246{
247#if USB_RESET_FROM_CLK
248 clock_reset_usb_phy();
249#else
250 qmp_phy_qmp_reset();
251#endif
252}
253
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800254/* USB 3.0 phy init: HPG for QMP phy*/
255void usb30_qmp_phy_init()
256{
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -0700257 int timeout = QMP_PHY_MAX_TIMEOUT;
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800258 uint32_t rev_id = 0;
259 uint32_t phy_status = 0;
260 uint32_t qmp_reg_size;
261 uint32_t i;
262
263 rev_id = platform_get_qmp_rev();
Channagoud Kadabib3d7f1f2014-04-22 15:02:51 -0700264
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800265 /* Sequence as per HPG */
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800266 writel(0x01, QMP_PHY_BASE + PCIE_USB3_PHY_POWER_DOWN_CONTROL);
Channagoud Kadabi0b13ba52014-05-12 18:08:33 -0700267
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800268 if (rev_id >= 0x20000000)
269 {
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700270 qmp_reg_size = sizeof(qmp_settings_rev2) / sizeof(struct qmp_reg);
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800271 for (i = 0 ; i < qmp_reg_size; i++)
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700272 writel(qmp_settings_rev2[i].val, QMP_PHY_BASE + qmp_settings_rev2[i].off);
273
Channagoud Kadabie35356f2015-08-05 18:06:38 -0700274#if PLATFORM_USE_QMP_MISC
275 if (platform_use_qmp_misc_settings())
276 for (i = 0; i < ARRAY_SIZE(qmp_misc_settings_rev2); i++)
277 writel(qmp_misc_settings_rev2[i].val, QMP_PHY_BASE + qmp_misc_settings_rev2[i].off);
278#endif
Channagoud Kadabi6a1b8ba2015-04-28 17:14:32 -0700279 if (target_override_pll())
280 {
281 qmp_reg_size = sizeof(qmp_override_pll_rev2) / sizeof(struct qmp_reg);
282 for (i = 0 ; i < qmp_reg_size; i++)
283 writel(qmp_override_pll_rev2[i].val, QMP_PHY_BASE + qmp_override_pll_rev2[i].off);
284 }
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800285 }
Channagoud Kadabi0b13ba52014-05-12 18:08:33 -0700286 else
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800287 {
288 writel(0x08, QMP_PHY_BASE + QSERDES_COM_SYSCLK_EN_SEL_TXBAND);
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800289
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800290 if (target_override_pll())
291 writel(0xE1, QMP_PHY_BASE + QSERDES_COM_PLL_VCOTAIL_EN);
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800292
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800293 writel(0x82, QMP_PHY_BASE + QSERDES_COM_DEC_START1);
294 writel(0x03, QMP_PHY_BASE + QSERDES_COM_DEC_START2);
295 writel(0xD5, QMP_PHY_BASE + QSERDES_COM_DIV_FRAC_START1);
296 writel(0xAA, QMP_PHY_BASE + QSERDES_COM_DIV_FRAC_START2);
297 writel(0x4D, QMP_PHY_BASE + QSERDES_COM_DIV_FRAC_START3);
298 writel(0x01, QMP_PHY_BASE + QSERDES_COM_PLLLOCK_CMP_EN);
299 writel(0x2B, QMP_PHY_BASE + QSERDES_COM_PLLLOCK_CMP1);
300 writel(0x68, QMP_PHY_BASE + QSERDES_COM_PLLLOCK_CMP2);
301 writel(0x7C, QMP_PHY_BASE + QSERDES_COM_PLL_CRCTRL);
302 writel(0x02, QMP_PHY_BASE + QSERDES_COM_PLL_CP_SETI);
303 writel(0x1F, QMP_PHY_BASE + QSERDES_COM_PLL_IP_SETP);
304 writel(0x0F, QMP_PHY_BASE + QSERDES_COM_PLL_CP_SETP);
305 writel(0x01, QMP_PHY_BASE + QSERDES_COM_PLL_IP_SETI);
306 writel(0x0F, QMP_PHY_BASE + QSERDES_COM_IE_TRIM);
307 writel(0x0F, QMP_PHY_BASE + QSERDES_COM_IP_TRIM);
308 writel(0x46, QMP_PHY_BASE + QSERDES_COM_PLL_CNTRL);
309
310 /* CDR Settings */
311 writel(0xDA, QMP_PHY_BASE + QSERDES_RX_CDR_CONTROL1);
312 writel(0x42, QMP_PHY_BASE + QSERDES_RX_CDR_CONTROL2);
313
314 /* Calibration Settings */
315 writel(0x90, QMP_PHY_BASE + QSERDES_COM_RESETSM_CNTRL);
316 if (target_override_pll())
317 writel(0x07, QMP_PHY_BASE + QSERDES_COM_RESETSM_CNTRL2);
318 else
319 writel(0x05, QMP_PHY_BASE + QSERDES_COM_RESETSM_CNTRL2);
320
321 writel(0x20, QMP_PHY_BASE + QSERDES_COM_RES_CODE_START_SEG1);
322 writel(0x77, QMP_PHY_BASE + QSERDES_COM_RES_CODE_CAL_CSR);
323 writel(0x15, QMP_PHY_BASE + QSERDES_COM_RES_TRIM_CONTROL);
324 writel(0x03, QMP_PHY_BASE + QSERDES_TX_RCV_DETECT_LVL);
325 writel(0x02, QMP_PHY_BASE + QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2);
326 writel(0x6C, QMP_PHY_BASE + QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3);
327 writel(0xC7, QMP_PHY_BASE + QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4);
328 writel(0x40, QMP_PHY_BASE + QSERDES_RX_SIGDET_ENABLES);
329 writel(0x73, QMP_PHY_BASE + QSERDES_RX_SIGDET_CNTRL);
330 writel(0x06, QMP_PHY_BASE + QSERDES_RX_SIGDET_DEGLITCH_CNTRL);
331 writel(0x48, QMP_PHY_BASE + PCIE_USB3_PHY_RX_IDLE_DTCT_CNTRL);
332 writel(0x01, QMP_PHY_BASE + QSERDES_COM_SSC_EN_CENTER);
333 writel(0x02, QMP_PHY_BASE + QSERDES_COM_SSC_ADJ_PER1);
334 writel(0x31, QMP_PHY_BASE + QSERDES_COM_SSC_PER1);
335 writel(0x01, QMP_PHY_BASE + QSERDES_COM_SSC_PER2);
336 writel(0x19, QMP_PHY_BASE + QSERDES_COM_SSC_STEP_SIZE1);
337 writel(0x19, QMP_PHY_BASE + QSERDES_COM_SSC_STEP_SIZE2);
338 writel(0x08, QMP_PHY_BASE + PCIE_USB3_PHY_POWER_STATE_CONFIG2);
339
340 writel(0x00, QMP_PHY_BASE + PCIE_USB3_PHY_SW_RESET);
341 writel(0x03, QMP_PHY_BASE + PCIE_USB3_PHY_START);
342 }
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800343
Channagoud Kadabi662a7fa2014-11-17 17:24:27 -0800344 if (rev_id >= 0x20000000)
345 phy_status = 0x77c;
346 else
347 phy_status = 0x728;
348
349 while ((readl(QMP_PHY_BASE + phy_status) & PHYSTATUS))
Channagoud Kadabi7bc9edb2014-06-01 19:01:12 -0700350 {
351 udelay(1);
352 timeout--;
353 if (!timeout)
354 {
Channagoud Kadabi1f24f8a2015-02-11 15:43:10 -0800355 dprintf(CRITICAL, "QMP phy initialization failed, fallback to HighSpeed only mode\n");
356 hsonly_mode = true;
Channagoud Kadabi7bc9edb2014-06-01 19:01:12 -0700357 return;
358 }
359 }
Channagoud Kadabi1f24f8a2015-02-11 15:43:10 -0800360
361 clock_bumpup_pipe3_clk();
362}
363
364bool use_hsonly_mode()
365{
366 return hsonly_mode;
Channagoud Kadabiaab99d42014-02-04 15:45:56 -0800367}