int target_ldo_ctrl(uint8_t enable) { uint32_t ldocounter = 0; uint32_t pm8x41_ldo_base = 0x13F00; while (ldocounter < TOTAL_LDO_DEFINED) { struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base + 0x100 * ldo_entry_array[ldocounter].ldo_id), ldo_entry_array[ldocounter].ldo_type); dprintf(SPEW, "Setting %s\n", ldo_entry_array[ldocounter].ldo_id); /* Set voltage during power on */ if (enable) { pm8x41_ldo_set_voltage(&ldo_entry, ldo_entry_array[ldocounter].ldo_voltage); pm8x41_ldo_control(&ldo_entry, enable); } else if(ldo_entry_array[ldocounter].ldo_id != HFPLL_LDO_ID) { pm8x41_ldo_control(&ldo_entry, enable); } ldocounter++; } 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; }
static int msm8974_edp_panel_power(int enable) { struct pm8x41_gpio gpio36_param = { .direction = PM_GPIO_DIR_OUT, .function = PM_GPIO_FUNC_2, .vin_sel = 2, /* VIN_2 */ .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10, .output_buffer = PM_GPIO_OUT_CMOS, .out_strength = PM_GPIO_OUT_DRIVE_HIGH, }; struct pm8x41_ldo ldo12 = LDO(PM8x41_LDO12, PLDO_TYPE); if (enable) { /* Enable backlight */ dprintf(SPEW, "Enable Backlight\n"); msm8974_pwm_backlight_ctrl(36, 8, 1); dprintf(SPEW, "Enable Backlight Done\n"); /* Turn on LDO12 for edp vdda */ dprintf(SPEW, "Setting LDO12 n"); pm8x41_ldo_set_voltage(&ldo12, 1800000); pm8x41_ldo_control(&ldo12, enable); dprintf(SPEW, "Setting LDO12 Done\n"); /* Panel Enable */ dprintf(SPEW, "Panel Enable\n"); gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); gpio_set(58, 2); dprintf(SPEW, "Panel Enable Done\n"); } else { /* Keep LDO12 on, otherwise kernel will not boot */ gpio_set(58, 0); msm8974_pwm_backlight_ctrl(36, 8, 0); } return 0; } bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size) { int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX); bool ret = true; panel_name += strspn(panel_name, " "); if (!strcmp(panel_name, HDMI_PANEL_NAME)) { if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN + HDMI_CONTROLLER_STRING)) { dprintf(CRITICAL, "command line argument is greater than buffer size\n"); return false; } strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size); buf_size -= prefix_string_len; strlcat(pbuf, LK_OVERRIDE_PANEL, buf_size); buf_size -= LK_OVERRIDE_PANEL_LEN; strlcat(pbuf, HDMI_CONTROLLER_STRING, buf_size); } else { ret = gcdb_display_cmdline_arg(panel_name, pbuf, buf_size); } return ret; }