Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions |
| 5 | * are 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 copyright |
| 9 | * notice, this list of conditions and the following disclaimer in |
| 10 | * the documentation and/or other materials provided with the |
| 11 | * 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 23 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 24 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 26 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <debug.h> |
| 31 | #include <smem.h> |
| 32 | #include <msm_panel.h> |
| 33 | #include <pm8x41.h> |
| 34 | #include <pm8x41_wled.h> |
| 35 | #include <board.h> |
| 36 | #include <mdp5.h> |
| 37 | #include <platform/gpio.h> |
Asaf Penso | c9080dc | 2013-05-21 21:53:50 +0300 | [diff] [blame] | 38 | #include <platform/clock.h> |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 39 | #include <target/display.h> |
| 40 | |
| 41 | static struct msm_fb_panel_data panel; |
| 42 | static uint8_t display_enable; |
| 43 | |
| 44 | extern int msm_display_init(struct msm_fb_panel_data *pdata); |
| 45 | extern int msm_display_off(); |
| 46 | extern int mdss_dsi_uniphy_pll_config(void); |
Asaf Penso | 325f43a | 2013-05-21 21:55:48 +0300 | [diff] [blame^] | 47 | extern int mdss_sharp_dsi_uniphy_pll_config(void); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 48 | |
| 49 | static int msm8974_backlight_on() |
| 50 | { |
| 51 | static struct pm8x41_wled_data wled_ctrl = { |
| 52 | .mod_scheme = 0xC3, |
| 53 | .led1_brightness = (0x0F << 8) | 0xEF, |
| 54 | .led2_brightness = (0x0F << 8) | 0xEF, |
| 55 | .led3_brightness = (0x0F << 8) | 0xEF, |
| 56 | .max_duty_cycle = 0x01, |
| 57 | }; |
| 58 | |
| 59 | pm8x41_wled_config(&wled_ctrl); |
| 60 | pm8x41_wled_sink_control(1); |
| 61 | pm8x41_wled_iled_sync_control(1); |
| 62 | pm8x41_wled_enable(1); |
| 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static int msm8974_mdss_dsi_panel_clock(uint8_t enable) |
| 68 | { |
| 69 | if (enable) { |
| 70 | mdp_gdsc_ctrl(enable); |
| 71 | mdp_clock_init(); |
| 72 | mdss_dsi_uniphy_pll_config(); |
Asaf Penso | c9080dc | 2013-05-21 21:53:50 +0300 | [diff] [blame] | 73 | mmss_clock_init(DSI0_PHY_PLL_OUT | PIXEL_SRC_DIV_1_5); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 74 | } else if(!target_cont_splash_screen()) { |
| 75 | // * Add here for continuous splash * |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 76 | mmss_clock_disable(); |
| 77 | mdp_clock_disable(); |
| 78 | mdp_gdsc_ctrl(enable); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | return 0; |
| 82 | } |
| 83 | |
Asaf Penso | 325f43a | 2013-05-21 21:55:48 +0300 | [diff] [blame^] | 84 | static int msm8974_mdss_sharp_dsi_panel_clock(uint8_t enable) |
| 85 | { |
| 86 | if (enable) { |
| 87 | mdp_gdsc_ctrl(enable); |
| 88 | mdp_clock_init(); |
| 89 | mdss_sharp_dsi_uniphy_pll_config(); |
| 90 | mmss_clock_init(DSI0_PHY_PLL_OUT); |
| 91 | } else if (!target_cont_splash_screen()) { |
| 92 | /* Add here for continuous splash */ |
| 93 | mmss_clock_disable(); |
| 94 | mdp_clock_disable(); |
| 95 | mdp_gdsc_ctrl(enable); |
| 96 | } |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 101 | /* Pull DISP_RST_N high to get panel out of reset */ |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 102 | static void msm8974_mdss_mipi_panel_reset(uint8_t enable) |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 103 | { |
| 104 | struct pm8x41_gpio gpio19_param = { |
| 105 | .direction = PM_GPIO_DIR_OUT, |
| 106 | .output_buffer = PM_GPIO_OUT_CMOS, |
| 107 | .out_strength = PM_GPIO_OUT_DRIVE_MED, |
| 108 | }; |
| 109 | |
| 110 | pm8x41_gpio_config(19, &gpio19_param); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 111 | if (enable) { |
| 112 | gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 113 | |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 114 | pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH); |
| 115 | mdelay(2); |
| 116 | pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW); |
| 117 | mdelay(5); |
| 118 | pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH); |
| 119 | mdelay(2); |
| 120 | gpio_set(58, 2); |
| 121 | } else { |
| 122 | gpio19_param.out_strength = PM_GPIO_OUT_DRIVE_LOW; |
| 123 | pm8x41_gpio_config(19, &gpio19_param); |
| 124 | pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW); |
| 125 | gpio_set(58, 2); |
| 126 | } |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 127 | } |
| 128 | |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 129 | static int msm8974_mipi_panel_power(uint8_t enable) |
| 130 | { |
| 131 | if (enable) { |
| 132 | |
| 133 | /* Enable backlight */ |
| 134 | msm8974_backlight_on(); |
| 135 | |
| 136 | /* Turn on LDO8 for lcd1 mipi vdd */ |
| 137 | dprintf(SPEW, " Setting LDO22\n"); |
| 138 | pm8x41_ldo_set_voltage("LDO22", 3000000); |
| 139 | pm8x41_ldo_control("LDO22", enable); |
| 140 | |
| 141 | dprintf(SPEW, " Setting LDO12\n"); |
| 142 | /* Turn on LDO23 for lcd1 mipi vddio */ |
| 143 | pm8x41_ldo_set_voltage("LDO12", 1800000); |
| 144 | pm8x41_ldo_control("LDO12", enable); |
| 145 | |
| 146 | dprintf(SPEW, " Setting LDO2\n"); |
| 147 | /* Turn on LDO2 for vdda_mipi_dsi */ |
| 148 | pm8x41_ldo_set_voltage("LDO2", 1200000); |
| 149 | pm8x41_ldo_control("LDO2", enable); |
| 150 | |
| 151 | dprintf(SPEW, " Panel Reset \n"); |
| 152 | /* Panel Reset */ |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 153 | msm8974_mdss_mipi_panel_reset(enable); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 154 | dprintf(SPEW, " Panel Reset Done\n"); |
Siddhartha Agrawal | c43c487 | 2013-04-21 16:23:16 -0700 | [diff] [blame] | 155 | } else { |
| 156 | msm8974_mdss_mipi_panel_reset(enable); |
| 157 | pm8x41_wled_enable(enable); |
| 158 | pm8x41_ldo_control("LDO2", enable); |
| 159 | pm8x41_ldo_control("LDO22", enable); |
| 160 | |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | void display_init(void) |
| 167 | { |
| 168 | uint32_t hw_id = board_hardware_id(); |
Channagoud Kadabi | 1cc5e9c | 2013-02-11 14:50:15 -0800 | [diff] [blame] | 169 | uint32_t soc_ver = board_soc_version(); |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 170 | |
| 171 | dprintf(INFO, "display_init(),target_id=%d.\n", hw_id); |
| 172 | |
| 173 | switch (hw_id) { |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 174 | case HW_PLATFORM_MTP: |
| 175 | case HW_PLATFORM_FLUID: |
Siddhartha Agrawal | 17a6b83 | 2013-02-17 18:36:25 -0800 | [diff] [blame] | 176 | case HW_PLATFORM_SURF: |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 177 | mipi_toshiba_video_720p_init(&(panel.panel_info)); |
| 178 | panel.clk_func = msm8974_mdss_dsi_panel_clock; |
| 179 | panel.power_func = msm8974_mipi_panel_power; |
| 180 | panel.fb.base = MIPI_FB_ADDR; |
| 181 | panel.fb.width = panel.panel_info.xres; |
| 182 | panel.fb.height = panel.panel_info.yres; |
| 183 | panel.fb.stride = panel.panel_info.xres; |
| 184 | panel.fb.bpp = panel.panel_info.bpp; |
| 185 | panel.fb.format = FB_FORMAT_RGB888; |
| 186 | panel.mdp_rev = MDP_REV_50; |
| 187 | break; |
Asaf Penso | 325f43a | 2013-05-21 21:55:48 +0300 | [diff] [blame^] | 188 | case HW_PLATFORM_DRAGON: |
| 189 | mipi_sharp_video_qhd_init(&(panel.panel_info)); |
| 190 | panel.clk_func = msm8974_mdss_sharp_dsi_panel_clock; |
| 191 | panel.power_func = msm8974_mipi_panel_power; |
| 192 | panel.fb.base = MIPI_FB_ADDR; |
| 193 | panel.fb.width = panel.panel_info.xres; |
| 194 | panel.fb.height = panel.panel_info.yres; |
| 195 | panel.fb.stride = panel.panel_info.xres; |
| 196 | panel.fb.bpp = panel.panel_info.bpp; |
| 197 | panel.fb.format = FB_FORMAT_RGB888; |
| 198 | panel.mdp_rev = MDP_REV_50; |
| 199 | break; |
Siddhartha Agrawal | 7ac6d51 | 2013-01-22 18:39:50 -0800 | [diff] [blame] | 200 | default: |
| 201 | return; |
| 202 | }; |
| 203 | |
| 204 | if (msm_display_init(&panel)) { |
| 205 | dprintf(CRITICAL, "Display init failed!\n"); |
| 206 | return; |
| 207 | } |
| 208 | |
| 209 | display_enable = 1; |
| 210 | } |
| 211 | |
| 212 | void display_shutdown(void) |
| 213 | { |
| 214 | if (display_enable) |
| 215 | msm_display_off(); |
| 216 | } |