blob: b46ef083486af45dbcd2adcfa539298dddad37ab [file] [log] [blame]
Jeevan Shriram2d3500b2014-12-29 16:25:06 -08001/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Dhaval Patelf9986272013-10-18 19:06:05 -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 <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>
Dhaval Patel914e8db2014-04-16 12:07:13 -070039#include <scm.h>
Dhaval Patelf9986272013-10-18 19:06:05 -070040#include <endian.h>
41#include <platform/gpio.h>
42#include <platform/clock.h>
43#include <platform/iomap.h>
44#include <target/display.h>
45#include "include/panel.h"
46#include "include/display_resource.h"
Veera Sundaram Sankaran87f88132015-01-28 11:32:44 -080047#include "gcdb_display.h"
Dhaval Patelf9986272013-10-18 19:06:05 -070048
49#define HFPLL_LDO_ID 12
50
51#define GPIO_STATE_LOW 0
52#define GPIO_STATE_HIGH 2
53#define RESET_GPIO_SEQ_LEN 3
54
Kuogee Hsiehacc31942014-06-17 15:12:10 -070055static struct backlight edp_bklt = {
56 0, 1, 4095, 100, 1, "PMIC_8941"
57};
58
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053059static uint32_t dsi_pll_lock_status(uint32_t pll_base)
Dhaval Patelf9986272013-10-18 19:06:05 -070060{
Dhaval Patelbb408712014-03-18 11:45:53 -070061 uint32_t counter, status;
Dhaval Patelf9986272013-10-18 19:06:05 -070062
Dhaval Patelbb408712014-03-18 11:45:53 -070063 udelay(100);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053064 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -070065
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053066 status = readl(pll_base + 0x00c0) & 0x01;
Dhaval Patelbb408712014-03-18 11:45:53 -070067 for (counter = 0; counter < 5 && !status; counter++) {
68 udelay(100);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053069 status = readl(pll_base + 0x00c0) & 0x01;
Dhaval Patelbb408712014-03-18 11:45:53 -070070 }
71
72 return status;
73}
74
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053075static uint32_t dsi_pll_enable_seq_b(uint32_t pll_base)
Dhaval Patelbb408712014-03-18 11:45:53 -070076{
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053077 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Dhaval Patelf9986272013-10-18 19:06:05 -070078
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053079 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070080 udelay(1);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053081 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070082 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053083 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070084 udelay(500);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053085 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070086 udelay(500);
Dhaval Patelf9986272013-10-18 19:06:05 -070087
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053088 return dsi_pll_lock_status(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -070089}
Dhaval Patelf9986272013-10-18 19:06:05 -070090
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053091static uint32_t dsi_pll_enable_seq_d(uint32_t pll_base)
Dhaval Patelbb408712014-03-18 11:45:53 -070092{
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053093 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -070094
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053095 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070096 udelay(1);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053097 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070098 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053099 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -0700100 udelay(250);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530101 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -0700102 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530103 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -0700104 udelay(500);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530105 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -0700106 udelay(500);
107
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530108 return dsi_pll_lock_status(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700109}
110
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530111static void dsi_pll_enable_seq(uint32_t pll_base)
Dhaval Patelbb408712014-03-18 11:45:53 -0700112{
113 uint32_t counter, status;
114
115 for (counter = 0; counter < 3; counter++) {
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530116 status = dsi_pll_enable_seq_b(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700117 if (status)
118 break;
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530119 status = dsi_pll_enable_seq_d(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700120 if (status)
121 break;
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530122 status = dsi_pll_enable_seq_d(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700123 if(status)
124 break;
Dhaval Patelf9986272013-10-18 19:06:05 -0700125 }
Dhaval Patelbb408712014-03-18 11:45:53 -0700126
127 if (!status)
128 dprintf(CRITICAL, "Pll lock sequence failed\n");
Dhaval Patelf9986272013-10-18 19:06:05 -0700129}
130
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800131int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
Dhaval Patelf9986272013-10-18 19:06:05 -0700132{
133 struct pm8x41_gpio pwmgpio_param = {
134 .direction = PM_GPIO_DIR_OUT,
135 .function = PM_GPIO_FUNC_1,
136 .vin_sel = 2, /* VIN_2 */
137 .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10,
138 .output_buffer = PM_GPIO_OUT_CMOS,
139 .out_strength = 0x03,
140 };
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800141
Dhaval Patelf9986272013-10-18 19:06:05 -0700142 if (enable) {
Dhaval Patel499b7d22014-01-07 21:57:30 -0800143 pm8x41_gpio_config(pwm_gpio.pin_id, &pwmgpio_param);
Dhaval Patelf9986272013-10-18 19:06:05 -0700144
Kuogee Hsiehacc31942014-06-17 15:12:10 -0700145 /* lpg channel 3 */
Dhaval Patel499b7d22014-01-07 21:57:30 -0800146 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */
147 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */
148 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */
149 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x44, 0xcc); /* LPG_VALUE_LSB */
150 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x45, 0x00); /* LPG_VALUE_MSB */
151 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */
Dhaval Patelf9986272013-10-18 19:06:05 -0700152 } else {
Dhaval Patel499b7d22014-01-07 21:57:30 -0800153 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x46, 0x0); /* LPG_ENABLE_CONTROL */
Dhaval Patelf9986272013-10-18 19:06:05 -0700154 }
155
156 return NO_ERROR;
157}
158
159int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
160{
Dhaval Patel914e8db2014-04-16 12:07:13 -0700161 uint32_t ret;
Dhaval Patelf9986272013-10-18 19:06:05 -0700162 struct mdss_dsi_pll_config *pll_data;
163 uint32_t dual_dsi = pinfo->mipi.dual_dsi;
164 dprintf(SPEW, "target_panel_clock\n");
165
166 pll_data = pinfo->mipi.dsi_pll_config;
167 if (enable) {
168 mdp_gdsc_ctrl(enable);
169 mmss_bus_clock_enable();
170 mdp_clock_enable();
Dhaval Patel914e8db2014-04-16 12:07:13 -0700171 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
172 if (ret) {
173 dprintf(CRITICAL,
174 "%s: Failed to restore MDP security configs",
175 __func__);
176 mdp_clock_disable();
177 mmss_bus_clock_disable();
178 mdp_gdsc_ctrl(0);
179 return ret;
180 }
Jeevan Shriram2d3500b2014-12-29 16:25:06 -0800181 mdss_dsi_auto_pll_config(pinfo->mipi.pll_0_base,
182 pinfo->mipi.ctl_base, pll_data);
183 dsi_pll_enable_seq(pinfo->mipi.pll_0_base);
Dhaval Patelf9986272013-10-18 19:06:05 -0700184 mmss_dsi_clock_enable(DSI0_PHY_PLL_OUT, dual_dsi,
185 pll_data->pclk_m,
186 pll_data->pclk_n,
187 pll_data->pclk_d);
188 } else if(!target_cont_splash_screen()) {
189 /* Disable clocks if continuous splash off */
Dhaval Patelf14af122013-10-29 12:48:41 -0700190 mmss_dsi_clock_disable(dual_dsi);
Dhaval Patelf9986272013-10-18 19:06:05 -0700191 mdp_clock_disable();
192 mmss_bus_clock_disable();
193 mdp_gdsc_ctrl(enable);
194 }
195
196 return NO_ERROR;
197}
198
199/* Pull DISP_RST_N high to get panel out of reset */
200int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
201 struct msm_panel_info *pinfo)
202{
203 uint32_t i = 0;
204
205 if (enable) {
206 gpio_tlmm_config(reset_gpio.pin_id, 0,
207 reset_gpio.pin_direction, reset_gpio.pin_pull,
208 reset_gpio.pin_strength, reset_gpio.pin_state);
209
210 gpio_tlmm_config(enable_gpio.pin_id, 0,
211 enable_gpio.pin_direction, enable_gpio.pin_pull,
212 enable_gpio.pin_strength, enable_gpio.pin_state);
213
214 gpio_tlmm_config(bkl_gpio.pin_id, 0,
215 bkl_gpio.pin_direction, bkl_gpio.pin_pull,
216 bkl_gpio.pin_strength, bkl_gpio.pin_state);
217
218 gpio_set(enable_gpio.pin_id, 2);
219 gpio_set(bkl_gpio.pin_id, 2);
220 /* reset */
221 for (i = 0; i < RESET_GPIO_SEQ_LEN; i++) {
222 if (resetseq->pin_state[i] == GPIO_STATE_LOW)
223 gpio_set(reset_gpio.pin_id, GPIO_STATE_LOW);
224 else
225 gpio_set(reset_gpio.pin_id, GPIO_STATE_HIGH);
226 mdelay(resetseq->sleep[i]);
227 }
228 } else {
229 gpio_set(reset_gpio.pin_id, 0);
230 gpio_set(enable_gpio.pin_id, 0);
231 gpio_set(bkl_gpio.pin_id, 0);
232 }
233
234 return NO_ERROR;
235}
236
Kuogee Hsieh93bcff62014-08-22 14:02:08 -0700237int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
Dhaval Patelf9986272013-10-18 19:06:05 -0700238{
239 uint32_t ldocounter = 0;
240 uint32_t pm8x41_ldo_base = 0x13F00;
241
242 while (ldocounter < TOTAL_LDO_DEFINED) {
243 struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base +
244 0x100 * ldo_entry_array[ldocounter].ldo_id),
245 ldo_entry_array[ldocounter].ldo_type);
246
247 dprintf(SPEW, "Setting %s\n",
248 ldo_entry_array[ldocounter].ldo_id);
249
250 /* Set voltage during power on */
251 if (enable) {
252 pm8x41_ldo_set_voltage(&ldo_entry,
253 ldo_entry_array[ldocounter].ldo_voltage);
254 pm8x41_ldo_control(&ldo_entry, enable);
255 } else if(ldo_entry_array[ldocounter].ldo_id != HFPLL_LDO_ID) {
256 pm8x41_ldo_control(&ldo_entry, enable);
257 }
258 ldocounter++;
259 }
260
261 return NO_ERROR;
262}
263
Dhaval Patelab2de892013-10-25 10:40:58 -0700264int target_display_pre_on()
265{
266 writel(0x000000FA, MDP_QOS_REMAPPER_CLASS_0);
267 writel(0x00000055, MDP_QOS_REMAPPER_CLASS_1);
268 writel(0xC0000CCD, MDP_CLK_CTRL0);
269 writel(0xD0000CCC, MDP_CLK_CTRL1);
270 writel(0x00CCCCCC, MDP_CLK_CTRL2);
271 writel(0x000000CC, MDP_CLK_CTRL6);
272 writel(0x0CCCC0C0, MDP_CLK_CTRL3);
273 writel(0xCCCCC0C0, MDP_CLK_CTRL4);
274 writel(0xCCCCC0C0, MDP_CLK_CTRL5);
275 writel(0x00CCC000, MDP_CLK_CTRL7);
276
Dhaval Patelab2de892013-10-25 10:40:58 -0700277 writel(0x00080808, VBIF_VBIF_IN_RD_LIM_CONF0);
278 writel(0x08000808, VBIF_VBIF_IN_RD_LIM_CONF1);
279 writel(0x00080808, VBIF_VBIF_IN_RD_LIM_CONF2);
280 writel(0x00000808, VBIF_VBIF_IN_RD_LIM_CONF3);
281 writel(0x10000000, VBIF_VBIF_IN_WR_LIM_CONF0);
282 writel(0x00100000, VBIF_VBIF_IN_WR_LIM_CONF1);
283 writel(0x10000000, VBIF_VBIF_IN_WR_LIM_CONF2);
284 writel(0x00000000, VBIF_VBIF_IN_WR_LIM_CONF3);
285 writel(0x00013fff, VBIF_VBIF_ABIT_SHORT);
286 writel(0x000000A4, VBIF_VBIF_ABIT_SHORT_CONF);
287 writel(0x00003FFF, VBIF_VBIF_GATE_OFF_WRREQ_EN);
288 writel(0x00000003, VBIF_VBIF_DDR_RND_RBN_QOS_ARB);
289
290 return NO_ERROR;
291}
292
Ajay Singh Parmar60430b92014-07-23 23:39:01 -0700293int target_hdmi_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
294{
295 uint32_t ret;
296
297 dprintf(SPEW, "%s: target_panel_clock\n", __func__);
298
299 if (enable) {
300 mdp_gdsc_ctrl(enable);
301 mmss_bus_clock_enable();
302 mdp_clock_enable();
303 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
304 if (ret) {
305 dprintf(CRITICAL,
306 "%s: Failed to restore MDP security configs",
307 __func__);
308 mdp_clock_disable();
309 mmss_bus_clock_disable();
310 mdp_gdsc_ctrl(0);
311 return ret;
312 }
313
314 hdmi_phy_reset();
315 hdmi_pll_config();
316 hdmi_vco_enable();
317 hdmi_clk_enable();
318 } else if(!target_cont_splash_screen()) {
319 /* Disable clocks if continuous splash off */
320 hdmi_clk_disable();
321 hdmi_vco_disable();
322 mdp_clock_disable();
323 mmss_bus_clock_disable();
324 mdp_gdsc_ctrl(enable);
325 }
326
327 return NO_ERROR;
328}
329
330static void target_hdmi_mvs_enable(bool enable)
331{
332 struct pm8x41_mvs mvs;
333 mvs.base = PM8x41_MVS1_BASE;
334
335 if (enable)
336 pm8x41_enable_mvs(&mvs, MVS_ENABLE);
337 else
338 pm8x41_enable_mvs(&mvs, MVS_DISABLE);
339}
340
341static void target_hdmi_vreg_enable(bool enable)
342{
343 struct pm8x41_mpp mpp;
344 mpp.base = PM8x41_MMP3_BASE;
345
346 if (enable) {
347 mpp.mode = MPP_HIGH;
348 mpp.vin = MPP_VIN2;
349 pm8x41_config_output_mpp(&mpp);
350 pm8x41_enable_mpp(&mpp, MPP_ENABLE);
351 } else {
352 pm8x41_enable_mpp(&mpp, MPP_DISABLE);
353 }
354}
355
356int target_hdmi_regulator_ctrl(bool enable)
357{
358 target_hdmi_mvs_enable(enable);
359 target_hdmi_vreg_enable(enable);
360
361 return 0;
362}
363
Ajay Singh Parmar7f31e0e2014-09-03 22:09:46 -0700364int target_hdmi_gpio_ctrl(bool enable)
365{
366 gpio_tlmm_config(hdmi_cec_gpio.pin_id, 1, /* gpio 31, CEC */
367 hdmi_cec_gpio.pin_direction, hdmi_cec_gpio.pin_pull,
368 hdmi_cec_gpio.pin_strength, hdmi_cec_gpio.pin_state);
369
370 gpio_tlmm_config(hdmi_ddc_clk_gpio.pin_id, 1, /* gpio 32, DDC CLK */
371 hdmi_ddc_clk_gpio.pin_direction, hdmi_ddc_clk_gpio.pin_pull,
372 hdmi_ddc_clk_gpio.pin_strength, hdmi_ddc_clk_gpio.pin_state);
373
374
375 gpio_tlmm_config(hdmi_ddc_data_gpio.pin_id, 1, /* gpio 33, DDC DATA */
376 hdmi_ddc_data_gpio.pin_direction, hdmi_ddc_data_gpio.pin_pull,
377 hdmi_ddc_data_gpio.pin_strength, hdmi_ddc_data_gpio.pin_state);
378
379 gpio_tlmm_config(hdmi_hpd_gpio.pin_id, 1, /* gpio 34, HPD */
380 hdmi_hpd_gpio.pin_direction, hdmi_hpd_gpio.pin_pull,
381 hdmi_hpd_gpio.pin_strength, hdmi_hpd_gpio.pin_state);
382
383 gpio_set(hdmi_cec_gpio.pin_id, hdmi_cec_gpio.pin_direction);
384 gpio_set(hdmi_ddc_clk_gpio.pin_id, hdmi_ddc_clk_gpio.pin_direction);
385 gpio_set(hdmi_ddc_data_gpio.pin_id, hdmi_ddc_data_gpio.pin_direction);
386 gpio_set(hdmi_hpd_gpio.pin_id, hdmi_hpd_gpio.pin_direction);
387
388 /* MUX */
389 gpio_tlmm_config(hdmi_mux_lpm_gpio.pin_id, 0, /* gpio 27 MUX LPM */
390 hdmi_mux_lpm_gpio.pin_direction, hdmi_mux_lpm_gpio.pin_pull,
391 hdmi_mux_lpm_gpio.pin_strength, hdmi_mux_lpm_gpio.pin_state);
392
393 gpio_tlmm_config(hdmi_mux_en_gpio.pin_id, 0, /* gpio 83 MUX EN */
394 hdmi_mux_en_gpio.pin_direction, hdmi_mux_en_gpio.pin_pull,
395 hdmi_mux_en_gpio.pin_strength, hdmi_mux_en_gpio.pin_state);
396
397 gpio_tlmm_config(hdmi_mux_sel_gpio.pin_id, 0, /* gpio 85 MUX SEL */
398 hdmi_mux_sel_gpio.pin_direction, hdmi_mux_sel_gpio.pin_pull,
399 hdmi_mux_sel_gpio.pin_strength, hdmi_mux_sel_gpio.pin_state);
400
401 gpio_set(hdmi_mux_lpm_gpio.pin_id, hdmi_mux_lpm_gpio.pin_direction);
402 gpio_set(hdmi_mux_en_gpio.pin_id, hdmi_mux_en_gpio.pin_direction);
403 gpio_set(hdmi_mux_sel_gpio.pin_id, hdmi_mux_sel_gpio.pin_direction);
404
405 return NO_ERROR;
406}
407
Kuogee Hsiehacc31942014-06-17 15:12:10 -0700408void target_edp_panel_init(struct msm_panel_info *pinfo)
409{
410 edp_panel_init(pinfo);
411}
412
413int target_edp_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
414{
415 uint32_t ret;
416
417 dprintf(SPEW, "%s: target_panel_clock\n", __func__);
418
419 if (enable) {
420 mdp_gdsc_ctrl(enable);
421 mmss_bus_clock_enable();
422 mdp_clock_enable();
423 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
424 if (ret) {
425 dprintf(CRITICAL,
426 "%s: Failed to restore MDP security configs",
427 __func__);
428 mdp_clock_disable();
429 mmss_bus_clock_disable();
430 mdp_gdsc_ctrl(0);
431 return ret;
432 }
433
434 edp_clk_enable();
435 } else if(!target_cont_splash_screen()) {
436 /* Disable clocks if continuous splash off */
437 edp_clk_disable();
438 mdp_clock_disable();
439 mmss_bus_clock_disable();
440 mdp_gdsc_ctrl(enable);
441 }
442
443 return NO_ERROR;
444}
445
446int target_edp_panel_enable(void)
447{
448 gpio_tlmm_config(enable_gpio.pin_id, 0, /* gpio 137 */
449 enable_gpio.pin_direction, enable_gpio.pin_pull,
450 enable_gpio.pin_strength, enable_gpio.pin_state);
451
452
453 gpio_tlmm_config(edp_hpd_gpio.pin_id, 0, /* hpd 103 */
454 edp_hpd_gpio.pin_direction, edp_hpd_gpio.pin_pull,
455 edp_hpd_gpio.pin_strength, edp_hpd_gpio.pin_state);
456
457
458 gpio_tlmm_config(edp_lvl_en_gpio.pin_id, 0, /* lvl_en 91 */
459 edp_lvl_en_gpio.pin_direction, edp_lvl_en_gpio.pin_pull,
460 edp_lvl_en_gpio.pin_strength, edp_lvl_en_gpio.pin_state);
461
462 gpio_set(enable_gpio.pin_id, 2);
463 gpio_set(edp_lvl_en_gpio.pin_id, 2);
464
465 return NO_ERROR;
466}
467
468int target_edp_panel_disable(void)
469{
470 gpio_set(edp_lvl_en_gpio.pin_id, 0);
471 gpio_set(enable_gpio.pin_id, 0);
472
473 return NO_ERROR;
474}
475
476int target_edp_bl_ctrl(int enable)
477{
478 return target_backlight_ctrl(&edp_bklt, enable);
479}
480
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700481bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size)
482{
483 int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
484 bool ret = true;
485
486 panel_name += strspn(panel_name, " ");
487
488 if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
489 if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN +
Ajay Singh Parmar3d14bdd2014-07-11 14:56:32 -0700490 strlen(HDMI_CONTROLLER_STRING))) {
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700491 dprintf(CRITICAL, "command line argument is greater than buffer size\n");
492 return false;
493 }
494
495 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
496 buf_size -= prefix_string_len;
497 strlcat(pbuf, LK_OVERRIDE_PANEL, buf_size);
498 buf_size -= LK_OVERRIDE_PANEL_LEN;
499 strlcat(pbuf, HDMI_CONTROLLER_STRING, buf_size);
500 } else {
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700501 ret = gcdb_display_cmdline_arg(panel_name, pbuf, buf_size);
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700502 }
503
504 return ret;
505}
506
Aravind Venkateswaran6385f7e2014-02-25 16:45:11 -0800507void target_display_init(const char *panel_name)
Dhaval Patelf9986272013-10-18 19:06:05 -0700508{
509 uint32_t ret = 0;
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800510 char cont_splash = '\0';
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700511
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800512 set_panel_cmd_string(panel_name, &cont_splash);
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700513 panel_name += strspn(panel_name, " ");
514
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700515 if (!strcmp(panel_name, NO_PANEL_CONFIG)
516 || !strcmp(panel_name, SIM_VIDEO_PANEL)
517 || !strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)
518 || !strcmp(panel_name, SIM_CMD_PANEL)
519 || !strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) {
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700520 dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
Veera Sundaram Sankaran3b758822014-10-17 12:15:39 -0700521 panel_name);
Jeevan Shriramb0d523a2014-05-30 12:55:17 -0700522 return;
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700523 } else if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700524 dprintf(INFO, "%s: HDMI is primary\n", __func__);
Ajay Singh Parmar243d82b2014-07-23 23:01:44 -0700525 mdss_hdmi_display_init(MDP_REV_50, HDMI_FB_ADDR);
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700526 return;
527 }
528
Aravind Venkateswarand494f962014-02-25 17:16:49 -0800529 ret = gcdb_display_init(panel_name, MDP_REV_50, MIPI_FB_ADDR);
Justin Philipbe9de5c2014-09-17 12:26:49 +0530530 if (ret) {
531 target_force_cont_splash_disable(true);
Dhaval Patelf9986272013-10-18 19:06:05 -0700532 msm_display_off();
Justin Philipbe9de5c2014-09-17 12:26:49 +0530533 }
Veera Sundaram Sankaran7868d542015-01-02 14:48:47 -0800534
535 if (cont_splash == '0') {
536 dprintf(INFO, "Forcing continuous splash disable\n");
537 target_force_cont_splash_disable(true);
538 }
Dhaval Patelf9986272013-10-18 19:06:05 -0700539}
540
Aravind Venkateswarandd50c1a2014-02-25 14:42:43 -0800541void target_display_shutdown(void)
Dhaval Patelf9986272013-10-18 19:06:05 -0700542{
543 gcdb_display_shutdown();
544}