static uint32_t dev_tree_compatible(void *dtb) { int root_offset; const void *prop; char model[128]; struct msm_id msm_id; int len; root_offset = fdt_path_offset(dtb, "/"); if (root_offset < 0) return false; prop = fdt_getprop(dtb, root_offset, "model", &len); if (prop && len > 0) { memcpy(model, prop, MIN((int)sizeof(model), len)); model[sizeof(model) - 1] = '\0'; } else { model[0] = '\0'; } prop = fdt_getprop(dtb, root_offset, "qcom,msm-id", &len); if (!prop || len <= 0) { dprintf(INFO, "qcom,msm-id entry not found\n"); return false; } else if (len < (int)sizeof(struct msm_id)) { dprintf(INFO, "qcom,msm-id entry size mismatch (%d != %d)\n", len, sizeof(struct msm_id)); return false; } msm_id.platform_id = fdt32_to_cpu(((const struct msm_id *)prop)->platform_id); msm_id.hardware_id = fdt32_to_cpu(((const struct msm_id *)prop)->hardware_id); msm_id.soc_rev = fdt32_to_cpu(((const struct msm_id *)prop)->soc_rev); dprintf(INFO, "Found an appended flattened device tree (%s - %d %d 0x%x)\n", *model ? model : "unknown", msm_id.platform_id, msm_id.hardware_id, msm_id.soc_rev); if (msm_id.platform_id != board_platform_id() || msm_id.hardware_id != board_hardware_id()) { dprintf(INFO, "Device tree's msm_id doesn't match the board: <%d %d 0x%x> != <%d %d 0x%x>\n", msm_id.platform_id, msm_id.hardware_id, msm_id.soc_rev, board_platform_id(), board_hardware_id(), board_soc_version()); return INVALID_SOC_REV_ID; } dprintf(INFO, "Device tree's msm_id matches the board: <%d %d 0x%x> == <%d %d 0x%x>\n", msm_id.platform_id, msm_id.hardware_id, msm_id.soc_rev, board_platform_id(), board_hardware_id(), board_soc_version()); return msm_id.soc_rev; }
unsigned *target_first_256M_atag(unsigned *ptr) { unsigned int platform_id = board_platform_id(); unsigned int baseband = board_baseband(); switch (platform_id) { case APQ8064: if(baseband == BASEBAND_MDM) { /* Use 8064 Fusion 3 memory map */ ptr = target_atag(ptr, apq8064_fusion_first_256M, ARRAY_SIZE(apq8064_fusion_first_256M)); } else { /* Use 8064 standalone memory map */ ptr = target_atag(ptr, apq8064_standalone_first_256M, ARRAY_SIZE(apq8064_standalone_first_256M)); } break; case MPQ8064: ptr = target_atag(ptr, mpq8064_first_256M, ARRAY_SIZE(mpq8064_first_256M)); break; case MSM8960: /* fall through */ default: ptr = target_atag(ptr, msm8960_default_first_256M, ARRAY_SIZE(msm8960_default_first_256M)); break; } return ptr; }
/* Check for 8974PRO AC chip */ int platform_is_8974ac() { uint32_t platform = board_platform_id(); int ret = 0; switch(platform) { case APQ8074AA: case APQ8074AB: case APQ8074AC: case MSM8274AA: case MSM8274AB: case MSM8274AC: case MSM8674AA: case MSM8674AB: case MSM8674AC: case MSM8974AA: case MSM8974AB: case MSM8974AC: ret = 1; break; default: ret = 0; }; return ret; }
int platform_is_msm8996() { if (board_platform_id() == MSM8996) return 1; else return 0; }
void target_usb_stop(void) { uint32_t platform = board_platform_id(); /* Disable VBUS mimicing in the controller. */ if (target_needs_vbus_mimic()) ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR); }
void usb_wrapper_workaround_10(usb_wrapper_dev_t *dev) { /* 10. */ if ( (board_platform_id() == MSM8974) && (board_soc_version() < BOARD_SOC_VERSION2)) { REG_WRITE(dev, GENERAL_CFG, 0x78); } }
/* Returns 1 if target supports continuous splash screen. */ int target_cont_splash_screen() { switch(board_platform_id()) { case HW_PLATFORM_SURF: case HW_PLATFORM_FFA: default: return 0; } }
void target_init(void) { unsigned base_addr; unsigned char slot; unsigned platform_id = board_platform_id(); dprintf(INFO, "target_init()\n"); /* Initialize PMIC driver */ pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes; pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes; pm8921_init(&pmic); /* Keypad init */ keys_init(); if(platform_id == MSM8960) { msm8960_keypad_init(); } else if(platform_id == MSM8930) { msm8930_keypad_init(); } else if( (platform_id == APQ8064) || (platform_id == MPQ8064)) { apq8064_keypad_init(); } /* Display splash screen if enabled */ #if DISPLAY_SPLASH_SCREEN display_init(); dprintf(SPEW, "Diplay initialized\n"); #endif if ((platform_id == MSM8960) || (platform_id == MSM8660A) || (platform_id == MSM8260A) || (platform_id == APQ8060A)) /* Enable Hardware CE */ platform_ce_type = CRYPTO_ENGINE_TYPE_HW; /* Trying Slot 1 first */ slot = 1; base_addr = mmc_sdc_base[slot - 1]; if (mmc_boot_main(slot, base_addr)) { /* Trying Slot 3 next */ slot = 3; base_addr = mmc_sdc_base[slot - 1]; if (mmc_boot_main(slot, base_addr)) { dprintf(CRITICAL, "mmc init failed!"); ASSERT(0); } } }
static void set_sdc_power_ctrl() { uint8_t tlmm_hdrv_clk = 0; uint32_t platform_id = 0; platform_id = board_platform_id(); switch(platform_id) { case MSM8274AA: case MSM8274AB: case MSM8674AA: case MSM8674AB: case MSM8974AA: case MSM8974AB: if (board_hardware_id() == HW_PLATFORM_MTP) tlmm_hdrv_clk = TLMM_CUR_VAL_10MA; else tlmm_hdrv_clk = TLMM_CUR_VAL_16MA; break; default: tlmm_hdrv_clk = TLMM_CUR_VAL_16MA; }; /* Drive strength configs for sdc pins */ struct tlmm_cfgs sdc1_hdrv_cfg[] = { { SDC1_CLK_HDRV_CTL_OFF, tlmm_hdrv_clk, TLMM_HDRV_MASK }, { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK }, { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK }, }; /* Pull configs for sdc pins */ struct tlmm_cfgs sdc1_pull_cfg[] = { { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK }, { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK }, { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK }, }; struct tlmm_cfgs sdc1_rclk_cfg[] = { { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK }, }; /* Set the drive strength & pull control values */ tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg)); tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg)); /* RCLK is supported only with 8974 pro, set rclk to pull down * only for 8974 pro targets */ if (!platform_is_8974()) tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg)); }
/* Returns 1 if target supports continuous splash screen. */ int target_cont_splash_screen() { switch(board_platform_id()) { case MSM8960: return 1; default: return 0; } }
void wr_ce(uint32_t val,uint32_t reg) { uint32_t platform_id; platform_id = board_platform_id(); if((platform_id == APQ8064) || (platform_id == APQ8064AA) || (platform_id == APQ8064AB)) writel(val,CRYPTO_ENG_REG(CE3_CRYPTO4_BASE, reg)); else writel(val,CRYPTO_ENG_REG(CE1_CRYPTO4_BASE, reg)); }
/* Function to return the pointer to the start of the correct device tree * based on the platform data. */ struct dt_entry * dev_tree_get_entry_ptr(struct dt_table *table) { uint32_t i; struct dt_entry *dt_entry_ptr; struct dt_entry *latest_dt_entry = NULL; dt_entry_ptr = (struct dt_entry *)((char *)table + DEV_TREE_HEADER_SIZE); for(i = 0; i < table->num_entries; i++) { /* DTBs are stored in the ascending order of soc revision. * For eg: Rev0..Rev1..Rev2 & so on. * we pickup the DTB with highest soc rev number which is less * than or equal to actual hardware */ if((dt_entry_ptr->platform_id == board_platform_id()) && (dt_entry_ptr->variant_id == board_hardware_id()) && (dt_entry_ptr->soc_rev == board_soc_version())) { return dt_entry_ptr; } /* if the exact match not found, return the closest match * assuming it to be the nearest soc version */ if((dt_entry_ptr->platform_id == board_platform_id()) && (dt_entry_ptr->variant_id == board_hardware_id()) && (dt_entry_ptr->soc_rev <= board_soc_version())) { latest_dt_entry = dt_entry_ptr; } dt_entry_ptr++; } if (latest_dt_entry) { dprintf(SPEW, "Loading DTB with SOC version:%x\n", latest_dt_entry->soc_rev); return latest_dt_entry; } return NULL; }
/* identify the usb controller to be used for the target */ const char * target_usb_controller() { switch(board_platform_id()) { /* use dwc controller for PRO chips (with some exceptions) */ case MSM8974AA: case MSM8974AB: case MSM8974AC: /* exceptions based on hardware id */ if (board_hardware_id() != HW_PLATFORM_DRAGON && !target_hw_interposer()) return "dwc"; /* fall through to default "ci" for anything that did'nt select "dwc" */ default: return "ci"; } }
uint32_t rd_ce(uint32_t reg) { uint32_t val; uint32_t platform_id; platform_id = board_platform_id(); if((platform_id == APQ8064) || (platform_id == APQ8064AA) || (platform_id == APQ8064AB)) val = readl(CRYPTO_ENG_REG(CE3_CRYPTO4_BASE, reg)); else val = readl(CRYPTO_ENG_REG(CE1_CRYPTO4_BASE, reg)); return val; }
/* configure SS phy as specified in HPG */ void usb_wrapper_ss_phy_configure(usb_wrapper_dev_t *dev) { /* 4.a */ REG_WRITE_FIELD(dev, SS_PHY_CTRL, REF_USE_PAD, 1); /* .b */ REG_WRITE_FIELD(dev, SS_PHY_CTRL, LANE0_PWR_PRESENT, 1); /* .c */ REG_WRITE_FIELD(dev, SS_PHY_CTRL, REF_SS_PHY_EN, 1); /* For Aragorn V1, reset value fix is required.*/ if ( (board_platform_id() == MSM8974) && (board_soc_version() < BOARD_SOC_VERSION2)) { REG_WRITE_FIELD(dev, SS_PHY_CTRL, SSC_REF_CLK_SEL, 0x108); } }
/* Check for 8974 chip */ static int target_is_8974() { uint32_t platform = board_platform_id(); int ret = 0; switch(platform) { case APQ8074: case MSM8274: case MSM8674: case MSM8974: ret = 1; break; default: ret = 0; }; return ret; }
int platform_is_msm8956() { uint32_t platform = board_platform_id(); uint32_t ret = 0; switch(platform) { case MSM8956: case APQ8056: case APQ8076: case MSM8976: ret = 1; break; default: ret = 0; }; return ret; }
bool platform_is_mdmcalifornium() { uint32_t platform_id = board_platform_id(); bool ret; switch(platform_id) { case MDMCALIFORNIUM1: case MDMCALIFORNIUM2: case MDMCALIFORNIUM3: case MDMCALIFORNIUM4: ret = true; break; default: ret = false; }; return ret; }
/* Pull DISP_RST_N high to get panel out of reset */ int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, struct msm_panel_info *pinfo) { uint32_t rst_gpio = reset_gpio.pin_id; uint32_t platform_id = board_platform_id(); uint32_t hardware_id = board_hardware_id(); struct pm8x41_gpio resetgpio_param = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_CMOS, .out_strength = PM_GPIO_OUT_DRIVE_MED, }; if (platform_id == MSM8974AC) if ((hardware_id == HW_PLATFORM_MTP) || (hardware_id == HW_PLATFORM_LIQUID)) rst_gpio = 20; dprintf(SPEW, "platform_id: %u, rst_gpio: %u\n", platform_id, rst_gpio); pm8x41_gpio_config(rst_gpio, &resetgpio_param); if (enable) { gpio_tlmm_config(enable_gpio.pin_id, 0, enable_gpio.pin_direction, enable_gpio.pin_pull, enable_gpio.pin_strength, enable_gpio.pin_state); gpio_set(enable_gpio.pin_id, resetseq->pin_direction); pm8x41_gpio_set(rst_gpio, resetseq->pin_state[0]); mdelay(resetseq->sleep[0]); pm8x41_gpio_set(rst_gpio, resetseq->pin_state[1]); mdelay(resetseq->sleep[1]); pm8x41_gpio_set(rst_gpio, resetseq->pin_state[2]); mdelay(resetseq->sleep[2]); } else { resetgpio_param.out_strength = PM_GPIO_OUT_DRIVE_LOW; pm8x41_gpio_config(rst_gpio, &resetgpio_param); pm8x41_gpio_set(rst_gpio, PM_GPIO_FUNC_LOW); gpio_set(enable_gpio.pin_id, resetseq->pin_direction); } return NO_ERROR; }
int platform_is_msm8909() { uint32_t platform = board_platform_id(); uint32_t ret = 0; switch(platform) { case MSM8909: case MSM8209: case MSM8208: case APQ8009: case MSM8609: ret = 1; break; default: ret = 0; }; return ret; }
/* Returns 1 if target supports continuous splash screen. */ int target_cont_splash_screen() { switch(board_platform_id()) { case MSM8960: case APQ8064: /* Splash screen and continuous splash screen feature is not * supported on 8960 Liquid target. But kernel display driver * crashes on Liquid if display clocks are disabled. Until that is * fixed, assume this feature is enabled for Liquid also. */ case MSM8960AB: case APQ8060AB: case MSM8260AB: case MSM8660AB: return 1; default: return 0; } }
static int msm8974_wled_backlight_ctrl(uint8_t enable) { uint32_t platform_id = board_platform_id(); uint32_t hardware_id = board_hardware_id(); uint8_t slave_id = 1; if (enable) { if (platform_id == MSM8974AC) if ((hardware_id == HW_PLATFORM_MTP) || (hardware_id == HW_PLATFORM_LIQUID)) slave_id = 3; pm8x41_wled_config_slave_id(slave_id); pm8x41_wled_config(&wled_ctrl); pm8x41_wled_sink_control(enable); pm8x41_wled_iled_sync_control(enable); pm8x41_wled_led_mod_enable(enable); } pm8x41_wled_enable(enable); return NO_ERROR; }
static int platform_dt_match(struct dt_entry *cur_dt_entry, uint32_t target_variant_id, uint32_t subtype_mask) { /* 1. must match the platform_id, hardware_id, platform_version * 2. soc rev number equal then return 0 * 3. dt soc rev number less than cdt return -1 * 4. otherwise return 1 */ uint32_t cur_dt_target_id ; cur_dt_target_id = cur_dt_entry->variant_id | ((cur_dt_entry->board_hw_subtype & subtype_mask & 0xff) << 24); if((cur_dt_entry->platform_id == board_platform_id()) && (cur_dt_target_id == target_variant_id)) { if(cur_dt_entry->soc_rev == board_soc_version()) { return 0; } else if(cur_dt_entry->soc_rev < board_soc_version()) { return -1; } } return 1; }
/* Configure crypto engine clock */ void ce_clock_init(void) { uint32_t platform_id; platform_id = board_platform_id(); if ((platform_id == APQ8064) || (platform_id == APQ8064AA) || (platform_id == APQ8064AB)) { /* Enable HCLK for CE3 */ clk_get_set_enable("ce3_pclk", 0, 1); /* Enable core clk for CE3 */ clk_get_set_enable("ce3_clk", 0, 1); } else { /* Enable HCLK for CE1 */ clk_get_set_enable("ce1_pclk", 0, 1); /* Enable core clk for CE3 */ clk_get_set_enable("ce1_clk", 0, 1); } }
void* platform_mmap_report_first_256MB(void* pdata, platform_mmap_cb_t cb) { uint32_t platform_id = board_platform_id(); uint32_t baseband = board_baseband(); switch (platform_id) { case APQ8064: case APQ8064AA: case APQ8064AB: if(baseband == BASEBAND_MDM) { // Use 8064 Fusion 3 memory map pdata = platform_mmap_report_meminfo_table(pdata, cb, apq8064_fusion_first_256M, ARRAY_SIZE(apq8064_fusion_first_256M)); } else { // Use 8064 standalone memory map pdata = platform_mmap_report_meminfo_table(pdata, cb, apq8064_standalone_first_256M, ARRAY_SIZE(apq8064_standalone_first_256M)); } break; case MPQ8064: pdata = platform_mmap_report_meminfo_table(pdata, cb, mpq8064_first_256M, ARRAY_SIZE(mpq8064_first_256M)); break; case MSM8130: case MSM8230: case MSM8930: case MSM8630: case MSM8130AA: case MSM8230AA: case MSM8630AA: case MSM8930AA: case MSM8930AB: case MSM8630AB: case MSM8230AB: case MSM8130AB: case APQ8030AB: case APQ8030: case APQ8030AA: pdata = platform_mmap_report_meminfo_table(pdata, cb, msm8930_default_first_256M, ARRAY_SIZE(msm8930_default_first_256M)); break; case MSM8960: // fall through case MSM8960AB: case APQ8060AB: case MSM8260AB: case MSM8660AB: default: pdata = platform_mmap_report_meminfo_table(pdata, cb, msm8960_default_first_256M, ARRAY_SIZE(msm8960_default_first_256M)); break; } return pdata; }
void target_init(void) { unsigned base_addr; unsigned char slot; unsigned platform_id = board_platform_id(); dprintf(INFO, "target_init()\n"); pu_reason = target_check_power_on_reason(); reboot_mode = check_reboot_mode(); /* Initialize PMIC driver */ pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes; pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes; pm8921_init(&pmic); target_shutdown_for_battinfo(); target_shutdown_for_pwrkey(); /* Keypad init */ keys_init(); if((platform_id == MSM8960) || (platform_id == MSM8960AB) || (platform_id == APQ8060AB) || (platform_id == MSM8260AB) || (platform_id == MSM8660AB)) { msm8960_keypad_init(); } else if((platform_id == MSM8230) || (platform_id == MSM8630) || (platform_id == MSM8930) || (platform_id == MSM8230AA) || (platform_id == MSM8630AA) || (platform_id == MSM8930AA)) { msm8930_keypad_init(); } else if((platform_id == APQ8064) || (platform_id == MPQ8064) || (platform_id == APQ8064AB)) { apq8064_keypad_init(); } /* Display splash screen if enabled */ #if DISPLAY_SPLASH_SCREEN if (board_target_id() == LINUX_MACHTYPE_8960_CDP || (board_target_id() == LINUX_MACHTYPE_8960_MITWOA)) panel_backlight_on_mitwoa(0); display_init(); dprintf(INFO, "Diplay initialized\n"); mdelay(34); if (board_target_id() == LINUX_MACHTYPE_8064_MITWO || (board_target_id() == LINUX_MACHTYPE_8064_MTP)) panel_backlight_on_mitwo(1); else panel_backlight_on_mitwoa(1); #endif if ((platform_id == MSM8960) || (platform_id == MSM8960AB) || (platform_id == APQ8060AB) || (platform_id == MSM8260AB) || (platform_id == MSM8660AB) || (platform_id == MSM8660A) || (platform_id == MSM8260A) || (platform_id == APQ8060A)) /* Enable Hardware CE */ platform_ce_type = CRYPTO_ENGINE_TYPE_HW; /* Trying Slot 1 first */ slot = 1; base_addr = mmc_sdc_base[slot - 1]; if (mmc_boot_main(slot, base_addr)) { /* Trying Slot 3 next */ slot = 3; base_addr = mmc_sdc_base[slot - 1]; if (mmc_boot_main(slot, base_addr)) { dprintf(CRITICAL, "mmc init failed!"); ASSERT(0); } } }
static int dev_tree_compatible(void *dtb, uint32_t dtb_size, struct dt_entry_node *dtb_list) { int root_offset; const void *prop = NULL; const char *plat_prop = NULL; const char *board_prop = NULL; const char *pmic_prop = NULL; char *model = NULL; struct dt_entry *cur_dt_entry; struct dt_entry *dt_entry_array = NULL; struct board_id *board_data = NULL; struct plat_id *platform_data = NULL; struct pmic_id *pmic_data = NULL; int len; int len_board_id; int len_plat_id; int min_plat_id_len = 0; int len_pmic_id; uint32_t dtb_ver; uint32_t num_entries = 0; uint32_t i, j, k, n; uint32_t msm_data_count; uint32_t board_data_count; uint32_t pmic_data_count; root_offset = fdt_path_offset(dtb, "/"); if (root_offset < 0) return false; prop = fdt_getprop(dtb, root_offset, "model", &len); if (prop && len > 0) { model = (char *) malloc(sizeof(char) * len); ASSERT(model); strlcpy(model, prop, len); } else { dprintf(INFO, "model does not exist in device tree\n"); } /* Find the pmic-id prop from DTB , if pmic-id is present then * the DTB is version 3, otherwise find the board-id prop from DTB , * if board-id is present then the DTB is version 2 */ pmic_prop = (const char *)fdt_getprop(dtb, root_offset, "qcom,pmic-id", &len_pmic_id); board_prop = (const char *)fdt_getprop(dtb, root_offset, "qcom,board-id", &len_board_id); if (pmic_prop && (len_pmic_id > 0) && board_prop && (len_board_id > 0)) { if ((len_pmic_id % PMIC_ID_SIZE) || (len_board_id % BOARD_ID_SIZE)) { dprintf(CRITICAL, "qcom,pmic-id(%d) or qcom,board-id(%d) in device tree is not a multiple of (%d %d)\n", len_pmic_id, len_board_id, PMIC_ID_SIZE, BOARD_ID_SIZE); return false; } dtb_ver = DEV_TREE_VERSION_V3; min_plat_id_len = PLAT_ID_SIZE; } else if (board_prop && len_board_id > 0) { if (len_board_id % BOARD_ID_SIZE) { dprintf(CRITICAL, "qcom,board-id in device tree is (%d) not a multiple of (%d)\n", len_board_id, BOARD_ID_SIZE); return false; } dtb_ver = DEV_TREE_VERSION_V2; min_plat_id_len = PLAT_ID_SIZE; } else { dtb_ver = DEV_TREE_VERSION_V1; min_plat_id_len = DT_ENTRY_V1_SIZE; } /* Get the msm-id prop from DTB */ plat_prop = (const char *)fdt_getprop(dtb, root_offset, "qcom,msm-id", &len_plat_id); if (!plat_prop || len_plat_id <= 0) { dprintf(INFO, "qcom,msm-id entry not found\n"); return false; } else if (len_plat_id % min_plat_id_len) { dprintf(INFO, "qcom,msm-id in device tree is (%d) not a multiple of (%d)\n", len_plat_id, min_plat_id_len); return false; } /* * If DTB version is '1' look for <x y z> pair in the DTB * x: platform_id * y: variant_id * z: SOC rev */ if (dtb_ver == DEV_TREE_VERSION_V1) { cur_dt_entry = (struct dt_entry *) malloc(sizeof(struct dt_entry)); if (!cur_dt_entry) { dprintf(CRITICAL, "Out of memory\n"); return false; } memset(cur_dt_entry, 0, sizeof(struct dt_entry)); while (len_plat_id) { cur_dt_entry->platform_id = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->platform_id); cur_dt_entry->variant_id = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->variant_id); cur_dt_entry->soc_rev = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->soc_rev); cur_dt_entry->board_hw_subtype = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->variant_id) >> 0x18; cur_dt_entry->pmic_rev[0] = board_pmic_target(0); cur_dt_entry->pmic_rev[1] = board_pmic_target(1); cur_dt_entry->pmic_rev[2] = board_pmic_target(2); cur_dt_entry->pmic_rev[3] = board_pmic_target(3); cur_dt_entry->offset = (uint32_t)dtb; cur_dt_entry->size = dtb_size; dprintf(SPEW, "Found an appended flattened device tree (%s - %u %u 0x%x)\n", *model ? model : "unknown", cur_dt_entry->platform_id, cur_dt_entry->variant_id, cur_dt_entry->soc_rev); if (platform_dt_absolute_match(cur_dt_entry, dtb_list)) { dprintf(SPEW, "Device tree exact match the board: <%u %u 0x%x> != <%u %u 0x%x>\n", cur_dt_entry->platform_id, cur_dt_entry->variant_id, cur_dt_entry->soc_rev, board_platform_id(), board_hardware_id(), board_soc_version()); } else { dprintf(SPEW, "Device tree's msm_id doesn't match the board: <%u %u 0x%x> != <%u %u 0x%x>\n", cur_dt_entry->platform_id, cur_dt_entry->variant_id, cur_dt_entry->soc_rev, board_platform_id(), board_hardware_id(), board_soc_version()); plat_prop += DT_ENTRY_V1_SIZE; len_plat_id -= DT_ENTRY_V1_SIZE; continue; } } free(cur_dt_entry); }
static int __dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info, uint32_t target_variant_id, uint32_t subtype_mask) { uint32_t i; unsigned char *table_ptr; struct dt_entry dt_entry_buf_1; struct dt_entry dt_entry_buf_2; struct dt_entry *cur_dt_entry; struct dt_entry *best_match_dt_entry; struct dt_entry_v1 *dt_entry_v1; uint32_t found = 0; if (!dt_entry_info) { dprintf(CRITICAL, "ERROR: Bad parameter passed to %s \n", __func__); return -1; } table_ptr = (unsigned char *)table + DEV_TREE_HEADER_SIZE; cur_dt_entry = &dt_entry_buf_1; best_match_dt_entry = NULL; for(i = 0; found == 0 && i < table->num_entries; i++) { memset(cur_dt_entry, 0, sizeof(struct dt_entry)); switch(table->version) { case DEV_TREE_VERSION_V1: dt_entry_v1 = (struct dt_entry_v1 *)table_ptr; cur_dt_entry->platform_id = dt_entry_v1->platform_id; cur_dt_entry->variant_id = dt_entry_v1->variant_id; cur_dt_entry->soc_rev = dt_entry_v1->soc_rev; cur_dt_entry->board_hw_subtype = board_hardware_subtype(); cur_dt_entry->offset = dt_entry_v1->offset; cur_dt_entry->size = dt_entry_v1->size; table_ptr += sizeof(struct dt_entry_v1); break; case DEV_TREE_VERSION_V2: memcpy(cur_dt_entry, (struct dt_entry *)table_ptr, sizeof(struct dt_entry)); table_ptr += sizeof(struct dt_entry); break; default: dprintf(CRITICAL, "ERROR: Unsupported version (%d) in DT table \n", table->version); return -1; } /* DTBs are stored in the ascending order of soc revision. * For eg: Rev0..Rev1..Rev2 & so on. * we pickup the DTB with highest soc rev number which is less * than or equal to actual hardware */ switch(platform_dt_match(cur_dt_entry, target_variant_id, subtype_mask)) { case 0: best_match_dt_entry = cur_dt_entry; found = 1; break; case -1: if (!best_match_dt_entry) { /* copy structure */ best_match_dt_entry = cur_dt_entry; cur_dt_entry = &dt_entry_buf_2; } else { /* Swap dt_entry buffers */ struct dt_entry *temp = cur_dt_entry; cur_dt_entry = best_match_dt_entry; best_match_dt_entry = temp; } default: break; } } if (best_match_dt_entry) { *dt_entry_info = *best_match_dt_entry; found = 1; } if (found != 0) { dprintf(INFO, "Using DTB entry %u/%08x/%u/%u for device %u/%08x/%u/%u\n", dt_entry_info->platform_id, dt_entry_info->soc_rev, dt_entry_info->variant_id, dt_entry_info->board_hw_subtype, board_platform_id(), board_soc_version(), board_hardware_id(), board_hardware_subtype()); return 0; } dprintf(CRITICAL, "ERROR: Unable to find suitable device tree for device (%u/0x%08x/%u/%u)\n", board_platform_id(), board_soc_version(), board_hardware_id(), board_hardware_subtype()); return -1; }
void platform_init(void) { unsigned base_addr; unsigned char slot; unsigned platform_id = board_platform_id(); static pm8921_dev_t pmic; /* Initialize PMIC driver */ pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes; pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes; pm8921_init(&pmic); keys_add_source(&event_source); switch(platform_id) { case MSM8960: case MSM8960AB: case APQ8060AB: case MSM8260AB: case MSM8660AB: msm8960_keypad_init(); break; case MSM8130: case MSM8230: case MSM8630: case MSM8930: case MSM8130AA: case MSM8230AA: case MSM8630AA: case MSM8930AA: case MSM8930AB: case MSM8630AB: case MSM8230AB: case MSM8130AB: case APQ8030AB: case APQ8030: case APQ8030AA: msm8930_keypad_init(); break; case APQ8064: case MPQ8064: case APQ8064AA: case APQ8064AB: apq8064_keypad_init(); break; default: dprintf(CRITICAL,"Keyboard is not supported for platform: %d\n",platform_id); }; #ifdef QCOM_ENABLE_EMMC unsigned mmc_sdc_base[] = { MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE }; /* Trying Slot 1 first */ slot = 1; base_addr = mmc_sdc_base[slot - 1]; if (mmc_boot_main(slot, base_addr)) { /* Trying Slot 3 next */ slot = 3; base_addr = mmc_sdc_base[slot - 1]; if (mmc_boot_main(slot, base_addr)) { dprintf(CRITICAL, "mmc init failed!"); ASSERT(0); } } #endif }
/* Configure gpio for uart - based on gsbi id */ void gpio_config_uart_dm(uint8_t id) { if(board_platform_id() == MPQ8064) { switch (id) { case GSBI_ID_5: /* configure rx gpio */ gpio_tlmm_config(52, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); /* configure tx gpio */ gpio_tlmm_config(51, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); break; default: ASSERT(0); } } else if(board_platform_id() == APQ8064) { switch (id) { case GSBI_ID_1: /* configure rx gpio */ gpio_tlmm_config(19, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); /* configure tx gpio */ gpio_tlmm_config(18, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); break; case GSBI_ID_7: /* configure rx gpio */ gpio_tlmm_config(83, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); /* configure tx gpio */ gpio_tlmm_config(82, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); break; default: ASSERT(0); } } else { switch (id) { case GSBI_ID_3: /* configure rx gpio */ gpio_tlmm_config(15, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); /* configure tx gpio */ gpio_tlmm_config(14, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); break; case GSBI_ID_5: /* configure rx gpio */ gpio_tlmm_config(23, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); /* configure tx gpio */ gpio_tlmm_config(22, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); break; default: ASSERT(0); } } }