6 /* =============================================== */
8 * change u-boot macro to celinux macro
12 #if defined(CONFIG_JZ4730)
13 #define CONFIG_MIPS_JZ4730 1
15 #if defined(CONFIG_JZ4740)
16 #define CONFIG_MIPS_JZ4740 1
18 #if defined(CONFIG_JZ5730)
19 #define CONFIG_MIPS_JZ5730 1
23 #if defined(CONFIG_LIBRA)
24 #define CONFIG_MIPS_JZ4730_LIBRA 1
26 #if defined(CONFIG_PMPV1)
27 #define CONFIG_MIPS_JZ4730_PMPV1 1
29 #if defined(CONFIG_PMPV2)
30 #define CONFIG_MIPS_JZ4730_PMPV2 1
32 #if defined(CONFIG_GPS)
33 #define CONFIG_MIPS_JZ4730_GPS 1
35 #if defined(CONFIG_FPRINT)
36 #define CONFIG_MIPS_JZ4730_FPRINT 1
38 #if defined(CONFIG_LEO)
39 #define CONFIG_MIPS_JZ4740_LEO 1
41 #if defined(CONFIG_PAVO)
42 #define CONFIG_MIPS_JZ4740_PAVO 1
44 #if defined(CONFIG_VIRGO)
45 #define CONFIG_MIPS_JZ4740_VIRGO 1
48 #define mdelay(n) udelay((n)*1000)
51 * change u-boot macro to celinux macro
53 /* =============================================== */
55 #define NR_PALETTE 256
58 unsigned int next_desc
; /* LCDDAx */
59 unsigned int databuf
; /* LCDSAx */
60 unsigned int frame_id
; /* LCDFIDx */
61 unsigned int cmd
; /* LCDCMDx */
64 #define MODE_MASK 0x0f
65 #define MODE_TFT_GEN 0x00
66 #define MODE_TFT_SHARP 0x01
67 #define MODE_TFT_CASIO 0x02
68 #define MODE_TFT_SAMSUNG 0x03
69 #define MODE_CCIR656_NONINT 0x04
70 #define MODE_CCIR656_INT 0x05
71 #define MODE_STN_COLOR_SINGLE 0x08
72 #define MODE_STN_MONO_SINGLE 0x09
73 #define MODE_STN_COLOR_DUAL 0x0a
74 #define MODE_STN_MONO_DUAL 0x0b
75 #define MODE_8BIT_SERIAL_TFT 0x0c
77 #define MODE_TFT_18BIT (1<<7)
79 #define STN_DAT_PIN1 (0x00 << 4)
80 #define STN_DAT_PIN2 (0x01 << 4)
81 #define STN_DAT_PIN4 (0x02 << 4)
82 #define STN_DAT_PIN8 (0x03 << 4)
83 #define STN_DAT_PINMASK STN_DAT_PIN8
85 #define STFT_PSHI (1 << 15)
86 #define STFT_CLSHI (1 << 14)
87 #define STFT_SPLHI (1 << 13)
88 #define STFT_REVHI (1 << 12)
90 #define SYNC_MASTER (0 << 16)
91 #define SYNC_SLAVE (1 << 16)
96 #define PCLK_P (0 << 10)
97 #define PCLK_N (1 << 10)
99 #define HSYNC_P (0 << 11)
100 #define HSYNC_N (1 << 11)
102 #define VSYNC_P (0 << 8)
103 #define VSYNC_N (1 << 8)
105 #define DATA_NORMAL (0 << 17)
106 #define DATA_INVERSE (1 << 17)
109 /* Jz LCDFB supported I/O controls. */
110 #define FBIOSETBACKLIGHT 0x4688
111 #define FBIODISPON 0x4689
112 #define FBIODISPOFF 0x468a
113 #define FBIORESET 0x468b
114 #define FBIOPRINT_REG 0x468c
117 * LCD panel specific definition
120 #if defined(CONFIG_JZLCD_TRULY_TFTG320240DTSW) || defined(CONFIG_JZLCD_TRULY_TFTG320240DTSW_SERIAL)
122 #if defined(CONFIG_MIPS_JZ4730_PMPV1)
123 #define LCD_RESET_PIN 63
124 #elif defined(CONFIG_MIPS_JZ4730_PMPV2)
125 #define LCD_RESET_PIN 60
126 #elif defined(CONFIG_MIPS_JZ4740_LEO)
127 #define LCD_RESET_PIN 50
130 #define __lcd_special_on() \
132 __gpio_set_pin(LCD_RESET_PIN); \
133 __gpio_as_output(LCD_RESET_PIN); \
134 __gpio_clear_pin(LCD_RESET_PIN); \
136 __gpio_set_pin(LCD_RESET_PIN); \
139 #endif /* CONFIG_JZLCD_TRULY_TFTG320240DTSW, parellel or serial RGB mode */
141 #if defined(CONFIG_JZLCD_SAMSUNG_LTV350QVF04)
143 #if defined(CONFIG_MIPS_JZ4730_FPRINT)
151 #if defined(CONFIG_MIPS_JZ4730_GPS)
175 #define __lcd_special_pin_init() \
177 __gpio_as_output(PortSDI); /* SDI */\
178 __gpio_as_output(PortSCL); /* SCL */ \
179 __gpio_as_output(PortCS); /* CS */ \
180 __gpio_as_output(PortRST); /* Reset */ \
181 __gpio_as_output(PortSht); /* Shut Down # */ \
182 __gpio_set_pin(PortCS); \
183 __gpio_set_pin(PortSCL); \
184 __gpio_set_pin(PortSDI); \
187 #define __spi_out(val) \
190 unsigned int _t_ = (val); \
191 __gpio_clear_pin(PortCS); \
193 for (__i__ = 0; __i__ < 24; __i__++ ) { \
194 __gpio_clear_pin(PortSCL); \
195 if (_t_ & 0x800000) \
196 __gpio_set_pin(PortSDI); \
198 __gpio_clear_pin(PortSDI); \
201 __gpio_set_pin(PortSCL); \
204 __gpio_set_pin(PortCS); \
206 __gpio_set_pin(PortSDI); \
208 __gpio_set_pin(PortSCL); \
211 #define __spi_id_op_data(rs, rw, val) \
212 __spi_out((0x1d<<18)|((rs)<<17)|((rw)<<16)|(val))
214 #define __spi_write_reg(reg, val) \
216 __spi_id_op_data(0, 0, (reg)); \
217 __spi_id_op_data(1, 0, (val)); \
220 #define __lcd_special_on() \
222 __gpio_set_pin(PortSht); \
223 __gpio_clear_pin(PortRST); \
225 __gpio_set_pin(PortRST); \
227 __spi_write_reg(0x09, 0); \
229 __spi_write_reg(0x09, 0x4000); \
230 __spi_write_reg(0x0a, 0x2000); \
232 __spi_write_reg(0x09, 0x4055); \
234 __spi_write_reg(0x01, 0x409d); \
235 __spi_write_reg(0x02, 0x0204); \
236 __spi_write_reg(0x03, 0x0100); \
237 __spi_write_reg(0x04, 0x3000); \
238 __spi_write_reg(0x05, 0x4003); \
239 __spi_write_reg(0x06, 0x000a); \
240 __spi_write_reg(0x07, 0x0021); \
241 __spi_write_reg(0x08, 0x0c00); \
242 __spi_write_reg(0x10, 0x0103); \
243 __spi_write_reg(0x11, 0x0301); \
244 __spi_write_reg(0x12, 0x1f0f); \
245 __spi_write_reg(0x13, 0x1f0f); \
246 __spi_write_reg(0x14, 0x0707); \
247 __spi_write_reg(0x15, 0x0307); \
248 __spi_write_reg(0x16, 0x0707); \
249 __spi_write_reg(0x17, 0x0000); \
250 __spi_write_reg(0x18, 0x0004); \
251 __spi_write_reg(0x19, 0x0000); \
253 __spi_write_reg(0x09, 0x4a55); \
254 __spi_write_reg(0x05, 0x5003); \
257 #define __lcd_special_off() \
259 __spi_write_reg(0x09, 0x4055); \
260 __spi_write_reg(0x05, 0x4003); \
261 __spi_write_reg(0x0a, 0x0000); \
263 __spi_write_reg(0x09, 0x4000); \
264 __gpio_clear_pin(PortSht); \
267 #endif /* CONFIG_JZLCD_SAMSUNG_LTV350QVF04 */
269 #if defined(CONFIG_JZLCD_FOXCONN_PT035TN01) || defined(CONFIG_JZLCD_INNOLUX_PT035TN01_SERIAL)
271 #if defined(CONFIG_JZLCD_FOXCONN_PT035TN01) /* board pmp */
272 #define MODE 0xcd /* 24bit parellel RGB */
274 #if defined(CONFIG_JZLCD_INNOLUX_PT035TN01_SERIAL)
275 #define MODE 0xc9 /* 8bit serial RGB */
278 #if defined(CONFIG_MIPS_JZ4730_PMPV1) || defined(CONFIG_MIPS_JZ4730_PMPV2)
279 #define SPEN 60 //LCD_SPL
280 #define SPCK 61 //LCD_CLS
281 #define SPDA 62 //LCD_PS
282 #define LCD_RET 63 //LCD_REV //use for lcd reset
283 #elif defined(CONFIG_MIPS_JZ4740_LEO) /* board leo */
284 #define SPEN (32*1+18) //LCD_SPL
285 #define SPCK (32*1+17) //LCD_CLS
286 #define SPDA (32*2+22) //LCD_PS
287 #define LCD_RET (32*2+23) //LCD_REV //use for lcd reset
288 #elif defined(CONFIG_MIPS_JZ4740_PAVO) /* board pavo */
289 #define SPEN (32*1+18) //LCD_SPL
290 #define SPCK (32*1+17) //LCD_CLS
291 #define SPDA (32*2+12) //LCD_D12
292 #define LCD_RET (32*2+23) //LCD_REV, GPC23
294 #error "driver/video/Jzlcd.h, please define SPI pins on your board."
297 #define __spi_write_reg1(reg, val) \
300 unsigned short value;\
305 __gpio_set_pin(SPEN);\
306 __gpio_set_pin(SPCK);\
307 __gpio_clear_pin(SPDA);\
308 __gpio_clear_pin(SPEN);\
310 value=((a<<8)|(b&0xFF));\
311 for(no=0;no<16;no++)\
313 __gpio_clear_pin(SPCK);\
314 if((value&0x8000)==0x8000)\
315 __gpio_set_pin(SPDA);\
317 __gpio_clear_pin(SPDA);\
319 __gpio_set_pin(SPCK);\
323 __gpio_set_pin(SPEN);\
327 #define __spi_write_reg(reg, val) \
329 __spi_write_reg1((reg<<2|2), val);\
334 #define __lcd_special_pin_init() \
336 __gpio_as_output(SPEN); /* use SPDA */\
337 __gpio_as_output(SPCK); /* use SPCK */\
338 __gpio_as_output(SPDA); /* use SPDA */\
339 __gpio_as_output(LCD_RET);\
342 #define __lcd_special_on() \
345 __gpio_clear_pin(LCD_RET);\
347 __gpio_set_pin(LCD_RET);\
349 __spi_write_reg(0x00, 0x03); \
350 __spi_write_reg(0x01, 0x40); \
351 __spi_write_reg(0x02, 0x11); \
352 __spi_write_reg(0x03, MODE); /* mode */ \
353 __spi_write_reg(0x04, 0x32); \
354 __spi_write_reg(0x05, 0x0e); \
355 __spi_write_reg(0x07, 0x03); \
356 __spi_write_reg(0x08, 0x08); \
357 __spi_write_reg(0x09, 0x40); \
358 __spi_write_reg(0x0A, 0x88); \
359 __spi_write_reg(0x0B, 0x88); \
360 __spi_write_reg(0x0C, 0x20); \
361 __spi_write_reg(0x0D, 0x20); \
362 } while (0) //reg 0x0a is control the display direction:DB0->horizontal level DB1->vertical level
364 #define __lcd_special_off() \
366 __spi_write_reg(0x00, 0x03); \
369 #endif /* CONFIG_JZLCD_FOXCONN_PT035TN01 or CONFIG_JZLCD_INNOLUX_PT035TN01_SERIAL */
371 #if defined(CONFIG_JZLCD_TRULY_TFTG240320UTSW_63W_E)
373 #if defined(CONFIG_MIPS_JZ4730_FPRINT)
375 #define PortSCL 65 /* GPIO65 as WR/SCL */
381 #error "driver/video/Jzlcd.h, please define pins on your board."
384 #define __spi_out(val) \
387 unsigned int _t_ = (val); \
388 __gpio_clear_pin(PortCS); \
390 for (__i__ = 0; __i__ < 24; __i__++ ) { \
391 __gpio_clear_pin(PortSCL); \
392 if (_t_ & 0x800000) \
393 __gpio_set_pin(PortSDI); \
395 __gpio_clear_pin(PortSDI); \
398 __gpio_set_pin(PortSCL); \
402 __gpio_set_pin(PortCS); \
403 __gpio_set_pin(PortSDI); \
404 __gpio_set_pin(PortSCL); \
407 #define __spi_id_op_data(rs, rw, val) \
408 __spi_out((0x0e<<19)|(0<<18)|((rs)<<17)|((rw)<<16)|(val)) /* 0e: 01110. ID:? */
410 #define __spi_write_reg(reg, val) \
412 __spi_id_op_data(0, 0, (reg)); \
413 __spi_id_op_data(1, 0, (val)); \
416 #define get_data(n) (__gpio_get_pin((n)) ? 1:0) /* 1: high level, 0: low level */
418 static inline unsigned int __spi_in(void)
421 unsigned int read_val
= 0;
422 unsigned int _t_
= (0x0e<<19)|(0<<18)|((1)<<17)|((1)<<16);/* 0e: 01110. ID:? */
424 __gpio_clear_pin(PortCS
);
426 //for (__i__ = 0; __i__ < 24; __i__++ ) {
427 for (__i__
= 0; __i__
< 32; __i__
++ ) {
428 __gpio_clear_pin(PortSCL
);
429 if (_t_
& 0x800000) /* send data */
430 __gpio_set_pin(PortSDI
);
432 __gpio_clear_pin(PortSDI
);
435 __gpio_set_pin(PortSCL
);
437 read_val
|= get_data(PortSDO
); /* receive data */
441 __gpio_set_pin(PortCS
);
442 __gpio_set_pin(PortSDI
);
443 __gpio_set_pin(PortSCL
);
447 static inline unsigned int __spi_read_reg(int reg
)
449 unsigned int read_val
;
450 __spi_id_op_data(0, 0, (reg
));
452 read_val
= __spi_in();
457 #define WMLCDCOM(val) __spi_id_op_data(0,0,val)
458 #define WMLCDDATA(val) __spi_id_op_data(1,0,val)
459 #define Delayms(n) mdelay(n)
461 static inline void mlcd_mode_setting(void)
464 WMLCDCOM(0x0001);WMLCDDATA(0x0000); /* Horizontal reverse */
465 WMLCDCOM(0x0002);WMLCDDATA(0x0700);
467 //WMLCDCOM(0x0003);WMLCDDATA(0x1230); /* default 240x320, HWM=1 write data in high speed */
468 WMLCDCOM(0x0003);WMLCDDATA(0x1038); /* Rotate to 320x240, HWM=0, low speed */
469 WMLCDCOM(0x000C);WMLCDDATA(0x0111); /* External interface, as 16bit RGB interface */
470 WMLCDCOM(0x0020);WMLCDDATA(0x0000); /* Horizontal base */
471 WMLCDCOM(0x0021);WMLCDDATA(0x0000); /* Vertical base */
472 WMLCDCOM(0x0030);WMLCDDATA(0x0707);
473 WMLCDCOM(0x0031);WMLCDDATA(0x0407);
474 WMLCDCOM(0x0032);WMLCDDATA(0x0203);
475 WMLCDCOM(0x0033);WMLCDDATA(0x0303);
476 WMLCDCOM(0x0034);WMLCDDATA(0x0303);
477 WMLCDCOM(0x0035);WMLCDDATA(0x0202);
478 WMLCDCOM(0x0036);WMLCDDATA(0x001F);
479 WMLCDCOM(0x0037);WMLCDDATA(0x0707);
480 WMLCDCOM(0x0038);WMLCDDATA(0x0407);
481 WMLCDCOM(0x0039);WMLCDDATA(0x0203);
482 WMLCDCOM(0x003A);WMLCDDATA(0x0303);
483 WMLCDCOM(0x003B);WMLCDDATA(0x0303);
484 WMLCDCOM(0x003C);WMLCDDATA(0x0202);
485 WMLCDCOM(0x003D);WMLCDDATA(0x001F);
486 WMLCDCOM(0x0050);WMLCDDATA(0x0000); /* X start: 0 */
487 WMLCDCOM(0x0051);WMLCDDATA(0x00EF); /* X end: 239 */
488 WMLCDCOM(0x0052);WMLCDDATA(0x0000); /* Y start: 0 */
489 WMLCDCOM(0x0053);WMLCDDATA(0x013F); /* Y end: 319 */
490 WMLCDCOM(0x0060);WMLCDDATA(0x2700);
491 WMLCDCOM(0x0061);WMLCDDATA(0x0001);
492 WMLCDCOM(0x006A);WMLCDDATA(0x0000); /* VL: Vertical Scroll */
493 WMLCDCOM(0x0090);WMLCDDATA(0x0016);
494 WMLCDCOM(0x0092);WMLCDDATA(0x0000);
495 WMLCDCOM(0x0093);WMLCDDATA(0x0000);
498 static inline void mlcd_power_on(void)
500 /* Power supply on */
501 WMLCDCOM(0x0007);WMLCDDATA(0x0001);
502 WMLCDCOM(0x0017);WMLCDDATA(0x0001);
504 WMLCDCOM(0x0010);WMLCDDATA(0x17B0);
505 WMLCDCOM(0x0011);WMLCDDATA(0x0007);
506 WMLCDCOM(0x0012);WMLCDDATA(0x011A);
507 WMLCDCOM(0x0013);WMLCDDATA(0x0F00);
508 WMLCDCOM(0x0029);WMLCDDATA(0x0010);
509 WMLCDCOM(0x0012);WMLCDDATA(0x013A);
512 static inline void mlcd_power_off(void)
514 WMLCDCOM(0x0010);WMLCDDATA(0x0780);
515 WMLCDCOM(0x0011);WMLCDDATA(0x0067);
516 WMLCDCOM(0x0012);WMLCDDATA(0x010A);
518 WMLCDCOM(0x0010);WMLCDDATA(0x0700);
521 static inline void mlcd_display_on(void)
523 /* Display on sequence */
524 WMLCDCOM(0x0007);WMLCDDATA(0x0021);
526 WMLCDCOM(0x0007);WMLCDDATA(0x0061);
528 WMLCDCOM(0x0007);WMLCDDATA(0x0173);
529 WMLCDCOM(0x0022); /* set Index register R22 */
531 static inline void mlcd_display_off(void)
533 /* Display off sequence */
534 WMLCDCOM(0x0007);WMLCDDATA(0x0072);
536 WMLCDCOM(0x0007);WMLCDDATA(0x0001);
538 WMLCDCOM(0x0007);WMLCDDATA(0x0000);
541 #define __lcd_special_pin_init() \
543 __gpio_as_input(PortSDO); /* SDO */\
544 __gpio_as_output(PortSDI); /* SDI */\
545 __gpio_as_output(PortSCL); /* SCL */ \
546 __gpio_as_output(PortCS); /* CS */ \
547 __gpio_as_output(PortRST); /* Reset */ \
548 __gpio_as_output(PortSCL1); /* SCL1 */ \
549 __gpio_set_pin(PortCS); \
550 __gpio_set_pin(PortSCL); \
551 __gpio_set_pin(PortSDI); \
552 __gpio_set_pin(PortRST); \
553 __gpio_set_pin(PortSCL1); \
554 __gpio_set_pin(PortRST); \
557 #define __lcd_special_on() \
560 __gpio_clear_pin(PortRST); /* Reset period > 1ms */ \
562 __gpio_set_pin(PortRST); \
565 mlcd_mode_setting();\
569 #if 0 /* Customer need Power Off? --No need, right now */
570 #define __lcd_special_off() \
572 mlcd_display_off(); \
577 #endif /* CONFIG_JZLCD_TRULY_TFTG240320UTSW_63W_E */
579 #ifndef __lcd_special_pin_init
580 #define __lcd_special_pin_init()
582 #ifndef __lcd_special_on
583 #define __lcd_special_on()
585 #ifndef __lcd_special_off
586 #define __lcd_special_off()
591 * Platform specific definition
594 #if defined(CONFIG_MIPS_JZ4730_GPS)
596 #define __lcd_set_backlight_level(n) \
601 #define __lcd_display_pin_init() \
603 __lcd_special_pin_init(); \
604 __gpio_as_output(94); /* PWM0 pin */ \
605 __gpio_as_output(95); /* PWM1 pin */ \
608 #define __lcd_display_on() \
610 __lcd_special_on(); \
611 __gpio_set_pin(94); /* PWM0 pin */ \
612 __gpio_set_pin(95); /* PWM1 pin */ \
613 __lcd_set_backlight_level(8); \
616 #define __lcd_display_off() \
618 __lcd_special_off(); \
621 #endif /* CONFIG_MIPS_JZ4730_GPS */
623 #if defined(CONFIG_MIPS_JZ4730_FPRINT)
625 #define __lcd_set_backlight_level(n) \
627 REG_PWM_DUT(0) = n; \
628 REG_PWM_PER(0) = 7; \
629 REG_PWM_CTR(0) = 0xc1; \
632 #if defined(CONFIG_JZLCD_FOXCONN_PT035TN01)
634 #define __lcd_display_pin_init() \
636 __lcd_special_pin_init();\
638 __lcd_set_backlight_level(8);\
641 #define __lcd_display_on() \
643 __lcd_set_backlight_level(8); \
647 #define __lcd_display_off() \
649 __lcd_set_backlight_level(0); \
650 __lcd_special_off();\
653 #elif defined(CONFIG_JZLCD_TRULY_TFTG240320UTSW_63W_E)
654 /* pwm circle frequece = 1KHz */
655 /* back light level: 0~100 */
656 #undef __lcd_set_backlight_level
657 #define __lcd_set_backlight_level(n) \
659 REG_PWM_DUT(0) = n; \
660 REG_PWM_PER(0) = 99; \
661 REG_PWM_CTR(0) = 0xe4; \
664 #define __lcd_display_pin_init() \
666 __lcd_special_pin_init();\
668 __lcd_set_backlight_level(88);\
671 #define __lcd_display_on() \
673 __lcd_set_backlight_level(88); \
677 #define __lcd_display_off() \
679 __lcd_set_backlight_level(0); \
680 __lcd_special_off();\
685 #define __lcd_display_pin_init() \
687 __gpio_as_output(GPIO_DISP_OFF_N); \
689 __lcd_set_backlight_level(8); \
692 #define __lcd_display_on() \
694 __lcd_set_backlight_level(8); \
695 __gpio_set_pin(GPIO_DISP_OFF_N); \
698 #define __lcd_display_off() \
700 __lcd_set_backlight_level(0); \
701 __gpio_clear_pin(GPIO_DISP_OFF_N); \
705 #endif /* CONFIG_MIPS_JZ4730_FPRINT */
707 #if defined(CONFIG_MIPS_JZ4730_LIBRA)
709 #define __lcd_set_backlight_level(n) \
713 #define __lcd_display_pin_init() \
715 __lcd_special_pin_init(); \
716 __gpio_clear_pin(100); \
717 __gpio_as_output(100); \
718 __gpio_as_output(94); \
719 __gpio_as_output(95); \
720 __lcd_set_backlight_level(8); \
723 #define __lcd_display_on() \
725 __lcd_special_on(); \
726 __gpio_set_pin(100); \
727 __gpio_set_pin(94); \
728 __gpio_set_pin(95); \
731 #define __lcd_display_off() \
733 __lcd_special_off(); \
734 __gpio_clear_pin(100); \
735 __gpio_clear_pin(94); \
736 __gpio_clear_pin(95); \
739 #endif /* CONFIG_MIPS_JZ4730_LIBRA */
741 #if defined(CONFIG_MIPS_JZ4730_PMPV1) || defined(CONFIG_MIPS_JZ4730_PMPV2)
745 #define __lcd_set_backlight_level(n) \
748 REG_PWM_DUT(0) = n; \
749 REG_PWM_PER(0) = 7; \
750 REG_PWM_CTR(0) = 0xc1; \
753 #define __lcd_close_backlight() \
755 __gpio_as_output(GPIO_PWM0);\
756 __gpio_clear_pin(GPIO_PWM0);\
759 #define __lcd_display_pin_init() \
761 __gpio_as_output(GPIO_DISP_OFF_N); \
762 __lcd_set_backlight_level(8); \
763 __lcd_special_pin_init(); \
766 #define __lcd_display_on() \
768 __gpio_set_pin(GPIO_DISP_OFF_N); \
769 __lcd_special_on(); \
770 __lcd_set_backlight_level(8); \
773 #define __lcd_display_off() \
775 __lcd_special_off(); \
776 __lcd_close_backlight(); \
777 __gpio_clear_pin(GPIO_DISP_OFF_N); \
780 #endif /* CONFIG_MIPS_JZ4730_PMPV1 | CONFIG_MIPS_JZ4730_PMPV1 */
783 #if defined(CONFIG_MIPS_JZ4740_LEO) || defined(CONFIG_MIPS_JZ4740_PAVO)|| defined(CONFIG_MIPS_JZ4740_VIRGO)
785 #if defined(CONFIG_MIPS_JZ4740_PAVO)
786 #define GPIO_PWM 123 /* GP_D27 */
787 #define PWM_CHN 4 /* pwm channel */
789 /* 100 level: 0,1,...,100 */
790 /*#define __lcd_set_backlight_level(n) \
793 __tcu_disable_pwm_output(PWM_CHN); \
794 __tcu_stop_counter(PWM_CHN); \
795 __tcu_init_pwm_output_high(PWM_CHN); \
796 __tcu_set_pwm_output_shutdown_abrupt(PWM_CHN); \
797 __tcu_select_clk_div1(PWM_CHN); \
798 __tcu_mask_full_match_irq(PWM_CHN); \
799 __tcu_mask_half_match_irq(PWM_CHN); \
800 __tcu_set_count(PWM_CHN,0); \
801 __tcu_set_full_data(PWM_CHN,__cpm_get_extalclk()/1000); \
802 __tcu_set_half_data(PWM_CHN,__cpm_get_extalclk()/1000*n/100); \
803 __tcu_enable_pwm_output(PWM_CHN); \
804 __tcu_select_extalclk(PWM_CHN); \
805 __tcu_start_counter(PWM_CHN); \
808 #define __lcd_set_backlight_level(n) \
810 __gpio_as_output(GPIO_PWM); \
811 __gpio_set_pin(GPIO_PWM); \
814 #define __lcd_close_backlight() \
816 __gpio_as_output(GPIO_PWM); \
817 __gpio_clear_pin(GPIO_PWM); \
820 #elif defined(CONFIG_MIPS_JZ4740_VIRGO)
821 #define GPIO_PWM 119 /* GP_D23 */
822 #define PWM_CHN 0 /* pwm channel */
824 /* 100 level: 0,1,...,100 */
825 /*#define __lcd_set_backlight_level(n) \
828 __tcu_disable_pwm_output(PWM_CHN); \
829 __tcu_stop_counter(PWM_CHN); \
830 __tcu_init_pwm_output_high(PWM_CHN); \
831 __tcu_set_pwm_output_shutdown_abrupt(PWM_CHN); \
832 __tcu_select_clk_div1(PWM_CHN); \
833 __tcu_mask_full_match_irq(PWM_CHN); \
834 __tcu_mask_half_match_irq(PWM_CHN); \
835 __tcu_set_count(PWM_CHN,0); \
836 __tcu_set_full_data(PWM_CHN,__cpm_get_extalclk()/1000); \
837 __tcu_set_half_data(PWM_CHN,__cpm_get_extalclk()/1000*n/100); \
838 __tcu_enable_pwm_output(PWM_CHN); \
839 __tcu_select_extalclk(PWM_CHN); \
840 __tcu_start_counter(PWM_CHN); \
844 #define __lcd_set_backlight_level(n) \
846 __gpio_as_output(GPIO_PWM); \
847 __gpio_set_pin(GPIO_PWM); \
850 #define __lcd_close_backlight() \
852 __gpio_as_output(GPIO_PWM); \
853 __gpio_clear_pin(GPIO_PWM); \
856 #elif defined CONFIG_MIPS_JZ4740_LEO
858 #define __lcd_set_backlight_level(n)
859 #define __lcd_close_backlight()
861 #endif /* #if defined(CONFIG_MIPS_JZ4740_PAVO) */
863 #define __lcd_display_pin_init() \
865 __gpio_as_output(GPIO_DISP_OFF_N); \
867 __lcd_special_pin_init(); \
870 #define __lcd_display_on() \
872 __lcd_special_on(); \
873 __gpio_set_pin(GPIO_DISP_OFF_N); \
875 __lcd_set_backlight_level(80); \
878 #define __lcd_display_off() \
880 __lcd_close_backlight(); \
881 __lcd_special_off(); \
882 __gpio_clear_pin(GPIO_DISP_OFF_N); \
885 #endif /* CONFIG_MIPS_JZ4740_LEO */
887 #if defined(CONFIG_JZLCD_MSTN_240x128)
888 #if 0 /* The final version does not use software emulation of VCOM. */
890 #define GPIO_VSYNC 59
893 #define REG_VCOM REG_GPIO_GPDR((GPIO_VCOM>>5))
894 #define VCOM_BIT (1 << (GPIO_VCOM & 0x1f))
895 static unsigned int vcom_static
;
896 static void vsync_irq(int irq
, void *dev_id
, struct pt_regs
*reg
)
898 vcom_static
= REG_VCOM
;
899 vcom_static
^= VCOM_BIT
;
900 REG_VCOM
= vcom_static
;
903 #define __lcd_display_pin_init() \
904 __gpio_as_irq_rise_edge(GPIO_VSYNC); \
905 __gpio_as_output(GPIO_VCOM); \
907 static int inited = 0; \
910 if (request_irq(IRQ_GPIO_0 + GPIO_VSYNC, vsync_irq, SA_INTERRUPT, \
918 /* We uses AC BIAs pin to generate VCOM signal, so above code should be removed.
922 /*****************************************************************************
923 * LCD display pin dummy macros
924 *****************************************************************************/
925 #ifndef __lcd_display_pin_init
926 #define __lcd_display_pin_init()
928 #ifndef __lcd_display_on
929 #define __lcd_display_on()
931 #ifndef __lcd_display_off
932 #define __lcd_display_off()
934 #ifndef __lcd_set_backlight_level
935 #define __lcd_set_backlight_level(n)
938 #endif /* __JZLCD_H__ */