blob: 48a26bc916a2253c7337eef70cef48fe69a00361 [file] [log] [blame]
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -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 are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of The Linux Foundation nor
11 * the names of its contributors may be used to endorse or promote
12 * products derived from this software without specific prior written
13 * permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <mdp5.h>
29#include <debug.h>
30#include <reg.h>
31#include <target/display.h>
32#include <platform/timer.h>
33#include <platform/iomap.h>
34#include <dev/lcdc.h>
35#include <dev/fbcon.h>
36#include <bits.h>
37#include <msm_panel.h>
38#include <mipi_dsi.h>
39#include <err.h>
40#include <clock.h>
41#include <mdp5.h>
Siddhartha Agrawal8d690822013-01-28 12:18:58 -080042#include <scm.h>
43
44int restore_secure_cfg(uint32_t id);
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -080045
46static int mdp_rev;
47
48void mdp_set_revision(int rev)
49{
50 mdp_rev = rev;
51}
52
53int mdp_get_revision()
54{
55 return mdp_rev;
56}
57
58void mdp_clk_gating_ctrl(void)
59{
60 writel(0x40000000, MDP_CLK_CTRL0);
61 udelay(20);
62 writel(0x40000040, MDP_CLK_CTRL0);
63 writel(0x40000000, MDP_CLK_CTRL1);
64 writel(0x00400000, MDP_CLK_CTRL3);
65 udelay(20);
66 writel(0x00404000, MDP_CLK_CTRL3);
67 writel(0x40000000, MDP_CLK_CTRL4);
68}
69
70int mdp_dsi_video_config(struct msm_panel_info *pinfo,
71 struct fbcon_config *fb)
72{
73 int ret = NO_ERROR;
74 uint32_t hsync_period, vsync_period;
75 uint32_t hsync_start_x, hsync_end_x;
76 uint32_t display_hctl, active_hctl, hsync_ctl, display_vstart, display_vend;
77 struct lcdc_panel_info *lcdc = NULL;
78 unsigned mdp_rgb_size;
Siddhartha Agrawal8d690822013-01-28 12:18:58 -080079 int access_secure = 0;
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -080080
81 if (pinfo == NULL)
82 return ERR_INVALID_ARGS;
83
84 lcdc = &(pinfo->lcdc);
85 if (lcdc == NULL)
86 return ERR_INVALID_ARGS;
87
88 hsync_period = lcdc->h_pulse_width +
89 lcdc->h_back_porch +
90 pinfo->xres + lcdc->xres_pad + lcdc->h_front_porch;
91 vsync_period = (lcdc->v_pulse_width +
92 lcdc->v_back_porch +
93 pinfo->yres + lcdc->yres_pad +
94 lcdc->v_front_porch);
95
96 hsync_start_x =
97 lcdc->h_pulse_width +
98 lcdc->h_back_porch;
99 hsync_end_x =
100 hsync_period - lcdc->h_front_porch - 1;
101
102 display_vstart = (lcdc->v_pulse_width +
103 lcdc->v_back_porch)
104 * hsync_period + lcdc->hsync_skew;
105 display_vend = ((vsync_period - lcdc->v_front_porch) * hsync_period)
106 +lcdc->hsync_skew - 1;
107
108 hsync_ctl = (hsync_period << 16) | lcdc->h_pulse_width;
109 display_hctl = (hsync_end_x << 16) | hsync_start_x;
110
111 /* write active region size*/
112 mdp_rgb_size = (fb->height << 16) + fb->width;
113
Siddhartha Agrawal8d690822013-01-28 12:18:58 -0800114 access_secure = restore_secure_cfg(SECURE_DEVICE_MDSS);
115
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -0800116 mdp_clk_gating_ctrl();
117
Siddhartha Agrawal8d690822013-01-28 12:18:58 -0800118 if (!access_secure) {
119 /* Force VBIF Clocks on */
120 writel(0x1, VBIF_VBIF_DDR_FORCE_CLK_ON);
121 /* Configure DDR burst length */
122 writel(0x00000707, VBIF_VBIF_DDR_OUT_MAX_BURST);
123 }
124
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -0800125 /* Allocate SMP blocks */
126 writel(0x00101010, MMSS_MDP_SMP_ALLOC_W_0);
127 writel(0x00000010, MMSS_MDP_SMP_ALLOC_W_1);
128 writel(0x00101010, MMSS_MDP_SMP_ALLOC_R_0);
129 writel(0x00000010, MMSS_MDP_SMP_ALLOC_R_1);
130
131 writel(hsync_ctl, MDP_INTF_1_HSYNC_CTL);
132 writel(vsync_period*hsync_period, MDP_INTF_1_VSYNC_PERIOD_F0);
133 writel(0x00, MDP_INTF_1_VSYNC_PERIOD_F1);
134 writel(lcdc->v_pulse_width*hsync_period, MDP_INTF_1_VSYNC_PULSE_WIDTH_F0);
135 writel(0x00, MDP_INTF_1_VSYNC_PULSE_WIDTH_F1);
136 writel(display_hctl, MDP_INTF_1_DISPLAY_HCTL);
137 writel(display_vstart, MDP_INTF_1_DISPLAY_V_START_F0);
138 writel(0x00, MDP_INTF_1_DISPLAY_V_START_F1);
139 writel(display_vend, MDP_INTF_1_DISPLAY_V_END_F0);
140 writel(0x00, MDP_INTF_1_DISPLAY_V_END_F1);
141 writel(0x00, MDP_INTF_1_ACTIVE_HCTL);
142 writel(0x00, MDP_INTF_1_ACTIVE_V_START_F0);
143 writel(0x00, MDP_INTF_1_ACTIVE_V_START_F1);
144 writel(0x00, MDP_INTF_1_ACTIVE_V_END_F0);
145 writel(0x00, MDP_INTF_1_ACTIVE_V_END_F1);
146 writel(0xFF, MDP_INTF_1_UNDERFFLOW_COLOR);
147
148 writel(fb->base, MDP_VP_0_RGB_0_SSPP_SRC0_ADDR);
149 writel((fb->stride * fb->bpp/8),MDP_VP_0_RGB_0_SSPP_SRC_YSTRIDE);
150 writel(mdp_rgb_size, MDP_VP_0_RGB_0_SSPP_SRC_IMG_SIZE);
151 writel(mdp_rgb_size, MDP_VP_0_RGB_0_SSPP_SRC_SIZE);
152 writel(mdp_rgb_size, MDP_VP_0_RGB_0_SSPP_SRC_OUT_SIZE);
153 writel(0x00, MDP_VP_0_RGB_0_SSPP_SRC_XY);
154 writel(0x00, MDP_VP_0_RGB_0_SSPP_OUT_XY);
155 /* Tight Packing 3bpp 0-Alpha 8-bit R B G */
156 writel(0x0002243F, MDP_VP_0_RGB_0_SSPP_SRC_FORMAT);
157 writel(0x00020001, MDP_VP_0_RGB_0_SSPP_SRC_UNPACK_PATTERN);
158 writel(0x00, MDP_VP_0_RGB_0_SSPP_SRC_OP_MODE);
159
160 writel(mdp_rgb_size,MDP_VP_0_LAYER_0_OUT_SIZE);
161 writel(0x00, MDP_VP_0_LAYER_0_OP_MODE);
162 writel(0x100, MDP_VP_0_LAYER_0_BLEND_OP);
163 writel(0xFF, MDP_VP_0_LAYER_0_BLEND0_FG_ALPHA);
164 writel(0x100, MDP_VP_0_LAYER_1_BLEND_OP);
165 writel(0xFF, MDP_VP_0_LAYER_1_BLEND0_FG_ALPHA);
166 writel(0x100, MDP_VP_0_LAYER_2_BLEND_OP);
167 writel(0xFF, MDP_VP_0_LAYER_2_BLEND0_FG_ALPHA);
168 writel(0x100, MDP_VP_0_LAYER_3_BLEND_OP);
169 writel(0xFF, MDP_VP_0_LAYER_3_BLEND0_FG_ALPHA);
170
171 /* Baselayer for layer mixer 0 */
172 writel(0x010000200, MDP_CTL_0_LAYER_0);
173
174 writel(0x1F20, MDP_CTL_0_TOP);
175 writel(0x213F, MDP_INTF_1_PANEL_FORMAT);
176
177 writel(0x0100, MDP_DISP_INTF_SEL);
178 writel(0x1111, MDP_VIDEO_INTF_UNDERFLOW_CTL);
179 writel(0x01, MDP_UPPER_NEW_ROI_PRIOR_RO_START);
180 writel(0x01, MDP_LOWER_NEW_ROI_PRIOR_TO_START);
181
182 return 0;
183}
184
185int mdp_dsi_cmd_config(struct msm_panel_info *pinfo,
186 struct fbcon_config *fb)
187{
188
189 int ret = 0;
190 return ret;
191}
192
193int mdp_dsi_video_on(void)
194{
195 int ret = NO_ERROR;
196 writel(0x32048, MDP_CTL_0_FLUSH);
197 writel(0x01, MDP_INTF_1_TIMING_ENGINE_EN);
198 return ret;
199}
200
201int mdp_dsi_video_off()
202{
203 if(!target_cont_splash_screen())
204 {
205 writel(0x00000000, MDP_INTF_1_TIMING_ENGINE_EN);
206 mdelay(60);
207 /* Ping-Pong done Tear Check Read/Write */
208 /* Underrun(Interface 0/1/2/3) VSYNC Interrupt Enable */
209 writel(0xFF777713, MDP_INTR_CLEAR);
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -0800210 }
211
Siddhartha Agrawal6a598222013-02-17 18:33:27 -0800212 writel(0x00000000, MDP_INTR_EN);
213
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -0800214 return NO_ERROR;
215}
216
217int mdp_dsi_cmd_off()
218{
219 return NO_ERROR;
220}
221
222int mdp_dma_on(void)
223{
224 return NO_ERROR;
225}
226
227void mdp_disable(void)
228{
229
230}