blob: a4d8f6afc7d8df404142befae88b3ea111a16218 [file] [log] [blame]
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -08001/* Copyright (c) 2012-2013, The Linux Foundation. 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
5 * are 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 copyright
9 * notice, this list of conditions and the following disclaimer in
10 * the documentation and/or other materials provided with the
11 * distribution.
12 * * Neither the name of The Linux Foundation 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <debug.h>
31#include <smem.h>
32#include <msm_panel.h>
33#include <pm8x41.h>
34#include <pm8x41_wled.h>
35#include <board.h>
36#include <mdp5.h>
37#include <platform/gpio.h>
Asaf Pensoc9080dc2013-05-21 21:53:50 +030038#include <platform/clock.h>
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -080039#include <target/display.h>
40
41static struct msm_fb_panel_data panel;
42static uint8_t display_enable;
43
44extern int msm_display_init(struct msm_fb_panel_data *pdata);
45extern int msm_display_off();
46extern int mdss_dsi_uniphy_pll_config(void);
Asaf Penso325f43a2013-05-21 21:55:48 +030047extern int mdss_sharp_dsi_uniphy_pll_config(void);
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -080048
Asaf Penso0ecd86f2013-05-29 14:49:19 +030049static struct pm8x41_wled_data wled_ctrl = {
50 .mod_scheme = 0xC3,
51 .led1_brightness = (0x0F << 8) | 0xEF,
52 .led2_brightness = (0x0F << 8) | 0xEF,
53 .led3_brightness = (0x0F << 8) | 0xEF,
54 .max_duty_cycle = 0x01,
55 .ovp = 0x2,
56 .full_current_scale = 0x19
57};
58
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -080059static int msm8974_backlight_on()
60{
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -080061 pm8x41_wled_config(&wled_ctrl);
62 pm8x41_wled_sink_control(1);
63 pm8x41_wled_iled_sync_control(1);
64 pm8x41_wled_enable(1);
65
66 return 0;
67}
68
69static int msm8974_mdss_dsi_panel_clock(uint8_t enable)
70{
71 if (enable) {
72 mdp_gdsc_ctrl(enable);
73 mdp_clock_init();
74 mdss_dsi_uniphy_pll_config();
Siddhartha Agrawal70577592013-05-23 15:10:09 -070075 mmss_clock_init(DSI0_PHY_PLL_OUT);
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -080076 } else if(!target_cont_splash_screen()) {
77 // * Add here for continuous splash *
Siddhartha Agrawalc43c4872013-04-21 16:23:16 -070078 mmss_clock_disable();
79 mdp_clock_disable();
80 mdp_gdsc_ctrl(enable);
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -080081 }
82
83 return 0;
84}
85
Asaf Penso325f43a2013-05-21 21:55:48 +030086static int msm8974_mdss_sharp_dsi_panel_clock(uint8_t enable)
87{
88 if (enable) {
89 mdp_gdsc_ctrl(enable);
90 mdp_clock_init();
91 mdss_sharp_dsi_uniphy_pll_config();
92 mmss_clock_init(DSI0_PHY_PLL_OUT);
93 } else if (!target_cont_splash_screen()) {
94 /* Add here for continuous splash */
95 mmss_clock_disable();
96 mdp_clock_disable();
97 mdp_gdsc_ctrl(enable);
98 }
99
100 return 0;
101}
102
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800103/* Pull DISP_RST_N high to get panel out of reset */
Siddhartha Agrawalc43c4872013-04-21 16:23:16 -0700104static void msm8974_mdss_mipi_panel_reset(uint8_t enable)
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800105{
106 struct pm8x41_gpio gpio19_param = {
107 .direction = PM_GPIO_DIR_OUT,
108 .output_buffer = PM_GPIO_OUT_CMOS,
109 .out_strength = PM_GPIO_OUT_DRIVE_MED,
110 };
111
112 pm8x41_gpio_config(19, &gpio19_param);
Siddhartha Agrawalc43c4872013-04-21 16:23:16 -0700113 if (enable) {
114 gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE);
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800115
Siddhartha Agrawalc43c4872013-04-21 16:23:16 -0700116 pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH);
117 mdelay(2);
118 pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW);
119 mdelay(5);
120 pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH);
121 mdelay(2);
122 gpio_set(58, 2);
123 } else {
124 gpio19_param.out_strength = PM_GPIO_OUT_DRIVE_LOW;
125 pm8x41_gpio_config(19, &gpio19_param);
126 pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW);
127 gpio_set(58, 2);
128 }
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800129}
130
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800131static int msm8974_mipi_panel_power(uint8_t enable)
132{
133 if (enable) {
134
135 /* Enable backlight */
136 msm8974_backlight_on();
137
138 /* Turn on LDO8 for lcd1 mipi vdd */
139 dprintf(SPEW, " Setting LDO22\n");
140 pm8x41_ldo_set_voltage("LDO22", 3000000);
141 pm8x41_ldo_control("LDO22", enable);
142
143 dprintf(SPEW, " Setting LDO12\n");
144 /* Turn on LDO23 for lcd1 mipi vddio */
145 pm8x41_ldo_set_voltage("LDO12", 1800000);
146 pm8x41_ldo_control("LDO12", enable);
147
148 dprintf(SPEW, " Setting LDO2\n");
149 /* Turn on LDO2 for vdda_mipi_dsi */
150 pm8x41_ldo_set_voltage("LDO2", 1200000);
151 pm8x41_ldo_control("LDO2", enable);
152
153 dprintf(SPEW, " Panel Reset \n");
154 /* Panel Reset */
Siddhartha Agrawalc43c4872013-04-21 16:23:16 -0700155 msm8974_mdss_mipi_panel_reset(enable);
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800156 dprintf(SPEW, " Panel Reset Done\n");
Siddhartha Agrawalc43c4872013-04-21 16:23:16 -0700157 } else {
158 msm8974_mdss_mipi_panel_reset(enable);
159 pm8x41_wled_enable(enable);
160 pm8x41_ldo_control("LDO2", enable);
161 pm8x41_ldo_control("LDO22", enable);
162
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800163 }
164
165 return 0;
166}
167
168void display_init(void)
169{
170 uint32_t hw_id = board_hardware_id();
Channagoud Kadabi1cc5e9c2013-02-11 14:50:15 -0800171 uint32_t soc_ver = board_soc_version();
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800172
173 dprintf(INFO, "display_init(),target_id=%d.\n", hw_id);
174
175 switch (hw_id) {
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800176 case HW_PLATFORM_MTP:
177 case HW_PLATFORM_FLUID:
Siddhartha Agrawal17a6b832013-02-17 18:36:25 -0800178 case HW_PLATFORM_SURF:
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800179 mipi_toshiba_video_720p_init(&(panel.panel_info));
180 panel.clk_func = msm8974_mdss_dsi_panel_clock;
181 panel.power_func = msm8974_mipi_panel_power;
182 panel.fb.base = MIPI_FB_ADDR;
183 panel.fb.width = panel.panel_info.xres;
184 panel.fb.height = panel.panel_info.yres;
185 panel.fb.stride = panel.panel_info.xres;
186 panel.fb.bpp = panel.panel_info.bpp;
187 panel.fb.format = FB_FORMAT_RGB888;
188 panel.mdp_rev = MDP_REV_50;
189 break;
Asaf Penso325f43a2013-05-21 21:55:48 +0300190 case HW_PLATFORM_DRAGON:
191 mipi_sharp_video_qhd_init(&(panel.panel_info));
192 panel.clk_func = msm8974_mdss_sharp_dsi_panel_clock;
193 panel.power_func = msm8974_mipi_panel_power;
194 panel.fb.base = MIPI_FB_ADDR;
195 panel.fb.width = panel.panel_info.xres;
196 panel.fb.height = panel.panel_info.yres;
197 panel.fb.stride = panel.panel_info.xres;
198 panel.fb.bpp = panel.panel_info.bpp;
199 panel.fb.format = FB_FORMAT_RGB888;
200 panel.mdp_rev = MDP_REV_50;
201 break;
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800202 default:
203 return;
204 };
205
206 if (msm_display_init(&panel)) {
207 dprintf(CRITICAL, "Display init failed!\n");
208 return;
209 }
210
211 display_enable = 1;
212}
213
214void display_shutdown(void)
215{
216 if (display_enable)
217 msm_display_off();
218}