blob: 59e7aad1e0af87304b6cd41568588316c7b3a176 [file] [log] [blame]
Asaf Pensob8f524c2013-05-20 12:32:31 +03001/* Copyright (c) 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 "edp.h"
31#include "mdp5.h"
32
33#define RGB_COMPONENTS 3
34#define MAX_NUMBER_EDP_LANES 4
35
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -070036static struct msm_panel_info *edp_pinfo;
37
Asaf Pensob8f524c2013-05-20 12:32:31 +030038static void edp_config_sync(void)
39{
40 int ret = 0;
41
42 ret = edp_read(EDP_BASE + 0xc); /* EDP_CONFIGURATION_CTRL */
43 ret &= ~0x733;
44 ret |= (0x55 & 0x733);
45 edp_write(EDP_BASE + 0xc, ret);
46 edp_write(EDP_BASE + 0xc, 0x55); /* EDP_CONFIGURATION_CTRL */
47}
48
49static void edp_config_sw_div(void)
50{
51 edp_write(EDP_BASE + 0x14, 0x13b); /* EDP_SOFTWARE_MVID */
52 edp_write(EDP_BASE + 0x18, 0x266); /* EDP_SOFTWARE_NVID */
53}
54
55static void edp_config_static_mdiv(void)
56{
57 int ret = 0;
58
59 ret = edp_read(EDP_BASE + 0xc); /* EDP_CONFIGURATION_CTRL */
60 edp_write(EDP_BASE + 0xc, ret | 0x2); /* EDP_CONFIGURATION_CTRL */
61 edp_write(EDP_BASE + 0xc, 0x57); /* EDP_CONFIGURATION_CTRL */
62}
63
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -070064static void edp_config_tu(void)
Asaf Pensob8f524c2013-05-20 12:32:31 +030065{
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -070066 /* temporary */
67 edp_write(EDP_BASE + 0x160, 0x2b);
68 edp_write(EDP_BASE + 0x15c, 0x00320033);
69 edp_write(EDP_BASE + 0x34, 0x0023001a);
70
71}
72
73static void edp_config_timing(struct msm_panel_info *pinfo)
74{
75 unsigned long total_ver, total_hor;
76 unsigned long data;
77
78 dprintf(INFO, "%s: width=%d hporch= %d %d %d\n", __func__,
79 pinfo->xres, pinfo->lcdc.h_back_porch,
80 pinfo->lcdc.h_front_porch, pinfo->lcdc.h_pulse_width);
81
82 dprintf(INFO, "%s: height=%d vporch= %d %d %d\n", __func__,
83 pinfo->yres, pinfo->lcdc.v_back_porch,
84 pinfo->lcdc.v_front_porch, pinfo->lcdc.v_pulse_width);
85
86 total_hor = pinfo->xres + pinfo->lcdc.h_back_porch +
87 pinfo->lcdc.h_front_porch + pinfo->lcdc.h_pulse_width;
88
89 total_ver = pinfo->yres + pinfo->lcdc.v_back_porch +
90 pinfo->lcdc.v_front_porch + pinfo->lcdc.v_pulse_width;
91
92 data = total_ver;
93 data <<= 16;
94 data |= total_hor;
95 edp_write(EDP_BASE + 0x1c, data); /* EDP_TOTAL_HOR_VER */
96
97 data = (pinfo->lcdc.v_back_porch + pinfo->lcdc.v_pulse_width);
98 data <<= 16;
99 data |= (pinfo->lcdc.h_back_porch + pinfo->lcdc.h_pulse_width);
100 edp_write(EDP_BASE + 0x20, data); /* EDP_START_HOR_VER_FROM_SYNC */
101
102 data = pinfo->lcdc.v_pulse_width;
103 data <<= 16;
104 data |= pinfo->lcdc.h_pulse_width;
105 edp_write(EDP_BASE + 0x24, data); /* EDP_HSYNC_VSYNC_WIDTH_POLARITY */
106
107 data = pinfo->yres;
108 data <<= 16;
109 data |= pinfo->xres;
110 edp_write(EDP_BASE + 0x28, data); /* EDP_ACTIVE_HOR_VER */
Asaf Pensob8f524c2013-05-20 12:32:31 +0300111}
112
113static void edp_enable(int enable)
114{
115 edp_write(EDP_BASE + 0x8, 0x0); /* EDP_STATE_CTRL */
116 edp_write(EDP_BASE + 0x8, 0x40); /* EDP_STATE_CTRL */
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700117 edp_write(EDP_BASE + 0x4, 0x01); /* EDP_MAINLINK_CTRL */
Asaf Pensob8f524c2013-05-20 12:32:31 +0300118}
119
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700120static void edp_disable(int enable)
Asaf Pensob8f524c2013-05-20 12:32:31 +0300121{
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700122 edp_write(EDP_BASE + 0x8, 0x0); /* EDP_STATE_CTRL */
123 edp_write(EDP_BASE + 0x4, 0x00); /* EDP_MAINLINK_CTRL */
Asaf Pensob8f524c2013-05-20 12:32:31 +0300124}
125
126int edp_on(void)
127{
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700128 mdss_edp_pll_configure();
129 mdss_edp_phy_pll_ready();
Asaf Pensob8f524c2013-05-20 12:32:31 +0300130 edp_phy_misc_cfg();
131 edp_config_sync();
132 edp_config_sw_div();
133 edp_config_static_mdiv();
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700134 edp_config_timing(edp_pinfo);
135 edp_config_tu();
Asaf Pensob8f524c2013-05-20 12:32:31 +0300136
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700137 edp_config_clk();
138 mdss_edp_lane_power_ctrl(1);
Asaf Pensob8f524c2013-05-20 12:32:31 +0300139
140 edp_enable_mainlink(1);
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700141
142 mdss_edp_link_train();
143
Asaf Pensob8f524c2013-05-20 12:32:31 +0300144 edp_enable(1);
145
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700146 mdss_edp_wait_for_video_ready();
147
148 mdss_edp_irq_disable();
149 dprintf(INFO, "%s:\n", __func__);
150
Asaf Pensob8f524c2013-05-20 12:32:31 +0300151 return 0;
152}
153
154int edp_off(void)
155{
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700156 mdss_edp_irq_disable();
Asaf Pensob8f524c2013-05-20 12:32:31 +0300157 edp_enable_mainlink(0);
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700158 edp_phy_pll_reset();
159 edp_mainlink_reset();
160 edp_aux_reset();
Asaf Pensob8f524c2013-05-20 12:32:31 +0300161
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700162 edp_disable(1);
163 edp_unconfig_clk();
Asaf Pensob8f524c2013-05-20 12:32:31 +0300164
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700165 mdss_edp_lane_power_ctrl(0);
166 edp_phy_powerup(0);
167
168 dprintf(INFO, "%s:\n", __func__);
169
Asaf Pensob8f524c2013-05-20 12:32:31 +0300170
171 return 0;
172}
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700173
174int edp_prepare(void)
175{
176
177 mdss_edp_aux_init();
178 edp_phy_pll_reset();
179 edp_mainlink_reset();
180 edp_aux_reset();
181 edp_phy_powerup(1);
182 edp_aux_enable();
183 mdss_edp_irq_enable();
184
185 mdss_edp_wait_for_hpd();
186
187 mdss_edp_edid_read();
188 mdss_edp_dpcd_cap_read();
189
190 edp_edid2pinfo(edp_pinfo);
191 edp_cap2pinfo(edp_pinfo);
192
193 dprintf(INFO, "%s:\n", __func__);
194
195 return 0;
196}
197
198void edp_panel_init(struct msm_panel_info *pinfo)
199{
200 if (!pinfo)
201 return;
202
Siddhartha Agrawalf67b3ff2013-10-23 18:08:04 -0700203 pinfo->lcdc.dual_pipe = 0;
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700204 pinfo->lcdc.split_display = 0;
205
206 edp_pinfo = pinfo;
207 edp_pinfo->on = edp_on;
208 edp_pinfo->off = edp_off;
209 edp_pinfo->prepare = edp_prepare;
210}