blob: 1a289ef41b1b4781ee67c367727461dc81446735 [file] [log] [blame]
Kuogee Hsiehdf961742013-12-18 14:13:45 -08001/* Copyright (c) 2013-2014, 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"
47
48#define HFPLL_LDO_ID 12
49
50#define GPIO_STATE_LOW 0
51#define GPIO_STATE_HIGH 2
52#define RESET_GPIO_SEQ_LEN 3
53
Kuogee Hsiehacc31942014-06-17 15:12:10 -070054static struct backlight edp_bklt = {
55 0, 1, 4095, 100, 1, "PMIC_8941"
56};
57
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053058static uint32_t dsi_pll_lock_status(uint32_t pll_base)
Dhaval Patelf9986272013-10-18 19:06:05 -070059{
Dhaval Patelbb408712014-03-18 11:45:53 -070060 uint32_t counter, status;
Dhaval Patelf9986272013-10-18 19:06:05 -070061
Dhaval Patelbb408712014-03-18 11:45:53 -070062 udelay(100);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053063 mdss_dsi_uniphy_pll_lock_detect_setting(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -070064
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053065 status = readl(pll_base + 0x00c0) & 0x01;
Dhaval Patelbb408712014-03-18 11:45:53 -070066 for (counter = 0; counter < 5 && !status; counter++) {
67 udelay(100);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053068 status = readl(pll_base + 0x00c0) & 0x01;
Dhaval Patelbb408712014-03-18 11:45:53 -070069 }
70
71 return status;
72}
73
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053074static uint32_t dsi_pll_enable_seq_b(uint32_t pll_base)
Dhaval Patelbb408712014-03-18 11:45:53 -070075{
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053076 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Dhaval Patelf9986272013-10-18 19:06:05 -070077
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053078 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070079 udelay(1);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053080 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070081 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053082 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070083 udelay(500);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053084 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070085 udelay(500);
Dhaval Patelf9986272013-10-18 19:06:05 -070086
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053087 return dsi_pll_lock_status(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -070088}
Dhaval Patelf9986272013-10-18 19:06:05 -070089
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053090static uint32_t dsi_pll_enable_seq_d(uint32_t pll_base)
Dhaval Patelbb408712014-03-18 11:45:53 -070091{
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053092 mdss_dsi_uniphy_pll_sw_reset(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -070093
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053094 writel(0x01, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070095 udelay(1);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053096 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070097 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +053098 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -070099 udelay(250);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530100 writel(0x05, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -0700101 udelay(200);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530102 writel(0x07, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -0700103 udelay(500);
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530104 writel(0x0f, pll_base + 0x0020); /* GLB CFG */
Dhaval Patelbb408712014-03-18 11:45:53 -0700105 udelay(500);
106
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530107 return dsi_pll_lock_status(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700108}
109
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530110static void dsi_pll_enable_seq(uint32_t pll_base)
Dhaval Patelbb408712014-03-18 11:45:53 -0700111{
112 uint32_t counter, status;
113
114 for (counter = 0; counter < 3; counter++) {
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530115 status = dsi_pll_enable_seq_b(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700116 if (status)
117 break;
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530118 status = dsi_pll_enable_seq_d(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700119 if (status)
120 break;
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530121 status = dsi_pll_enable_seq_d(pll_base);
Dhaval Patelbb408712014-03-18 11:45:53 -0700122 if(status)
123 break;
Dhaval Patelf9986272013-10-18 19:06:05 -0700124 }
Dhaval Patelbb408712014-03-18 11:45:53 -0700125
126 if (!status)
127 dprintf(CRITICAL, "Pll lock sequence failed\n");
Dhaval Patelf9986272013-10-18 19:06:05 -0700128}
129
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800130int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
Dhaval Patelf9986272013-10-18 19:06:05 -0700131{
132 struct pm8x41_gpio pwmgpio_param = {
133 .direction = PM_GPIO_DIR_OUT,
134 .function = PM_GPIO_FUNC_1,
135 .vin_sel = 2, /* VIN_2 */
136 .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10,
137 .output_buffer = PM_GPIO_OUT_CMOS,
138 .out_strength = 0x03,
139 };
Kuogee Hsiehdf961742013-12-18 14:13:45 -0800140
Dhaval Patelf9986272013-10-18 19:06:05 -0700141 if (enable) {
Dhaval Patel499b7d22014-01-07 21:57:30 -0800142 pm8x41_gpio_config(pwm_gpio.pin_id, &pwmgpio_param);
Dhaval Patelf9986272013-10-18 19:06:05 -0700143
Kuogee Hsiehacc31942014-06-17 15:12:10 -0700144 /* lpg channel 3 */
Dhaval Patel499b7d22014-01-07 21:57:30 -0800145 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */
146 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */
147 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */
148 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x44, 0xcc); /* LPG_VALUE_LSB */
149 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x45, 0x00); /* LPG_VALUE_MSB */
150 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */
Dhaval Patelf9986272013-10-18 19:06:05 -0700151 } else {
Dhaval Patel499b7d22014-01-07 21:57:30 -0800152 pm8x41_lpg_write(PWM_BL_LPG_CHAN_ID, 0x46, 0x0); /* LPG_ENABLE_CONTROL */
Dhaval Patelf9986272013-10-18 19:06:05 -0700153 }
154
155 return NO_ERROR;
156}
157
158int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
159{
Dhaval Patel914e8db2014-04-16 12:07:13 -0700160 uint32_t ret;
Dhaval Patelf9986272013-10-18 19:06:05 -0700161 struct mdss_dsi_pll_config *pll_data;
162 uint32_t dual_dsi = pinfo->mipi.dual_dsi;
163 dprintf(SPEW, "target_panel_clock\n");
164
165 pll_data = pinfo->mipi.dsi_pll_config;
166 if (enable) {
167 mdp_gdsc_ctrl(enable);
168 mmss_bus_clock_enable();
169 mdp_clock_enable();
Dhaval Patel914e8db2014-04-16 12:07:13 -0700170 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
171 if (ret) {
172 dprintf(CRITICAL,
173 "%s: Failed to restore MDP security configs",
174 __func__);
175 mdp_clock_disable();
176 mmss_bus_clock_disable();
177 mdp_gdsc_ctrl(0);
178 return ret;
179 }
Padmanabhan Komanduru703bd6d2014-03-25 19:57:01 +0530180 mdss_dsi_auto_pll_config(DSI0_PLL_BASE,
181 MIPI_DSI0_BASE, pll_data);
182 dsi_pll_enable_seq(DSI0_PLL_BASE);
Dhaval Patelf9986272013-10-18 19:06:05 -0700183 mmss_dsi_clock_enable(DSI0_PHY_PLL_OUT, dual_dsi,
184 pll_data->pclk_m,
185 pll_data->pclk_n,
186 pll_data->pclk_d);
187 } else if(!target_cont_splash_screen()) {
188 /* Disable clocks if continuous splash off */
Dhaval Patelf14af122013-10-29 12:48:41 -0700189 mmss_dsi_clock_disable(dual_dsi);
Dhaval Patelf9986272013-10-18 19:06:05 -0700190 mdp_clock_disable();
191 mmss_bus_clock_disable();
192 mdp_gdsc_ctrl(enable);
193 }
194
195 return NO_ERROR;
196}
197
198/* Pull DISP_RST_N high to get panel out of reset */
199int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
200 struct msm_panel_info *pinfo)
201{
202 uint32_t i = 0;
203
204 if (enable) {
205 gpio_tlmm_config(reset_gpio.pin_id, 0,
206 reset_gpio.pin_direction, reset_gpio.pin_pull,
207 reset_gpio.pin_strength, reset_gpio.pin_state);
208
209 gpio_tlmm_config(enable_gpio.pin_id, 0,
210 enable_gpio.pin_direction, enable_gpio.pin_pull,
211 enable_gpio.pin_strength, enable_gpio.pin_state);
212
213 gpio_tlmm_config(bkl_gpio.pin_id, 0,
214 bkl_gpio.pin_direction, bkl_gpio.pin_pull,
215 bkl_gpio.pin_strength, bkl_gpio.pin_state);
216
217 gpio_set(enable_gpio.pin_id, 2);
218 gpio_set(bkl_gpio.pin_id, 2);
219 /* reset */
220 for (i = 0; i < RESET_GPIO_SEQ_LEN; i++) {
221 if (resetseq->pin_state[i] == GPIO_STATE_LOW)
222 gpio_set(reset_gpio.pin_id, GPIO_STATE_LOW);
223 else
224 gpio_set(reset_gpio.pin_id, GPIO_STATE_HIGH);
225 mdelay(resetseq->sleep[i]);
226 }
227 } else {
228 gpio_set(reset_gpio.pin_id, 0);
229 gpio_set(enable_gpio.pin_id, 0);
230 gpio_set(bkl_gpio.pin_id, 0);
231 }
232
233 return NO_ERROR;
234}
235
Kuogee Hsieh93bcff62014-08-22 14:02:08 -0700236int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
Dhaval Patelf9986272013-10-18 19:06:05 -0700237{
238 uint32_t ldocounter = 0;
239 uint32_t pm8x41_ldo_base = 0x13F00;
240
241 while (ldocounter < TOTAL_LDO_DEFINED) {
242 struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base +
243 0x100 * ldo_entry_array[ldocounter].ldo_id),
244 ldo_entry_array[ldocounter].ldo_type);
245
246 dprintf(SPEW, "Setting %s\n",
247 ldo_entry_array[ldocounter].ldo_id);
248
249 /* Set voltage during power on */
250 if (enable) {
251 pm8x41_ldo_set_voltage(&ldo_entry,
252 ldo_entry_array[ldocounter].ldo_voltage);
253 pm8x41_ldo_control(&ldo_entry, enable);
254 } else if(ldo_entry_array[ldocounter].ldo_id != HFPLL_LDO_ID) {
255 pm8x41_ldo_control(&ldo_entry, enable);
256 }
257 ldocounter++;
258 }
259
260 return NO_ERROR;
261}
262
Dhaval Patelab2de892013-10-25 10:40:58 -0700263int target_display_pre_on()
264{
265 writel(0x000000FA, MDP_QOS_REMAPPER_CLASS_0);
266 writel(0x00000055, MDP_QOS_REMAPPER_CLASS_1);
267 writel(0xC0000CCD, MDP_CLK_CTRL0);
268 writel(0xD0000CCC, MDP_CLK_CTRL1);
269 writel(0x00CCCCCC, MDP_CLK_CTRL2);
270 writel(0x000000CC, MDP_CLK_CTRL6);
271 writel(0x0CCCC0C0, MDP_CLK_CTRL3);
272 writel(0xCCCCC0C0, MDP_CLK_CTRL4);
273 writel(0xCCCCC0C0, MDP_CLK_CTRL5);
274 writel(0x00CCC000, MDP_CLK_CTRL7);
275
Dhaval Patelab2de892013-10-25 10:40:58 -0700276 writel(0x00080808, VBIF_VBIF_IN_RD_LIM_CONF0);
277 writel(0x08000808, VBIF_VBIF_IN_RD_LIM_CONF1);
278 writel(0x00080808, VBIF_VBIF_IN_RD_LIM_CONF2);
279 writel(0x00000808, VBIF_VBIF_IN_RD_LIM_CONF3);
280 writel(0x10000000, VBIF_VBIF_IN_WR_LIM_CONF0);
281 writel(0x00100000, VBIF_VBIF_IN_WR_LIM_CONF1);
282 writel(0x10000000, VBIF_VBIF_IN_WR_LIM_CONF2);
283 writel(0x00000000, VBIF_VBIF_IN_WR_LIM_CONF3);
284 writel(0x00013fff, VBIF_VBIF_ABIT_SHORT);
285 writel(0x000000A4, VBIF_VBIF_ABIT_SHORT_CONF);
286 writel(0x00003FFF, VBIF_VBIF_GATE_OFF_WRREQ_EN);
287 writel(0x00000003, VBIF_VBIF_DDR_RND_RBN_QOS_ARB);
288
289 return NO_ERROR;
290}
291
Ajay Singh Parmar60430b92014-07-23 23:39:01 -0700292int target_hdmi_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
293{
294 uint32_t ret;
295
296 dprintf(SPEW, "%s: target_panel_clock\n", __func__);
297
298 if (enable) {
299 mdp_gdsc_ctrl(enable);
300 mmss_bus_clock_enable();
301 mdp_clock_enable();
302 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
303 if (ret) {
304 dprintf(CRITICAL,
305 "%s: Failed to restore MDP security configs",
306 __func__);
307 mdp_clock_disable();
308 mmss_bus_clock_disable();
309 mdp_gdsc_ctrl(0);
310 return ret;
311 }
312
313 hdmi_phy_reset();
314 hdmi_pll_config();
315 hdmi_vco_enable();
316 hdmi_clk_enable();
317 } else if(!target_cont_splash_screen()) {
318 /* Disable clocks if continuous splash off */
319 hdmi_clk_disable();
320 hdmi_vco_disable();
321 mdp_clock_disable();
322 mmss_bus_clock_disable();
323 mdp_gdsc_ctrl(enable);
324 }
325
326 return NO_ERROR;
327}
328
329static void target_hdmi_mvs_enable(bool enable)
330{
331 struct pm8x41_mvs mvs;
332 mvs.base = PM8x41_MVS1_BASE;
333
334 if (enable)
335 pm8x41_enable_mvs(&mvs, MVS_ENABLE);
336 else
337 pm8x41_enable_mvs(&mvs, MVS_DISABLE);
338}
339
340static void target_hdmi_vreg_enable(bool enable)
341{
342 struct pm8x41_mpp mpp;
343 mpp.base = PM8x41_MMP3_BASE;
344
345 if (enable) {
346 mpp.mode = MPP_HIGH;
347 mpp.vin = MPP_VIN2;
348 pm8x41_config_output_mpp(&mpp);
349 pm8x41_enable_mpp(&mpp, MPP_ENABLE);
350 } else {
351 pm8x41_enable_mpp(&mpp, MPP_DISABLE);
352 }
353}
354
355int target_hdmi_regulator_ctrl(bool enable)
356{
357 target_hdmi_mvs_enable(enable);
358 target_hdmi_vreg_enable(enable);
359
360 return 0;
361}
362
Ajay Singh Parmar7f31e0e2014-09-03 22:09:46 -0700363int target_hdmi_gpio_ctrl(bool enable)
364{
365 gpio_tlmm_config(hdmi_cec_gpio.pin_id, 1, /* gpio 31, CEC */
366 hdmi_cec_gpio.pin_direction, hdmi_cec_gpio.pin_pull,
367 hdmi_cec_gpio.pin_strength, hdmi_cec_gpio.pin_state);
368
369 gpio_tlmm_config(hdmi_ddc_clk_gpio.pin_id, 1, /* gpio 32, DDC CLK */
370 hdmi_ddc_clk_gpio.pin_direction, hdmi_ddc_clk_gpio.pin_pull,
371 hdmi_ddc_clk_gpio.pin_strength, hdmi_ddc_clk_gpio.pin_state);
372
373
374 gpio_tlmm_config(hdmi_ddc_data_gpio.pin_id, 1, /* gpio 33, DDC DATA */
375 hdmi_ddc_data_gpio.pin_direction, hdmi_ddc_data_gpio.pin_pull,
376 hdmi_ddc_data_gpio.pin_strength, hdmi_ddc_data_gpio.pin_state);
377
378 gpio_tlmm_config(hdmi_hpd_gpio.pin_id, 1, /* gpio 34, HPD */
379 hdmi_hpd_gpio.pin_direction, hdmi_hpd_gpio.pin_pull,
380 hdmi_hpd_gpio.pin_strength, hdmi_hpd_gpio.pin_state);
381
382 gpio_set(hdmi_cec_gpio.pin_id, hdmi_cec_gpio.pin_direction);
383 gpio_set(hdmi_ddc_clk_gpio.pin_id, hdmi_ddc_clk_gpio.pin_direction);
384 gpio_set(hdmi_ddc_data_gpio.pin_id, hdmi_ddc_data_gpio.pin_direction);
385 gpio_set(hdmi_hpd_gpio.pin_id, hdmi_hpd_gpio.pin_direction);
386
387 /* MUX */
388 gpio_tlmm_config(hdmi_mux_lpm_gpio.pin_id, 0, /* gpio 27 MUX LPM */
389 hdmi_mux_lpm_gpio.pin_direction, hdmi_mux_lpm_gpio.pin_pull,
390 hdmi_mux_lpm_gpio.pin_strength, hdmi_mux_lpm_gpio.pin_state);
391
392 gpio_tlmm_config(hdmi_mux_en_gpio.pin_id, 0, /* gpio 83 MUX EN */
393 hdmi_mux_en_gpio.pin_direction, hdmi_mux_en_gpio.pin_pull,
394 hdmi_mux_en_gpio.pin_strength, hdmi_mux_en_gpio.pin_state);
395
396 gpio_tlmm_config(hdmi_mux_sel_gpio.pin_id, 0, /* gpio 85 MUX SEL */
397 hdmi_mux_sel_gpio.pin_direction, hdmi_mux_sel_gpio.pin_pull,
398 hdmi_mux_sel_gpio.pin_strength, hdmi_mux_sel_gpio.pin_state);
399
400 gpio_set(hdmi_mux_lpm_gpio.pin_id, hdmi_mux_lpm_gpio.pin_direction);
401 gpio_set(hdmi_mux_en_gpio.pin_id, hdmi_mux_en_gpio.pin_direction);
402 gpio_set(hdmi_mux_sel_gpio.pin_id, hdmi_mux_sel_gpio.pin_direction);
403
404 return NO_ERROR;
405}
406
Kuogee Hsiehacc31942014-06-17 15:12:10 -0700407void target_edp_panel_init(struct msm_panel_info *pinfo)
408{
409 edp_panel_init(pinfo);
410}
411
412int target_edp_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
413{
414 uint32_t ret;
415
416 dprintf(SPEW, "%s: target_panel_clock\n", __func__);
417
418 if (enable) {
419 mdp_gdsc_ctrl(enable);
420 mmss_bus_clock_enable();
421 mdp_clock_enable();
422 ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
423 if (ret) {
424 dprintf(CRITICAL,
425 "%s: Failed to restore MDP security configs",
426 __func__);
427 mdp_clock_disable();
428 mmss_bus_clock_disable();
429 mdp_gdsc_ctrl(0);
430 return ret;
431 }
432
433 edp_clk_enable();
434 } else if(!target_cont_splash_screen()) {
435 /* Disable clocks if continuous splash off */
436 edp_clk_disable();
437 mdp_clock_disable();
438 mmss_bus_clock_disable();
439 mdp_gdsc_ctrl(enable);
440 }
441
442 return NO_ERROR;
443}
444
445int target_edp_panel_enable(void)
446{
447 gpio_tlmm_config(enable_gpio.pin_id, 0, /* gpio 137 */
448 enable_gpio.pin_direction, enable_gpio.pin_pull,
449 enable_gpio.pin_strength, enable_gpio.pin_state);
450
451
452 gpio_tlmm_config(edp_hpd_gpio.pin_id, 0, /* hpd 103 */
453 edp_hpd_gpio.pin_direction, edp_hpd_gpio.pin_pull,
454 edp_hpd_gpio.pin_strength, edp_hpd_gpio.pin_state);
455
456
457 gpio_tlmm_config(edp_lvl_en_gpio.pin_id, 0, /* lvl_en 91 */
458 edp_lvl_en_gpio.pin_direction, edp_lvl_en_gpio.pin_pull,
459 edp_lvl_en_gpio.pin_strength, edp_lvl_en_gpio.pin_state);
460
461 gpio_set(enable_gpio.pin_id, 2);
462 gpio_set(edp_lvl_en_gpio.pin_id, 2);
463
464 return NO_ERROR;
465}
466
467int target_edp_panel_disable(void)
468{
469 gpio_set(edp_lvl_en_gpio.pin_id, 0);
470 gpio_set(enable_gpio.pin_id, 0);
471
472 return NO_ERROR;
473}
474
475int target_edp_bl_ctrl(int enable)
476{
477 return target_backlight_ctrl(&edp_bklt, enable);
478}
479
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700480bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size)
481{
482 int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
483 bool ret = true;
484
485 panel_name += strspn(panel_name, " ");
486
487 if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
488 if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN +
Ajay Singh Parmar3d14bdd2014-07-11 14:56:32 -0700489 strlen(HDMI_CONTROLLER_STRING))) {
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700490 dprintf(CRITICAL, "command line argument is greater than buffer size\n");
491 return false;
492 }
493
494 strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
495 buf_size -= prefix_string_len;
496 strlcat(pbuf, LK_OVERRIDE_PANEL, buf_size);
497 buf_size -= LK_OVERRIDE_PANEL_LEN;
498 strlcat(pbuf, HDMI_CONTROLLER_STRING, buf_size);
499 } else {
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700500 ret = gcdb_display_cmdline_arg(panel_name, pbuf, buf_size);
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700501 }
502
503 return ret;
504}
505
Aravind Venkateswaran6385f7e2014-02-25 16:45:11 -0800506void target_display_init(const char *panel_name)
Dhaval Patelf9986272013-10-18 19:06:05 -0700507{
508 uint32_t ret = 0;
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700509
510 panel_name += strspn(panel_name, " ");
511
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700512 if ((!strcmp(panel_name, NO_PANEL_CONFIG))
513 || (!strcmp(panel_name, SIM_VIDEO_PANEL))
514 || (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL))) {
515 dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
516 panel_name);
Jeevan Shriramb0d523a2014-05-30 12:55:17 -0700517 return;
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700518 } else if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700519 dprintf(INFO, "%s: HDMI is primary\n", __func__);
Ajay Singh Parmar243d82b2014-07-23 23:01:44 -0700520 mdss_hdmi_display_init(MDP_REV_50, HDMI_FB_ADDR);
Ajay Singh Parmareef1d602014-03-15 17:41:52 -0700521 return;
522 }
523
Aravind Venkateswarand494f962014-02-25 17:16:49 -0800524 ret = gcdb_display_init(panel_name, MDP_REV_50, MIPI_FB_ADDR);
Veera Sundaram Sankaranc95d6752014-07-31 11:49:52 -0700525 if (ret)
Dhaval Patelf9986272013-10-18 19:06:05 -0700526 msm_display_off();
Dhaval Patelf9986272013-10-18 19:06:05 -0700527}
528
Aravind Venkateswarandd50c1a2014-02-25 14:42:43 -0800529void target_display_shutdown(void)
Dhaval Patelf9986272013-10-18 19:06:05 -0700530{
531 gcdb_display_shutdown();
532}