blob: 2f27fda1fd84d8caeb57ea32f315db0bc1d37349 [file] [log] [blame]
Umang Agrawald1939942018-02-13 16:23:58 +05301/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -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>
31#include <string.h>
32#include <smem.h>
33#include <err.h>
34#include <msm_panel.h>
35#include <mipi_dsi.h>
36#include <pm8x41.h>
37#include <pm8x41_wled.h>
38#include <qpnp_wled.h>
Umang Agrawald1939942018-02-13 16:23:58 +053039#include <qpnp_lcdb.h>
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070040#include <board.h>
41#include <mdp5.h>
42#include <scm.h>
43#include <regulator.h>
44#include <platform/clock.h>
45#include <platform/gpio.h>
46#include <platform/iomap.h>
47#include <target/display.h>
48#include <qtimer.h>
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +053049#include <platform.h>
Umang Agrawald1939942018-02-13 16:23:58 +053050#include <target.h>
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070051
52#include "include/panel.h"
53#include "include/display_resource.h"
54#include "gcdb_display.h"
55
Ashish Garg9cfd6ca2016-12-20 01:41:54 +053056#define TRULY_720P_VID_PANEL "truly_720p_video"
57#define TRULY_720P_CMD_PANEL "truly_720p_cmd"
58
59#define HDMI_ADV_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_adv7533_1080p:1:none:cfg:single_dsi"
60#define TRULY_VID_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_video:1:none:cfg:single_dsi"
61#define TRULY_CMD_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_cmd:1:none:cfg:single_dsi"
62
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070063/*---------------------------------------------------------------------------*/
64/* GPIO configuration */
65/*---------------------------------------------------------------------------*/
66static struct gpio_pin reset_gpio = {
67 "msmgpio", 0, 3, 1, 0, 1
68};
69
70static struct gpio_pin enable_gpio = {
71 "msmgpio", 90, 3, 1, 0, 1
72};
73
74static struct gpio_pin bkl_gpio = {
75 "msmgpio", 91, 3, 1, 0, 1
76};
77
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +053078static struct gpio_pin lcd_mode_gpio = {
79 "msmgpio", 107, 3, 1, 0, 1
80};
81
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070082#define VCO_DELAY_USEC 1000
83#define GPIO_STATE_LOW 0
84#define GPIO_STATE_HIGH 2
85#define RESET_GPIO_SEQ_LEN 3
86#define PMIC_WLED_SLAVE_ID 3
87
Padmanabhan Komandurub3381932015-06-15 22:14:02 +053088#define DSI0_BASE_ADJUST -0x4000
89#define DSI0_PHY_BASE_ADJUST -0x4100
90#define DSI0_PHY_PLL_BASE_ADJUST -0x3900
91#define DSI0_PHY_REGULATOR_BASE_ADJUST -0x3C00
92
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070093static void mdss_dsi_uniphy_pll_sw_reset_8952(uint32_t pll_base)
94{
95 writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */
96 mdelay(1);
97 writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */
98 mdelay(1);
99}
100
101static void dsi_pll_toggle_lock_detect_8952(uint32_t pll_base)
102{
103 writel(0x04, pll_base + 0x0064); /* LKDetect CFG2 */
104 udelay(1);
105 writel(0x05, pll_base + 0x0064); /* LKDetect CFG2 */
106 udelay(512);
107}
108
109static void dsi_pll_sw_reset_8952(uint32_t pll_base)
110{
111 writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */
112 udelay(1);
113 writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */
Padmanabhan Komanduru6cf63522015-06-08 14:48:00 +0530114 udelay(1);
115}
116
117static uint32_t dsi_pll_lock_status_8956(uint32_t pll_base)
118{
119 uint32_t counter, status;
120
121 status = readl(pll_base + 0x00c0) & 0x01;
122 for (counter = 0; counter < 5 && !status; counter++) {
123 udelay(100);
124 status = readl(pll_base + 0x00c0) & 0x01;
125 }
126
127 return status;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700128}
129
130static uint32_t gf_1_dsi_pll_enable_sequence_8952(uint32_t pll_base)
131{
132 uint32_t rc;
133
134 dsi_pll_sw_reset_8952(pll_base);
135
136 /*
137 * Add hardware recommended delays between register writes for
138 * the updates to take effect. These delays are necessary for the
139 * PLL to successfully lock
140 */
141 writel(0x14, pll_base + 0x0070); /* CAL CFG1*/
142 writel(0x01, pll_base + 0x0020); /* GLB CFG */
143 writel(0x05, pll_base + 0x0020); /* GLB CFG */
144 udelay(3);
145 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
146 udelay(500);
147
148 dsi_pll_toggle_lock_detect_8952(pll_base);
149 rc = readl(pll_base + 0x00c0) & 0x01;
150
151 return rc;
152}
153
154static uint32_t gf_2_dsi_pll_enable_sequence_8952(uint32_t pll_base)
155{
156 uint32_t rc;
157
158 dsi_pll_sw_reset_8952(pll_base);
159
160 /*
161 * Add hardware recommended delays between register writes for
162 * the updates to take effect. These delays are necessary for the
163 * PLL to successfully lock
164 */
165 writel(0x04, pll_base + 0x0070); /* CAL CFG1*/
166 writel(0x01, pll_base + 0x0020); /* GLB CFG */
167 writel(0x05, pll_base + 0x0020); /* GLB CFG */
168 udelay(3);
169 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
170 udelay(500);
171
172 dsi_pll_toggle_lock_detect_8952(pll_base);
173 rc = readl(pll_base + 0x00c0) & 0x01;
174
175 return rc;
176}
177
178static uint32_t tsmc_dsi_pll_enable_sequence_8952(uint32_t pll_base)
179{
180 uint32_t rc;
181
182 dsi_pll_sw_reset_8952(pll_base);
183 /*
184 * Add hardware recommended delays between register writes for
185 * the updates to take effect. These delays are necessary for the
186 * PLL to successfully lock
187 */
188
189 writel(0x34, pll_base + 0x0070); /* CAL CFG1*/
190 writel(0x01, pll_base + 0x0020); /* GLB CFG */
191 writel(0x05, pll_base + 0x0020); /* GLB CFG */
192 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
193 udelay(500);
194
195 dsi_pll_toggle_lock_detect_8952(pll_base);
196 rc = readl(pll_base + 0x00c0) & 0x01;
197
198 return rc;
199}
200
201
202static uint32_t dsi_pll_enable_seq_8952(uint32_t pll_base)
203{
204 uint32_t pll_locked = 0;
205 uint32_t counter = 0;
206
207 do {
208 pll_locked = tsmc_dsi_pll_enable_sequence_8952(pll_base);
209
210 dprintf(SPEW, "TSMC pll locked status is %d\n", pll_locked);
211 ++counter;
212 } while (!pll_locked && (counter < 3));
213
214 if(!pll_locked) {
215 counter = 0;
216 do {
217 pll_locked = gf_1_dsi_pll_enable_sequence_8952(pll_base);
218
219 dprintf(SPEW, "GF P1 pll locked status is %d\n", pll_locked);
220 ++counter;
221 } while (!pll_locked && (counter < 3));
222 }
223
224 if(!pll_locked) {
225 counter = 0;
226 do {
227 pll_locked = gf_2_dsi_pll_enable_sequence_8952(pll_base);
228
229 dprintf(SPEW, "GF P2 pll locked status is %d\n", pll_locked);
230 ++counter;
231 } while (!pll_locked && (counter < 3));
232 }
233
234 return pll_locked;
235}
236
Padmanabhan Komanduru6cf63522015-06-08 14:48:00 +0530237static uint32_t dsi_pll_enable_seq_8956(uint32_t pll_base)
238{
239 /*
240 * PLL power up sequence
241 * Add necessary delays recommended by h/w team
242 */
243
244 /* Lock Detect setting */
245 writel(0x0d, pll_base + 0x0064); /* LKDetect CFG2 */
246 writel(0x34, pll_base + 0x0070); /* PLL CAL_CFG1 */
247 writel(0x10, pll_base + 0x005c); /* LKDetect CFG0 */
248 writel(0x1a, pll_base + 0x0060); /* LKDetect CFG1 */
249
250 writel(0x01, pll_base + 0x0020); /* GLB CFG */
251 udelay(300);
252 writel(0x05, pll_base + 0x0020); /* GLB CFG */
253 udelay(300);
254 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
255 udelay(300);
256 writel(0x07, pll_base + 0x0020); /* GLB CFG */
257 udelay(300);
258 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
259 udelay(1000);
260
261 return dsi_pll_lock_status_8956(pll_base);
262}
263
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700264static int msm8952_wled_backlight_ctrl(uint8_t enable)
265{
266 uint8_t slave_id = PMIC_WLED_SLAVE_ID; /* pmi */
267
268 pm8x41_wled_config_slave_id(slave_id);
Umang Agrawald1939942018-02-13 16:23:58 +0530269 if (target_get_pmic() == PMIC_IS_PMI632) {
270 qpnp_lcdb_enable(enable);
271 }
272 else {
273 qpnp_wled_enable_backlight(enable);
274 qpnp_ibb_enable(enable);
275 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700276 return NO_ERROR;
277}
278
279int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
280{
281 uint32_t ret = NO_ERROR;
282
283 if (bl->bl_interface_type == BL_DCS)
284 return ret;
285
286 ret = msm8952_wled_backlight_ctrl(enable);
287
288 return ret;
289}
290
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530291static int32_t mdss_dsi_pll_config(uint32_t pll_base, uint32_t ctl_base,
292 struct mdss_dsi_pll_config *pll_data)
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700293{
294 int32_t ret = 0;
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530295 if (!platform_is_msm8956())
296 mdss_dsi_uniphy_pll_sw_reset_8952(pll_base);
297 else
298 dsi_pll_sw_reset_8952(pll_base);
299 mdss_dsi_auto_pll_config(pll_base, ctl_base, pll_data);
300 if (platform_is_msm8956())
301 ret = dsi_pll_enable_seq_8956(pll_base);
302 else
303 ret = dsi_pll_enable_seq_8952(pll_base);
304
305 return ret;
306}
307
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700308int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
309{
Padmanabhan Komanduru82ae7132015-06-08 15:46:33 +0530310 int32_t ret = 0, flags;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700311 struct mdss_dsi_pll_config *pll_data;
312 dprintf(SPEW, "target_panel_clock\n");
313
Padmanabhan Komanduru82ae7132015-06-08 15:46:33 +0530314 if (pinfo->dest == DISPLAY_2) {
315 flags = MMSS_DSI_CLKS_FLAG_DSI1;
316 if (pinfo->mipi.dual_dsi)
317 flags |= MMSS_DSI_CLKS_FLAG_DSI0;
318 } else {
319 flags = MMSS_DSI_CLKS_FLAG_DSI0;
320 if (pinfo->mipi.dual_dsi)
321 flags |= MMSS_DSI_CLKS_FLAG_DSI1;
322 }
323
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700324 pll_data = pinfo->mipi.dsi_pll_config;
325 pll_data->vco_delay = VCO_DELAY_USEC;
326
Padmanabhan Komanduruf68f51b2015-12-21 18:32:12 +0530327 /* SSC parameters */
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530328 if (platform_is_msm8937() || platform_is_msm8917()) {
Padmanabhan Komanduruf68f51b2015-12-21 18:32:12 +0530329 pll_data->ssc_en = true;
330 pll_data->is_center_spread = false;
331 pll_data->ssc_freq = 30000;
332 pll_data->ssc_ppm = 5000;
333 }
334
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700335 if (enable) {
336 mdp_gdsc_ctrl(enable);
337 mdss_bus_clocks_enable();
338 mdp_clock_enable();
339 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
340 if (ret) {
341 dprintf(CRITICAL,
342 "%s: Failed to restore MDP security configs",
343 __func__);
344 mdp_clock_disable();
345 mdss_bus_clocks_disable();
346 mdp_gdsc_ctrl(0);
347 return ret;
348 }
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530349
350 ret = mdss_dsi_pll_config(pinfo->mipi.pll_base,
351 pinfo->mipi.ctl_base, pll_data);
Padmanabhan Komanduru6cf63522015-06-08 14:48:00 +0530352 if (!ret)
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530353 dprintf(CRITICAL, "Not able to enable master pll\n");
354
Padmanabhan Komanduru2a6c3452015-09-09 18:46:06 +0530355 if (platform_is_msm8956() && pinfo->mipi.dual_dsi &&
356 !platform_is_msm8976_v_1_1()) {
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530357 ret = mdss_dsi_pll_config(pinfo->mipi.spll_base,
358 pinfo->mipi.sctl_base, pll_data);
359 if (!ret)
360 dprintf(CRITICAL, "Not able to enable second pll\n");
361 }
362
Padmanabhan Komanduru2a6c3452015-09-09 18:46:06 +0530363 gcc_dsi_clocks_enable(flags, pinfo->mipi.use_dsi1_pll,
364 pll_data->pclk_m, pll_data->pclk_n, pll_data->pclk_d);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700365 } else if(!target_cont_splash_screen()) {
Padmanabhan Komanduru82ae7132015-06-08 15:46:33 +0530366 gcc_dsi_clocks_disable(flags);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700367 mdp_clock_disable();
368 mdss_bus_clocks_disable();
369 mdp_gdsc_ctrl(enable);
370 }
371
372 return 0;
373}
374
375int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
376 struct msm_panel_info *pinfo)
377{
378 int ret = NO_ERROR;
Sujeev Dias6bc9fa32015-08-03 23:13:44 -0700379 uint32_t hw_id = board_hardware_id();
380 uint32_t hw_subtype = board_hardware_subtype();
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700381
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530382 if (platform_is_msm8956()) {
383 reset_gpio.pin_id = 25;
384 bkl_gpio.pin_id = 66;
Padmanabhan Komandurub3231322015-11-12 16:54:21 +0530385 } else if (platform_is_msm8937()) {
386 reset_gpio.pin_id = 60;
387 bkl_gpio.pin_id = 98;
388 enable_gpio.pin_id = 99;
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530389 } else if (platform_is_msm8917()) {
Jayant Shekhar9c0533e2016-01-28 11:17:18 +0530390 reset_gpio.pin_id = 60;
391 bkl_gpio.pin_id = 98;
392 pinfo->mipi.use_enable_gpio = 0;
Sujeev Dias6bc9fa32015-08-03 23:13:44 -0700393 } else if ((hw_id == HW_PLATFORM_QRD) &&
394 (hw_subtype == HW_PLATFORM_SUBTYPE_POLARIS)) {
395 enable_gpio.pin_id = 19;
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530396 }
397
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700398 if (enable) {
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530399 if (pinfo->mipi.use_enable_gpio && !platform_is_msm8956()) {
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700400 gpio_tlmm_config(enable_gpio.pin_id, 0,
401 enable_gpio.pin_direction, enable_gpio.pin_pull,
402 enable_gpio.pin_strength,
403 enable_gpio.pin_state);
404
405 gpio_set_dir(enable_gpio.pin_id, 2);
406 }
407
408 gpio_tlmm_config(bkl_gpio.pin_id, 0,
409 bkl_gpio.pin_direction, bkl_gpio.pin_pull,
410 bkl_gpio.pin_strength, bkl_gpio.pin_state);
411
412 gpio_set_dir(bkl_gpio.pin_id, 2);
413
414 gpio_tlmm_config(reset_gpio.pin_id, 0,
415 reset_gpio.pin_direction, reset_gpio.pin_pull,
416 reset_gpio.pin_strength, reset_gpio.pin_state);
417
418 gpio_set_dir(reset_gpio.pin_id, 2);
419
420 /* reset */
421 for (int i = 0; i < RESET_GPIO_SEQ_LEN; i++) {
422 if (resetseq->pin_state[i] == GPIO_STATE_LOW)
423 gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_LOW);
424 else
425 gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_HIGH);
426 mdelay(resetseq->sleep[i]);
427 }
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530428
429 if (platform_is_msm8956()) {
430 gpio_tlmm_config(lcd_mode_gpio.pin_id, 0,
431 lcd_mode_gpio.pin_direction, lcd_mode_gpio.pin_pull,
432 lcd_mode_gpio.pin_strength, lcd_mode_gpio.pin_state);
433
434 if (pinfo->lcdc.split_display || pinfo->lcdc.dst_split)
435 gpio_set_dir(lcd_mode_gpio.pin_id, GPIO_STATE_LOW);
436 else
437 gpio_set_dir(lcd_mode_gpio.pin_id, GPIO_STATE_HIGH);
438 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700439 } else if(!target_cont_splash_screen()) {
440 gpio_set_dir(reset_gpio.pin_id, 0);
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530441 if (pinfo->mipi.use_enable_gpio && !platform_is_msm8956())
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700442 gpio_set_dir(enable_gpio.pin_id, 0);
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530443 if (platform_is_msm8956())
444 gpio_set_dir(lcd_mode_gpio.pin_id, 0);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700445 }
446
447 return ret;
448}
449
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530450static int wled_init(struct msm_panel_info *pinfo)
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700451{
452 struct qpnp_wled_config_data config = {0};
453 struct labibb_desc *labibb;
454 int display_type = 0;
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530455 bool swire_control = 0;
456 bool wled_avdd_control = 0;
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530457 int rc = NO_ERROR;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700458
459 labibb = pinfo->labibb;
460
461 if (labibb)
462 display_type = labibb->amoled_panel;
463
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530464 if (display_type) {
465 swire_control = labibb->swire_control;
466 wled_avdd_control = true;
467 } else {
468 swire_control = false;
469 wled_avdd_control = false;
470 }
471
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700472 config.display_type = display_type;
473 config.lab_init_volt = 4600000; /* fixed, see pmi register */
474 config.ibb_init_volt = 1400000; /* fixed, see pmi register */
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530475 config.lab_ibb_swire_control = swire_control;
476 config.wled_avdd_control = wled_avdd_control;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700477
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530478 if(!swire_control) {
479 if (labibb && labibb->force_config) {
480 config.lab_min_volt = labibb->lab_min_volt;
481 config.lab_max_volt = labibb->lab_max_volt;
482 config.ibb_min_volt = labibb->ibb_min_volt;
483 config.ibb_max_volt = labibb->ibb_max_volt;
484 config.pwr_up_delay = labibb->pwr_up_delay;
485 config.pwr_down_delay = labibb->pwr_down_delay;
486 config.ibb_discharge_en = labibb->ibb_discharge_en;
487 } else {
488 /* default */
489 config.pwr_up_delay = 3;
490 config.pwr_down_delay = 3;
491 config.ibb_discharge_en = 1;
492 if (display_type) { /* amoled */
493 config.lab_min_volt = 4600000;
494 config.lab_max_volt = 4600000;
495 config.ibb_min_volt = 4000000;
496 config.ibb_max_volt = 4000000;
497 } else { /* lcd */
498 config.lab_min_volt = 5500000;
499 config.lab_max_volt = 5500000;
500 config.ibb_min_volt = 5500000;
501 config.ibb_max_volt = 5500000;
502 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700503 }
504 }
505
506 dprintf(SPEW, "%s: %d %d %d %d %d %d %d %d %d %d\n", __func__,
507 config.display_type,
508 config.lab_min_volt, config.lab_max_volt,
509 config.ibb_min_volt, config.ibb_max_volt,
510 config.lab_init_volt, config.ibb_init_volt,
511 config.pwr_up_delay, config.pwr_down_delay,
512 config.ibb_discharge_en);
513
514 /* QPNP WLED init for display backlight */
515 pm8x41_wled_config_slave_id(PMIC_WLED_SLAVE_ID);
516
Umang Agrawald1939942018-02-13 16:23:58 +0530517 if (target_get_pmic() == PMIC_IS_PMI632)
518 rc = qpnp_lcdb_init(&config);
519 else
520 rc = qpnp_wled_init(&config);
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530521
522 return rc;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700523}
524
Dhaval Patel7709c412015-05-12 10:09:41 -0700525int target_dsi_phy_config(struct mdss_dsi_phy_ctrl *phy_db)
526{
527 memcpy(phy_db->regulator, panel_regulator_settings, REGULATOR_SIZE);
528 memcpy(phy_db->ctrl, panel_physical_ctrl, PHYSICAL_SIZE);
529 memcpy(phy_db->strength, panel_strength_ctrl, STRENGTH_SIZE);
530 memcpy(phy_db->bistCtrl, panel_bist_ctrl, BIST_SIZE);
531 memcpy(phy_db->laneCfg, panel_lane_config, LANE_SIZE);
532 return NO_ERROR;
533}
534
Padmanabhan Komandurub3381932015-06-15 22:14:02 +0530535int target_display_get_base_offset(uint32_t base)
536{
Jayant Shekhar9c0533e2016-01-28 11:17:18 +0530537 if(platform_is_msm8956() || platform_is_msm8937() ||
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530538 platform_is_msm8917()) {
Padmanabhan Komandurub3381932015-06-15 22:14:02 +0530539 if (base == MIPI_DSI0_BASE)
540 return DSI0_BASE_ADJUST;
541 else if (base == DSI0_PHY_BASE)
542 return DSI0_PHY_BASE_ADJUST;
543 else if (base == DSI0_PLL_BASE)
544 return DSI0_PHY_PLL_BASE_ADJUST;
545 else if (base == DSI0_REGULATOR_BASE)
546 return DSI0_PHY_REGULATOR_BASE_ADJUST;
547 }
548
549 return 0;
550}
551
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700552int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
553{
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530554 int rc = 0;
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530555 uint32_t ldo_num = REG_LDO6 | REG_LDO17;
556
557 if (platform_is_msm8956())
558 ldo_num |= REG_LDO1;
559 else
560 ldo_num |= REG_LDO2;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700561
562 if (enable) {
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530563 regulator_enable(ldo_num);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700564 mdelay(10);
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530565 rc = wled_init(pinfo);
566 if (rc) {
567 dprintf(CRITICAL, "%s: wled init failed\n", __func__);
568 return rc;
569 }
Umang Agrawald1939942018-02-13 16:23:58 +0530570 if (target_get_pmic() == PMIC_IS_PMI632)
571 rc = qpnp_lcdb_enable(true);
572 else
573 rc = qpnp_ibb_enable(true); /*5V boost*/
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530574 if (rc) {
Umang Agrawald1939942018-02-13 16:23:58 +0530575 dprintf(CRITICAL, "%s: qpnp_ibb/lcdb failed\n", __func__);
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530576 return rc;
577 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700578 mdelay(50);
579 } else {
Padmanabhan Komandurufa2899b2015-06-30 16:25:33 +0530580 /*
581 * LDO1, LDO2 and LDO6 are shared with other subsystems.
582 * Do not disable them.
583 */
584 regulator_disable(REG_LDO17);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700585 }
586
587 return NO_ERROR;
588}
589
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530590bool target_display_panel_node(char *pbuf, uint16_t buf_size)
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700591{
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530592 int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
593 bool ret = true;
594 struct oem_panel_data oem = mdss_dsi_get_oem_data();
595 uint32_t platform_subtype = board_hardware_subtype();
596
597 /* default to hdmi for apq iot */
Parth Dixitacec6bf2017-02-27 19:06:39 +0530598 if ((HW_PLATFORM_SUBTYPE_SAP == platform_subtype) ||
599 (HW_PLATFORM_SUBTYPE_SAP_NOPMI == platform_subtype)) {
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530600 if (!strcmp(oem.panel, "")) {
601 if (buf_size < (prefix_string_len +
602 strlen(HDMI_ADV_PANEL_STRING))) {
603 dprintf(CRITICAL, "HDMI command line argument \
604 is greater than buffer size\n");
605 return false;
606 }
607 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
608 buf_size -= prefix_string_len;
609 pbuf += prefix_string_len;
610 strlcpy(pbuf, HDMI_ADV_PANEL_STRING, buf_size);
611 } else if (!strcmp(oem.panel, TRULY_720P_VID_PANEL)) {
612 if (buf_size < (prefix_string_len +
613 strlen(TRULY_VID_PANEL_STRING))) {
614 dprintf(CRITICAL, "TRULY VIDEO command line \
615 argument is greater than \
616 buffer size\n");
617 return false;
618 }
619 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
620 buf_size -= prefix_string_len;
621 pbuf += prefix_string_len;
622 strlcpy(pbuf, TRULY_VID_PANEL_STRING, buf_size);
623 } else if (!strcmp(oem.panel, TRULY_720P_CMD_PANEL)) {
624 if (buf_size < (prefix_string_len +
625 strlen(TRULY_CMD_PANEL_STRING))) {
626 dprintf(CRITICAL, "TRULY CMD command line argument \
627 argument is greater than \
628 buffer size\n");
629 return false;
630 }
631 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
632 buf_size -= prefix_string_len;
633 pbuf += prefix_string_len;
634 strlcpy(pbuf, TRULY_CMD_PANEL_STRING, buf_size);
635 }
636 } else {
637 ret = gcdb_display_cmdline_arg(pbuf, buf_size);
638 }
639
640 return ret;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700641}
642
643void target_display_init(const char *panel_name)
644{
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530645 struct oem_panel_data oem;
Ray Zhangf95f5b92015-06-25 15:34:29 +0800646 int32_t ret = 0;
647 uint32_t panel_loop = 0;
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530648 uint32_t platform_subtype = board_hardware_subtype();
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700649
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530650 set_panel_cmd_string(panel_name);
651 oem = mdss_dsi_get_oem_data();
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700652
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530653 if (!strcmp(oem.panel, NO_PANEL_CONFIG)
654 || !strcmp(oem.panel, SIM_VIDEO_PANEL)
655 || !strcmp(oem.panel, SIM_CMD_PANEL)
656 || oem.skip) {
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700657 dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530658 oem.panel);
Vishnuvardhan Prodduturi4cd56382017-08-22 21:46:38 +0530659 oem.cont_splash = false;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700660 }
661
Parth Dixitacec6bf2017-02-27 19:06:39 +0530662 if ((HW_PLATFORM_SUBTYPE_SAP == platform_subtype) ||
663 (HW_PLATFORM_SUBTYPE_SAP_NOPMI == platform_subtype)) {
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530664 dprintf(INFO, "%s: Platform subtype %d\n",
665 __func__, platform_subtype);
666 return;
667 }
668
Ray Zhangf95f5b92015-06-25 15:34:29 +0800669 do {
670 target_force_cont_splash_disable(false);
671 ret = gcdb_display_init(oem.panel, MDP_REV_50, (void *)MIPI_FB_ADDR);
672 if (!ret || ret == ERR_NOT_SUPPORTED) {
673 break;
674 } else {
675 target_force_cont_splash_disable(true);
676 msm_display_off();
677 }
678 } while (++panel_loop <= oem_panel_max_auto_detect_panels());
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700679
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530680 if (!oem.cont_splash) {
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700681 dprintf(INFO, "Forcing continuous splash disable\n");
682 target_force_cont_splash_disable(true);
683 }
684}
685
686void target_display_shutdown(void)
687{
688 gcdb_display_shutdown();
689}