blob: 2eec1eaa7e12de91c1c57b3480d55872860045d5 [file] [log] [blame]
Aravind Venkateswarandd50c1a2014-02-25 14:42:43 -08001/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07002 *
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.
Duy Truongf3ac7b32013-02-13 01:07:28 -080012 * * Neither the name of The Linux Foundation nor the names of its
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070013 * 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>
Neeti Desai465491e2012-07-31 12:53:35 -070035#include <target/board.h>
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070036
37static struct msm_fb_panel_data panel;
38static uint8_t display_enable;
39
40extern int msm_display_init(struct msm_fb_panel_data *pdata);
41extern int msm_display_off();
42
43static 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 Jadida118b92012-07-06 19:53:18 -070052 /* TODO: IS this really needed? This wasn't even implemented correctly.
53 * GPIO enable was not happening.
54 */
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070055 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
66static int apq8064_lvds_clock(int enable)
67{
68 if (enable)
69 mdp_clock_init();
70
71 return 0;
72}
73
74static 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
92static int fusion3_mtp_clock(int enable)
93{
94 if (enable) {
95 mdp_clock_init();
96 mmss_clock_init();
Amol Jadi6834f1a2012-06-29 14:42:59 -070097 } else if(!target_cont_splash_screen()) {
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070098 mmss_clock_disable();
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070099 }
100
101 return 0;
102}
103
104static 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 */
123static 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
139static int msm8960_mipi_panel_clock(int enable)
140{
141 if (enable) {
142 mdp_clock_init();
143 mmss_clock_init();
Amol Jadi6834f1a2012-06-29 14:42:59 -0700144 } else if(!target_cont_splash_screen()) {
145 mmss_clock_disable();
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700146 }
147
148 return 0;
149}
150
Ajay Singh Parmarfdab1ec2013-02-13 20:35:50 +0530151static int mpq8064_hdmi_panel_clock(int enable)
152{
153 if (enable)
154 mdp_clock_init();
155
156 hdmi_app_clk_init(enable);
157
158 return 0;
159}
160
161static int mpq8064_hdmi_panel_power(int enable)
162{
163 if (enable)
164 hdmi_power_init();
165
166 return 0;
167}
168
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300169static int msm8960_liquid_mipi_panel_clock(int enable)
170{
171 if (enable) {
172 mdp_clock_init();
173 liquid_mmss_clock_init(); /* 240 MHZ MIPI-DSI clk */
174 } else if(!target_cont_splash_screen()) {
175 mmss_clock_disable();
176 }
177
178 return 0;
179}
180
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700181static int msm8960_mipi_panel_power(int enable)
182{
183 if (enable) {
184 msm8960_backlight_on();
185
186 /* Turn on LDO8 for lcd1 mipi vdd */
187 pm8921_ldo_set_voltage(LDO_8, LDO_VOLTAGE_3_0V);
188
189 /* Turn on LDO23 for lcd1 mipi vddio */
190 pm8921_ldo_set_voltage(LDO_23, LDO_VOLTAGE_1_8V);
191
192 /* Turn on LDO2 for vdda_mipi_dsi */
193 pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
194
195 msm8960_mipi_panel_reset();
196 }
197
198 return 0;
199}
200
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300201#define PM_GPIO_VIN_VPH 0 /* 3v ~ 4.4v */
202#define PM_GPIO_VIN_BB 1 /* ~3.3v */
203#define PM_GPIO_VIN_S4 2 /* 1.8v */
204#define PM_GPIO_VIN_L15 3
205
206static int msm8960_liquid_mipi_panel_power(int enable)
207{
208 if (enable) {
209 static int gpio17, gpio21, gpio43 ;
210 int rc;
211
212 struct pm8921_gpio gpio_config = {
213 .direction = PM_GPIO_DIR_OUT,
214 .output_buffer = 0,
215 .output_value = 1,
216 .pull = PM_GPIO_PULL_NO,
217 .vin_sel = PM_GPIO_VIN_S4,
218 .out_strength = PM_GPIO_STRENGTH_HIGH,
219 .function = PM_GPIO_FUNC_NORMAL,
220 .inv_int_pol = 0,
221 .disable_pin = 0,
222 };
223
224 /* Note: PWM is controlled by PM-GPIO#24 */
225 gpio17 = PM_GPIO(17); /* ext_3p3v */
226 gpio21 = PM_GPIO(21); /* disp power enable_n , vin=VPH-PWR */
227 gpio43 = PM_GPIO(43); /* Displays Enable (rst_n) */
228
229 gpio_config.output_value = 1;
230 rc = pm8921_gpio_config(gpio17, &gpio_config);
231 mdelay(100);
232 gpio_config.output_value = 0;
233 /* disp disable (resx=0) */
234 rc = pm8921_gpio_config(gpio43, &gpio_config);
235 mdelay(100);
236 gpio_config.output_value = 0;
237 gpio_config.vin_sel = PM_GPIO_VIN_VPH; /* VPH_PWR */
238 /* disp power enable_n */
239 rc = pm8921_gpio_config(gpio21, &gpio_config);
240 mdelay(100);
241 gpio_config.output_value = 1;
242 gpio_config.vin_sel = PM_GPIO_VIN_S4;
243 /* disp enable */
244 rc = pm8921_gpio_config(gpio43, &gpio_config);
245 mdelay(100);
246
247 pm8921_low_voltage_switch_enable(lvs_4); /* S4 1.8 V */
248
249 /* Turn on LDO2 for vdda_mipi_dsi */
250 pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
251
252 msm8960_backlight_on();
253 }
254
255 return 0;
256}
257
Aravind Venkateswaran6385f7e2014-02-25 16:45:11 -0800258void target_display_init(const char *panel_name)
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700259{
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300260 int target_id = board_target_id();
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700261
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300262 dprintf(INFO, "display_init(),target_id=%d.\n", target_id);
263
264 switch (target_id) {
265 case LINUX_MACHTYPE_8960_LIQUID:
266 mipi_chimei_video_wxga_init(&(panel.panel_info));
267 /*
268 * mipi_chimei_wxga panel not supported yet in LK.
269 * However, MIPI clocks and power should be set in LK.
270 */
271 panel.clk_func = msm8960_liquid_mipi_panel_clock;
272 panel.power_func = msm8960_liquid_mipi_panel_power;
273 panel.fb.base = MIPI_FB_ADDR;
274 panel.fb.width = panel.panel_info.xres;
275 panel.fb.height = panel.panel_info.yres;
276 panel.fb.stride = panel.panel_info.xres;
277 panel.fb.bpp = panel.panel_info.bpp;
278 panel.fb.format = FB_FORMAT_RGB888;
279 panel.mdp_rev = MDP_REV_44;
280 break;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700281 case LINUX_MACHTYPE_8064_CDP:
282 lvds_chimei_wxga_init(&(panel.panel_info));
283 panel.clk_func = apq8064_lvds_clock;
284 panel.power_func = apq8064_lvds_panel_power;
285 panel.fb.base = 0x80B00000;
286 panel.fb.width = panel.panel_info.xres;
287 panel.fb.height = panel.panel_info.yres;
288 panel.fb.stride = panel.panel_info.xres;
289 panel.fb.bpp = panel.panel_info.bpp;
290 panel.fb.format = FB_FORMAT_RGB888;
291 panel.mdp_rev = MDP_REV_44;
292 break;
293 case LINUX_MACHTYPE_8064_MTP:
294 mipi_toshiba_video_wsvga_init(&(panel.panel_info));
295 panel.clk_func = fusion3_mtp_clock;
296 panel.power_func = fusion3_mtp_panel_power;
297 panel.fb.base = 0x89000000;
298 panel.fb.width = panel.panel_info.xres;
299 panel.fb.height = panel.panel_info.yres;
300 panel.fb.stride = panel.panel_info.xres;
301 panel.fb.bpp = panel.panel_info.bpp;
302 panel.fb.format = FB_FORMAT_RGB888;
303 panel.mdp_rev = MDP_REV_44;
304 break;
305 case LINUX_MACHTYPE_8960_CDP:
306 case LINUX_MACHTYPE_8960_MTP:
307 case LINUX_MACHTYPE_8960_FLUID:
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700308 mipi_toshiba_video_wsvga_init(&(panel.panel_info));
309 panel.clk_func = msm8960_mipi_panel_clock;
310 panel.power_func = msm8960_mipi_panel_power;
311 panel.fb.base = 0x89000000;
312 panel.fb.width = panel.panel_info.xres;
313 panel.fb.height = panel.panel_info.yres;
314 panel.fb.stride = panel.panel_info.xres;
315 panel.fb.bpp = panel.panel_info.bpp;
316 panel.fb.format = FB_FORMAT_RGB888;
317 panel.mdp_rev = MDP_REV_42;
318 break;
Ajay Singh Parmarfdab1ec2013-02-13 20:35:50 +0530319 case LINUX_MACHTYPE_8064_MPQ_CDP:
320 case LINUX_MACHTYPE_8064_MPQ_HRD:
321 case LINUX_MACHTYPE_8064_MPQ_DTV:
322 hdmi_msm_panel_init(&panel.panel_info);
323
324 panel.clk_func = mpq8064_hdmi_panel_clock;
325 panel.power_func = mpq8064_hdmi_panel_power;
326 panel.fb.base = 0x89000000;
327 panel.fb.width = panel.panel_info.xres;
328 panel.fb.height = panel.panel_info.yres;
329 panel.fb.stride = panel.panel_info.xres;
330 panel.fb.bpp = panel.panel_info.bpp;
331 panel.fb.format = FB_FORMAT_RGB565;
332 panel.mdp_rev = MDP_REV_44;
333
334 hdmi_set_fb_addr(panel.fb.base);
335 break;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700336 default:
337 return;
338 };
339
340 if (msm_display_init(&panel)) {
Channagoud Kadabi898453d2012-06-06 11:14:35 +0530341 dprintf(CRITICAL, "Display init failed!\n");
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700342 return;
343 }
344
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700345 display_enable = 1;
346}
347
Aravind Venkateswarandd50c1a2014-02-25 14:42:43 -0800348void target_display_shutdown(void)
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700349{
Ajay Singh Parmarfdab1ec2013-02-13 20:35:50 +0530350 if (display_enable) {
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700351 msm_display_off();
Ajay Singh Parmarfdab1ec2013-02-13 20:35:50 +0530352 }
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700353}
354