blob: fe2e6d5ced88634ca5d4e66798c3d75ba0aba37f [file] [log] [blame]
Jeevan Shriram2d3500b2014-12-29 16:25:06 -08001/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Ray Zhang743e5032013-05-25 23:25:39 +08002 *
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>
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070032#include <err.h>
Ray Zhang743e5032013-05-25 23:25:39 +080033#include <msm_panel.h>
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070034#include <mipi_dsi.h>
Ray Zhang743e5032013-05-25 23:25:39 +080035#include <pm8x41.h>
36#include <pm8x41_wled.h>
37#include <board.h>
38#include <mdp5.h>
Aravind Venkateswaranfada7f32013-09-19 15:23:34 -070039#include <scm.h>
Ray Zhang743e5032013-05-25 23:25:39 +080040#include <platform/gpio.h>
41#include <platform/iomap.h>
42#include <target/display.h>
43
Casey Pipercbdfbd22013-08-14 17:22:16 -070044#include "include/panel.h"
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070045#include "include/display_resource.h"
Veera Sundaram Sankaran87f88132015-01-28 11:32:44 -080046#include "gcdb_display.h"
Ray Zhang743e5032013-05-25 23:25:39 +080047
Dhaval Patel815567c2013-07-31 11:13:25 -070048#define HFPLL_LDO_ID 8
49
Ray Zhang743e5032013-05-25 23:25:39 +080050static struct pm8x41_wled_data wled_ctrl = {
rayzhanga3667cd2013-07-01 12:22:54 +080051 .mod_scheme = 0x00,
Ray Zhang743e5032013-05-25 23:25:39 +080052 .led1_brightness = (0x0F << 8) | 0xEF,
Ray Zhang743e5032013-05-25 23:25:39 +080053 .max_duty_cycle = 0x01,
rayzhanga3667cd2013-07-01 12:22:54 +080054 .ovp = 0x0,
Zhenhua Huangd5355cb2013-09-04 16:03:01 +080055 .full_current_scale = 0x19,
56 .fdbck = 0x1
Ray Zhang743e5032013-05-25 23:25:39 +080057};
58
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053059static uint32_t dsi_pll_enable_seq_m(uint32_t pll_base)
Casey Piperaee81202013-08-26 11:14:02 -070060{
61 uint32_t i = 0;
62 uint32_t pll_locked = 0;
63
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053064 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Casey Piperaee81202013-08-26 11:14:02 -070065
66 /*
67 * Add hardware recommended delays between register writes for
68 * the updates to take effect. These delays are necessary for the
69 * PLL to successfully lock
70 */
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053071 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -070072 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053073 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -070074 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053075 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -070076 udelay(1000);
77
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053078 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
79 pll_locked = readl(pll_base + 0x00c0) & 0x01;
Casey Piperaee81202013-08-26 11:14:02 -070080 for (i = 0; (i < 4) && !pll_locked; i++) {
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053081 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -070082 if (i != 0)
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053083 writel(0x34, pll_base + 0x00070); /* CAL CFG1*/
Casey Piperaee81202013-08-26 11:14:02 -070084 udelay(1);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053085 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -070086 udelay(1000);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053087 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
88 pll_locked = readl(pll_base + 0x00c0) & 0x01;
Casey Piperaee81202013-08-26 11:14:02 -070089 }
90
91 return pll_locked;
92}
93
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053094static uint32_t dsi_pll_enable_seq_d(uint32_t pll_base)
Casey Piperaee81202013-08-26 11:14:02 -070095{
96 uint32_t pll_locked = 0;
97
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053098 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Casey Piperaee81202013-08-26 11:14:02 -070099
100 /*
101 * Add hardware recommended delays between register writes for
102 * the updates to take effect. These delays are necessary for the
103 * PLL to successfully lock
104 */
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530105 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700106 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530107 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700108 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530109 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700110 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530111 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700112 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530113 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700114 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530115 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700116 udelay(1000);
117
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530118 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
119 pll_locked = readl(pll_base + 0x00c0) & 0x01;
Casey Piperaee81202013-08-26 11:14:02 -0700120
121 return pll_locked;
122}
123
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530124static uint32_t dsi_pll_enable_seq_f1(uint32_t pll_base)
Casey Piperaee81202013-08-26 11:14:02 -0700125{
126 uint32_t pll_locked = 0;
127
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530128 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Casey Piperaee81202013-08-26 11:14:02 -0700129
130 /*
131 * Add hardware recommended delays between register writes for
132 * the updates to take effect. These delays are necessary for the
133 * PLL to successfully lock
134 */
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530135 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700136 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530137 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700138 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530139 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700140 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530141 writel(0x0d, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700142 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530143 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700144 udelay(1000);
145
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530146 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
147 pll_locked = readl(pll_base + 0x00c0) & 0x01;
Casey Piperaee81202013-08-26 11:14:02 -0700148
149 return pll_locked;
150}
151
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530152static uint32_t dsi_pll_enable_seq_c(uint32_t pll_base)
Casey Piperaee81202013-08-26 11:14:02 -0700153{
154 uint32_t pll_locked = 0;
155
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530156 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Casey Piperaee81202013-08-26 11:14:02 -0700157
158 /*
159 * Add hardware recommended delays between register writes for
160 * the updates to take effect. These delays are necessary for the
161 * PLL to successfully lock
162 */
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530163 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700164 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530165 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700166 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530167 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700168 udelay(1000);
169
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530170 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
171 pll_locked = readl(pll_base + 0x00c0) & 0x01;
Casey Piperaee81202013-08-26 11:14:02 -0700172
173 return pll_locked;
174}
175
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530176static uint32_t dsi_pll_enable_seq_e(uint32_t pll_base)
Casey Piperaee81202013-08-26 11:14:02 -0700177{
178 uint32_t pll_locked = 0;
179
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530180 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Casey Piperaee81202013-08-26 11:14:02 -0700181
182 /*
183 * Add hardware recommended delays between register writes for
184 * the updates to take effect. These delays are necessary for the
185 * PLL to successfully lock
186 */
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530187 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700188 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530189 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700190 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530191 writel(0x0d, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700192 udelay(1);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530193 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Casey Piperaee81202013-08-26 11:14:02 -0700194 udelay(1000);
195
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530196 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
197 pll_locked = readl(pll_base + 0x00c0) & 0x01;
Casey Piperaee81202013-08-26 11:14:02 -0700198
199 return pll_locked;
200}
201
Vineet Bajajbb14cb02014-04-25 00:38:09 +0530202static int msm8226_wled_backlight_ctrl(uint8_t enable)
203{
204 if (enable) {
205 pm8x41_wled_config(&wled_ctrl);
206 pm8x41_wled_sink_control(enable);
207 pm8x41_wled_iled_sync_control(enable);
208 pm8x41_wled_led_mod_enable(enable);
209 }
210 pm8x41_wled_enable(enable);
211
212 return NO_ERROR;
213}
214
215static int msm8226_pwm_backlight_ctrl(int gpio_num, int lpg_chan, int enable)
216{
217 struct pm8x41_gpio gpio_param = {
218 .direction = PM_GPIO_DIR_OUT,
219 .function = PM_GPIO_FUNC_2,
220 .vin_sel = 2, /* VIN_2 */
221 .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10,
222 .output_buffer = PM_GPIO_OUT_CMOS,
223 .out_strength = PM_GPIO_OUT_DRIVE_HIGH,
224 };
225
226 dprintf(SPEW, "%s: gpio=%d lpg=%d enable=%d\n", __func__,
227 gpio_num, lpg_chan, enable);
228
229 if (enable) {
230 pm8x41_gpio_config(gpio_num, &gpio_param);
231 pm8x41_lpg_write(lpg_chan, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */
232 pm8x41_lpg_write(lpg_chan, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */
233 pm8x41_lpg_write(lpg_chan, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */
234 pm8x41_lpg_write(lpg_chan, 0x44, 0xb2); /* LPG_VALUE_LSB */
235 pm8x41_lpg_write(lpg_chan, 0x45, 0x01); /* LPG_VALUE_MSB */
236 pm8x41_lpg_write(lpg_chan, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */
237 } else {
238 pm8x41_lpg_write(lpg_chan, 0x46, 0x00);
239 }
240
241 return NO_ERROR;
242}
243
244
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800245int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
Ray Zhang743e5032013-05-25 23:25:39 +0800246{
Vineet Bajajbb14cb02014-04-25 00:38:09 +0530247 uint32_t ret = NO_ERROR;
248
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700249 dprintf(SPEW, "target_backlight_ctrl\n");
250
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800251 if (!bl) {
252 dprintf(CRITICAL, "backlight structure is not available\n");
253 return ERR_INVALID_ARGS;
254 }
255
Vineet Bajajbb14cb02014-04-25 00:38:09 +0530256 switch (bl->bl_interface_type) {
257 case BL_WLED:
258 ret = msm8226_wled_backlight_ctrl(enable);
259 break;
260 case BL_PWM:
261 ret = msm8226_pwm_backlight_ctrl(pwm_gpio.pin_id,
262 PWM_BL_LPG_CHAN_ID,
263 enable);
264 break;
Aravind Venkateswarand4b57602015-01-29 23:22:14 -0800265 case BL_DCS:
266 break;
Vineet Bajajbb14cb02014-04-25 00:38:09 +0530267 default:
268 dprintf(CRITICAL, "backlight type:%d not supported\n",
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800269 bl->bl_interface_type);
Vineet Bajajbb14cb02014-04-25 00:38:09 +0530270 return ERR_NOT_SUPPORTED;
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800271 }
272
Vineet Bajajbb14cb02014-04-25 00:38:09 +0530273 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800274}
275
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530276static void dsi_pll_enable_seq(uint32_t pll_base)
Casey Piperaee81202013-08-26 11:14:02 -0700277{
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530278 if (dsi_pll_enable_seq_m(pll_base)) {
279 } else if (dsi_pll_enable_seq_d(pll_base)) {
280 } else if (dsi_pll_enable_seq_d(pll_base)) {
281 } else if (dsi_pll_enable_seq_f1(pll_base)) {
282 } else if (dsi_pll_enable_seq_c(pll_base)) {
283 } else if (dsi_pll_enable_seq_e(pll_base)) {
Casey Piperaee81202013-08-26 11:14:02 -0700284 } else {
285 dprintf(CRITICAL, "Not able to enable the pll\n");
286 }
287}
288
Arpita Banerjee0906ffd2013-05-24 16:25:38 -0700289int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
Ray Zhang743e5032013-05-25 23:25:39 +0800290{
Aravind Venkateswaranfada7f32013-09-19 15:23:34 -0700291 int32_t ret;
Arpita Banerjee0906ffd2013-05-24 16:25:38 -0700292 struct mdss_dsi_pll_config *pll_data;
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700293 dprintf(SPEW, "target_panel_clock\n");
Ray Zhang743e5032013-05-25 23:25:39 +0800294
Arpita Banerjee0906ffd2013-05-24 16:25:38 -0700295 pll_data = pinfo->mipi.dsi_pll_config;
296
Ray Zhang743e5032013-05-25 23:25:39 +0800297 if (enable) {
298 mdp_gdsc_ctrl(enable);
Aravind Venkateswaran5f546922013-09-19 15:13:43 -0700299 mmss_bus_clocks_enable();
300 mdp_clock_enable();
Aravind Venkateswaranfada7f32013-09-19 15:23:34 -0700301 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
302 if (ret) {
303 dprintf(CRITICAL,
304 "%s: Failed to restore MDP security configs",
305 __func__);
306 mdp_clock_disable();
307 mmss_bus_clocks_disable();
308 mdp_gdsc_ctrl(0);
309 return ret;
310 }
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700311 mdss_dsi_auto_pll_config(pinfo->mipi.pll_base,
Jeevan Shriram2d3500b2014-12-29 16:25:06 -0800312 pinfo->mipi.ctl_base, pll_data);
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700313 dsi_pll_enable_seq(pinfo->mipi.pll_base);
Aravind Venkateswaran5f546922013-09-19 15:13:43 -0700314 mmss_dsi_clocks_enable(pll_data->pclk_m,
Arpita Banerjee0906ffd2013-05-24 16:25:38 -0700315 pll_data->pclk_n,
316 pll_data->pclk_d);
Ray Zhang743e5032013-05-25 23:25:39 +0800317 } else if(!target_cont_splash_screen()) {
Aravind Venkateswaran5f546922013-09-19 15:13:43 -0700318 mmss_dsi_clocks_disable();
319 mdp_clock_disable();
320 mmss_bus_clocks_disable();
321 mdp_gdsc_ctrl(enable);
Ray Zhang743e5032013-05-25 23:25:39 +0800322 }
323
324 return 0;
325}
326
Dhaval Patel7a349562013-08-08 20:43:52 -0700327int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
328 struct msm_panel_info *pinfo)
Ray Zhang743e5032013-05-25 23:25:39 +0800329{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700330 int ret = NO_ERROR;
Ray Zhang743e5032013-05-25 23:25:39 +0800331 if (enable) {
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800332 if (pinfo->mipi.use_enable_gpio) {
333 gpio_tlmm_config(enable_gpio.pin_id, 0,
334 enable_gpio.pin_direction, enable_gpio.pin_pull,
335 enable_gpio.pin_strength,
336 enable_gpio.pin_state);
337
338 gpio_set_dir(enable_gpio.pin_id, 2);
339 }
340
Dhaval Patel7a349562013-08-08 20:43:52 -0700341 gpio_tlmm_config(reset_gpio.pin_id, 0,
342 reset_gpio.pin_direction, reset_gpio.pin_pull,
343 reset_gpio.pin_strength, reset_gpio.pin_state);
Ray Zhang743e5032013-05-25 23:25:39 +0800344
Dhaval Patel7a349562013-08-08 20:43:52 -0700345 gpio_set_dir(reset_gpio.pin_id, 2);
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700346
Dhaval Patel7a349562013-08-08 20:43:52 -0700347 gpio_set_value(reset_gpio.pin_id, resetseq->pin_state[0]);
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700348 mdelay(resetseq->sleep[0]);
Dhaval Patel7a349562013-08-08 20:43:52 -0700349 gpio_set_value(reset_gpio.pin_id, resetseq->pin_state[1]);
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700350 mdelay(resetseq->sleep[1]);
Dhaval Patel7a349562013-08-08 20:43:52 -0700351 gpio_set_value(reset_gpio.pin_id, resetseq->pin_state[2]);
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700352 mdelay(resetseq->sleep[2]);
Ray Zhang743e5032013-05-25 23:25:39 +0800353 } else if(!target_cont_splash_screen()) {
Dhaval Patel7a349562013-08-08 20:43:52 -0700354 gpio_set_value(reset_gpio.pin_id, 0);
Aravind Venkateswaranaf241212013-11-04 16:46:46 -0800355 if (pinfo->mipi.use_enable_gpio)
356 gpio_set_value(enable_gpio.pin_id, 0);
Ray Zhang743e5032013-05-25 23:25:39 +0800357 }
358
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700359 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800360}
361
Kuogee Hsieh93bcff62014-08-22 14:02:08 -0700362int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
Ray Zhang743e5032013-05-25 23:25:39 +0800363{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700364 uint32_t ret = NO_ERROR;
365 uint32_t ldocounter = 0;
366 uint32_t pm8x41_ldo_base = 0x13F00;
Ray Zhang743e5032013-05-25 23:25:39 +0800367
Dhaval Patel7a349562013-08-08 20:43:52 -0700368 while (ldocounter < TOTAL_LDO_DEFINED) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700369 struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base +
370 0x100 * ldo_entry_array[ldocounter].ldo_id),
371 ldo_entry_array[ldocounter].ldo_type);
Ray Zhang743e5032013-05-25 23:25:39 +0800372
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700373 dprintf(SPEW, "Setting %s\n",
374 ldo_entry_array[ldocounter].ldo_id);
Ray Zhang743e5032013-05-25 23:25:39 +0800375
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700376 /* Set voltage during power on */
Dhaval Patel815567c2013-07-31 11:13:25 -0700377 if (enable) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700378 pm8x41_ldo_set_voltage(&ldo_entry,
379 ldo_entry_array[ldocounter].ldo_voltage);
Dhaval Patel815567c2013-07-31 11:13:25 -0700380
381 pm8x41_ldo_control(&ldo_entry, enable);
382
383 } else if(!target_cont_splash_screen() &&
384 ldo_entry_array[ldocounter].ldo_id != HFPLL_LDO_ID) {
385 pm8x41_ldo_control(&ldo_entry, enable);
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700386 }
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700387 ldocounter++;
Ray Zhang743e5032013-05-25 23:25:39 +0800388 }
389
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700390 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800391}
392
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700393bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size)
394{
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700395 return gcdb_display_cmdline_arg(panel_name, pbuf, buf_size);
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700396}
397
Aravind Venkateswaran6385f7e2014-02-25 16:45:11 -0800398void target_display_init(const char *panel_name)
Ray Zhang743e5032013-05-25 23:25:39 +0800399{
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530400 uint32_t panel_loop = 0;
401 uint32_t ret = 0;
Aravind Venkateswaran148e0df2014-03-28 16:26:05 -0700402 uint32_t fb_addr = MIPI_FB_ADDR;
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800403 char cont_splash = '\0';
404
405 set_panel_cmd_string(panel_name, &cont_splash);
Aravind Venkateswaran148e0df2014-03-28 16:26:05 -0700406
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700407 if (!strcmp(panel_name, NO_PANEL_CONFIG)
408 || !strcmp(panel_name, SIM_VIDEO_PANEL)
409 || !strcmp(panel_name, SIM_CMD_PANEL)) {
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700410 dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700411 panel_name);
Jeevan Shriramb0d523a2014-05-30 12:55:17 -0700412 return;
413 }
414
Aravind Venkateswaran148e0df2014-03-28 16:26:05 -0700415 if (board_hardware_subtype() == HW_PLATFORM_SUBTYPE_QVGA)
416 fb_addr = MIPI_FB_ADDR_QVGA;
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530417
418 do {
Justin Philipbe9de5c2014-09-17 12:26:49 +0530419 target_force_cont_splash_disable(false);
Aravind Venkateswaran148e0df2014-03-28 16:26:05 -0700420 ret = gcdb_display_init(panel_name, MDP_REV_50, fb_addr);
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530421 if (!ret || ret == ERR_NOT_SUPPORTED) {
422 break;
423 } else {
424 target_force_cont_splash_disable(true);
425 msm_display_off();
Pradeep Jilagamfeb15982013-10-29 13:08:51 +0530426 }
427 } while (++panel_loop <= oem_panel_max_auto_detect_panels());
428
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800429 if (cont_splash == '0') {
430 dprintf(INFO, "Forcing continuous splash disable\n");
431 target_force_cont_splash_disable(true);
432 }
Ray Zhang743e5032013-05-25 23:25:39 +0800433}
434
Aravind Venkateswarandd50c1a2014-02-25 14:42:43 -0800435void target_display_shutdown(void)
Ray Zhang743e5032013-05-25 23:25:39 +0800436{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700437 gcdb_display_shutdown();
Ray Zhang743e5032013-05-25 23:25:39 +0800438}