blob: cde469c655a50895548e54778226957cbac901af [file] [log] [blame]
Eugene Yasman6382ee02013-01-16 13:00:56 +02001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Deepa Dinamani7d6c8972011-12-14 15:16:56 -08002 *
3 * Redistribution and use in source and binary forms, with or without
Deepa Dinamani1e094942012-10-30 15:49:02 -07004 * 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.
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080015 *
Deepa Dinamani1e094942012-10-30 15:49:02 -070016 * 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.
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080027 */
28
29#include <debug.h>
30#include <platform/iomap.h>
Channagoud Kadabi744c8902013-04-02 11:54:53 -070031#include <platform/gpio.h>
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080032#include <reg.h>
33#include <target.h>
34#include <platform.h>
Deepa Dinamani26e93262012-05-21 17:35:14 -070035#include <uart_dm.h>
Amol Jadi29f95032012-06-22 12:52:54 -070036#include <mmc.h>
Deepa Dinamanic2a9b362012-02-23 15:15:54 -080037#include <spmi.h>
Neeti Desai465491e2012-07-31 12:53:35 -070038#include <board.h>
39#include <smem.h>
40#include <baseband.h>
Deepa Dinamani9a612932012-08-14 16:15:03 -070041#include <dev/keys.h>
42#include <pm8x41.h>
Deepa Dinamanib9a57202012-12-20 18:05:11 -080043#include <crypto5_wrapper.h>
Eugene Yasmana0d18122013-02-26 13:23:05 +020044#include <hsusb.h>
45#include <clock.h>
sundarajan srinivasana098d832013-03-07 12:19:30 -080046#include <partition_parser.h>
47#include <scm.h>
48#include <platform/clock.h>
Channagoud Kadabic1fdc8d2013-04-05 11:29:23 -070049#include <platform/gpio.h>
Channagoud Kadabif84830c2013-04-19 14:35:47 -070050#include <stdlib.h>
Deepa Dinamanib9a57202012-12-20 18:05:11 -080051
52extern bool target_use_signed_kernel(void);
Channagoud Kadabi744c8902013-04-02 11:54:53 -070053static void set_sdc_power_ctrl();
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080054
55static unsigned int target_id;
Deepa Dinamani07f15712013-03-08 17:02:13 -080056static uint32_t pmic_ver;
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080057
Channagoud Kadabic1fdc8d2013-04-05 11:29:23 -070058#if MMC_SDHCI_SUPPORT
59struct mmc_device *dev;
60#endif
61
Deepa Dinamanic2a9b362012-02-23 15:15:54 -080062#define PMIC_ARB_CHANNEL_NUM 0
63#define PMIC_ARB_OWNER_ID 0
64
Deepa Dinamani1e094942012-10-30 15:49:02 -070065#define WDOG_DEBUG_DISABLE_BIT 17
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080066
Deepa Dinamanib9a57202012-12-20 18:05:11 -080067#define CE_INSTANCE 2
68#define CE_EE 1
69#define CE_FIFO_SIZE 64
70#define CE_READ_PIPE 3
71#define CE_WRITE_PIPE 2
72#define CE_ARRAY_SIZE 20
73
sundarajan srinivasana098d832013-03-07 12:19:30 -080074#ifdef SSD_ENABLE
75#define SSD_CE_INSTANCE_1 1
76#define SSD_PARTITION_SIZE 8192
77#endif
78
Channagoud Kadabic1fdc8d2013-04-05 11:29:23 -070079#if MMC_SDHCI_SUPPORT
80static uint32_t mmc_sdhci_base[] =
81 { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE, MSM_SDC3_SDHCI_BASE, MSM_SDC4_SDHCI_BASE };
82#endif
83
Deepa Dinamanica5ad852012-05-07 18:19:47 -070084static uint32_t mmc_sdc_base[] =
85 { MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE };
86
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080087void target_early_init(void)
88{
Deepa Dinamanib073ba22012-08-10 11:06:41 -070089#if WITH_DEBUG_UART
Neeti Desaiac011272012-08-29 18:24:54 -070090 uart_dm_init(1, 0, BLSP1_UART1_BASE);
Deepa Dinamanib073ba22012-08-10 11:06:41 -070091#endif
Deepa Dinamani7d6c8972011-12-14 15:16:56 -080092}
93
Deepa Dinamani9a612932012-08-14 16:15:03 -070094/* Return 1 if vol_up pressed */
95static int target_volume_up()
96{
97 uint8_t status = 0;
98 struct pm8x41_gpio gpio;
99
100 /* CDP vol_up seems to be always grounded. So gpio status is read as 0,
101 * whether key is pressed or not.
102 * Ignore volume_up key on CDP for now.
103 */
104 if (board_hardware_id() == HW_PLATFORM_SURF)
105 return 0;
106
107 /* Configure the GPIO */
108 gpio.direction = PM_GPIO_DIR_IN;
109 gpio.function = 0;
110 gpio.pull = PM_GPIO_PULL_UP_30;
Eugene Yasman6382ee02013-01-16 13:00:56 +0200111 gpio.vin_sel = 2;
Deepa Dinamani9a612932012-08-14 16:15:03 -0700112
113 pm8x41_gpio_config(5, &gpio);
114
115 /* Get status of P_GPIO_5 */
116 pm8x41_gpio_get(5, &status);
117
118 return !status; /* active low */
119}
120
121/* Return 1 if vol_down pressed */
Deepa Dinamani66a87962013-02-04 10:39:30 -0800122uint32_t target_volume_down()
Deepa Dinamani9a612932012-08-14 16:15:03 -0700123{
Deepa Dinamani66a87962013-02-04 10:39:30 -0800124 /* Volume down button is tied in with RESIN on MSM8974. */
Deepa Dinamani07f15712013-03-08 17:02:13 -0800125 if (pmic_ver == PMIC_VERSION_V2)
Deepa Dinamani13bfc852013-02-05 17:56:47 -0800126 return pm8x41_resin_bark_workaround_status();
127 else
128 return pm8x41_resin_status();
Deepa Dinamani9a612932012-08-14 16:15:03 -0700129}
130
131static void target_keystatus()
132{
133 keys_init();
134
135 if(target_volume_down())
136 keys_post_event(KEY_VOLUMEDOWN, 1);
137
138 if(target_volume_up())
139 keys_post_event(KEY_VOLUMEUP, 1);
140}
141
Deepa Dinamanib9a57202012-12-20 18:05:11 -0800142/* Set up params for h/w CE. */
143void target_crypto_init_params()
144{
145 struct crypto_init_params ce_params;
146
147 /* Set up base addresses and instance. */
148 ce_params.crypto_instance = CE_INSTANCE;
149 ce_params.crypto_base = MSM_CE2_BASE;
150 ce_params.bam_base = MSM_CE2_BAM_BASE;
151
152 /* Set up BAM config. */
153 ce_params.bam_ee = CE_EE;
154 ce_params.pipes.read_pipe = CE_READ_PIPE;
155 ce_params.pipes.write_pipe = CE_WRITE_PIPE;
156
157 /* Assign buffer sizes. */
158 ce_params.num_ce = CE_ARRAY_SIZE;
159 ce_params.read_fifo_size = CE_FIFO_SIZE;
160 ce_params.write_fifo_size = CE_FIFO_SIZE;
161
162 crypto_init_params(&ce_params);
163}
164
165crypto_engine_type board_ce_type(void)
166{
167 return CRYPTO_ENGINE_TYPE_HW;
168}
169
Channagoud Kadabic1fdc8d2013-04-05 11:29:23 -0700170#if MMC_SDHCI_SUPPORT
171static target_mmc_sdhci_init()
172{
173 struct mmc_config_data config;
174 uint32_t soc_ver = 0;
175
176 /* Enable sdhci mode */
177 sdhci_mode_enable(1);
178
179 soc_ver = board_soc_version();
180
181 /*
182 * 8974 v1 fluid devices, have a hardware bug
183 * which limits the bus width to 4 bit.
184 */
185 switch(board_hardware_id())
186 {
187 case HW_PLATFORM_FLUID:
188 if (soc_ver >= BOARD_SOC_VERSION2)
189 config.bus_width = DATA_BUS_WIDTH_8BIT;
190 else
191 config.bus_width = DATA_BUS_WIDTH_4BIT;
192 break;
193 default:
194 config.bus_width = DATA_BUS_WIDTH_8BIT;
195 };
196
197 config.max_clk_rate = MMC_CLK_200MHZ;
198
199 /* Trying Slot 1*/
200 config.slot = 1;
201 config.base = mmc_sdhci_base[config.slot - 1];
202
203 if (!(dev = mmc_init(&config))) {
204 /* Trying Slot 2 next */
205 config.slot = 2;
206 config.base = mmc_sdhci_base[config.slot - 1];
207 if (!(dev = mmc_init(&config))) {
208 dprintf(CRITICAL, "mmc init failed!");
209 ASSERT(0);
210 }
211 }
212}
213
214struct mmc_device *target_mmc_device()
215{
216 return dev;
217}
218#else
219static target_mmc_mci_init()
Deepa Dinamani7d6c8972011-12-14 15:16:56 -0800220{
Deepa Dinamanica5ad852012-05-07 18:19:47 -0700221 uint32_t base_addr;
222 uint8_t slot;
Deepa Dinamani7d6c8972011-12-14 15:16:56 -0800223
Channagoud Kadabic1fdc8d2013-04-05 11:29:23 -0700224 /* Trying Slot 1 */
225 slot = 1;
226 base_addr = mmc_sdc_base[slot - 1];
227
228 if (mmc_boot_main(slot, base_addr))
229 {
230 /* Trying Slot 2 next */
231 slot = 2;
232 base_addr = mmc_sdc_base[slot - 1];
233 if (mmc_boot_main(slot, base_addr)) {
234 dprintf(CRITICAL, "mmc init failed!");
235 ASSERT(0);
236 }
237 }
238}
239
240/*
241 * Function to set the capabilities for the host
242 */
243void target_mmc_caps(struct mmc_host *host)
244{
245 uint32_t soc_ver = 0;
246
247 soc_ver = board_soc_version();
248
249 /*
250 * 8974 v1 fluid devices, have a hardware bug
251 * which limits the bus width to 4 bit.
252 */
253 switch(board_hardware_id())
254 {
255 case HW_PLATFORM_FLUID:
256 if (soc_ver >= BOARD_SOC_VERSION2)
257 host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT;
258 else
259 host->caps.bus_width = MMC_BOOT_BUS_WIDTH_4_BIT;
260 break;
261 default:
262 host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT;
263 };
264
265 host->caps.ddr_mode = 1;
266 host->caps.hs200_mode = 1;
267 host->caps.hs_clk_rate = MMC_CLK_96MHZ;
268}
269#endif
270
271
272void target_init(void)
273{
Deepa Dinamani7d6c8972011-12-14 15:16:56 -0800274 dprintf(INFO, "target_init()\n");
275
Deepa Dinamanic2a9b362012-02-23 15:15:54 -0800276 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
Deepa Dinamani7d6c8972011-12-14 15:16:56 -0800277
Deepa Dinamani07f15712013-03-08 17:02:13 -0800278 /* Save PM8941 version info. */
279 pmic_ver = pm8x41_get_pmic_rev();
280
Deepa Dinamani9a612932012-08-14 16:15:03 -0700281 target_keystatus();
282
Deepa Dinamanib9a57202012-12-20 18:05:11 -0800283 if (target_use_signed_kernel())
284 target_crypto_init_params();
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800285 /* Display splash screen if enabled */
286#if DISPLAY_SPLASH_SCREEN
Channagoud Kadabi8a9c6a22013-02-05 14:43:48 -0800287 dprintf(INFO, "Display Init: Start\n");
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800288 display_init();
Channagoud Kadabi8a9c6a22013-02-05 14:43:48 -0800289 dprintf(INFO, "Display Init: Done\n");
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800290#endif
Deepa Dinamanib9a57202012-12-20 18:05:11 -0800291
Channagoud Kadabi744c8902013-04-02 11:54:53 -0700292 /*
293 * Set drive strength & pull ctrl for
294 * emmc
295 */
296 set_sdc_power_ctrl();
297
Channagoud Kadabic1fdc8d2013-04-05 11:29:23 -0700298#if MMC_SDHCI_SUPPORT
299 target_mmc_sdhci_init();
300#else
301 target_mmc_mci_init();
302#endif
Deepa Dinamanid18b47a2012-06-27 13:06:03 -0700303
Channagoud Kadabic1fdc8d2013-04-05 11:29:23 -0700304 /*
305 * MMC initialization is complete, read the partition table info
306 */
307 if (partition_read_table()) {
308 dprintf(CRITICAL, "Error reading the partition table info\n");
309 ASSERT(0);
Deepa Dinamanica5ad852012-05-07 18:19:47 -0700310 }
Deepa Dinamani7d6c8972011-12-14 15:16:56 -0800311}
312
313unsigned board_machtype(void)
314{
315 return target_id;
316}
317
318/* Do any target specific intialization needed before entering fastboot mode */
sundarajan srinivasana098d832013-03-07 12:19:30 -0800319#ifdef SSD_ENABLE
sundarajan srinivasana098d832013-03-07 12:19:30 -0800320static void ssd_load_keystore_from_emmc()
321{
322 uint64_t ptn = 0;
323 int index = -1;
324 uint32_t size = SSD_PARTITION_SIZE;
325 int ret = -1;
326
Channagoud Kadabif84830c2013-04-19 14:35:47 -0700327 uint32_t *buffer = (uint32_t *)memalign(CACHE_LINE,
328 ROUNDUP(SSD_PARTITION_SIZE, CACHE_LINE));
329
330 if (!buffer) {
331 dprintf(CRITICAL, "Error Allocating memory for SSD buffer\n");
332 ASSERT(0);
333 }
334
sundarajan srinivasana098d832013-03-07 12:19:30 -0800335 index = partition_get_index("ssd");
336
337 ptn = partition_get_offset(index);
338 if(ptn == 0){
339 dprintf(CRITICAL,"ERROR: ssd parition not found");
340 return;
341 }
342
343 if(mmc_read(ptn, buffer, size)){
344 dprintf(CRITICAL,"ERROR:Cannot read data\n");
345 return;
346 }
347
348 ret = scm_protect_keystore((uint32_t *)&buffer[0],size);
349 if(ret != 0)
350 dprintf(CRITICAL,"ERROR: scm_protect_keystore Failed");
Channagoud Kadabif84830c2013-04-19 14:35:47 -0700351
352 free(buffer);
sundarajan srinivasana098d832013-03-07 12:19:30 -0800353}
354#endif
355
Deepa Dinamani7d6c8972011-12-14 15:16:56 -0800356void target_fastboot_init(void)
357{
Deepa Dinamani9a612932012-08-14 16:15:03 -0700358 /* Set the BOOT_DONE flag in PM8921 */
359 pm8x41_set_boot_done();
sundarajan srinivasana098d832013-03-07 12:19:30 -0800360
361#ifdef SSD_ENABLE
362 clock_ce_enable(SSD_CE_INSTANCE_1);
363 ssd_load_keystore_from_emmc();
364#endif
Deepa Dinamani7d6c8972011-12-14 15:16:56 -0800365}
Neeti Desai465491e2012-07-31 12:53:35 -0700366
367/* Detect the target type */
368void target_detect(struct board_data *board)
369{
370 board->target = LINUX_MACHTYPE_UNKNOWN;
371}
372
373/* Detect the modem type */
374void target_baseband_detect(struct board_data *board)
375{
Channagoud Kadabif1d44422013-02-21 22:59:35 -0800376 uint32_t platform;
377 uint32_t platform_subtype;
378
379 platform = board->platform;
380 platform_subtype = board->platform_subtype;
381
382 /*
383 * Look for platform subtype if present, else
384 * check for platform type to decide on the
385 * baseband type
386 */
387 switch(platform_subtype) {
388 case HW_PLATFORM_SUBTYPE_UNKNOWN:
389 break;
Joel Kingead31e82013-04-20 11:26:01 -0700390 case HW_PLATFORM_SUBTYPE_MDM:
391 board->baseband = BASEBAND_MDM;
392 return;
Channagoud Kadabif1d44422013-02-21 22:59:35 -0800393 default:
394 dprintf(CRITICAL, "Platform Subtype : %u is not supported\n",platform_subtype);
395 ASSERT(0);
396 };
397
398 switch(platform) {
399 case MSM8974:
Neeti Desai465491e2012-07-31 12:53:35 -0700400 board->baseband = BASEBAND_MSM;
Channagoud Kadabif1d44422013-02-21 22:59:35 -0800401 break;
402 case APQ8074:
403 board->baseband = BASEBAND_APQ;
404 break;
405 default:
406 dprintf(CRITICAL, "Platform type: %u is not supported\n",platform);
407 ASSERT(0);
408 };
Neeti Desai465491e2012-07-31 12:53:35 -0700409}
Deepa Dinamani9a612932012-08-14 16:15:03 -0700410
Deepa Dinamani927a6b62013-03-28 17:05:32 -0700411unsigned target_baseband()
412{
413 return board_baseband();
414}
415
Deepa Dinamani9a612932012-08-14 16:15:03 -0700416void target_serialno(unsigned char *buf)
417{
418 unsigned int serialno;
419 if (target_is_emmc_boot()) {
420 serialno = mmc_get_psn();
421 snprintf((char *)buf, 13, "%x", serialno);
422 }
423}
Amol Jadi6639d452012-08-16 14:51:19 -0700424
425unsigned check_reboot_mode(void)
426{
427 uint32_t restart_reason = 0;
Channagoud Kadabi8c8587f2013-02-08 12:46:09 -0800428 uint32_t soc_ver = 0;
429 uint32_t restart_reason_addr;
430
431 soc_ver = board_soc_version();
432
433 if (soc_ver >= BOARD_SOC_VERSION2)
434 restart_reason_addr = RESTART_REASON_ADDR_V2;
435 else
436 restart_reason_addr = RESTART_REASON_ADDR;
Amol Jadi6639d452012-08-16 14:51:19 -0700437
438 /* Read reboot reason and scrub it */
Channagoud Kadabi8c8587f2013-02-08 12:46:09 -0800439 restart_reason = readl(restart_reason_addr);
440 writel(0x00, restart_reason_addr);
Amol Jadi6639d452012-08-16 14:51:19 -0700441
442 return restart_reason;
443}
Neeti Desai120b55d2012-08-20 17:15:56 -0700444
445void reboot_device(unsigned reboot_reason)
446{
Channagoud Kadabi8c8587f2013-02-08 12:46:09 -0800447 uint32_t soc_ver = 0;
448
449 soc_ver = board_soc_version();
450
Neeti Desai120b55d2012-08-20 17:15:56 -0700451 /* Write the reboot reason */
Channagoud Kadabi8c8587f2013-02-08 12:46:09 -0800452 if (soc_ver >= BOARD_SOC_VERSION2)
453 writel(reboot_reason, RESTART_REASON_ADDR_V2);
454 else
455 writel(reboot_reason, RESTART_REASON_ADDR);
Neeti Desai120b55d2012-08-20 17:15:56 -0700456
457 /* Configure PMIC for warm reset */
Deepa Dinamani07f15712013-03-08 17:02:13 -0800458 if (pmic_ver == PMIC_VERSION_V2)
459 pm8x41_v2_reset_configure(PON_PSHOLD_WARM_RESET);
460 else
461 pm8x41_reset_configure(PON_PSHOLD_WARM_RESET);
Neeti Desai120b55d2012-08-20 17:15:56 -0700462
Deepa Dinamani1e094942012-10-30 15:49:02 -0700463 /* Disable Watchdog Debug.
464 * Required becuase of a H/W bug which causes the system to
465 * reset partially even for non watchdog resets.
466 */
467 writel(readl(GCC_WDOG_DEBUG) & ~(1 << WDOG_DEBUG_DISABLE_BIT), GCC_WDOG_DEBUG);
468
Deepa Dinamanie0808e52012-11-26 15:22:46 -0800469 dsb();
470
471 /* Wait until the write takes effect. */
472 while(readl(GCC_WDOG_DEBUG) & (1 << WDOG_DEBUG_DISABLE_BIT));
473
Neeti Desai120b55d2012-08-20 17:15:56 -0700474 /* Drop PS_HOLD for MSM */
475 writel(0x00, MPM2_MPM_PS_HOLD);
476
477 mdelay(5000);
478
479 dprintf(CRITICAL, "Rebooting failed\n");
480}
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800481
Eugene Yasmana0d18122013-02-26 13:23:05 +0200482/* Do target specific usb initialization */
483void target_usb_init(void)
484{
485 /* Enable secondary USB PHY on DragonBoard8074 */
486 if (board_hardware_id() == HW_PLATFORM_DRAGON) {
487 /* Route ChipIDea to use secondary USB HS port2 */
488 writel_relaxed(1, USB2_PHY_SEL);
489
490 /* Enable access to secondary PHY by clamping the low
491 * voltage interface between DVDD of the PHY and Vddcx
492 * (set bit16 (USB2_PHY_HS2_DIG_CLAMP_N_2) = 1) */
493 writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_SEC_CTRL)
494 | 0x00010000, USB_OTG_HS_PHY_SEC_CTRL);
495
496 /* Perform power-on-reset of the PHY.
497 * Delay values are arbitrary */
498 writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL)|1,
499 USB_OTG_HS_PHY_CTRL);
500 thread_sleep(10);
501 writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL) & 0xFFFFFFFE,
502 USB_OTG_HS_PHY_CTRL);
503 thread_sleep(10);
504
505 /* Enable HSUSB PHY port for ULPI interface,
506 * then configure related parameters within the PHY */
507 writel_relaxed(((readl_relaxed(USB_PORTSC) & 0xC0000000)
508 | 0x8c000004), USB_PORTSC);
509 }
510}
511
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800512/* Returns 1 if target supports continuous splash screen. */
513int target_cont_splash_screen()
514{
Siddhartha Agrawal17a6b832013-02-17 18:36:25 -0800515 switch(board_hardware_id())
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800516 {
Siddhartha Agrawal17a6b832013-02-17 18:36:25 -0800517 case HW_PLATFORM_SURF:
518 case HW_PLATFORM_MTP:
519 case HW_PLATFORM_FLUID:
520 dprintf(SPEW, "Target_cont_splash=1\n");
521 return 1;
522 break;
523 default:
524 dprintf(SPEW, "Target_cont_splash=0\n");
525 return 0;
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800526 }
527}
sundarajan srinivasanb5db0a92013-02-12 19:19:27 -0800528
529unsigned target_pause_for_battery_charge(void)
530{
531 uint8_t pon_reason = pm8x41_get_pon_reason();
532
533 /* This function will always return 0 to facilitate
534 * automated testing/reboot with usb connected.
535 * uncomment if this feature is needed */
536 /* if ((pon_reason == USB_CHG) || (pon_reason == DC_CHG))
537 return 1;*/
538
539 return 0;
540}
sundarajan srinivasana098d832013-03-07 12:19:30 -0800541
542void target_usb_stop(void)
543{
544#ifdef SSD_ENABLE
545 clock_ce_disable(SSD_CE_INSTANCE_1);
546#endif
547}
Deepa Dinamani65df9822013-03-08 13:38:34 -0800548
549void shutdown_device()
550{
551 dprintf(CRITICAL, "Going down for shutdown.\n");
552
553 /* Configure PMIC for shutdown. */
554 if (pmic_ver == PMIC_VERSION_V2)
555 pm8x41_v2_reset_configure(PON_PSHOLD_SHUTDOWN);
556 else
557 pm8x41_reset_configure(PON_PSHOLD_SHUTDOWN);
558
559 /* Drop PS_HOLD for MSM */
560 writel(0x00, MPM2_MPM_PS_HOLD);
561
562 mdelay(5000);
563
564 dprintf(CRITICAL, "Shutdown failed\n");
Channagoud Kadabi744c8902013-04-02 11:54:53 -0700565}
566
567static void set_sdc_power_ctrl()
568{
569 /* Drive strength configs for sdc pins */
570 struct tlmm_cfgs sdc1_hdrv_cfg[] =
571 {
572 { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK },
573 { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
574 { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
575 };
576
577 /* Pull configs for sdc pins */
578 struct tlmm_cfgs sdc1_pull_cfg[] =
579 {
580 { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK },
581 { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
582 { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
583 };
584
585 /* Set the drive strength & pull control values */
586 tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
587 tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
588}