blob: 46f5f7ea336ef0d0457eec5314a024236189727c [file] [log] [blame]
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +05301/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -08002 *
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>
Channagoud Kadabi25e4d932013-05-10 17:54:29 -070031#include <platform/irqs.h>
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -080032#include <reg.h>
33#include <target.h>
34#include <platform.h>
Aparna Mallavarapu6d4ec9e2014-02-16 02:22:12 +053035#include <dload_util.h>
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -080036#include <uart_dm.h>
37#include <mmc.h>
Deepa Dinamani8ff46f02013-03-20 17:52:14 -070038#include <platform/gpio.h>
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -080039#include <spmi.h>
40#include <board.h>
Deepa Dinamani41803e02013-03-25 11:44:15 -070041#include <smem.h>
42#include <baseband.h>
Deepa Dinamani8ff46f02013-03-20 17:52:14 -070043#include <dev/keys.h>
44#include <pm8x41.h>
Deepa Dinamani98cf8ee2013-03-27 15:16:47 -070045#include <hsusb.h>
richardlb52d3f52013-04-12 17:37:28 -070046#include <kernel/thread.h>
Amol Jadif2139012013-08-23 18:44:10 -070047#include <arch/defines.h>
48#include <stdlib.h>
49#include <scm.h>
50#include <partition_parser.h>
51#include <platform/clock.h>
52#include <platform/timer.h>
Channagoud Kadabida988fd2013-12-04 13:44:42 -080053#include <crypto5_wrapper.h>
Matthew Qinb894e682014-04-10 17:02:45 +080054
55#if LONG_PRESS_POWER_ON
Matthew Qin7e7bb4b2014-03-06 13:20:00 +080056#include <shutdown_detect.h>
Matthew Qinb894e682014-04-10 17:02:45 +080057#endif
58
Matthew Qine91ba6e2014-04-15 13:01:10 +080059#if PON_VIB_SUPPORT
Matthew Qin19ad5362014-03-06 13:42:35 +080060#include <vibrator.h>
Matthew Qine91ba6e2014-04-15 13:01:10 +080061#endif
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -080062
63#define PMIC_ARB_CHANNEL_NUM 0
64#define PMIC_ARB_OWNER_ID 0
65
Channagoud Kadabida988fd2013-12-04 13:44:42 -080066#define CRYPTO_ENGINE_INSTANCE 1
67#define CRYPTO_ENGINE_EE 1
68#define CRYPTO_ENGINE_FIFO_SIZE 64
69#define CRYPTO_ENGINE_READ_PIPE 3
70#define CRYPTO_ENGINE_WRITE_PIPE 2
71#define CRYPTO_READ_PIPE_LOCK_GRP 0
72#define CRYPTO_WRITE_PIPE_LOCK_GRP 0
73#define CRYPTO_ENGINE_CMD_ARRAY_SIZE 20
74
Deepa Dinamani8ff46f02013-03-20 17:52:14 -070075#define TLMM_VOL_UP_BTN_GPIO 72
Matthew Qine91ba6e2014-04-15 13:01:10 +080076
77#if PON_VIB_SUPPORT
Matthew Qin19ad5362014-03-06 13:42:35 +080078#define VIBRATE_TIME 250
Matthew Qine91ba6e2014-04-15 13:01:10 +080079#endif
Deepa Dinamani8ff46f02013-03-20 17:52:14 -070080
Maria Yu00fd3822013-06-26 10:12:54 +080081enum target_subtype {
82 HW_PLATFORM_SUBTYPE_SKUAA = 1,
83 HW_PLATFORM_SUBTYPE_SKUF = 2,
84 HW_PLATFORM_SUBTYPE_SKUAB = 3,
85};
86
Channagoud Kadabi25e4d932013-05-10 17:54:29 -070087static void set_sdc_power_ctrl(void);
88
89static uint32_t mmc_pwrctl_base[] =
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -080090 { MSM_SDC1_BASE, MSM_SDC2_BASE };
91
Channagoud Kadabi25e4d932013-05-10 17:54:29 -070092static uint32_t mmc_sdhci_base[] =
93 { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE };
94
95static uint32_t mmc_sdc_pwrctl_irq[] =
96 { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ };
97
98struct mmc_device *dev;
99
vijay kumar0411ca82014-08-08 17:14:52 +0530100void target_crypto_init_params();
101
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800102void target_early_init(void)
103{
104#if WITH_DEBUG_UART
Deepa Dinamanid1823b42013-03-21 11:49:35 -0700105 uart_dm_init(2, 0, BLSP1_UART1_BASE);
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800106#endif
107}
108
Deepa Dinamani8ff46f02013-03-20 17:52:14 -0700109/* Return 1 if vol_up pressed */
110static int target_volume_up()
111{
112 uint8_t status = 0;
113
114 gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);
115
richardlb52d3f52013-04-12 17:37:28 -0700116 /* Wait for the configuration to complete.*/
117 thread_sleep(1);
Deepa Dinamani8ff46f02013-03-20 17:52:14 -0700118 /* Get status of GPIO */
119 status = gpio_status(TLMM_VOL_UP_BTN_GPIO);
120
121 /* Active low signal. */
122 return !status;
123}
124
125/* Return 1 if vol_down pressed */
126uint32_t target_volume_down()
127{
128 /* Volume down button tied in with PMIC RESIN. */
129 return pm8x41_resin_status();
130}
131
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800132static void target_keystatus()
133{
Deepa Dinamani8ff46f02013-03-20 17:52:14 -0700134 keys_init();
135
136 if(target_volume_down())
137 keys_post_event(KEY_VOLUMEDOWN, 1);
138
139 if(target_volume_up())
140 keys_post_event(KEY_VOLUMEUP, 1);
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800141}
142
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700143void target_sdc_init()
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800144{
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700145 struct mmc_config_data config;
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800146
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700147 /* Set drive strength & pull ctrl values */
148 set_sdc_power_ctrl();
Deepa Dinamani8ff46f02013-03-20 17:52:14 -0700149
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700150 config.bus_width = DATA_BUS_WIDTH_8BIT;
151 config.max_clk_rate = MMC_CLK_200MHZ;
152
153 /* Try slot 1*/
154 config.slot = 1;
155 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
156 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
157 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
Aparna Mallavarapu1a5c9d52014-03-11 13:48:13 +0530158 config.hs400_support = 0;
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700159
160 if (!(dev = mmc_init(&config)))
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800161 {
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700162 /* Try slot 2 */
163 config.slot = 2;
164 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
165 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
166 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800167
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700168 if (!(dev = mmc_init(&config)))
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800169 {
170 dprintf(CRITICAL, "mmc init failed!");
171 ASSERT(0);
172 }
173 }
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700174
175 /* MMC initialization is complete, read the partition table info */
176 if (partition_read_table())
177 {
178 dprintf(CRITICAL, "Error reading the partition table info\n");
179 ASSERT(0);
180 }
181}
182
183void target_init(void)
184{
185 dprintf(INFO, "target_init()\n");
186
187 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
188
189 target_keystatus();
190
191 target_sdc_init();
Aparna Mallavarapu6fe7a902013-09-11 20:19:11 +0530192
Matthew Qinb894e682014-04-10 17:02:45 +0800193#if LONG_PRESS_POWER_ON
Matthew Qin7e7bb4b2014-03-06 13:20:00 +0800194 shutdown_detect();
Matthew Qinb894e682014-04-10 17:02:45 +0800195#endif
Matthew Qin7e7bb4b2014-03-06 13:20:00 +0800196
Matthew Qine91ba6e2014-04-15 13:01:10 +0800197#if PON_VIB_SUPPORT
Matthew Qin19ad5362014-03-06 13:42:35 +0800198 /* turn on vibrator to indicate that phone is booting up to end user */
199 vib_timed_turn_on(VIBRATE_TIME);
Matthew Qine91ba6e2014-04-15 13:01:10 +0800200#endif
Matthew Qin19ad5362014-03-06 13:42:35 +0800201
Channagoud Kadabida988fd2013-12-04 13:44:42 -0800202 if (target_use_signed_kernel())
203 target_crypto_init_params();
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800204}
205
Aparna Mallavarapu2ce9f762013-07-30 15:29:12 +0530206void target_uninit(void)
207{
Matthew Qine91ba6e2014-04-15 13:01:10 +0800208#if PON_VIB_SUPPORT
Matthew Qin19ad5362014-03-06 13:42:35 +0800209 /* wait for the vibrator timer is expried */
210 wait_vib_timeout();
Matthew Qine91ba6e2014-04-15 13:01:10 +0800211#endif
Matthew Qin19ad5362014-03-06 13:42:35 +0800212
Channagoud Kadabid93cb812013-12-04 16:37:32 -0800213 mmc_put_card_to_sleep(dev);
214
215 if (crypto_initialized())
216 crypto_eng_cleanup();
Aparna Mallavarapuaeac7982014-09-22 18:36:24 +0530217
218 /* Disable HC mode before jumping to kernel */
219 sdhci_mode_disable(&dev->host);
Aparna Mallavarapu2ce9f762013-07-30 15:29:12 +0530220}
Amol Jadif2139012013-08-23 18:44:10 -0700221
222#define SSD_CE_INSTANCE 1
223
224void target_load_ssd_keystore(void)
225{
226 uint64_t ptn;
227 int index;
228 uint64_t size;
229 uint32_t *buffer;
230
231 if (!target_is_ssd_enabled())
232 return;
233
234 index = partition_get_index("ssd");
235
236 ptn = partition_get_offset(index);
237 if (ptn == 0){
238 dprintf(CRITICAL, "Error: ssd partition not found\n");
239 return;
240 }
241
242 size = partition_get_size(index);
243 if (size == 0) {
244 dprintf(CRITICAL, "Error: invalid ssd partition size\n");
245 return;
246 }
247
248 buffer = memalign(CACHE_LINE, ROUNDUP(size, CACHE_LINE));
249 if (!buffer) {
250 dprintf(CRITICAL, "Error: allocating memory for ssd buffer\n");
251 return;
252 }
253
254 if (mmc_read(ptn, buffer, size)) {
255 dprintf(CRITICAL, "Error: cannot read data\n");
256 free(buffer);
257 return;
258 }
259
260 clock_ce_enable(SSD_CE_INSTANCE);
261 scm_protect_keystore(buffer, size);
262 clock_ce_disable(SSD_CE_INSTANCE);
263 free(buffer);
264}
265
Deepa Dinamani2b795bb2013-03-25 11:31:58 -0700266/* Do any target specific intialization needed before entering fastboot mode */
267void target_fastboot_init(void)
268{
269 /* Set the BOOT_DONE flag in PM8110 */
270 pm8x41_set_boot_done();
Amol Jadif2139012013-08-23 18:44:10 -0700271
272 if (target_is_ssd_enabled()) {
273 clock_ce_enable(SSD_CE_INSTANCE);
274 target_load_ssd_keystore();
275 }
276
Deepa Dinamani2b795bb2013-03-25 11:31:58 -0700277}
278
Deepa Dinamani41803e02013-03-25 11:44:15 -0700279/* Detect the target type */
280void target_detect(struct board_data *board)
281{
Maria Yuca51ee22013-06-27 21:45:24 +0800282 /*
283 * already fill the board->target on board.c
284 */
285
Deepa Dinamani41803e02013-03-25 11:44:15 -0700286}
287
288/* Detect the modem type */
289void target_baseband_detect(struct board_data *board)
290{
291 uint32_t platform;
292 uint32_t platform_subtype;
293
294 platform = board->platform;
295 platform_subtype = board->platform_subtype;
296
297 /*
298 * Look for platform subtype if present, else
299 * check for platform type to decide on the
300 * baseband type
301 */
302 switch(platform_subtype)
303 {
304 case HW_PLATFORM_SUBTYPE_UNKNOWN:
305 break;
Maria Yu00fd3822013-06-26 10:12:54 +0800306 case HW_PLATFORM_SUBTYPE_SKUAA:
307 break;
308 case HW_PLATFORM_SUBTYPE_SKUF:
309 break;
310 case HW_PLATFORM_SUBTYPE_SKUAB:
311 break;
Deepa Dinamani41803e02013-03-25 11:44:15 -0700312 default:
313 dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype);
314 ASSERT(0);
315 };
316
317 switch(platform)
318 {
319 case MSM8610:
320 case MSM8110:
321 case MSM8210:
322 case MSM8810:
Deepa Dinamani39345cd2013-04-08 19:46:53 -0700323 case MSM8612:
David Ng2de18062013-04-19 20:22:16 -0700324 case MSM8212:
325 case MSM8812:
Deepa Dinamania8206cc2013-09-12 11:02:34 -0700326 case MSM8510:
327 case MSM8512:
Deepa Dinamani41803e02013-03-25 11:44:15 -0700328 board->baseband = BASEBAND_MSM;
329 break;
330 default:
331 dprintf(CRITICAL, "Platform type: %u is not supported\n", platform);
332 ASSERT(0);
333 };
334}
335
336unsigned target_baseband()
337{
338 return board_baseband();
339}
340
Deepa Dinamania6d1b752013-03-25 11:47:20 -0700341void target_serialno(unsigned char *buf)
342{
343 uint32_t serialno;
344 if (target_is_emmc_boot()) {
345 serialno = mmc_get_psn();
346 snprintf((char *)buf, 13, "%x", serialno);
347 }
348}
349
Deepa Dinamani5390e102013-03-25 11:55:31 -0700350unsigned check_reboot_mode(void)
351{
352 uint32_t restart_reason = 0;
353
354 /* Read reboot reason and scrub it */
355 restart_reason = readl(RESTART_REASON_ADDR);
356 writel(0x00, RESTART_REASON_ADDR);
357
358 return restart_reason;
359}
360
Deepa Dinamani172b7e62013-03-25 11:59:21 -0700361void reboot_device(unsigned reboot_reason)
362{
Channagoud Kadabi87306302013-12-12 14:55:47 -0800363 int ret = 0;
364
Deepa Dinamani172b7e62013-03-25 11:59:21 -0700365 writel(reboot_reason, RESTART_REASON_ADDR);
366
367 /* Configure PMIC for warm reset */
368 pm8x41_reset_configure(PON_PSHOLD_WARM_RESET);
369
Channagoud Kadabi87306302013-12-12 14:55:47 -0800370 ret = scm_halt_pmic_arbiter();
371 if (ret)
372 dprintf(CRITICAL , "Failed to halt pmic arbiter: %d\n", ret);
373
Deepa Dinamani172b7e62013-03-25 11:59:21 -0700374 /* Drop PS_HOLD for MSM */
375 writel(0x00, MPM2_MPM_PS_HOLD);
376
377 mdelay(5000);
378
379 dprintf(CRITICAL, "Rebooting failed\n");
380}
381
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +0530382/* Returns 1 if autopanel detection is enabled for the target. */
383uint8_t target_panel_auto_detect_enabled()
Terence Hampsonafded262013-06-18 14:48:18 -0400384{
385 int ret = 0;
Shuo Yanb757da82013-08-09 08:58:24 +0800386
Terence Hampsonafded262013-06-18 14:48:18 -0400387 switch(board_hardware_id())
388 {
Terence Hampson0e2f6552013-07-09 15:45:37 -0400389 case HW_PLATFORM_MTP:
390 case HW_PLATFORM_SURF:
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +0530391 case HW_PLATFORM_QRD:
Terence Hampsonafded262013-06-18 14:48:18 -0400392 default:
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +0530393 dprintf(SPEW, "Panel auto-detection is disabled\n");
Terence Hampsonafded262013-06-18 14:48:18 -0400394 ret = 0;
395 }
396 return ret;
397}
398
Shivaraj Shetty25b0aa02013-10-30 20:55:49 +0530399static uint8_t splash_override;
400
401/* Returns 1 if target supports continuous splash screen. */
402int target_cont_splash_screen()
403{
404 uint8_t splash_screen = 0;
405 if(!splash_override) {
406 switch(board_hardware_id())
407 {
408 case HW_PLATFORM_QRD:
409 case HW_PLATFORM_MTP:
410 case HW_PLATFORM_SURF:
411 dprintf(SPEW, "Target_cont_splash=1\n");
412 splash_screen = 1;
413 break;
414 default:
415 dprintf(SPEW, "Target_cont_splash=0\n");
416 splash_screen = 0;
417 }
418 }
419 return splash_screen;
420}
421
422void target_force_cont_splash_disable(uint8_t override)
423{
424 splash_override = override;
425}
426
Deepa Dinamani004eb322013-03-25 13:20:50 -0700427unsigned target_pause_for_battery_charge(void)
428{
429 uint8_t pon_reason = pm8x41_get_pon_reason();
Xu Kaic2e0afc2013-07-19 13:26:36 +0800430 uint8_t is_cold_boot = pm8x41_get_is_cold_boot();
431 dprintf(INFO, "%s : pon_reason is %d cold_boot:%d\n", __func__,
432 pon_reason, is_cold_boot);
433 /*In case of fastboot reboot, adb reboot or if we see the power key
434 * pressed we do not want go into charger mode.
435 * fastboot reboot is warm boot with PON hard reset bit not set
436 * adb reboot is a cold boot with PON hard reset bit set
Deepa Dinamani004eb322013-03-25 13:20:50 -0700437 */
Xu Kaic2e0afc2013-07-19 13:26:36 +0800438 if (is_cold_boot &&
439 (!(pon_reason & HARD_RST)) &&
440 (!(pon_reason & KPDPWR_N)) &&
441 ((pon_reason & USB_CHG) || (pon_reason & DC_CHG)))
442 return 1;
443 else
444 return 0;
Deepa Dinamani004eb322013-03-25 13:20:50 -0700445}
446
Deepa Dinamani98cf8ee2013-03-27 15:16:47 -0700447void target_usb_stop(void)
448{
449 /* Disable VBUS mimicing in the controller. */
450 ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR);
451}
452
453void target_usb_init(void)
454{
455 uint32_t val;
456
457 /* Select and enable external configuration with USB PHY */
458 ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET);
459
460 /* Enable sess_vld */
461 val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN;
462 writel(val, USB_GENCONFIG_2);
463
464 /* Enable external vbus configuration in the LINK */
465 val = readl(USB_USBCMD);
466 val |= SESS_VLD_CTRL;
467 writel(val, USB_USBCMD);
468}
469
470
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800471unsigned board_machtype(void)
472{
Deepa Dinamani2b795bb2013-03-25 11:31:58 -0700473 return 0;
Deepa Dinamani7dc3d4b2013-02-08 16:40:38 -0800474}
Channagoud Kadabie1b75262013-05-08 12:58:39 -0700475
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700476static void set_sdc_power_ctrl()
Channagoud Kadabie1b75262013-05-08 12:58:39 -0700477{
Channagoud Kadabid2fbf572013-11-07 11:33:50 -0800478
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700479 /* Drive strength configs for sdc pins */
480 struct tlmm_cfgs sdc1_hdrv_cfg[] =
481 {
482 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK },
483 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
Unnati Gandhi8967ba32014-02-25 21:58:39 +0530484 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_6MA, TLMM_HDRV_MASK },
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700485 };
486
487 /* Pull configs for sdc pins */
488 struct tlmm_cfgs sdc1_pull_cfg[] =
489 {
490 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK },
491 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
492 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
493 };
494
495 /* Set the drive strength & pull control values */
496 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
497 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
498}
499
Channagoud Kadabif59e4672013-09-10 14:24:43 -0700500void *target_mmc_device()
Channagoud Kadabi25e4d932013-05-10 17:54:29 -0700501{
Channagoud Kadabif59e4672013-09-10 14:24:43 -0700502 return (void *) dev;
Channagoud Kadabie1b75262013-05-08 12:58:39 -0700503}
Channagoud Kadabida988fd2013-12-04 13:44:42 -0800504
505/* Set up params for h/w CRYPTO_ENGINE. */
506void target_crypto_init_params()
507{
508 struct crypto_init_params ce_params;
509
510 /* Set up base addresses and instance. */
511 ce_params.crypto_instance = CRYPTO_ENGINE_INSTANCE;
512 ce_params.crypto_base = MSM_CE1_BASE;
513 ce_params.bam_base = MSM_CE1_BAM_BASE;
514
515 /* Set up BAM config. */
516 ce_params.bam_ee = CRYPTO_ENGINE_EE;
517 ce_params.pipes.read_pipe = CRYPTO_ENGINE_READ_PIPE;
518 ce_params.pipes.write_pipe = CRYPTO_ENGINE_WRITE_PIPE;
519 ce_params.pipes.read_pipe_grp = CRYPTO_READ_PIPE_LOCK_GRP;
520 ce_params.pipes.write_pipe_grp = CRYPTO_WRITE_PIPE_LOCK_GRP;
521
522 /* Assign buffer sizes. */
523 ce_params.num_ce = CRYPTO_ENGINE_CMD_ARRAY_SIZE;
524 ce_params.read_fifo_size = CRYPTO_ENGINE_FIFO_SIZE;
525 ce_params.write_fifo_size = CRYPTO_ENGINE_FIFO_SIZE;
526
527 ce_params.do_bam_init = 0;
528
529 crypto_init_params(&ce_params);
530}
531
Aparna Mallavarapu6d4ec9e2014-02-16 02:22:12 +0530532int set_download_mode(enum dload_mode mode)
533{
534 dload_util_write_cookie(mode == NORMAL_DLOAD ?
535 DLOAD_MODE_ADDR : EMERGENCY_DLOAD_MODE_ADDR, mode);
536
537 pm8x41_clear_pmic_watchdog();
538
539 return 0;
540}
541
Matthew Qin6dfa2ee2014-03-06 13:11:28 +0800542/* Configure PMIC and Drop PS_HOLD for shutdown */
543void shutdown_device()
544{
545 dprintf(CRITICAL, "Going down for shutdown.\n");
546
547 /* Configure PMIC for shutdown */
548 pm8x41_reset_configure(PON_PSHOLD_SHUTDOWN);
549
550 /* Drop PS_HOLD for MSM */
551 writel(0x00, MPM2_MPM_PS_HOLD);
552
553 mdelay(5000);
554
555 dprintf(CRITICAL, "shutdown failed\n");
556
557 ASSERT(0);
558}
559
Channagoud Kadabida988fd2013-12-04 13:44:42 -0800560crypto_engine_type board_ce_type(void)
561{
562 return CRYPTO_ENGINE_TYPE_HW;
563}