blob: 5b3db4be06ee6a3e7b50cbbcaa233d5c2b035a0f [file] [log] [blame]
Channagoud Kadabif8ad8e72015-01-06 15:10:13 -08001/* Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
Channagoud Kadabied60a8b2014-06-27 15:35:09 -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
Sridhar Parasuram568e7a62015-08-06 13:16:02 -070021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, nit
22 * PROCUREMENT OF
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <debug.h>
31#include <platform/iomap.h>
32#include <platform/irqs.h>
33#include <platform/gpio.h>
34#include <reg.h>
35#include <target.h>
36#include <platform.h>
37#include <dload_util.h>
38#include <uart_dm.h>
39#include <mmc.h>
40#include <spmi.h>
41#include <board.h>
42#include <smem.h>
43#include <baseband.h>
Sridhar Parasuramd75ade52015-03-09 15:45:16 -070044#include <regulator.h>
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070045#include <dev/keys.h>
46#include <pm8x41.h>
47#include <crypto5_wrapper.h>
48#include <clock.h>
49#include <partition_parser.h>
50#include <scm.h>
51#include <platform/clock.h>
52#include <platform/gpio.h>
53#include <platform/timer.h>
54#include <stdlib.h>
55#include <ufs.h>
56#include <boot_device.h>
57#include <qmp_phy.h>
Channagoud Kadabi7d308202014-12-22 12:07:04 -080058#include <sdhci_msm.h>
59#include <qusb2_phy.h>
Sridhar Parasuram568e7a62015-08-06 13:16:02 -070060#include <secapp_loader.h>
Channagoud Kadabi2bab29b2015-02-11 13:26:03 -080061#include <rpmb.h>
Sridhar Parasuram9f28f672015-03-17 15:40:47 -070062#include <rpm-glink.h>
Channagoud Kadabibb8f1f92015-04-27 11:14:45 -070063#if ENABLE_WBC
64#include <pm_app_smbchg.h>
65#endif
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070066
c_wufengf433f232015-09-21 15:21:21 +080067#if LONG_PRESS_POWER_ON
68#include <shutdown_detect.h>
69#endif
70
c_wufeng196210d2015-09-21 12:49:43 +080071#if PON_VIB_SUPPORT
72#include <vibrator.h>
73#define VIBRATE_TIME 250
74#endif
c_wufengf433f232015-09-21 15:21:21 +080075
Channagoud Kadabi9b28c0b2016-01-11 18:42:33 -080076#include <pm_smbchg_usb_chgpth.h>
77
Channagoud Kadabi4a870cf2015-01-21 10:39:01 -080078#define CE_INSTANCE 1
Channagoud Kadabi7edb9b42015-08-11 23:45:31 -070079#define CE_EE 0
Channagoud Kadabi4a870cf2015-01-21 10:39:01 -080080#define CE_FIFO_SIZE 64
81#define CE_READ_PIPE 3
82#define CE_WRITE_PIPE 2
83#define CE_READ_PIPE_LOCK_GRP 0
84#define CE_WRITE_PIPE_LOCK_GRP 0
85#define CE_ARRAY_SIZE 20
86
Channagoud Kadabied60a8b2014-06-27 15:35:09 -070087#define PMIC_ARB_CHANNEL_NUM 0
88#define PMIC_ARB_OWNER_ID 0
89
Channagoud Kadabi4021fa92015-11-03 16:35:26 -080090enum
91{
92 FUSION_I2S_MTP = 1,
93 FUSION_SLIMBUS = 2,
94} mtp_subtype;
95
96enum
97{
98 FUSION_I2S_CDP = 2,
99} cdp_subtype;
100
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700101static void set_sdc_power_ctrl(void);
102static uint32_t mmc_pwrctl_base[] =
103 { MSM_SDC1_BASE, MSM_SDC2_BASE };
104
105static uint32_t mmc_sdhci_base[] =
106 { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE };
107
108static uint32_t mmc_sdc_pwrctl_irq[] =
109 { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ };
110
111struct mmc_device *dev;
112struct ufs_dev ufs_device;
113
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700114void target_early_init(void)
115{
116#if WITH_DEBUG_UART
Channagoud Kadabi35503c42014-11-14 16:22:43 -0800117 uart_dm_init(8, 0, BLSP2_UART1_BASE);
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700118#endif
119}
120
121/* Return 1 if vol_up pressed */
Amit Blay6a3e88b2015-06-23 22:25:06 +0300122int target_volume_up()
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700123{
lijuang2d2b8a02015-06-05 21:34:15 +0800124 static uint8_t first_time = 0;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700125 uint8_t status = 0;
126 struct pm8x41_gpio gpio;
127
lijuang2d2b8a02015-06-05 21:34:15 +0800128 if (!first_time) {
129 /* Configure the GPIO */
130 gpio.direction = PM_GPIO_DIR_IN;
131 gpio.function = 0;
132 gpio.pull = PM_GPIO_PULL_UP_30;
133 gpio.vin_sel = 2;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700134
lijuang2d2b8a02015-06-05 21:34:15 +0800135 pm8x41_gpio_config(2, &gpio);
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700136
lijuang2d2b8a02015-06-05 21:34:15 +0800137 /* Wait for the pmic gpio config to take effect */
138 udelay(10000);
139
140 first_time = 1;
141 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700142
143 /* Get status of P_GPIO_5 */
Channagoud Kadabi99d23702015-02-02 20:52:17 -0800144 pm8x41_gpio_get(2, &status);
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700145
146 return !status; /* active low */
147}
148
149/* Return 1 if vol_down pressed */
150uint32_t target_volume_down()
151{
152 return pm8x41_resin_status();
153}
154
155static void target_keystatus()
156{
157 keys_init();
158
159 if(target_volume_down())
160 keys_post_event(KEY_VOLUMEDOWN, 1);
161
162 if(target_volume_up())
163 keys_post_event(KEY_VOLUMEUP, 1);
164}
165
166void target_uninit(void)
167{
168 if (platform_boot_dev_isemmc())
169 {
170 mmc_put_card_to_sleep(dev);
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700171 }
Channagoud Kadabi2bab29b2015-02-11 13:26:03 -0800172
173 if (is_sec_app_loaded())
174 {
Sridhar Parasuram568e7a62015-08-06 13:16:02 -0700175 if (send_milestone_call_to_tz() < 0)
Channagoud Kadabi2bab29b2015-02-11 13:26:03 -0800176 {
177 dprintf(CRITICAL, "Failed to unload App for rpmb\n");
178 ASSERT(0);
179 }
180 }
181
Channagoud Kadabibb8f1f92015-04-27 11:14:45 -0700182#if ENABLE_WBC
Channagoud Kadabi22165612015-07-22 14:04:37 -0700183 if (board_hardware_id() == HW_PLATFORM_MTP)
184 pm_appsbl_set_dcin_suspend(1);
Channagoud Kadabibb8f1f92015-04-27 11:14:45 -0700185#endif
186
Channagoud Kadabi7edb9b42015-08-11 23:45:31 -0700187
188 if (crypto_initialized())
189 {
190 crypto_eng_cleanup();
191 clock_ce_disable(CE_INSTANCE);
192 }
193
Sridhar Parasuram9f28f672015-03-17 15:40:47 -0700194 /* Tear down glink channels */
195 rpm_glink_uninit();
196
Channagoud Kadabi2bab29b2015-02-11 13:26:03 -0800197 if (rpmb_uninit() < 0)
198 {
199 dprintf(CRITICAL, "RPMB uninit failed\n");
200 ASSERT(0);
201 }
202
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700203}
204
205static void set_sdc_power_ctrl()
206{
207 /* Drive strength configs for sdc pins */
208 struct tlmm_cfgs sdc1_hdrv_cfg[] =
209 {
210 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, SDC1_HDRV_PULL_CTL },
211 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, SDC1_HDRV_PULL_CTL },
212 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, SDC1_HDRV_PULL_CTL },
213 };
214
215 /* Pull configs for sdc pins */
216 struct tlmm_cfgs sdc1_pull_cfg[] =
217 {
218 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL },
219 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL },
220 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL },
221 };
222
223 struct tlmm_cfgs sdc1_rclk_cfg[] =
224 {
225 { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, SDC1_HDRV_PULL_CTL },
226 };
227
228 /* Set the drive strength & pull control values */
229 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
230 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
231 tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg));
232}
233
c_wufengf433f232015-09-21 15:21:21 +0800234uint32_t target_is_pwrkey_pon_reason()
235{
236 uint8_t pon_reason = pm8950_get_pon_reason();
237 if (pm8x41_get_is_cold_boot() && ((pon_reason == KPDPWR_N) || (pon_reason == (KPDPWR_N|PON1))))
238 return 1;
239 else
240 return 0;
241}
242
243
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700244void target_sdc_init()
245{
246 struct mmc_config_data config = {0};
247
248 /* Set drive strength & pull ctrl values */
249 set_sdc_power_ctrl();
250
251 config.bus_width = DATA_BUS_WIDTH_8BIT;
252 config.max_clk_rate = MMC_CLK_192MHZ;
Channagoud Kadabi99d23702015-02-02 20:52:17 -0800253 config.hs400_support = 1;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700254
255 /* Try slot 1*/
256 config.slot = 1;
257 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
258 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
259 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
260
261 if (!(dev = mmc_init(&config)))
262 {
263 /* Try slot 2 */
264 config.slot = 2;
265 config.max_clk_rate = MMC_CLK_200MHZ;
266 config.sdhc_base = mmc_sdhci_base[config.slot - 1];
267 config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
268 config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
269
270 if (!(dev = mmc_init(&config)))
271 {
272 dprintf(CRITICAL, "mmc init failed!");
273 ASSERT(0);
274 }
275 }
276}
277
278void *target_mmc_device()
279{
280 if (platform_boot_dev_isemmc())
281 return (void *) dev;
282 else
283 return (void *) &ufs_device;
284}
285
286void target_init(void)
287{
Sridhar Parasuram568e7a62015-08-06 13:16:02 -0700288 int ret = 0;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700289 dprintf(INFO, "target_init()\n");
290
Sridhar Parasuram1d224322015-06-15 11:03:40 -0700291 pmic_info_populate();
292
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700293 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
294
Channagoud Kadabibb8f1f92015-04-27 11:14:45 -0700295 /* Initialize Glink */
296 rpm_glink_init();
297
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700298 target_keystatus();
299
c_wufengf433f232015-09-21 15:21:21 +0800300#if defined(LONG_PRESS_POWER_ON) || defined(PON_VIB_SUPPORT)
301 switch(board_hardware_id())
302 {
303 case HW_PLATFORM_QRD:
304#if LONG_PRESS_POWER_ON
305 shutdown_detect();
306#endif
c_wufeng196210d2015-09-21 12:49:43 +0800307#if PON_VIB_SUPPORT
308 vib_timed_turn_on(VIBRATE_TIME);
309#endif
c_wufengf433f232015-09-21 15:21:21 +0800310 break;
311 }
312#endif
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700313
314 if (target_use_signed_kernel())
315 target_crypto_init_params();
316
317 platform_read_boot_config();
318
Sridhar Parasuram50b9d962015-02-12 11:28:09 -0800319#ifdef MMC_SDHCI_SUPPORT
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700320 if (platform_boot_dev_isemmc())
321 {
322 target_sdc_init();
323 }
Sridhar Parasuram50b9d962015-02-12 11:28:09 -0800324#endif
325#ifdef UFS_SUPPORT
326 if (!platform_boot_dev_isemmc())
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700327 {
328 ufs_device.base = UFS_BASE;
329 ufs_init(&ufs_device);
330 }
Sridhar Parasuram50b9d962015-02-12 11:28:09 -0800331#endif
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700332
333 /* Storage initialization is complete, read the partition table info */
Channagoud Kadabi58a273b2015-02-10 12:56:22 -0800334 mmc_read_partition_table(0);
Channagoud Kadabi2bab29b2015-02-11 13:26:03 -0800335
Channagoud Kadabi1171d8d2015-07-30 19:12:44 -0700336#if ENABLE_WBC
337 /* Look for battery voltage and make sure we have enough to bootup
338 * Otherwise initiate battery charging
339 * Charging should happen as early as possible, any other driver
340 * initialization before this should consider the power impact
341 */
Channagoud Kadabi25fd8ce2015-08-19 14:45:08 -0700342 switch(board_hardware_id())
343 {
344 case HW_PLATFORM_MTP:
345 case HW_PLATFORM_FLUID:
lijuang0e98add2015-11-10 10:40:27 +0800346 case HW_PLATFORM_QRD:
Channagoud Kadabi25fd8ce2015-08-19 14:45:08 -0700347 pm_appsbl_chg_check_weak_battery_status(1);
348 break;
349 default:
350 /* Charging not supported */
351 break;
352 };
Channagoud Kadabi1171d8d2015-07-30 19:12:44 -0700353#endif
354
Sridhar Parasuram568e7a62015-08-06 13:16:02 -0700355 /* Initialize Qseecom */
356 ret = qseecom_init();
357
358 if (ret < 0)
359 {
360 dprintf(CRITICAL, "Failed to initialize qseecom, error: %d\n", ret);
361 ASSERT(0);
362 }
363
364 /* Start Qseecom */
365 ret = qseecom_tz_init();
366
367 if (ret < 0)
368 {
369 dprintf(CRITICAL, "Failed to start qseecom, error: %d\n", ret);
370 ASSERT(0);
371 }
372
Sridhar Parasuramc61ecc22015-09-22 13:53:31 -0700373 if (rpmb_init() < 0)
374 {
375 dprintf(CRITICAL, "RPMB init failed\n");
376 ASSERT(0);
377 }
378
Sridhar Parasuram568e7a62015-08-06 13:16:02 -0700379 /*
380 * Load the sec app for first time
381 */
382 if (load_sec_app() < 0)
383 {
384 dprintf(CRITICAL, "Failed to load App for verified\n");
385 ASSERT(0);
386 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700387}
388
389unsigned board_machtype(void)
390{
391 return LINUX_MACHTYPE_UNKNOWN;
392}
393
394/* Detect the target type */
395void target_detect(struct board_data *board)
396{
397 /* This is filled from board.c */
398}
399
Dhaval Patelb95039c2015-03-16 11:14:06 -0700400static uint8_t splash_override;
401/* Returns 1 if target supports continuous splash screen. */
402int target_cont_splash_screen()
403{
404 uint8_t splash_screen = 0;
Channagoud Kadabi25fd8ce2015-08-19 14:45:08 -0700405 if(!splash_override && !pm_appsbl_charging_in_progress()) {
Dhaval Patelb95039c2015-03-16 11:14:06 -0700406 switch(board_hardware_id())
407 {
408 case HW_PLATFORM_SURF:
409 case HW_PLATFORM_MTP:
410 case HW_PLATFORM_FLUID:
feifanz76fe6482015-09-02 15:25:16 +0800411 case HW_PLATFORM_QRD:
Kuogee Hsiehb976dfc2015-08-28 13:21:30 -0700412 case HW_PLATFORM_LIQUID:
Dhaval Patelb95039c2015-03-16 11:14:06 -0700413 dprintf(SPEW, "Target_cont_splash=1\n");
414 splash_screen = 1;
415 break;
416 default:
417 dprintf(SPEW, "Target_cont_splash=0\n");
418 splash_screen = 0;
419 }
420 }
421 return splash_screen;
422}
423
424void target_force_cont_splash_disable(uint8_t override)
425{
426 splash_override = override;
427}
428
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700429/* Detect the modem type */
430void target_baseband_detect(struct board_data *board)
431{
432 uint32_t platform;
Channagoud Kadabi4021fa92015-11-03 16:35:26 -0800433 uint32_t platform_hardware;
434 uint32_t platform_subtype;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700435
436 platform = board->platform;
Channagoud Kadabi4021fa92015-11-03 16:35:26 -0800437 platform_hardware = board->platform_hw;
438 platform_subtype = board->platform_subtype;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700439
Channagoud Kadabi4021fa92015-11-03 16:35:26 -0800440 if (platform_hardware == HW_PLATFORM_SURF)
441 {
442 if (platform_subtype == FUSION_I2S_CDP)
443 board->baseband = BASEBAND_MDM;
444 }
445 else if (platform_hardware == HW_PLATFORM_MTP)
446 {
447 if (platform_subtype == FUSION_I2S_MTP ||
448 platform_subtype == FUSION_SLIMBUS)
449 board->baseband = BASEBAND_MDM;
450 }
451 /*
452 * Special case if MDM is not set look for chip info to decide
453 * platform subtype
454 */
455 if (board->baseband != BASEBAND_MDM)
456 {
457 switch(platform) {
458 case APQ8096:
Channagoud Kadabi99d23702015-02-02 20:52:17 -0800459 board->baseband = BASEBAND_APQ;
Channagoud Kadabi4021fa92015-11-03 16:35:26 -0800460 break;
461 case MSM8996:
462 if (board->platform_version == 0x10000)
463 board->baseband = BASEBAND_APQ;
464 else
465 board->baseband = BASEBAND_MSM;
466 break;
467 default:
468 dprintf(CRITICAL, "Platform type: %u is not supported\n",platform);
469 ASSERT(0);
470 };
471 }
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700472}
Channagoud Kadabi4021fa92015-11-03 16:35:26 -0800473
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700474unsigned target_baseband()
475{
476 return board_baseband();
477}
478
479void target_serialno(unsigned char *buf)
480{
481 unsigned int serialno;
482 if (target_is_emmc_boot()) {
483 serialno = mmc_get_psn();
484 snprintf((char *)buf, 13, "%x", serialno);
485 }
486}
487
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700488int emmc_recovery_init(void)
489{
490 return _emmc_recovery_init();
491}
492
493void target_usb_phy_reset()
494{
495 usb30_qmp_phy_reset();
496 qusb2_phy_reset();
497}
498
499target_usb_iface_t* target_usb30_init()
500{
501 target_usb_iface_t *t_usb_iface;
502
503 t_usb_iface = calloc(1, sizeof(target_usb_iface_t));
504 ASSERT(t_usb_iface);
505
506 t_usb_iface->phy_init = usb30_qmp_phy_init;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700507 t_usb_iface->phy_reset = target_usb_phy_reset;
508 t_usb_iface->clock_init = clock_usb30_init;
509 t_usb_iface->vbus_override = 1;
510
511 return t_usb_iface;
512}
513
514/* identify the usb controller to be used for the target */
515const char * target_usb_controller()
516{
517 return "dwc";
518}
519
520uint32_t target_override_pll()
521{
Channagoud Kadabi1e5144b2015-04-28 17:15:05 -0700522 if (board_soc_version() >= 0x20000)
523 return 0;
524 else
525 return 1;
Channagoud Kadabied60a8b2014-06-27 15:35:09 -0700526}
527
Channagoud Kadabi4a870cf2015-01-21 10:39:01 -0800528crypto_engine_type board_ce_type(void)
529{
Channagoud Kadabi7edb9b42015-08-11 23:45:31 -0700530 return CRYPTO_ENGINE_TYPE_HW;
Channagoud Kadabi4a870cf2015-01-21 10:39:01 -0800531}
532
533/* Set up params for h/w CE. */
534void target_crypto_init_params()
535{
536 struct crypto_init_params ce_params;
537
538 /* Set up base addresses and instance. */
539 ce_params.crypto_instance = CE_INSTANCE;
540 ce_params.crypto_base = MSM_CE_BASE;
541 ce_params.bam_base = MSM_CE_BAM_BASE;
542
543 /* Set up BAM config. */
544 ce_params.bam_ee = CE_EE;
545 ce_params.pipes.read_pipe = CE_READ_PIPE;
546 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
547 ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP;
548 ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP;
549
550 /* Assign buffer sizes. */
551 ce_params.num_ce = CE_ARRAY_SIZE;
552 ce_params.read_fifo_size = CE_FIFO_SIZE;
553 ce_params.write_fifo_size = CE_FIFO_SIZE;
554
555 /* BAM is initialized by TZ for this platform.
556 * Do not do it again as the initialization address space
557 * is locked.
558 */
559 ce_params.do_bam_init = 0;
560
561 crypto_init_params(&ce_params);
562}
Channagoud Kadabi083290f2015-03-13 14:18:38 -0700563
564unsigned target_pause_for_battery_charge(void)
565{
566 uint8_t pon_reason = pm8x41_get_pon_reason();
567 uint8_t is_cold_boot = pm8x41_get_is_cold_boot();
Channagoud Kadabi9b28c0b2016-01-11 18:42:33 -0800568 pm_smbchg_usb_chgpth_pwr_pth_type charger_path = PM_SMBCHG_USB_CHGPTH_PWR_PATH__INVALID;
569 dprintf(INFO, "%s : pon_reason is %d cold_boot:%d charger path: %d\n", __func__,
570 pon_reason, is_cold_boot, charger_path);
Channagoud Kadabi083290f2015-03-13 14:18:38 -0700571 /* In case of fastboot reboot,adb reboot or if we see the power key
572 * pressed we do not want go into charger mode.
573 * fastboot reboot is warm boot with PON hard reset bit not set
574 * adb reboot is a cold boot with PON hard reset bit set
575 */
Channagoud Kadabi9b28c0b2016-01-11 18:42:33 -0800576 pm_smbchg_get_charger_path(1, &charger_path);
Channagoud Kadabi083290f2015-03-13 14:18:38 -0700577 if (is_cold_boot &&
578 (!(pon_reason & HARD_RST)) &&
579 (!(pon_reason & KPDPWR_N)) &&
Channagoud Kadabi9b28c0b2016-01-11 18:42:33 -0800580 ((pon_reason & PON1)) &&
581 ((charger_path == PM_SMBCHG_USB_CHGPTH_PWR_PATH__DC_CHARGER) ||
582 (charger_path == PM_SMBCHG_USB_CHGPTH_PWR_PATH__USB_CHARGER)))
583
Channagoud Kadabi083290f2015-03-13 14:18:38 -0700584 return 1;
585 else
586 return 0;
587}
Channagoud Kadabi23edc0c2015-03-27 18:31:32 -0700588
589int set_download_mode(enum dload_mode mode)
590{
591 int ret = 0;
592 ret = scm_dload_mode(mode);
593
594 return ret;
595}
Channagoud Kadabiffc4b902015-06-25 23:14:27 -0700596
Channagoud Kadabi65b518d2015-08-05 16:17:14 -0700597void pmic_reset_configure(uint8_t reset_type)
Channagoud Kadabiffc4b902015-06-25 23:14:27 -0700598{
Channagoud Kadabi65b518d2015-08-05 16:17:14 -0700599 pm8994_reset_configure(reset_type);
Channagoud Kadabiffc4b902015-06-25 23:14:27 -0700600}
lijuang3606df82015-09-02 21:14:43 +0800601
602uint32_t target_get_pmic()
603{
604 return PMIC_IS_PMI8996;
605}