blob: b335731cf000373c7a60f10a7a40475d461c1434 [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);
Runmin Wangc16e4f92016-11-18 17:09:53 -0800153 if(!platform_is_sdxhedgehog())
154 rpm_smd_init();
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700155
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700156 if (platform_boot_dev_isemmc()) {
157 target_sdc_init();
158 if (partition_read_table()) {
159 dprintf(CRITICAL, "Error reading the partition table info\n");
160 ASSERT(0);
161 }
anisha agarwal70b8cd12015-02-02 11:44:46 -0800162 /* Below setting is to enable EBI2 function selection in TLMM so
163 that GPIOs can be used for display */
164 writel((readl(TLMM_EBI2_EMMC_GPIO_CFG) | EBI2_BOOT_SELECT), TLMM_EBI2_EMMC_GPIO_CFG);
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700165 } else {
166 config.pipes.read_pipe = DATA_PRODUCER_PIPE;
167 config.pipes.write_pipe = DATA_CONSUMER_PIPE;
168 config.pipes.cmd_pipe = CMD_PIPE;
169
170 config.pipes.read_pipe_grp = DATA_PRODUCER_PIPE_GRP;
171 config.pipes.write_pipe_grp = DATA_CONSUMER_PIPE_GRP;
172 config.pipes.cmd_pipe_grp = CMD_PIPE_GRP;
173
174 config.bam_base = MSM_NAND_BAM_BASE;
175 config.nand_base = MSM_NAND_BASE;
176 config.ee = QPIC_NAND_EE;
177 config.max_desc_len = QPIC_NAND_MAX_DESC_LEN;
178
179 qpic_nand_init(&config);
180
181 ptable_init(&flash_ptable);
182 smem_ptable_init();
183 smem_add_modem_partitions(&flash_ptable);
184
185 update_ptable_names();
186 flash_set_ptable(&flash_ptable);
187 }
vijay kumar7d06bbb2015-11-24 13:04:55 +0530188
189 if (target_use_signed_kernel())
190 target_crypto_init_params();
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700191}
192
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530193static int scm_clear_boot_partition_select()
194{
195 int ret = 0;
196
197 ret = scm_call_atomic2(SCM_SVC_BOOT, WDOG_DEBUG_DISABLE, 1, 0);
198 if (ret)
199 dprintf(CRITICAL, "Failed to disable the wdog debug \n");
200
201 return ret;
202}
203
204/* Trigger reboot */
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700205void reboot_device(unsigned reboot_reason)
206{
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530207 uint8_t reset_type = 0;
208
Runmin Wang7231ec22016-11-18 11:18:41 -0800209 if (platform_is_mdmcalifornium() || platform_is_sdxhedgehog())
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530210 {
211 /* Clear the boot partition select cookie to indicate
212 * its a normal reset and avoid going to download mode */
213 scm_clear_boot_partition_select();
214 }
215
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700216 /* Write the reboot reason */
217 writel(reboot_reason, RESTART_REASON_ADDR);
218
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530219 if(reboot_reason)
220 reset_type = PON_PSHOLD_WARM_RESET;
Channagoud Kadabia85ed6e2015-03-23 14:35:16 -0700221 else
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530222 reset_type = PON_PSHOLD_HARD_RESET;
223
Runmin Wang7231ec22016-11-18 11:18:41 -0800224 if (platform_is_mdmcalifornium() || platform_is_sdxhedgehog())
P.V. Phani Kumar6b1083d2016-07-19 20:55:04 +0530225 {
226 /* PMD9655 is the PMIC used for MDMcalifornium */
227 pm8x41_reset_configure(reset_type);
228 } else {
229 /* Configure PMIC for warm reset */
230 /* PM 8019 v1 aligns with PM8941 v2.
231 * This call should be based on the pmic version
232 * when PM8019 v2 is available.
233 */
234 pm8x41_v2_reset_configure(reset_type);
235 }
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700236
237 /* Drop PS_HOLD for MSM */
238 writel(0x00, MPM2_MPM_PS_HOLD);
239
240 mdelay(5000);
241
242 dprintf(CRITICAL, "Rebooting failed\n");
243 return;
244}
245
246/* Identify the current target */
247void target_detect(struct board_data *board)
248{
249 /* This property is filled as part of board.c */
250}
251
252unsigned board_machtype(void)
253{
254 return LINUX_MACHTYPE_UNKNOWN;
255}
256
257/* Identify the baseband being used */
258void target_baseband_detect(struct board_data *board)
259{
260 board->baseband = BASEBAND_MSM;
261}
262
Sridhar Parasuram1d8c4222014-10-22 13:43:00 -0700263void target_serialno(unsigned char *buf)
264{
265 uint32_t serialno;
266 serialno = board_chip_serial();
267 snprintf((char *)buf, 13, "%x", serialno);
268}
269
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700270unsigned check_reboot_mode(void)
271{
272 unsigned restart_reason = 0;
273
274 /* Read reboot reason and scrub it */
275 restart_reason = readl(RESTART_REASON_ADDR);
276
277 writel(0x00, RESTART_REASON_ADDR);
278
279 return restart_reason;
280}
281
vijay kumarff36c312015-08-31 17:12:33 +0530282int get_target_boot_params(const char *cmdline, const char *part, char **buf)
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700283{
284 struct ptable *ptable;
285 int system_ptn_index = -1;
vijay kumarff36c312015-08-31 17:12:33 +0530286 uint32_t buflen;
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700287 int ret = -1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700288
vijay kumarff36c312015-08-31 17:12:33 +0530289 if (!cmdline || !part ) {
anisha agarwalce363dd2014-08-26 15:17:09 -0700290 dprintf(CRITICAL, "WARN: Invalid input param\n");
291 return -1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700292 }
293
anisha agarwalce363dd2014-08-26 15:17:09 -0700294 if (!strstr(cmdline, "root=/dev/ram")) /* This check is to handle kdev boot */
295 {
296 if (!target_is_emmc_boot()) {
vijay kumarff36c312015-08-31 17:12:33 +0530297
298 buflen = strlen(UBI_CMDLINE) + strlen(" root=ubi0:rootfs ubi.mtd=") + sizeof(int) + 1;
299 *buf = (char *)malloc(buflen);
300 if(!(*buf)) {
301 dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
302 return -1;
303 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700304 /* Below is for NAND boot */
305 ptable = flash_get_ptable();
306 if (!ptable) {
307 dprintf(CRITICAL,
308 "WARN: Cannot get flash partition table\n");
vijay kumarff36c312015-08-31 17:12:33 +0530309 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700310 return -1;
311 }
312
313 system_ptn_index = ptable_get_index(ptable, part);
314 if (system_ptn_index < 0) {
315 dprintf(CRITICAL,
316 "WARN: Cannot get partition index for %s\n", part);
vijay kumarff36c312015-08-31 17:12:33 +0530317 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700318 return -1;
319 }
320 /* Adding command line parameters according to target boot type */
vijay kumarff36c312015-08-31 17:12:33 +0530321 snprintf(*buf, buflen, UBI_CMDLINE);
322 snprintf(*buf+strlen(*buf), buflen, " root=ubi0:rootfs ubi.mtd=%d", system_ptn_index);
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700323 ret = 0;
anisha agarwalce363dd2014-08-26 15:17:09 -0700324 }
325 else {
Channagoud Kadabi9d9b5212015-10-20 17:29:50 -0700326 buflen = strlen(EXT4_CMDLINE) + sizeof(int) +1;
vijay kumarff36c312015-08-31 17:12:33 +0530327 *buf = (char *)malloc(buflen);
328 if(!(*buf)) {
329 dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
330 return -1;
331 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700332 /* Below is for emmc boot */
anisha agarwalc49a3252014-10-15 17:37:40 -0700333 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 -0700334 if (system_ptn_index < 0) {
335 dprintf(CRITICAL,
336 "WARN: Cannot get partition index for %s\n", part);
vijay kumarff36c312015-08-31 17:12:33 +0530337 free(*buf);
anisha agarwalce363dd2014-08-26 15:17:09 -0700338 return -1;
339 }
vijay kumarff36c312015-08-31 17:12:33 +0530340 snprintf(*buf, buflen, EXT4_CMDLINE"%d", system_ptn_index);
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700341 ret = 0;
anisha agarwalce363dd2014-08-26 15:17:09 -0700342 }
anisha agarwalce363dd2014-08-26 15:17:09 -0700343 }
vijay kumarff36c312015-08-31 17:12:33 +0530344 /*in success case buf will be freed in the calling function of this*/
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700345 return ret;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700346}
347
348const char * target_usb_controller()
349{
350 return "dwc";
351}
352
353static void set_sdc_power_ctrl()
354{
355 /* Drive strength configs for sdc pins */
356 struct tlmm_cfgs sdc1_hdrv_cfg[] =
357 {
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800358 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0 },
359 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0 },
360 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_6MA, TLMM_HDRV_MASK, 0 },
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700361 };
362
363 /* Pull configs for sdc pins */
364 struct tlmm_cfgs sdc1_pull_cfg[] =
365 {
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800366 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0 },
367 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 },
368 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 },
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700369 };
370
371 /* Set the drive strength & pull control values */
372 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
373 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
374}
375
376static struct mmc_device *dev;
377
378void *target_mmc_device()
379{
380 return (void *) dev;
381}
382
383void target_sdc_init()
384{
385 struct mmc_config_data config;
386
387 /* Set drive strength & pull ctrl values */
388 set_sdc_power_ctrl();
389
390 config.slot = 1;
Channagoud Kadabide17ba82014-11-12 13:05:57 -0800391 config.bus_width = DATA_BUS_WIDTH_8BIT;
Channagoud Kadabi6608d022015-04-20 11:31:56 -0700392 config.max_clk_rate = MMC_CLK_171MHZ;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700393 config.sdhc_base = MSM_SDC1_SDHCI_BASE;
394 config.pwrctl_base = MSM_SDC1_BASE;
395 config.pwr_irq = SDCC1_PWRCTL_IRQ;
396 config.hs400_support = 0;
Channagoud Kadabide17ba82014-11-12 13:05:57 -0800397 config.hs200_support = 0;
Channagoud Kadabid23379d2014-10-13 11:33:50 -0700398 config.use_io_switch = 1;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700399
400 if (!(dev = mmc_init(&config))) {
401 dprintf(CRITICAL, "mmc init failed!");
402 ASSERT(0);
403 }
404}
405
anisha agarwal0fc661d2014-11-26 11:54:32 -0800406int target_cont_splash_screen()
407{
408 /* FOR OEMs - Set cont_splash_screen to keep the splash enable after LK.*/
anisha agarwal58d25cf2014-11-26 12:09:23 -0800409 return false;
anisha agarwal0fc661d2014-11-26 11:54:32 -0800410}
411
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700412void target_uninit(void)
413{
414 if (platform_boot_dev_isemmc())
415 {
416 mmc_put_card_to_sleep(dev);
417 sdhci_mode_disable(&dev->host);
418 }
vijay kumar7d06bbb2015-11-24 13:04:55 +0530419
420 if (crypto_initialized())
421 crypto_eng_cleanup();
422
Runmin Wangc16e4f92016-11-18 17:09:53 -0800423 if(!platform_is_sdxhedgehog())
424 rpm_smd_uninit();
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700425}
426
Joonwoo Park39aed062014-06-09 17:00:07 -0700427void target_usb_phy_reset(void)
428{
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700429 /* Reset sequence for californium is different from 9x40, use the reset sequence
430 * from clock driver
431 */
Runmin Wangdc8e9732016-10-06 11:14:08 -0700432 if (platform_is_mdmcalifornium() || platform_is_sdxhedgehog())
433 clock_reset_usb_phy(); // This is the reset function for USB3
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700434 else
435 usb30_qmp_phy_reset();
436
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700437 qusb2_phy_reset();
Joonwoo Park39aed062014-06-09 17:00:07 -0700438}
439
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700440target_usb_iface_t* target_usb30_init()
441{
442 target_usb_iface_t *t_usb_iface;
443
Sridhar Parasuramdbe91a42014-12-29 13:45:30 -0800444 t_usb_iface = (target_usb_iface_t *) calloc(1, sizeof(target_usb_iface_t));
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700445 ASSERT(t_usb_iface);
446
447 t_usb_iface->mux_config = NULL;
Runmin Wangdc8e9732016-10-06 11:14:08 -0700448 if (platform_is_sdxhedgehog())
449 t_usb_iface->phy_init = NULL;
450 else
451 t_usb_iface->phy_init = usb30_qmp_phy_init;
Joonwoo Park39aed062014-06-09 17:00:07 -0700452 t_usb_iface->phy_reset = target_usb_phy_reset;
Joonwoo Parke586c2e2014-04-02 11:04:10 -0700453 t_usb_iface->clock_init = clock_usb30_init;
454 t_usb_iface->vbus_override = 1;
455
456 return t_usb_iface;
457}
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700458
459uint32_t target_override_pll()
460{
Runmin Wangdc8e9732016-10-06 11:14:08 -0700461 if (platform_is_mdmcalifornium() || platform_is_sdxhedgehog())
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700462 return 0;
463 else
464 return 1;
Channagoud Kadabi1b69e482014-09-23 15:20:22 -0700465}
Channagoud Kadabid23379d2014-10-13 11:33:50 -0700466
467uint32_t target_get_hlos_subtype()
468{
469 return board_hlos_subtype();
470}
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700471
472/* QMP settings are different from californium when compared to v2.0/v1.0 hardware.
473 * Use the QMP settings from target code to keep the common driver clean
474 */
475struct qmp_reg qmp_settings[] =
476{
477 {0x804, 0x01}, /*USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */
478 {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */
479 {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */
480 {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */
481 {0x3C, 0x06}, /* QSERDES_COM_SYS_CLK_CTRL */
482 {0xB4, 0x00}, /* QSERDES_COM_RESETSM_CNTRL */
483 {0xB8, 0x08}, /* QSERDES_COM_RESETSM_CNTRL2 */
484 {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */
485 {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */
486 {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */
487 {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */
488 {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */
489 {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */
490 {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */
491 {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */
492 {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */
493 {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */
494 {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */
495 {0x10C, 0x00}, /* QSERDES_COM_INTEGLOOP_GAIN1_MODE0 */
496 {0x184, 0x0A}, /* QSERDES_COM_CORECLK_DIV */
497 {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */
498 {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */
499 {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */
500 {0xC8, 0x00}, /* QSERDES_COM_LOCK_CMP_EN */
501 {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */
502 {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */
503 {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */
504 {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */
505 {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */
506 {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */
507 {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */
508 {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */
509 {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */
510 {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */
511 {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */
512 {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */
513 {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */
514 {0x100, 0x80}, /* QSERDES_COM_INTEGLOOP_INITVAL */
515
516 /* Rx Settings */
517 {0x440, 0x0b}, /* QSERDES_RX_UCDR_FASTLOCK_FO_GAIN */
518 {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */
519 {0x4dc, 0x6c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */
520 {0x4e0, 0xbb}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */
521 {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
522 {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
523 {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */
524 {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
525 {0x448, 0x75}, /* QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE */
526 {0x450, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_LOW */
527 {0x454, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_HIGH */
528 {0x40C, 0x0a}, /* QSERDES_RX_UCDR_FO_GAIN */
529 {0x41C, 0x06}, /* QSERDES_RX_UCDR_SO_GAIN */
530 {0x510, 0x00}, /*QSERDES_RX_SIGDET_ENABLES */
531
532 /* Tx settings */
533 {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */
534 {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */
535 {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */
536 {0x254, 0x00}, /* QSERDES_TX_RES_CODE_LANE_OFFSET */
537
538 /* FLL settings */
539 {0x8c8, 0x83}, /* PCIE_USB3_PCS_FLL_CNTRL2 */
540 {0x8c4, 0x02}, /* PCIE_USB3_PCS_FLL_CNTRL1 */
541 {0x8cc, 0x09}, /* PCIE_USB3_PCS_FLL_CNT_VAL_L */
542 {0x8D0, 0xA2}, /* PCIE_USB3_PCS_FLL_CNT_VAL_H_TOL */
543 {0x8D4, 0x85}, /* PCIE_USB3_PCS_FLL_MAN_CODE */
544
545 /* PCS Settings */
546 {0x880, 0xD1}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG1 */
547 {0x884, 0x1F}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG2 */
548 {0x888, 0x47}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG3 */
549 {0x80C, 0x9F}, /* PCIE_USB3_PCS_TXMGN_V0 */
550 {0x824, 0x17}, /* PCIE_USB3_PCS_TXDEEMPH_M6DB_V0 */
551 {0x828, 0x0F}, /* PCIE_USB3_PCS_TXDEEMPH_M3P5DB_V0 */
552 {0x8B8, 0x75}, /* PCIE_USB3_PCS_RXEQTRAINING_WAIT_TIME */
553 {0x8BC, 0x13}, /* PCIE_USB3_PCS_RXEQTRAINING_RUN_TIME */
554 {0x8B0, 0x86}, /* PCIE_USB3_PCS_LFPS_TX_ECSTART_EQTLOCK */
555 {0x8A0, 0x04}, /* PCIE_USB3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */
556 {0x88C, 0x44}, /* PCIE_USB3_PCS_TSYNC_RSYNC_TIME */
557 {0x870, 0xE7}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_L */
558 {0x874, 0x03}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_H */
559 {0x878, 0x40}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_L */
560 {0x87c, 0x00}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_H */
561 {0x9D8, 0x88}, /* PCIE_USB3_PCS_RX_SIGDET_LVL */
562 {0x808, 0x03}, /* PCIE_USB3_PCS_START_CONTROL */
563 {0x800, 0x00}, /* PCIE_USB3_PCS_SW_RESET */
564};
565
566struct qmp_reg *target_get_qmp_settings()
567{
Runmin Wangdc8e9732016-10-06 11:14:08 -0700568 if (platform_is_mdmcalifornium() || platform_is_sdxhedgehog())
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700569 return qmp_settings;
570 else
571 return NULL;
572}
573
574int target_get_qmp_regsize()
575{
Runmin Wangdc8e9732016-10-06 11:14:08 -0700576 if (platform_is_mdmcalifornium() || platform_is_sdxhedgehog())
Channagoud Kadabifdfee232015-10-07 11:55:47 -0700577 return ARRAY_SIZE(qmp_settings);
578 else
579 return 0;
580}
vijay kumar7d06bbb2015-11-24 13:04:55 +0530581
582crypto_engine_type board_ce_type(void)
583{
584 return CRYPTO_ENGINE_TYPE_HW;
585}
586
587/* Set up params for h/w CE. */
588void target_crypto_init_params()
589{
590 struct crypto_init_params ce_params;
591
592 /* Set up base addresses and instance. */
593 ce_params.crypto_instance = CE1_INSTANCE;
594 ce_params.crypto_base = MSM_CE1_BASE;
595 ce_params.bam_base = MSM_CE1_BAM_BASE;
596
597 /* Set up BAM config. */
598 ce_params.bam_ee = CE_EE;
599 ce_params.pipes.read_pipe = CE_READ_PIPE;
600 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
601 ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP;
602 ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP;
603
604 /* Assign buffer sizes. */
605 ce_params.num_ce = CE_ARRAY_SIZE;
606 ce_params.read_fifo_size = CE_FIFO_SIZE;
607 ce_params.write_fifo_size = CE_FIFO_SIZE;
608
609 /* BAM is initialized by TZ for this platform.
610 * Do not do it again as the initialization address space
611 * is locked.
612 */
613 ce_params.do_bam_init = 0;
614 crypto_init_params(&ce_params);
615}