/* Function to obtain the index information for the correct device tree * based on the platform data. * If a matching device tree is found, the information is returned in the * "dt_entry_info" out parameter and a function value of 0 is returned, otherwise * a non-zero function value is returned. */ int dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info) { uint32_t target_variant_id; if(board_hardware_id() == HW_PLATFORM_QRD) { target_variant_id = board_target_id(); if (__dev_tree_get_entry_info(table, dt_entry_info, target_variant_id, 0xff) == 0) { return 0; } } /* * for compatible with version 1 and version 2 dtbtool * will compare the subtype inside the variant id */ target_variant_id = board_hardware_id() | ((board_hardware_subtype() & 0xff) << 24); if (__dev_tree_get_entry_info(table, dt_entry_info, target_variant_id, 0xff) == 0) { return 0; } /* * add compatible with old device selection method which don't compare subtype */ target_variant_id = board_hardware_id(); return __dev_tree_get_entry_info(table, dt_entry_info, target_variant_id, 0); }
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; }
/* * Function to set the capabilities for the host */ void target_mmc_caps(struct mmc_host *host) { uint32_t soc_ver = 0; soc_ver = board_soc_version(); /* * 8974 v1 fluid devices, have a hardware bug * which limits the bus width to 4 bit. */ switch(board_hardware_id()) { case HW_PLATFORM_FLUID: if (soc_ver >= BOARD_SOC_VERSION2) host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT; else host->caps.bus_width = MMC_BOOT_BUS_WIDTH_4_BIT; break; default: host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT; }; host->caps.ddr_mode = 1; host->caps.hs200_mode = 1; host->caps.hs_clk_rate = MMC_CLK_96MHZ; }
/* Do target specific usb initialization */ void target_usb_init(void) { /* Enable secondary USB PHY on DragonBoard8074 */ if (board_hardware_id() == HW_PLATFORM_DRAGON) { /* Route ChipIDea to use secondary USB HS port2 */ writel_relaxed(1, USB2_PHY_SEL); /* Enable access to secondary PHY by clamping the low * voltage interface between DVDD of the PHY and Vddcx * (set bit16 (USB2_PHY_HS2_DIG_CLAMP_N_2) = 1) */ writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_SEC_CTRL) | 0x00010000, USB_OTG_HS_PHY_SEC_CTRL); /* Perform power-on-reset of the PHY. * Delay values are arbitrary */ writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL)|1, USB_OTG_HS_PHY_CTRL); thread_sleep(10); writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL) & 0xFFFFFFFE, USB_OTG_HS_PHY_CTRL); thread_sleep(10); /* Enable HSUSB PHY port for ULPI interface, * then configure related parameters within the PHY */ writel_relaxed(((readl_relaxed(USB_PORTSC) & 0xC0000000) | 0x8c000004), USB_PORTSC); } }
int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, struct msm_panel_info *pinfo, struct mdss_dsi_phy_ctrl *phy_db) { uint32_t hw_id = board_hardware_id(); uint32_t target_id = board_target_id(); int32_t panel_override_id; if (panel_name) { panel_override_id = panel_name_to_id(supp_panels, ARRAY_SIZE(supp_panels), panel_name); if (panel_override_id < 0) { dprintf(CRITICAL, "Not able to search the panel:%s\n", panel_name + strspn(panel_name, " ")); } else if (panel_override_id < UNKNOWN_PANEL) { /* panel override using fastboot oem command */ panel_id = panel_override_id; dprintf(INFO, "OEM panel override:%s\n", panel_name + strspn(panel_name, " ")); goto panel_init; } } switch (target_id) { default: dprintf(CRITICAL, "Display not enabled for %d HW type\n" , hw_id); return PANEL_TYPE_UNKNOWN; } panel_init: return init_panel_data(panelstruct, pinfo, phy_db); }
/* Return 1 if vol_up pressed */ static int target_volume_up() { uint8_t status = 0; struct pm8x41_gpio gpio; /* CDP vol_up seems to be always grounded. So gpio status is read as 0, * whether key is pressed or not. * Ignore volume_up key on CDP for now. */ if (board_hardware_id() == HW_PLATFORM_SURF) return 0; /* Configure the GPIO */ gpio.direction = PM_GPIO_DIR_IN; gpio.function = 0; gpio.pull = PM_GPIO_PULL_UP_30; gpio.vin_sel = 2; pm8x41_gpio_config(5, &gpio); /* Get status of P_GPIO_5 */ pm8x41_gpio_get(5, &status); return !status; /* active low */ }
int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, struct msm_panel_info *pinfo, struct mdss_dsi_phy_ctrl *phy_db) { uint32_t hw_id = board_hardware_id(); uint32_t target_id = board_target_id(); int32_t panel_override_id; uint32_t manu_id, manu_id0; if (panel_name && panel_name[0]) { panel_override_id = panel_name_to_id(supp_panels, ARRAY_SIZE(supp_panels), panel_name); if (panel_override_id < 0) { dprintf(CRITICAL, "Not able to search the panel:%s\n", panel_name + strspn(panel_name, " ")); } else if (panel_override_id < UNKNOWN_PANEL) { /* panel override using fastboot oem command */ panel_id = panel_override_id; dprintf(INFO, "OEM panel override:%s\n", panel_name + strspn(panel_name, " ")); goto panel_init; } } switch (target_id) { case LINUX_MACHTYPE_8064_MTP: case LINUX_MACHTYPE_8064_MITWO: if (panel_id_detection()) panel_id = HITACHI_720P_CMD_PANEL; else panel_id = SHARP_720P_CMD_PANEL; break; case LINUX_MACHTYPE_8960_CDP: case LINUX_MACHTYPE_8960_MITWOA: panel_manu_id_detection(&manu_id, &manu_id0); if ((manu_id) && (manu_id0)) panel_id = LGD_720P_CMD_PANEL; if ((manu_id)&& !manu_id0) panel_id = AUO_720P_CMD_PANEL; if (manu_id == 0x60 && manu_id0 == 0x141304) panel_id = JDI_720P_CMD_PANEL; else { dprintf(CRITICAL, "Unknown panel\n"); return PANEL_TYPE_UNKNOWN; } break; default: dprintf(CRITICAL, "Display not enabled for %d HW type\n" , hw_id); return PANEL_TYPE_UNKNOWN; } pinfo->early_config = mipi_dsi_cmd_trigger; panel_init: return init_panel_data(panelstruct, pinfo, phy_db); }
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)); }
void target_display_init(const char *panel_name) { uint32_t hw_id = board_hardware_id(); uint32_t panel_loop = 0; uint32_t ret = 0; if (target_hw_interposer()) return; panel_name += strspn(panel_name, " "); if ((!strcmp(panel_name, NO_PANEL_CONFIG)) || (!strcmp(panel_name, SIM_VIDEO_PANEL)) || (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL))) { dprintf(INFO, "Selected panel: %s\nSkip panel configuration", panel_name); return; } else if (!strcmp(panel_name, HDMI_PANEL_NAME)) { dprintf(INFO, "%s: HDMI is primary\n", __func__); return; } switch (hw_id) { case HW_PLATFORM_LIQUID: edp_panel_init(&(panel.panel_info)); panel.clk_func = msm8974_mdss_edp_panel_clock; panel.power_func = msm8974_edp_panel_power; panel.fb.base = (void *)EDP_FB_ADDR; panel.fb.format = FB_FORMAT_RGB888; panel.mdp_rev = MDP_REV_50; if (msm_display_init(&panel)) { dprintf(CRITICAL, "edp init failed!\n"); return; } edp_enable = 1; break; default: do { ret = gcdb_display_init(panel_name, MDP_REV_50, MIPI_FB_ADDR); if (!ret || ret == ERR_NOT_SUPPORTED) { break; } else { target_force_cont_splash_disable(true); msm_display_off(); target_force_cont_splash_disable(false); } } while (++panel_loop <= oem_panel_max_auto_detect_panels()); break; } }
void target_display_shutdown(void) { uint32_t hw_id = board_hardware_id(); switch (hw_id) { case HW_PLATFORM_LIQUID: if (edp_enable) msm_display_off(); break; default: gcdb_display_shutdown(); break; } }
/* 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; }
uint8_t target_is_edp() { switch(board_hardware_id()) { case HW_PLATFORM_LIQUID: return 1; break; default: return 0; break; } return 0; }
uint8_t target_panel_auto_detect_enabled() { switch(board_hardware_id()) { case HW_PLATFORM_QRD: return 1; case HW_PLATFORM_SURF: case HW_PLATFORM_MTP: default: return 0; } return 0; }
int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, struct msm_panel_info *pinfo, struct mdss_dsi_phy_ctrl *phy_db) { uint32_t hw_id = board_hardware_id(); int32_t panel_override_id; if (panel_name) { panel_override_id = panel_name_to_id(supp_panels, ARRAY_SIZE(supp_panels), panel_name); if (panel_override_id < 0) { dprintf(CRITICAL, "Not able to search the panel:%s\n", panel_name + strspn(panel_name, " ")); } else if (panel_override_id < UNKNOWN_PANEL) { /* panel override using fastboot oem command */ panel_id = panel_override_id; dprintf(INFO, "OEM panel override:%s\n", panel_name + strspn(panel_name, " ")); goto panel_init; } } switch (hw_id) { case HW_PLATFORM_MTP: panel_id = TRULY_1080P_VIDEO_PANEL; break; case HW_PLATFORM_SURF: panel_id = TRULY_1080P_VIDEO_PANEL; break; case HW_PLATFORM_QRD: panel_id = OTM1906C_1080P_CMD_PANEL; break; default: dprintf(CRITICAL, "Display not enabled for %d HW type\n", hw_id); return PANEL_TYPE_UNKNOWN; } panel_init: /* * Update all data structures after 'panel_init' label. Only panel * selection is supposed to happen before that. */ memcpy(panel_regulator_settings, dcdc_regulator_settings, REGULATOR_SIZE); pinfo->pipe_type = MDSS_MDP_PIPE_TYPE_RGB; return init_panel_data(panelstruct, pinfo, phy_db); }
/* Returns 1 if target supports continuous splash screen. */ int target_cont_splash_screen() { switch(board_hardware_id()) { case HW_PLATFORM_SURF: case HW_PLATFORM_MTP: case HW_PLATFORM_FLUID: case HW_PLATFORM_LIQUID: dprintf(SPEW, "Target_cont_splash=1\n"); return 1; default: dprintf(SPEW, "Target_cont_splash=0\n"); return 0; } }
/* Returns 1 if autopanel detection is enabled for the target. */ uint8_t target_panel_auto_detect_enabled(void) { int ret = 0; switch(board_hardware_id()) { case HW_PLATFORM_MTP: case HW_PLATFORM_SURF: case HW_PLATFORM_QRD: default: dprintf(SPEW, "Panel auto-detection is disabled\n"); ret = 0; } return ret; }
/* 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"; } }
uint8_t target_panel_auto_detect_enabled() { uint8_t ret = 0; uint32_t hw_subtype = board_hardware_subtype(); switch(board_hardware_id()) { case HW_PLATFORM_SURF: case HW_PLATFORM_MTP: ret = 1; break; default: ret = 0; break; } return ret; }
size_t smem_get_hw_platform_name(void *buf, uint32_t buf_size) { uint32_t hw_id; if (buf == NULL) { dprintf(CRITICAL, "ERROR: buf is NULL\n"); return 1; } hw_id = board_hardware_id(); if (buf_size < strlen(hw_platform[hw_id]) + 1) return 1; return snprintf(buf, strlen(hw_platform[hw_id]) + 1, "%s\n", hw_platform[hw_id]); }
uint8_t target_panel_auto_detect_enabled() { uint8_t ret = 0; switch(board_hardware_id()) { case HW_PLATFORM_QRD: ret = platform_is_msm8956() ? 1 : 0; break; case HW_PLATFORM_SURF: case HW_PLATFORM_MTP: default: ret = 0; } return ret; }
/* Do target specific usb initialization */ void target_usb_init(void) { uint32_t val; /* Enable secondary USB PHY on DragonBoard8074 */ if (board_hardware_id() == HW_PLATFORM_DRAGON) { /* Route ChipIDea to use secondary USB HS port2 */ writel_relaxed(1, USB2_PHY_SEL); /* Enable access to secondary PHY by clamping the low * voltage interface between DVDD of the PHY and Vddcx * (set bit16 (USB2_PHY_HS2_DIG_CLAMP_N_2) = 1) */ writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_SEC_CTRL) | 0x00010000, USB_OTG_HS_PHY_SEC_CTRL); /* Perform power-on-reset of the PHY. * Delay values are arbitrary */ writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL)|1, USB_OTG_HS_PHY_CTRL); thread_sleep(10); writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL) & 0xFFFFFFFE, USB_OTG_HS_PHY_CTRL); thread_sleep(10); /* Enable HSUSB PHY port for ULPI interface, * then configure related parameters within the PHY */ writel_relaxed(((readl_relaxed(USB_PORTSC) & 0xC0000000) | 0x8c000004), USB_PORTSC); } if (target_needs_vbus_mimic()) { /* Select and enable external configuration with USB PHY */ ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET); /* Enable sess_vld */ val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN; writel(val, USB_GENCONFIG_2); /* Enable external vbus configuration in the LINK */ val = readl(USB_USBCMD); val |= SESS_VLD_CTRL; writel(val, USB_USBCMD); } }
/* Returns 1 if target supports continuous splash screen. */ int target_cont_splash_screen() { uint8_t splash_screen = 0; if (!splash_override) { switch (board_hardware_id()) { case HW_PLATFORM_MTP: case HW_PLATFORM_SURF: case HW_PLATFORM_QRD: splash_screen = 1; break; default: splash_screen = 0; break; } dprintf(SPEW, "Target_cont_splash=%d\n", splash_screen); } return splash_screen; }
int oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, struct msm_panel_info *pinfo, struct mdss_dsi_phy_ctrl *phy_db) { uint32_t hw_id = board_hardware_id(); int32_t panel_override_id; if (panel_name) { panel_override_id = panel_name_to_id(supp_panels, ARRAY_SIZE(supp_panels), panel_name); if (panel_override_id < 0) { dprintf(CRITICAL, "Not able to search the panel:%s\n", panel_name); } else if (panel_override_id < UNKNOWN_PANEL) { /* panel override using fastboot oem command */ panel_id = panel_override_id; dprintf(INFO, "OEM panel override:%s\n", panel_name); goto panel_init; } } switch (hw_id) { case HW_PLATFORM_MTP: case HW_PLATFORM_FLUID: case HW_PLATFORM_SURF: panel_id = SHARP_WQXGA_DUALDSI_VIDEO_PANEL; break; case HW_PLATFORM_LIQUID: panel_id = JDI_4K_DUALDSI_VIDEO_PANEL; break; default: dprintf(CRITICAL, "Display not enabled for %d HW type\n" , hw_id); return PANEL_TYPE_UNKNOWN; } panel_init: if (panel_id == JDI_4K_DUALDSI_VIDEO_PANEL || panel_id == HX8379A_TRULY_FWVGA_VIDEO_PANEL) phy_db->regulator_mode = DSI_PHY_REGULATOR_LDO_MODE; return init_panel_data(panelstruct, pinfo, phy_db); }
/* Returns 1 if target supports continuous splash screen. */ int target_cont_splash_screen(void) { uint8_t splash_screen = 0; if(!splash_override) { switch(board_hardware_id()) { case HW_PLATFORM_QRD: case HW_PLATFORM_MTP: case HW_PLATFORM_SURF: dprintf(SPEW, "Target_cont_splash=1\n"); splash_screen = 1; break; default: dprintf(SPEW, "Target_cont_splash=0\n"); splash_screen = 0; } } return splash_screen; }
static target_mmc_sdhci_init() { struct mmc_config_data config; uint32_t soc_ver = 0; /* Enable sdhci mode */ sdhci_mode_enable(1); soc_ver = board_soc_version(); /* * 8974 v1 fluid devices, have a hardware bug * which limits the bus width to 4 bit. */ switch(board_hardware_id()) { case HW_PLATFORM_FLUID: if (soc_ver >= BOARD_SOC_VERSION2) config.bus_width = DATA_BUS_WIDTH_8BIT; else config.bus_width = DATA_BUS_WIDTH_4BIT; break; default: config.bus_width = DATA_BUS_WIDTH_8BIT; }; config.max_clk_rate = MMC_CLK_200MHZ; /* Trying Slot 1*/ config.slot = 1; config.base = mmc_sdhci_base[config.slot - 1]; if (!(dev = mmc_init(&config))) { /* Trying Slot 2 next */ config.slot = 2; config.base = mmc_sdhci_base[config.slot - 1]; if (!(dev = mmc_init(&config))) { dprintf(CRITICAL, "mmc init failed!"); ASSERT(0); } } }
/* 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 oem_panel_select(const char *panel_name, struct panel_struct *panelstruct, struct msm_panel_info *pinfo, struct mdss_dsi_phy_ctrl *phy_db) { uint32_t hw_id = board_hardware_id(); int32_t panel_override_id; phy_db->pll_type = DSI_PLL_TYPE_THULIUM; if (panel_name) { panel_override_id = panel_name_to_id(supp_panels, ARRAY_SIZE(supp_panels), panel_name); if (panel_override_id < 0) { dprintf(CRITICAL, "Not able to search the panel:%s\n", panel_name + strspn(panel_name, " ")); } else if (panel_override_id < UNKNOWN_PANEL) { /* panel override using fastboot oem command */ panel_id = panel_override_id; dprintf(INFO, "OEM panel override:%s\n", panel_name + strspn(panel_name, " ")); goto panel_init; } } switch (hw_id) { case HW_PLATFORM_MTP: case HW_PLATFORM_FLUID: case HW_PLATFORM_SURF: panel_id = SHARP_WQXGA_DUALDSI_VIDEO_PANEL; break; default: dprintf(CRITICAL, "Display not enabled for %d HW type\n" , hw_id); return PANEL_TYPE_UNKNOWN; } panel_init: return init_panel_data(panelstruct, pinfo, phy_db); }
/* Do target specific usb initialization */ void target_usb_init(void) { uint32_t val; if(board_hardware_id() == HW_PLATFORM_DRAGON) { /* Select the QUSB2 PHY */ writel(0x1, USB2_PHY_SEL); qusb2_phy_reset(); } /* Enable sess_vld */ val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN; writel(val, USB_GENCONFIG_2); /* Enable external vbus configuration in the LINK */ val = readl(USB_USBCMD); val |= SESS_VLD_CTRL; writel(val, USB_USBCMD); }
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 msm8974_backlight_on() { static struct pm8x41_wled_data wled_ctrl = { .mod_scheme = 0xC3, .led1_brightness = (0x0F << 8) | 0xEF, .led2_brightness = (0x0F << 8) | 0xEF, .led3_brightness = (0x0F << 8) | 0xEF, .max_duty_cycle = 0x01, }; pm8x41_wled_config(&wled_ctrl); pm8x41_wled_sink_control(1); pm8x41_wled_iled_sync_control(1); pm8x41_wled_enable(1); return 0; } static int msm8974_mdss_dsi_panel_clock(uint8_t enable) { if (enable) { mdp_gdsc_ctrl(enable); mdp_clock_init(); mdss_dsi_uniphy_pll_config(); mmss_clock_init(); } else if(!target_cont_splash_screen()) { // * Add here for continuous splash * mmss_clock_disable(); mdp_clock_disable(); mdp_gdsc_ctrl(enable); } return 0; } /* Pull DISP_RST_N high to get panel out of reset */ static void msm8974_mdss_mipi_panel_reset(uint8_t enable) { struct pm8x41_gpio gpio19_param = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_CMOS, .out_strength = PM_GPIO_OUT_DRIVE_MED, }; pm8x41_gpio_config(19, &gpio19_param); if (enable) { gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH); mdelay(2); pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW); mdelay(5); pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH); mdelay(2); gpio_set(58, 2); } else { gpio19_param.out_strength = PM_GPIO_OUT_DRIVE_LOW; pm8x41_gpio_config(19, &gpio19_param); pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW); gpio_set(58, 2); } } static int msm8974_mipi_panel_power(uint8_t enable) { if (enable) { /* Enable backlight */ msm8974_backlight_on(); /* Turn on LDO8 for lcd1 mipi vdd */ dprintf(SPEW, " Setting LDO22\n"); pm8x41_ldo_set_voltage("LDO22", 3000000); pm8x41_ldo_control("LDO22", enable); dprintf(SPEW, " Setting LDO12\n"); /* Turn on LDO23 for lcd1 mipi vddio */ pm8x41_ldo_set_voltage("LDO12", 1800000); pm8x41_ldo_control("LDO12", enable); dprintf(SPEW, " Setting LDO2\n"); /* Turn on LDO2 for vdda_mipi_dsi */ pm8x41_ldo_set_voltage("LDO2", 1200000); pm8x41_ldo_control("LDO2", enable); dprintf(SPEW, " Panel Reset \n"); /* Panel Reset */ msm8974_mdss_mipi_panel_reset(enable); dprintf(SPEW, " Panel Reset Done\n"); } else { msm8974_mdss_mipi_panel_reset(enable); pm8x41_wled_enable(enable); pm8x41_ldo_control("LDO2", enable); pm8x41_ldo_control("LDO22", enable); } return 0; } void display_init(void) { uint32_t hw_id = board_hardware_id(); uint32_t soc_ver = board_soc_version(); dprintf(INFO, "display_init(),target_id=%d.\n", hw_id); switch (hw_id) { case HW_PLATFORM_MTP: case HW_PLATFORM_FLUID: case HW_PLATFORM_SURF: mipi_toshiba_video_720p_init(&(panel.panel_info)); panel.clk_func = msm8974_mdss_dsi_panel_clock; panel.power_func = msm8974_mipi_panel_power; panel.fb.base = MIPI_FB_ADDR; panel.fb.width = panel.panel_info.xres; panel.fb.height = panel.panel_info.yres; panel.fb.stride = panel.panel_info.xres; panel.fb.bpp = panel.panel_info.bpp; panel.fb.format = FB_FORMAT_RGB888; panel.mdp_rev = MDP_REV_50; break; default: return; }; if (msm_display_init(&panel)) { dprintf(CRITICAL, "Display init failed!\n"); return; } display_enable = 1; }