blob: de04f2f82942b38ce1430742c47cd81aff714fbd [file] [log] [blame]
shuoy336dd012013-07-18 19:38:56 +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
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.
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 "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 <target/display.h>
38#include <platform/iomap.h>
39
40#define WVGA_MIPI_FB_WIDTH 480
41#define WVGA_MIPI_FB_HEIGHT 800
42
43#define HX8379A_PANEL_FRAME_RATE 60
44#define HX8379A_PANEL_NUM_OF_LANES 2
45#define HX8379A_PANEL_LANE_SWAP 1
46#define HX8379A_PANEL_T_CLK_PRE 0x41b
47#define HX8379A_PANEL_T_CLK_POST 0x0
48#define HX8379A_PANEL_BPP 24
49#define HX8379A_PANEL_CLK_RATE 499000000
50
51#define MIPI_HSYNC_PULSE_WIDTH 17
52#define MIPI_HSYNC_BACK_PORCH_DCLK 90
53#define MIPI_HSYNC_FRONT_PORCH_DCLK 90
54#define MIPI_VSYNC_PULSE_WIDTH 6
55#define MIPI_VSYNC_BACK_PORCH_LINES 10
56#define MIPI_VSYNC_FRONT_PORCH_LINES 15
57
58static char disp_on0[8] = {
59 0x04, 0x00, 0x39, 0xC0,
60 0xB9, 0xFF, 0x83, 0x79
61};
62static char disp_on1[4] = {
63 0xBA, 0x51, 0x23, 0x80,
64};
65static char disp_on2[8] = {
66 0x04, 0x00, 0x39, 0xC0,
67 0xDE, 0x05, 0x50, 0x04
68};
69static char disp_on3[24] = {
70 0x14, 0x00, 0x39, 0xC0,
71 0xB1, 0x00, 0x50, 0x44,
72 0xEA, 0x8D, 0x08, 0x11,
73 0x11, 0x11, 0x27, 0x2F,
74 0x9A, 0x1A, 0x42, 0x0B,
75 0x6E, 0xF1, 0x00, 0xE6
76};
77static char disp_on4[20] = {
78 0x0E, 0x00, 0x39, 0xC0,
79 0xB2, 0x00, 0x00, 0x3C,
80 0x08, 0x04, 0x19, 0x22,
81 0x00, 0xFF, 0x08, 0x04,
82 0x19, 0x20, 0xFF, 0xFF
83};
84static char disp_on5[36] = {
85 0x20, 0x00, 0x39, 0xC0,
86 0xB4, 0x82, 0x08, 0x00,
87 0x32, 0x10, 0x03, 0x32,
88 0x13, 0x70, 0x32, 0x10,
89 0x08, 0x37, 0x01, 0x28,
90 0x07, 0x37, 0x08, 0x3A,
91 0x08, 0x42, 0x42, 0x08,
92 0x00, 0x40, 0x08, 0x28,
93 0x08, 0x30, 0x30, 0x04
94};
95static char disp_on6[52] = {
96 0x30, 0x00, 0x39, 0xC0,
97 0xD5, 0x00, 0x00, 0x0A,
98 0x00, 0x01, 0x05, 0x00,
99 0x03, 0x00, 0x88, 0x88,
100 0x88, 0x88, 0x23, 0x01,
101 0x67, 0x45, 0x02, 0x13,
102 0x88, 0x88, 0x88, 0x88,
103 0x88, 0x88, 0x88, 0x88,
104 0x88, 0x88, 0x54, 0x76,
105 0x10, 0x32, 0x31, 0x20,
106 0x88, 0x88, 0x88, 0x88,
107 0x88, 0x88, 0x00, 0x00,
108 0x00, 0x00, 0x00, 0x00
109};
110static char disp_on7[40] = {
111 0x24, 0x00, 0x39, 0xC0,
112 0xE0, 0x79, 0x05, 0x0F,
113 0x14, 0x26, 0x29, 0x3F,
114 0x2B, 0x46, 0x04, 0x0E,
115 0x12, 0x15, 0x18, 0x16,
116 0x16, 0x11, 0x17, 0x05,
117 0x0F, 0x14, 0x26, 0x29,
118 0x3F, 0x2B, 0x46, 0x04,
119 0x0E, 0x12, 0x15, 0x18,
120 0x16, 0x16, 0x11, 0x17
121};
122static char disp_on8[4] = {
123 0xCC, 0x02, 0x23, 0x80,
124};
125static char disp_on9[12] = {
126 0x05, 0x00, 0x39, 0xC0,
127 0xB6, 0x00, 0x9C, 0x00,
128 0x9C, 0xFF, 0xFF, 0xFF
129};
130static char disp_on10[4] = {
131 0x11, 0x00, 0x05, 0x80
132};
133static char disp_on11[4] = {
134 0x29, 0x00, 0x05, 0x80
135};
136
137static struct mipi_dsi_cmd hx8379a_wvga_panel_video_mode_cmds[] = {
138 {sizeof(disp_on0), (char *)disp_on0},
139 {sizeof(disp_on1), (char *)disp_on1},
140 {sizeof(disp_on2), (char *)disp_on2},
141 {sizeof(disp_on3), (char *)disp_on3},
142 {sizeof(disp_on4), (char *)disp_on4},
143 {sizeof(disp_on5), (char *)disp_on5},
144 {sizeof(disp_on6), (char *)disp_on6},
145 {sizeof(disp_on7), (char *)disp_on7},
146 {sizeof(disp_on8), (char *)disp_on8},
147 {sizeof(disp_on9), (char *)disp_on9},
148 {sizeof(disp_on10), (char *)disp_on10},
149 {sizeof(disp_on11), (char *)disp_on11},
150};
151
152int mipi_hx8379a_video_wvga_config(void *pdata)
153{
154 int ret = NO_ERROR;
155 /* 2 Lanes -- Enables Data Lane0, 1 */
156 unsigned char lane_en = 3;
157 unsigned long low_pwr_stop_mode = 0;
158
159 /* Needed or else will have blank line at top of display */
160 unsigned char eof_bllp_pwr = 0x9;
161
162 unsigned char interleav = 0;
163 struct lcdc_panel_info *lcdc = NULL;
164 struct msm_panel_info *pinfo = (struct msm_panel_info *) pdata;
165
166 if (pinfo == NULL)
167 return ERR_INVALID_ARGS;
168
169 lcdc = &(pinfo->lcdc);
170 if (lcdc == NULL)
171 return ERR_INVALID_ARGS;
172
173 ret = mdss_dsi_video_mode_config((pinfo->xres),
174 (pinfo->yres),
175 (pinfo->xres),
176 (pinfo->yres),
177 (lcdc->h_front_porch),
178 (lcdc->h_back_porch),
179 (lcdc->v_front_porch),
180 (lcdc->v_back_porch),
181 (lcdc->h_pulse_width),
182 (lcdc->v_pulse_width),
183 pinfo->mipi.dst_format,
184 pinfo->mipi.traffic_mode,
185 lane_en,
186 low_pwr_stop_mode,
187 eof_bllp_pwr,
188 interleav,
189 MIPI_DSI0_BASE);
190 return ret;
191}
192
193int mipi_hx8379a_video_wvga_on()
194{
195 int ret = NO_ERROR;
196 return ret;
197}
198
199int mipi_hx8379a_video_wvga_off()
200{
201 int ret = NO_ERROR;
202 return ret;
203}
204
205static struct mdss_dsi_phy_ctrl dsi_video_mode_phy_db = {
206 /* regulator */
207 {0x02, 0x08, 0x05, 0x00, 0x20, 0x03},
208 /* timing */
209 {0x5d, 0x12, 0x0c, 0x00, 0x33, 0x39,
210 0x10, 0x16, 0x15, 0x03, 0x04, 0x00},
211 /* phy ctrl */
212 {0x7f, 0x00, 0x00, 0x00},
213 /* strength */
214 {0xff, 0x06},
215 /* bist */
216 {0x03, 0x03, 0x00, 0x00, 0x0f, 0x00},
217 /* lane config */
218 { 0x80, 0x45, 0x00, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00,
219 0x80, 0x45, 0x00, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00,
220 0x80, 0x45, 0x00, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00,
221 0x80, 0x45, 0x00, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00,
222 0x40, 0x67, 0x00, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00},
223};
224
225void mipi_hx8379a_video_wvga_init(struct msm_panel_info *pinfo)
226{
227 if (!pinfo)
228 return;
229
230 pinfo->xres = WVGA_MIPI_FB_WIDTH;
231 pinfo->yres = WVGA_MIPI_FB_HEIGHT;
232 pinfo->lcdc.h_back_porch = MIPI_HSYNC_BACK_PORCH_DCLK;
233 pinfo->lcdc.h_front_porch = MIPI_HSYNC_FRONT_PORCH_DCLK;
234 pinfo->lcdc.h_pulse_width = MIPI_HSYNC_PULSE_WIDTH;
235 pinfo->lcdc.v_back_porch = MIPI_VSYNC_BACK_PORCH_LINES;
236 pinfo->lcdc.v_front_porch = MIPI_VSYNC_FRONT_PORCH_LINES;
237 pinfo->lcdc.v_pulse_width = MIPI_VSYNC_PULSE_WIDTH;
238 pinfo->mipi.num_of_lanes = HX8379A_PANEL_NUM_OF_LANES;
239 pinfo->mipi.frame_rate = HX8379A_PANEL_FRAME_RATE;
240
241 pinfo->type = MIPI_VIDEO_PANEL;
242 pinfo->wait_cycle = 0;
243 pinfo->bpp = HX8379A_PANEL_BPP;
244 pinfo->clk_rate = HX8379A_PANEL_CLK_RATE;
245
246 pinfo->mipi.mode = DSI_VIDEO_MODE;
247 pinfo->mipi.traffic_mode = 2;
248 pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
249 pinfo->mipi.mdss_dsi_phy_db = &dsi_video_mode_phy_db;
250 pinfo->mipi.tx_eot_append = TRUE;
251
252 pinfo->mipi.lane_swap = HX8379A_PANEL_LANE_SWAP;
253 pinfo->mipi.t_clk_post = HX8379A_PANEL_T_CLK_POST;
254 pinfo->mipi.t_clk_pre = HX8379A_PANEL_T_CLK_PRE;
255 pinfo->mipi.panel_cmds = hx8379a_wvga_panel_video_mode_cmds;
256 pinfo->mipi.num_of_panel_cmds = ARRAY_SIZE(hx8379a_wvga_panel_video_mode_cmds);
257
258 pinfo->on = mipi_hx8379a_video_wvga_on;
259 pinfo->off = mipi_hx8379a_video_wvga_off;
260 pinfo->config = mipi_hx8379a_video_wvga_config;
261
262 return;
263};