blob: 3ddbed4d7891372f5e428b07b55f23ad9c53d743 [file] [log] [blame]
Duy Truongf3ac7b32013-02-13 01:07:28 -08001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
Channagoud Kadabi539ef722012-03-29 16:02:50 +05302 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * 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
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
Duy Truongf3ac7b32013-02-13 01:07:28 -080012 * * Neither the name of The Linux Foundation nor the names of its
Channagoud Kadabi539ef722012-03-29 16:02:50 +053013 * 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 "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include <stdint.h>
31#include <msm_panel.h>
32#include <mipi_dsi.h>
33#include <sys/types.h>
34#include <err.h>
35#include <reg.h>
36#include <debug.h>
37#include <platform/iomap.h>
38#include <target/display.h>
39#include <dev/gpio.h>
40
41
42/* MIPI NT35510 panel commands */
43static char exit_sleep[4] = {0x11, 0x00, 0x09, 0x80};
44static char display_on[4] = {0x29, 0x00, 0x05, 0x80};
45
46static char video0[12] = {
47 0x06, 0x00, 0x29, 0xc0, 0xF0, 0x55, 0xAA, 0x52,
48 0x08, 0x01, 0xff, 0xff,
49};
50static char video1[8] = {
51 0x04, 0x00, 0x29, 0xc0, 0xBC, 0x00, 0xA0, 0x00,
52};
53static char video2[8] = {
54 0x04, 0x00, 0x29, 0xc0, 0xBD, 0x00, 0xA0, 0x00,
55};
56static char video3[8] = {
57 0x03, 0x00, 0x29, 0xc0, 0xBE, 0x00, 0x79, 0xff,
58};
59static char video4[60] = {
60 0x35, 0x00, 0x29, 0xc0, 0xD1, 0x00, 0x00, 0x00,
61 0x14, 0x00, 0x32, 0x00,
62 0x4F, 0x00, 0x65, 0x00,
63 0x8B, 0x00, 0xA8, 0x00,
64 0xD5, 0x00, 0xF7, 0x01,
65 0x2B, 0x01, 0x54, 0x01,
66 0x8E, 0x01, 0xBB, 0x01,
67 0xBC, 0x01, 0xE3, 0x02,
68 0x08, 0x02, 0x1C, 0x02,
69 0x39, 0x02, 0x4F, 0x02,
70 0x76, 0x02, 0xA3, 0x02,
71 0xE3, 0x03, 0x12, 0x03,
72 0x4C, 0x03, 0x66, 0x03,
73 0x9A, 0xff, 0xff, 0xff,
74};
75static char video5[60] = {
76 0x35, 0x00, 0x29, 0xc0, 0xD2, 0x00, 0x00, 0x00,
77 0x14, 0x00, 0x32, 0x00,
78 0x4F, 0x00, 0x65, 0x00,
79 0x8B, 0x00, 0xA8, 0x00,
80 0xD5, 0x00, 0xF7, 0x01,
81 0x2B, 0x01, 0x54, 0x01,
82 0x8E, 0x01, 0xBB, 0x01,
83 0xBC, 0x01, 0xE3, 0x02,
84 0x08, 0x02, 0x1C, 0x02,
85 0x39, 0x02, 0x4F, 0x02,
86 0x76, 0x02, 0xA3, 0x02,
87 0xE3, 0x03, 0x12, 0x03,
88 0x4C, 0x03, 0x66, 0x03,
89 0x9A, 0xff, 0xff, 0xff
90};
91static char video6[60] = {
92 0x35, 0x00, 0x29, 0xc0, 0xD3, 0x00, 0x00, 0x00,
93 0x14, 0x00, 0x32, 0x00,
94 0x4F, 0x00, 0x65, 0x00,
95 0x8B, 0x00, 0xA8, 0x00,
96 0xD5, 0x00, 0xF7, 0x01,
97 0x2B, 0x01, 0x54, 0x01,
98 0x8E, 0x01, 0xBB, 0x01,
99 0xBC, 0x01, 0xE3, 0x02,
100 0x08, 0x02, 0x1C, 0x02,
101 0x39, 0x02, 0x4F, 0x02,
102 0x76, 0x02, 0xA3, 0x02,
103 0xE3, 0x03, 0x12, 0x03,
104 0x4C, 0x03, 0x66, 0x03,
105 0x9A, 0xff, 0xff, 0xff,
106};
107static char video7[60] = {
108 0x35, 0x00, 0x29, 0xc0, 0xD4, 0x00, 0x00, 0x00,
109 0x14, 0x00, 0x32, 0x00,
110 0x4F, 0x00, 0x65, 0x00,
111 0x8B, 0x00, 0xA8, 0x00,
112 0xD5, 0x00, 0xF7, 0x01,
113 0x2B, 0x01, 0x54, 0x01,
114 0x8E, 0x01, 0xBB, 0x01,
115 0xBC, 0x01, 0xE3, 0x02,
116 0x08, 0x02, 0x1C, 0x02,
117 0x39, 0x02, 0x4F, 0x02,
118 0x76, 0x02, 0xA3, 0x02,
119 0xE3, 0x03, 0x12, 0x03,
120 0x4C, 0x03, 0x66, 0x03,
121 0x9A, 0xff, 0xff, 0xff,
122};
123static char video8[60] = {
124 0x35, 0x00, 0x29, 0xc0, 0xD5, 0x00, 0x00, 0x00,
125 0x14, 0x00, 0x32, 0x00,
126 0x4F, 0x00, 0x65, 0x00,
127 0x8B, 0x00, 0xA8, 0x00,
128 0xD5, 0x00, 0xF7, 0x01,
129 0x2B, 0x01, 0x54, 0x01,
130 0x8E, 0x01, 0xBB, 0x01,
131 0xBC, 0x01, 0xE3, 0x02,
132 0x08, 0x02, 0x1C, 0x02,
133 0x39, 0x02, 0x4F, 0x02,
134 0x76, 0x02, 0xA3, 0x02,
135 0xE3, 0x03, 0x12, 0x03,
136 0x4C, 0x03, 0x66, 0x03,
137 0x9A, 0xff, 0xff, 0xff,
138};
139static char video9[60] = {
140 0x35, 0x00, 0x29, 0xc0, 0xD6, 0x00, 0x00, 0x00,
141 0x14, 0x00, 0x32, 0x00,
142 0x4F, 0x00, 0x65, 0x00,
143 0x8B, 0x00, 0xA8, 0x00,
144 0xD5, 0x00, 0xF7, 0x01,
145 0x2B, 0x01, 0x54, 0x01,
146 0x8E, 0x01, 0xBB, 0x01,
147 0xBC, 0x01, 0xE3, 0x02,
148 0x08, 0x02, 0x1C, 0x02,
149 0x39, 0x02, 0x4F, 0x02,
150 0x76, 0x02, 0xA3, 0x02,
151 0xE3, 0x03, 0x12, 0x03,
152 0x4C, 0x03, 0x66, 0x03,
153 0x9A, 0xff, 0xff, 0xff,
154};
155static char video10[8] = {
156 0x04, 0x00, 0x29, 0xc0, 0xB0, 0x0A, 0x0A, 0x0A,
157};
158static char video11[8] = {
159 0x04, 0x00, 0x29, 0xc0, 0xB1, 0x0A, 0x0A, 0x0A,
160};
161static char video12[8] = {
162 0x04, 0x00, 0x29, 0xc0, 0xBA, 0x24, 0x24, 0x24,
163};
164static char video13[8] = {
165 0x04, 0x00, 0x29, 0xc0, 0xB9, 0x24, 0x24, 0x24,
166};
167static char video14[8] = {
168 0x04, 0x00, 0x29, 0xc0, 0xB8, 0x24, 0x24, 0x24,
169};
170static char video15[12] = {
171 0x06, 0x00, 0x29, 0xc0, 0xF0, 0x55, 0xAA, 0x52,
172 0x08, 0x00, 0xff, 0xff,
173};
174static char video16[8] = {
175 0x02, 0x00, 0x29, 0xc0, 0xB3, 0x00, 0xff, 0xff,
176};
177static char video17[8] = {
178 0x02, 0x00, 0x29, 0xc0, 0xB4, 0x10, 0xff, 0xff,
179};
180static char video18[8] = {
181 0x02, 0x00, 0x29, 0xc0, 0xB6, 0x02, 0xff, 0xff,
182};
183static char video19[8] = {
184 0x03, 0x00, 0x29, 0xc0, 0xB1, 0xFC, 0x00, 0xff,
185};
Padmanabhan Komanduru6ec00332012-09-22 15:48:43 +0530186static char video19_rotate[8] = {
187 0x03, 0x00, 0x29, 0xc0, 0xB1, 0xFC, 0x06, 0xff,
188};
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530189static char video20[8] = {
190 0x04, 0x00, 0x29, 0xc0, 0xBC, 0x05, 0x05, 0x05,
191};
192static char video21[8] = {
193 0x03, 0x00, 0x29, 0xc0, 0xB7, 0x20, 0x20, 0xff,
194};
195
196static char video22[12] = {
197 0x05, 0x00, 0x29, 0xc0, 0xB8, 0x01, 0x03, 0x03,
198 0x03, 0xff, 0xff, 0xff,
199};
200static char video23[24] = {
201 0x13, 0x00, 0x29, 0xc0, 0xC8, 0x01, 0x00, 0x78,
202 0x50, 0x78, 0x50, 0x78,
203 0x50, 0x78, 0x50, 0xC8,
204 0x3C, 0x3C, 0xC8, 0xC8,
205 0x3C, 0x3C, 0xC8, 0xff,
206};
207static char video24[12] = {
208 0x06, 0x00, 0x29, 0xc0, 0xBD, 0x01, 0x84, 0x07,
209 0x31, 0x00, 0xff, 0xff,
210};
211static char video25[12] = {
212 0x06, 0x00, 0x29, 0xc0, 0xBE, 0x01, 0x84, 0x07,
213 0x31, 0x00, 0xff, 0xff,
214};
215static char video26[12] = {
216 0x06, 0x00, 0x29, 0xc0, 0xBF, 0x01, 0x84, 0x07,
217 0x31, 0x00, 0xff, 0xff
218};
219static char video27[8] = {
220 0x02, 0x00, 0x29, 0xc0, 0x35, 0x00, 0xff, 0xff,
221};
222
223static struct mipi_dsi_cmd nt35510_panel_video_mode_cmds[] = {
224 {sizeof(video0), video0},
225 {sizeof(video1), video1},
226 {sizeof(video2), video2},
227 {sizeof(video3), video3},
228 {sizeof(video4), video4},
229 {sizeof(video5), video5},
230 {sizeof(video6), video6},
231 {sizeof(video7), video7},
232 {sizeof(video8), video8},
233 {sizeof(video9), video9},
234 {sizeof(video10), video10},
235 {sizeof(video11), video11},
236 {sizeof(video12), video12},
237 {sizeof(video13), video13},
238 {sizeof(video14), video14},
239 {sizeof(video15), video15},
240 {sizeof(video16), video16},
241 {sizeof(video17), video17},
242 {sizeof(video18), video18},
243 {sizeof(video19), video19},
244 {sizeof(video20), video20},
245 {sizeof(video21), video21},
246 {sizeof(video22), video22},
247 {sizeof(video23), video23},
248 {sizeof(video24), video24},
249 {sizeof(video25), video25},
250 {sizeof(video26), video26},
251 {sizeof(video27), video27},
252 {sizeof(exit_sleep), exit_sleep},
253 {sizeof(display_on), display_on},
254};
255
Padmanabhan Komanduru6ec00332012-09-22 15:48:43 +0530256static struct mipi_dsi_cmd nt35510_video_rotate_cmds[] = {
257 {sizeof(video19_rotate), video19_rotate},
258};
259
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530260int mipi_nt35510_video_wvga_config(void *pdata)
261{
262 int ret = NO_ERROR;
263 /* 3 Lanes -- Enables Data Lane0, 1, 2 */
264 unsigned char lane_en = 3;
265 unsigned long low_pwr_stop_mode = 1;
266
267 /* Needed or else will have blank line at top of display */
268 unsigned char eof_bllp_pwr = 0x9;
269
270 unsigned char interleav = 0;
271 struct lcdc_panel_info *lcdc = NULL;
272 struct msm_panel_info *pinfo = (struct msm_panel_info *) pdata;
273
274 if (pinfo == NULL)
275 return ERR_INVALID_ARGS;
276
277 lcdc = &(pinfo->lcdc);
278 if (lcdc == NULL)
279 return ERR_INVALID_ARGS;
280
281 ret = mipi_dsi_video_mode_config((pinfo->xres),
282 (pinfo->yres),
283 (pinfo->xres),
284 (pinfo->yres),
285 (lcdc->h_front_porch),
286 (lcdc->h_back_porch),
287 (lcdc->v_front_porch),
288 (lcdc->v_back_porch),
289 (lcdc->h_pulse_width),
290 (lcdc->v_pulse_width),
291 pinfo->mipi.dst_format,
292 pinfo->mipi.traffic_mode,
293 lane_en,
294 low_pwr_stop_mode,
295 eof_bllp_pwr,
296 interleav);
297 return ret;
298}
299
300int mipi_nt35510_video_wvga_on()
301{
302 int ret = NO_ERROR;
303 return ret;
304}
305
306int mipi_nt35510_video_wvga_off()
307{
308 int ret = NO_ERROR;
309 return ret;
310}
311
Padmanabhan Komanduru6ec00332012-09-22 15:48:43 +0530312int mipi_nt35510_video_wvga_rotate()
313{
314 int ret = NO_ERROR;
315
316 ret = mipi_dsi_cmds_tx(nt35510_video_rotate_cmds, ARRAY_SIZE(nt35510_video_rotate_cmds));
317
318 return ret;
319}
320
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530321static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = {
322 /* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
323 {0x03, 0x01, 0x01, 0x00}, /* regulator */
324 /* timing */
325 {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22,
326 0x90, 0x18, 0x03, 0x04},
327 {0x7f, 0x00, 0x00, 0x00}, /* phy ctrl */
328 {0xbb, 0x02, 0x06, 0x00}, /* strength */
329 /* pll control */
330 {0x00, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62,
331 0x01, 0x0f, 0x07, /* --> Two lane configuration */
332 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0},
333};
334
335void mipi_nt35510_video_wvga_init(struct msm_panel_info *pinfo)
336{
337 if (!pinfo)
338 return;
339
340 pinfo->xres = NT35510_MIPI_FB_WIDTH;
341 pinfo->yres = NT35510_MIPI_FB_HEIGHT;
342 pinfo->lcdc.h_back_porch = MIPI_HSYNC_BACK_PORCH_DCLK;
343 pinfo->lcdc.h_front_porch = MIPI_HSYNC_FRONT_PORCH_DCLK;
344 pinfo->lcdc.h_pulse_width = MIPI_HSYNC_PULSE_WIDTH;
345 pinfo->lcdc.v_back_porch = MIPI_VSYNC_BACK_PORCH_LINES;
346 pinfo->lcdc.v_front_porch = MIPI_VSYNC_FRONT_PORCH_LINES;
347 pinfo->lcdc.v_pulse_width = MIPI_VSYNC_PULSE_WIDTH;
348 pinfo->mipi.num_of_lanes = 2;
349
350 pinfo->type = MIPI_VIDEO_PANEL;
351 pinfo->wait_cycle = 0;
352 pinfo->bpp = 24;
Channagoud Kadabiebbca342012-06-29 18:14:31 +0530353 pinfo->clk_rate = 499000000;
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530354
355 pinfo->mipi.mode = DSI_VIDEO_MODE;
356 pinfo->mipi.traffic_mode = 2;
357 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
358 pinfo->mipi.dsi_phy_db = &dsi_video_mode_phy_db;
359 pinfo->mipi.tx_eot_append = TRUE;
360
361 pinfo->mipi.lane_swap = 1;
362 pinfo->mipi.panel_cmds = nt35510_panel_video_mode_cmds;
363 pinfo->mipi.num_of_panel_cmds = \
364 ARRAY_SIZE(nt35510_panel_video_mode_cmds);
365
366 pinfo->on = mipi_nt35510_video_wvga_on;
367 pinfo->off = mipi_nt35510_video_wvga_off;
368 pinfo->config = mipi_nt35510_video_wvga_config;
Padmanabhan Komanduru6ec00332012-09-22 15:48:43 +0530369 pinfo->rotate = mipi_nt35510_video_wvga_rotate;
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530370
371 return;
372}