blob: f7fb2db13d544c4d2d47cc4075416eedd90ac8d8 [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>
34
35static struct msm_fb_panel_data panel;
36static uint8_t display_enable;
37
38extern int msm_display_init(struct msm_fb_panel_data *pdata);
39extern int msm_display_off();
40
41static int apq8064_lvds_panel_power(int enable)
42{
43 if (enable) {
44 /* Enable LVS7 */
45 pm8921_low_voltage_switch_enable(lvs_7);
46 /* Set and enabale LDO2 1.2V for VDDA_LVDS_PLL*/
47 pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
48
49 /* Enable Ext 3.3V - MSM GPIO 77*/
50 apq8064_ext_3p3V_enable();
51
52 apq8064_display_gpio_init();
53
54 /* Configure PMM MPP 3*/
55 pm8921_mpp_set_digital_output(mpp_3);
56 }
57
58 return 0;
59}
60
61static int apq8064_lvds_clock(int enable)
62{
63 if (enable)
64 mdp_clock_init();
65
66 return 0;
67}
68
69static int fusion3_mtp_panel_power(int enable)
70{
71 if (enable) {
72 /* Enable LVS7 */
73 pm8921_low_voltage_switch_enable(7);
74
75 /* Set and enabale LDO2 1.2V for VDDA_MIPI_DSI0/1_PLL */
76 pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
77
78 /* Set and enabale LDO11 3.0V for LCD1_MIPI_AVDD */
79 pm8921_ldo_set_voltage(LDO_11, LDO_VOLTAGE_3_0V);
80
81 apq8064_display_gpio_init();
82 }
83
84 return 0;
85}
86
87static int fusion3_mtp_clock(int enable)
88{
89 if (enable) {
90 mdp_clock_init();
91 mmss_clock_init();
92 } else {
93#if (!CONT_SPLASH_SCREEN)
94 mmss_clock_disable();
95#endif
96 }
97
98 return 0;
99}
100
101static void msm8960_backlight_on(void)
102{
103 struct pm8921_gpio backlight_pwm = {
104 .direction = PM_GPIO_DIR_OUT,
105 .output_buffer = 0,
106 .output_value = 0,
107 .pull = PM_GPIO_PULL_NO,
108 .vin_sel = 2,
109 .out_strength = PM_GPIO_STRENGTH_HIGH,
110 .function = PM_GPIO_FUNC_1,
111 .inv_int_pol = 0,
112 };
113
114 int rc = pm8921_gpio_config(PM_GPIO(24), &backlight_pwm);
115 if (rc)
116 dprintf(CRITICAL, "FAIL pm8921_gpio_config(): rc=%d.\n", rc);
117}
118
119/* Pull DISP_RST_N high to get panel out of reset */
120static void msm8960_mipi_panel_reset(void)
121{
122 struct pm8921_gpio gpio43_param = {
123 .direction = PM_GPIO_DIR_OUT,
124 .output_buffer = 0,
125 .output_value = 1,
126 .pull = PM_GPIO_PULL_UP_30,
127 .vin_sel = 2,
128 .out_strength = PM_GPIO_STRENGTH_HIGH,
129 .function = PM_GPIO_FUNC_PAIRED,
130 .inv_int_pol = 0,
131 .disable_pin = 0,
132 };
133 pm8921_gpio_config(PM_GPIO(43), &gpio43_param);
134}
135
136static int msm8960_mipi_panel_clock(int enable)
137{
138 if (enable) {
139 mdp_clock_init();
140 mmss_clock_init();
141 } else {
142#if (!CONT_SPLASH_SCREEN)
143 mmss_clock_disable();
144#endif
145 }
146
147 return 0;
148}
149
150static int msm8960_mipi_panel_power(int enable)
151{
152 if (enable) {
153 msm8960_backlight_on();
154
155 /* Turn on LDO8 for lcd1 mipi vdd */
156 pm8921_ldo_set_voltage(LDO_8, LDO_VOLTAGE_3_0V);
157
158 /* Turn on LDO23 for lcd1 mipi vddio */
159 pm8921_ldo_set_voltage(LDO_23, LDO_VOLTAGE_1_8V);
160
161 /* Turn on LDO2 for vdda_mipi_dsi */
162 pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
163
164 msm8960_mipi_panel_reset();
165 }
166
167 return 0;
168}
169
170void display_init(void)
171{
172 dprintf(CRITICAL, "display_init\n");
173
174 switch (board_target_id()) {
175 case LINUX_MACHTYPE_8064_CDP:
176 lvds_chimei_wxga_init(&(panel.panel_info));
177 panel.clk_func = apq8064_lvds_clock;
178 panel.power_func = apq8064_lvds_panel_power;
179 panel.fb.base = 0x80B00000;
180 panel.fb.width = panel.panel_info.xres;
181 panel.fb.height = panel.panel_info.yres;
182 panel.fb.stride = panel.panel_info.xres;
183 panel.fb.bpp = panel.panel_info.bpp;
184 panel.fb.format = FB_FORMAT_RGB888;
185 panel.mdp_rev = MDP_REV_44;
186 break;
187 case LINUX_MACHTYPE_8064_MTP:
188 mipi_toshiba_video_wsvga_init(&(panel.panel_info));
189 panel.clk_func = fusion3_mtp_clock;
190 panel.power_func = fusion3_mtp_panel_power;
191 panel.fb.base = 0x89000000;
192 panel.fb.width = panel.panel_info.xres;
193 panel.fb.height = panel.panel_info.yres;
194 panel.fb.stride = panel.panel_info.xres;
195 panel.fb.bpp = panel.panel_info.bpp;
196 panel.fb.format = FB_FORMAT_RGB888;
197 panel.mdp_rev = MDP_REV_44;
198 break;
199 case LINUX_MACHTYPE_8960_CDP:
200 case LINUX_MACHTYPE_8960_MTP:
201 case LINUX_MACHTYPE_8960_FLUID:
Shashank Mittal3750dda2012-05-17 10:43:55 -0700202 case LINUX_MACHTYPE_8960_LIQUID:
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700203 mipi_toshiba_video_wsvga_init(&(panel.panel_info));
204 panel.clk_func = msm8960_mipi_panel_clock;
205 panel.power_func = msm8960_mipi_panel_power;
206 panel.fb.base = 0x89000000;
207 panel.fb.width = panel.panel_info.xres;
208 panel.fb.height = panel.panel_info.yres;
209 panel.fb.stride = panel.panel_info.xres;
210 panel.fb.bpp = panel.panel_info.bpp;
211 panel.fb.format = FB_FORMAT_RGB888;
212 panel.mdp_rev = MDP_REV_42;
213 break;
214 default:
215 return;
216 };
217
218 if (msm_display_init(&panel)) {
Channagoud Kadabi898453d2012-06-06 11:14:35 +0530219 dprintf(CRITICAL, "Display init failed!\n");
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700220 return;
221 }
222
223 display_image_on_screen();
224 display_enable = 1;
225}
226
227void display_shutdown(void)
228{
229 if (display_enable)
230 msm_display_off();
231}
232