blob: 1f09bb16d76f5811d369b4fd7191ef087ecce745 [file] [log] [blame]
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
2 *
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 <msm_panel.h>
33#include <pm8x41.h>
34#include <pm8x41_wled.h>
35#include <board.h>
36#include <mdp5.h>
37#include <platform/gpio.h>
38#include <target/display.h>
39
40static struct msm_fb_panel_data panel;
41static uint8_t display_enable;
42
43extern int msm_display_init(struct msm_fb_panel_data *pdata);
44extern int msm_display_off();
45extern int mdss_dsi_uniphy_pll_config(void);
46
47static int msm8974_backlight_on()
48{
49 static struct pm8x41_wled_data wled_ctrl = {
50 .mod_scheme = 0xC3,
51 .led1_brightness = (0x0F << 8) | 0xEF,
52 .led2_brightness = (0x0F << 8) | 0xEF,
53 .led3_brightness = (0x0F << 8) | 0xEF,
54 .max_duty_cycle = 0x01,
55 };
56
57 pm8x41_wled_config(&wled_ctrl);
58 pm8x41_wled_sink_control(1);
59 pm8x41_wled_iled_sync_control(1);
60 pm8x41_wled_enable(1);
61
62 return 0;
63}
64
65static int msm8974_mdss_dsi_panel_clock(uint8_t enable)
66{
67 if (enable) {
68 mdp_gdsc_ctrl(enable);
69 mdp_clock_init();
70 mdss_dsi_uniphy_pll_config();
71 mmss_clock_init();
72 } else if(!target_cont_splash_screen()) {
73 // * Add here for continuous splash *
74 }
75
76 return 0;
77}
78
79/* Pull DISP_RST_N high to get panel out of reset */
80static void msm8974_mdss_mipi_panel_reset(void)
81{
82 struct pm8x41_gpio gpio19_param = {
83 .direction = PM_GPIO_DIR_OUT,
84 .output_buffer = PM_GPIO_OUT_CMOS,
85 .out_strength = PM_GPIO_OUT_DRIVE_MED,
86 };
87
88 pm8x41_gpio_config(19, &gpio19_param);
89 gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE);
90
91 pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH);
92 mdelay(2);
93 pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW);
94 mdelay(5);
95 pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH);
96 mdelay(2);
97 gpio_set(58, 2);
98}
99
100
101static int msm8974_mipi_panel_power(uint8_t enable)
102{
103 if (enable) {
104
105 /* Enable backlight */
106 msm8974_backlight_on();
107
108 /* Turn on LDO8 for lcd1 mipi vdd */
109 dprintf(SPEW, " Setting LDO22\n");
110 pm8x41_ldo_set_voltage("LDO22", 3000000);
111 pm8x41_ldo_control("LDO22", enable);
112
113 dprintf(SPEW, " Setting LDO12\n");
114 /* Turn on LDO23 for lcd1 mipi vddio */
115 pm8x41_ldo_set_voltage("LDO12", 1800000);
116 pm8x41_ldo_control("LDO12", enable);
117
118 dprintf(SPEW, " Setting LDO2\n");
119 /* Turn on LDO2 for vdda_mipi_dsi */
120 pm8x41_ldo_set_voltage("LDO2", 1200000);
121 pm8x41_ldo_control("LDO2", enable);
122
123 dprintf(SPEW, " Panel Reset \n");
124 /* Panel Reset */
125 msm8974_mdss_mipi_panel_reset();
126 dprintf(SPEW, " Panel Reset Done\n");
127 }
128
129 return 0;
130}
131
132void display_init(void)
133{
134 uint32_t hw_id = board_hardware_id();
135
136 dprintf(INFO, "display_init(),target_id=%d.\n", hw_id);
137
138 switch (hw_id) {
Siddhartha Agrawal7ac6d512013-01-22 18:39:50 -0800139 case HW_PLATFORM_MTP:
140 case HW_PLATFORM_FLUID:
141 mipi_toshiba_video_720p_init(&(panel.panel_info));
142 panel.clk_func = msm8974_mdss_dsi_panel_clock;
143 panel.power_func = msm8974_mipi_panel_power;
144 panel.fb.base = MIPI_FB_ADDR;
145 panel.fb.width = panel.panel_info.xres;
146 panel.fb.height = panel.panel_info.yres;
147 panel.fb.stride = panel.panel_info.xres;
148 panel.fb.bpp = panel.panel_info.bpp;
149 panel.fb.format = FB_FORMAT_RGB888;
150 panel.mdp_rev = MDP_REV_50;
151 break;
152 default:
153 return;
154 };
155
156 if (msm_display_init(&panel)) {
157 dprintf(CRITICAL, "Display init failed!\n");
158 return;
159 }
160
161 display_enable = 1;
162}
163
164void display_shutdown(void)
165{
166 if (display_enable)
167 msm_display_off();
168}