blob: b40246a75b30e812cf4edadc5fcf457ca1dc6e66 [file] [log] [blame]
lijuang395b5e62015-11-19 17:39:44 +08001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +05302 *
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
29#include <debug.h>
30#include <platform/iomap.h>
31#include <reg.h>
32#include <target.h>
33#include <platform.h>
34#include <uart_dm.h>
35#include <mmc.h>
36#include <platform/gpio.h>
37#include <dev/keys.h>
38#include <spmi_v2.h>
39#include <pm8x41.h>
P.V. Phani Kumara053a322015-08-13 18:36:05 +053040#include <pm8x41_hw.h>
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053041#include <board.h>
42#include <baseband.h>
43#include <hsusb.h>
44#include <scm.h>
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053045#include <platform/irqs.h>
46#include <platform/clock.h>
P.V. Phani Kumara053a322015-08-13 18:36:05 +053047#include <platform/timer.h>
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053048#include <crypto5_wrapper.h>
49#include <partition_parser.h>
50#include <stdlib.h>
P.V. Phani Kumara053a322015-08-13 18:36:05 +053051#include <rpm-smd.h>
52#include <spmi.h>
53#include <sdhci_msm.h>
54#include <clock.h>
P.V. Phani Kumar77826d32015-12-26 20:56:35 +053055#include <boot_device.h>
56#include <secapp_loader.h>
57#include <rpmb.h>
58#include <smem.h>
59#include <qmp_phy.h>
60#include <qusb2_phy.h>
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053061
62#if LONG_PRESS_POWER_ON
63#include <shutdown_detect.h>
64#endif
65
c_wufeng41310ae2016-01-14 17:59:22 +080066#if PON_VIB_SUPPORT
67#include <vibrator.h>
68#define VIBRATE_TIME 250
69#endif
70
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053071#define PMIC_ARB_CHANNEL_NUM 0
72#define PMIC_ARB_OWNER_ID 0
73#define TLMM_VOL_UP_BTN_GPIO 85
74
75#define FASTBOOT_MODE 0x77665500
P.V. Phani Kumar77826d32015-12-26 20:56:35 +053076#define RECOVERY_MODE 0x77665502
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053077#define PON_SOFT_RB_SPARE 0x88F
78
P.V. Phani Kumar77826d32015-12-26 20:56:35 +053079#define CE1_INSTANCE 1
80#define CE_EE 1
81#define CE_FIFO_SIZE 64
82#define CE_READ_PIPE 3
83#define CE_WRITE_PIPE 2
84#define CE_READ_PIPE_LOCK_GRP 0
85#define CE_WRITE_PIPE_LOCK_GRP 0
86#define CE_ARRAY_SIZE 20
87
P.V. Phani Kumara053a322015-08-13 18:36:05 +053088struct mmc_device *dev;
89
90static uint32_t mmc_pwrctl_base[] =
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053091 { MSM_SDC1_BASE, MSM_SDC2_BASE };
92
P.V. Phani Kumara053a322015-08-13 18:36:05 +053093static uint32_t mmc_sdhci_base[] =
94 { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE };
95
96static uint32_t mmc_sdc_pwrctl_irq[] =
97 { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ };
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053098
99void target_early_init(void)
100{
101#if WITH_DEBUG_UART
P.V. Phani Kumar2e4eeae2015-12-31 16:52:54 +0530102 uart_dm_init(1, 0, BLSP1_UART0_BASE);
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530103#endif
104}
105
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530106static void set_sdc_power_ctrl()
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530107{
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530108 /* Drive strength configs for sdc pins */
109 struct tlmm_cfgs sdc1_hdrv_cfg[] =
110 {
111 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0},
112 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0},
113 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK , 0},
114 };
115
116 /* Pull configs for sdc pins */
117 struct tlmm_cfgs sdc1_pull_cfg[] =
118 {
119 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0},
120 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
121 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
122 };
123
124 struct tlmm_cfgs sdc1_rclk_cfg[] =
125 {
126 { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, 0},
127 };
128
129 /* Set the drive strength & pull control values */
130 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
131 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
132 tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg));
133}
134
135void target_sdc_init()
136{
137 struct mmc_config_data config;
138
139 /* Set drive strength & pull ctrl values */
140 set_sdc_power_ctrl();
141
142 config.slot = MMC_SLOT;
143 config.bus_width = DATA_BUS_WIDTH_8BIT;
144 config.max_clk_rate = MMC_CLK_192MHZ;
145 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
146 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
147 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
148 config.hs400_support = 1;
149
150 if (!(dev = mmc_init(&config))) {
151 /* Try different config. values */
152 config.max_clk_rate = MMC_CLK_200MHZ;
153 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
154 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
155 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
156 config.hs400_support = 0;
157
158 if (!(dev = mmc_init(&config))) {
159 dprintf(CRITICAL, "mmc init failed!");
160 ASSERT(0);
161 }
162 }
163}
164
165void *target_mmc_device()
166{
167 return (void *) dev;
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530168}
169
170/* Return 1 if vol_up pressed */
171static int target_volume_up()
172{
173 uint8_t status = 0;
174
175 gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);
176
177 /* Wait for the gpio config to take effect - debounce time */
178 thread_sleep(10);
179
180 /* Get status of GPIO */
181 status = gpio_status(TLMM_VOL_UP_BTN_GPIO);
182
183 /* Active high signal. */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530184 return !status;
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530185}
186
187/* Return 1 if vol_down pressed */
188uint32_t target_volume_down()
189{
190 /* Volume down button tied in with PMIC RESIN. */
191 return pm8x41_resin_status();
192}
193
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530194uint32_t target_is_pwrkey_pon_reason()
195{
196 uint8_t pon_reason = pm8950_get_pon_reason();
197 if (pm8x41_get_is_cold_boot() && ((pon_reason == KPDPWR_N) || (pon_reason == (KPDPWR_N|PON1))))
198 return 1;
199 else
200 return 0;
201}
202
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530203static void target_keystatus()
204{
205 keys_init();
206
207 if(target_volume_down())
208 keys_post_event(KEY_VOLUMEDOWN, 1);
209
210 if(target_volume_up())
211 keys_post_event(KEY_VOLUMEUP, 1);
212}
213
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530214void target_init(void)
215{
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530216#if VERIFIED_BOOT
217#if !VBOOT_MOTA
218 int ret = 0;
219#endif
220#endif
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530221 dprintf(INFO, "target_init()\n");
222
223 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
224
225 target_keystatus();
226
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530227 target_sdc_init();
228 if (partition_read_table())
229 {
230 dprintf(CRITICAL, "Error reading the partition table info\n");
231 ASSERT(0);
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530232 }
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530233
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530234#if LONG_PRESS_POWER_ON
235 shutdown_detect();
236#endif
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530237
c_wufeng41310ae2016-01-14 17:59:22 +0800238#if PON_VIB_SUPPORT
239 vib_timed_turn_on(VIBRATE_TIME);
240#endif
241
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530242
243 if (target_use_signed_kernel())
244 target_crypto_init_params();
245
246#if VERIFIED_BOOT
247#if !VBOOT_MOTA
248 clock_ce_enable(CE1_INSTANCE);
249
250 /* Initialize Qseecom */
251 ret = qseecom_init();
252
253 if (ret < 0)
254 {
255 dprintf(CRITICAL, "Failed to initialize qseecom, error: %d\n", ret);
256 ASSERT(0);
257 }
258
259 /* Start Qseecom */
260 ret = qseecom_tz_init();
261
262 if (ret < 0)
263 {
264 dprintf(CRITICAL, "Failed to start qseecom, error: %d\n", ret);
265 ASSERT(0);
266 }
267
268 if (rpmb_init() < 0)
269 {
270 dprintf(CRITICAL, "RPMB init failed\n");
271 ASSERT(0);
272 }
273
274 /*
275 * Load the sec app for first time
276 */
277 if (load_sec_app() < 0)
278 {
279 dprintf(CRITICAL, "Failed to load App for verified\n");
280 ASSERT(0);
281 }
282#endif
283#endif
284
285#if SMD_SUPPORT
286 rpm_smd_init();
287#endif
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530288}
289
290void target_serialno(unsigned char *buf)
291{
292 uint32_t serialno;
293 if (target_is_emmc_boot()) {
294 serialno = mmc_get_psn();
295 snprintf((char *)buf, 13, "%x", serialno);
296 }
297}
298
299unsigned board_machtype(void)
300{
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530301 return LINUX_MACHTYPE_UNKNOWN;
302}
303
304/* Detect the target type */
305void target_detect(struct board_data *board)
306{
307 /* This is already filled as part of board.c */
308}
309
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530310/* Detect the modem type */
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530311void target_baseband_detect(struct board_data *board)
312{
313 uint32_t platform;
314
315 platform = board->platform;
316
317 switch(platform) {
318 case MSMTITANIUM:
319 board->baseband = BASEBAND_MSM;
320 break;
Gaurav Nebhwani22a0d9f2015-12-29 13:49:26 +0530321 case APQTITANIUM:
322 board->baseband = BASEBAND_APQ;
323 break;
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530324 default:
325 dprintf(CRITICAL, "Platform type: %u is not supported\n",platform);
326 ASSERT(0);
327 };
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530328}
329
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530330unsigned target_baseband()
331{
332 return board_baseband();
333}
lijuang395b5e62015-11-19 17:39:44 +0800334
335int set_download_mode(enum reboot_reason mode)
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530336{
337 int ret = 0;
338 ret = scm_dload_mode(mode);
339
340 pm8x41_clear_pmic_watchdog();
341
342 return ret;
343}
344
345int emmc_recovery_init(void)
346{
347 return _emmc_recovery_init();
348}
349
350unsigned target_pause_for_battery_charge(void)
351{
352 uint8_t pon_reason = pm8x41_get_pon_reason();
353 uint8_t is_cold_boot = pm8x41_get_is_cold_boot();
354 dprintf(INFO, "%s : pon_reason is %d cold_boot:%d\n", __func__,
355 pon_reason, is_cold_boot);
356 /* In case of fastboot reboot,adb reboot or if we see the power key
357 * pressed we do not want go into charger mode.
358 * fastboot reboot is warm boot with PON hard reset bit not set
359 * adb reboot is a cold boot with PON hard reset bit set
360 */
361 if (is_cold_boot &&
362 (!(pon_reason & HARD_RST)) &&
363 (!(pon_reason & KPDPWR_N)) &&
364 ((pon_reason & USB_CHG) || (pon_reason & DC_CHG) || (pon_reason & CBLPWR_N)))
365 return 1;
366 else
367 return 0;
368}
369
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530370void target_uninit(void)
371{
372 mmc_put_card_to_sleep(dev);
373 sdhci_mode_disable(&dev->host);
374 if (crypto_initialized())
375 crypto_eng_cleanup();
376
377 if (target_is_ssd_enabled())
378 clock_ce_disable(CE1_INSTANCE);
379
380#if VERIFIED_BOOT
381#if !VBOOT_MOTA
382 if (is_sec_app_loaded())
383 {
384 if (send_milestone_call_to_tz() < 0)
385 {
386 dprintf(CRITICAL, "Failed to unload App for rpmb\n");
387 ASSERT(0);
388 }
389 }
390
391 if (rpmb_uninit() < 0)
392 {
393 dprintf(CRITICAL, "RPMB uninit failed\n");
394 ASSERT(0);
395 }
396
397 clock_ce_disable(CE1_INSTANCE);
398#endif
399#endif
400
401#if SMD_SUPPORT
402 rpm_smd_uninit();
403#endif
404}
405
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530406/* UTMI MUX configuration to connect PHY to SNPS controller:
407 * Configure primary HS phy mux to use UTMI interface
408 * (connected to usb30 controller).
409 */
410static void tcsr_hs_phy_mux_configure(void)
411{
412 uint32_t reg;
413
414 reg = readl(USB2_PHY_SEL);
415
416 writel(reg | 0x1, USB2_PHY_SEL);
417}
418
419/* configure hs phy mux if using dwc controller */
420void target_usb_phy_mux_configure(void)
421{
422 if(!strcmp(target_usb_controller(), "dwc"))
423 {
424 tcsr_hs_phy_mux_configure();
425 }
426}
427
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530428void target_usb_phy_reset()
429{
430
431 usb30_qmp_phy_reset();
432 qusb2_phy_reset();
433}
434
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530435/* Initialize target specific USB handlers */
436target_usb_iface_t* target_usb30_init()
437{
438 target_usb_iface_t *t_usb_iface;
439
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530440 t_usb_iface = (target_usb_iface_t *) calloc(1, sizeof(target_usb_iface_t));
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530441 ASSERT(t_usb_iface);
442
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530443 t_usb_iface->mux_config = NULL;
444 t_usb_iface->phy_init = usb30_qmp_phy_init;
445 t_usb_iface->phy_reset = target_usb_phy_reset;
446 t_usb_iface->clock_init = clock_usb30_init;
447 t_usb_iface->vbus_override = 1;
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530448
449 return t_usb_iface;
450}
451
452/* identify the usb controller to be used for the target */
453const char * target_usb_controller()
454{
455 return "dwc";
456}
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530457
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530458/* Do any target specific intialization needed before entering fastboot mode */
459void target_fastboot_init(void)
460{
461 if (target_is_ssd_enabled()) {
462 clock_ce_enable(CE1_INSTANCE);
463 target_load_ssd_keystore();
464 }
465}
466
467void target_load_ssd_keystore(void)
468{
469 uint64_t ptn;
470 int index;
471 uint64_t size;
472 uint32_t *buffer = NULL;
473
474 if (!target_is_ssd_enabled())
475 return;
476
477 index = partition_get_index("ssd");
478
479 ptn = partition_get_offset(index);
480 if (ptn == 0){
481 dprintf(CRITICAL, "Error: ssd partition not found\n");
482 return;
483 }
484
485 size = partition_get_size(index);
486 if (size == 0) {
487 dprintf(CRITICAL, "Error: invalid ssd partition size\n");
488 return;
489 }
490
491 buffer = memalign(CACHE_LINE, ROUNDUP(size, CACHE_LINE));
492 if (!buffer) {
493 dprintf(CRITICAL, "Error: allocating memory for ssd buffer\n");
494 return;
495 }
496
497 if (mmc_read(ptn, buffer, size)) {
498 dprintf(CRITICAL, "Error: cannot read data\n");
499 free(buffer);
500 return;
501 }
502
503 clock_ce_enable(CE1_INSTANCE);
504 scm_protect_keystore(buffer, size);
505 clock_ce_disable(CE1_INSTANCE);
506 free(buffer);
507}
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530508
509crypto_engine_type board_ce_type(void)
510{
511 return CRYPTO_ENGINE_TYPE_HW;
512}
513
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530514/* Set up params for h/w CE. */
515void target_crypto_init_params()
516{
517 struct crypto_init_params ce_params;
518
519 /* Set up base addresses and instance. */
520 ce_params.crypto_instance = CE1_INSTANCE;
521 ce_params.crypto_base = MSM_CE1_BASE;
522 ce_params.bam_base = MSM_CE1_BAM_BASE;
523
524 /* Set up BAM config. */
525 ce_params.bam_ee = CE_EE;
526 ce_params.pipes.read_pipe = CE_READ_PIPE;
527 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
528 ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP;
529 ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP;
530
531 /* Assign buffer sizes. */
532 ce_params.num_ce = CE_ARRAY_SIZE;
533 ce_params.read_fifo_size = CE_FIFO_SIZE;
534 ce_params.write_fifo_size = CE_FIFO_SIZE;
535
536 /* BAM is initialized by TZ for this platform.
537 * Do not do it again as the initialization address space
538 * is locked.
539 */
540 ce_params.do_bam_init = 0;
541
542 crypto_init_params(&ce_params);
543}
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530544
545void pmic_reset_configure(uint8_t reset_type)
546{
547 pm8x41_reset_configure(reset_type);
548}
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530549
550uint32_t target_get_pmic()
551{
552 return PMIC_IS_PMI8950;
553}
554
555struct qmp_reg qmp_settings[] =
556{
557 {0x804, 0x01}, /*USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */
558 {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */
559 {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */
560 {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */
561 {0x3C, 0x06}, /* QSERDES_COM_SYS_CLK_CTRL */
562 {0xB4, 0x00}, /* QSERDES_COM_RESETSM_CNTRL */
563 {0xB8, 0x08}, /* QSERDES_COM_RESETSM_CNTRL2 */
564 {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */
565 {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */
566 {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */
567 {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */
568 {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */
569 {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */
570 {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */
571 {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */
572 {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */
573 {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */
574 {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */
575 {0x10C, 0x00}, /* QSERDES_COM_INTEGLOOP_GAIN1_MODE0 */
576 {0x184, 0x0A}, /* QSERDES_COM_CORECLK_DIV */
577 {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */
578 {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */
579 {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */
580 {0xC8, 0x00}, /* QSERDES_COM_LOCK_CMP_EN */
581 {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */
582 {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */
583 {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */
584 {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */
585 {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */
586 {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */
587 {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */
588 {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */
589 {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */
590 {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */
591 {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */
592 {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */
593 {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */
594 {0x100, 0x80}, /* QSERDES_COM_INTEGLOOP_INITVAL */
595
596 /* Rx Settings */
597 {0x440, 0x0b}, /* QSERDES_RX_UCDR_FASTLOCK_FO_GAIN */
598 {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */
599 {0x4dc, 0x6c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */
600 {0x4e0, 0xbb}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */
601 {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
602 {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
603 {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */
604 {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
605 {0x448, 0x75}, /* QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE */
606 {0x450, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_LOW */
607 {0x454, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_HIGH */
608 {0x40C, 0x0a}, /* QSERDES_RX_UCDR_FO_GAIN */
609 {0x41C, 0x06}, /* QSERDES_RX_UCDR_SO_GAIN */
610 {0x510, 0x00}, /*QSERDES_RX_SIGDET_ENABLES */
611
612 /* Tx settings */
613 {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */
614 {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */
615 {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */
616 {0x254, 0x00}, /* QSERDES_TX_RES_CODE_LANE_OFFSET */
617
618 /* FLL settings */
619 {0x8c8, 0x83}, /* PCIE_USB3_PCS_FLL_CNTRL2 */
620 {0x8c4, 0x02}, /* PCIE_USB3_PCS_FLL_CNTRL1 */
621 {0x8cc, 0x09}, /* PCIE_USB3_PCS_FLL_CNT_VAL_L */
622 {0x8D0, 0xA2}, /* PCIE_USB3_PCS_FLL_CNT_VAL_H_TOL */
623 {0x8D4, 0x85}, /* PCIE_USB3_PCS_FLL_MAN_CODE */
624
625 /* PCS Settings */
626 {0x880, 0xD1}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG1 */
627 {0x884, 0x1F}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG2 */
628 {0x888, 0x47}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG3 */
629 {0x80C, 0x9F}, /* PCIE_USB3_PCS_TXMGN_V0 */
630 {0x824, 0x17}, /* PCIE_USB3_PCS_TXDEEMPH_M6DB_V0 */
631 {0x828, 0x0F}, /* PCIE_USB3_PCS_TXDEEMPH_M3P5DB_V0 */
632 {0x8B8, 0x75}, /* PCIE_USB3_PCS_RXEQTRAINING_WAIT_TIME */
633 {0x8BC, 0x13}, /* PCIE_USB3_PCS_RXEQTRAINING_RUN_TIME */
634 {0x8B0, 0x86}, /* PCIE_USB3_PCS_LFPS_TX_ECSTART_EQTLOCK */
635 {0x8A0, 0x04}, /* PCIE_USB3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */
636 {0x88C, 0x44}, /* PCIE_USB3_PCS_TSYNC_RSYNC_TIME */
637 {0x870, 0xE7}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_L */
638 {0x874, 0x03}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_H */
639 {0x878, 0x40}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_L */
640 {0x87c, 0x00}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_H */
641 {0x9D8, 0x88}, /* PCIE_USB3_PCS_RX_SIGDET_LVL */
642 {0x808, 0x03}, /* PCIE_USB3_PCS_START_CONTROL */
643 {0x800, 0x00}, /* PCIE_USB3_PCS_SW_RESET */
644};
645
646struct qmp_reg *target_get_qmp_settings()
647{
648 return qmp_settings;
649}
650
651int target_get_qmp_regsize()
652{
653 return ARRAY_SIZE(qmp_settings);
654}