blob: 54fc33b4a235361ed1bfa87411558b0001eba8fd [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
114 /* Ping-Pong done Tear Check Read/Write */
115 /* Underrun(Interface 0/1/2/3) VSYNC Interrupt Enable */
116 writel(0xFF777713, MDP_INTR_EN);
117
Siddhartha Agrawal8d690822013-01-28 12:18:58 -0800118 access_secure = restore_secure_cfg(SECURE_DEVICE_MDSS);
119
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -0800120 mdp_clk_gating_ctrl();
121
Siddhartha Agrawal8d690822013-01-28 12:18:58 -0800122 if (!access_secure) {
123 /* Force VBIF Clocks on */
124 writel(0x1, VBIF_VBIF_DDR_FORCE_CLK_ON);
125 /* Configure DDR burst length */
126 writel(0x00000707, VBIF_VBIF_DDR_OUT_MAX_BURST);
127 }
128
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -0800129 /* Allocate SMP blocks */
130 writel(0x00101010, MMSS_MDP_SMP_ALLOC_W_0);
131 writel(0x00000010, MMSS_MDP_SMP_ALLOC_W_1);
132 writel(0x00101010, MMSS_MDP_SMP_ALLOC_R_0);
133 writel(0x00000010, MMSS_MDP_SMP_ALLOC_R_1);
134
135 writel(hsync_ctl, MDP_INTF_1_HSYNC_CTL);
136 writel(vsync_period*hsync_period, MDP_INTF_1_VSYNC_PERIOD_F0);
137 writel(0x00, MDP_INTF_1_VSYNC_PERIOD_F1);
138 writel(lcdc->v_pulse_width*hsync_period, MDP_INTF_1_VSYNC_PULSE_WIDTH_F0);
139 writel(0x00, MDP_INTF_1_VSYNC_PULSE_WIDTH_F1);
140 writel(display_hctl, MDP_INTF_1_DISPLAY_HCTL);
141 writel(display_vstart, MDP_INTF_1_DISPLAY_V_START_F0);
142 writel(0x00, MDP_INTF_1_DISPLAY_V_START_F1);
143 writel(display_vend, MDP_INTF_1_DISPLAY_V_END_F0);
144 writel(0x00, MDP_INTF_1_DISPLAY_V_END_F1);
145 writel(0x00, MDP_INTF_1_ACTIVE_HCTL);
146 writel(0x00, MDP_INTF_1_ACTIVE_V_START_F0);
147 writel(0x00, MDP_INTF_1_ACTIVE_V_START_F1);
148 writel(0x00, MDP_INTF_1_ACTIVE_V_END_F0);
149 writel(0x00, MDP_INTF_1_ACTIVE_V_END_F1);
150 writel(0xFF, MDP_INTF_1_UNDERFFLOW_COLOR);
151
152 writel(fb->base, MDP_VP_0_RGB_0_SSPP_SRC0_ADDR);
153 writel((fb->stride * fb->bpp/8),MDP_VP_0_RGB_0_SSPP_SRC_YSTRIDE);
154 writel(mdp_rgb_size, MDP_VP_0_RGB_0_SSPP_SRC_IMG_SIZE);
155 writel(mdp_rgb_size, MDP_VP_0_RGB_0_SSPP_SRC_SIZE);
156 writel(mdp_rgb_size, MDP_VP_0_RGB_0_SSPP_SRC_OUT_SIZE);
157 writel(0x00, MDP_VP_0_RGB_0_SSPP_SRC_XY);
158 writel(0x00, MDP_VP_0_RGB_0_SSPP_OUT_XY);
159 /* Tight Packing 3bpp 0-Alpha 8-bit R B G */
160 writel(0x0002243F, MDP_VP_0_RGB_0_SSPP_SRC_FORMAT);
161 writel(0x00020001, MDP_VP_0_RGB_0_SSPP_SRC_UNPACK_PATTERN);
162 writel(0x00, MDP_VP_0_RGB_0_SSPP_SRC_OP_MODE);
163
164 writel(mdp_rgb_size,MDP_VP_0_LAYER_0_OUT_SIZE);
165 writel(0x00, MDP_VP_0_LAYER_0_OP_MODE);
166 writel(0x100, MDP_VP_0_LAYER_0_BLEND_OP);
167 writel(0xFF, MDP_VP_0_LAYER_0_BLEND0_FG_ALPHA);
168 writel(0x100, MDP_VP_0_LAYER_1_BLEND_OP);
169 writel(0xFF, MDP_VP_0_LAYER_1_BLEND0_FG_ALPHA);
170 writel(0x100, MDP_VP_0_LAYER_2_BLEND_OP);
171 writel(0xFF, MDP_VP_0_LAYER_2_BLEND0_FG_ALPHA);
172 writel(0x100, MDP_VP_0_LAYER_3_BLEND_OP);
173 writel(0xFF, MDP_VP_0_LAYER_3_BLEND0_FG_ALPHA);
174
175 /* Baselayer for layer mixer 0 */
176 writel(0x010000200, MDP_CTL_0_LAYER_0);
177
178 writel(0x1F20, MDP_CTL_0_TOP);
179 writel(0x213F, MDP_INTF_1_PANEL_FORMAT);
180
181 writel(0x0100, MDP_DISP_INTF_SEL);
182 writel(0x1111, MDP_VIDEO_INTF_UNDERFLOW_CTL);
183 writel(0x01, MDP_UPPER_NEW_ROI_PRIOR_RO_START);
184 writel(0x01, MDP_LOWER_NEW_ROI_PRIOR_TO_START);
185
186 return 0;
187}
188
189int mdp_dsi_cmd_config(struct msm_panel_info *pinfo,
190 struct fbcon_config *fb)
191{
192
193 int ret = 0;
194 return ret;
195}
196
197int mdp_dsi_video_on(void)
198{
199 int ret = NO_ERROR;
200 writel(0x32048, MDP_CTL_0_FLUSH);
201 writel(0x01, MDP_INTF_1_TIMING_ENGINE_EN);
202 return ret;
203}
204
205int mdp_dsi_video_off()
206{
207 if(!target_cont_splash_screen())
208 {
209 writel(0x00000000, MDP_INTF_1_TIMING_ENGINE_EN);
210 mdelay(60);
211 /* Ping-Pong done Tear Check Read/Write */
212 /* Underrun(Interface 0/1/2/3) VSYNC Interrupt Enable */
213 writel(0xFF777713, MDP_INTR_CLEAR);
214 writel(0x00000000, MDP_INTR_EN);
215 }
216
217 return NO_ERROR;
218}
219
220int mdp_dsi_cmd_off()
221{
222 return NO_ERROR;
223}
224
225int mdp_dma_on(void)
226{
227 return NO_ERROR;
228}
229
230void mdp_disable(void)
231{
232
233}