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