blob: 487e7d8e3076e0cf20e036a50ac7488c8d16f30b [file] [log] [blame]
Runmin Wang60ed4b82016-11-18 11:49:37 -08001/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
Joonwoo Parke586c2e2014-04-02 11:04:10 -07002 *
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 <board.h>
31#include <platform.h>
32#include <target.h>
33#include <smem.h>
34#include <baseband.h>
35#include <lib/ptable.h>
36#include <qpic_nand.h>
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -080037#include <malloc.h>
Joonwoo Parke586c2e2014-04-02 11:04:10 -070038#include <ctype.h>
39#include <string.h>
40#include <pm8x41.h>
41#include <reg.h>
42#include <hsusb.h>
43#include <mmc.h>
44#include <platform/timer.h>
45#include <platform/irqs.h>
46#include <platform/gpio.h>
47#include <platform/clock.h>
48#include <qmp_phy.h>
Joonwoo Park39aed062014-06-09 17:00:07 -070049#include <qusb2_phy.h>
anisha agarwalffb78ab2014-11-18 15:20:31 -080050#include <rpm-smd.h>
51#include <scm.h>
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -080052#include <spmi.h>
53#include <partition_parser.h>
54#include <sdhci_msm.h>
55#include <uart_dm.h>
56#include <boot_device.h>
Channagoud Kadabifdfee232015-10-07 11:55:47 -070057#include <qmp_phy.h>
vijay kumar7d06bbb2015-11-24 13:04:55 +053058#include <crypto5_wrapper.h>
Mayank Grover9714e2c2016-12-15 14:48:54 +053059#include <rpm-glink.h>
Joonwoo Parke586c2e2014-04-02 11:04:10 -070060
61extern void smem_ptable_init(void);
62extern void smem_add_modem_partitions(struct ptable *flash_ptable);
63void target_sdc_init();
64
65static struct ptable flash_ptable;
66
67/* PMIC config data */
68#define PMIC_ARB_CHANNEL_NUM 0
69#define PMIC_ARB_OWNER_ID 0
70
71/* NANDc BAM pipe numbers */
72#define DATA_CONSUMER_PIPE 0
73#define DATA_PRODUCER_PIPE 1
74#define CMD_PIPE 2
75
76/* NANDc BAM pipe groups */
77#define DATA_PRODUCER_PIPE_GRP 0
78#define DATA_CONSUMER_PIPE_GRP 0
79#define CMD_PIPE_GRP 1
80
81/* NANDc EE */
82#define QPIC_NAND_EE 0
83
84/* NANDc max desc length. */
85#define QPIC_NAND_MAX_DESC_LEN 0x7FFF
86
87#define LAST_NAND_PTN_LEN_PATTERN 0xFFFFFFFF
88
Smita Ghosh50a53ac2015-02-11 12:33:30 -080089#define EXT4_CMDLINE " rootwait rootfstype=ext4 root=/dev/mmcblk0p"
anisha agarwal11df23e2015-06-12 14:37:34 -070090#define UBI_CMDLINE " rootfstype=ubifs rootflags=bulk_read"
anisha agarwalce363dd2014-08-26 15:17:09 -070091
vijay kumar7d06bbb2015-11-24 13:04:55 +053092#define CE1_INSTANCE 1
93#define CE_EE 1
94#define CE_FIFO_SIZE 64
95#define CE_READ_PIPE 3
96#define CE_WRITE_PIPE 2
97#define CE_READ_PIPE_LOCK_GRP 0
98#define CE_WRITE_PIPE_LOCK_GRP 0
99#define CE_ARRAY_SIZE 20
100#define SUB_TYPE_SKUT 0x0A
101
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700102struct qpic_nand_init_config config;
103
104void update_ptable_names(void)
105{
106 uint32_t ptn_index;
107 struct ptentry *ptentry_ptr = flash_ptable.parts;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700108 unsigned i;
109 uint32_t len;
110
111 /* Change all names to lower case. */
112 for (ptn_index = 0; ptn_index != (uint32_t)flash_ptable.count; ptn_index++)
113 {
114 len = strlen(ptentry_ptr[ptn_index].name);
115
116 for (i = 0; i < len; i++)
117 {
118 if (isupper(ptentry_ptr[ptn_index].name[i]))
119 {
120 ptentry_ptr[ptn_index].name[i] = tolower(ptentry_ptr[ptn_index].name[i]);
121 }
122 }
123
124 /* SBL fills in the last partition length as 0xFFFFFFFF.
125 * Update the length field based on the number of blocks on the flash.
126 */
127 if ((uint32_t)(ptentry_ptr[ptn_index].length) == LAST_NAND_PTN_LEN_PATTERN)
128 {
129 ptentry_ptr[ptn_index].length = flash_num_blocks() - ptentry_ptr[ptn_index].start;
130 }
131 }
132}
133
134void target_early_init(void)
135{
136#if WITH_DEBUG_UART
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700137 uart_dm_init(3, 0, BLSP1_UART2_BASE);
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700138#endif
139}
140
141int target_is_emmc_boot(void)
142{
143 return platform_boot_dev_isemmc();
144}
145
Sachin Prakash Gejjif557d222017-08-04 17:18:45 +0530146#if ENABLE_EARLY_ETHERNET
147void toggle_neutrino(void)
148{
149 struct pm8x41_gpio gpio = {
150 .direction = PM_GPIO_DIR_OUT,
151 .function = PM_GPIO_FUNC_HIGH,
152 .vin_sel = 1, /* VIN_1 */
153 .output_buffer = PM_GPIO_OUT_CMOS,
154 .out_strength = PM_GPIO_OUT_DRIVE_LOW,
155 };
156
157 pm8x41_gpio_config(4, &gpio);
158 pm8x41_gpio_set(4, 1);
159 mdelay(10);
160 pm8x41_gpio_set(4, 0);
161}
162#endif
163
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700164/* init */
165void target_init(void)
166{
167 dprintf(INFO, "target_init()\n");
168
Sridhar Parasuram9ed91f32015-07-07 15:37:44 -0700169 pmic_info_populate();
170
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700171 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
anisha agarwal35eb8032017-03-21 13:12:12 -0700172 if(!platform_is_sdx20())
Mayank Grover9714e2c2016-12-15 14:48:54 +0530173 {
Runmin Wangc16e4f92016-11-18 17:09:53 -0800174 rpm_smd_init();
Mayank Grover9714e2c2016-12-15 14:48:54 +0530175 }
176 else
177 {
178 /* Initialize Glink */
179 rpm_glink_init();
180 }
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700181
Sachin Prakash Gejjif557d222017-08-04 17:18:45 +0530182#if ENABLE_EARLY_ETHERNET
183 /*enable pmic gpio 4*/
184 toggle_neutrino();
185#endif
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700186 if (platform_boot_dev_isemmc()) {
187 target_sdc_init();
188 if (partition_read_table()) {
189 dprintf(CRITICAL, "Error reading the partition table info\n");
190 ASSERT(0);
191 }
anisha agarwal70b8cd12015-02-02 11:44:46 -0800192 /* Below setting is to enable EBI2 function selection in TLMM so
193 that GPIOs can be used for display */
194 writel((readl(TLMM_EBI2_EMMC_GPIO_CFG) | EBI2_BOOT_SELECT), TLMM_EBI2_EMMC_GPIO_CFG);
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700195 } else {
196 config.pipes.read_pipe = DATA_PRODUCER_PIPE;
197 config.pipes.write_pipe = DATA_CONSUMER_PIPE;
198 config.pipes.cmd_pipe = CMD_PIPE;
199
200 config.pipes.read_pipe_grp = DATA_PRODUCER_PIPE_GRP;
201 config.pipes.write_pipe_grp = DATA_CONSUMER_PIPE_GRP;
202 config.pipes.cmd_pipe_grp = CMD_PIPE_GRP;
203
204 config.bam_base = MSM_NAND_BAM_BASE;
205 config.nand_base = MSM_NAND_BASE;
206 config.ee = QPIC_NAND_EE;
207 config.max_desc_len = QPIC_NAND_MAX_DESC_LEN;
208
209 qpic_nand_init(&config);
210
211 ptable_init(&flash_ptable);
212 smem_ptable_init();
213 smem_add_modem_partitions(&flash_ptable);
214
215 update_ptable_names();
216 flash_set_ptable(&flash_ptable);
217 }
vijay kumar7d06bbb2015-11-24 13:04:55 +0530218
219 if (target_use_signed_kernel())
220 target_crypto_init_params();
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700221}
222
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530223static int scm_clear_boot_partition_select()
224{
225 int ret = 0;
226
227 ret = scm_call_atomic2(SCM_SVC_BOOT, WDOG_DEBUG_DISABLE, 1, 0);
228 if (ret)
229 dprintf(CRITICAL, "Failed to disable the wdog debug \n");
230
231 return ret;
232}
233
234/* Trigger reboot */
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700235void reboot_device(unsigned reboot_reason)
236{
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530237 uint8_t reset_type = 0;
238
anisha agarwal35eb8032017-03-21 13:12:12 -0700239 if (platform_is_mdm9650() || platform_is_sdx20())
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530240 {
241 /* Clear the boot partition select cookie to indicate
242 * its a normal reset and avoid going to download mode */
243 scm_clear_boot_partition_select();
244 }
245
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700246 /* Write the reboot reason */
247 writel(reboot_reason, RESTART_REASON_ADDR);
248
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530249 if(reboot_reason)
250 reset_type = PON_PSHOLD_WARM_RESET;
Channagoud Kadabia85ed6e2015-03-23 14:35:16 -0700251 else
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530252 reset_type = PON_PSHOLD_HARD_RESET;
253
anisha agarwal35eb8032017-03-21 13:12:12 -0700254 if (platform_is_mdm9650() || platform_is_sdx20())
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530255 {
Karthik Jadala8e6b2192017-02-08 12:59:16 +0530256 /* PMD9655 is the PMIC used for MDM9650 */
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530257 pm8x41_reset_configure(reset_type);
258 } else {
259 /* Configure PMIC for warm reset */
260 /* PM 8019 v1 aligns with PM8941 v2.
261 * This call should be based on the pmic version
262 * when PM8019 v2 is available.
263 */
264 pm8x41_v2_reset_configure(reset_type);
265 }
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700266
267 /* Drop PS_HOLD for MSM */
268 writel(0x00, MPM2_MPM_PS_HOLD);
269
270 mdelay(5000);
271
272 dprintf(CRITICAL, "Rebooting failed\n");
273 return;
274}
275
276/* Identify the current target */
277void target_detect(struct board_data *board)
278{
279 /* This property is filled as part of board.c */
280}
281
282unsigned board_machtype(void)
283{
284 return LINUX_MACHTYPE_UNKNOWN;
285}
286
287/* Identify the baseband being used */
288void target_baseband_detect(struct board_data *board)
289{
290 board->baseband = BASEBAND_MSM;
291}
292
Sridhar Parasuram1d8c4222014-10-22 13:43:00 -0700293void target_serialno(unsigned char *buf)
294{
295 uint32_t serialno;
296 serialno = board_chip_serial();
297 snprintf((char *)buf, 13, "%x", serialno);
298}
299
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700300unsigned check_reboot_mode(void)
301{
302 unsigned restart_reason = 0;
303
304 /* Read reboot reason and scrub it */
305 restart_reason = readl(RESTART_REASON_ADDR);
306
307 writel(0x00, RESTART_REASON_ADDR);
308
309 return restart_reason;
310}
311
vijay kumarff36c312015-08-31 17:12:33 +0530312int get_target_boot_params(const char *cmdline, const char *part, char **buf)
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700313{
314 struct ptable *ptable;
315 int system_ptn_index = -1;
vijay kumarff36c312015-08-31 17:12:33 +0530316 uint32_t buflen;
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700317 int ret = -1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700318
vijay kumarff36c312015-08-31 17:12:33 +0530319 if (!cmdline || !part ) {
anisha agarwalce363dd2014-08-26 15:17:09 -0700320 dprintf(CRITICAL, "WARN: Invalid input param\n");
321 return -1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700322 }
323
anisha agarwalce363dd2014-08-26 15:17:09 -0700324 if (!strstr(cmdline, "root=/dev/ram")) /* This check is to handle kdev boot */
325 {
326 if (!target_is_emmc_boot()) {
vijay kumarff36c312015-08-31 17:12:33 +0530327
328 buflen = strlen(UBI_CMDLINE) + strlen(" root=ubi0:rootfs ubi.mtd=") + sizeof(int) + 1;
329 *buf = (char *)malloc(buflen);
330 if(!(*buf)) {
331 dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
332 return -1;
333 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700334 /* Below is for NAND boot */
335 ptable = flash_get_ptable();
336 if (!ptable) {
337 dprintf(CRITICAL,
338 "WARN: Cannot get flash partition table\n");
vijay kumarff36c312015-08-31 17:12:33 +0530339 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700340 return -1;
341 }
342
343 system_ptn_index = ptable_get_index(ptable, part);
344 if (system_ptn_index < 0) {
345 dprintf(CRITICAL,
346 "WARN: Cannot get partition index for %s\n", part);
vijay kumarff36c312015-08-31 17:12:33 +0530347 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700348 return -1;
349 }
350 /* Adding command line parameters according to target boot type */
vijay kumarff36c312015-08-31 17:12:33 +0530351 snprintf(*buf, buflen, UBI_CMDLINE);
352 snprintf(*buf+strlen(*buf), buflen, " root=ubi0:rootfs ubi.mtd=%d", system_ptn_index);
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700353 ret = 0;
anisha agarwalce363dd2014-08-26 15:17:09 -0700354 }
355 else {
Channagoud Kadabi9d9b5212015-10-20 17:29:50 -0700356 buflen = strlen(EXT4_CMDLINE) + sizeof(int) +1;
vijay kumarff36c312015-08-31 17:12:33 +0530357 *buf = (char *)malloc(buflen);
358 if(!(*buf)) {
359 dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
360 return -1;
361 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700362 /* Below is for emmc boot */
anisha agarwalc49a3252014-10-15 17:37:40 -0700363 system_ptn_index = partition_get_index(part) + 1; /* Adding +1 as offsets for eMMC start at 1 and NAND at 0 */
anisha agarwalce363dd2014-08-26 15:17:09 -0700364 if (system_ptn_index < 0) {
365 dprintf(CRITICAL,
366 "WARN: Cannot get partition index for %s\n", part);
vijay kumarff36c312015-08-31 17:12:33 +0530367 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700368 return -1;
369 }
vijay kumarff36c312015-08-31 17:12:33 +0530370 snprintf(*buf, buflen, EXT4_CMDLINE"%d", system_ptn_index);
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700371 ret = 0;
anisha agarwalce363dd2014-08-26 15:17:09 -0700372 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700373 }
vijay kumarff36c312015-08-31 17:12:33 +0530374 /*in success case buf will be freed in the calling function of this*/
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700375 return ret;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700376}
377
378const char * target_usb_controller()
379{
380 return "dwc";
381}
382
383static void set_sdc_power_ctrl()
384{
385 /* Drive strength configs for sdc pins */
386 struct tlmm_cfgs sdc1_hdrv_cfg[] =
387 {
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800388 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0 },
389 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0 },
390 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_6MA, TLMM_HDRV_MASK, 0 },
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700391 };
392
393 /* Pull configs for sdc pins */
394 struct tlmm_cfgs sdc1_pull_cfg[] =
395 {
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800396 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0 },
397 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 },
398 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 },
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700399 };
400
401 /* Set the drive strength & pull control values */
402 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
403 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
404}
405
406static struct mmc_device *dev;
407
408void *target_mmc_device()
409{
410 return (void *) dev;
411}
412
413void target_sdc_init()
414{
415 struct mmc_config_data config;
416
417 /* Set drive strength & pull ctrl values */
418 set_sdc_power_ctrl();
419
420 config.slot = 1;
Channagoud Kadabide17ba82014-11-12 13:05:57 -0800421 config.bus_width = DATA_BUS_WIDTH_8BIT;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700422 config.sdhc_base = MSM_SDC1_SDHCI_BASE;
423 config.pwrctl_base = MSM_SDC1_BASE;
424 config.pwr_irq = SDCC1_PWRCTL_IRQ;
425 config.hs400_support = 0;
Channagoud Kadabide17ba82014-11-12 13:05:57 -0800426 config.hs200_support = 0;
Channagoud Kadabid23379d2014-10-13 11:33:50 -0700427 config.use_io_switch = 1;
Mayank Groverb9029522017-04-12 14:57:07 +0530428 if (platform_is_sdx20())
429 config.max_clk_rate = MMC_CLK_200MHZ;
430 else
431 config.max_clk_rate = MMC_CLK_171MHZ;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700432
433 if (!(dev = mmc_init(&config))) {
434 dprintf(CRITICAL, "mmc init failed!");
435 ASSERT(0);
436 }
437}
438
anisha agarwal0fc661d2014-11-26 11:54:32 -0800439int target_cont_splash_screen()
440{
441 /* FOR OEMs - Set cont_splash_screen to keep the splash enable after LK.*/
anisha agarwal58d25cf2014-11-26 12:09:23 -0800442 return false;
anisha agarwal0fc661d2014-11-26 11:54:32 -0800443}
444
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700445void target_uninit(void)
446{
447 if (platform_boot_dev_isemmc())
448 {
449 mmc_put_card_to_sleep(dev);
450 sdhci_mode_disable(&dev->host);
451 }
vijay kumar7d06bbb2015-11-24 13:04:55 +0530452
453 if (crypto_initialized())
454 crypto_eng_cleanup();
455
anisha agarwal35eb8032017-03-21 13:12:12 -0700456 if(!platform_is_sdx20())
Mayank Grover9714e2c2016-12-15 14:48:54 +0530457 {
Runmin Wangc16e4f92016-11-18 17:09:53 -0800458 rpm_smd_uninit();
Mayank Grover9714e2c2016-12-15 14:48:54 +0530459 }
460 else
461 {
462 /* Tear down glink channels */
463 rpm_glink_uninit();
464 }
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700465}
Runmin Wang60ed4b82016-11-18 11:49:37 -0800466void target_mux_configure(void)
467{
468 uint32_t val;
469 //USB30_GENERAL_CFG_PIPE_UTMI_CLK_DIS
470 val = readl(USB30_GENERAL_CFG_PIPE);
471 val = val | 0x100;
472 writel(val, USB30_GENERAL_CFG_PIPE);
473 udelay(100);
474
475 //USB30_GENERAL_CFG_PIPE_UTMI_CLK_SEL
476 val = readl(USB30_GENERAL_CFG_PIPE);
477 val = val | 0x1;
478 writel(val, USB30_GENERAL_CFG_PIPE);
479 udelay(100);
480
481 //USB30_GENERAL_CFG_PIPE3_PHYSTATUS_SW
482 val = readl(USB30_GENERAL_CFG_PIPE);
483 val = val | 0x8;
484 writel(val, USB30_GENERAL_CFG_PIPE);
485 udelay(100);
486
487 //USB30_GENERAL_CFG_PIPE_UTMI_CLK_ENABLE
488 val = readl(USB30_GENERAL_CFG_PIPE);
489 val = val & 0xfffffeff;
490 writel(val, USB30_GENERAL_CFG_PIPE);
491 udelay(100);
492}
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700493
Joonwoo Park39aed062014-06-09 17:00:07 -0700494void target_usb_phy_reset(void)
495{
Karthik Jadala8e6b2192017-02-08 12:59:16 +0530496 /* Reset sequence for 9650 is different from 9x40, use the reset sequence
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700497 * from clock driver
498 */
anisha agarwal35eb8032017-03-21 13:12:12 -0700499 if (platform_is_mdm9650() || platform_is_sdx20())
Runmin Wangdc8e9732016-10-06 11:14:08 -0700500 clock_reset_usb_phy(); // This is the reset function for USB3
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700501 else
502 usb30_qmp_phy_reset();
503
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700504 qusb2_phy_reset();
Joonwoo Park39aed062014-06-09 17:00:07 -0700505}
506
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700507target_usb_iface_t* target_usb30_init()
508{
509 target_usb_iface_t *t_usb_iface;
510
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800511 t_usb_iface = (target_usb_iface_t *) calloc(1, sizeof(target_usb_iface_t));
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700512 ASSERT(t_usb_iface);
513
514 t_usb_iface->mux_config = NULL;
Mayank Groverd1233272017-11-15 19:52:42 +0530515 t_usb_iface->phy_init = usb30_qmp_phy_init;
Joonwoo Park39aed062014-06-09 17:00:07 -0700516 t_usb_iface->phy_reset = target_usb_phy_reset;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700517 t_usb_iface->clock_init = clock_usb30_init;
518 t_usb_iface->vbus_override = 1;
519
520 return t_usb_iface;
521}
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700522
523uint32_t target_override_pll()
524{
anisha agarwal35eb8032017-03-21 13:12:12 -0700525 if (platform_is_mdm9650() || platform_is_sdx20())
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700526 return 0;
527 else
528 return 1;
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700529}
Channagoud Kadabid23379d2014-10-13 11:33:50 -0700530
531uint32_t target_get_hlos_subtype()
532{
533 return board_hlos_subtype();
534}
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700535
Karthik Jadala8e6b2192017-02-08 12:59:16 +0530536/* QMP settings are different from 9650 when compared to v2.0/v1.0 hardware.
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700537 * Use the QMP settings from target code to keep the common driver clean
538 */
539struct qmp_reg qmp_settings[] =
540{
541 {0x804, 0x01}, /*USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */
542 {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */
543 {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */
544 {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */
545 {0x3C, 0x06}, /* QSERDES_COM_SYS_CLK_CTRL */
546 {0xB4, 0x00}, /* QSERDES_COM_RESETSM_CNTRL */
547 {0xB8, 0x08}, /* QSERDES_COM_RESETSM_CNTRL2 */
548 {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */
549 {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */
550 {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */
551 {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */
552 {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */
553 {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */
554 {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */
555 {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */
556 {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */
557 {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */
558 {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */
559 {0x10C, 0x00}, /* QSERDES_COM_INTEGLOOP_GAIN1_MODE0 */
560 {0x184, 0x0A}, /* QSERDES_COM_CORECLK_DIV */
561 {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */
562 {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */
563 {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */
564 {0xC8, 0x00}, /* QSERDES_COM_LOCK_CMP_EN */
565 {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */
566 {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */
567 {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */
568 {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */
569 {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */
570 {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */
571 {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */
572 {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */
573 {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */
574 {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */
575 {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */
576 {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */
577 {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */
578 {0x100, 0x80}, /* QSERDES_COM_INTEGLOOP_INITVAL */
579
580 /* Rx Settings */
581 {0x440, 0x0b}, /* QSERDES_RX_UCDR_FASTLOCK_FO_GAIN */
582 {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */
583 {0x4dc, 0x6c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */
584 {0x4e0, 0xbb}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */
585 {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
586 {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
587 {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */
588 {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
589 {0x448, 0x75}, /* QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE */
590 {0x450, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_LOW */
591 {0x454, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_HIGH */
592 {0x40C, 0x0a}, /* QSERDES_RX_UCDR_FO_GAIN */
593 {0x41C, 0x06}, /* QSERDES_RX_UCDR_SO_GAIN */
594 {0x510, 0x00}, /*QSERDES_RX_SIGDET_ENABLES */
595
596 /* Tx settings */
597 {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */
598 {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */
599 {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */
600 {0x254, 0x00}, /* QSERDES_TX_RES_CODE_LANE_OFFSET */
601
602 /* FLL settings */
603 {0x8c8, 0x83}, /* PCIE_USB3_PCS_FLL_CNTRL2 */
604 {0x8c4, 0x02}, /* PCIE_USB3_PCS_FLL_CNTRL1 */
605 {0x8cc, 0x09}, /* PCIE_USB3_PCS_FLL_CNT_VAL_L */
606 {0x8D0, 0xA2}, /* PCIE_USB3_PCS_FLL_CNT_VAL_H_TOL */
607 {0x8D4, 0x85}, /* PCIE_USB3_PCS_FLL_MAN_CODE */
608
609 /* PCS Settings */
610 {0x880, 0xD1}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG1 */
611 {0x884, 0x1F}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG2 */
612 {0x888, 0x47}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG3 */
613 {0x80C, 0x9F}, /* PCIE_USB3_PCS_TXMGN_V0 */
614 {0x824, 0x17}, /* PCIE_USB3_PCS_TXDEEMPH_M6DB_V0 */
615 {0x828, 0x0F}, /* PCIE_USB3_PCS_TXDEEMPH_M3P5DB_V0 */
616 {0x8B8, 0x75}, /* PCIE_USB3_PCS_RXEQTRAINING_WAIT_TIME */
617 {0x8BC, 0x13}, /* PCIE_USB3_PCS_RXEQTRAINING_RUN_TIME */
618 {0x8B0, 0x86}, /* PCIE_USB3_PCS_LFPS_TX_ECSTART_EQTLOCK */
619 {0x8A0, 0x04}, /* PCIE_USB3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */
620 {0x88C, 0x44}, /* PCIE_USB3_PCS_TSYNC_RSYNC_TIME */
621 {0x870, 0xE7}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_L */
622 {0x874, 0x03}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_H */
623 {0x878, 0x40}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_L */
624 {0x87c, 0x00}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_H */
625 {0x9D8, 0x88}, /* PCIE_USB3_PCS_RX_SIGDET_LVL */
626 {0x808, 0x03}, /* PCIE_USB3_PCS_START_CONTROL */
627 {0x800, 0x00}, /* PCIE_USB3_PCS_SW_RESET */
628};
629
Mayank Groverd1233272017-11-15 19:52:42 +0530630/* QMP settings are different for sdx20 when compared to v2.0/v1.0 hardware.
631 * Use the QMP settings from target code to keep the common driver clean
632 */
633struct qmp_reg qmp_settings_sdx20[] =
634{
635 {0x804, 0x01}, /* USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */
636 {0x048, 0x07}, /* USB3PHY_QSERDES_COM_PLL_IVCO */
637 {0x080, 0x1A}, /* USB3PHY_QSERDES_COM_SYSCLK_EN_SEL */
638 {0x034, 0x04}, /* USB3PHY_QSERDES_COM_BIAS_EN_CLKBUFLR_EN */
639 {0x138, 0x30}, /* USB3PHY_QSERDES_COM_CLK_SELECT */
640 {0x03C, 0x02}, /* USB3PHY_QSERDES_COM_SYS_CLK_CTRL */
641 {0x08C, 0x08}, /* USB3PHY_QSERDES_COM_RESETSM_CNTRL2 */
642 {0x15C, 0x06}, /* USB3PHY_QSERDES_COM_CMN_CONFIG */
643 {0x164, 0x01}, /* USB3PHY_QSERDES_COM_SVS_MODE_CLK_SEL */
644 {0x13C, 0x80}, /* USB3PHY_QSERDES_COM_HSCLK_SEL */
645 {0x0B0, 0x82}, /* USB3PHY_QSERDES_COM_DEC_START_MODE0 */
646 {0x0B8, 0xAB}, /* USB3PHY_QSERDES_COM_DIV_FRAC_START1_MODE0 */
647 {0x0BC, 0xEA}, /* USB3PHY_QSERDES_COM_DIV_FRAC_START2_MODE0 */
648 {0x0C0, 0x02}, /* USB3PHY_QSERDES_COM_DIV_FRAC_START3_MODE0 */
649 {0x060, 0x06}, /* USB3PHY_QSERDES_COM_CP_CTRL_MODE0 */
650 {0x068, 0x16}, /* USB3PHY_QSERDES_COM_PLL_RCTRL_MODE0 */
651 {0x070, 0x36}, /* USB3PHY_QSERDES_COM_PLL_CCTRL_MODE0 */
652 {0x0DC, 0x00}, /* USB3PHY_QSERDES_COM_INTEGLOOP_GAIN1_MODE0 */
653 {0x0D8, 0x3F}, /* USB3PHY_QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */
654 {0x0F8, 0x01}, /* USB3PHY_QSERDES_COM_VCO_TUNE2_MODE0 */
655 {0x0F4, 0xC9}, /* USB3PHY_QSERDES_COM_VCO_TUNE1_MODE0 */
656 {0x148, 0x0A}, /* USB3PHY_QSERDES_COM_CORECLK_DIV_MODE0 */
657 {0x0A0, 0x00}, /* USB3PHY_QSERDES_COM_LOCK_CMP3_MODE0 */
658 {0x09C, 0x34}, /* USB3PHY_QSERDES_COM_LOCK_CMP2_MODE0 */
659 {0x098, 0x15}, /* USB3PHY_QSERDES_COM_LOCK_CMP1_MODE0 */
660 {0x154, 0x00}, /* USB3PHY_QSERDES_COM_CORE_CLK_EN */
661 {0x094, 0x00}, /* USB3PHY_QSERDES_COM_LOCK_CMP_CFG */
662 {0x0F0, 0x00}, /* USB3PHY_QSERDES_COM_VCO_TUNE_MAP */
663 {0x00C, 0x0A}, /* USB3PHY_QSERDES_COM_BG_TIMER */
664 {0x010, 0x01}, /* USB3PHY_QSERDES_COM_SSC_EN_CENTER */
665 {0x01C, 0x31}, /* USB3PHY_QSERDES_COM_SSC_PER1 */
666 {0x020, 0x01}, /* USB3PHY_QSERDES_COM_SSC_PER2 */
667 {0x014, 0x00}, /* USB3PHY_QSERDES_COM_SSC_ADJ_PER1 */
668 {0x018, 0x00}, /* USB3PHY_QSERDES_COM_SSC_ADJ_PER2 */
669 {0x024, 0x85}, /* USB3PHY_QSERDES_COM_SSC_STEP_SIZE1 */
670 {0x028, 0x07}, /* USB3PHY_QSERDES_COM_SSC_STEP_SIZE2 */
671
672 /* Rx Settings */
673 {0x4C0, 0x0C}, /* USB3PHY_QSERDES_RX_VGA_CAL_CNTRL2 */
674 {0x564, 0x59}, /* USB3PHY_QSERDES_RX_RX_MODE_00 */
675 {0x430, 0x0B}, /* USB3PHY_QSERDES_RX_UCDR_FASTLOCK_FO_GAIN */
676 {0x4D4, 0x0E}, /* USB3PHY_QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */
677 {0x4D8, 0x4E}, /* USB3PHY_QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */
678 {0x4DC, 0x18}, /* USB3PHY_QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */
679 {0x4F8, 0x77}, /* USB3PHY_QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
680 {0x4FC, 0x80}, /* USB3PHY_QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
681 {0x504, 0x03}, /* USB3PHY_QSERDES_RX_SIGDET_CNTRL */
682 {0x50C, 0x1A}, /* USB3PHY_QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
683 {0x50C, 0x1A}, /* USB3PHY_QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
684 {0x260, 0x10}, /* USB3PHY_QSERDES_TX_HIGHZ_DRVR_EN */
685 {0x2A4, 0x12}, /* USB3PHY_QSERDES_TX_RCV_DETECT_LVL_2 */
686 {0x28C, 0xC6}, /* USB3PHY_QSERDES_TX_LANE_MODE_1 */
687 {0x8C8, 0x83}, /* USB3PHY_PCIE_USB3_UNI_PCS_FLL_CNTRL2 */
688 {0x8CC, 0x09}, /* USB3PHY_PCIE_USB3_UNI_PCS_FLL_CNT_VAL_L */
689 {0x8D0, 0xA2}, /* USB3PHY_PCIE_USB3_UNI_PCS_FLL_CNT_VAL_H_TOL */
690 {0x8D0, 0xA2}, /* USB3PHY_PCIE_USB3_UNI_PCS_FLL_CNT_VAL_H_TOL */
691 {0x8D4, 0x40}, /* USB3PHY_PCIE_USB3_UNI_PCS_FLL_MAN_CODE */
692 {0x8C4, 0x02}, /* USB3PHY_PCIE_USB3_UNI_PCS_FLL_CNTRL1 */
693 {0x880, 0xD1}, /* USB3PHY_PCIE_USB3_UNI_PCS_LOCK_DETECT_CONFIG1 */
694 {0x884, 0x1F}, /* USB3PHY_PCIE_USB3_UNI_PCS_LOCK_DETECT_CONFIG2 */
695 {0x888, 0x47}, /* USB3PHY_PCIE_USB3_UNI_PCS_LOCK_DETECT_CONFIG3 */
696 {0x864, 0x1B}, /* USB3PHY_PCIE_USB3_UNI_PCS_POWER_STATE_CONFIG2 */
697 {0x0D0, 0x80}, /* USB3PHY_QSERDES_COM_INTEGLOOP_INITVAL */
698 {0x434, 0x75}, /* USB3PHY_QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE */
699 {0x43C, 0x00}, /* USB3PHY_QSERDES_RX_UCDR_FASTLOCK_COUNT_LOW */
700 {0x440, 0x00}, /* USB3PHY_QSERDES_RX_UCDR_FASTLOCK_COUNT_HIGH */
701 {0x444, 0x80}, /* USB3PHY_QSERDES_RX_UCDR_PI_CONTROLS */
702 {0x408, 0x0A}, /* USB3PHY_QSERDES_RX_UCDR_FO_GAIN */
703 {0x414, 0x06}, /* USB3PHY_QSERDES_RX_UCDR_SO_GAIN */
704 {0x500, 0x00}, /* USB3PHY_QSERDES_RX_SIGDET_ENABLES */
705 {0x244, 0x0D}, /* USB3PHY_QSERDES_TX_RES_CODE_LANE_OFFSET_TX */
706 {0x248, 0x09}, /* USB3PHY_QSERDES_TX_RES_CODE_LANE_OFFSET_RX */
707 {0x80C, 0x9F}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXMGN_V0 */
708 {0x810, 0x9F}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXMGN_V1 */
709 {0x814, 0xB5}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXMGN_V2 */
710 {0x818, 0x4C}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXMGN_V3 */
711 {0x81C, 0x64}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXMGN_V4 */
712 {0x820, 0x6A}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXMGN_LS */
713 {0x824, 0x15}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M6DB_V0 */
714 {0x828, 0x0D}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M3P5DB_V0 */
715 {0x82C, 0x15}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M6DB_V1 */
716 {0x830, 0x0D}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M3P5DB_V1 */
717 {0x834, 0x15}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M6DB_V2 */
718 {0x838, 0x0D}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M3P5DB_V2 */
719 {0x83C, 0x15}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M6DB_V3 */
720 {0x840, 0x0D}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M3P5DB_V3 */
721 {0x844, 0x15}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M6DB_V4 */
722 {0x848, 0x0D}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M3P5DB_V4 */
723 {0x84C, 0x15}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M6DB_LS */
724 {0x850, 0x0D}, /* USB3PHY_PCIE_USB3_UNI_PCS_TXDEEMPH_M3P5DB_LS */
725 {0x85C, 0x02}, /* USB3PHY_PCIE_USB3_UNI_PCS_RATE_SLEW_CNTRL */
726 {0x8B8, 0x75}, /* USB3PHY_PCIE_USB3_UNI_PCS_RXEQTRAINING_WAIT_TIME */
727 {0x8BC, 0x7A}, /* USB3PHY_PCIE_USB3_UNI_PCS_RXEQTRAINING_RUN_TIME */
728 {0x8B0, 0x86}, /* USB3PHY_PCIE_USB3_UNI_PCS_LFPS_TX_ECSTART_EQTLOCK */
729 {0x8A0, 0x04}, /* USB3PHY_PCIE_USB3_UNI_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */
730 {0x88C, 0x44}, /* USB3PHY_PCIE_USB3_UNI_PCS_TSYNC_RSYNC_TIME */
731 {0x880, 0xD1}, /* USB3PHY_PCIE_USB3_UNI_PCS_LOCK_DETECT_CONFIG1 */
732 {0x884, 0x1F}, /* USB3PHY_PCIE_USB3_UNI_PCS_LOCK_DETECT_CONFIG2 */
733 {0x888, 0x47}, /* USB3PHY_PCIE_USB3_UNI_PCS_LOCK_DETECT_CONFIG3 */
734 {0x870, 0xF1}, /* USB3PHY_PCIE_USB3_UNI_PCS_RCVR_DTCT_DLY_P1U2_L */
735 {0x874, 0x01}, /* USB3PHY_PCIE_USB3_UNI_PCS_RCVR_DTCT_DLY_P1U2_H */
736 {0x878, 0x40}, /* USB3PHY_PCIE_USB3_UNI_PCS_RCVR_DTCT_DLY_U3_L */
737 {0x87C, 0x00}, /* USB3PHY_PCIE_USB3_UNI_PCS_RCVR_DTCT_DLY_U3_H */
738// {0x9DB, 0xBA}, /* USB3PHY_PCIE_USB3_UNI_PCS_RX_SIGDET_LVL */
739 {0x8B8, 0x75}, /* USB3PHY_PCIE_USB3_UNI_PCS_RXEQTRAINING_WAIT_TIME */
740 {0x8B0, 0x86}, /* USB3PHY_PCIE_USB3_UNI_PCS_LFPS_TX_ECSTART_EQTLOCK */
741 {0x8BC, 0x13}, /* USB3PHY_PCIE_USB3_UNI_PCS_RXEQTRAINING_RUN_TIME */
742 {0xA0C, 0x21}, /* USB3PHY_PCIE_USB3_UNI_PCS_REFGEN_REQ_CONFIG1 */
743 {0xA10, 0x60}, /* USB3PHY_PCIE_USB3_UNI_PCS_REFGEN_REQ_CONFIG2 */
744 {0x800, 0x00}, /* USB3PHY_PCIE_USB3_UNI_PCS_SW_RESET */
745 {0x808, 0x03}, /* USB3PHY_PCIE_USB3_UNI_PCS_START_CONTROL */
746};
747
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700748struct qmp_reg *target_get_qmp_settings()
749{
Mayank Groverd1233272017-11-15 19:52:42 +0530750 if (platform_is_mdm9650())
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700751 return qmp_settings;
Mayank Groverd1233272017-11-15 19:52:42 +0530752 else if(platform_is_sdx20())
753 return qmp_settings_sdx20;
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700754 else
755 return NULL;
756}
757
758int target_get_qmp_regsize()
759{
Mayank Groverd1233272017-11-15 19:52:42 +0530760 if (platform_is_mdm9650())
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700761 return ARRAY_SIZE(qmp_settings);
Mayank Groverd1233272017-11-15 19:52:42 +0530762 else if(platform_is_sdx20())
763 return ARRAY_SIZE(qmp_settings_sdx20);
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700764 else
765 return 0;
766}
vijay kumar7d06bbb2015-11-24 13:04:55 +0530767
768crypto_engine_type board_ce_type(void)
769{
770 return CRYPTO_ENGINE_TYPE_HW;
771}
772
773/* Set up params for h/w CE. */
774void target_crypto_init_params()
775{
776 struct crypto_init_params ce_params;
777
778 /* Set up base addresses and instance. */
779 ce_params.crypto_instance = CE1_INSTANCE;
780 ce_params.crypto_base = MSM_CE1_BASE;
781 ce_params.bam_base = MSM_CE1_BAM_BASE;
782
783 /* Set up BAM config. */
784 ce_params.bam_ee = CE_EE;
785 ce_params.pipes.read_pipe = CE_READ_PIPE;
786 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
787 ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP;
788 ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP;
789
790 /* Assign buffer sizes. */
791 ce_params.num_ce = CE_ARRAY_SIZE;
792 ce_params.read_fifo_size = CE_FIFO_SIZE;
793 ce_params.write_fifo_size = CE_FIFO_SIZE;
794
795 /* BAM is initialized by TZ for this platform.
796 * Do not do it again as the initialization address space
797 * is locked.
798 */
799 ce_params.do_bam_init = 0;
800 crypto_init_params(&ce_params);
801}