Eugene Yasman | 6382ee0 | 2013-01-16 13:00:56 +0200 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
Deepa Dinamani | 1e09494 | 2012-10-30 15:49:02 -0700 | [diff] [blame] | 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. |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 15 | * |
Deepa Dinamani | 1e09494 | 2012-10-30 15:49:02 -0700 | [diff] [blame] | 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. |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #include <debug.h> |
| 30 | #include <platform/iomap.h> |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 31 | #include <platform/irqs.h> |
Channagoud Kadabi | 744c890 | 2013-04-02 11:54:53 -0700 | [diff] [blame] | 32 | #include <platform/gpio.h> |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 33 | #include <reg.h> |
| 34 | #include <target.h> |
| 35 | #include <platform.h> |
Pavel Nedev | 0351149 | 2013-03-08 19:05:32 -0800 | [diff] [blame] | 36 | #include <dload_util.h> |
Deepa Dinamani | 26e9326 | 2012-05-21 17:35:14 -0700 | [diff] [blame] | 37 | #include <uart_dm.h> |
Amol Jadi | 29f9503 | 2012-06-22 12:52:54 -0700 | [diff] [blame] | 38 | #include <mmc.h> |
Deepa Dinamani | c2a9b36 | 2012-02-23 15:15:54 -0800 | [diff] [blame] | 39 | #include <spmi.h> |
Neeti Desai | 465491e | 2012-07-31 12:53:35 -0700 | [diff] [blame] | 40 | #include <board.h> |
| 41 | #include <smem.h> |
| 42 | #include <baseband.h> |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 43 | #include <dev/keys.h> |
| 44 | #include <pm8x41.h> |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 45 | #include <crypto5_wrapper.h> |
Eugene Yasman | a0d1812 | 2013-02-26 13:23:05 +0200 | [diff] [blame] | 46 | #include <hsusb.h> |
| 47 | #include <clock.h> |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 48 | #include <partition_parser.h> |
| 49 | #include <scm.h> |
| 50 | #include <platform/clock.h> |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 51 | #include <platform/gpio.h> |
Channagoud Kadabi | f84830c | 2013-04-19 14:35:47 -0700 | [diff] [blame] | 52 | #include <stdlib.h> |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 53 | |
Channagoud Kadabi | 20e0dd1 | 2013-08-06 12:30:51 -0700 | [diff] [blame] | 54 | enum hw_platform_subtype |
| 55 | { |
| 56 | HW_PLATFORM_SUBTYPE_CDP_INTERPOSER = 8, |
| 57 | }; |
| 58 | |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 59 | extern bool target_use_signed_kernel(void); |
Channagoud Kadabi | 744c890 | 2013-04-02 11:54:53 -0700 | [diff] [blame] | 60 | static void set_sdc_power_ctrl(); |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 61 | |
| 62 | static unsigned int target_id; |
Deepa Dinamani | 07f1571 | 2013-03-08 17:02:13 -0800 | [diff] [blame] | 63 | static uint32_t pmic_ver; |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 64 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 65 | #if MMC_SDHCI_SUPPORT |
| 66 | struct mmc_device *dev; |
| 67 | #endif |
| 68 | |
Deepa Dinamani | c2a9b36 | 2012-02-23 15:15:54 -0800 | [diff] [blame] | 69 | #define PMIC_ARB_CHANNEL_NUM 0 |
| 70 | #define PMIC_ARB_OWNER_ID 0 |
| 71 | |
Deepa Dinamani | 1e09494 | 2012-10-30 15:49:02 -0700 | [diff] [blame] | 72 | #define WDOG_DEBUG_DISABLE_BIT 17 |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 73 | |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 74 | #define CE_INSTANCE 2 |
| 75 | #define CE_EE 1 |
| 76 | #define CE_FIFO_SIZE 64 |
| 77 | #define CE_READ_PIPE 3 |
| 78 | #define CE_WRITE_PIPE 2 |
Deepa Dinamani | 809c428 | 2013-07-09 14:06:02 -0700 | [diff] [blame] | 79 | #define CE_READ_PIPE_LOCK_GRP 0 |
| 80 | #define CE_WRITE_PIPE_LOCK_GRP 0 |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 81 | #define CE_ARRAY_SIZE 20 |
| 82 | |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 83 | #ifdef SSD_ENABLE |
| 84 | #define SSD_CE_INSTANCE_1 1 |
| 85 | #define SSD_PARTITION_SIZE 8192 |
| 86 | #endif |
| 87 | |
Sundarajan Srinivasan | d00f31d | 2013-07-19 12:09:15 -0700 | [diff] [blame] | 88 | #define FASTBOOT_MODE 0x77665500 |
| 89 | |
Channagoud Kadabi | c48b3e9 | 2013-06-23 16:19:10 -0700 | [diff] [blame] | 90 | #define BOARD_SOC_VERSION1(soc_rev) (soc_rev >= 0x10000 && soc_rev < 0x20000) |
| 91 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 92 | #if MMC_SDHCI_SUPPORT |
| 93 | static uint32_t mmc_sdhci_base[] = |
| 94 | { MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE, MSM_SDC3_SDHCI_BASE, MSM_SDC4_SDHCI_BASE }; |
| 95 | #endif |
| 96 | |
Deepa Dinamani | ca5ad85 | 2012-05-07 18:19:47 -0700 | [diff] [blame] | 97 | static uint32_t mmc_sdc_base[] = |
| 98 | { MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE }; |
| 99 | |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 100 | static uint32_t mmc_sdc_pwrctl_irq[] = |
| 101 | { SDCC1_PWRCTL_IRQ, SDCC2_PWRCTL_IRQ, SDCC3_PWRCTL_IRQ, SDCC4_PWRCTL_IRQ }; |
| 102 | |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 103 | void target_early_init(void) |
| 104 | { |
Deepa Dinamani | b073ba2 | 2012-08-10 11:06:41 -0700 | [diff] [blame] | 105 | #if WITH_DEBUG_UART |
Neeti Desai | ac01127 | 2012-08-29 18:24:54 -0700 | [diff] [blame] | 106 | uart_dm_init(1, 0, BLSP1_UART1_BASE); |
Deepa Dinamani | b073ba2 | 2012-08-10 11:06:41 -0700 | [diff] [blame] | 107 | #endif |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 108 | } |
| 109 | |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 110 | /* Return 1 if vol_up pressed */ |
| 111 | static int target_volume_up() |
| 112 | { |
| 113 | uint8_t status = 0; |
| 114 | struct pm8x41_gpio gpio; |
| 115 | |
| 116 | /* CDP vol_up seems to be always grounded. So gpio status is read as 0, |
| 117 | * whether key is pressed or not. |
| 118 | * Ignore volume_up key on CDP for now. |
| 119 | */ |
| 120 | if (board_hardware_id() == HW_PLATFORM_SURF) |
| 121 | return 0; |
| 122 | |
| 123 | /* Configure the GPIO */ |
| 124 | gpio.direction = PM_GPIO_DIR_IN; |
| 125 | gpio.function = 0; |
| 126 | gpio.pull = PM_GPIO_PULL_UP_30; |
Eugene Yasman | 6382ee0 | 2013-01-16 13:00:56 +0200 | [diff] [blame] | 127 | gpio.vin_sel = 2; |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 128 | |
| 129 | pm8x41_gpio_config(5, &gpio); |
| 130 | |
Channagoud Kadabi | 4d7b530 | 2013-08-07 16:34:08 -0700 | [diff] [blame] | 131 | /* Wait for the pmic gpio config to take effect */ |
| 132 | thread_sleep(1); |
| 133 | |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 134 | /* Get status of P_GPIO_5 */ |
| 135 | pm8x41_gpio_get(5, &status); |
| 136 | |
| 137 | return !status; /* active low */ |
| 138 | } |
| 139 | |
| 140 | /* Return 1 if vol_down pressed */ |
Deepa Dinamani | 66a8796 | 2013-02-04 10:39:30 -0800 | [diff] [blame] | 141 | uint32_t target_volume_down() |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 142 | { |
Deepa Dinamani | 66a8796 | 2013-02-04 10:39:30 -0800 | [diff] [blame] | 143 | /* Volume down button is tied in with RESIN on MSM8974. */ |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 144 | if (platform_is_8974() && (pmic_ver == PM8X41_VERSION_V2)) |
Channagoud Kadabi | 84dcd91 | 2013-07-03 15:33:15 -0700 | [diff] [blame] | 145 | return pm8x41_v2_resin_status(); |
Deepa Dinamani | 13bfc85 | 2013-02-05 17:56:47 -0800 | [diff] [blame] | 146 | else |
| 147 | return pm8x41_resin_status(); |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static void target_keystatus() |
| 151 | { |
| 152 | keys_init(); |
| 153 | |
| 154 | if(target_volume_down()) |
| 155 | keys_post_event(KEY_VOLUMEDOWN, 1); |
| 156 | |
| 157 | if(target_volume_up()) |
| 158 | keys_post_event(KEY_VOLUMEUP, 1); |
| 159 | } |
| 160 | |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 161 | /* Set up params for h/w CE. */ |
| 162 | void target_crypto_init_params() |
| 163 | { |
| 164 | struct crypto_init_params ce_params; |
| 165 | |
| 166 | /* Set up base addresses and instance. */ |
| 167 | ce_params.crypto_instance = CE_INSTANCE; |
| 168 | ce_params.crypto_base = MSM_CE2_BASE; |
| 169 | ce_params.bam_base = MSM_CE2_BAM_BASE; |
| 170 | |
| 171 | /* Set up BAM config. */ |
Deepa Dinamani | 809c428 | 2013-07-09 14:06:02 -0700 | [diff] [blame] | 172 | ce_params.bam_ee = CE_EE; |
| 173 | ce_params.pipes.read_pipe = CE_READ_PIPE; |
| 174 | ce_params.pipes.write_pipe = CE_WRITE_PIPE; |
| 175 | ce_params.pipes.read_pipe_grp = CE_READ_PIPE_LOCK_GRP; |
| 176 | ce_params.pipes.write_pipe_grp = CE_WRITE_PIPE_LOCK_GRP; |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 177 | |
| 178 | /* Assign buffer sizes. */ |
| 179 | ce_params.num_ce = CE_ARRAY_SIZE; |
| 180 | ce_params.read_fifo_size = CE_FIFO_SIZE; |
| 181 | ce_params.write_fifo_size = CE_FIFO_SIZE; |
| 182 | |
Deepa Dinamani | e505d3d | 2013-05-14 16:55:38 -0700 | [diff] [blame] | 183 | /* BAM is initialized by TZ for this platform. |
| 184 | * Do not do it again as the initialization address space |
| 185 | * is locked. |
| 186 | */ |
| 187 | ce_params.do_bam_init = 0; |
| 188 | |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 189 | crypto_init_params(&ce_params); |
| 190 | } |
| 191 | |
| 192 | crypto_engine_type board_ce_type(void) |
| 193 | { |
| 194 | return CRYPTO_ENGINE_TYPE_HW; |
| 195 | } |
| 196 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 197 | #if MMC_SDHCI_SUPPORT |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 198 | static void target_mmc_sdhci_init() |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 199 | { |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 200 | struct mmc_config_data config = {0}; |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 201 | uint32_t soc_ver = 0; |
| 202 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 203 | soc_ver = board_soc_version(); |
| 204 | |
| 205 | /* |
| 206 | * 8974 v1 fluid devices, have a hardware bug |
| 207 | * which limits the bus width to 4 bit. |
| 208 | */ |
| 209 | switch(board_hardware_id()) |
| 210 | { |
| 211 | case HW_PLATFORM_FLUID: |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 212 | if (platform_is_8974() && BOARD_SOC_VERSION1(soc_ver)) |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 213 | config.bus_width = DATA_BUS_WIDTH_4BIT; |
Channagoud Kadabi | c48b3e9 | 2013-06-23 16:19:10 -0700 | [diff] [blame] | 214 | else |
| 215 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 216 | break; |
| 217 | default: |
| 218 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
| 219 | }; |
| 220 | |
| 221 | config.max_clk_rate = MMC_CLK_200MHZ; |
| 222 | |
| 223 | /* Trying Slot 1*/ |
| 224 | config.slot = 1; |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 225 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 226 | config.pwrctl_base = mmc_sdc_base[config.slot - 1]; |
| 227 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 228 | |
| 229 | if (!(dev = mmc_init(&config))) { |
| 230 | /* Trying Slot 2 next */ |
| 231 | config.slot = 2; |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 232 | config.sdhc_base = mmc_sdhci_base[config.slot - 1]; |
| 233 | config.pwrctl_base = mmc_sdc_base[config.slot - 1]; |
| 234 | config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1]; |
| 235 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 236 | if (!(dev = mmc_init(&config))) { |
| 237 | dprintf(CRITICAL, "mmc init failed!"); |
| 238 | ASSERT(0); |
| 239 | } |
| 240 | } |
Channagoud Kadabi | ef5332f | 2013-05-16 15:23:43 -0700 | [diff] [blame] | 241 | |
| 242 | /* |
| 243 | * MMC initialization is complete, read the partition table info |
| 244 | */ |
| 245 | if (partition_read_table()) { |
| 246 | dprintf(CRITICAL, "Error reading the partition table info\n"); |
| 247 | ASSERT(0); |
| 248 | } |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Channagoud Kadabi | 6faaf70 | 2013-09-10 15:00:51 -0700 | [diff] [blame] | 251 | void *target_mmc_device() |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 252 | { |
Channagoud Kadabi | 6faaf70 | 2013-09-10 15:00:51 -0700 | [diff] [blame] | 253 | return (void *) dev; |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 254 | } |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 255 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 256 | #else |
Channagoud Kadabi | b14d6d0 | 2013-05-15 10:48:59 -0700 | [diff] [blame] | 257 | static void target_mmc_mci_init() |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 258 | { |
Deepa Dinamani | ca5ad85 | 2012-05-07 18:19:47 -0700 | [diff] [blame] | 259 | uint32_t base_addr; |
| 260 | uint8_t slot; |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 261 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 262 | /* Trying Slot 1 */ |
| 263 | slot = 1; |
| 264 | base_addr = mmc_sdc_base[slot - 1]; |
| 265 | |
| 266 | if (mmc_boot_main(slot, base_addr)) |
| 267 | { |
| 268 | /* Trying Slot 2 next */ |
| 269 | slot = 2; |
| 270 | base_addr = mmc_sdc_base[slot - 1]; |
| 271 | if (mmc_boot_main(slot, base_addr)) { |
| 272 | dprintf(CRITICAL, "mmc init failed!"); |
| 273 | ASSERT(0); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /* |
| 279 | * Function to set the capabilities for the host |
| 280 | */ |
| 281 | void target_mmc_caps(struct mmc_host *host) |
| 282 | { |
| 283 | uint32_t soc_ver = 0; |
| 284 | |
| 285 | soc_ver = board_soc_version(); |
| 286 | |
| 287 | /* |
| 288 | * 8974 v1 fluid devices, have a hardware bug |
| 289 | * which limits the bus width to 4 bit. |
| 290 | */ |
| 291 | switch(board_hardware_id()) |
| 292 | { |
| 293 | case HW_PLATFORM_FLUID: |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 294 | if (platform_is_8974() && BOARD_SOC_VERSION1(soc_ver)) |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 295 | host->caps.bus_width = MMC_BOOT_BUS_WIDTH_4_BIT; |
Channagoud Kadabi | c48b3e9 | 2013-06-23 16:19:10 -0700 | [diff] [blame] | 296 | else |
| 297 | host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT; |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 298 | break; |
| 299 | default: |
| 300 | host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT; |
| 301 | }; |
| 302 | |
| 303 | host->caps.ddr_mode = 1; |
| 304 | host->caps.hs200_mode = 1; |
| 305 | host->caps.hs_clk_rate = MMC_CLK_96MHZ; |
| 306 | } |
| 307 | #endif |
| 308 | |
| 309 | |
| 310 | void target_init(void) |
| 311 | { |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 312 | dprintf(INFO, "target_init()\n"); |
| 313 | |
Deepa Dinamani | c2a9b36 | 2012-02-23 15:15:54 -0800 | [diff] [blame] | 314 | spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 315 | |
Deepa Dinamani | 07f1571 | 2013-03-08 17:02:13 -0800 | [diff] [blame] | 316 | /* Save PM8941 version info. */ |
| 317 | pmic_ver = pm8x41_get_pmic_rev(); |
| 318 | |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 319 | target_keystatus(); |
| 320 | |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 321 | if (target_use_signed_kernel()) |
| 322 | target_crypto_init_params(); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 323 | /* Display splash screen if enabled */ |
| 324 | #if DISPLAY_SPLASH_SCREEN |
Channagoud Kadabi | 8a9c6a2 | 2013-02-05 14:43:48 -0800 | [diff] [blame] | 325 | dprintf(INFO, "Display Init: Start\n"); |
Channagoud Kadabi | 20e0dd1 | 2013-08-06 12:30:51 -0700 | [diff] [blame] | 326 | if (board_hardware_subtype() != HW_PLATFORM_SUBTYPE_CDP_INTERPOSER) |
| 327 | { |
| 328 | display_init(); |
| 329 | } |
Channagoud Kadabi | 8a9c6a2 | 2013-02-05 14:43:48 -0800 | [diff] [blame] | 330 | dprintf(INFO, "Display Init: Done\n"); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 331 | #endif |
Deepa Dinamani | b9a5720 | 2012-12-20 18:05:11 -0800 | [diff] [blame] | 332 | |
Channagoud Kadabi | 744c890 | 2013-04-02 11:54:53 -0700 | [diff] [blame] | 333 | /* |
| 334 | * Set drive strength & pull ctrl for |
| 335 | * emmc |
| 336 | */ |
| 337 | set_sdc_power_ctrl(); |
| 338 | |
Channagoud Kadabi | c1fdc8d | 2013-04-05 11:29:23 -0700 | [diff] [blame] | 339 | #if MMC_SDHCI_SUPPORT |
| 340 | target_mmc_sdhci_init(); |
| 341 | #else |
| 342 | target_mmc_mci_init(); |
| 343 | #endif |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | unsigned board_machtype(void) |
| 347 | { |
| 348 | return target_id; |
| 349 | } |
| 350 | |
| 351 | /* Do any target specific intialization needed before entering fastboot mode */ |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 352 | #ifdef SSD_ENABLE |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 353 | static void ssd_load_keystore_from_emmc() |
| 354 | { |
| 355 | uint64_t ptn = 0; |
| 356 | int index = -1; |
| 357 | uint32_t size = SSD_PARTITION_SIZE; |
| 358 | int ret = -1; |
| 359 | |
Channagoud Kadabi | f84830c | 2013-04-19 14:35:47 -0700 | [diff] [blame] | 360 | uint32_t *buffer = (uint32_t *)memalign(CACHE_LINE, |
| 361 | ROUNDUP(SSD_PARTITION_SIZE, CACHE_LINE)); |
| 362 | |
| 363 | if (!buffer) { |
| 364 | dprintf(CRITICAL, "Error Allocating memory for SSD buffer\n"); |
| 365 | ASSERT(0); |
| 366 | } |
| 367 | |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 368 | index = partition_get_index("ssd"); |
| 369 | |
| 370 | ptn = partition_get_offset(index); |
| 371 | if(ptn == 0){ |
| 372 | dprintf(CRITICAL,"ERROR: ssd parition not found"); |
| 373 | return; |
| 374 | } |
| 375 | |
| 376 | if(mmc_read(ptn, buffer, size)){ |
| 377 | dprintf(CRITICAL,"ERROR:Cannot read data\n"); |
| 378 | return; |
| 379 | } |
| 380 | |
| 381 | ret = scm_protect_keystore((uint32_t *)&buffer[0],size); |
| 382 | if(ret != 0) |
| 383 | dprintf(CRITICAL,"ERROR: scm_protect_keystore Failed"); |
Channagoud Kadabi | f84830c | 2013-04-19 14:35:47 -0700 | [diff] [blame] | 384 | |
| 385 | free(buffer); |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 386 | } |
| 387 | #endif |
| 388 | |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 389 | void target_fastboot_init(void) |
| 390 | { |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 391 | /* Set the BOOT_DONE flag in PM8921 */ |
| 392 | pm8x41_set_boot_done(); |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 393 | |
| 394 | #ifdef SSD_ENABLE |
| 395 | clock_ce_enable(SSD_CE_INSTANCE_1); |
| 396 | ssd_load_keystore_from_emmc(); |
| 397 | #endif |
Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame] | 398 | } |
Neeti Desai | 465491e | 2012-07-31 12:53:35 -0700 | [diff] [blame] | 399 | |
| 400 | /* Detect the target type */ |
| 401 | void target_detect(struct board_data *board) |
| 402 | { |
| 403 | board->target = LINUX_MACHTYPE_UNKNOWN; |
| 404 | } |
| 405 | |
| 406 | /* Detect the modem type */ |
| 407 | void target_baseband_detect(struct board_data *board) |
| 408 | { |
Channagoud Kadabi | f1d4442 | 2013-02-21 22:59:35 -0800 | [diff] [blame] | 409 | uint32_t platform; |
| 410 | uint32_t platform_subtype; |
| 411 | |
| 412 | platform = board->platform; |
Channagoud Kadabi | f1d4442 | 2013-02-21 22:59:35 -0800 | [diff] [blame] | 413 | |
| 414 | switch(platform) { |
| 415 | case MSM8974: |
Deepa Dinamani | 713a76f | 2013-05-03 13:17:24 -0700 | [diff] [blame] | 416 | case MSM8274: |
| 417 | case MSM8674: |
Deepa Dinamani | caf9e77 | 2013-06-14 12:39:41 -0700 | [diff] [blame] | 418 | case MSM8274AA: |
| 419 | case MSM8274AB: |
| 420 | case MSM8274AC: |
| 421 | case MSM8674AA: |
| 422 | case MSM8674AB: |
| 423 | case MSM8674AC: |
| 424 | case MSM8974AA: |
| 425 | case MSM8974AB: |
| 426 | case MSM8974AC: |
Channagoud Kadabi | 20e0dd1 | 2013-08-06 12:30:51 -0700 | [diff] [blame] | 427 | case MSMSAMARIUM2: |
| 428 | case MSMSAMARIUM9: |
Neeti Desai | 465491e | 2012-07-31 12:53:35 -0700 | [diff] [blame] | 429 | board->baseband = BASEBAND_MSM; |
Channagoud Kadabi | f1d4442 | 2013-02-21 22:59:35 -0800 | [diff] [blame] | 430 | break; |
| 431 | case APQ8074: |
Deepa Dinamani | caf9e77 | 2013-06-14 12:39:41 -0700 | [diff] [blame] | 432 | case APQ8074AA: |
| 433 | case APQ8074AB: |
| 434 | case APQ8074AC: |
Channagoud Kadabi | 20e0dd1 | 2013-08-06 12:30:51 -0700 | [diff] [blame] | 435 | case MSMSAMARIUM0: |
Channagoud Kadabi | f1d4442 | 2013-02-21 22:59:35 -0800 | [diff] [blame] | 436 | board->baseband = BASEBAND_APQ; |
| 437 | break; |
| 438 | default: |
| 439 | dprintf(CRITICAL, "Platform type: %u is not supported\n",platform); |
| 440 | ASSERT(0); |
| 441 | }; |
Neeti Desai | 465491e | 2012-07-31 12:53:35 -0700 | [diff] [blame] | 442 | } |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 443 | |
Deepa Dinamani | 927a6b6 | 2013-03-28 17:05:32 -0700 | [diff] [blame] | 444 | unsigned target_baseband() |
| 445 | { |
| 446 | return board_baseband(); |
| 447 | } |
| 448 | |
Deepa Dinamani | 9a61293 | 2012-08-14 16:15:03 -0700 | [diff] [blame] | 449 | void target_serialno(unsigned char *buf) |
| 450 | { |
| 451 | unsigned int serialno; |
| 452 | if (target_is_emmc_boot()) { |
| 453 | serialno = mmc_get_psn(); |
| 454 | snprintf((char *)buf, 13, "%x", serialno); |
| 455 | } |
| 456 | } |
Amol Jadi | 6639d45 | 2012-08-16 14:51:19 -0700 | [diff] [blame] | 457 | |
| 458 | unsigned check_reboot_mode(void) |
| 459 | { |
| 460 | uint32_t restart_reason = 0; |
Channagoud Kadabi | 8c8587f | 2013-02-08 12:46:09 -0800 | [diff] [blame] | 461 | uint32_t soc_ver = 0; |
| 462 | uint32_t restart_reason_addr; |
| 463 | |
| 464 | soc_ver = board_soc_version(); |
| 465 | |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 466 | if (platform_is_8974() && BOARD_SOC_VERSION1(soc_ver)) |
Channagoud Kadabi | 8c8587f | 2013-02-08 12:46:09 -0800 | [diff] [blame] | 467 | restart_reason_addr = RESTART_REASON_ADDR; |
Channagoud Kadabi | c48b3e9 | 2013-06-23 16:19:10 -0700 | [diff] [blame] | 468 | else |
| 469 | restart_reason_addr = RESTART_REASON_ADDR_V2; |
Amol Jadi | 6639d45 | 2012-08-16 14:51:19 -0700 | [diff] [blame] | 470 | |
| 471 | /* Read reboot reason and scrub it */ |
Channagoud Kadabi | 8c8587f | 2013-02-08 12:46:09 -0800 | [diff] [blame] | 472 | restart_reason = readl(restart_reason_addr); |
| 473 | writel(0x00, restart_reason_addr); |
Amol Jadi | 6639d45 | 2012-08-16 14:51:19 -0700 | [diff] [blame] | 474 | |
| 475 | return restart_reason; |
| 476 | } |
Neeti Desai | 120b55d | 2012-08-20 17:15:56 -0700 | [diff] [blame] | 477 | |
| 478 | void reboot_device(unsigned reboot_reason) |
| 479 | { |
Channagoud Kadabi | 8c8587f | 2013-02-08 12:46:09 -0800 | [diff] [blame] | 480 | uint32_t soc_ver = 0; |
Sundarajan Srinivasan | d00f31d | 2013-07-19 12:09:15 -0700 | [diff] [blame] | 481 | uint8_t reset_type = 0; |
Channagoud Kadabi | 8c8587f | 2013-02-08 12:46:09 -0800 | [diff] [blame] | 482 | |
| 483 | soc_ver = board_soc_version(); |
| 484 | |
Neeti Desai | 120b55d | 2012-08-20 17:15:56 -0700 | [diff] [blame] | 485 | /* Write the reboot reason */ |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 486 | if (platform_is_8974() && BOARD_SOC_VERSION1(soc_ver)) |
Channagoud Kadabi | 8c8587f | 2013-02-08 12:46:09 -0800 | [diff] [blame] | 487 | writel(reboot_reason, RESTART_REASON_ADDR); |
Channagoud Kadabi | c48b3e9 | 2013-06-23 16:19:10 -0700 | [diff] [blame] | 488 | else |
| 489 | writel(reboot_reason, RESTART_REASON_ADDR_V2); |
Neeti Desai | 120b55d | 2012-08-20 17:15:56 -0700 | [diff] [blame] | 490 | |
Sundarajan Srinivasan | d00f31d | 2013-07-19 12:09:15 -0700 | [diff] [blame] | 491 | if(reboot_reason == FASTBOOT_MODE) |
| 492 | reset_type = PON_PSHOLD_WARM_RESET; |
| 493 | else |
| 494 | reset_type = PON_PSHOLD_HARD_RESET; |
| 495 | |
Neeti Desai | 120b55d | 2012-08-20 17:15:56 -0700 | [diff] [blame] | 496 | /* Configure PMIC for warm reset */ |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 497 | if (platform_is_8974() && (pmic_ver == PM8X41_VERSION_V2)) |
Sundarajan Srinivasan | d00f31d | 2013-07-19 12:09:15 -0700 | [diff] [blame] | 498 | pm8x41_v2_reset_configure(reset_type); |
Deepa Dinamani | 07f1571 | 2013-03-08 17:02:13 -0800 | [diff] [blame] | 499 | else |
Sundarajan Srinivasan | d00f31d | 2013-07-19 12:09:15 -0700 | [diff] [blame] | 500 | pm8x41_reset_configure(reset_type); |
Neeti Desai | 120b55d | 2012-08-20 17:15:56 -0700 | [diff] [blame] | 501 | |
Deepa Dinamani | 1e09494 | 2012-10-30 15:49:02 -0700 | [diff] [blame] | 502 | /* Disable Watchdog Debug. |
| 503 | * Required becuase of a H/W bug which causes the system to |
| 504 | * reset partially even for non watchdog resets. |
| 505 | */ |
| 506 | writel(readl(GCC_WDOG_DEBUG) & ~(1 << WDOG_DEBUG_DISABLE_BIT), GCC_WDOG_DEBUG); |
| 507 | |
Deepa Dinamani | e0808e5 | 2012-11-26 15:22:46 -0800 | [diff] [blame] | 508 | dsb(); |
| 509 | |
| 510 | /* Wait until the write takes effect. */ |
| 511 | while(readl(GCC_WDOG_DEBUG) & (1 << WDOG_DEBUG_DISABLE_BIT)); |
| 512 | |
Neeti Desai | 120b55d | 2012-08-20 17:15:56 -0700 | [diff] [blame] | 513 | /* Drop PS_HOLD for MSM */ |
| 514 | writel(0x00, MPM2_MPM_PS_HOLD); |
| 515 | |
| 516 | mdelay(5000); |
| 517 | |
| 518 | dprintf(CRITICAL, "Rebooting failed\n"); |
| 519 | } |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 520 | |
Pavel Nedev | a4c9d3a | 2013-05-15 14:42:34 +0300 | [diff] [blame] | 521 | int set_download_mode(enum dload_mode mode) |
Pavel Nedev | 0351149 | 2013-03-08 19:05:32 -0800 | [diff] [blame] | 522 | { |
Pavel Nedev | a4c9d3a | 2013-05-15 14:42:34 +0300 | [diff] [blame] | 523 | dload_util_write_cookie(mode == NORMAL_DLOAD ? |
| 524 | DLOAD_MODE_ADDR_V2 : EMERGENCY_DLOAD_MODE_ADDR_V2, mode); |
Pavel Nedev | 0351149 | 2013-03-08 19:05:32 -0800 | [diff] [blame] | 525 | |
| 526 | return 0; |
| 527 | } |
| 528 | |
Channagoud Kadabi | 6d215b9 | 2013-06-23 16:47:07 -0700 | [diff] [blame] | 529 | /* Check if MSM needs VBUS mimic for USB */ |
| 530 | static int target_needs_vbus_mimic() |
| 531 | { |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 532 | if (platform_is_8974()) |
Channagoud Kadabi | 6d215b9 | 2013-06-23 16:47:07 -0700 | [diff] [blame] | 533 | return 0; |
| 534 | |
| 535 | return 1; |
| 536 | } |
| 537 | |
Eugene Yasman | a0d1812 | 2013-02-26 13:23:05 +0200 | [diff] [blame] | 538 | /* Do target specific usb initialization */ |
| 539 | void target_usb_init(void) |
| 540 | { |
Channagoud Kadabi | 6d215b9 | 2013-06-23 16:47:07 -0700 | [diff] [blame] | 541 | uint32_t val; |
| 542 | |
Eugene Yasman | a0d1812 | 2013-02-26 13:23:05 +0200 | [diff] [blame] | 543 | /* Enable secondary USB PHY on DragonBoard8074 */ |
| 544 | if (board_hardware_id() == HW_PLATFORM_DRAGON) { |
| 545 | /* Route ChipIDea to use secondary USB HS port2 */ |
| 546 | writel_relaxed(1, USB2_PHY_SEL); |
| 547 | |
| 548 | /* Enable access to secondary PHY by clamping the low |
| 549 | * voltage interface between DVDD of the PHY and Vddcx |
| 550 | * (set bit16 (USB2_PHY_HS2_DIG_CLAMP_N_2) = 1) */ |
| 551 | writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_SEC_CTRL) |
| 552 | | 0x00010000, USB_OTG_HS_PHY_SEC_CTRL); |
| 553 | |
| 554 | /* Perform power-on-reset of the PHY. |
| 555 | * Delay values are arbitrary */ |
| 556 | writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL)|1, |
| 557 | USB_OTG_HS_PHY_CTRL); |
| 558 | thread_sleep(10); |
| 559 | writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL) & 0xFFFFFFFE, |
| 560 | USB_OTG_HS_PHY_CTRL); |
| 561 | thread_sleep(10); |
| 562 | |
| 563 | /* Enable HSUSB PHY port for ULPI interface, |
| 564 | * then configure related parameters within the PHY */ |
| 565 | writel_relaxed(((readl_relaxed(USB_PORTSC) & 0xC0000000) |
| 566 | | 0x8c000004), USB_PORTSC); |
| 567 | } |
Channagoud Kadabi | 6d215b9 | 2013-06-23 16:47:07 -0700 | [diff] [blame] | 568 | |
| 569 | if (target_needs_vbus_mimic()) |
| 570 | { |
| 571 | /* Select and enable external configuration with USB PHY */ |
| 572 | ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET); |
| 573 | |
| 574 | /* Enable sess_vld */ |
| 575 | val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN; |
| 576 | writel(val, USB_GENCONFIG_2); |
| 577 | |
| 578 | /* Enable external vbus configuration in the LINK */ |
| 579 | val = readl(USB_USBCMD); |
| 580 | val |= SESS_VLD_CTRL; |
| 581 | writel(val, USB_USBCMD); |
| 582 | } |
Eugene Yasman | a0d1812 | 2013-02-26 13:23:05 +0200 | [diff] [blame] | 583 | } |
| 584 | |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 585 | /* Returns 1 if target supports continuous splash screen. */ |
| 586 | int target_cont_splash_screen() |
| 587 | { |
Siddhartha Agrawal | 17a6b83 | 2013-02-17 18:36:25 -0800 | [diff] [blame] | 588 | switch(board_hardware_id()) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 589 | { |
Siddhartha Agrawal | 17a6b83 | 2013-02-17 18:36:25 -0800 | [diff] [blame] | 590 | case HW_PLATFORM_SURF: |
| 591 | case HW_PLATFORM_MTP: |
| 592 | case HW_PLATFORM_FLUID: |
Asaf Penso | b85263f | 2013-05-01 10:54:34 +0300 | [diff] [blame] | 593 | case HW_PLATFORM_DRAGON: |
Kuogee Hsieh | df636eb | 2013-08-01 14:52:08 -0700 | [diff] [blame] | 594 | case HW_PLATFORM_LIQUID: |
Siddhartha Agrawal | 17a6b83 | 2013-02-17 18:36:25 -0800 | [diff] [blame] | 595 | dprintf(SPEW, "Target_cont_splash=1\n"); |
| 596 | return 1; |
| 597 | break; |
| 598 | default: |
| 599 | dprintf(SPEW, "Target_cont_splash=0\n"); |
| 600 | return 0; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 601 | } |
| 602 | } |
sundarajan srinivasan | b5db0a9 | 2013-02-12 19:19:27 -0800 | [diff] [blame] | 603 | |
| 604 | unsigned target_pause_for_battery_charge(void) |
| 605 | { |
| 606 | uint8_t pon_reason = pm8x41_get_pon_reason(); |
| 607 | |
| 608 | /* This function will always return 0 to facilitate |
| 609 | * automated testing/reboot with usb connected. |
| 610 | * uncomment if this feature is needed */ |
| 611 | /* if ((pon_reason == USB_CHG) || (pon_reason == DC_CHG)) |
| 612 | return 1;*/ |
| 613 | |
| 614 | return 0; |
| 615 | } |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 616 | |
Channagoud Kadabi | 9faa45b | 2013-06-18 18:33:02 -0700 | [diff] [blame] | 617 | void target_uninit(void) |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 618 | { |
Channagoud Kadabi | 9faa45b | 2013-06-18 18:33:02 -0700 | [diff] [blame] | 619 | #if MMC_SDHCI_SUPPORT |
| 620 | mmc_put_card_to_sleep(dev); |
| 621 | #else |
| 622 | mmc_put_card_to_sleep(); |
| 623 | #endif |
sundarajan srinivasan | a098d83 | 2013-03-07 12:19:30 -0800 | [diff] [blame] | 624 | #ifdef SSD_ENABLE |
| 625 | clock_ce_disable(SSD_CE_INSTANCE_1); |
| 626 | #endif |
| 627 | } |
Deepa Dinamani | 65df982 | 2013-03-08 13:38:34 -0800 | [diff] [blame] | 628 | |
| 629 | void shutdown_device() |
| 630 | { |
| 631 | dprintf(CRITICAL, "Going down for shutdown.\n"); |
| 632 | |
| 633 | /* Configure PMIC for shutdown. */ |
Channagoud Kadabi | 0de103c | 2013-09-26 10:44:57 -0700 | [diff] [blame] | 634 | if (platform_is_8974() && (pmic_ver == PM8X41_VERSION_V2)) |
Deepa Dinamani | 65df982 | 2013-03-08 13:38:34 -0800 | [diff] [blame] | 635 | pm8x41_v2_reset_configure(PON_PSHOLD_SHUTDOWN); |
| 636 | else |
| 637 | pm8x41_reset_configure(PON_PSHOLD_SHUTDOWN); |
| 638 | |
| 639 | /* Drop PS_HOLD for MSM */ |
| 640 | writel(0x00, MPM2_MPM_PS_HOLD); |
| 641 | |
| 642 | mdelay(5000); |
| 643 | |
| 644 | dprintf(CRITICAL, "Shutdown failed\n"); |
Channagoud Kadabi | 744c890 | 2013-04-02 11:54:53 -0700 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | static void set_sdc_power_ctrl() |
| 648 | { |
Channagoud Kadabi | 224d832 | 2013-09-27 14:25:22 -0700 | [diff] [blame] | 649 | uint8_t tlmm_hdrv_clk = 0; |
| 650 | uint32_t platform_id = 0; |
| 651 | |
| 652 | platform_id = board_platform_id(); |
| 653 | |
| 654 | switch(platform_id) |
| 655 | { |
| 656 | case MSM8274AA: |
| 657 | case MSM8274AB: |
| 658 | case MSM8674AA: |
| 659 | case MSM8674AB: |
| 660 | case MSM8974AA: |
| 661 | case MSM8974AB: |
| 662 | if (board_hardware_id() == HW_PLATFORM_MTP) |
| 663 | tlmm_hdrv_clk = TLMM_CUR_VAL_10MA; |
| 664 | else |
| 665 | tlmm_hdrv_clk = TLMM_CUR_VAL_16MA; |
| 666 | break; |
| 667 | default: |
| 668 | tlmm_hdrv_clk = TLMM_CUR_VAL_16MA; |
| 669 | }; |
| 670 | |
Channagoud Kadabi | 744c890 | 2013-04-02 11:54:53 -0700 | [diff] [blame] | 671 | /* Drive strength configs for sdc pins */ |
| 672 | struct tlmm_cfgs sdc1_hdrv_cfg[] = |
| 673 | { |
Channagoud Kadabi | 224d832 | 2013-09-27 14:25:22 -0700 | [diff] [blame] | 674 | { SDC1_CLK_HDRV_CTL_OFF, tlmm_hdrv_clk, TLMM_HDRV_MASK }, |
Channagoud Kadabi | 744c890 | 2013-04-02 11:54:53 -0700 | [diff] [blame] | 675 | { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK }, |
| 676 | { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK }, |
| 677 | }; |
| 678 | |
| 679 | /* Pull configs for sdc pins */ |
| 680 | struct tlmm_cfgs sdc1_pull_cfg[] = |
| 681 | { |
| 682 | { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK }, |
| 683 | { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK }, |
| 684 | { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK }, |
| 685 | }; |
| 686 | |
| 687 | /* Set the drive strength & pull control values */ |
| 688 | tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); |
| 689 | tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); |
| 690 | } |
Stanimir Varbanov | f64a029 | 2013-04-29 11:58:27 +0300 | [diff] [blame] | 691 | |
| 692 | int emmc_recovery_init(void) |
| 693 | { |
| 694 | return _emmc_recovery_init(); |
| 695 | } |
Channagoud Kadabi | 6d215b9 | 2013-06-23 16:47:07 -0700 | [diff] [blame] | 696 | |
| 697 | void target_usb_stop(void) |
| 698 | { |
| 699 | uint32_t platform = board_platform_id(); |
| 700 | |
| 701 | /* Disable VBUS mimicing in the controller. */ |
| 702 | if (target_needs_vbus_mimic()) |
| 703 | ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR); |
| 704 | } |
Amol Jadi | 4c3229f | 2013-10-07 14:38:06 -0700 | [diff] [blame] | 705 | |
| 706 | /* identify the usb controller to be used for the target */ |
| 707 | const char * target_usb_controller() |
| 708 | { |
| 709 | switch(board_platform_id()) |
| 710 | { |
| 711 | /* use dwc controller for PRO chips (with some exceptions) */ |
| 712 | case MSM8974AA: |
| 713 | case MSM8974AB: |
| 714 | case MSM8974AC: |
| 715 | /* exceptions based on hardware id */ |
| 716 | if (board_hardware_id() != HW_PLATFORM_DRAGON) |
| 717 | return "dwc"; |
| 718 | /* fall through to default "ci" for anything that did'nt select "dwc" */ |
| 719 | default: |
| 720 | return "ci"; |
| 721 | } |
| 722 | } |