blob: db85b7b85a54895ece331b9c140b78a1d1f64ad4 [file] [log] [blame]
Jeevan Shriram2d3500b2014-12-29 16:25:06 -08001/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +05302 *
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 <err.h>
33#include <msm_panel.h>
34#include <mipi_dsi.h>
35#include <pm8x41.h>
36#include <pm8x41_wled.h>
37#include <board.h>
38#include <mdp5.h>
39#include <scm.h>
40#include <platform/gpio.h>
41#include <platform/iomap.h>
42#include <target/display.h>
Aparna Mallavarapu430797d2014-05-15 11:52:56 +053043#include <i2c_qup.h>
44#include <blsp_qup.h>
Vineet Bajaja83cf802015-05-07 17:31:33 +053045#include <mipi_dsi_i2c.h>
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053046
47#include "include/panel.h"
48#include "include/display_resource.h"
Veera Sundaram Sankaran87f88132015-01-28 11:32:44 -080049#include "gcdb_display.h"
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053050
Padmanabhan Komanduru18aa5072014-04-17 16:52:53 +053051#define VCO_DELAY_USEC 1000
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053052#define GPIO_STATE_LOW 0
53#define GPIO_STATE_HIGH 2
54#define RESET_GPIO_SEQ_LEN 3
55#define PWM_DUTY_US 13
56#define PWM_PERIOD_US 27
57
Padmanabhan Komanduru0a5db942014-04-17 16:56:04 +053058static void mdss_dsi_uniphy_pll_sw_reset_8916(uint32_t pll_base)
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053059{
Padmanabhan Komanduru0a5db942014-04-17 16:56:04 +053060 writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */
61 mdelay(1);
62 writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */
63 mdelay(1);
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053064}
65
Shuo Yand954f182015-02-11 10:08:49 +080066static void dsi_pll_toggle_lock_detect_8916(uint32_t pll_base)
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053067{
Shuo Yand954f182015-02-11 10:08:49 +080068 writel(0x04, pll_base + 0x0064); /* LKDetect CFG2 */
69 udelay(1);
70 writel(0x05, pll_base + 0x0064); /* LKDetect CFG2 */
71 udelay(512);
72}
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053073
Shuo Yand954f182015-02-11 10:08:49 +080074static void dsi_pll_sw_reset_8916(uint32_t pll_base)
75{
Padmanabhan Komanduru0a5db942014-04-17 16:56:04 +053076 writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */
77 udelay(1);
78 writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */
Shuo Yand954f182015-02-11 10:08:49 +080079}
80
81static uint32_t gf_1_dsi_pll_enable_sequence_8916(uint32_t pll_base)
82{
83 uint32_t rc;
84
85 dsi_pll_sw_reset_8916(pll_base);
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053086
87 /*
88 * Add hardware recommended delays between register writes for
89 * the updates to take effect. These delays are necessary for the
90 * PLL to successfully lock
91 */
Shuo Yand954f182015-02-11 10:08:49 +080092 writel(0x14, pll_base + 0x0070); /* CAL CFG1*/
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053093 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053094 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Shuo Yand954f182015-02-11 10:08:49 +080095 udelay(3);
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053096 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Shuo Yand954f182015-02-11 10:08:49 +080097 udelay(500);
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +053098
Shuo Yand954f182015-02-11 10:08:49 +080099 dsi_pll_toggle_lock_detect_8916(pll_base);
100 rc = readl(pll_base + 0x00c0) & 0x01;
101
102 return rc;
103}
104
105static uint32_t gf_2_dsi_pll_enable_sequence_8916(uint32_t pll_base)
106{
107 uint32_t rc;
108
109 dsi_pll_sw_reset_8916(pll_base);
110
111 /*
112 * Add hardware recommended delays between register writes for
113 * the updates to take effect. These delays are necessary for the
114 * PLL to successfully lock
115 */
116 writel(0x04, pll_base + 0x0070); /* CAL CFG1*/
117 writel(0x01, pll_base + 0x0020); /* GLB CFG */
118 writel(0x05, pll_base + 0x0020); /* GLB CFG */
119 udelay(3);
120 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
121 udelay(500);
122
123 dsi_pll_toggle_lock_detect_8916(pll_base);
124 rc = readl(pll_base + 0x00c0) & 0x01;
125
126 return rc;
127}
128
129static uint32_t tsmc_dsi_pll_enable_sequence_8916(uint32_t pll_base)
130{
131 uint32_t rc;
132
133 dsi_pll_sw_reset_8916(pll_base);
134 /*
135 * Add hardware recommended delays between register writes for
136 * the updates to take effect. These delays are necessary for the
137 * PLL to successfully lock
138 */
139
140 writel(0x34, pll_base + 0x0070); /* CAL CFG1*/
141 writel(0x01, pll_base + 0x0020); /* GLB CFG */
142 writel(0x05, pll_base + 0x0020); /* GLB CFG */
143 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
144 udelay(500);
145
146 dsi_pll_toggle_lock_detect_8916(pll_base);
147 rc = readl(pll_base + 0x00c0) & 0x01;
148
149 return rc;
150}
151
152
153static uint32_t dsi_pll_enable_seq_8916(uint32_t pll_base)
154{
155 uint32_t pll_locked = 0;
156 uint32_t counter = 0;
157
158 do {
159 pll_locked = tsmc_dsi_pll_enable_sequence_8916(pll_base);
160
161 dprintf(SPEW, "TSMC pll locked status is %d\n", pll_locked);
162 ++counter;
163 } while (!pll_locked && (counter < 3));
164
165 if(!pll_locked) {
166 counter = 0;
167 do {
168 pll_locked = gf_1_dsi_pll_enable_sequence_8916(pll_base);
169
170 dprintf(SPEW, "GF P1 pll locked status is %d\n", pll_locked);
171 ++counter;
172 } while (!pll_locked && (counter < 3));
173 }
174
175 if(!pll_locked) {
176 counter = 0;
177 do {
178 pll_locked = gf_2_dsi_pll_enable_sequence_8916(pll_base);
179
180 dprintf(SPEW, "GF P2 pll locked status is %d\n", pll_locked);
181 ++counter;
182 } while (!pll_locked && (counter < 3));
183 }
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530184
185 return pll_locked;
186}
187
188int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
189{
190 struct pm8x41_mpp mpp;
191 int rc;
192
Shuo Yan123546b2014-05-19 19:35:41 +0800193 if (bl->bl_interface_type == BL_DCS)
194 return 0;
195
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530196 mpp.base = PM8x41_MMP4_BASE;
197 mpp.vin = MPP_VIN0;
198 if (enable) {
199 pm_pwm_enable(false);
200 rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
201 if (rc < 0)
202 mpp.mode = MPP_HIGH;
203 else {
204 mpp.mode = MPP_DTEST1;
205 pm_pwm_enable(true);
206 }
207 pm8x41_config_output_mpp(&mpp);
208 pm8x41_enable_mpp(&mpp, MPP_ENABLE);
209 } else {
210 pm_pwm_enable(false);
211 pm8x41_enable_mpp(&mpp, MPP_DISABLE);
212 }
213 mdelay(20);
214 return 0;
215}
216
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530217int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
218{
219 int32_t ret = 0;
220 struct mdss_dsi_pll_config *pll_data;
221 dprintf(SPEW, "target_panel_clock\n");
222
223 pll_data = pinfo->mipi.dsi_pll_config;
Padmanabhan Komanduru18aa5072014-04-17 16:52:53 +0530224 pll_data->vco_delay = VCO_DELAY_USEC;
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530225
226 if (enable) {
227 mdp_gdsc_ctrl(enable);
228 mdss_bus_clocks_enable();
229 mdp_clock_enable();
230 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
231 if (ret) {
232 dprintf(CRITICAL,
233 "%s: Failed to restore MDP security configs",
234 __func__);
235 mdp_clock_disable();
236 mdss_bus_clocks_disable();
237 mdp_gdsc_ctrl(0);
238 return ret;
239 }
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700240 mdss_dsi_uniphy_pll_sw_reset_8916(pinfo->mipi.pll_base);
241 mdss_dsi_auto_pll_config(pinfo->mipi.pll_base,
Jeevan Shriram2d3500b2014-12-29 16:25:06 -0800242 pinfo->mipi.ctl_base, pll_data);
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700243 if (!dsi_pll_enable_seq_8916(pinfo->mipi.pll_base))
Padmanabhan Komanduru0a5db942014-04-17 16:56:04 +0530244 dprintf(CRITICAL, "Not able to enable the pll\n");
Vineet Bajaje022da62014-07-24 19:13:34 +0530245 gcc_dsi_clocks_enable(pinfo->mipi.dual_dsi, pll_data->pclk_m,
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530246 pll_data->pclk_n,
247 pll_data->pclk_d);
248 } else if(!target_cont_splash_screen()) {
Vineet Bajaje022da62014-07-24 19:13:34 +0530249 gcc_dsi_clocks_disable(pinfo->mipi.dual_dsi);
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530250 mdp_clock_disable();
251 mdss_bus_clocks_disable();
252 mdp_gdsc_ctrl(enable);
253 }
254
255 return 0;
256}
257
Aparna Mallavarapu430797d2014-05-15 11:52:56 +0530258#define QRD_LCD_I2C_ADDRESS 0x3E
259#define QRD_LCD_VPOS_ADDRESS 0x00
260#define QRD_LCD_VNEG_ADDRESS 0x01
261#define QRD_LCD_DIS_ADDRESS 0x03
262#define QRD_LCD_CONTROL_ADDRESS 0xFF
263
264static struct qup_i2c_dev *i2c_dev;
265static int qrd_lcd_i2c_read(uint8_t addr)
266{
267 int ret = 0;
268 /* Create a i2c_msg buffer, that is used to put the controller into read
269 mode and then to read some data. */
270 struct i2c_msg msg_buf[] = {
271 {QRD_LCD_I2C_ADDRESS, I2C_M_WR, 1, &addr},
272 {QRD_LCD_I2C_ADDRESS, I2C_M_RD, 1, &ret}
273 };
274
275 ret = qup_i2c_xfer(i2c_dev, msg_buf, 2);
276 if(ret < 0) {
277 dprintf(CRITICAL, "qup_i2c_xfer error %d\n", ret);
278 return ret;
279 }
280 return 0;
281}
282
283static int qrd_lcd_i2c_write(uint8_t addr, uint8_t val)
284{
285 int ret = 0;
286 uint8_t data_buf[] = { addr, val };
287
288 /* Create a i2c_msg buffer, that is used to put the controller into write
289 mode and then to write some data. */
290 struct i2c_msg msg_buf[] = { {QRD_LCD_I2C_ADDRESS,
291 I2C_M_WR, 2, data_buf}
292 };
293
294 ret = qup_i2c_xfer(i2c_dev, msg_buf, 1);
295 if(ret < 0) {
296 dprintf(CRITICAL, "qup_i2c_xfer error %d\n", ret);
297 return ret;
298 }
299 return 0;
300}
301
Vineet Bajaja83cf802015-05-07 17:31:33 +0530302static int dsi2HDMI_i2c_write_regs(struct mipi_dsi_i2c_cmd *cfg, int size)
303{
304 int ret = NO_ERROR;
305 int i;
306
307 if (!cfg)
308 return ERR_INVALID_ARGS;
309
310 for (i = 0; i < size; i++) {
311 ret = mipi_dsi_i2c_write_byte(cfg[i].i2c_addr, cfg[i].reg,
312 cfg[i].val);
313 if (ret) {
314 dprintf(CRITICAL, "mipi_dsi reg writes failed\n");
315 goto w_regs_fail;
316 }
317 if (cfg[i].sleep_in_ms) {
318 udelay(cfg[i].sleep_in_ms*1000);
319 }
320 }
321w_regs_fail:
322 return ret;
323}
324
325int target_display_dsi2hdmi_config(struct msm_panel_info *pinfo)
326{
327 int ret = NO_ERROR;
328
329 if (!pinfo)
330 return ERR_INVALID_ARGS;
331
332 /*
333 * If dsi to HDMI bridge chip connected then
334 * send I2c commands to the chip
335 */
336 if (pinfo->adv7533.dsi_setup_cfg_i2c_cmd)
337 ret = dsi2HDMI_i2c_write_regs(pinfo->adv7533.dsi_setup_cfg_i2c_cmd,
338 pinfo->adv7533.num_of_cfg_i2c_cmds);
339
340 if (pinfo->adv7533.dsi_tg_i2c_cmd)
341 ret = dsi2HDMI_i2c_write_regs(pinfo->adv7533.dsi_tg_i2c_cmd,
342 pinfo->adv7533.num_of_tg_i2c_cmds);
343
344 return ret;
345}
346
Mao Flynn732e3c22014-07-02 17:39:02 +0800347static int target_panel_reset_skuh(uint8_t enable)
348{
349 int ret = NO_ERROR;
350 if (enable) {
351 /* for tps65132 ENP pin */
352 gpio_tlmm_config(enp_gpio.pin_id, 0,
353 enp_gpio.pin_direction, enp_gpio.pin_pull,
354 enp_gpio.pin_strength,
355 enp_gpio.pin_state);
356 gpio_set_dir(enp_gpio.pin_id, 2);
357
358 /* for tps65132 ENN pin*/
359 gpio_tlmm_config(enn_gpio.pin_id, 0,
360 enn_gpio.pin_direction, enn_gpio.pin_pull,
361 enn_gpio.pin_strength,
362 enn_gpio.pin_state);
363 gpio_set_dir(enn_gpio.pin_id, 2);
364
365 i2c_dev = qup_blsp_i2c_init(BLSP_ID_1, QUP_ID_1, 100000, 19200000);
366 if(!i2c_dev) {
367 dprintf(CRITICAL, "qup_blsp_i2c_init failed \n");
368 ASSERT(0);
369 }
370
371 ret = qrd_lcd_i2c_write(QRD_LCD_VPOS_ADDRESS, 0x0E); /* 5.4V */
372 if (ret) {
373 dprintf(CRITICAL, "VPOS Register: I2C Write failure\n");
374 }
375
376 ret = qrd_lcd_i2c_write(QRD_LCD_VNEG_ADDRESS, 0x0E); /* -5.4V */
377 if (ret) {
378 dprintf(CRITICAL, "VNEG Register: I2C write failure\n");
379 }
380
381 ret = qrd_lcd_i2c_write(QRD_LCD_DIS_ADDRESS, 0x0F);
382 if (ret) {
383 dprintf(CRITICAL, "Apps freq DIS Register: I2C write failure\n");
384 }
385
386 ret = qrd_lcd_i2c_write(QRD_LCD_CONTROL_ADDRESS, 0xF0);
387 if (ret) {
388 dprintf(CRITICAL, "Control Register: I2C write failure\n");
389 }
390 } else {
391 gpio_set_dir(enp_gpio.pin_id, 0); /* ENP */
392 gpio_set_dir(enn_gpio.pin_id, 0); /* ENN */
393 }
394 return 0;
395}
396
397static int target_panel_reset_skuk(uint8_t enable)
398{
399 if (enable) {
400 /* for tps65132 ENP pin*/
401 gpio_tlmm_config(enp_gpio_skuk.pin_id, 0,
402 enp_gpio_skuk.pin_direction, enp_gpio_skuk.pin_pull,
403 enp_gpio_skuk.pin_strength, enp_gpio_skuk.pin_state);
404 gpio_set_dir(enp_gpio_skuk.pin_id, 2);
405
406 /* for tps65132 ENN pin*/
407 gpio_tlmm_config(enn_gpio_skuk.pin_id, 0,
408 enn_gpio_skuk.pin_direction, enn_gpio_skuk.pin_pull,
409 enn_gpio_skuk.pin_strength, enn_gpio_skuk.pin_state);
410 gpio_set_dir(enn_gpio_skuk.pin_id, 2);
411
412 /* configure backlight gpio for SKUK */
413 gpio_tlmm_config(bkl_gpio_skuk.pin_id, 0,
414 bkl_gpio_skuk.pin_direction, bkl_gpio_skuk.pin_pull,
415 bkl_gpio_skuk.pin_strength, bkl_gpio_skuk.pin_state);
416 gpio_set_dir(bkl_gpio_skuk.pin_id, 2);
417 } else {
418 gpio_set_dir(bkl_gpio_skuk.pin_id, 0);
419 gpio_set_dir(enp_gpio_skuk.pin_id, 0); /* ENP */
420 gpio_set_dir(enn_gpio_skuk.pin_id, 0); /* ENN */
421 }
422 return 0;
423}
424
Vineet Bajaj3acf94f2014-12-04 19:55:03 +0530425int target_panel_reset_incell(uint8_t enable)
426{
427 /*Enable the gpios in 75->97->77 order for incell panel*/
428 if (enable) {
429 gpio_tlmm_config(enable_gpio_1.pin_id, 0,
430 enable_gpio_1.pin_direction, enable_gpio_1.pin_pull,
431 enable_gpio_1.pin_strength, enable_gpio_1.pin_state);
432 gpio_set_dir(enable_gpio_1.pin_id, 2);
433
434 gpio_tlmm_config(enp_gpio.pin_id, 0,
435 enp_gpio.pin_direction, enp_gpio.pin_pull,
436 enp_gpio.pin_strength, enp_gpio.pin_state);
437 gpio_set_dir(enp_gpio.pin_id, 2);
438
439 gpio_tlmm_config(enn_gpio_1.pin_id, 0,
440 enn_gpio_1.pin_direction, enn_gpio_1.pin_pull,
441 enn_gpio_1.pin_strength, enn_gpio_1.pin_state);
442 gpio_set_dir(enn_gpio_1.pin_id, 2);
443 }
444 else {
445 gpio_set_dir(enable_gpio_1.pin_id, 0);
446 gpio_set_dir(enp_gpio.pin_id, 0); /* ENP */
447 gpio_set_dir(enn_gpio_1.pin_id, 0); /* ENN */
448 }
449}
450
Vineet Bajaj5be1e4a2015-02-02 15:07:49 +0530451int target_panel_reset_jdi_a216(uint8_t enable)
452{
453 if (enable) {
454 gpio_tlmm_config(ts_reset_gpio.pin_id, 0,
455 ts_reset_gpio.pin_direction, ts_reset_gpio.pin_pull,
456 ts_reset_gpio.pin_strength, ts_reset_gpio.pin_state);
457 gpio_set_dir(ts_reset_gpio.pin_id, GPIO_STATE_HIGH);
458 } else {
459 gpio_set_dir(ts_reset_gpio.pin_id, GPIO_STATE_LOW);
460 }
461}
462
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530463int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
464 struct msm_panel_info *pinfo)
465{
466 int ret = NO_ERROR;
Mao Flynn81409472014-04-10 15:01:30 +0800467 uint32_t hw_id = board_hardware_id();
468 uint32_t hw_subtype = board_hardware_subtype();
Gustavo Solaira80c274c2014-10-22 16:21:27 -0300469 uint32_t target_id, plat_hw_ver_major;
Mao Flynn81409472014-04-10 15:01:30 +0800470
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530471 if (enable) {
472 if (pinfo->mipi.use_enable_gpio) {
Gustavo Solairafb6fdd62014-09-30 08:15:32 -0300473 /* set enable gpio pin for SKUT1 */
474 if ((hw_id == HW_PLATFORM_QRD) &&
Gustavo Solaira80c274c2014-10-22 16:21:27 -0300475 (hw_subtype == HW_PLATFORM_SUBTYPE_SKUT1)) {
476 target_id = board_target_id();
477 plat_hw_ver_major = ((target_id >> 16) & 0xFF);
478 if ((plat_hw_ver_major & 0x0F) == 0x1)
479 enable_gpio = enable_gpio_skut1;
480 else
481 enable_gpio = enable_gpio_skut2;
482 }
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530483 gpio_tlmm_config(enable_gpio.pin_id, 0,
484 enable_gpio.pin_direction, enable_gpio.pin_pull,
485 enable_gpio.pin_strength,
486 enable_gpio.pin_state);
487
488 gpio_set_dir(enable_gpio.pin_id, 2);
489 }
490
vijay kumardd51c592015-01-05 12:46:28 +0530491 if (platform_is_msm8939() || platform_is_msm8929()) {
Mao Flynn732e3c22014-07-02 17:39:02 +0800492 if ((hw_id == HW_PLATFORM_QRD) &&
493 (hw_subtype == HW_PLATFORM_SUBTYPE_SKUK))
494 target_panel_reset_skuk(enable);
Vineet Bajaj5be1e4a2015-02-02 15:07:49 +0530495 if (((hw_id == HW_PLATFORM_SURF) &&
496 (hw_subtype == HW_PLATFORM_SUBTYPE_CDP_1)) ||
497 ((hw_id == HW_PLATFORM_MTP) &&
498 (hw_subtype == HW_PLATFORM_SUBTYPE_MTP_3)))
Vineet Bajaj3acf94f2014-12-04 19:55:03 +0530499 target_panel_reset_incell(enable);
Vineet Bajaj5be1e4a2015-02-02 15:07:49 +0530500 if ((hw_id == HW_PLATFORM_SURF) &&
501 (hw_subtype == HW_PLATFORM_SUBTYPE_CDP_2))
502 target_panel_reset_jdi_a216(enable);
Mao Flynn732e3c22014-07-02 17:39:02 +0800503 } else { /* msm8916 */
504 if ((hw_id == HW_PLATFORM_QRD) &&
505 (hw_subtype == HW_PLATFORM_SUBTYPE_SKUH))
506 target_panel_reset_skuh(enable);
Mao Flynn81409472014-04-10 15:01:30 +0800507 }
508
Shuo Yanc8a417f2014-05-20 14:44:56 +0800509 if (hw_id == HW_PLATFORM_MTP || hw_id == HW_PLATFORM_SURF) {
510 /* configure backlight gpio for MTP & CDP */
Vineet Bajaj3acf94f2014-12-04 19:55:03 +0530511 gpio_tlmm_config(bkl_gpio.pin_id, 0,
512 bkl_gpio.pin_direction, bkl_gpio.pin_pull,
513 bkl_gpio.pin_strength, bkl_gpio.pin_state);
514 gpio_set_dir(bkl_gpio.pin_id, 2);
Shuo Yanc8a417f2014-05-20 14:44:56 +0800515 }
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530516
517 gpio_tlmm_config(reset_gpio.pin_id, 0,
518 reset_gpio.pin_direction, reset_gpio.pin_pull,
519 reset_gpio.pin_strength, reset_gpio.pin_state);
520
521 gpio_set_dir(reset_gpio.pin_id, 2);
522
523 /* reset */
524 for (int i = 0; i < RESET_GPIO_SEQ_LEN; i++) {
525 if (resetseq->pin_state[i] == GPIO_STATE_LOW)
526 gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_LOW);
527 else
528 gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_HIGH);
529 mdelay(resetseq->sleep[i]);
530 }
531 } else if(!target_cont_splash_screen()) {
532 gpio_set_dir(reset_gpio.pin_id, 0);
533 if (pinfo->mipi.use_enable_gpio)
534 gpio_set_dir(enable_gpio.pin_id, 0);
Mao Flynn81409472014-04-10 15:01:30 +0800535
vijay kumardd51c592015-01-05 12:46:28 +0530536 if (platform_is_msm8939() || platform_is_msm8929()) {
Mao Flynn732e3c22014-07-02 17:39:02 +0800537 if ((hw_id == HW_PLATFORM_QRD) &&
538 (hw_subtype == HW_PLATFORM_SUBTYPE_SKUK))
539 target_panel_reset_skuk(enable);
540 } else { /* msm8916 */
541 if ((hw_id == HW_PLATFORM_QRD) &&
542 (hw_subtype == HW_PLATFORM_SUBTYPE_SKUH))
543 target_panel_reset_skuh(enable);
Mao Flynn81409472014-04-10 15:01:30 +0800544 }
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530545 }
546
547 return ret;
548}
549
Kuogee Hsieh93bcff62014-08-22 14:02:08 -0700550int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530551{
Padmanabhan Komanduru0ed51fb2014-06-04 12:22:08 +0530552 /*
553 * The PMIC regulators needed for display are enabled in SBL.
554 * There is no access to the regulators is LK.
555 */
556 return NO_ERROR;
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530557}
558
559bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size)
560{
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700561 return gcdb_display_cmdline_arg(panel_name, pbuf, buf_size);
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530562}
563
564void target_display_init(const char *panel_name)
565{
Padmanabhan Komanduru1869a762014-04-01 20:12:05 +0530566 uint32_t panel_loop = 0;
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530567 uint32_t ret = 0;
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800568 char cont_splash = '\0';
Jeevan Shriramb0d523a2014-05-30 12:55:17 -0700569
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800570 set_panel_cmd_string(panel_name, &cont_splash);
Sandeep Pandae07c07b2014-08-25 17:04:17 +0530571 panel_name += strspn(panel_name, " ");
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700572
573 if (!strcmp(panel_name, NO_PANEL_CONFIG)
574 || !strcmp(panel_name, SIM_VIDEO_PANEL)
575 || !strcmp(panel_name, SIM_CMD_PANEL)) {
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700576 dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700577 panel_name);
Jeevan Shriramb0d523a2014-05-30 12:55:17 -0700578 return;
579 }
580
Padmanabhan Komanduru1869a762014-04-01 20:12:05 +0530581 do {
Justin Philipbe9de5c2014-09-17 12:26:49 +0530582 target_force_cont_splash_disable(false);
Padmanabhan Komanduru1869a762014-04-01 20:12:05 +0530583 ret = gcdb_display_init(panel_name, MDP_REV_50, MIPI_FB_ADDR);
584 if (!ret || ret == ERR_NOT_SUPPORTED) {
585 break;
586 } else {
587 target_force_cont_splash_disable(true);
588 msm_display_off();
Padmanabhan Komanduru1869a762014-04-01 20:12:05 +0530589 }
590 } while (++panel_loop <= oem_panel_max_auto_detect_panels());
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800591
592 if (cont_splash == '0') {
593 dprintf(INFO, "Forcing continuous splash disable\n");
594 target_force_cont_splash_disable(true);
595 }
Padmanabhan Komandurucd5645e2014-03-25 20:34:18 +0530596}
597
598void target_display_shutdown(void)
599{
600 gcdb_display_shutdown();
601}