blob: 2429cb9b05aafa626b6b00f210004061b3b897f7 [file] [log] [blame]
vijay kumar7d06bbb2015-11-24 13:04:55 +05301/* Copyright (c) 2014-2016, 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>
Joonwoo Parke586c2e2014-04-02 11:04:10 -070059
60extern void smem_ptable_init(void);
61extern void smem_add_modem_partitions(struct ptable *flash_ptable);
62void target_sdc_init();
63
64static struct ptable flash_ptable;
65
66/* PMIC config data */
67#define PMIC_ARB_CHANNEL_NUM 0
68#define PMIC_ARB_OWNER_ID 0
69
70/* NANDc BAM pipe numbers */
71#define DATA_CONSUMER_PIPE 0
72#define DATA_PRODUCER_PIPE 1
73#define CMD_PIPE 2
74
75/* NANDc BAM pipe groups */
76#define DATA_PRODUCER_PIPE_GRP 0
77#define DATA_CONSUMER_PIPE_GRP 0
78#define CMD_PIPE_GRP 1
79
80/* NANDc EE */
81#define QPIC_NAND_EE 0
82
83/* NANDc max desc length. */
84#define QPIC_NAND_MAX_DESC_LEN 0x7FFF
85
86#define LAST_NAND_PTN_LEN_PATTERN 0xFFFFFFFF
87
Smita Ghosh50a53ac2015-02-11 12:33:30 -080088#define EXT4_CMDLINE " rootwait rootfstype=ext4 root=/dev/mmcblk0p"
anisha agarwal11df23e2015-06-12 14:37:34 -070089#define UBI_CMDLINE " rootfstype=ubifs rootflags=bulk_read"
anisha agarwalce363dd2014-08-26 15:17:09 -070090
vijay kumar7d06bbb2015-11-24 13:04:55 +053091#define CE1_INSTANCE 1
92#define CE_EE 1
93#define CE_FIFO_SIZE 64
94#define CE_READ_PIPE 3
95#define CE_WRITE_PIPE 2
96#define CE_READ_PIPE_LOCK_GRP 0
97#define CE_WRITE_PIPE_LOCK_GRP 0
98#define CE_ARRAY_SIZE 20
99#define SUB_TYPE_SKUT 0x0A
100
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700101struct qpic_nand_init_config config;
102
103void update_ptable_names(void)
104{
105 uint32_t ptn_index;
106 struct ptentry *ptentry_ptr = flash_ptable.parts;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700107 unsigned i;
108 uint32_t len;
109
110 /* Change all names to lower case. */
111 for (ptn_index = 0; ptn_index != (uint32_t)flash_ptable.count; ptn_index++)
112 {
113 len = strlen(ptentry_ptr[ptn_index].name);
114
115 for (i = 0; i < len; i++)
116 {
117 if (isupper(ptentry_ptr[ptn_index].name[i]))
118 {
119 ptentry_ptr[ptn_index].name[i] = tolower(ptentry_ptr[ptn_index].name[i]);
120 }
121 }
122
123 /* SBL fills in the last partition length as 0xFFFFFFFF.
124 * Update the length field based on the number of blocks on the flash.
125 */
126 if ((uint32_t)(ptentry_ptr[ptn_index].length) == LAST_NAND_PTN_LEN_PATTERN)
127 {
128 ptentry_ptr[ptn_index].length = flash_num_blocks() - ptentry_ptr[ptn_index].start;
129 }
130 }
131}
132
133void target_early_init(void)
134{
135#if WITH_DEBUG_UART
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700136 uart_dm_init(3, 0, BLSP1_UART2_BASE);
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700137#endif
138}
139
140int target_is_emmc_boot(void)
141{
142 return platform_boot_dev_isemmc();
143}
144
145/* init */
146void target_init(void)
147{
148 dprintf(INFO, "target_init()\n");
149
Sridhar Parasuram9ed91f32015-07-07 15:37:44 -0700150 pmic_info_populate();
151
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700152 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
vijay kumar7d06bbb2015-11-24 13:04:55 +0530153 rpm_smd_init();
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700154
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700155 if (platform_boot_dev_isemmc()) {
156 target_sdc_init();
157 if (partition_read_table()) {
158 dprintf(CRITICAL, "Error reading the partition table info\n");
159 ASSERT(0);
160 }
anisha agarwal70b8cd12015-02-02 11:44:46 -0800161 /* Below setting is to enable EBI2 function selection in TLMM so
162 that GPIOs can be used for display */
163 writel((readl(TLMM_EBI2_EMMC_GPIO_CFG) | EBI2_BOOT_SELECT), TLMM_EBI2_EMMC_GPIO_CFG);
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700164 } else {
165 config.pipes.read_pipe = DATA_PRODUCER_PIPE;
166 config.pipes.write_pipe = DATA_CONSUMER_PIPE;
167 config.pipes.cmd_pipe = CMD_PIPE;
168
169 config.pipes.read_pipe_grp = DATA_PRODUCER_PIPE_GRP;
170 config.pipes.write_pipe_grp = DATA_CONSUMER_PIPE_GRP;
171 config.pipes.cmd_pipe_grp = CMD_PIPE_GRP;
172
173 config.bam_base = MSM_NAND_BAM_BASE;
174 config.nand_base = MSM_NAND_BASE;
175 config.ee = QPIC_NAND_EE;
176 config.max_desc_len = QPIC_NAND_MAX_DESC_LEN;
177
178 qpic_nand_init(&config);
179
180 ptable_init(&flash_ptable);
181 smem_ptable_init();
182 smem_add_modem_partitions(&flash_ptable);
183
184 update_ptable_names();
185 flash_set_ptable(&flash_ptable);
186 }
vijay kumar7d06bbb2015-11-24 13:04:55 +0530187
188 if (target_use_signed_kernel())
189 target_crypto_init_params();
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700190}
191
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530192static int scm_clear_boot_partition_select()
193{
194 int ret = 0;
195
196 ret = scm_call_atomic2(SCM_SVC_BOOT, WDOG_DEBUG_DISABLE, 1, 0);
197 if (ret)
198 dprintf(CRITICAL, "Failed to disable the wdog debug \n");
199
200 return ret;
201}
202
203/* Trigger reboot */
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700204void reboot_device(unsigned reboot_reason)
205{
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530206 uint8_t reset_type = 0;
207
208 if (platform_is_mdmcalifornium())
209 {
210 /* Clear the boot partition select cookie to indicate
211 * its a normal reset and avoid going to download mode */
212 scm_clear_boot_partition_select();
213 }
214
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700215 /* Write the reboot reason */
216 writel(reboot_reason, RESTART_REASON_ADDR);
217
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530218 if(reboot_reason)
219 reset_type = PON_PSHOLD_WARM_RESET;
Channagoud Kadabia85ed6e2015-03-23 14:35:16 -0700220 else
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530221 reset_type = PON_PSHOLD_HARD_RESET;
222
223 if (platform_is_mdmcalifornium())
224 {
225 /* PMD9655 is the PMIC used for MDMcalifornium */
226 pm8x41_reset_configure(reset_type);
227 } else {
228 /* Configure PMIC for warm reset */
229 /* PM 8019 v1 aligns with PM8941 v2.
230 * This call should be based on the pmic version
231 * when PM8019 v2 is available.
232 */
233 pm8x41_v2_reset_configure(reset_type);
234 }
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700235
236 /* Drop PS_HOLD for MSM */
237 writel(0x00, MPM2_MPM_PS_HOLD);
238
239 mdelay(5000);
240
241 dprintf(CRITICAL, "Rebooting failed\n");
242 return;
243}
244
245/* Identify the current target */
246void target_detect(struct board_data *board)
247{
248 /* This property is filled as part of board.c */
249}
250
251unsigned board_machtype(void)
252{
253 return LINUX_MACHTYPE_UNKNOWN;
254}
255
256/* Identify the baseband being used */
257void target_baseband_detect(struct board_data *board)
258{
259 board->baseband = BASEBAND_MSM;
260}
261
Sridhar Parasuram1d8c4222014-10-22 13:43:00 -0700262void target_serialno(unsigned char *buf)
263{
264 uint32_t serialno;
265 serialno = board_chip_serial();
266 snprintf((char *)buf, 13, "%x", serialno);
267}
268
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700269unsigned check_reboot_mode(void)
270{
271 unsigned restart_reason = 0;
272
273 /* Read reboot reason and scrub it */
274 restart_reason = readl(RESTART_REASON_ADDR);
275
276 writel(0x00, RESTART_REASON_ADDR);
277
278 return restart_reason;
279}
280
vijay kumarff36c312015-08-31 17:12:33 +0530281int get_target_boot_params(const char *cmdline, const char *part, char **buf)
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700282{
283 struct ptable *ptable;
284 int system_ptn_index = -1;
vijay kumarff36c312015-08-31 17:12:33 +0530285 uint32_t buflen;
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700286 int ret = -1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700287
vijay kumarff36c312015-08-31 17:12:33 +0530288 if (!cmdline || !part ) {
anisha agarwalce363dd2014-08-26 15:17:09 -0700289 dprintf(CRITICAL, "WARN: Invalid input param\n");
290 return -1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700291 }
292
anisha agarwalce363dd2014-08-26 15:17:09 -0700293 if (!strstr(cmdline, "root=/dev/ram")) /* This check is to handle kdev boot */
294 {
295 if (!target_is_emmc_boot()) {
vijay kumarff36c312015-08-31 17:12:33 +0530296
297 buflen = strlen(UBI_CMDLINE) + strlen(" root=ubi0:rootfs ubi.mtd=") + sizeof(int) + 1;
298 *buf = (char *)malloc(buflen);
299 if(!(*buf)) {
300 dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
301 return -1;
302 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700303 /* Below is for NAND boot */
304 ptable = flash_get_ptable();
305 if (!ptable) {
306 dprintf(CRITICAL,
307 "WARN: Cannot get flash partition table\n");
vijay kumarff36c312015-08-31 17:12:33 +0530308 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700309 return -1;
310 }
311
312 system_ptn_index = ptable_get_index(ptable, part);
313 if (system_ptn_index < 0) {
314 dprintf(CRITICAL,
315 "WARN: Cannot get partition index for %s\n", part);
vijay kumarff36c312015-08-31 17:12:33 +0530316 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700317 return -1;
318 }
319 /* Adding command line parameters according to target boot type */
vijay kumarff36c312015-08-31 17:12:33 +0530320 snprintf(*buf, buflen, UBI_CMDLINE);
321 snprintf(*buf+strlen(*buf), buflen, " root=ubi0:rootfs ubi.mtd=%d", system_ptn_index);
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700322 ret = 0;
anisha agarwalce363dd2014-08-26 15:17:09 -0700323 }
324 else {
Channagoud Kadabi9d9b5212015-10-20 17:29:50 -0700325 buflen = strlen(EXT4_CMDLINE) + sizeof(int) +1;
vijay kumarff36c312015-08-31 17:12:33 +0530326 *buf = (char *)malloc(buflen);
327 if(!(*buf)) {
328 dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
329 return -1;
330 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700331 /* Below is for emmc boot */
anisha agarwalc49a3252014-10-15 17:37:40 -0700332 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 -0700333 if (system_ptn_index < 0) {
334 dprintf(CRITICAL,
335 "WARN: Cannot get partition index for %s\n", part);
vijay kumarff36c312015-08-31 17:12:33 +0530336 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700337 return -1;
338 }
vijay kumarff36c312015-08-31 17:12:33 +0530339 snprintf(*buf, buflen, EXT4_CMDLINE"%d", system_ptn_index);
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700340 ret = 0;
anisha agarwalce363dd2014-08-26 15:17:09 -0700341 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700342 }
vijay kumarff36c312015-08-31 17:12:33 +0530343 /*in success case buf will be freed in the calling function of this*/
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700344 return ret;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700345}
346
347const char * target_usb_controller()
348{
349 return "dwc";
350}
351
352static void set_sdc_power_ctrl()
353{
354 /* Drive strength configs for sdc pins */
355 struct tlmm_cfgs sdc1_hdrv_cfg[] =
356 {
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800357 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0 },
358 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0 },
359 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_6MA, TLMM_HDRV_MASK, 0 },
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700360 };
361
362 /* Pull configs for sdc pins */
363 struct tlmm_cfgs sdc1_pull_cfg[] =
364 {
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800365 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0 },
366 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 },
367 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 },
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700368 };
369
370 /* Set the drive strength & pull control values */
371 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
372 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
373}
374
375static struct mmc_device *dev;
376
377void *target_mmc_device()
378{
379 return (void *) dev;
380}
381
382void target_sdc_init()
383{
384 struct mmc_config_data config;
385
386 /* Set drive strength & pull ctrl values */
387 set_sdc_power_ctrl();
388
389 config.slot = 1;
Channagoud Kadabide17ba82014-11-12 13:05:57 -0800390 config.bus_width = DATA_BUS_WIDTH_8BIT;
Channagoud Kadabi6608d022015-04-20 11:31:56 -0700391 config.max_clk_rate = MMC_CLK_171MHZ;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700392 config.sdhc_base = MSM_SDC1_SDHCI_BASE;
393 config.pwrctl_base = MSM_SDC1_BASE;
394 config.pwr_irq = SDCC1_PWRCTL_IRQ;
395 config.hs400_support = 0;
Channagoud Kadabide17ba82014-11-12 13:05:57 -0800396 config.hs200_support = 0;
Channagoud Kadabid23379d2014-10-13 11:33:50 -0700397 config.use_io_switch = 1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700398
399 if (!(dev = mmc_init(&config))) {
400 dprintf(CRITICAL, "mmc init failed!");
401 ASSERT(0);
402 }
403}
404
anisha agarwal0fc661d2014-11-26 11:54:32 -0800405int target_cont_splash_screen()
406{
407 /* FOR OEMs - Set cont_splash_screen to keep the splash enable after LK.*/
anisha agarwal58d25cf2014-11-26 12:09:23 -0800408 return false;
anisha agarwal0fc661d2014-11-26 11:54:32 -0800409}
410
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700411void target_uninit(void)
412{
413 if (platform_boot_dev_isemmc())
414 {
415 mmc_put_card_to_sleep(dev);
416 sdhci_mode_disable(&dev->host);
417 }
vijay kumar7d06bbb2015-11-24 13:04:55 +0530418
419 if (crypto_initialized())
420 crypto_eng_cleanup();
421
422 rpm_smd_uninit();
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700423}
424
Joonwoo Park39aed062014-06-09 17:00:07 -0700425void target_usb_phy_reset(void)
426{
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700427 /* Reset sequence for californium is different from 9x40, use the reset sequence
428 * from clock driver
429 */
430 if (platform_is_mdmcalifornium())
431 clock_reset_usb_phy();
432 else
433 usb30_qmp_phy_reset();
434
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700435 qusb2_phy_reset();
Joonwoo Park39aed062014-06-09 17:00:07 -0700436}
437
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700438target_usb_iface_t* target_usb30_init()
439{
440 target_usb_iface_t *t_usb_iface;
441
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800442 t_usb_iface = (target_usb_iface_t *) calloc(1, sizeof(target_usb_iface_t));
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700443 ASSERT(t_usb_iface);
444
445 t_usb_iface->mux_config = NULL;
446 t_usb_iface->phy_init = usb30_qmp_phy_init;
Joonwoo Park39aed062014-06-09 17:00:07 -0700447 t_usb_iface->phy_reset = target_usb_phy_reset;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700448 t_usb_iface->clock_init = clock_usb30_init;
449 t_usb_iface->vbus_override = 1;
450
451 return t_usb_iface;
452}
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700453
454uint32_t target_override_pll()
455{
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700456 if (platform_is_mdmcalifornium())
457 return 0;
458 else
459 return 1;
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700460}
Channagoud Kadabid23379d2014-10-13 11:33:50 -0700461
462uint32_t target_get_hlos_subtype()
463{
464 return board_hlos_subtype();
465}
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700466
467/* QMP settings are different from californium when compared to v2.0/v1.0 hardware.
468 * Use the QMP settings from target code to keep the common driver clean
469 */
470struct qmp_reg qmp_settings[] =
471{
472 {0x804, 0x01}, /*USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */
473 {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */
474 {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */
475 {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */
476 {0x3C, 0x06}, /* QSERDES_COM_SYS_CLK_CTRL */
477 {0xB4, 0x00}, /* QSERDES_COM_RESETSM_CNTRL */
478 {0xB8, 0x08}, /* QSERDES_COM_RESETSM_CNTRL2 */
479 {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */
480 {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */
481 {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */
482 {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */
483 {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */
484 {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */
485 {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */
486 {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */
487 {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */
488 {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */
489 {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */
490 {0x10C, 0x00}, /* QSERDES_COM_INTEGLOOP_GAIN1_MODE0 */
491 {0x184, 0x0A}, /* QSERDES_COM_CORECLK_DIV */
492 {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */
493 {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */
494 {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */
495 {0xC8, 0x00}, /* QSERDES_COM_LOCK_CMP_EN */
496 {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */
497 {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */
498 {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */
499 {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */
500 {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */
501 {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */
502 {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */
503 {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */
504 {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */
505 {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */
506 {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */
507 {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */
508 {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */
509 {0x100, 0x80}, /* QSERDES_COM_INTEGLOOP_INITVAL */
510
511 /* Rx Settings */
512 {0x440, 0x0b}, /* QSERDES_RX_UCDR_FASTLOCK_FO_GAIN */
513 {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */
514 {0x4dc, 0x6c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */
515 {0x4e0, 0xbb}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */
516 {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
517 {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
518 {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */
519 {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
520 {0x448, 0x75}, /* QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE */
521 {0x450, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_LOW */
522 {0x454, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_HIGH */
523 {0x40C, 0x0a}, /* QSERDES_RX_UCDR_FO_GAIN */
524 {0x41C, 0x06}, /* QSERDES_RX_UCDR_SO_GAIN */
525 {0x510, 0x00}, /*QSERDES_RX_SIGDET_ENABLES */
526
527 /* Tx settings */
528 {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */
529 {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */
530 {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */
531 {0x254, 0x00}, /* QSERDES_TX_RES_CODE_LANE_OFFSET */
532
533 /* FLL settings */
534 {0x8c8, 0x83}, /* PCIE_USB3_PCS_FLL_CNTRL2 */
535 {0x8c4, 0x02}, /* PCIE_USB3_PCS_FLL_CNTRL1 */
536 {0x8cc, 0x09}, /* PCIE_USB3_PCS_FLL_CNT_VAL_L */
537 {0x8D0, 0xA2}, /* PCIE_USB3_PCS_FLL_CNT_VAL_H_TOL */
538 {0x8D4, 0x85}, /* PCIE_USB3_PCS_FLL_MAN_CODE */
539
540 /* PCS Settings */
541 {0x880, 0xD1}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG1 */
542 {0x884, 0x1F}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG2 */
543 {0x888, 0x47}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG3 */
544 {0x80C, 0x9F}, /* PCIE_USB3_PCS_TXMGN_V0 */
545 {0x824, 0x17}, /* PCIE_USB3_PCS_TXDEEMPH_M6DB_V0 */
546 {0x828, 0x0F}, /* PCIE_USB3_PCS_TXDEEMPH_M3P5DB_V0 */
547 {0x8B8, 0x75}, /* PCIE_USB3_PCS_RXEQTRAINING_WAIT_TIME */
548 {0x8BC, 0x13}, /* PCIE_USB3_PCS_RXEQTRAINING_RUN_TIME */
549 {0x8B0, 0x86}, /* PCIE_USB3_PCS_LFPS_TX_ECSTART_EQTLOCK */
550 {0x8A0, 0x04}, /* PCIE_USB3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */
551 {0x88C, 0x44}, /* PCIE_USB3_PCS_TSYNC_RSYNC_TIME */
552 {0x870, 0xE7}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_L */
553 {0x874, 0x03}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_H */
554 {0x878, 0x40}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_L */
555 {0x87c, 0x00}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_H */
556 {0x9D8, 0x88}, /* PCIE_USB3_PCS_RX_SIGDET_LVL */
557 {0x808, 0x03}, /* PCIE_USB3_PCS_START_CONTROL */
558 {0x800, 0x00}, /* PCIE_USB3_PCS_SW_RESET */
559};
560
561struct qmp_reg *target_get_qmp_settings()
562{
563 if (platform_is_mdmcalifornium())
564 return qmp_settings;
565 else
566 return NULL;
567}
568
569int target_get_qmp_regsize()
570{
571 if (platform_is_mdmcalifornium())
572 return ARRAY_SIZE(qmp_settings);
573 else
574 return 0;
575}
vijay kumar7d06bbb2015-11-24 13:04:55 +0530576
577crypto_engine_type board_ce_type(void)
578{
579 return CRYPTO_ENGINE_TYPE_HW;
580}
581
582/* Set up params for h/w CE. */
583void target_crypto_init_params()
584{
585 struct crypto_init_params ce_params;
586
587 /* Set up base addresses and instance. */
588 ce_params.crypto_instance = CE1_INSTANCE;
589 ce_params.crypto_base = MSM_CE1_BASE;
590 ce_params.bam_base = MSM_CE1_BAM_BASE;
591
592 /* Set up BAM config. */
593 ce_params.bam_ee = CE_EE;
594 ce_params.pipes.read_pipe = CE_READ_PIPE;
595 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
596 ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP;
597 ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP;
598
599 /* Assign buffer sizes. */
600 ce_params.num_ce = CE_ARRAY_SIZE;
601 ce_params.read_fifo_size = CE_FIFO_SIZE;
602 ce_params.write_fifo_size = CE_FIFO_SIZE;
603
604 /* BAM is initialized by TZ for this platform.
605 * Do not do it again as the initialization address space
606 * is locked.
607 */
608 ce_params.do_bam_init = 0;
609 crypto_init_params(&ce_params);
610}