blob: 98c739d30e2bae147118bbcaf19bc67d6adbd8f3 [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>
Padmanabhan Komanduru0104a892016-01-22 16:58:10 +053061#include "target/display.h"
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053062
63#if LONG_PRESS_POWER_ON
64#include <shutdown_detect.h>
65#endif
66
c_wufeng41310ae2016-01-14 17:59:22 +080067#if PON_VIB_SUPPORT
68#include <vibrator.h>
69#define VIBRATE_TIME 250
70#endif
71
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053072#define PMIC_ARB_CHANNEL_NUM 0
73#define PMIC_ARB_OWNER_ID 0
74#define TLMM_VOL_UP_BTN_GPIO 85
75
76#define FASTBOOT_MODE 0x77665500
P.V. Phani Kumar77826d32015-12-26 20:56:35 +053077#define RECOVERY_MODE 0x77665502
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053078#define PON_SOFT_RB_SPARE 0x88F
anisha agarwalebc52bc2016-07-08 15:50:00 -070079#define EXT4_CMDLINE " rootfstype=ext4 root=/dev/mmcblk0p"
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053080
P.V. Phani Kumar77826d32015-12-26 20:56:35 +053081#define CE1_INSTANCE 1
82#define CE_EE 1
83#define CE_FIFO_SIZE 64
84#define CE_READ_PIPE 3
85#define CE_WRITE_PIPE 2
86#define CE_READ_PIPE_LOCK_GRP 0
87#define CE_WRITE_PIPE_LOCK_GRP 0
88#define CE_ARRAY_SIZE 20
89
Vijay Kumar Pendoti7e9226c2016-09-21 20:49:21 +053090#define SMBCHG_USB_RT_STS 0x21310
91#define USBIN_UV_RT_STS BIT(0)
92
P.V. Phani Kumara053a322015-08-13 18:36:05 +053093struct mmc_device *dev;
94
95static uint32_t mmc_pwrctl_base[] =
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +053096 { MSM_SDC1_BASE, MSM_SDC2_BASE };
97
P.V. Phani Kumara053a322015-08-13 18:36:05 +053098static uint32_t mmc_sdhci_base[] =
99 { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE };
100
101static uint32_t mmc_sdc_pwrctl_irq[] =
102 { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ };
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530103
104void target_early_init(void)
105{
106#if WITH_DEBUG_UART
P.V. Phani Kumar2e4eeae2015-12-31 16:52:54 +0530107 uart_dm_init(1, 0, BLSP1_UART0_BASE);
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530108#endif
109}
110
anisha agarwalebc52bc2016-07-08 15:50:00 -0700111#if _APPEND_CMDLINE
112int get_target_boot_params(const char *cmdline, const char *part, char **buf)
113{
114 int system_ptn_index = -1;
115 uint32_t buflen;
116 int ret = -1;
117
118 if (!cmdline || !part ) {
119 dprintf(CRITICAL, "WARN: Invalid input param\n");
120 return -1;
121 }
122
123 if (!strstr(cmdline, "root=/dev/ram")) /* This check is to handle kdev boot */
124 {
125 if (target_is_emmc_boot()) {
126 buflen = strlen(EXT4_CMDLINE) + sizeof(int) +1;
127 *buf = (char *)malloc(buflen);
128 if(!(*buf)) {
129 dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
130 return -1;
131 }
132 /* Below is for emmc boot */
133 system_ptn_index = partition_get_index(part) + 1; /* Adding +1 as offsets for eMMC start at 1 and NAND at 0 */
134 if (system_ptn_index < 0) {
135 dprintf(CRITICAL,
136 "WARN: Cannot get partition index for %s\n", part);
137 free(*buf);
138 return -1;
139 }
140 snprintf(*buf, buflen, EXT4_CMDLINE"%d", system_ptn_index);
141 ret = 0;
142 }
143 }
144 /*in success case buf will be freed in the calling function of this*/
145 return ret;
146}
147#endif
148
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530149static void set_sdc_power_ctrl()
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530150{
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530151 /* Drive strength configs for sdc pins */
152 struct tlmm_cfgs sdc1_hdrv_cfg[] =
153 {
154 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0},
155 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0},
156 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK , 0},
157 };
158
159 /* Pull configs for sdc pins */
160 struct tlmm_cfgs sdc1_pull_cfg[] =
161 {
162 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0},
163 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
164 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
165 };
166
167 struct tlmm_cfgs sdc1_rclk_cfg[] =
168 {
169 { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, 0},
170 };
171
172 /* Set the drive strength & pull control values */
173 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
174 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
175 tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg));
176}
177
178void target_sdc_init()
179{
180 struct mmc_config_data config;
181
182 /* Set drive strength & pull ctrl values */
183 set_sdc_power_ctrl();
184
185 config.slot = MMC_SLOT;
186 config.bus_width = DATA_BUS_WIDTH_8BIT;
187 config.max_clk_rate = MMC_CLK_192MHZ;
188 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
189 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
190 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
191 config.hs400_support = 1;
192
193 if (!(dev = mmc_init(&config))) {
194 /* Try different config. values */
195 config.max_clk_rate = MMC_CLK_200MHZ;
196 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
197 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
198 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
199 config.hs400_support = 0;
200
201 if (!(dev = mmc_init(&config))) {
202 dprintf(CRITICAL, "mmc init failed!");
203 ASSERT(0);
204 }
205 }
206}
207
208void *target_mmc_device()
209{
210 return (void *) dev;
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530211}
212
213/* Return 1 if vol_up pressed */
Gaurav Nebhwanid9dd0342016-01-28 16:35:55 +0530214int target_volume_up()
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530215{
216 uint8_t status = 0;
217
218 gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);
219
220 /* Wait for the gpio config to take effect - debounce time */
221 thread_sleep(10);
222
223 /* Get status of GPIO */
224 status = gpio_status(TLMM_VOL_UP_BTN_GPIO);
225
226 /* Active high signal. */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530227 return !status;
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530228}
229
230/* Return 1 if vol_down pressed */
231uint32_t target_volume_down()
232{
233 /* Volume down button tied in with PMIC RESIN. */
234 return pm8x41_resin_status();
235}
236
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530237uint32_t target_is_pwrkey_pon_reason()
238{
239 uint8_t pon_reason = pm8950_get_pon_reason();
Vijay Kumar Pendoti7e9226c2016-09-21 20:49:21 +0530240 bool usb_present_sts = !(USBIN_UV_RT_STS &
241 pm8x41_reg_read(SMBCHG_USB_RT_STS));
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530242 if (pm8x41_get_is_cold_boot() && ((pon_reason == KPDPWR_N) || (pon_reason == (KPDPWR_N|PON1))))
243 return 1;
Vijay Kumar Pendoti7e9226c2016-09-21 20:49:21 +0530244 else if ((pon_reason == PON1) && (!usb_present_sts))
245 return 1;
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530246 else
247 return 0;
248}
249
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530250static void target_keystatus()
251{
252 keys_init();
253
254 if(target_volume_down())
255 keys_post_event(KEY_VOLUMEDOWN, 1);
256
257 if(target_volume_up())
258 keys_post_event(KEY_VOLUMEUP, 1);
259}
260
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530261void target_init(void)
262{
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530263#if VERIFIED_BOOT
264#if !VBOOT_MOTA
265 int ret = 0;
266#endif
267#endif
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530268 dprintf(INFO, "target_init()\n");
269
270 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
271
272 target_keystatus();
273
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530274 target_sdc_init();
275 if (partition_read_table())
276 {
277 dprintf(CRITICAL, "Error reading the partition table info\n");
278 ASSERT(0);
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530279 }
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530280
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530281#if LONG_PRESS_POWER_ON
282 shutdown_detect();
283#endif
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530284
c_wufeng41310ae2016-01-14 17:59:22 +0800285#if PON_VIB_SUPPORT
286 vib_timed_turn_on(VIBRATE_TIME);
287#endif
288
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530289
290 if (target_use_signed_kernel())
291 target_crypto_init_params();
292
293#if VERIFIED_BOOT
294#if !VBOOT_MOTA
295 clock_ce_enable(CE1_INSTANCE);
296
297 /* Initialize Qseecom */
298 ret = qseecom_init();
299
300 if (ret < 0)
301 {
302 dprintf(CRITICAL, "Failed to initialize qseecom, error: %d\n", ret);
303 ASSERT(0);
304 }
305
306 /* Start Qseecom */
307 ret = qseecom_tz_init();
308
309 if (ret < 0)
310 {
311 dprintf(CRITICAL, "Failed to start qseecom, error: %d\n", ret);
312 ASSERT(0);
313 }
314
315 if (rpmb_init() < 0)
316 {
317 dprintf(CRITICAL, "RPMB init failed\n");
318 ASSERT(0);
319 }
320
321 /*
322 * Load the sec app for first time
323 */
324 if (load_sec_app() < 0)
325 {
326 dprintf(CRITICAL, "Failed to load App for verified\n");
327 ASSERT(0);
328 }
329#endif
330#endif
331
332#if SMD_SUPPORT
333 rpm_smd_init();
334#endif
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530335}
336
337void target_serialno(unsigned char *buf)
338{
339 uint32_t serialno;
340 if (target_is_emmc_boot()) {
341 serialno = mmc_get_psn();
342 snprintf((char *)buf, 13, "%x", serialno);
343 }
344}
345
346unsigned board_machtype(void)
347{
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530348 return LINUX_MACHTYPE_UNKNOWN;
349}
350
351/* Detect the target type */
352void target_detect(struct board_data *board)
353{
354 /* This is already filled as part of board.c */
355}
356
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530357/* Detect the modem type */
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530358void target_baseband_detect(struct board_data *board)
359{
360 uint32_t platform;
361
362 platform = board->platform;
363
364 switch(platform) {
Gaurav Nebhwani6c945a42016-02-16 17:26:51 +0530365 case MSM8953:
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530366 board->baseband = BASEBAND_MSM;
367 break;
Gaurav Nebhwani6c945a42016-02-16 17:26:51 +0530368 case APQ8053:
Gaurav Nebhwani22a0d9f2015-12-29 13:49:26 +0530369 board->baseband = BASEBAND_APQ;
370 break;
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530371 default:
372 dprintf(CRITICAL, "Platform type: %u is not supported\n",platform);
373 ASSERT(0);
374 };
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530375}
376
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530377unsigned target_baseband()
378{
379 return board_baseband();
380}
lijuang395b5e62015-11-19 17:39:44 +0800381
382int set_download_mode(enum reboot_reason mode)
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530383{
384 int ret = 0;
385 ret = scm_dload_mode(mode);
386
387 pm8x41_clear_pmic_watchdog();
388
389 return ret;
390}
391
392int emmc_recovery_init(void)
393{
394 return _emmc_recovery_init();
395}
396
397unsigned target_pause_for_battery_charge(void)
398{
399 uint8_t pon_reason = pm8x41_get_pon_reason();
400 uint8_t is_cold_boot = pm8x41_get_is_cold_boot();
Zhenhua Huangcf812d72016-01-27 17:27:47 +0800401 bool usb_present_sts = !(USBIN_UV_RT_STS &
402 pm8x41_reg_read(SMBCHG_USB_RT_STS));
403 dprintf(INFO, "%s : pon_reason is:0x%x cold_boot:%d usb_sts:%d\n", __func__,
404 pon_reason, is_cold_boot, usb_present_sts);
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530405 /* In case of fastboot reboot,adb reboot or if we see the power key
406 * pressed we do not want go into charger mode.
407 * fastboot reboot is warm boot with PON hard reset bit not set
408 * adb reboot is a cold boot with PON hard reset bit set
409 */
410 if (is_cold_boot &&
411 (!(pon_reason & HARD_RST)) &&
412 (!(pon_reason & KPDPWR_N)) &&
Zhenhua Huangcf812d72016-01-27 17:27:47 +0800413 usb_present_sts)
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530414 return 1;
415 else
416 return 0;
417}
418
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530419void target_uninit(void)
420{
421 mmc_put_card_to_sleep(dev);
422 sdhci_mode_disable(&dev->host);
423 if (crypto_initialized())
424 crypto_eng_cleanup();
425
426 if (target_is_ssd_enabled())
427 clock_ce_disable(CE1_INSTANCE);
428
429#if VERIFIED_BOOT
430#if !VBOOT_MOTA
431 if (is_sec_app_loaded())
432 {
433 if (send_milestone_call_to_tz() < 0)
434 {
435 dprintf(CRITICAL, "Failed to unload App for rpmb\n");
436 ASSERT(0);
437 }
438 }
439
440 if (rpmb_uninit() < 0)
441 {
442 dprintf(CRITICAL, "RPMB uninit failed\n");
443 ASSERT(0);
444 }
445
446 clock_ce_disable(CE1_INSTANCE);
447#endif
448#endif
449
450#if SMD_SUPPORT
451 rpm_smd_uninit();
452#endif
453}
454
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530455/* UTMI MUX configuration to connect PHY to SNPS controller:
456 * Configure primary HS phy mux to use UTMI interface
457 * (connected to usb30 controller).
458 */
459static void tcsr_hs_phy_mux_configure(void)
460{
461 uint32_t reg;
462
463 reg = readl(USB2_PHY_SEL);
464
465 writel(reg | 0x1, USB2_PHY_SEL);
466}
467
468/* configure hs phy mux if using dwc controller */
469void target_usb_phy_mux_configure(void)
470{
471 if(!strcmp(target_usb_controller(), "dwc"))
472 {
473 tcsr_hs_phy_mux_configure();
474 }
475}
476
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530477void target_usb_phy_reset()
478{
479
480 usb30_qmp_phy_reset();
481 qusb2_phy_reset();
482}
483
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530484/* Initialize target specific USB handlers */
485target_usb_iface_t* target_usb30_init()
486{
487 target_usb_iface_t *t_usb_iface;
488
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530489 t_usb_iface = (target_usb_iface_t *) calloc(1, sizeof(target_usb_iface_t));
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530490 ASSERT(t_usb_iface);
491
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530492 t_usb_iface->mux_config = NULL;
493 t_usb_iface->phy_init = usb30_qmp_phy_init;
494 t_usb_iface->phy_reset = target_usb_phy_reset;
495 t_usb_iface->clock_init = clock_usb30_init;
496 t_usb_iface->vbus_override = 1;
Aparna Mallavarapu01fc00a2015-06-01 20:37:05 +0530497
498 return t_usb_iface;
499}
500
501/* identify the usb controller to be used for the target */
502const char * target_usb_controller()
503{
504 return "dwc";
505}
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530506
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530507/* Do any target specific intialization needed before entering fastboot mode */
508void target_fastboot_init(void)
509{
510 if (target_is_ssd_enabled()) {
511 clock_ce_enable(CE1_INSTANCE);
512 target_load_ssd_keystore();
513 }
514}
515
516void target_load_ssd_keystore(void)
517{
518 uint64_t ptn;
519 int index;
520 uint64_t size;
521 uint32_t *buffer = NULL;
522
523 if (!target_is_ssd_enabled())
524 return;
525
526 index = partition_get_index("ssd");
527
528 ptn = partition_get_offset(index);
529 if (ptn == 0){
530 dprintf(CRITICAL, "Error: ssd partition not found\n");
531 return;
532 }
533
534 size = partition_get_size(index);
535 if (size == 0) {
536 dprintf(CRITICAL, "Error: invalid ssd partition size\n");
537 return;
538 }
539
540 buffer = memalign(CACHE_LINE, ROUNDUP(size, CACHE_LINE));
541 if (!buffer) {
542 dprintf(CRITICAL, "Error: allocating memory for ssd buffer\n");
543 return;
544 }
545
546 if (mmc_read(ptn, buffer, size)) {
547 dprintf(CRITICAL, "Error: cannot read data\n");
548 free(buffer);
549 return;
550 }
551
552 clock_ce_enable(CE1_INSTANCE);
553 scm_protect_keystore(buffer, size);
554 clock_ce_disable(CE1_INSTANCE);
555 free(buffer);
556}
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530557
558crypto_engine_type board_ce_type(void)
559{
560 return CRYPTO_ENGINE_TYPE_HW;
561}
562
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530563/* Set up params for h/w CE. */
564void target_crypto_init_params()
565{
566 struct crypto_init_params ce_params;
567
568 /* Set up base addresses and instance. */
569 ce_params.crypto_instance = CE1_INSTANCE;
570 ce_params.crypto_base = MSM_CE1_BASE;
571 ce_params.bam_base = MSM_CE1_BAM_BASE;
572
573 /* Set up BAM config. */
574 ce_params.bam_ee = CE_EE;
575 ce_params.pipes.read_pipe = CE_READ_PIPE;
576 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
577 ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP;
578 ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP;
579
580 /* Assign buffer sizes. */
581 ce_params.num_ce = CE_ARRAY_SIZE;
582 ce_params.read_fifo_size = CE_FIFO_SIZE;
583 ce_params.write_fifo_size = CE_FIFO_SIZE;
584
585 /* BAM is initialized by TZ for this platform.
586 * Do not do it again as the initialization address space
587 * is locked.
588 */
589 ce_params.do_bam_init = 0;
590
591 crypto_init_params(&ce_params);
592}
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530593
594void pmic_reset_configure(uint8_t reset_type)
595{
P.V. Phani Kumar765fe3e2016-01-23 00:59:03 +0530596 pm8994_reset_configure(reset_type);
P.V. Phani Kumara053a322015-08-13 18:36:05 +0530597}
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530598
599uint32_t target_get_pmic()
600{
601 return PMIC_IS_PMI8950;
602}
603
604struct qmp_reg qmp_settings[] =
605{
Mayank Grovere55fe622016-10-13 18:39:05 +0530606 {0x804, 0x01}, /* USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */
607
608 /* Common block settings */
609 {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */
610 {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530611 {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */
Mayank Grovere55fe622016-10-13 18:39:05 +0530612 {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530613 {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */
614 {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */
Mayank Grovere55fe622016-10-13 18:39:05 +0530615 {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */
616 {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */
617 {0x3C, 0x02}, /* QSERDES_COM_SYS_CLK_CTRL */
618
619 /* PLL & Loop filter settings */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530620 {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */
621 {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */
622 {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */
623 {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */
624 {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */
625 {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */
626 {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */
627 {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530628 {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */
629 {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */
630 {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530631 {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */
632 {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */
633 {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */
634 {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */
Mayank Grovere55fe622016-10-13 18:39:05 +0530635
636 /* SSC Settings */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530637 {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */
638 {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */
639 {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */
640 {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */
641 {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */
642 {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */
643 {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530644
645 /* Rx Settings */
Mayank Grovere55fe622016-10-13 18:39:05 +0530646 {0x41C, 0x06}, /* QSERDES_RX_UCDR_SO_GAIN */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530647 {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */
Mayank Grovere55fe622016-10-13 18:39:05 +0530648 {0x4dc, 0x4c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */
649 {0x4e0, 0xb8}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530650 {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
651 {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
652 {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */
653 {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
Mayank Grovere55fe622016-10-13 18:39:05 +0530654 {0x510, 0x0C}, /* QSERDES_RX_SIGDET_ENABLES */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530655
656 /* Tx settings */
657 {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */
658 {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */
659 {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */
Mayank Grovere55fe622016-10-13 18:39:05 +0530660 {0x824, 0x15}, /* PCIE_USB3_PCS_TXDEEMPH_M6DB_V0 */
661 {0x828, 0x0E}, /* PCIE_USB3_PCS_TXDEEMPH_M3P5DB_V0 */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530662
663 /* FLL settings */
664 {0x8c8, 0x83}, /* PCIE_USB3_PCS_FLL_CNTRL2 */
665 {0x8c4, 0x02}, /* PCIE_USB3_PCS_FLL_CNTRL1 */
666 {0x8cc, 0x09}, /* PCIE_USB3_PCS_FLL_CNT_VAL_L */
667 {0x8D0, 0xA2}, /* PCIE_USB3_PCS_FLL_CNT_VAL_H_TOL */
668 {0x8D4, 0x85}, /* PCIE_USB3_PCS_FLL_MAN_CODE */
669
670 /* PCS Settings */
671 {0x880, 0xD1}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG1 */
672 {0x884, 0x1F}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG2 */
673 {0x888, 0x47}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG3 */
Mayank Grovere55fe622016-10-13 18:39:05 +0530674 {0x864, 0x1B}, /* PCIE_USB3_PCS_POWER_STATE_CONFIG2 */
P.V. Phani Kumar77826d32015-12-26 20:56:35 +0530675 {0x8B8, 0x75}, /* PCIE_USB3_PCS_RXEQTRAINING_WAIT_TIME */
676 {0x8BC, 0x13}, /* PCIE_USB3_PCS_RXEQTRAINING_RUN_TIME */
677 {0x8B0, 0x86}, /* PCIE_USB3_PCS_LFPS_TX_ECSTART_EQTLOCK */
678 {0x8A0, 0x04}, /* PCIE_USB3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */
679 {0x88C, 0x44}, /* PCIE_USB3_PCS_TSYNC_RSYNC_TIME */
680 {0x870, 0xE7}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_L */
681 {0x874, 0x03}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_H */
682 {0x878, 0x40}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_L */
683 {0x87c, 0x00}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_H */
684 {0x9D8, 0x88}, /* PCIE_USB3_PCS_RX_SIGDET_LVL */
685 {0x808, 0x03}, /* PCIE_USB3_PCS_START_CONTROL */
686 {0x800, 0x00}, /* PCIE_USB3_PCS_SW_RESET */
687};
688
689struct qmp_reg *target_get_qmp_settings()
690{
691 return qmp_settings;
692}
693
694int target_get_qmp_regsize()
695{
696 return ARRAY_SIZE(qmp_settings);
697}
Padmanabhan Komanduru0104a892016-01-22 16:58:10 +0530698static uint8_t splash_override;
699/* Returns 1 if target supports continuous splash screen. */
700int target_cont_splash_screen()
701{
702 uint8_t splash_screen = 0;
703 if (!splash_override) {
704 switch (board_hardware_id()) {
705 case HW_PLATFORM_MTP:
706 case HW_PLATFORM_SURF:
707 case HW_PLATFORM_RCM:
708 case HW_PLATFORM_QRD:
709 splash_screen = 1;
710 break;
711 default:
712 splash_screen = 0;
713 break;
714 }
715 dprintf(SPEW, "Target_cont_splash=%d\n", splash_screen);
716 }
717 return splash_screen;
718}
719
720void target_force_cont_splash_disable(uint8_t override)
721{
722 splash_override = override;
723}