Smita Ghosh | 50a53ac | 2015-02-11 12:33:30 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [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 <board.h> |
| 31 | #include <platform.h> |
| 32 | #include <target.h> |
| 33 | #include <smem.h> |
| 34 | #include <baseband.h> |
| 35 | #include <lib/ptable.h> |
| 36 | #include <qpic_nand.h> |
Sridhar Parasuram | dbe91a4 | 2014-12-29 13:45:30 -0800 | [diff] [blame] | 37 | #include <malloc.h> |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 38 | #include <ctype.h> |
| 39 | #include <string.h> |
| 40 | #include <pm8x41.h> |
| 41 | #include <reg.h> |
| 42 | #include <hsusb.h> |
| 43 | #include <mmc.h> |
| 44 | #include <platform/timer.h> |
| 45 | #include <platform/irqs.h> |
| 46 | #include <platform/gpio.h> |
| 47 | #include <platform/clock.h> |
| 48 | #include <qmp_phy.h> |
Joonwoo Park | 39aed06 | 2014-06-09 17:00:07 -0700 | [diff] [blame] | 49 | #include <qusb2_phy.h> |
anisha agarwal | ffb78ab | 2014-11-18 15:20:31 -0800 | [diff] [blame] | 50 | #include <rpm-smd.h> |
| 51 | #include <scm.h> |
Sridhar Parasuram | dbe91a4 | 2014-12-29 13:45:30 -0800 | [diff] [blame] | 52 | #include <spmi.h> |
| 53 | #include <partition_parser.h> |
| 54 | #include <sdhci_msm.h> |
| 55 | #include <uart_dm.h> |
| 56 | #include <boot_device.h> |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 57 | #include <qmp_phy.h> |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 58 | |
| 59 | extern void smem_ptable_init(void); |
| 60 | extern void smem_add_modem_partitions(struct ptable *flash_ptable); |
| 61 | void target_sdc_init(); |
| 62 | |
| 63 | static struct ptable flash_ptable; |
| 64 | |
| 65 | /* PMIC config data */ |
| 66 | #define PMIC_ARB_CHANNEL_NUM 0 |
| 67 | #define PMIC_ARB_OWNER_ID 0 |
| 68 | |
| 69 | /* NANDc BAM pipe numbers */ |
| 70 | #define DATA_CONSUMER_PIPE 0 |
| 71 | #define DATA_PRODUCER_PIPE 1 |
| 72 | #define CMD_PIPE 2 |
| 73 | |
| 74 | /* NANDc BAM pipe groups */ |
| 75 | #define DATA_PRODUCER_PIPE_GRP 0 |
| 76 | #define DATA_CONSUMER_PIPE_GRP 0 |
| 77 | #define CMD_PIPE_GRP 1 |
| 78 | |
| 79 | /* NANDc EE */ |
| 80 | #define QPIC_NAND_EE 0 |
| 81 | |
| 82 | /* NANDc max desc length. */ |
| 83 | #define QPIC_NAND_MAX_DESC_LEN 0x7FFF |
| 84 | |
| 85 | #define LAST_NAND_PTN_LEN_PATTERN 0xFFFFFFFF |
| 86 | |
Smita Ghosh | 50a53ac | 2015-02-11 12:33:30 -0800 | [diff] [blame] | 87 | #define EXT4_CMDLINE " rootwait rootfstype=ext4 root=/dev/mmcblk0p" |
anisha agarwal | 11df23e | 2015-06-12 14:37:34 -0700 | [diff] [blame] | 88 | #define UBI_CMDLINE " rootfstype=ubifs rootflags=bulk_read" |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 89 | |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 90 | struct qpic_nand_init_config config; |
| 91 | |
| 92 | void update_ptable_names(void) |
| 93 | { |
| 94 | uint32_t ptn_index; |
| 95 | struct ptentry *ptentry_ptr = flash_ptable.parts; |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 96 | unsigned i; |
| 97 | uint32_t len; |
| 98 | |
| 99 | /* Change all names to lower case. */ |
| 100 | for (ptn_index = 0; ptn_index != (uint32_t)flash_ptable.count; ptn_index++) |
| 101 | { |
| 102 | len = strlen(ptentry_ptr[ptn_index].name); |
| 103 | |
| 104 | for (i = 0; i < len; i++) |
| 105 | { |
| 106 | if (isupper(ptentry_ptr[ptn_index].name[i])) |
| 107 | { |
| 108 | ptentry_ptr[ptn_index].name[i] = tolower(ptentry_ptr[ptn_index].name[i]); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | /* SBL fills in the last partition length as 0xFFFFFFFF. |
| 113 | * Update the length field based on the number of blocks on the flash. |
| 114 | */ |
| 115 | if ((uint32_t)(ptentry_ptr[ptn_index].length) == LAST_NAND_PTN_LEN_PATTERN) |
| 116 | { |
| 117 | ptentry_ptr[ptn_index].length = flash_num_blocks() - ptentry_ptr[ptn_index].start; |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | void target_early_init(void) |
| 123 | { |
| 124 | #if WITH_DEBUG_UART |
Channagoud Kadabi | 1b69e48 | 2014-09-23 15:20:22 -0700 | [diff] [blame] | 125 | uart_dm_init(3, 0, BLSP1_UART2_BASE); |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 126 | #endif |
| 127 | } |
| 128 | |
| 129 | int target_is_emmc_boot(void) |
| 130 | { |
| 131 | return platform_boot_dev_isemmc(); |
| 132 | } |
| 133 | |
| 134 | /* init */ |
| 135 | void target_init(void) |
| 136 | { |
| 137 | dprintf(INFO, "target_init()\n"); |
| 138 | |
Sridhar Parasuram | 9ed91f3 | 2015-07-07 15:37:44 -0700 | [diff] [blame] | 139 | pmic_info_populate(); |
| 140 | |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 141 | spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID); |
| 142 | |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 143 | if (platform_boot_dev_isemmc()) { |
| 144 | target_sdc_init(); |
| 145 | if (partition_read_table()) { |
| 146 | dprintf(CRITICAL, "Error reading the partition table info\n"); |
| 147 | ASSERT(0); |
| 148 | } |
anisha agarwal | 70b8cd1 | 2015-02-02 11:44:46 -0800 | [diff] [blame] | 149 | /* Below setting is to enable EBI2 function selection in TLMM so |
| 150 | that GPIOs can be used for display */ |
| 151 | writel((readl(TLMM_EBI2_EMMC_GPIO_CFG) | EBI2_BOOT_SELECT), TLMM_EBI2_EMMC_GPIO_CFG); |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 152 | } else { |
| 153 | config.pipes.read_pipe = DATA_PRODUCER_PIPE; |
| 154 | config.pipes.write_pipe = DATA_CONSUMER_PIPE; |
| 155 | config.pipes.cmd_pipe = CMD_PIPE; |
| 156 | |
| 157 | config.pipes.read_pipe_grp = DATA_PRODUCER_PIPE_GRP; |
| 158 | config.pipes.write_pipe_grp = DATA_CONSUMER_PIPE_GRP; |
| 159 | config.pipes.cmd_pipe_grp = CMD_PIPE_GRP; |
| 160 | |
| 161 | config.bam_base = MSM_NAND_BAM_BASE; |
| 162 | config.nand_base = MSM_NAND_BASE; |
| 163 | config.ee = QPIC_NAND_EE; |
| 164 | config.max_desc_len = QPIC_NAND_MAX_DESC_LEN; |
| 165 | |
| 166 | qpic_nand_init(&config); |
| 167 | |
| 168 | ptable_init(&flash_ptable); |
| 169 | smem_ptable_init(); |
| 170 | smem_add_modem_partitions(&flash_ptable); |
| 171 | |
| 172 | update_ptable_names(); |
| 173 | flash_set_ptable(&flash_ptable); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /* reboot */ |
| 178 | void reboot_device(unsigned reboot_reason) |
| 179 | { |
| 180 | /* Write the reboot reason */ |
| 181 | writel(reboot_reason, RESTART_REASON_ADDR); |
| 182 | |
| 183 | /* Configure PMIC for warm reset */ |
| 184 | /* PM 8019 v1 aligns with PM8941 v2. |
| 185 | * This call should be based on the pmic version |
| 186 | * when PM8019 v2 is available. |
| 187 | */ |
Channagoud Kadabi | a85ed6e | 2015-03-23 14:35:16 -0700 | [diff] [blame] | 188 | if (reboot_reason) |
| 189 | pm8x41_v2_reset_configure(PON_PSHOLD_WARM_RESET); |
| 190 | else |
| 191 | pm8x41_v2_reset_configure(PON_PSHOLD_HARD_RESET); |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 192 | |
| 193 | /* Drop PS_HOLD for MSM */ |
| 194 | writel(0x00, MPM2_MPM_PS_HOLD); |
| 195 | |
| 196 | mdelay(5000); |
| 197 | |
| 198 | dprintf(CRITICAL, "Rebooting failed\n"); |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | /* Identify the current target */ |
| 203 | void target_detect(struct board_data *board) |
| 204 | { |
| 205 | /* This property is filled as part of board.c */ |
| 206 | } |
| 207 | |
| 208 | unsigned board_machtype(void) |
| 209 | { |
| 210 | return LINUX_MACHTYPE_UNKNOWN; |
| 211 | } |
| 212 | |
| 213 | /* Identify the baseband being used */ |
| 214 | void target_baseband_detect(struct board_data *board) |
| 215 | { |
| 216 | board->baseband = BASEBAND_MSM; |
| 217 | } |
| 218 | |
Sridhar Parasuram | 1d8c422 | 2014-10-22 13:43:00 -0700 | [diff] [blame] | 219 | void target_serialno(unsigned char *buf) |
| 220 | { |
| 221 | uint32_t serialno; |
| 222 | serialno = board_chip_serial(); |
| 223 | snprintf((char *)buf, 13, "%x", serialno); |
| 224 | } |
| 225 | |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 226 | unsigned check_reboot_mode(void) |
| 227 | { |
| 228 | unsigned restart_reason = 0; |
| 229 | |
| 230 | /* Read reboot reason and scrub it */ |
| 231 | restart_reason = readl(RESTART_REASON_ADDR); |
| 232 | |
| 233 | writel(0x00, RESTART_REASON_ADDR); |
| 234 | |
| 235 | return restart_reason; |
| 236 | } |
| 237 | |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 238 | int get_target_boot_params(const char *cmdline, const char *part, char **buf) |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 239 | { |
| 240 | struct ptable *ptable; |
| 241 | int system_ptn_index = -1; |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 242 | uint32_t buflen; |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 243 | int ret = -1; |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 244 | |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 245 | if (!cmdline || !part ) { |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 246 | dprintf(CRITICAL, "WARN: Invalid input param\n"); |
| 247 | return -1; |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 248 | } |
| 249 | |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 250 | if (!strstr(cmdline, "root=/dev/ram")) /* This check is to handle kdev boot */ |
| 251 | { |
| 252 | if (!target_is_emmc_boot()) { |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 253 | |
| 254 | buflen = strlen(UBI_CMDLINE) + strlen(" root=ubi0:rootfs ubi.mtd=") + sizeof(int) + 1; |
| 255 | *buf = (char *)malloc(buflen); |
| 256 | if(!(*buf)) { |
| 257 | dprintf(CRITICAL,"Unable to allocate memory for boot params\n"); |
| 258 | return -1; |
| 259 | } |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 260 | /* Below is for NAND boot */ |
| 261 | ptable = flash_get_ptable(); |
| 262 | if (!ptable) { |
| 263 | dprintf(CRITICAL, |
| 264 | "WARN: Cannot get flash partition table\n"); |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 265 | free(*buf); |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 266 | return -1; |
| 267 | } |
| 268 | |
| 269 | system_ptn_index = ptable_get_index(ptable, part); |
| 270 | if (system_ptn_index < 0) { |
| 271 | dprintf(CRITICAL, |
| 272 | "WARN: Cannot get partition index for %s\n", part); |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 273 | free(*buf); |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 274 | return -1; |
| 275 | } |
| 276 | /* Adding command line parameters according to target boot type */ |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 277 | snprintf(*buf, buflen, UBI_CMDLINE); |
| 278 | snprintf(*buf+strlen(*buf), buflen, " root=ubi0:rootfs ubi.mtd=%d", system_ptn_index); |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 279 | ret = 0; |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 280 | } |
| 281 | else { |
Channagoud Kadabi | 9d9b521 | 2015-10-20 17:29:50 -0700 | [diff] [blame] | 282 | buflen = strlen(EXT4_CMDLINE) + sizeof(int) +1; |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 283 | *buf = (char *)malloc(buflen); |
| 284 | if(!(*buf)) { |
| 285 | dprintf(CRITICAL,"Unable to allocate memory for boot params\n"); |
| 286 | return -1; |
| 287 | } |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 288 | /* Below is for emmc boot */ |
anisha agarwal | c49a325 | 2014-10-15 17:37:40 -0700 | [diff] [blame] | 289 | system_ptn_index = partition_get_index(part) + 1; /* Adding +1 as offsets for eMMC start at 1 and NAND at 0 */ |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 290 | if (system_ptn_index < 0) { |
| 291 | dprintf(CRITICAL, |
| 292 | "WARN: Cannot get partition index for %s\n", part); |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 293 | free(*buf); |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 294 | return -1; |
| 295 | } |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 296 | snprintf(*buf, buflen, EXT4_CMDLINE"%d", system_ptn_index); |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 297 | ret = 0; |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 298 | } |
anisha agarwal | ce363dd | 2014-08-26 15:17:09 -0700 | [diff] [blame] | 299 | } |
vijay kumar | ff36c31 | 2015-08-31 17:12:33 +0530 | [diff] [blame] | 300 | /*in success case buf will be freed in the calling function of this*/ |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 301 | return ret; |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | const char * target_usb_controller() |
| 305 | { |
| 306 | return "dwc"; |
| 307 | } |
| 308 | |
| 309 | static void set_sdc_power_ctrl() |
| 310 | { |
| 311 | /* Drive strength configs for sdc pins */ |
| 312 | struct tlmm_cfgs sdc1_hdrv_cfg[] = |
| 313 | { |
Sridhar Parasuram | dbe91a4 | 2014-12-29 13:45:30 -0800 | [diff] [blame] | 314 | { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0 }, |
| 315 | { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0 }, |
| 316 | { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_6MA, TLMM_HDRV_MASK, 0 }, |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 317 | }; |
| 318 | |
| 319 | /* Pull configs for sdc pins */ |
| 320 | struct tlmm_cfgs sdc1_pull_cfg[] = |
| 321 | { |
Sridhar Parasuram | dbe91a4 | 2014-12-29 13:45:30 -0800 | [diff] [blame] | 322 | { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, 0 }, |
| 323 | { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 }, |
| 324 | { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0 }, |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | /* Set the drive strength & pull control values */ |
| 328 | tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); |
| 329 | tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); |
| 330 | } |
| 331 | |
| 332 | static struct mmc_device *dev; |
| 333 | |
| 334 | void *target_mmc_device() |
| 335 | { |
| 336 | return (void *) dev; |
| 337 | } |
| 338 | |
| 339 | void target_sdc_init() |
| 340 | { |
| 341 | struct mmc_config_data config; |
| 342 | |
| 343 | /* Set drive strength & pull ctrl values */ |
| 344 | set_sdc_power_ctrl(); |
| 345 | |
| 346 | config.slot = 1; |
Channagoud Kadabi | de17ba8 | 2014-11-12 13:05:57 -0800 | [diff] [blame] | 347 | config.bus_width = DATA_BUS_WIDTH_8BIT; |
Channagoud Kadabi | 6608d02 | 2015-04-20 11:31:56 -0700 | [diff] [blame] | 348 | config.max_clk_rate = MMC_CLK_171MHZ; |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 349 | config.sdhc_base = MSM_SDC1_SDHCI_BASE; |
| 350 | config.pwrctl_base = MSM_SDC1_BASE; |
| 351 | config.pwr_irq = SDCC1_PWRCTL_IRQ; |
| 352 | config.hs400_support = 0; |
Channagoud Kadabi | de17ba8 | 2014-11-12 13:05:57 -0800 | [diff] [blame] | 353 | config.hs200_support = 0; |
Channagoud Kadabi | d23379d | 2014-10-13 11:33:50 -0700 | [diff] [blame] | 354 | config.use_io_switch = 1; |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 355 | |
| 356 | if (!(dev = mmc_init(&config))) { |
| 357 | dprintf(CRITICAL, "mmc init failed!"); |
| 358 | ASSERT(0); |
| 359 | } |
| 360 | } |
| 361 | |
anisha agarwal | 0fc661d | 2014-11-26 11:54:32 -0800 | [diff] [blame] | 362 | int target_cont_splash_screen() |
| 363 | { |
| 364 | /* FOR OEMs - Set cont_splash_screen to keep the splash enable after LK.*/ |
anisha agarwal | 58d25cf | 2014-11-26 12:09:23 -0800 | [diff] [blame] | 365 | return false; |
anisha agarwal | 0fc661d | 2014-11-26 11:54:32 -0800 | [diff] [blame] | 366 | } |
| 367 | |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 368 | void target_uninit(void) |
| 369 | { |
| 370 | if (platform_boot_dev_isemmc()) |
| 371 | { |
| 372 | mmc_put_card_to_sleep(dev); |
| 373 | sdhci_mode_disable(&dev->host); |
| 374 | } |
| 375 | } |
| 376 | |
Joonwoo Park | 39aed06 | 2014-06-09 17:00:07 -0700 | [diff] [blame] | 377 | void target_usb_phy_reset(void) |
| 378 | { |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 379 | /* Reset sequence for californium is different from 9x40, use the reset sequence |
| 380 | * from clock driver |
| 381 | */ |
| 382 | if (platform_is_mdmcalifornium()) |
| 383 | clock_reset_usb_phy(); |
| 384 | else |
| 385 | usb30_qmp_phy_reset(); |
| 386 | |
Channagoud Kadabi | 1b69e48 | 2014-09-23 15:20:22 -0700 | [diff] [blame] | 387 | qusb2_phy_reset(); |
Joonwoo Park | 39aed06 | 2014-06-09 17:00:07 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 390 | target_usb_iface_t* target_usb30_init() |
| 391 | { |
| 392 | target_usb_iface_t *t_usb_iface; |
| 393 | |
Sridhar Parasuram | dbe91a4 | 2014-12-29 13:45:30 -0800 | [diff] [blame] | 394 | t_usb_iface = (target_usb_iface_t *) calloc(1, sizeof(target_usb_iface_t)); |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 395 | ASSERT(t_usb_iface); |
| 396 | |
| 397 | t_usb_iface->mux_config = NULL; |
| 398 | t_usb_iface->phy_init = usb30_qmp_phy_init; |
Joonwoo Park | 39aed06 | 2014-06-09 17:00:07 -0700 | [diff] [blame] | 399 | t_usb_iface->phy_reset = target_usb_phy_reset; |
Joonwoo Park | e586c2e | 2014-04-02 11:04:10 -0700 | [diff] [blame] | 400 | t_usb_iface->clock_init = clock_usb30_init; |
| 401 | t_usb_iface->vbus_override = 1; |
| 402 | |
| 403 | return t_usb_iface; |
| 404 | } |
Channagoud Kadabi | 1b69e48 | 2014-09-23 15:20:22 -0700 | [diff] [blame] | 405 | |
| 406 | uint32_t target_override_pll() |
| 407 | { |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 408 | if (platform_is_mdmcalifornium()) |
| 409 | return 0; |
| 410 | else |
| 411 | return 1; |
Channagoud Kadabi | 1b69e48 | 2014-09-23 15:20:22 -0700 | [diff] [blame] | 412 | } |
Channagoud Kadabi | d23379d | 2014-10-13 11:33:50 -0700 | [diff] [blame] | 413 | |
| 414 | uint32_t target_get_hlos_subtype() |
| 415 | { |
| 416 | return board_hlos_subtype(); |
| 417 | } |
Channagoud Kadabi | fdfee23 | 2015-10-07 11:55:47 -0700 | [diff] [blame] | 418 | |
| 419 | /* QMP settings are different from californium when compared to v2.0/v1.0 hardware. |
| 420 | * Use the QMP settings from target code to keep the common driver clean |
| 421 | */ |
| 422 | struct qmp_reg qmp_settings[] = |
| 423 | { |
| 424 | {0x804, 0x01}, /*USB3PHY_PCIE_USB3_PCS_POWER_DOWN_CONTROL */ |
| 425 | {0xAC, 0x14}, /* QSERDES_COM_SYSCLK_EN_SEL */ |
| 426 | {0x34, 0x08}, /* QSERDES_COM_BIAS_EN_CLKBUFLR_EN */ |
| 427 | {0x174, 0x30}, /* QSERDES_COM_CLK_SELECT */ |
| 428 | {0x3C, 0x06}, /* QSERDES_COM_SYS_CLK_CTRL */ |
| 429 | {0xB4, 0x00}, /* QSERDES_COM_RESETSM_CNTRL */ |
| 430 | {0xB8, 0x08}, /* QSERDES_COM_RESETSM_CNTRL2 */ |
| 431 | {0x194, 0x06}, /* QSERDES_COM_CMN_CONFIG */ |
| 432 | {0x19c, 0x01}, /* QSERDES_COM_SVS_MODE_CLK_SEL */ |
| 433 | {0x178, 0x00}, /* QSERDES_COM_HSCLK_SEL */ |
| 434 | {0xd0, 0x82}, /* QSERDES_COM_DEC_START_MODE0 */ |
| 435 | {0xdc, 0x55}, /* QSERDES_COM_DIV_FRAC_START1_MODE0 */ |
| 436 | {0xe0, 0x55}, /* QSERDES_COM_DIV_FRAC_START2_MODE0 */ |
| 437 | {0xe4, 0x03}, /* QSERDES_COM_DIV_FRAC_START3_MODE0 */ |
| 438 | {0x78, 0x0b}, /* QSERDES_COM_CP_CTRL_MODE0 */ |
| 439 | {0x84, 0x16}, /* QSERDES_COM_PLL_RCTRL_MODE0 */ |
| 440 | {0x90, 0x28}, /* QSERDES_COM_PLL_CCTRL_MODE0 */ |
| 441 | {0x108, 0x80}, /* QSERDES_COM_INTEGLOOP_GAIN0_MODE0 */ |
| 442 | {0x10C, 0x00}, /* QSERDES_COM_INTEGLOOP_GAIN1_MODE0 */ |
| 443 | {0x184, 0x0A}, /* QSERDES_COM_CORECLK_DIV */ |
| 444 | {0x4c, 0x15}, /* QSERDES_COM_LOCK_CMP1_MODE0 */ |
| 445 | {0x50, 0x34}, /* QSERDES_COM_LOCK_CMP2_MODE0 */ |
| 446 | {0x54, 0x00}, /* QSERDES_COM_LOCK_CMP3_MODE0 */ |
| 447 | {0xC8, 0x00}, /* QSERDES_COM_LOCK_CMP_EN */ |
| 448 | {0x18c, 0x00}, /* QSERDES_COM_CORE_CLK_EN */ |
| 449 | {0xcc, 0x00}, /* QSERDES_COM_LOCK_CMP_CFG */ |
| 450 | {0x128, 0x00}, /* QSERDES_COM_VCO_TUNE_MAP */ |
| 451 | {0x0C, 0x0A}, /* QSERDES_COM_BG_TIMER */ |
| 452 | {0x10, 0x01}, /* QSERDES_COM_SSC_EN_CENTER */ |
| 453 | {0x1c, 0x31}, /* QSERDES_COM_SSC_PER1 */ |
| 454 | {0x20, 0x01}, /* QSERDES_COM_SSC_PER2 */ |
| 455 | {0x14, 0x00}, /* QSERDES_COM_SSC_ADJ_PER1 */ |
| 456 | {0x18, 0x00}, /* QSERDES_COM_SSC_ADJ_PER2 */ |
| 457 | {0x24, 0xde}, /* QSERDES_COM_SSC_STEP_SIZE1 */ |
| 458 | {0x28, 0x07}, /* QSERDES_COM_SSC_STEP_SIZE2 */ |
| 459 | {0x48, 0x0F}, /* USB3PHY_QSERDES_COM_PLL_IVCO */ |
| 460 | {0x70, 0x0F}, /* USB3PHY_QSERDES_COM_BG_TRIM */ |
| 461 | {0x100, 0x80}, /* QSERDES_COM_INTEGLOOP_INITVAL */ |
| 462 | |
| 463 | /* Rx Settings */ |
| 464 | {0x440, 0x0b}, /* QSERDES_RX_UCDR_FASTLOCK_FO_GAIN */ |
| 465 | {0x4d8, 0x02}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2 */ |
| 466 | {0x4dc, 0x6c}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL3 */ |
| 467 | {0x4e0, 0xbb}, /* QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4 */ |
| 468 | {0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */ |
| 469 | {0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */ |
| 470 | {0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */ |
| 471 | {0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */ |
| 472 | {0x448, 0x75}, /* QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE */ |
| 473 | {0x450, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_LOW */ |
| 474 | {0x454, 0x00}, /* QSERDES_RX_UCDR_FASTLOCK_COUNT_HIGH */ |
| 475 | {0x40C, 0x0a}, /* QSERDES_RX_UCDR_FO_GAIN */ |
| 476 | {0x41C, 0x06}, /* QSERDES_RX_UCDR_SO_GAIN */ |
| 477 | {0x510, 0x00}, /*QSERDES_RX_SIGDET_ENABLES */ |
| 478 | |
| 479 | /* Tx settings */ |
| 480 | {0x268, 0x45}, /* QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN */ |
| 481 | {0x2ac, 0x12}, /* QSERDES_TX_RCV_DETECT_LVL_2 */ |
| 482 | {0x294, 0x06}, /* QSERDES_TX_LANE_MODE */ |
| 483 | {0x254, 0x00}, /* QSERDES_TX_RES_CODE_LANE_OFFSET */ |
| 484 | |
| 485 | /* FLL settings */ |
| 486 | {0x8c8, 0x83}, /* PCIE_USB3_PCS_FLL_CNTRL2 */ |
| 487 | {0x8c4, 0x02}, /* PCIE_USB3_PCS_FLL_CNTRL1 */ |
| 488 | {0x8cc, 0x09}, /* PCIE_USB3_PCS_FLL_CNT_VAL_L */ |
| 489 | {0x8D0, 0xA2}, /* PCIE_USB3_PCS_FLL_CNT_VAL_H_TOL */ |
| 490 | {0x8D4, 0x85}, /* PCIE_USB3_PCS_FLL_MAN_CODE */ |
| 491 | |
| 492 | /* PCS Settings */ |
| 493 | {0x880, 0xD1}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG1 */ |
| 494 | {0x884, 0x1F}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG2 */ |
| 495 | {0x888, 0x47}, /* PCIE_USB3_PCS_LOCK_DETECT_CONFIG3 */ |
| 496 | {0x80C, 0x9F}, /* PCIE_USB3_PCS_TXMGN_V0 */ |
| 497 | {0x824, 0x17}, /* PCIE_USB3_PCS_TXDEEMPH_M6DB_V0 */ |
| 498 | {0x828, 0x0F}, /* PCIE_USB3_PCS_TXDEEMPH_M3P5DB_V0 */ |
| 499 | {0x8B8, 0x75}, /* PCIE_USB3_PCS_RXEQTRAINING_WAIT_TIME */ |
| 500 | {0x8BC, 0x13}, /* PCIE_USB3_PCS_RXEQTRAINING_RUN_TIME */ |
| 501 | {0x8B0, 0x86}, /* PCIE_USB3_PCS_LFPS_TX_ECSTART_EQTLOCK */ |
| 502 | {0x8A0, 0x04}, /* PCIE_USB3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK */ |
| 503 | {0x88C, 0x44}, /* PCIE_USB3_PCS_TSYNC_RSYNC_TIME */ |
| 504 | {0x870, 0xE7}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_L */ |
| 505 | {0x874, 0x03}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_P1U2_H */ |
| 506 | {0x878, 0x40}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_L */ |
| 507 | {0x87c, 0x00}, /* PCIE_USB3_PCS_RCVR_DTCT_DLY_U3_H */ |
| 508 | {0x9D8, 0x88}, /* PCIE_USB3_PCS_RX_SIGDET_LVL */ |
| 509 | {0x808, 0x03}, /* PCIE_USB3_PCS_START_CONTROL */ |
| 510 | {0x800, 0x00}, /* PCIE_USB3_PCS_SW_RESET */ |
| 511 | }; |
| 512 | |
| 513 | struct qmp_reg *target_get_qmp_settings() |
| 514 | { |
| 515 | if (platform_is_mdmcalifornium()) |
| 516 | return qmp_settings; |
| 517 | else |
| 518 | return NULL; |
| 519 | } |
| 520 | |
| 521 | int target_get_qmp_regsize() |
| 522 | { |
| 523 | if (platform_is_mdmcalifornium()) |
| 524 | return ARRAY_SIZE(qmp_settings); |
| 525 | else |
| 526 | return 0; |
| 527 | } |