Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | #ifndef BUILD_LK |
2 | #include <linux/string.h> | |
3 | #endif | |
4 | #ifdef BUILD_LK | |
5 | #include <platform/mt_gpio.h> | |
6 | #include <platform/mt_pmic.h> | |
7 | #include <debug.h> | |
8 | #include <platform/upmu_common.h> | |
9 | ||
10 | #elif (defined BUILD_UBOOT) | |
11 | #include <asm/arch/mt6577_gpio.h> | |
12 | #else | |
13 | #include <mach/mt_gpio.h> | |
14 | #include <linux/xlog.h> | |
15 | #include <mach/mt_pm_ldo.h> | |
16 | #endif | |
17 | #include "lcm_drv.h" | |
18 | #include "mt8193_lvds.h" | |
19 | ||
20 | // --------------------------------------------------------------------------- | |
21 | // Local Constants | |
22 | // --------------------------------------------------------------------------- | |
23 | ||
24 | #if defined(MTK_ALPS_BOX_SUPPORT) | |
25 | /*for 8127 box hdmi main path */ | |
26 | #define FRAME_WIDTH (1920) | |
27 | #define FRAME_HEIGHT (1080) | |
28 | #else | |
29 | #define FRAME_WIDTH (800) | |
30 | #define FRAME_HEIGHT (1280) | |
31 | #endif | |
32 | ||
33 | //#define GPIO_LCD_RST_EN GPIO90 | |
34 | //#define GPIO_LCD_STB_EN GPIO89 | |
35 | ||
36 | ||
37 | #ifdef GPIO_LCM_PWR | |
38 | #define GPIO_LCD_PWR GPIO_LCM_PWR | |
39 | #else | |
40 | #define GPIO_LCD_PWR 0xFFFFFFFF | |
41 | #endif | |
42 | ||
43 | #ifdef GPIO_LCM_PWR_EN | |
44 | #define GPIO_LCD_PWR_EN GPIO_LCM_PWR_EN | |
45 | #else | |
46 | #define GPIO_LCD_PWR_EN 0xFFFFFFFF | |
47 | #endif | |
48 | ||
49 | #ifdef GPIO_LCM_PWR2_EN | |
50 | #define GPIO_LCD_PWR2_EN GPIO_LCM_PWR2_EN | |
51 | #else | |
52 | #define GPIO_LCD_PWR2_EN 0xFFFFFFFF | |
53 | #endif | |
54 | ||
55 | ||
56 | #ifdef GPIO_LCM_RST | |
57 | #define GPIO_LCD_RST_EN GPIO_LCM_RST | |
58 | #else | |
59 | #define GPIO_LCD_RST_EN 0xFFFFFFFF | |
60 | #endif | |
61 | ||
62 | #ifdef GPIO_LCM_STB | |
63 | #define GPIO_LCD_STB_EN GPIO_LCM_STB | |
64 | #else | |
65 | #define GPIO_LCD_STB_EN 0xFFFFFFFF | |
66 | #endif | |
67 | ||
68 | ||
69 | #ifdef GPIO_LCM_LVL_SHIFT_EN | |
70 | #define GPIO_SHIFT_EN GPIO_LCM_LVL_SHIFT_EN | |
71 | #else | |
72 | #define GPIO_SHIFT_EN 0xFFFFFFFF | |
73 | #endif | |
74 | ||
75 | #ifdef GPIO_LCM_BL_EN | |
76 | #define GPIO_LCD_BL_EN GPIO_LCM_BL_EN | |
77 | #else | |
78 | #define GPIO_LCD_BL_EN 0xFFFFFFFF | |
79 | #endif | |
80 | ||
81 | ||
82 | #ifdef GPIO_LCM_BRIDGE_EN | |
83 | #define GPIO_LCD_BRIDGE_EN GPIO_LCM_BRIDGE_EN | |
84 | #else | |
85 | #define GPIO_LCD_BRIDGE_EN 0xFFFFFFFF | |
86 | #endif | |
87 | ||
88 | ||
89 | ||
90 | #define HSYNC_PULSE_WIDTH 16 | |
91 | #define HSYNC_BACK_PORCH 16 | |
92 | #define HSYNC_FRONT_PORCH 32 | |
93 | #define VSYNC_PULSE_WIDTH 2 | |
94 | #define VSYNC_BACK_PORCH 2 | |
95 | #define VSYNC_FRONT_PORCH 4 | |
96 | ||
97 | ||
98 | // --------------------------------------------------------------------------- | |
99 | // Local Variables | |
100 | // --------------------------------------------------------------------------- | |
101 | ||
102 | static LCM_UTIL_FUNCS lcm_util = {0}; | |
103 | ||
104 | #define SET_RESET_PIN(v) (mt_set_reset_pin((v))) | |
105 | ||
106 | #define UDELAY(n) | |
107 | #define MDELAY(n) | |
108 | ||
109 | ||
110 | // --------------------------------------------------------------------------- | |
111 | // Local Functions | |
112 | // --------------------------------------------------------------------------- | |
113 | ||
114 | static __inline void send_ctrl_cmd(unsigned int cmd) | |
115 | { | |
116 | ||
117 | } | |
118 | ||
119 | static __inline void send_data_cmd(unsigned int data) | |
120 | { | |
121 | ||
122 | } | |
123 | ||
124 | static __inline void set_lcm_register(unsigned int regIndex, | |
125 | unsigned int regData) | |
126 | { | |
127 | ||
128 | } | |
129 | ||
130 | ||
131 | static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output) | |
132 | { | |
133 | ||
134 | if(GPIO == 0xFFFFFFFF) | |
135 | { | |
136 | #ifdef BUILD_LK | |
137 | printf("[LK/LCM] GPIO_LCD_PWR = 0x%x \n",GPIO_LCD_PWR); | |
138 | printf("[LK/LCM] GPIO_LCD_PWR_EN = 0x%x\n",GPIO_LCD_PWR_EN); | |
139 | printf("[LK/LCM] GPIO_LCD_PWR2_EN = 0x%x \n",GPIO_LCD_PWR2_EN); | |
140 | printf("[LK/LCM] GPIO_LCD_RST_EN = 0x%x \n",GPIO_LCD_RST_EN); | |
141 | printf("[LK/LCM] GPIO_LCD_STB_EN = 0x%x\n",GPIO_LCD_STB_EN); | |
142 | printf("[LK/LCM] GPIO_SHIFT_EN = 0x%x\n",GPIO_SHIFT_EN); | |
143 | printf("[LK/LCM] GPIO_LCD_BL_EN = 0x%x\n",GPIO_LCD_BL_EN); | |
144 | printf("[LK/LCM] GPIO_LCD_BRIDGE_EN = 0x%x \n",GPIO_LCD_BRIDGE_EN); | |
145 | ||
146 | #elif (defined BUILD_UBOOT) | |
147 | // do nothing in uboot | |
148 | #else | |
149 | //printf("kernel] lcm_set gpio() \n"); | |
150 | #endif | |
151 | return; | |
152 | } | |
153 | ||
154 | mt_set_gpio_mode(GPIO, GPIO_MODE_00); | |
155 | mt_set_gpio_dir(GPIO, GPIO_DIR_OUT); | |
156 | mt_set_gpio_out(GPIO, (output>0)? GPIO_OUT_ONE: GPIO_OUT_ZERO); | |
157 | } | |
158 | ||
159 | ||
160 | // --------------------------------------------------------------------------- | |
161 | // LCM Driver Implementations | |
162 | // --------------------------------------------------------------------------- | |
163 | ||
164 | static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util) | |
165 | { | |
166 | memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS)); | |
167 | } | |
168 | ||
169 | static void lcm_get_params(LCM_PARAMS *params) | |
170 | { | |
171 | memset(params, 0, sizeof(LCM_PARAMS)); | |
172 | ||
173 | params->type = LCM_TYPE_DPI; | |
174 | params->ctrl = LCM_CTRL_SERIAL_DBI; | |
175 | params->width = FRAME_WIDTH; | |
176 | params->height = FRAME_HEIGHT; | |
177 | params->io_select_mode = 0; | |
178 | ||
179 | params->dpi.PLL_CLOCK = 67; //67MHz | |
180 | ||
181 | ||
182 | /* RGB interface configurations */ | |
183 | params->dpi.mipi_pll_clk_ref = 0; | |
184 | params->dpi.mipi_pll_clk_div1 = 0x80000101; //lvds pll 65M | |
185 | params->dpi.mipi_pll_clk_div2 = 0x800a0000; | |
186 | //params->dpi.dpi_clk_div = 2; | |
187 | //params->dpi.dpi_clk_duty = 1; | |
188 | ||
189 | params->dpi.clk_pol = LCM_POLARITY_FALLING; | |
190 | params->dpi.de_pol = LCM_POLARITY_RISING; | |
191 | params->dpi.vsync_pol = LCM_POLARITY_FALLING; | |
192 | params->dpi.hsync_pol = LCM_POLARITY_FALLING; | |
193 | ||
194 | params->dpi.hsync_pulse_width = HSYNC_PULSE_WIDTH; | |
195 | params->dpi.hsync_back_porch = HSYNC_BACK_PORCH; | |
196 | params->dpi.hsync_front_porch = HSYNC_FRONT_PORCH; | |
197 | params->dpi.vsync_pulse_width = VSYNC_PULSE_WIDTH; | |
198 | params->dpi.vsync_back_porch = VSYNC_BACK_PORCH; | |
199 | params->dpi.vsync_front_porch = VSYNC_FRONT_PORCH; | |
200 | ||
201 | ||
202 | //params->dpi.i2x_en = 1; | |
203 | params->dpi.lvds_tx_en = 1; | |
204 | params->dpi.ssc_disable = 1; | |
205 | params->dpi.format = LCM_DPI_FORMAT_RGB888; // format is 24 bit | |
206 | params->dpi.rgb_order = LCM_COLOR_ORDER_RGB; | |
207 | params->dpi.is_serial_output = 0; | |
208 | ||
209 | params->dpi.intermediat_buffer_num = 0; | |
210 | ||
211 | params->dpi.io_driving_current = LCM_DRIVING_CURRENT_2MA; | |
212 | } | |
213 | ||
214 | ||
215 | static void lcm_init(void) | |
216 | { | |
217 | #ifdef BUILD_LK | |
218 | printf("[LK/LCM] lcm_init() enter\n"); | |
219 | ||
220 | lcm_set_gpio_output(GPIO_LCD_PWR, 1); | |
221 | lcm_set_gpio_output(GPIO_LCD_PWR_EN, 0); | |
222 | lcm_set_gpio_output(GPIO_LCD_PWR2_EN, 1); | |
223 | ||
224 | //VGP6 3.3V | |
225 | //pmic_config_interface(0x424, 0x1, 0x1, 15); | |
226 | //pmic_config_interface(0x45a, 0x07, 0x07, 5); | |
227 | ||
228 | #ifdef CONFIG_MTK_PMIC_MT6397 | |
229 | upmu_set_rg_vgp6_vosel(0x7); | |
230 | upmu_set_rg_vgp6_sw_en(0x1); | |
231 | #else | |
232 | upmu_set_rg_vgp1_vosel(0x7); | |
233 | upmu_set_rg_vgp1_en(0x1); | |
234 | #endif | |
235 | //hwPowerOn(MT65XX_POWER_LDO_VGP6, VOL_3300, "LCM"); | |
236 | ||
237 | lcm_set_gpio_output(GPIO_LCD_RST_EN,GPIO_OUT_ONE); | |
238 | ||
239 | MDELAY(20); | |
240 | ||
241 | lcm_set_gpio_output(GPIO_LCD_STB_EN,GPIO_OUT_ONE); | |
242 | ||
243 | MDELAY(20); | |
244 | ||
245 | lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ONE); | |
246 | ||
247 | ||
248 | #elif (defined BUILD_UBOOT) | |
249 | // do nothing in uboot | |
250 | #else | |
251 | printk("[LCM] lcm_init() enter\n"); | |
252 | ||
253 | lcm_set_gpio_output(GPIO_LCD_RST_EN,GPIO_OUT_ONE); | |
254 | ||
255 | ||
256 | MDELAY(20); | |
257 | ||
258 | lcm_set_gpio_output(GPIO_LCD_STB_EN,GPIO_OUT_ONE); | |
259 | ||
260 | ||
261 | MDELAY(20); | |
262 | ||
263 | lcm_set_gpio_output(GPIO_LCD_BL_EN, GPIO_OUT_ONE); | |
264 | ||
265 | ||
266 | #endif | |
267 | ||
268 | } | |
269 | ||
270 | ||
271 | static void lcm_suspend(void) | |
272 | { | |
273 | #ifdef BUILD_LK | |
274 | printf("[LK/LCM] lcm_suspend() enter\n"); | |
275 | ||
276 | lcm_set_gpio_output(GPIO_LCD_BL_EN, 0); | |
277 | MDELAY(20); | |
278 | ||
279 | ||
280 | ||
281 | lcm_set_gpio_output(GPIO_LCD_RST_EN,GPIO_OUT_ZERO); | |
282 | lcm_set_gpio_output(GPIO_LCD_STB_EN,GPIO_OUT_ZERO); | |
283 | ||
284 | lcm_set_gpio_output(GPIO_LCD_PWR, 0); | |
285 | lcm_set_gpio_output(GPIO_LCD_PWR_EN, 0); | |
286 | lcm_set_gpio_output(GPIO_LCD_PWR2_EN, 0); | |
287 | ||
288 | ||
289 | MDELAY(20); | |
290 | ||
291 | #elif (defined BUILD_UBOOT) | |
292 | // do nothing in uboot | |
293 | #else | |
294 | printk("[LCM] lcm_suspend() enter\n"); | |
295 | ||
296 | lcm_set_gpio_output(GPIO_LCD_BL_EN, 0); | |
297 | ||
298 | MDELAY(20); | |
299 | ||
300 | lcm_set_gpio_output(GPIO_LCD_RST_EN,GPIO_OUT_ZERO); | |
301 | lcm_set_gpio_output(GPIO_LCD_STB_EN,GPIO_OUT_ZERO); | |
302 | ||
303 | lcm_set_gpio_output(GPIO_LCD_PWR, 0); | |
304 | lcm_set_gpio_output(GPIO_LCD_PWR_EN, 0); | |
305 | lcm_set_gpio_output(GPIO_LCD_PWR2_EN, 0); | |
306 | ||
307 | MDELAY(20); | |
308 | #ifdef CONFIG_MTK_PMIC_MT6397 | |
309 | hwPowerDown(MT65XX_POWER_LDO_VGP6, "LCM");// | |
310 | #else | |
311 | hwPowerDown(MT6323_POWER_LDO_VGP1, "LCM");// | |
312 | #endif | |
313 | ||
314 | MDELAY(20); | |
315 | ||
316 | #endif | |
317 | ||
318 | } | |
319 | ||
320 | ||
321 | static void lcm_resume(void) | |
322 | { | |
323 | #ifdef BUILD_LK | |
324 | printf("[LK/LCM] lcm_resume() enter\n"); | |
325 | //VGP6 3.3V | |
326 | ||
327 | #ifdef CONFIG_MTK_PMIC_MT6397 | |
328 | upmu_set_rg_vgp6_vosel(0x7); | |
329 | upmu_set_rg_vgp6_sw_en(0x1); | |
330 | #else | |
331 | upmu_set_rg_vgp1_vosel(0x7); | |
332 | upmu_set_rg_vgp1_en(0x1); | |
333 | #endif | |
334 | //pmic_config_interface(0x424, 0x1, 0x1, 15); | |
335 | //pmic_config_interface(0x45a, 0x07, 0x07, 5); | |
336 | ||
337 | // hwPowerOn(MT65XX_POWER_LDO_VGP6, VOL_3300, "LCM"); | |
338 | ||
339 | lcm_set_gpio_output(GPIO_LCD_STB_EN,GPIO_OUT_ONE); | |
340 | MDELAY(20); | |
341 | ||
342 | lcm_set_gpio_output(GPIO_LCD_PWR, 1); | |
343 | lcm_set_gpio_output(GPIO_LCD_PWR_EN, 1); | |
344 | lcm_set_gpio_output(GPIO_LCD_PWR2_EN, 1); | |
345 | ||
346 | MDELAY(5); | |
347 | ||
348 | ||
349 | lcm_set_gpio_output(GPIO_LCD_RST_EN,GPIO_OUT_ONE); | |
350 | MDELAY(20); | |
351 | ||
352 | lcm_set_gpio_output(GPIO_LCD_BL_EN, 1); | |
353 | ||
354 | #elif (defined BUILD_UBOOT) | |
355 | // do nothing in uboot | |
356 | #else | |
357 | printk("[LCM] lcm_resume() enter\n"); | |
358 | ||
359 | #ifdef CONFIG_MTK_PMIC_MT6397 | |
360 | hwPowerOn(MT65XX_POWER_LDO_VGP6, VOL_3300, "LCM"); | |
361 | #else | |
362 | hwPowerOn(MT6323_POWER_LDO_VGP1, VOL_3300, "LCM"); | |
363 | #endif | |
364 | lcm_set_gpio_output(GPIO_LCD_PWR, 1); | |
365 | lcm_set_gpio_output(GPIO_LCD_PWR_EN, 1); | |
366 | lcm_set_gpio_output(GPIO_LCD_PWR2_EN, 1); | |
367 | ||
368 | MDELAY(5); | |
369 | ||
370 | lcm_set_gpio_output(GPIO_LCD_STB_EN, 1); | |
371 | MDELAY(5); | |
372 | lcm_set_gpio_output(GPIO_LCD_RST_EN, 1); | |
373 | MDELAY(20); | |
374 | ||
375 | ||
376 | lcm_set_gpio_output(GPIO_LCD_BL_EN, 1); | |
377 | ||
378 | #endif | |
379 | ||
380 | } | |
381 | ||
382 | LCM_DRIVER cpt_clap070wp03xg_lvds_lcm_drv = | |
383 | { | |
384 | .name = "cpt_clap070wp03xg_lvds", | |
385 | .set_util_funcs = lcm_set_util_funcs, | |
386 | .get_params = lcm_get_params, | |
387 | .init = lcm_init, | |
388 | .suspend = lcm_suspend, | |
389 | .resume = lcm_resume, | |
390 | }; | |
391 |