Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 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> |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 31 | #include <platform/irqs.h> |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 32 | #include <reg.h> |
| 33 | #include <target.h> |
| 34 | #include <platform.h> |
| 35 | #include <uart_dm.h> |
| 36 | #include <mmc.h> |
Deepa Dinamani | 8ff46f0 | 2013-03-20 17:52:14 -0700 | [diff] [blame] | 37 | #include <platform/gpio.h> |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 38 | #include <spmi.h> |
| 39 | #include <board.h> |
Deepa Dinamani | 41803e0 | 2013-03-25 11:44:15 -0700 | [diff] [blame] | 40 | #include <smem.h> |
| 41 | #include <baseband.h> |
Deepa Dinamani | 8ff46f0 | 2013-03-20 17:52:14 -0700 | [diff] [blame] | 42 | #include <dev/keys.h> |
| 43 | #include <pm8x41.h> |
Deepa Dinamani | 98cf8ee | 2013-03-27 15:16:47 -0700 | [diff] [blame] | 44 | #include <hsusb.h> |
richardl | b52d3f5 | 2013-04-12 17:37:28 -0700 | [diff] [blame] | 45 | #include <kernel/thread.h> |
Amol Jadi | f213901 | 2013-08-23 18:44:10 -0700 | [diff] [blame] | 46 | #include <arch/defines.h> |
| 47 | #include <stdlib.h> |
| 48 | #include <scm.h> |
| 49 | #include <partition_parser.h> |
| 50 | #include <platform/clock.h> |
| 51 | #include <platform/timer.h> |
Channagoud Kadabi | da988fd | 2013-12-04 13:44:42 -0800 | [diff] [blame] | 52 | #include <crypto5_wrapper.h> |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 53 | |
| 54 | #define PMIC_ARB_CHANNEL_NUM 0 |
| 55 | #define PMIC_ARB_OWNER_ID 0 |
| 56 | |
Channagoud Kadabi | da988fd | 2013-12-04 13:44:42 -0800 | [diff] [blame] | 57 | #define CRYPTO_ENGINE_INSTANCE 1 |
| 58 | #define CRYPTO_ENGINE_EE 1 |
| 59 | #define CRYPTO_ENGINE_FIFO_SIZE 64 |
| 60 | #define CRYPTO_ENGINE_READ_PIPE 3 |
| 61 | #define CRYPTO_ENGINE_WRITE_PIPE 2 |
| 62 | #define CRYPTO_READ_PIPE_LOCK_GRP 0 |
| 63 | #define CRYPTO_WRITE_PIPE_LOCK_GRP 0 |
| 64 | #define CRYPTO_ENGINE_CMD_ARRAY_SIZE 20 |
| 65 | |
Deepa Dinamani | 8ff46f0 | 2013-03-20 17:52:14 -0700 | [diff] [blame] | 66 | #define TLMM_VOL_UP_BTN_GPIO 72 |
| 67 | |
Maria Yu | 00fd382 | 2013-06-26 10:12:54 +0800 | [diff] [blame] | 68 | enum target_subtype { |
| 69 | HW_PLATFORM_SUBTYPE_SKUAA = 1, |
| 70 | HW_PLATFORM_SUBTYPE_SKUF = 2, |
| 71 | HW_PLATFORM_SUBTYPE_SKUAB = 3, |
| 72 | }; |
| 73 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 74 | static void set_sdc_power_ctrl(void); |
| 75 | |
| 76 | static uint32_t mmc_pwrctl_base[] = |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 77 | { MSM_SDC1_BASE, MSM_SDC2_BASE }; |
| 78 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 79 | static uint32_t mmc_sdhci_base[] = |
| 80 | { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE }; |
| 81 | |
| 82 | static uint32_t mmc_sdc_pwrctl_irq[] = |
| 83 | { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ }; |
| 84 | |
| 85 | struct mmc_device *dev; |
| 86 | |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 87 | void target_early_init(void) |
| 88 | { |
| 89 | #if WITH_DEBUG_UART |
Deepa Dinamani | d1823b4 | 2013-03-21 11:49:35 -0700 | [diff] [blame] | 90 | uart_dm_init(2, 0, BLSP1_UART1_BASE); |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 91 | #endif |
| 92 | } |
| 93 | |
Deepa Dinamani | 8ff46f0 | 2013-03-20 17:52:14 -0700 | [diff] [blame] | 94 | /* Return 1 if vol_up pressed */ |
| 95 | static int target_volume_up() |
| 96 | { |
| 97 | uint8_t status = 0; |
| 98 | |
| 99 | gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE); |
| 100 | |
richardl | b52d3f5 | 2013-04-12 17:37:28 -0700 | [diff] [blame] | 101 | /* Wait for the configuration to complete.*/ |
| 102 | thread_sleep(1); |
Deepa Dinamani | 8ff46f0 | 2013-03-20 17:52:14 -0700 | [diff] [blame] | 103 | /* Get status of GPIO */ |
| 104 | status = gpio_status(TLMM_VOL_UP_BTN_GPIO); |
| 105 | |
| 106 | /* Active low signal. */ |
| 107 | return !status; |
| 108 | } |
| 109 | |
| 110 | /* Return 1 if vol_down pressed */ |
| 111 | uint32_t target_volume_down() |
| 112 | { |
| 113 | /* Volume down button tied in with PMIC RESIN. */ |
| 114 | return pm8x41_resin_status(); |
| 115 | } |
| 116 | |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 117 | static void target_keystatus() |
| 118 | { |
Deepa Dinamani | 8ff46f0 | 2013-03-20 17:52:14 -0700 | [diff] [blame] | 119 | keys_init(); |
| 120 | |
| 121 | if(target_volume_down()) |
| 122 | keys_post_event(KEY_VOLUMEDOWN, 1); |
| 123 | |
| 124 | if(target_volume_up()) |
| 125 | keys_post_event(KEY_VOLUMEUP, 1); |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 128 | void target_sdc_init() |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 129 | { |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 130 | struct mmc_config_data config; |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 131 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 132 | /* Set drive strength & pull ctrl values */ |
| 133 | set_sdc_power_ctrl(); |
Deepa Dinamani | 8ff46f0 | 2013-03-20 17:52:14 -0700 | [diff] [blame] | 134 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 135 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
| 136 | config.max_clk_rate = MMC_CLK_200MHZ; |
| 137 | |
| 138 | /* Try slot 1*/ |
| 139 | config.slot = 1; |
| 140 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 141 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 142 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 143 | |
| 144 | if (!(dev = mmc_init(&config))) |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 145 | { |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 146 | /* Try slot 2 */ |
| 147 | config.slot = 2; |
| 148 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 149 | config.pwrctl_base = mmc_pwrctl_base[config.slot - 1]; |
| 150 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 151 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 152 | if (!(dev = mmc_init(&config))) |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 153 | { |
| 154 | dprintf(CRITICAL, "mmc init failed!"); |
| 155 | ASSERT(0); |
| 156 | } |
| 157 | } |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 158 | |
| 159 | /* MMC initialization is complete, read the partition table info */ |
| 160 | if (partition_read_table()) |
| 161 | { |
| 162 | dprintf(CRITICAL, "Error reading the partition table info\n"); |
| 163 | ASSERT(0); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | void target_init(void) |
| 168 | { |
| 169 | dprintf(INFO, "target_init()\n"); |
| 170 | |
| 171 | spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); |
| 172 | |
| 173 | target_keystatus(); |
| 174 | |
| 175 | target_sdc_init(); |
Aparna Mallavarapu | 6fe7a90 | 2013-09-11 20:19:11 +0530 | [diff] [blame] | 176 | |
| 177 | /* Display splash screen if enabled */ |
| 178 | dprintf(SPEW, "Display Init: Start\n"); |
Aravind Venkateswaran | dd50c1a | 2014-02-25 14:42:43 -0800 | [diff] [blame^] | 179 | target_display_init(); |
Aparna Mallavarapu | 6fe7a90 | 2013-09-11 20:19:11 +0530 | [diff] [blame] | 180 | dprintf(SPEW, "Display Init: Done\n"); |
Channagoud Kadabi | da988fd | 2013-12-04 13:44:42 -0800 | [diff] [blame] | 181 | |
| 182 | if (target_use_signed_kernel()) |
| 183 | target_crypto_init_params(); |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 184 | } |
| 185 | |
Aparna Mallavarapu | 2ce9f76 | 2013-07-30 15:29:12 +0530 | [diff] [blame] | 186 | void target_uninit(void) |
| 187 | { |
Channagoud Kadabi | d93cb81 | 2013-12-04 16:37:32 -0800 | [diff] [blame] | 188 | mmc_put_card_to_sleep(dev); |
| 189 | |
| 190 | if (crypto_initialized()) |
| 191 | crypto_eng_cleanup(); |
Aravind Venkateswaran | dd50c1a | 2014-02-25 14:42:43 -0800 | [diff] [blame^] | 192 | |
| 193 | target_display_shutdown(); |
Aparna Mallavarapu | 2ce9f76 | 2013-07-30 15:29:12 +0530 | [diff] [blame] | 194 | } |
Amol Jadi | f213901 | 2013-08-23 18:44:10 -0700 | [diff] [blame] | 195 | |
| 196 | #define SSD_CE_INSTANCE 1 |
| 197 | |
| 198 | void target_load_ssd_keystore(void) |
| 199 | { |
| 200 | uint64_t ptn; |
| 201 | int index; |
| 202 | uint64_t size; |
| 203 | uint32_t *buffer; |
| 204 | |
| 205 | if (!target_is_ssd_enabled()) |
| 206 | return; |
| 207 | |
| 208 | index = partition_get_index("ssd"); |
| 209 | |
| 210 | ptn = partition_get_offset(index); |
| 211 | if (ptn == 0){ |
| 212 | dprintf(CRITICAL, "Error: ssd partition not found\n"); |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | size = partition_get_size(index); |
| 217 | if (size == 0) { |
| 218 | dprintf(CRITICAL, "Error: invalid ssd partition size\n"); |
| 219 | return; |
| 220 | } |
| 221 | |
| 222 | buffer = memalign(CACHE_LINE, ROUNDUP(size, CACHE_LINE)); |
| 223 | if (!buffer) { |
| 224 | dprintf(CRITICAL, "Error: allocating memory for ssd buffer\n"); |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | if (mmc_read(ptn, buffer, size)) { |
| 229 | dprintf(CRITICAL, "Error: cannot read data\n"); |
| 230 | free(buffer); |
| 231 | return; |
| 232 | } |
| 233 | |
| 234 | clock_ce_enable(SSD_CE_INSTANCE); |
| 235 | scm_protect_keystore(buffer, size); |
| 236 | clock_ce_disable(SSD_CE_INSTANCE); |
| 237 | free(buffer); |
| 238 | } |
| 239 | |
Deepa Dinamani | 2b795bb | 2013-03-25 11:31:58 -0700 | [diff] [blame] | 240 | /* Do any target specific intialization needed before entering fastboot mode */ |
| 241 | void target_fastboot_init(void) |
| 242 | { |
| 243 | /* Set the BOOT_DONE flag in PM8110 */ |
| 244 | pm8x41_set_boot_done(); |
Amol Jadi | f213901 | 2013-08-23 18:44:10 -0700 | [diff] [blame] | 245 | |
| 246 | if (target_is_ssd_enabled()) { |
| 247 | clock_ce_enable(SSD_CE_INSTANCE); |
| 248 | target_load_ssd_keystore(); |
| 249 | } |
| 250 | |
Deepa Dinamani | 2b795bb | 2013-03-25 11:31:58 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Deepa Dinamani | 41803e0 | 2013-03-25 11:44:15 -0700 | [diff] [blame] | 253 | /* Detect the target type */ |
| 254 | void target_detect(struct board_data *board) |
| 255 | { |
Maria Yu | ca51ee2 | 2013-06-27 21:45:24 +0800 | [diff] [blame] | 256 | /* |
| 257 | * already fill the board->target on board.c |
| 258 | */ |
| 259 | |
Deepa Dinamani | 41803e0 | 2013-03-25 11:44:15 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /* Detect the modem type */ |
| 263 | void target_baseband_detect(struct board_data *board) |
| 264 | { |
| 265 | uint32_t platform; |
| 266 | uint32_t platform_subtype; |
| 267 | |
| 268 | platform = board->platform; |
| 269 | platform_subtype = board->platform_subtype; |
| 270 | |
| 271 | /* |
| 272 | * Look for platform subtype if present, else |
| 273 | * check for platform type to decide on the |
| 274 | * baseband type |
| 275 | */ |
| 276 | switch(platform_subtype) |
| 277 | { |
| 278 | case HW_PLATFORM_SUBTYPE_UNKNOWN: |
| 279 | break; |
Maria Yu | 00fd382 | 2013-06-26 10:12:54 +0800 | [diff] [blame] | 280 | case HW_PLATFORM_SUBTYPE_SKUAA: |
| 281 | break; |
| 282 | case HW_PLATFORM_SUBTYPE_SKUF: |
| 283 | break; |
| 284 | case HW_PLATFORM_SUBTYPE_SKUAB: |
| 285 | break; |
Deepa Dinamani | 41803e0 | 2013-03-25 11:44:15 -0700 | [diff] [blame] | 286 | default: |
| 287 | dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype); |
| 288 | ASSERT(0); |
| 289 | }; |
| 290 | |
| 291 | switch(platform) |
| 292 | { |
| 293 | case MSM8610: |
| 294 | case MSM8110: |
| 295 | case MSM8210: |
| 296 | case MSM8810: |
Deepa Dinamani | 39345cd | 2013-04-08 19:46:53 -0700 | [diff] [blame] | 297 | case MSM8612: |
David Ng | 2de1806 | 2013-04-19 20:22:16 -0700 | [diff] [blame] | 298 | case MSM8212: |
| 299 | case MSM8812: |
Deepa Dinamani | a8206cc | 2013-09-12 11:02:34 -0700 | [diff] [blame] | 300 | case MSM8510: |
| 301 | case MSM8512: |
Deepa Dinamani | 41803e0 | 2013-03-25 11:44:15 -0700 | [diff] [blame] | 302 | board->baseband = BASEBAND_MSM; |
| 303 | break; |
| 304 | default: |
| 305 | dprintf(CRITICAL, "Platform type: %u is not supported\n", platform); |
| 306 | ASSERT(0); |
| 307 | }; |
| 308 | } |
| 309 | |
| 310 | unsigned target_baseband() |
| 311 | { |
| 312 | return board_baseband(); |
| 313 | } |
| 314 | |
Deepa Dinamani | a6d1b75 | 2013-03-25 11:47:20 -0700 | [diff] [blame] | 315 | void target_serialno(unsigned char *buf) |
| 316 | { |
| 317 | uint32_t serialno; |
| 318 | if (target_is_emmc_boot()) { |
| 319 | serialno = mmc_get_psn(); |
| 320 | snprintf((char *)buf, 13, "%x", serialno); |
| 321 | } |
| 322 | } |
| 323 | |
Deepa Dinamani | 5390e10 | 2013-03-25 11:55:31 -0700 | [diff] [blame] | 324 | unsigned check_reboot_mode(void) |
| 325 | { |
| 326 | uint32_t restart_reason = 0; |
| 327 | |
| 328 | /* Read reboot reason and scrub it */ |
| 329 | restart_reason = readl(RESTART_REASON_ADDR); |
| 330 | writel(0x00, RESTART_REASON_ADDR); |
| 331 | |
| 332 | return restart_reason; |
| 333 | } |
| 334 | |
Deepa Dinamani | 172b7e6 | 2013-03-25 11:59:21 -0700 | [diff] [blame] | 335 | void reboot_device(unsigned reboot_reason) |
| 336 | { |
Channagoud Kadabi | 8730630 | 2013-12-12 14:55:47 -0800 | [diff] [blame] | 337 | int ret = 0; |
| 338 | |
Deepa Dinamani | 172b7e6 | 2013-03-25 11:59:21 -0700 | [diff] [blame] | 339 | writel(reboot_reason, RESTART_REASON_ADDR); |
| 340 | |
| 341 | /* Configure PMIC for warm reset */ |
| 342 | pm8x41_reset_configure(PON_PSHOLD_WARM_RESET); |
| 343 | |
Channagoud Kadabi | 8730630 | 2013-12-12 14:55:47 -0800 | [diff] [blame] | 344 | ret = scm_halt_pmic_arbiter(); |
| 345 | if (ret) |
| 346 | dprintf(CRITICAL , "Failed to halt pmic arbiter: %d\n", ret); |
| 347 | |
Deepa Dinamani | 172b7e6 | 2013-03-25 11:59:21 -0700 | [diff] [blame] | 348 | /* Drop PS_HOLD for MSM */ |
| 349 | writel(0x00, MPM2_MPM_PS_HOLD); |
| 350 | |
| 351 | mdelay(5000); |
| 352 | |
| 353 | dprintf(CRITICAL, "Rebooting failed\n"); |
| 354 | } |
| 355 | |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 356 | /* Returns 1 if autopanel detection is enabled for the target. */ |
| 357 | uint8_t target_panel_auto_detect_enabled() |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 358 | { |
| 359 | int ret = 0; |
Shuo Yan | b757da8 | 2013-08-09 08:58:24 +0800 | [diff] [blame] | 360 | |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 361 | switch(board_hardware_id()) |
| 362 | { |
Terence Hampson | 0e2f655 | 2013-07-09 15:45:37 -0400 | [diff] [blame] | 363 | case HW_PLATFORM_MTP: |
| 364 | case HW_PLATFORM_SURF: |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 365 | case HW_PLATFORM_QRD: |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 366 | default: |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 367 | dprintf(SPEW, "Panel auto-detection is disabled\n"); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 368 | ret = 0; |
| 369 | } |
| 370 | return ret; |
| 371 | } |
| 372 | |
Shivaraj Shetty | 25b0aa0 | 2013-10-30 20:55:49 +0530 | [diff] [blame] | 373 | static uint8_t splash_override; |
| 374 | |
| 375 | /* Returns 1 if target supports continuous splash screen. */ |
| 376 | int target_cont_splash_screen() |
| 377 | { |
| 378 | uint8_t splash_screen = 0; |
| 379 | if(!splash_override) { |
| 380 | switch(board_hardware_id()) |
| 381 | { |
| 382 | case HW_PLATFORM_QRD: |
| 383 | case HW_PLATFORM_MTP: |
| 384 | case HW_PLATFORM_SURF: |
| 385 | dprintf(SPEW, "Target_cont_splash=1\n"); |
| 386 | splash_screen = 1; |
| 387 | break; |
| 388 | default: |
| 389 | dprintf(SPEW, "Target_cont_splash=0\n"); |
| 390 | splash_screen = 0; |
| 391 | } |
| 392 | } |
| 393 | return splash_screen; |
| 394 | } |
| 395 | |
| 396 | void target_force_cont_splash_disable(uint8_t override) |
| 397 | { |
| 398 | splash_override = override; |
| 399 | } |
| 400 | |
Deepa Dinamani | 004eb32 | 2013-03-25 13:20:50 -0700 | [diff] [blame] | 401 | unsigned target_pause_for_battery_charge(void) |
| 402 | { |
| 403 | uint8_t pon_reason = pm8x41_get_pon_reason(); |
Xu Kai | c2e0afc | 2013-07-19 13:26:36 +0800 | [diff] [blame] | 404 | uint8_t is_cold_boot = pm8x41_get_is_cold_boot(); |
| 405 | dprintf(INFO, "%s : pon_reason is %d cold_boot:%d\n", __func__, |
| 406 | pon_reason, is_cold_boot); |
| 407 | /*In case of fastboot reboot, adb reboot or if we see the power key |
| 408 | * pressed we do not want go into charger mode. |
| 409 | * fastboot reboot is warm boot with PON hard reset bit not set |
| 410 | * adb reboot is a cold boot with PON hard reset bit set |
Deepa Dinamani | 004eb32 | 2013-03-25 13:20:50 -0700 | [diff] [blame] | 411 | */ |
Xu Kai | c2e0afc | 2013-07-19 13:26:36 +0800 | [diff] [blame] | 412 | if (is_cold_boot && |
| 413 | (!(pon_reason & HARD_RST)) && |
| 414 | (!(pon_reason & KPDPWR_N)) && |
| 415 | ((pon_reason & USB_CHG) || (pon_reason & DC_CHG))) |
| 416 | return 1; |
| 417 | else |
| 418 | return 0; |
Deepa Dinamani | 004eb32 | 2013-03-25 13:20:50 -0700 | [diff] [blame] | 419 | } |
| 420 | |
Deepa Dinamani | 98cf8ee | 2013-03-27 15:16:47 -0700 | [diff] [blame] | 421 | void target_usb_stop(void) |
| 422 | { |
| 423 | /* Disable VBUS mimicing in the controller. */ |
| 424 | ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR); |
| 425 | } |
| 426 | |
| 427 | void target_usb_init(void) |
| 428 | { |
| 429 | uint32_t val; |
| 430 | |
| 431 | /* Select and enable external configuration with USB PHY */ |
| 432 | ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET); |
| 433 | |
| 434 | /* Enable sess_vld */ |
| 435 | val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN; |
| 436 | writel(val, USB_GENCONFIG_2); |
| 437 | |
| 438 | /* Enable external vbus configuration in the LINK */ |
| 439 | val = readl(USB_USBCMD); |
| 440 | val |= SESS_VLD_CTRL; |
| 441 | writel(val, USB_USBCMD); |
| 442 | } |
| 443 | |
| 444 | |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 445 | unsigned board_machtype(void) |
| 446 | { |
Deepa Dinamani | 2b795bb | 2013-03-25 11:31:58 -0700 | [diff] [blame] | 447 | return 0; |
Deepa Dinamani | 7dc3d4b | 2013-02-08 16:40:38 -0800 | [diff] [blame] | 448 | } |
Channagoud Kadabi | e1b7526 | 2013-05-08 12:58:39 -0700 | [diff] [blame] | 449 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 450 | static void set_sdc_power_ctrl() |
Channagoud Kadabi | e1b7526 | 2013-05-08 12:58:39 -0700 | [diff] [blame] | 451 | { |
Channagoud Kadabi | d2fbf57 | 2013-11-07 11:33:50 -0800 | [diff] [blame] | 452 | uint8_t data_hdrv = 0; |
| 453 | uint32_t platform = board_platform_id(); |
| 454 | |
| 455 | if (platform == MSM8510 || platform == MSM8512) |
| 456 | data_hdrv = TLMM_CUR_VAL_6MA; |
| 457 | else |
| 458 | data_hdrv = TLMM_CUR_VAL_10MA; |
| 459 | |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 460 | /* Drive strength configs for sdc pins */ |
| 461 | struct tlmm_cfgs sdc1_hdrv_cfg[] = |
| 462 | { |
| 463 | { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK }, |
| 464 | { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK }, |
Channagoud Kadabi | d2fbf57 | 2013-11-07 11:33:50 -0800 | [diff] [blame] | 465 | { SDC1_DATA_HDRV_CTL_OFF, data_hdrv, TLMM_HDRV_MASK }, |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 466 | }; |
| 467 | |
| 468 | /* Pull configs for sdc pins */ |
| 469 | struct tlmm_cfgs sdc1_pull_cfg[] = |
| 470 | { |
| 471 | { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK }, |
| 472 | { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK }, |
| 473 | { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK }, |
| 474 | }; |
| 475 | |
| 476 | /* Set the drive strength & pull control values */ |
| 477 | tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); |
| 478 | tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); |
| 479 | } |
| 480 | |
Channagoud Kadabi | f59e467 | 2013-09-10 14:24:43 -0700 | [diff] [blame] | 481 | void *target_mmc_device() |
Channagoud Kadabi | 25e4d93 | 2013-05-10 17:54:29 -0700 | [diff] [blame] | 482 | { |
Channagoud Kadabi | f59e467 | 2013-09-10 14:24:43 -0700 | [diff] [blame] | 483 | return (void *) dev; |
Channagoud Kadabi | e1b7526 | 2013-05-08 12:58:39 -0700 | [diff] [blame] | 484 | } |
Channagoud Kadabi | da988fd | 2013-12-04 13:44:42 -0800 | [diff] [blame] | 485 | |
| 486 | /* Set up params for h/w CRYPTO_ENGINE. */ |
| 487 | void target_crypto_init_params() |
| 488 | { |
| 489 | struct crypto_init_params ce_params; |
| 490 | |
| 491 | /* Set up base addresses and instance. */ |
| 492 | ce_params.crypto_instance = CRYPTO_ENGINE_INSTANCE; |
| 493 | ce_params.crypto_base = MSM_CE1_BASE; |
| 494 | ce_params.bam_base = MSM_CE1_BAM_BASE; |
| 495 | |
| 496 | /* Set up BAM config. */ |
| 497 | ce_params.bam_ee = CRYPTO_ENGINE_EE; |
| 498 | ce_params.pipes.read_pipe = CRYPTO_ENGINE_READ_PIPE; |
| 499 | ce_params.pipes.write_pipe = CRYPTO_ENGINE_WRITE_PIPE; |
| 500 | ce_params.pipes.read_pipe_grp = CRYPTO_READ_PIPE_LOCK_GRP; |
| 501 | ce_params.pipes.write_pipe_grp = CRYPTO_WRITE_PIPE_LOCK_GRP; |
| 502 | |
| 503 | /* Assign buffer sizes. */ |
| 504 | ce_params.num_ce = CRYPTO_ENGINE_CMD_ARRAY_SIZE; |
| 505 | ce_params.read_fifo_size = CRYPTO_ENGINE_FIFO_SIZE; |
| 506 | ce_params.write_fifo_size = CRYPTO_ENGINE_FIFO_SIZE; |
| 507 | |
| 508 | ce_params.do_bam_init = 0; |
| 509 | |
| 510 | crypto_init_params(&ce_params); |
| 511 | } |
| 512 | |
| 513 | crypto_engine_type board_ce_type(void) |
| 514 | { |
| 515 | return CRYPTO_ENGINE_TYPE_HW; |
| 516 | } |