blob: 68baa709cfbd8b0557b5961849fb848de83db8d9 [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
Lei Chen2c11b462018-04-11 18:42:37 +080056#define PWM_DUTY_US 13
57#define PWM_PERIOD_US 27
58
Ashish Garg9cfd6ca2016-12-20 01:41:54 +053059#define TRULY_720P_VID_PANEL "truly_720p_video"
60#define TRULY_720P_CMD_PANEL "truly_720p_cmd"
61
62#define HDMI_ADV_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_adv7533_1080p:1:none:cfg:single_dsi"
63#define TRULY_VID_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_video:1:none:cfg:single_dsi"
64#define TRULY_CMD_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_cmd:1:none:cfg:single_dsi"
65
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070066/*---------------------------------------------------------------------------*/
67/* GPIO configuration */
68/*---------------------------------------------------------------------------*/
69static struct gpio_pin reset_gpio = {
70 "msmgpio", 0, 3, 1, 0, 1
71};
72
73static struct gpio_pin enable_gpio = {
74 "msmgpio", 90, 3, 1, 0, 1
75};
76
77static struct gpio_pin bkl_gpio = {
78 "msmgpio", 91, 3, 1, 0, 1
79};
80
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +053081static struct gpio_pin lcd_mode_gpio = {
82 "msmgpio", 107, 3, 1, 0, 1
83};
84
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070085#define VCO_DELAY_USEC 1000
86#define GPIO_STATE_LOW 0
87#define GPIO_STATE_HIGH 2
88#define RESET_GPIO_SEQ_LEN 3
89#define PMIC_WLED_SLAVE_ID 3
90
Padmanabhan Komandurub3381932015-06-15 22:14:02 +053091#define DSI0_BASE_ADJUST -0x4000
92#define DSI0_PHY_BASE_ADJUST -0x4100
93#define DSI0_PHY_PLL_BASE_ADJUST -0x3900
94#define DSI0_PHY_REGULATOR_BASE_ADJUST -0x3C00
95
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -070096static void mdss_dsi_uniphy_pll_sw_reset_8952(uint32_t pll_base)
97{
98 writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */
99 mdelay(1);
100 writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */
101 mdelay(1);
102}
103
104static void dsi_pll_toggle_lock_detect_8952(uint32_t pll_base)
105{
106 writel(0x04, pll_base + 0x0064); /* LKDetect CFG2 */
107 udelay(1);
108 writel(0x05, pll_base + 0x0064); /* LKDetect CFG2 */
109 udelay(512);
110}
111
112static void dsi_pll_sw_reset_8952(uint32_t pll_base)
113{
114 writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */
115 udelay(1);
116 writel(0x00, pll_base + 0x0068); /* PLL TEST CFG */
Padmanabhan Komanduru6cf63522015-06-08 14:48:00 +0530117 udelay(1);
118}
119
120static uint32_t dsi_pll_lock_status_8956(uint32_t pll_base)
121{
122 uint32_t counter, status;
123
124 status = readl(pll_base + 0x00c0) & 0x01;
125 for (counter = 0; counter < 5 && !status; counter++) {
126 udelay(100);
127 status = readl(pll_base + 0x00c0) & 0x01;
128 }
129
130 return status;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700131}
132
133static uint32_t gf_1_dsi_pll_enable_sequence_8952(uint32_t pll_base)
134{
135 uint32_t rc;
136
137 dsi_pll_sw_reset_8952(pll_base);
138
139 /*
140 * Add hardware recommended delays between register writes for
141 * the updates to take effect. These delays are necessary for the
142 * PLL to successfully lock
143 */
144 writel(0x14, pll_base + 0x0070); /* CAL CFG1*/
145 writel(0x01, pll_base + 0x0020); /* GLB CFG */
146 writel(0x05, pll_base + 0x0020); /* GLB CFG */
147 udelay(3);
148 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
149 udelay(500);
150
151 dsi_pll_toggle_lock_detect_8952(pll_base);
152 rc = readl(pll_base + 0x00c0) & 0x01;
153
154 return rc;
155}
156
157static uint32_t gf_2_dsi_pll_enable_sequence_8952(uint32_t pll_base)
158{
159 uint32_t rc;
160
161 dsi_pll_sw_reset_8952(pll_base);
162
163 /*
164 * Add hardware recommended delays between register writes for
165 * the updates to take effect. These delays are necessary for the
166 * PLL to successfully lock
167 */
168 writel(0x04, pll_base + 0x0070); /* CAL CFG1*/
169 writel(0x01, pll_base + 0x0020); /* GLB CFG */
170 writel(0x05, pll_base + 0x0020); /* GLB CFG */
171 udelay(3);
172 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
173 udelay(500);
174
175 dsi_pll_toggle_lock_detect_8952(pll_base);
176 rc = readl(pll_base + 0x00c0) & 0x01;
177
178 return rc;
179}
180
181static uint32_t tsmc_dsi_pll_enable_sequence_8952(uint32_t pll_base)
182{
183 uint32_t rc;
184
185 dsi_pll_sw_reset_8952(pll_base);
186 /*
187 * Add hardware recommended delays between register writes for
188 * the updates to take effect. These delays are necessary for the
189 * PLL to successfully lock
190 */
191
192 writel(0x34, pll_base + 0x0070); /* CAL CFG1*/
193 writel(0x01, pll_base + 0x0020); /* GLB CFG */
194 writel(0x05, pll_base + 0x0020); /* GLB CFG */
195 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
196 udelay(500);
197
198 dsi_pll_toggle_lock_detect_8952(pll_base);
199 rc = readl(pll_base + 0x00c0) & 0x01;
200
201 return rc;
202}
203
204
205static uint32_t dsi_pll_enable_seq_8952(uint32_t pll_base)
206{
207 uint32_t pll_locked = 0;
208 uint32_t counter = 0;
209
210 do {
211 pll_locked = tsmc_dsi_pll_enable_sequence_8952(pll_base);
212
213 dprintf(SPEW, "TSMC pll locked status is %d\n", pll_locked);
214 ++counter;
215 } while (!pll_locked && (counter < 3));
216
217 if(!pll_locked) {
218 counter = 0;
219 do {
220 pll_locked = gf_1_dsi_pll_enable_sequence_8952(pll_base);
221
222 dprintf(SPEW, "GF P1 pll locked status is %d\n", pll_locked);
223 ++counter;
224 } while (!pll_locked && (counter < 3));
225 }
226
227 if(!pll_locked) {
228 counter = 0;
229 do {
230 pll_locked = gf_2_dsi_pll_enable_sequence_8952(pll_base);
231
232 dprintf(SPEW, "GF P2 pll locked status is %d\n", pll_locked);
233 ++counter;
234 } while (!pll_locked && (counter < 3));
235 }
236
237 return pll_locked;
238}
239
Padmanabhan Komanduru6cf63522015-06-08 14:48:00 +0530240static uint32_t dsi_pll_enable_seq_8956(uint32_t pll_base)
241{
242 /*
243 * PLL power up sequence
244 * Add necessary delays recommended by h/w team
245 */
246
247 /* Lock Detect setting */
248 writel(0x0d, pll_base + 0x0064); /* LKDetect CFG2 */
249 writel(0x34, pll_base + 0x0070); /* PLL CAL_CFG1 */
250 writel(0x10, pll_base + 0x005c); /* LKDetect CFG0 */
251 writel(0x1a, pll_base + 0x0060); /* LKDetect CFG1 */
252
253 writel(0x01, pll_base + 0x0020); /* GLB CFG */
254 udelay(300);
255 writel(0x05, pll_base + 0x0020); /* GLB CFG */
256 udelay(300);
257 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
258 udelay(300);
259 writel(0x07, pll_base + 0x0020); /* GLB CFG */
260 udelay(300);
261 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
262 udelay(1000);
263
264 return dsi_pll_lock_status_8956(pll_base);
265}
266
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700267static int msm8952_wled_backlight_ctrl(uint8_t enable)
268{
269 uint8_t slave_id = PMIC_WLED_SLAVE_ID; /* pmi */
270
271 pm8x41_wled_config_slave_id(slave_id);
Umang Agrawald1939942018-02-13 16:23:58 +0530272 if (target_get_pmic() == PMIC_IS_PMI632) {
273 qpnp_lcdb_enable(enable);
274 }
275 else {
276 qpnp_wled_enable_backlight(enable);
277 qpnp_ibb_enable(enable);
278 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700279 return NO_ERROR;
280}
281
Lei Chen2c11b462018-04-11 18:42:37 +0800282static int pwm_backlight_ctrl(uint8_t enable)
283{
284 if (enable) {
285 pm_pwm_enable(false);
286 pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
287 pm_pwm_enable(true);
288 } else {
289 pm_pwm_enable(false);
290 }
291
292 return NO_ERROR;
293}
294
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700295int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
296{
297 uint32_t ret = NO_ERROR;
298
299 if (bl->bl_interface_type == BL_DCS)
300 return ret;
301
Lei Chen2c11b462018-04-11 18:42:37 +0800302 if ((target_get_pmic() == PMIC_IS_PMI632) &&
303 (bl->bl_interface_type == BL_PWM)) {
304 ret = pwm_backlight_ctrl(enable);
305 } else {
306 ret = msm8952_wled_backlight_ctrl(enable);
307 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700308 return ret;
309}
310
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530311static int32_t mdss_dsi_pll_config(uint32_t pll_base, uint32_t ctl_base,
312 struct mdss_dsi_pll_config *pll_data)
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700313{
314 int32_t ret = 0;
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530315 if (!platform_is_msm8956())
316 mdss_dsi_uniphy_pll_sw_reset_8952(pll_base);
317 else
318 dsi_pll_sw_reset_8952(pll_base);
319 mdss_dsi_auto_pll_config(pll_base, ctl_base, pll_data);
320 if (platform_is_msm8956())
321 ret = dsi_pll_enable_seq_8956(pll_base);
322 else
323 ret = dsi_pll_enable_seq_8952(pll_base);
324
325 return ret;
326}
327
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700328int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
329{
Padmanabhan Komanduru82ae7132015-06-08 15:46:33 +0530330 int32_t ret = 0, flags;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700331 struct mdss_dsi_pll_config *pll_data;
332 dprintf(SPEW, "target_panel_clock\n");
333
Padmanabhan Komanduru82ae7132015-06-08 15:46:33 +0530334 if (pinfo->dest == DISPLAY_2) {
335 flags = MMSS_DSI_CLKS_FLAG_DSI1;
336 if (pinfo->mipi.dual_dsi)
337 flags |= MMSS_DSI_CLKS_FLAG_DSI0;
338 } else {
339 flags = MMSS_DSI_CLKS_FLAG_DSI0;
340 if (pinfo->mipi.dual_dsi)
341 flags |= MMSS_DSI_CLKS_FLAG_DSI1;
342 }
343
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700344 pll_data = pinfo->mipi.dsi_pll_config;
345 pll_data->vco_delay = VCO_DELAY_USEC;
346
Padmanabhan Komanduruf68f51b2015-12-21 18:32:12 +0530347 /* SSC parameters */
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530348 if (platform_is_msm8937() || platform_is_msm8917()) {
Padmanabhan Komanduruf68f51b2015-12-21 18:32:12 +0530349 pll_data->ssc_en = true;
350 pll_data->is_center_spread = false;
351 pll_data->ssc_freq = 30000;
352 pll_data->ssc_ppm = 5000;
353 }
354
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700355 if (enable) {
356 mdp_gdsc_ctrl(enable);
357 mdss_bus_clocks_enable();
358 mdp_clock_enable();
359 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
360 if (ret) {
361 dprintf(CRITICAL,
362 "%s: Failed to restore MDP security configs",
363 __func__);
364 mdp_clock_disable();
365 mdss_bus_clocks_disable();
366 mdp_gdsc_ctrl(0);
367 return ret;
368 }
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530369
370 ret = mdss_dsi_pll_config(pinfo->mipi.pll_base,
371 pinfo->mipi.ctl_base, pll_data);
Padmanabhan Komanduru6cf63522015-06-08 14:48:00 +0530372 if (!ret)
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530373 dprintf(CRITICAL, "Not able to enable master pll\n");
374
Padmanabhan Komanduru2a6c3452015-09-09 18:46:06 +0530375 if (platform_is_msm8956() && pinfo->mipi.dual_dsi &&
376 !platform_is_msm8976_v_1_1()) {
Padmanabhan Komanduru77a979a2015-06-15 15:03:23 +0530377 ret = mdss_dsi_pll_config(pinfo->mipi.spll_base,
378 pinfo->mipi.sctl_base, pll_data);
379 if (!ret)
380 dprintf(CRITICAL, "Not able to enable second pll\n");
381 }
382
Padmanabhan Komanduru2a6c3452015-09-09 18:46:06 +0530383 gcc_dsi_clocks_enable(flags, pinfo->mipi.use_dsi1_pll,
384 pll_data->pclk_m, pll_data->pclk_n, pll_data->pclk_d);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700385 } else if(!target_cont_splash_screen()) {
Padmanabhan Komanduru82ae7132015-06-08 15:46:33 +0530386 gcc_dsi_clocks_disable(flags);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700387 mdp_clock_disable();
388 mdss_bus_clocks_disable();
389 mdp_gdsc_ctrl(enable);
390 }
391
392 return 0;
393}
394
395int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
396 struct msm_panel_info *pinfo)
397{
398 int ret = NO_ERROR;
Sujeev Dias6bc9fa32015-08-03 23:13:44 -0700399 uint32_t hw_id = board_hardware_id();
400 uint32_t hw_subtype = board_hardware_subtype();
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700401
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530402 if (platform_is_msm8956()) {
403 reset_gpio.pin_id = 25;
404 bkl_gpio.pin_id = 66;
Padmanabhan Komandurub3231322015-11-12 16:54:21 +0530405 } else if (platform_is_msm8937()) {
406 reset_gpio.pin_id = 60;
407 bkl_gpio.pin_id = 98;
408 enable_gpio.pin_id = 99;
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530409 } else if (platform_is_msm8917()) {
Jayant Shekhar9c0533e2016-01-28 11:17:18 +0530410 reset_gpio.pin_id = 60;
411 bkl_gpio.pin_id = 98;
412 pinfo->mipi.use_enable_gpio = 0;
Sujeev Dias6bc9fa32015-08-03 23:13:44 -0700413 } else if ((hw_id == HW_PLATFORM_QRD) &&
414 (hw_subtype == HW_PLATFORM_SUBTYPE_POLARIS)) {
415 enable_gpio.pin_id = 19;
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530416 }
417
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700418 if (enable) {
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530419 if (pinfo->mipi.use_enable_gpio && !platform_is_msm8956()) {
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700420 gpio_tlmm_config(enable_gpio.pin_id, 0,
421 enable_gpio.pin_direction, enable_gpio.pin_pull,
422 enable_gpio.pin_strength,
423 enable_gpio.pin_state);
424
425 gpio_set_dir(enable_gpio.pin_id, 2);
426 }
427
428 gpio_tlmm_config(bkl_gpio.pin_id, 0,
429 bkl_gpio.pin_direction, bkl_gpio.pin_pull,
430 bkl_gpio.pin_strength, bkl_gpio.pin_state);
431
432 gpio_set_dir(bkl_gpio.pin_id, 2);
433
434 gpio_tlmm_config(reset_gpio.pin_id, 0,
435 reset_gpio.pin_direction, reset_gpio.pin_pull,
436 reset_gpio.pin_strength, reset_gpio.pin_state);
437
438 gpio_set_dir(reset_gpio.pin_id, 2);
439
440 /* reset */
441 for (int i = 0; i < RESET_GPIO_SEQ_LEN; i++) {
442 if (resetseq->pin_state[i] == GPIO_STATE_LOW)
443 gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_LOW);
444 else
445 gpio_set_dir(reset_gpio.pin_id, GPIO_STATE_HIGH);
446 mdelay(resetseq->sleep[i]);
447 }
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530448
449 if (platform_is_msm8956()) {
450 gpio_tlmm_config(lcd_mode_gpio.pin_id, 0,
451 lcd_mode_gpio.pin_direction, lcd_mode_gpio.pin_pull,
452 lcd_mode_gpio.pin_strength, lcd_mode_gpio.pin_state);
453
454 if (pinfo->lcdc.split_display || pinfo->lcdc.dst_split)
455 gpio_set_dir(lcd_mode_gpio.pin_id, GPIO_STATE_LOW);
456 else
457 gpio_set_dir(lcd_mode_gpio.pin_id, GPIO_STATE_HIGH);
458 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700459 } else if(!target_cont_splash_screen()) {
460 gpio_set_dir(reset_gpio.pin_id, 0);
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530461 if (pinfo->mipi.use_enable_gpio && !platform_is_msm8956())
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700462 gpio_set_dir(enable_gpio.pin_id, 0);
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530463 if (platform_is_msm8956())
464 gpio_set_dir(lcd_mode_gpio.pin_id, 0);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700465 }
466
467 return ret;
468}
469
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530470static int wled_init(struct msm_panel_info *pinfo)
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700471{
472 struct qpnp_wled_config_data config = {0};
473 struct labibb_desc *labibb;
474 int display_type = 0;
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530475 bool swire_control = 0;
476 bool wled_avdd_control = 0;
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530477 int rc = NO_ERROR;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700478
479 labibb = pinfo->labibb;
480
481 if (labibb)
482 display_type = labibb->amoled_panel;
483
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530484 if (display_type) {
485 swire_control = labibb->swire_control;
486 wled_avdd_control = true;
487 } else {
488 swire_control = false;
489 wled_avdd_control = false;
490 }
491
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700492 config.display_type = display_type;
493 config.lab_init_volt = 4600000; /* fixed, see pmi register */
494 config.ibb_init_volt = 1400000; /* fixed, see pmi register */
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530495 config.lab_ibb_swire_control = swire_control;
496 config.wled_avdd_control = wled_avdd_control;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700497
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530498 if(!swire_control) {
499 if (labibb && labibb->force_config) {
500 config.lab_min_volt = labibb->lab_min_volt;
501 config.lab_max_volt = labibb->lab_max_volt;
502 config.ibb_min_volt = labibb->ibb_min_volt;
503 config.ibb_max_volt = labibb->ibb_max_volt;
504 config.pwr_up_delay = labibb->pwr_up_delay;
505 config.pwr_down_delay = labibb->pwr_down_delay;
506 config.ibb_discharge_en = labibb->ibb_discharge_en;
507 } else {
508 /* default */
509 config.pwr_up_delay = 3;
510 config.pwr_down_delay = 3;
511 config.ibb_discharge_en = 1;
512 if (display_type) { /* amoled */
513 config.lab_min_volt = 4600000;
514 config.lab_max_volt = 4600000;
515 config.ibb_min_volt = 4000000;
516 config.ibb_max_volt = 4000000;
517 } else { /* lcd */
518 config.lab_min_volt = 5500000;
519 config.lab_max_volt = 5500000;
520 config.ibb_min_volt = 5500000;
521 config.ibb_max_volt = 5500000;
522 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700523 }
524 }
525
526 dprintf(SPEW, "%s: %d %d %d %d %d %d %d %d %d %d\n", __func__,
527 config.display_type,
528 config.lab_min_volt, config.lab_max_volt,
529 config.ibb_min_volt, config.ibb_max_volt,
530 config.lab_init_volt, config.ibb_init_volt,
531 config.pwr_up_delay, config.pwr_down_delay,
532 config.ibb_discharge_en);
533
534 /* QPNP WLED init for display backlight */
535 pm8x41_wled_config_slave_id(PMIC_WLED_SLAVE_ID);
536
Umang Agrawald1939942018-02-13 16:23:58 +0530537 if (target_get_pmic() == PMIC_IS_PMI632)
538 rc = qpnp_lcdb_init(&config);
539 else
540 rc = qpnp_wled_init(&config);
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530541
542 return rc;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700543}
544
Dhaval Patel7709c412015-05-12 10:09:41 -0700545int target_dsi_phy_config(struct mdss_dsi_phy_ctrl *phy_db)
546{
547 memcpy(phy_db->regulator, panel_regulator_settings, REGULATOR_SIZE);
548 memcpy(phy_db->ctrl, panel_physical_ctrl, PHYSICAL_SIZE);
549 memcpy(phy_db->strength, panel_strength_ctrl, STRENGTH_SIZE);
550 memcpy(phy_db->bistCtrl, panel_bist_ctrl, BIST_SIZE);
551 memcpy(phy_db->laneCfg, panel_lane_config, LANE_SIZE);
552 return NO_ERROR;
553}
554
Padmanabhan Komandurub3381932015-06-15 22:14:02 +0530555int target_display_get_base_offset(uint32_t base)
556{
Jayant Shekhar9c0533e2016-01-28 11:17:18 +0530557 if(platform_is_msm8956() || platform_is_msm8937() ||
Parth Dixit05f3c9f2016-03-18 17:14:57 +0530558 platform_is_msm8917()) {
Padmanabhan Komandurub3381932015-06-15 22:14:02 +0530559 if (base == MIPI_DSI0_BASE)
560 return DSI0_BASE_ADJUST;
561 else if (base == DSI0_PHY_BASE)
562 return DSI0_PHY_BASE_ADJUST;
563 else if (base == DSI0_PLL_BASE)
564 return DSI0_PHY_PLL_BASE_ADJUST;
565 else if (base == DSI0_REGULATOR_BASE)
566 return DSI0_PHY_REGULATOR_BASE_ADJUST;
567 }
568
569 return 0;
570}
571
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700572int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
573{
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530574 int rc = 0;
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530575 uint32_t ldo_num = REG_LDO6 | REG_LDO17;
576
577 if (platform_is_msm8956())
578 ldo_num |= REG_LDO1;
579 else
580 ldo_num |= REG_LDO2;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700581
582 if (enable) {
Padmanabhan Komanduru3cb07662015-06-08 17:13:33 +0530583 regulator_enable(ldo_num);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700584 mdelay(10);
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530585 rc = wled_init(pinfo);
586 if (rc) {
587 dprintf(CRITICAL, "%s: wled init failed\n", __func__);
588 return rc;
589 }
Umang Agrawald1939942018-02-13 16:23:58 +0530590 if (target_get_pmic() == PMIC_IS_PMI632)
591 rc = qpnp_lcdb_enable(true);
592 else
593 rc = qpnp_ibb_enable(true); /*5V boost*/
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530594 if (rc) {
Umang Agrawald1939942018-02-13 16:23:58 +0530595 dprintf(CRITICAL, "%s: qpnp_ibb/lcdb failed\n", __func__);
Sandeep Pandaaa4ea2f2016-07-05 13:52:25 +0530596 return rc;
597 }
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700598 mdelay(50);
599 } else {
Padmanabhan Komandurufa2899b2015-06-30 16:25:33 +0530600 /*
601 * LDO1, LDO2 and LDO6 are shared with other subsystems.
602 * Do not disable them.
603 */
604 regulator_disable(REG_LDO17);
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700605 }
606
607 return NO_ERROR;
608}
609
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530610bool target_display_panel_node(char *pbuf, uint16_t buf_size)
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700611{
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530612 int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
613 bool ret = true;
614 struct oem_panel_data oem = mdss_dsi_get_oem_data();
615 uint32_t platform_subtype = board_hardware_subtype();
Sachin Bhayare0ad72772018-03-22 19:11:29 +0530616 uint32_t platform = board_platform_id();
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530617
618 /* default to hdmi for apq iot */
Sachin Bhayare0ad72772018-03-22 19:11:29 +0530619 if ((APQ8017 == platform) && ((HW_PLATFORM_SUBTYPE_SAP == platform_subtype) ||
620 (HW_PLATFORM_SUBTYPE_SAP_NOPMI == platform_subtype))) {
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530621 if (!strcmp(oem.panel, "")) {
622 if (buf_size < (prefix_string_len +
623 strlen(HDMI_ADV_PANEL_STRING))) {
624 dprintf(CRITICAL, "HDMI command line argument \
625 is greater than buffer size\n");
626 return false;
627 }
628 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
629 buf_size -= prefix_string_len;
630 pbuf += prefix_string_len;
631 strlcpy(pbuf, HDMI_ADV_PANEL_STRING, buf_size);
632 } else if (!strcmp(oem.panel, TRULY_720P_VID_PANEL)) {
633 if (buf_size < (prefix_string_len +
634 strlen(TRULY_VID_PANEL_STRING))) {
635 dprintf(CRITICAL, "TRULY VIDEO command line \
636 argument is greater than \
637 buffer size\n");
638 return false;
639 }
640 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
641 buf_size -= prefix_string_len;
642 pbuf += prefix_string_len;
643 strlcpy(pbuf, TRULY_VID_PANEL_STRING, buf_size);
644 } else if (!strcmp(oem.panel, TRULY_720P_CMD_PANEL)) {
645 if (buf_size < (prefix_string_len +
646 strlen(TRULY_CMD_PANEL_STRING))) {
647 dprintf(CRITICAL, "TRULY CMD command line argument \
648 argument is greater than \
649 buffer size\n");
650 return false;
651 }
652 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
653 buf_size -= prefix_string_len;
654 pbuf += prefix_string_len;
655 strlcpy(pbuf, TRULY_CMD_PANEL_STRING, buf_size);
656 }
657 } else {
658 ret = gcdb_display_cmdline_arg(pbuf, buf_size);
659 }
660
661 return ret;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700662}
663
664void target_display_init(const char *panel_name)
665{
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530666 struct oem_panel_data oem;
Ray Zhangf95f5b92015-06-25 15:34:29 +0800667 int32_t ret = 0;
668 uint32_t panel_loop = 0;
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530669 uint32_t platform_subtype = board_hardware_subtype();
Sachin Bhayare0ad72772018-03-22 19:11:29 +0530670 uint32_t platform = board_platform_id();
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700671
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530672 set_panel_cmd_string(panel_name);
673 oem = mdss_dsi_get_oem_data();
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700674
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530675 if (!strcmp(oem.panel, NO_PANEL_CONFIG)
676 || !strcmp(oem.panel, SIM_VIDEO_PANEL)
677 || !strcmp(oem.panel, SIM_CMD_PANEL)
678 || oem.skip) {
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700679 dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530680 oem.panel);
Vishnuvardhan Prodduturi4cd56382017-08-22 21:46:38 +0530681 oem.cont_splash = false;
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700682 }
683
Sachin Bhayare0ad72772018-03-22 19:11:29 +0530684 if ((APQ8017 == platform) && ((HW_PLATFORM_SUBTYPE_SAP == platform_subtype) ||
685 (HW_PLATFORM_SUBTYPE_SAP_NOPMI == platform_subtype))) {
Ashish Garg9cfd6ca2016-12-20 01:41:54 +0530686 dprintf(INFO, "%s: Platform subtype %d\n",
687 __func__, platform_subtype);
688 return;
689 }
690
Ray Zhangf95f5b92015-06-25 15:34:29 +0800691 do {
692 target_force_cont_splash_disable(false);
693 ret = gcdb_display_init(oem.panel, MDP_REV_50, (void *)MIPI_FB_ADDR);
694 if (!ret || ret == ERR_NOT_SUPPORTED) {
695 break;
696 } else {
697 target_force_cont_splash_disable(true);
698 msm_display_off();
699 }
700 } while (++panel_loop <= oem_panel_max_auto_detect_panels());
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700701
Padmanabhan Komandurubccbcdc2015-06-30 16:19:24 +0530702 if (!oem.cont_splash) {
Padmanabhan Komanduru9d49f892015-04-10 12:58:46 -0700703 dprintf(INFO, "Forcing continuous splash disable\n");
704 target_force_cont_splash_disable(true);
705 }
706}
707
708void target_display_shutdown(void)
709{
710 gcdb_display_shutdown();
711}