blob: 9a27bf1e4dc09099f4a9de10053cdfbade35484b [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();
Amol Jadi6834f1a2012-06-29 14:42:59 -070092 } else if(!target_cont_splash_screen()) {
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070093 mmss_clock_disable();
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070094 }
95
96 return 0;
97}
98
99static void msm8960_backlight_on(void)
100{
101 struct pm8921_gpio backlight_pwm = {
102 .direction = PM_GPIO_DIR_OUT,
103 .output_buffer = 0,
104 .output_value = 0,
105 .pull = PM_GPIO_PULL_NO,
106 .vin_sel = 2,
107 .out_strength = PM_GPIO_STRENGTH_HIGH,
108 .function = PM_GPIO_FUNC_1,
109 .inv_int_pol = 0,
110 };
111
112 int rc = pm8921_gpio_config(PM_GPIO(24), &backlight_pwm);
113 if (rc)
114 dprintf(CRITICAL, "FAIL pm8921_gpio_config(): rc=%d.\n", rc);
115}
116
117/* Pull DISP_RST_N high to get panel out of reset */
118static void msm8960_mipi_panel_reset(void)
119{
120 struct pm8921_gpio gpio43_param = {
121 .direction = PM_GPIO_DIR_OUT,
122 .output_buffer = 0,
123 .output_value = 1,
124 .pull = PM_GPIO_PULL_UP_30,
125 .vin_sel = 2,
126 .out_strength = PM_GPIO_STRENGTH_HIGH,
127 .function = PM_GPIO_FUNC_PAIRED,
128 .inv_int_pol = 0,
129 .disable_pin = 0,
130 };
131 pm8921_gpio_config(PM_GPIO(43), &gpio43_param);
132}
133
134static int msm8960_mipi_panel_clock(int enable)
135{
136 if (enable) {
137 mdp_clock_init();
138 mmss_clock_init();
Amol Jadi6834f1a2012-06-29 14:42:59 -0700139 } else if(!target_cont_splash_screen()) {
140 mmss_clock_disable();
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700141 }
142
143 return 0;
144}
145
146static int msm8960_mipi_panel_power(int enable)
147{
148 if (enable) {
149 msm8960_backlight_on();
150
151 /* Turn on LDO8 for lcd1 mipi vdd */
152 pm8921_ldo_set_voltage(LDO_8, LDO_VOLTAGE_3_0V);
153
154 /* Turn on LDO23 for lcd1 mipi vddio */
155 pm8921_ldo_set_voltage(LDO_23, LDO_VOLTAGE_1_8V);
156
157 /* Turn on LDO2 for vdda_mipi_dsi */
158 pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
159
160 msm8960_mipi_panel_reset();
161 }
162
163 return 0;
164}
165
166void display_init(void)
167{
168 dprintf(CRITICAL, "display_init\n");
169
170 switch (board_target_id()) {
171 case LINUX_MACHTYPE_8064_CDP:
172 lvds_chimei_wxga_init(&(panel.panel_info));
173 panel.clk_func = apq8064_lvds_clock;
174 panel.power_func = apq8064_lvds_panel_power;
175 panel.fb.base = 0x80B00000;
176 panel.fb.width = panel.panel_info.xres;
177 panel.fb.height = panel.panel_info.yres;
178 panel.fb.stride = panel.panel_info.xres;
179 panel.fb.bpp = panel.panel_info.bpp;
180 panel.fb.format = FB_FORMAT_RGB888;
181 panel.mdp_rev = MDP_REV_44;
182 break;
183 case LINUX_MACHTYPE_8064_MTP:
184 mipi_toshiba_video_wsvga_init(&(panel.panel_info));
185 panel.clk_func = fusion3_mtp_clock;
186 panel.power_func = fusion3_mtp_panel_power;
187 panel.fb.base = 0x89000000;
188 panel.fb.width = panel.panel_info.xres;
189 panel.fb.height = panel.panel_info.yres;
190 panel.fb.stride = panel.panel_info.xres;
191 panel.fb.bpp = panel.panel_info.bpp;
192 panel.fb.format = FB_FORMAT_RGB888;
193 panel.mdp_rev = MDP_REV_44;
194 break;
195 case LINUX_MACHTYPE_8960_CDP:
196 case LINUX_MACHTYPE_8960_MTP:
197 case LINUX_MACHTYPE_8960_FLUID:
Shashank Mittal3750dda2012-05-17 10:43:55 -0700198 case LINUX_MACHTYPE_8960_LIQUID:
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700199 mipi_toshiba_video_wsvga_init(&(panel.panel_info));
200 panel.clk_func = msm8960_mipi_panel_clock;
201 panel.power_func = msm8960_mipi_panel_power;
202 panel.fb.base = 0x89000000;
203 panel.fb.width = panel.panel_info.xres;
204 panel.fb.height = panel.panel_info.yres;
205 panel.fb.stride = panel.panel_info.xres;
206 panel.fb.bpp = panel.panel_info.bpp;
207 panel.fb.format = FB_FORMAT_RGB888;
208 panel.mdp_rev = MDP_REV_42;
209 break;
210 default:
211 return;
212 };
213
214 if (msm_display_init(&panel)) {
Channagoud Kadabi898453d2012-06-06 11:14:35 +0530215 dprintf(CRITICAL, "Display init failed!\n");
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700216 return;
217 }
218
219 display_image_on_screen();
220 display_enable = 1;
221}
222
223void display_shutdown(void)
224{
225 if (display_enable)
226 msm_display_off();
227}
228