blob: d12a60f69d170624c93436a498e69a7ffad4fb85 [file] [log] [blame]
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -08001/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
2 *
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 <platform/irqs.h>
32#include <platform/gpio.h>
33#include <reg.h>
34#include <target.h>
35#include <platform.h>
36#include <dload_util.h>
37#include <uart_dm.h>
38#include <mmc.h>
39#include <spmi.h>
40#include <board.h>
41#include <smem.h>
42#include <baseband.h>
43#include <dev/keys.h>
44#include <pm8x41.h>
45#include <crypto5_wrapper.h>
46#include <hsusb.h>
47#include <clock.h>
48#include <partition_parser.h>
49#include <scm.h>
50#include <platform/clock.h>
51#include <platform/gpio.h>
52#include <platform/timer.h>
53#include <stdlib.h>
vijay kumar4e5859e2014-09-22 17:49:02 +053054#include <string.h>
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -080055#include <ufs.h>
Sundarajan Srinivasand598b122014-03-21 17:33:29 -070056#include <boot_device.h>
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -070057#include <qmp_phy.h>
Joonwoo Park8b309972014-06-09 16:58:38 -070058#include <qusb2_phy.h>
Sundarajan Srinivasan19b95c72014-07-24 16:37:04 -070059#include <rpm-smd.h>
vijay kumar4e5859e2014-09-22 17:49:02 +053060#include <sdhci_msm.h>
61#include <pm8x41_wled.h>
62#include <qpnp_wled.h>
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -080063
Veera Sundaram Sankaran089f70d2014-12-09 14:17:05 -080064#include "target/display.h"
65
Channagoud Kadabi27ff9342014-06-16 11:19:29 -070066#define CE_INSTANCE 2
Channagoud Kadabi4b93fd32014-06-04 17:28:03 -070067#define CE_EE 1
68#define CE_FIFO_SIZE 64
69#define CE_READ_PIPE 3
70#define CE_WRITE_PIPE 2
71#define CE_READ_PIPE_LOCK_GRP 0
72#define CE_WRITE_PIPE_LOCK_GRP 0
73#define CE_ARRAY_SIZE 20
74
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -080075#define PMIC_ARB_CHANNEL_NUM 0
76#define PMIC_ARB_OWNER_ID 0
77
78#define FASTBOOT_MODE 0x77665500
79
Aparna Mallavarapu965fac92014-08-04 22:45:01 +053080#define PMIC_WLED_SLAVE_ID 3
Channagoud Kadabi41c81a62014-10-08 19:55:30 -070081#define DDR_CFG_DLY_VAL 0x80040870
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -080082
Sridhar Parasuram357d2b92014-12-05 10:39:23 -080083void target_crypto_init_params(void);
Channagoud Kadabie804d642014-08-20 17:43:57 -070084static void set_sdc_power_ctrl(uint8_t slot);
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -080085static uint32_t mmc_pwrctl_base[] =
86 { MSM_SDC1_BASE, MSM_SDC2_BASE };
87
88static uint32_t mmc_sdhci_base[] =
89 { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE };
90
91static uint32_t mmc_sdc_pwrctl_irq[] =
92 { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ };
93
94struct mmc_device *dev;
95struct ufs_dev ufs_device;
96
97extern void ulpi_write(unsigned val, unsigned reg);
Sridhar Parasuram39419a32014-09-12 18:11:05 -070098extern int platform_is_msm8994();
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -080099
100void target_early_init(void)
101{
102#if WITH_DEBUG_UART
103 uart_dm_init(2, 0, BLSP1_UART1_BASE);
104#endif
105}
106
107/* Return 1 if vol_up pressed */
108static int target_volume_up()
109{
110 uint8_t status = 0;
111 struct pm8x41_gpio gpio;
112
113 /* Configure the GPIO */
114 gpio.direction = PM_GPIO_DIR_IN;
115 gpio.function = 0;
116 gpio.pull = PM_GPIO_PULL_UP_30;
117 gpio.vin_sel = 2;
118
119 pm8x41_gpio_config(3, &gpio);
120
121 /* Wait for the pmic gpio config to take effect */
122 thread_sleep(1);
123
124 /* Get status of P_GPIO_5 */
125 pm8x41_gpio_get(3, &status);
126
127 return !status; /* active low */
128}
129
130/* Return 1 if vol_down pressed */
131uint32_t target_volume_down()
132{
133 return pm8x41_resin_status();
134}
135
136static void target_keystatus()
137{
138 keys_init();
139
140 if(target_volume_down())
141 keys_post_event(KEY_VOLUMEDOWN, 1);
142
143 if(target_volume_up())
144 keys_post_event(KEY_VOLUMEUP, 1);
145}
146
147void target_uninit(void)
148{
Sundarajan Srinivasand598b122014-03-21 17:33:29 -0700149 if (platform_boot_dev_isemmc())
Channagoud Kadabid6a45ea2014-06-02 21:12:51 -0700150 {
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800151 mmc_put_card_to_sleep(dev);
Channagoud Kadabid6a45ea2014-06-02 21:12:51 -0700152 /* Disable HC mode before jumping to kernel */
153 sdhci_mode_disable(&dev->host);
154 }
Channagoud Kadabi4b93fd32014-06-04 17:28:03 -0700155
156 if (crypto_initialized())
Channagoud Kadabi2c488742014-12-02 11:37:18 -0800157 {
Channagoud Kadabi4b93fd32014-06-04 17:28:03 -0700158 crypto_eng_cleanup();
Channagoud Kadabi2c488742014-12-02 11:37:18 -0800159 clock_ce_disable(CE_INSTANCE);
160 }
Sundarajan Srinivasan19b95c72014-07-24 16:37:04 -0700161
162 rpm_smd_uninit();
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800163}
164
165/* Do target specific usb initialization */
166void target_usb_init(void)
167{
168 uint32_t val;
169
Sundarajan Srinivasan0ebf2fc2014-04-23 16:45:18 -0700170 if(board_hardware_id() == HW_PLATFORM_DRAGON)
171 {
172 /* Select the QUSB2 PHY */
173 writel(0x1, USB2_PHY_SEL);
174
Joonwoo Park8b309972014-06-09 16:58:38 -0700175 qusb2_phy_reset();
Sundarajan Srinivasan0ebf2fc2014-04-23 16:45:18 -0700176 }
177
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800178 /* Enable sess_vld */
179 val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN;
180 writel(val, USB_GENCONFIG_2);
181
182 /* Enable external vbus configuration in the LINK */
183 val = readl(USB_USBCMD);
184 val |= SESS_VLD_CTRL;
185 writel(val, USB_USBCMD);
186}
187
188void target_usb_stop(void)
189{
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800190}
191
Channagoud Kadabib9473932014-10-09 13:08:35 -0700192unsigned target_pause_for_battery_charge(void)
193{
194 uint8_t pon_reason = pm8x41_get_pon_reason();
195 uint8_t is_cold_boot = pm8x41_get_is_cold_boot();
196 dprintf(INFO, "%s : pon_reason is %d cold_boot:%d\n", __func__,
197 pon_reason, is_cold_boot);
198 /* In case of fastboot reboot,adb reboot or if we see the power key
199 * pressed we do not want go into charger mode.
200 * fastboot reboot is warm boot with PON hard reset bit not set
201 * adb reboot is a cold boot with PON hard reset bit set
202 */
203 if (is_cold_boot &&
204 (!(pon_reason & HARD_RST)) &&
205 (!(pon_reason & KPDPWR_N)) &&
Channagoud Kadabi439833a2014-10-22 13:42:06 -0700206 ((pon_reason & PON1)))
Channagoud Kadabib9473932014-10-09 13:08:35 -0700207 return 1;
208 else
209 return 0;
210}
211
Channagoud Kadabie804d642014-08-20 17:43:57 -0700212static void set_sdc_power_ctrl(uint8_t slot)
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800213{
Channagoud Kadabie804d642014-08-20 17:43:57 -0700214 uint32_t reg = 0;
Channagoud Kadabi751fe7a2014-09-04 18:52:24 -0700215 uint8_t clk;
216 uint8_t cmd;
217 uint8_t dat;
Channagoud Kadabie804d642014-08-20 17:43:57 -0700218
219 if (slot == 0x1)
Channagoud Kadabi751fe7a2014-09-04 18:52:24 -0700220 {
Channagoud Kadabic8da67d2014-11-20 12:07:11 -0800221 clk = TLMM_CUR_VAL_10MA;
Channagoud Kadabi751fe7a2014-09-04 18:52:24 -0700222 cmd = TLMM_CUR_VAL_8MA;
223 dat = TLMM_CUR_VAL_8MA;
Channagoud Kadabie804d642014-08-20 17:43:57 -0700224 reg = SDC1_HDRV_PULL_CTL;
Channagoud Kadabi751fe7a2014-09-04 18:52:24 -0700225 }
Channagoud Kadabie804d642014-08-20 17:43:57 -0700226 else if (slot == 0x2)
Channagoud Kadabi751fe7a2014-09-04 18:52:24 -0700227 {
228 clk = TLMM_CUR_VAL_16MA;
229 cmd = TLMM_CUR_VAL_10MA;
230 dat = TLMM_CUR_VAL_10MA;
Channagoud Kadabie804d642014-08-20 17:43:57 -0700231 reg = SDC2_HDRV_PULL_CTL;
Channagoud Kadabi751fe7a2014-09-04 18:52:24 -0700232 }
233 else
234 {
235 dprintf(CRITICAL, "Unsupported SDC slot passed\n");
236 return;
237 }
Channagoud Kadabie804d642014-08-20 17:43:57 -0700238
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800239 /* Drive strength configs for sdc pins */
240 struct tlmm_cfgs sdc1_hdrv_cfg[] =
241 {
Channagoud Kadabi751fe7a2014-09-04 18:52:24 -0700242 { SDC1_CLK_HDRV_CTL_OFF, clk, TLMM_HDRV_MASK, reg },
243 { SDC1_CMD_HDRV_CTL_OFF, cmd, TLMM_HDRV_MASK, reg },
244 { SDC1_DATA_HDRV_CTL_OFF, dat, TLMM_HDRV_MASK, reg },
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800245 };
246
247 /* Pull configs for sdc pins */
248 struct tlmm_cfgs sdc1_pull_cfg[] =
249 {
Channagoud Kadabie804d642014-08-20 17:43:57 -0700250 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, reg },
251 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg },
252 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg },
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800253 };
254
Channagoud Kadabi95717152014-06-04 17:59:29 -0700255 struct tlmm_cfgs sdc1_rclk_cfg[] =
256 {
Channagoud Kadabie804d642014-08-20 17:43:57 -0700257 { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, reg },
Channagoud Kadabi95717152014-06-04 17:59:29 -0700258 };
259
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800260 /* Set the drive strength & pull control values */
261 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
262 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
Channagoud Kadabi95717152014-06-04 17:59:29 -0700263 tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg));
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800264}
265
266void target_sdc_init()
267{
Channagoud Kadabia66a6f22014-05-28 17:19:44 -0700268 struct mmc_config_data config = {0};
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800269
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800270 config.bus_width = DATA_BUS_WIDTH_8BIT;
271 config.max_clk_rate = MMC_CLK_192MHZ;
272
273 /* Try slot 1*/
274 config.slot = 1;
275 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
276 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
277 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
Channagoud Kadabi6b3a9982014-06-05 12:59:46 -0700278 config.hs400_support = 1;
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800279
Channagoud Kadabie804d642014-08-20 17:43:57 -0700280 /* Set drive strength & pull ctrl values */
281 set_sdc_power_ctrl(config.slot);
282
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800283 if (!(dev = mmc_init(&config)))
284 {
285 /* Try slot 2 */
286 config.slot = 2;
287 config.max_clk_rate = MMC_CLK_200MHZ;
288 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
289 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
290 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
291
Channagoud Kadabie804d642014-08-20 17:43:57 -0700292 /* Set drive strength & pull ctrl values */
293 set_sdc_power_ctrl(config.slot);
294
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800295 if (!(dev = mmc_init(&config)))
296 {
297 dprintf(CRITICAL, "mmc init failed!");
298 ASSERT(0);
299 }
300 }
301}
302
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800303void *target_mmc_device()
304{
Sundarajan Srinivasand598b122014-03-21 17:33:29 -0700305 if (platform_boot_dev_isemmc())
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800306 return (void *) dev;
307 else
308 return (void *) &ufs_device;
309}
310
311void target_init(void)
312{
313 dprintf(INFO, "target_init()\n");
314
315 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
316
317 target_keystatus();
318
Channagoud Kadabi4b93fd32014-06-04 17:28:03 -0700319
320 if (target_use_signed_kernel())
321 target_crypto_init_params();
322
Sundarajan Srinivasand598b122014-03-21 17:33:29 -0700323 platform_read_boot_config();
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800324
Sundarajan Srinivasand598b122014-03-21 17:33:29 -0700325 if (platform_boot_dev_isemmc())
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800326 {
327 target_sdc_init();
328 }
329 else
330 {
331 ufs_device.base = UFS_BASE;
332 ufs_init(&ufs_device);
333 }
334
335 /* Storage initialization is complete, read the partition table info */
Channagoud Kadabi78a368e2014-10-21 22:25:35 -0700336 mmc_read_partition_table(0);
Sundarajan Srinivasan19b95c72014-07-24 16:37:04 -0700337
338 rpm_smd_init();
Aparna Mallavarapu965fac92014-08-04 22:45:01 +0530339
340 /* QPNP WLED init for display backlight */
341 pm8x41_wled_config_slave_id(PMIC_WLED_SLAVE_ID);
342 qpnp_wled_init();
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800343}
344
345unsigned board_machtype(void)
346{
347 return LINUX_MACHTYPE_UNKNOWN;
348}
349
350/* Detect the target type */
351void target_detect(struct board_data *board)
352{
353 /* This is filled from board.c */
354}
355
Justin Philipbe9de5c2014-09-17 12:26:49 +0530356static uint8_t splash_override;
Dhaval Patel019057a2014-08-12 13:52:25 -0700357/* Returns 1 if target supports continuous splash screen. */
358int target_cont_splash_screen()
359{
Justin Philipbe9de5c2014-09-17 12:26:49 +0530360 uint8_t splash_screen = 0;
361 if(!splash_override) {
362 switch(board_hardware_id())
363 {
364 case HW_PLATFORM_SURF:
365 case HW_PLATFORM_MTP:
366 case HW_PLATFORM_FLUID:
Siddhartha Agrawalcddb0b82014-10-14 15:07:18 -0700367 case HW_PLATFORM_LIQUID:
Ilia Lin45668192014-11-23 16:15:03 +0200368 case HW_PLATFORM_DRAGON:
Justin Philipbe9de5c2014-09-17 12:26:49 +0530369 dprintf(SPEW, "Target_cont_splash=1\n");
370 splash_screen = 1;
371 break;
372 default:
373 dprintf(SPEW, "Target_cont_splash=0\n");
374 splash_screen = 0;
375 }
376 }
377 return splash_screen;
378}
379
380void target_force_cont_splash_disable(uint8_t override)
381{
382 splash_override = override;
Dhaval Patel019057a2014-08-12 13:52:25 -0700383}
384
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800385/* Detect the modem type */
386void target_baseband_detect(struct board_data *board)
387{
388 uint32_t platform;
389
390 platform = board->platform;
391
392 switch(platform) {
Channagoud Kadabi44ea30d2014-04-14 13:59:42 -0700393 case MSM8994:
Channagoud Kadabi23c90ab2014-08-28 15:49:19 -0700394 case MSM8992:
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800395 board->baseband = BASEBAND_MSM;
396 break;
Channagoud Kadabi30ef4452014-07-12 13:03:30 -0700397 case APQ8094:
Channagoud Kadabi23c90ab2014-08-28 15:49:19 -0700398 case APQ8092:
Channagoud Kadabi30ef4452014-07-12 13:03:30 -0700399 board->baseband = BASEBAND_APQ;
400 break;
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800401 default:
402 dprintf(CRITICAL, "Platform type: %u is not supported\n",platform);
403 ASSERT(0);
404 };
405}
406unsigned target_baseband()
407{
408 return board_baseband();
409}
410
411void target_serialno(unsigned char *buf)
412{
Pothuluraiah Usarthi79e70ba2014-11-22 11:11:44 -0800413 unsigned int serialno;
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800414 if (target_is_emmc_boot()) {
Pothuluraiah Usarthi79e70ba2014-11-22 11:11:44 -0800415 serialno = mmc_get_psn();
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800416 snprintf((char *)buf, 13, "%x", serialno);
417 }
418}
419
420unsigned check_reboot_mode(void)
421{
422 uint32_t restart_reason = 0;
423 uint32_t restart_reason_addr;
424
Sridhar Parasuram39419a32014-09-12 18:11:05 -0700425 if (platform_is_msm8994())
426 restart_reason_addr = RESTART_REASON_ADDR;
427 else
428 restart_reason_addr = RESTART_REASON_ADDR2;
Channagoud Kadabi0f3a4f72014-02-06 13:22:07 -0800429
430 /* Read reboot reason and scrub it */
431 restart_reason = readl(restart_reason_addr);
432 writel(0x00, restart_reason_addr);
433
434 return restart_reason;
435}
436
437void reboot_device(unsigned reboot_reason)
438{
439 uint8_t reset_type = 0;
440
441 /* Write the reboot reason */
442 writel(reboot_reason, RESTART_REASON_ADDR);
443
444 if(reboot_reason == FASTBOOT_MODE)
445 reset_type = PON_PSHOLD_WARM_RESET;
446 else
447 reset_type = PON_PSHOLD_HARD_RESET;
448
449 pm8x41_reset_configure(reset_type);
450
451 /* Drop PS_HOLD for MSM */
452 writel(0x00, MPM2_MPM_PS_HOLD);
453
454 mdelay(5000);
455
456 dprintf(CRITICAL, "Rebooting failed\n");
457}
458
459int emmc_recovery_init(void)
460{
461 return _emmc_recovery_init();
462}
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -0700463
464target_usb_iface_t* target_usb30_init()
465{
466 target_usb_iface_t *t_usb_iface;
467
468 t_usb_iface = calloc(1, sizeof(target_usb_iface_t));
469 ASSERT(t_usb_iface);
470
471 t_usb_iface->mux_config = target_usb_phy_mux_configure;
472 t_usb_iface->phy_init = usb30_qmp_phy_init;
473 t_usb_iface->phy_reset = usb30_qmp_phy_reset;
474 t_usb_iface->clock_init = clock_usb30_init;
475 t_usb_iface->vbus_override = 1;
476
477 return t_usb_iface;
478}
479
480/* identify the usb controller to be used for the target */
481const char * target_usb_controller()
482{
Tanya Finkel90abab72014-07-30 09:55:23 +0300483 if(board_hardware_id() == HW_PLATFORM_DRAGON)
484 return "ci";
Channagoud Kadabi3dcc4ed2014-04-10 14:59:41 -0700485 return "dwc";
486}
487
488/* mux hs phy to route to dwc controller */
489static void phy_mux_configure_with_tcsr()
490{
491 /* As per the hardware team, set the mux for snps controller */
492 RMWREG32(TCSR_PHSS_USB2_PHY_SEL, 0x0, 0x1, 0x1);
493}
494
495/* configure hs phy mux if using dwc controller */
496void target_usb_phy_mux_configure(void)
497{
498 if(!strcmp(target_usb_controller(), "dwc"))
499 {
500 phy_mux_configure_with_tcsr();
501 }
502}
Channagoud Kadabi3c2be1c2014-06-01 18:59:21 -0700503
504uint32_t target_override_pll()
505{
506 return 1;
507}
Channagoud Kadabi4b93fd32014-06-04 17:28:03 -0700508
509/* Set up params for h/w CE. */
510void target_crypto_init_params()
511{
512 struct crypto_init_params ce_params;
513
514 /* Set up base addresses and instance. */
515 ce_params.crypto_instance = CE_INSTANCE;
Channagoud Kadabi27ff9342014-06-16 11:19:29 -0700516 ce_params.crypto_base = MSM_CE2_BASE;
517 ce_params.bam_base = MSM_CE2_BAM_BASE;
Channagoud Kadabi4b93fd32014-06-04 17:28:03 -0700518
519 /* Set up BAM config. */
520 ce_params.bam_ee = CE_EE;
521 ce_params.pipes.read_pipe = CE_READ_PIPE;
522 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
523 ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP;
524 ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP;
525
526 /* Assign buffer sizes. */
527 ce_params.num_ce = CE_ARRAY_SIZE;
528 ce_params.read_fifo_size = CE_FIFO_SIZE;
529 ce_params.write_fifo_size = CE_FIFO_SIZE;
530
531 /* BAM is initialized by TZ for this platform.
532 * Do not do it again as the initialization address space
533 * is locked.
534 */
535 ce_params.do_bam_init = 0;
536
537 crypto_init_params(&ce_params);
538}
539
540crypto_engine_type board_ce_type(void)
541{
542 return CRYPTO_ENGINE_TYPE_HW;
543}
Channagoud Kadabi84f860f2014-07-01 15:46:09 -0700544
545void shutdown_device()
546{
547 dprintf(CRITICAL, "Going down for shutdown.\n");
548
549 /* Configure PMIC for shutdown. */
550 pm8x41_reset_configure(PON_PSHOLD_SHUTDOWN);
551
552 /* Drop PS_HOLD for MSM */
553 writel(0x00, MPM2_MPM_PS_HOLD);
554
555 mdelay(5000);
556
557 dprintf(CRITICAL, "Shutdown failed\n");
558
559 ASSERT(0);
560}
Sundarajan Srinivasancd3bb3c2014-07-23 12:25:44 -0700561
Channagoud Kadabi41c81a62014-10-08 19:55:30 -0700562uint32_t target_ddr_cfg_val()
563{
564 return DDR_CFG_DLY_VAL;
565}