Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. 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 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 Code Aurora Forum, Inc. 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 <msm_panel.h> |
| 31 | #include <dev/pm8921.h> |
| 32 | #include <board.h> |
| 33 | #include <mdp4.h> |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 34 | #include <target/display.h> |
Neeti Desai | 465491e | 2012-07-31 12:53:35 -0700 | [diff] [blame^] | 35 | #include <target/board.h> |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 36 | |
| 37 | static struct msm_fb_panel_data panel; |
| 38 | static uint8_t display_enable; |
| 39 | |
| 40 | extern int msm_display_init(struct msm_fb_panel_data *pdata); |
| 41 | extern int msm_display_off(); |
| 42 | |
| 43 | static int apq8064_lvds_panel_power(int enable) |
| 44 | { |
| 45 | if (enable) { |
| 46 | /* Enable LVS7 */ |
| 47 | pm8921_low_voltage_switch_enable(lvs_7); |
| 48 | /* Set and enabale LDO2 1.2V for VDDA_LVDS_PLL*/ |
| 49 | pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V); |
| 50 | |
| 51 | /* Enable Ext 3.3V - MSM GPIO 77*/ |
Amol Jadi | da118b9 | 2012-07-06 19:53:18 -0700 | [diff] [blame] | 52 | /* TODO: IS this really needed? This wasn't even implemented correctly. |
| 53 | * GPIO enable was not happening. |
| 54 | */ |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 55 | apq8064_ext_3p3V_enable(); |
| 56 | |
| 57 | apq8064_display_gpio_init(); |
| 58 | |
| 59 | /* Configure PMM MPP 3*/ |
| 60 | pm8921_mpp_set_digital_output(mpp_3); |
| 61 | } |
| 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static int apq8064_lvds_clock(int enable) |
| 67 | { |
| 68 | if (enable) |
| 69 | mdp_clock_init(); |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | static int fusion3_mtp_panel_power(int enable) |
| 75 | { |
| 76 | if (enable) { |
| 77 | /* Enable LVS7 */ |
| 78 | pm8921_low_voltage_switch_enable(7); |
| 79 | |
| 80 | /* Set and enabale LDO2 1.2V for VDDA_MIPI_DSI0/1_PLL */ |
| 81 | pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V); |
| 82 | |
| 83 | /* Set and enabale LDO11 3.0V for LCD1_MIPI_AVDD */ |
| 84 | pm8921_ldo_set_voltage(LDO_11, LDO_VOLTAGE_3_0V); |
| 85 | |
| 86 | apq8064_display_gpio_init(); |
| 87 | } |
| 88 | |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | static int fusion3_mtp_clock(int enable) |
| 93 | { |
| 94 | if (enable) { |
| 95 | mdp_clock_init(); |
| 96 | mmss_clock_init(); |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 97 | } else if(!target_cont_splash_screen()) { |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 98 | mmss_clock_disable(); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | static void msm8960_backlight_on(void) |
| 105 | { |
| 106 | struct pm8921_gpio backlight_pwm = { |
| 107 | .direction = PM_GPIO_DIR_OUT, |
| 108 | .output_buffer = 0, |
| 109 | .output_value = 0, |
| 110 | .pull = PM_GPIO_PULL_NO, |
| 111 | .vin_sel = 2, |
| 112 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 113 | .function = PM_GPIO_FUNC_1, |
| 114 | .inv_int_pol = 0, |
| 115 | }; |
| 116 | |
| 117 | int rc = pm8921_gpio_config(PM_GPIO(24), &backlight_pwm); |
| 118 | if (rc) |
| 119 | dprintf(CRITICAL, "FAIL pm8921_gpio_config(): rc=%d.\n", rc); |
| 120 | } |
| 121 | |
| 122 | /* Pull DISP_RST_N high to get panel out of reset */ |
| 123 | static void msm8960_mipi_panel_reset(void) |
| 124 | { |
| 125 | struct pm8921_gpio gpio43_param = { |
| 126 | .direction = PM_GPIO_DIR_OUT, |
| 127 | .output_buffer = 0, |
| 128 | .output_value = 1, |
| 129 | .pull = PM_GPIO_PULL_UP_30, |
| 130 | .vin_sel = 2, |
| 131 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 132 | .function = PM_GPIO_FUNC_PAIRED, |
| 133 | .inv_int_pol = 0, |
| 134 | .disable_pin = 0, |
| 135 | }; |
| 136 | pm8921_gpio_config(PM_GPIO(43), &gpio43_param); |
| 137 | } |
| 138 | |
| 139 | static int msm8960_mipi_panel_clock(int enable) |
| 140 | { |
| 141 | if (enable) { |
| 142 | mdp_clock_init(); |
| 143 | mmss_clock_init(); |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 144 | } else if(!target_cont_splash_screen()) { |
| 145 | mmss_clock_disable(); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 151 | static int msm8960_liquid_mipi_panel_clock(int enable) |
| 152 | { |
| 153 | if (enable) { |
| 154 | mdp_clock_init(); |
| 155 | liquid_mmss_clock_init(); /* 240 MHZ MIPI-DSI clk */ |
| 156 | } else if(!target_cont_splash_screen()) { |
| 157 | mmss_clock_disable(); |
| 158 | } |
| 159 | |
| 160 | return 0; |
| 161 | } |
| 162 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 163 | static int msm8960_mipi_panel_power(int enable) |
| 164 | { |
| 165 | if (enable) { |
| 166 | msm8960_backlight_on(); |
| 167 | |
| 168 | /* Turn on LDO8 for lcd1 mipi vdd */ |
| 169 | pm8921_ldo_set_voltage(LDO_8, LDO_VOLTAGE_3_0V); |
| 170 | |
| 171 | /* Turn on LDO23 for lcd1 mipi vddio */ |
| 172 | pm8921_ldo_set_voltage(LDO_23, LDO_VOLTAGE_1_8V); |
| 173 | |
| 174 | /* Turn on LDO2 for vdda_mipi_dsi */ |
| 175 | pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V); |
| 176 | |
| 177 | msm8960_mipi_panel_reset(); |
| 178 | } |
| 179 | |
| 180 | return 0; |
| 181 | } |
| 182 | |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 183 | #define PM_GPIO_VIN_VPH 0 /* 3v ~ 4.4v */ |
| 184 | #define PM_GPIO_VIN_BB 1 /* ~3.3v */ |
| 185 | #define PM_GPIO_VIN_S4 2 /* 1.8v */ |
| 186 | #define PM_GPIO_VIN_L15 3 |
| 187 | |
| 188 | static int msm8960_liquid_mipi_panel_power(int enable) |
| 189 | { |
| 190 | if (enable) { |
| 191 | static int gpio17, gpio21, gpio43 ; |
| 192 | int rc; |
| 193 | |
| 194 | struct pm8921_gpio gpio_config = { |
| 195 | .direction = PM_GPIO_DIR_OUT, |
| 196 | .output_buffer = 0, |
| 197 | .output_value = 1, |
| 198 | .pull = PM_GPIO_PULL_NO, |
| 199 | .vin_sel = PM_GPIO_VIN_S4, |
| 200 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 201 | .function = PM_GPIO_FUNC_NORMAL, |
| 202 | .inv_int_pol = 0, |
| 203 | .disable_pin = 0, |
| 204 | }; |
| 205 | |
| 206 | /* Note: PWM is controlled by PM-GPIO#24 */ |
| 207 | gpio17 = PM_GPIO(17); /* ext_3p3v */ |
| 208 | gpio21 = PM_GPIO(21); /* disp power enable_n , vin=VPH-PWR */ |
| 209 | gpio43 = PM_GPIO(43); /* Displays Enable (rst_n) */ |
| 210 | |
| 211 | gpio_config.output_value = 1; |
| 212 | rc = pm8921_gpio_config(gpio17, &gpio_config); |
| 213 | mdelay(100); |
| 214 | gpio_config.output_value = 0; |
| 215 | /* disp disable (resx=0) */ |
| 216 | rc = pm8921_gpio_config(gpio43, &gpio_config); |
| 217 | mdelay(100); |
| 218 | gpio_config.output_value = 0; |
| 219 | gpio_config.vin_sel = PM_GPIO_VIN_VPH; /* VPH_PWR */ |
| 220 | /* disp power enable_n */ |
| 221 | rc = pm8921_gpio_config(gpio21, &gpio_config); |
| 222 | mdelay(100); |
| 223 | gpio_config.output_value = 1; |
| 224 | gpio_config.vin_sel = PM_GPIO_VIN_S4; |
| 225 | /* disp enable */ |
| 226 | rc = pm8921_gpio_config(gpio43, &gpio_config); |
| 227 | mdelay(100); |
| 228 | |
| 229 | pm8921_low_voltage_switch_enable(lvs_4); /* S4 1.8 V */ |
| 230 | |
| 231 | /* Turn on LDO2 for vdda_mipi_dsi */ |
| 232 | pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V); |
| 233 | |
| 234 | msm8960_backlight_on(); |
| 235 | } |
| 236 | |
| 237 | return 0; |
| 238 | } |
| 239 | |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 240 | void display_init(void) |
| 241 | { |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 242 | int target_id = board_target_id(); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 243 | |
Amir Samuelov | 2d4ba16 | 2012-07-22 11:53:14 +0300 | [diff] [blame] | 244 | dprintf(INFO, "display_init(),target_id=%d.\n", target_id); |
| 245 | |
| 246 | switch (target_id) { |
| 247 | case LINUX_MACHTYPE_8960_LIQUID: |
| 248 | mipi_chimei_video_wxga_init(&(panel.panel_info)); |
| 249 | /* |
| 250 | * mipi_chimei_wxga panel not supported yet in LK. |
| 251 | * However, MIPI clocks and power should be set in LK. |
| 252 | */ |
| 253 | panel.clk_func = msm8960_liquid_mipi_panel_clock; |
| 254 | panel.power_func = msm8960_liquid_mipi_panel_power; |
| 255 | panel.fb.base = MIPI_FB_ADDR; |
| 256 | panel.fb.width = panel.panel_info.xres; |
| 257 | panel.fb.height = panel.panel_info.yres; |
| 258 | panel.fb.stride = panel.panel_info.xres; |
| 259 | panel.fb.bpp = panel.panel_info.bpp; |
| 260 | panel.fb.format = FB_FORMAT_RGB888; |
| 261 | panel.mdp_rev = MDP_REV_44; |
| 262 | break; |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 263 | case LINUX_MACHTYPE_8064_CDP: |
| 264 | lvds_chimei_wxga_init(&(panel.panel_info)); |
| 265 | panel.clk_func = apq8064_lvds_clock; |
| 266 | panel.power_func = apq8064_lvds_panel_power; |
| 267 | panel.fb.base = 0x80B00000; |
| 268 | panel.fb.width = panel.panel_info.xres; |
| 269 | panel.fb.height = panel.panel_info.yres; |
| 270 | panel.fb.stride = panel.panel_info.xres; |
| 271 | panel.fb.bpp = panel.panel_info.bpp; |
| 272 | panel.fb.format = FB_FORMAT_RGB888; |
| 273 | panel.mdp_rev = MDP_REV_44; |
| 274 | break; |
| 275 | case LINUX_MACHTYPE_8064_MTP: |
| 276 | mipi_toshiba_video_wsvga_init(&(panel.panel_info)); |
| 277 | panel.clk_func = fusion3_mtp_clock; |
| 278 | panel.power_func = fusion3_mtp_panel_power; |
| 279 | panel.fb.base = 0x89000000; |
| 280 | panel.fb.width = panel.panel_info.xres; |
| 281 | panel.fb.height = panel.panel_info.yres; |
| 282 | panel.fb.stride = panel.panel_info.xres; |
| 283 | panel.fb.bpp = panel.panel_info.bpp; |
| 284 | panel.fb.format = FB_FORMAT_RGB888; |
| 285 | panel.mdp_rev = MDP_REV_44; |
| 286 | break; |
| 287 | case LINUX_MACHTYPE_8960_CDP: |
| 288 | case LINUX_MACHTYPE_8960_MTP: |
| 289 | case LINUX_MACHTYPE_8960_FLUID: |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 290 | mipi_toshiba_video_wsvga_init(&(panel.panel_info)); |
| 291 | panel.clk_func = msm8960_mipi_panel_clock; |
| 292 | panel.power_func = msm8960_mipi_panel_power; |
| 293 | panel.fb.base = 0x89000000; |
| 294 | panel.fb.width = panel.panel_info.xres; |
| 295 | panel.fb.height = panel.panel_info.yres; |
| 296 | panel.fb.stride = panel.panel_info.xres; |
| 297 | panel.fb.bpp = panel.panel_info.bpp; |
| 298 | panel.fb.format = FB_FORMAT_RGB888; |
| 299 | panel.mdp_rev = MDP_REV_42; |
| 300 | break; |
| 301 | default: |
| 302 | return; |
| 303 | }; |
| 304 | |
| 305 | if (msm_display_init(&panel)) { |
Channagoud Kadabi | 898453d | 2012-06-06 11:14:35 +0530 | [diff] [blame] | 306 | dprintf(CRITICAL, "Display init failed!\n"); |
Shashank Mittal | 4bfb2e3 | 2012-04-16 10:56:27 -0700 | [diff] [blame] | 307 | return; |
| 308 | } |
| 309 | |
| 310 | display_image_on_screen(); |
| 311 | display_enable = 1; |
| 312 | } |
| 313 | |
| 314 | void display_shutdown(void) |
| 315 | { |
| 316 | if (display_enable) |
| 317 | msm_display_off(); |
| 318 | } |
| 319 | |