blob: 0b40e7da58b0b728fb0db89ed51f1592ccdc5e89 [file] [log] [blame]
Jeevan Shriram2d3500b2014-12-29 16:25:06 -08001/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Dhaval Patel019057a2014-08-12 13:52:25 -07002 *
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>
Veera Sundaram Sankaran089f70d2014-12-09 14:17:05 -080031#include <string.h>
Dhaval Patel019057a2014-08-12 13:52:25 -070032#include <smem.h>
33#include <err.h>
34#include <msm_panel.h>
35#include <mipi_dsi.h>
Casey Piper6c2f1132015-03-24 11:37:19 -070036#include <mdss_hdmi.h>
Dhaval Patel019057a2014-08-12 13:52:25 -070037#include <pm8x41.h>
38#include <pm8x41_wled.h>
39#include <qpnp_wled.h>
40#include <board.h>
41#include <mdp5.h>
42#include <scm.h>
43#include <endian.h>
Veera Sundaram Sankaran089f70d2014-12-09 14:17:05 -080044#include <regulator.h>
45#include <qtimer.h>
46#include <arch/defines.h>
Dhaval Patel019057a2014-08-12 13:52:25 -070047#include <platform/gpio.h>
48#include <platform/clock.h>
49#include <platform/iomap.h>
50#include <target/display.h>
51#include "include/panel.h"
52#include "include/display_resource.h"
Veera Sundaram Sankaran089f70d2014-12-09 14:17:05 -080053#include "gcdb_display.h"
Dhaval Patel019057a2014-08-12 13:52:25 -070054
55#define HFPLL_LDO_ID 12
56
57#define GPIO_STATE_LOW 0
58#define GPIO_STATE_HIGH 2
59#define RESET_GPIO_SEQ_LEN 3
60
61#define PWM_DUTY_US 13
62#define PWM_PERIOD_US 27
63#define PMIC_WLED_SLAVE_ID 3
64#define PMIC_MPP_SLAVE_ID 2
65
Jeevan Shriram7aacc322014-12-29 16:02:25 -080066#define DSI0_BASE_ADJUST -0x4000
67#define DSI1_BASE_ADJUST -0xA000
68
Veera Sundaram Sankaran089f70d2014-12-09 14:17:05 -080069/*---------------------------------------------------------------------------*/
70/* GPIO configuration */
71/*---------------------------------------------------------------------------*/
72static struct gpio_pin reset_gpio = {
73 "msmgpio", 78, 3, 1, 0, 1
74};
75
76static struct gpio_pin lcd_reg_en = { /* boost regulator */
77 "pm8994_gpios", 14, 3, 1, 0, 1
78};
79
80static struct gpio_pin bklt_gpio = { /* lcd_bklt_reg_en */
81 "pmi8994_gpios", 2, 3, 1, 0, 1
82};
83
Ajay Singh Parmar20bdc1b2015-02-13 23:47:40 -080084/* gpio name, id, strength, direction, pull, state. */
85static struct gpio_pin hdmi_cec_gpio = { /* CEC */
86 "msmgpio", 31, 0, 2, 3, 1
87};
88
89static struct gpio_pin hdmi_ddc_clk_gpio = { /* DDC CLK */
90 "msmgpio", 32, 0, 2, 3, 1
91};
92
93static struct gpio_pin hdmi_ddc_data_gpio = { /* DDC DATA */
94 "msmgpio", 33, 0, 2, 3, 1
95};
96
97static struct gpio_pin hdmi_hpd_gpio = { /* HPD, input */
98 "msmgpio", 34, 7, 0, 1, 1
99};
100
101int target_hdmi_gpio_ctrl(uint8_t enable)
102{
103 gpio_tlmm_config(hdmi_cec_gpio.pin_id, 1, /* gpio 31, CEC */
104 hdmi_cec_gpio.pin_direction, hdmi_cec_gpio.pin_pull,
105 hdmi_cec_gpio.pin_strength, hdmi_cec_gpio.pin_state);
106
107 gpio_tlmm_config(hdmi_ddc_clk_gpio.pin_id, 1, /* gpio 32, DDC CLK */
108 hdmi_ddc_clk_gpio.pin_direction, hdmi_ddc_clk_gpio.pin_pull,
109 hdmi_ddc_clk_gpio.pin_strength, hdmi_ddc_clk_gpio.pin_state);
110
111
112 gpio_tlmm_config(hdmi_ddc_data_gpio.pin_id, 1, /* gpio 33, DDC DATA */
113 hdmi_ddc_data_gpio.pin_direction, hdmi_ddc_data_gpio.pin_pull,
114 hdmi_ddc_data_gpio.pin_strength, hdmi_ddc_data_gpio.pin_state);
115
116 gpio_tlmm_config(hdmi_hpd_gpio.pin_id, 1, /* gpio 34, HPD */
117 hdmi_hpd_gpio.pin_direction, hdmi_hpd_gpio.pin_pull,
118 hdmi_hpd_gpio.pin_strength, hdmi_hpd_gpio.pin_state);
119
120 gpio_set(hdmi_cec_gpio.pin_id, hdmi_cec_gpio.pin_direction);
121 gpio_set(hdmi_ddc_clk_gpio.pin_id, hdmi_ddc_clk_gpio.pin_direction);
122 gpio_set(hdmi_ddc_data_gpio.pin_id, hdmi_ddc_data_gpio.pin_direction);
123 gpio_set(hdmi_hpd_gpio.pin_id, hdmi_hpd_gpio.pin_direction);
124
125 return NO_ERROR;
126}
127
Dhaval Patel019057a2014-08-12 13:52:25 -0700128static uint32_t dsi_pll_20nm_enable_seq(uint32_t pll_base)
129{
130 uint32_t pll_locked;
Jeevan Shriram5a9f8f42014-12-14 14:56:14 -0800131 /* MDSS_DSI_0_PHY_DSIPHY_CTRL_1 */
132 writel(0x00, pll_base + 0x374);
Dhaval Patel019057a2014-08-12 13:52:25 -0700133 dmb();
Jeevan Shriram5a9f8f42014-12-14 14:56:14 -0800134 /* MDSS_DSI_0_PHY_DSIPHY_CTRL_0 */
135 writel(0x7f, pll_base + 0x370);
136 dmb();
137 pll_locked = mdss_dsi_pll_20nm_lock_status(pll_base);
138 if (!pll_locked)
139 dprintf(INFO, "%s: DSI PLL lock failed\n", __func__);
140 else
141 dprintf(INFO, "%s: DSI PLL lock Success\n", __func__);
Dhaval Patel019057a2014-08-12 13:52:25 -0700142
143 return pll_locked;
144}
145
146static int msm8994_wled_backlight_ctrl(uint8_t enable)
147{
Kuogee Hsieh911866e2014-09-02 16:41:18 -0700148 uint8_t slave_id = 3; /* pmi */
Dhaval Patel019057a2014-08-12 13:52:25 -0700149
Veera Sundaram Sankaranf9ddd6c2014-12-02 11:04:52 -0800150 pm8x41_wled_config_slave_id(slave_id);
151 qpnp_wled_enable_backlight(enable);
Dhaval Patel019057a2014-08-12 13:52:25 -0700152 qpnp_ibb_enable(enable);
153 return NO_ERROR;
154}
155
156static int msm8994_pwm_backlight_ctrl(uint8_t enable)
157{
Kuogee Hsieh911866e2014-09-02 16:41:18 -0700158 uint8_t slave_id = 3; /* lpg at pmi */
159
160 if (enable) {
161 /* mpp-1 had been configured already */
162 /* lpg channel 4 */
163
164 /* LPG_ENABLE_CONTROL */
165 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0x0);
166 mdelay(100);
167
168 /* LPG_VALUE_LSB, duty cycle = 0x80/0x200 = 1/4 */
169 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x44, 0x80);
170 /* LPG_VALUE_MSB */
171 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x45, 0x00);
172 /* LPG_PWM_SYNC */
173 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x47, 0x01);
174
175 /* LPG_PWM_SIZE_CLK, */
176 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x41, 0x13);
177 /* LPG_PWM_FREQ_PREDIV */
178 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x42, 0x02);
179 /* LPG_PWM_TYPE_CONFIG */
180 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x43, 0x20);
181 /* LPG_ENABLE_CONTROL */
182 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0x04);
183
184 /* SEC_ACCESS */
185 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0xD0, 0xA5);
186 /* DTEST4, OUT_HI */
187 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0xE5, 0x01);
188 /* LPG_ENABLE_CONTROL */
189 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0xA4);
190 } else {
191 /* LPG_ENABLE_CONTROL */
192 pm8x41_lpg_write_sid(slave_id, PWM_BL_LPG_CHAN_ID, 0x46, 0x0);
193 }
194
195 return NO_ERROR;
196}
197
198void lcd_bklt_reg_enable(void)
199{
200 uint8_t slave_id = 2; /* gpio at pmi */
201
202 struct pm8x41_gpio gpio = {
203 .direction = PM_GPIO_DIR_OUT,
204 .function = PM_GPIO_FUNC_HIGH,
205 .vin_sel = 2, /* VIN_2 */
206 .output_buffer = PM_GPIO_OUT_CMOS,
207 .out_strength = PM_GPIO_OUT_DRIVE_LOW,
208 };
209
210 pm8x41_gpio_config_sid(slave_id, bklt_gpio.pin_id, &gpio);
211 pm8x41_gpio_set_sid(slave_id, bklt_gpio.pin_id, 1);
212}
213
214void lcd_bklt_reg_disable(void)
215{
216 uint8_t slave_id = 2; /* gpio at pmi */
217
218 pm8x41_gpio_set_sid(slave_id, bklt_gpio.pin_id, 0);
Dhaval Patel019057a2014-08-12 13:52:25 -0700219}
220
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700221void lcd_reg_enable(void)
Dhaval Patel019057a2014-08-12 13:52:25 -0700222{
223 struct pm8x41_gpio gpio = {
224 .direction = PM_GPIO_DIR_OUT,
225 .function = PM_GPIO_FUNC_HIGH,
226 .vin_sel = 2, /* VIN_2 */
227 .output_buffer = PM_GPIO_OUT_CMOS,
228 .out_strength = PM_GPIO_OUT_DRIVE_MED,
229 };
230
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700231 pm8x41_gpio_config(lcd_reg_en.pin_id, &gpio);
232 pm8x41_gpio_set(lcd_reg_en.pin_id, 1);
233}
234
235void lcd_reg_disable(void)
236{
237 pm8x41_gpio_set(lcd_reg_en.pin_id, 0);
Dhaval Patel019057a2014-08-12 13:52:25 -0700238}
239
240int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
241{
242 uint32_t ret = NO_ERROR;
243 struct pm8x41_mpp mpp;
244 int rc;
245
246 if (!bl) {
247 dprintf(CRITICAL, "backlight structure is not available\n");
248 return ERR_INVALID_ARGS;
249 }
250
251 switch (bl->bl_interface_type) {
252 case BL_WLED:
253 /* Enable MPP4 */
254 pmi8994_config_mpp_slave_id(PMIC_MPP_SLAVE_ID);
255 mpp.base = PM8x41_MMP4_BASE;
256 mpp.vin = MPP_VIN2;
257 if (enable) {
258 pm_pwm_enable(false);
259 rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
260 if (rc < 0) {
261 mpp.mode = MPP_HIGH;
262 } else {
263 mpp.mode = MPP_DTEST1;
264 pm_pwm_enable(true);
265 }
266 pm8x41_config_output_mpp(&mpp);
267 pm8x41_enable_mpp(&mpp, MPP_ENABLE);
268 } else {
269 pm_pwm_enable(false);
270 pm8x41_enable_mpp(&mpp, MPP_DISABLE);
271 }
272 /* Need delay before power on regulators */
273 mdelay(20);
274 /* Enable WLED backlight control */
275 ret = msm8994_wled_backlight_ctrl(enable);
276 break;
277 case BL_PWM:
Kuogee Hsieh911866e2014-09-02 16:41:18 -0700278 /* Enable MPP1 */
279 pmi8994_config_mpp_slave_id(PMIC_MPP_SLAVE_ID);
280 mpp.base = PM8x41_MMP1_BASE;
281 mpp.vin = MPP_VIN2;
282 mpp.mode = MPP_DTEST4;
283 if (enable) {
284 pm8x41_config_output_mpp(&mpp);
285 pm8x41_enable_mpp(&mpp, MPP_ENABLE);
286 } else {
287 pm8x41_enable_mpp(&mpp, MPP_DISABLE);
288 }
289 /* Need delay before power on regulators */
290 mdelay(20);
Dhaval Patel019057a2014-08-12 13:52:25 -0700291 ret = msm8994_pwm_backlight_ctrl(enable);
292 break;
293 default:
294 dprintf(CRITICAL, "backlight type:%d not supported\n",
295 bl->bl_interface_type);
296 return ERR_NOT_SUPPORTED;
297 }
298
299 return ret;
300}
301
Casey Piper6c2f1132015-03-24 11:37:19 -0700302int target_hdmi_pll_clock(uint8_t enable, struct msm_panel_info *pinfo)
303{
304 if (enable) {
305 hdmi_phy_reset();
306 hdmi_pll_config(pinfo->clk_rate);
307 hdmi_vco_enable();
308 hdmi_pixel_clk_enable(pinfo->clk_rate);
309 } else if(!target_cont_splash_screen()) {
310 /* Disable clocks if continuous splash off */
311 hdmi_pixel_clk_disable();
312 hdmi_vco_disable();
313 }
314
315 return NO_ERROR;
316}
317
Dhaval Patel019057a2014-08-12 13:52:25 -0700318int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
319{
Huaibin Yang928201b2015-01-15 10:40:21 -0800320 uint32_t ret = NO_ERROR;
Dhaval Patel019057a2014-08-12 13:52:25 -0700321 struct mdss_dsi_pll_config *pll_data;
Aravind Venkateswaranf3554322014-12-08 12:03:48 -0800322 uint32_t flags;
Huaibin Yang928201b2015-01-15 10:40:21 -0800323 struct dfps_pll_codes *pll_codes = &pinfo->mipi.pll_codes;
Aravind Venkateswaranf3554322014-12-08 12:03:48 -0800324
325 if (pinfo->dest == DISPLAY_2) {
326 flags = MMSS_DSI_CLKS_FLAG_DSI1;
327 if (pinfo->mipi.dual_dsi)
328 flags |= MMSS_DSI_CLKS_FLAG_DSI0;
329 } else {
330 flags = MMSS_DSI_CLKS_FLAG_DSI0;
331 if (pinfo->mipi.dual_dsi)
332 flags |= MMSS_DSI_CLKS_FLAG_DSI1;
333 }
Dhaval Patel019057a2014-08-12 13:52:25 -0700334
335 pll_data = pinfo->mipi.dsi_pll_config;
Huaibin Yang928201b2015-01-15 10:40:21 -0800336
337 if (!enable) {
Aravind Venkateswaranf3554322014-12-08 12:03:48 -0800338 mmss_dsi_clock_disable(flags);
Huaibin Yang928201b2015-01-15 10:40:21 -0800339 goto clks_disable;
Dhaval Patel019057a2014-08-12 13:52:25 -0700340 }
341
Huaibin Yang928201b2015-01-15 10:40:21 -0800342 mdp_gdsc_ctrl(enable);
343 mmss_bus_clock_enable();
344 mdp_clock_enable();
345
346 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
347 if (ret) {
348 dprintf(CRITICAL,
349 "%s: Failed to restore MDP security configs",
350 __func__);
351 goto clks_disable;
352 }
353
354 mdss_dsi_auto_pll_20nm_config(pinfo->mipi.pll_0_base,
355 pinfo->mipi.pll_1_base, pll_data);
356
357 if (!dsi_pll_20nm_enable_seq(pinfo->mipi.pll_0_base)) {
358 ret = ERROR;
359 dprintf(CRITICAL, "PLL failed to lock!\n");
360 goto clks_disable;
361 }
362
363 pll_codes->codes[0] = readl_relaxed(pinfo->mipi.pll_0_base +
364 MMSS_DSI_PHY_PLL_CORE_KVCO_CODE);
365 pll_codes->codes[1] = readl_relaxed(pinfo->mipi.pll_0_base +
366 MMSS_DSI_PHY_PLL_CORE_VCO_TUNE);
367 dprintf(SPEW, "codes %d %d\n", pll_codes->codes[0],
368 pll_codes->codes[1]);
369
370 mmss_dsi_clock_enable(DSI0_PHY_PLL_OUT, flags,
371 pll_data->pclk_m,
372 pll_data->pclk_n,
373 pll_data->pclk_d);
374
Dhaval Patel019057a2014-08-12 13:52:25 -0700375 return NO_ERROR;
Huaibin Yang928201b2015-01-15 10:40:21 -0800376
377clks_disable:
378 mdp_clock_disable();
379 mmss_bus_clock_disable();
380 mdp_gdsc_ctrl(0);
381
382 return ret;
Dhaval Patel019057a2014-08-12 13:52:25 -0700383}
384
385int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
386 struct msm_panel_info *pinfo)
387{
388 uint32_t i = 0;
389
390 if (enable) {
391 gpio_tlmm_config(reset_gpio.pin_id, 0,
392 reset_gpio.pin_direction, reset_gpio.pin_pull,
393 reset_gpio.pin_strength, reset_gpio.pin_state);
394 /* reset */
395 for (i = 0; i < RESET_GPIO_SEQ_LEN; i++) {
396 if (resetseq->pin_state[i] == GPIO_STATE_LOW)
397 gpio_set(reset_gpio.pin_id, GPIO_STATE_LOW);
398 else
399 gpio_set(reset_gpio.pin_id, GPIO_STATE_HIGH);
400 mdelay(resetseq->sleep[i]);
401 }
Kuogee Hsieh911866e2014-09-02 16:41:18 -0700402 lcd_bklt_reg_enable();
Dhaval Patel019057a2014-08-12 13:52:25 -0700403 } else {
Kuogee Hsieh911866e2014-09-02 16:41:18 -0700404 lcd_bklt_reg_disable();
Dhaval Patel019057a2014-08-12 13:52:25 -0700405 gpio_set(reset_gpio.pin_id, 0);
406 }
407
408 return NO_ERROR;
409}
410
Kuogee Hsieh099022f2014-12-05 15:43:40 -0800411static void wled_init(struct msm_panel_info *pinfo)
412{
413 struct qpnp_wled_config_data config = {0};
414 struct labibb_desc *labibb;
415 int display_type = 0;
416
417 labibb = pinfo->labibb;
418
419 if (labibb)
420 display_type = labibb->amoled_panel;
421
422 config.display_type = display_type;
423 config.lab_init_volt = 4600000; /* fixed, see pmi register */
424 config.ibb_init_volt = 1400000; /* fixed, see pmi register */
425
426 if (labibb && labibb->force_config) {
427 config.lab_min_volt = labibb->lab_min_volt;
428 config.lab_max_volt = labibb->lab_max_volt;
429 config.ibb_min_volt = labibb->ibb_min_volt;
430 config.ibb_max_volt = labibb->ibb_max_volt;
431 config.pwr_up_delay = labibb->pwr_up_delay;
432 config.pwr_down_delay = labibb->pwr_down_delay;
433 config.ibb_discharge_en = labibb->ibb_discharge_en;
434 } else {
435 /* default */
436 config.pwr_up_delay = 3;
437 config.pwr_down_delay = 3;
438 config.ibb_discharge_en = 1;
439 if (display_type) { /* amoled */
440 config.lab_min_volt = 4600000;
441 config.lab_max_volt = 4600000;
442 config.ibb_min_volt = 4000000;
443 config.ibb_max_volt = 4000000;
444 } else { /* lcd */
445 config.lab_min_volt = 5500000;
446 config.lab_max_volt = 5500000;
447 config.ibb_min_volt = 5500000;
448 config.ibb_max_volt = 5500000;
449 }
450 }
451
452 dprintf(SPEW, "%s: %d %d %d %d %d %d %d %d %d %d\n", __func__,
453 config.display_type,
454 config.lab_min_volt, config.lab_max_volt,
455 config.ibb_min_volt, config.ibb_max_volt,
456 config.lab_init_volt, config.ibb_init_volt,
457 config.pwr_up_delay, config.pwr_down_delay,
458 config.ibb_discharge_en);
459
460
461 /* QPNP WLED init for display backlight */
462 pm8x41_wled_config_slave_id(PMIC_WLED_SLAVE_ID);
463
464 qpnp_wled_init(&config);
465}
466
Kuogee Hsieh93bcff62014-08-22 14:02:08 -0700467int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
Dhaval Patel019057a2014-08-12 13:52:25 -0700468{
469 if (enable) {
470 regulator_enable(); /* L2, L12, L14, and L28 */
471 mdelay(10);
Kuogee Hsieh099022f2014-12-05 15:43:40 -0800472 wled_init(pinfo);
Dhaval Patel019057a2014-08-12 13:52:25 -0700473 qpnp_ibb_enable(true); /* +5V and -5V */
474 mdelay(50);
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700475
476 if (pinfo->lcd_reg_en)
477 lcd_reg_enable();
Dhaval Patel019057a2014-08-12 13:52:25 -0700478 } else {
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700479 if (pinfo->lcd_reg_en)
480 lcd_reg_disable();
481
Dhaval Patel019057a2014-08-12 13:52:25 -0700482 regulator_disable();
483 }
484
485 return NO_ERROR;
486}
487
488int target_display_pre_on()
489{
Ingrid Gallardoc9776bd2014-09-04 14:13:28 -0700490 writel(0xC0000CCC, MDP_CLK_CTRL0);
491 writel(0xC0000CCC, MDP_CLK_CTRL1);
Dhaval Patel019057a2014-08-12 13:52:25 -0700492 writel(0x00CCCCCC, MDP_CLK_CTRL2);
493 writel(0x000000CC, MDP_CLK_CTRL6);
494 writel(0x0CCCC0C0, MDP_CLK_CTRL3);
495 writel(0xCCCCC0C0, MDP_CLK_CTRL4);
496 writel(0xCCCCC0C0, MDP_CLK_CTRL5);
497 writel(0x00CCC000, MDP_CLK_CTRL7);
498
Dhaval Patel019057a2014-08-12 13:52:25 -0700499 return NO_ERROR;
500}
501
Jeevan Shriram7aacc322014-12-29 16:02:25 -0800502int target_display_get_base_offset(uint32_t base)
503{
504 if(platform_is_msm8992()) {
505 if (base == MIPI_DSI0_BASE)
506 return DSI0_BASE_ADJUST;
507 else if (base == MIPI_DSI1_BASE)
508 return DSI1_BASE_ADJUST;
509 }
510
511 return 0;
512}
513
Dhaval Patel019057a2014-08-12 13:52:25 -0700514bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size)
515{
Ajay Singh Parmarcc6477b2014-11-14 16:59:44 -0800516 int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
517 bool ret = true;
Casey Piper4fd18e12015-03-20 16:51:52 -0700518 char vic_buf[HDMI_VIC_LEN] = "0";
Dhaval Patel019057a2014-08-12 13:52:25 -0700519
Ajay Singh Parmarcc6477b2014-11-14 16:59:44 -0800520 panel_name += strspn(panel_name, " ");
521
522 if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
523 if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN +
524 strlen(HDMI_CONTROLLER_STRING))) {
525 dprintf(CRITICAL, "command line argument is greater than buffer size\n");
526 return false;
527 }
528
529 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
530 buf_size -= prefix_string_len;
531 strlcat(pbuf, LK_OVERRIDE_PANEL, buf_size);
532 buf_size -= LK_OVERRIDE_PANEL_LEN;
533 strlcat(pbuf, HDMI_CONTROLLER_STRING, buf_size);
Casey Piper4fd18e12015-03-20 16:51:52 -0700534 buf_size -= strlen(HDMI_CONTROLLER_STRING);
535 mdss_hdmi_get_vic(vic_buf);
536 strlcat(pbuf, vic_buf, buf_size);
Ajay Singh Parmarcc6477b2014-11-14 16:59:44 -0800537 } else {
538 ret = gcdb_display_cmdline_arg(panel_name, pbuf, buf_size);
539 }
540
541 return ret;
Dhaval Patel019057a2014-08-12 13:52:25 -0700542}
543
544void target_display_init(const char *panel_name)
545{
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800546 char cont_splash = '\0';
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700547
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800548 set_panel_cmd_string(panel_name, &cont_splash);
549 panel_name += strspn(panel_name, " ");
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700550 if (!strcmp(panel_name, NO_PANEL_CONFIG)
551 || !strcmp(panel_name, SIM_VIDEO_PANEL)
552 || !strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)
553 || !strcmp(panel_name, SIM_CMD_PANEL)
554 || !strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) {
Veera Sundaram Sankaranb620f232014-09-03 22:43:53 -0700555 dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700556 panel_name);
Veera Sundaram Sankaranb620f232014-09-03 22:43:53 -0700557 return;
Ajay Singh Parmarcc6477b2014-11-14 16:59:44 -0800558 } else if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
559 return;
Veera Sundaram Sankaranb620f232014-09-03 22:43:53 -0700560 }
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800561
Veera Sundaram Sankaran089f70d2014-12-09 14:17:05 -0800562 if (gcdb_display_init(panel_name, MDP_REV_50, (void *)MIPI_FB_ADDR)) {
Justin Philipbe9de5c2014-09-17 12:26:49 +0530563 target_force_cont_splash_disable(true);
Dhaval Patel019057a2014-08-12 13:52:25 -0700564 msm_display_off();
Justin Philipbe9de5c2014-09-17 12:26:49 +0530565 }
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800566
567 if (cont_splash == '0') {
568 dprintf(INFO, "Forcing continuous splash disable\n");
569 target_force_cont_splash_disable(true);
570 }
Dhaval Patel019057a2014-08-12 13:52:25 -0700571}
572
573void target_display_shutdown(void)
574{
575 gcdb_display_shutdown();
576}