tizen 2.4 release
[kernel/u-boot-tm1.git] / drivers / video / sc8825fb / lcd_nt35512_mipi.c
1 /* drivers/video/sc8825/lcd_nt35516_mipi.c\r
2  *\r
3  * Support for nt35516 mipi LCD device\r
4  *\r
5  * Copyright (C) 2010 Spreadtrum\r
6  *\r
7  * This software is licensed under the terms of the GNU General Public\r
8  * License version 2, as published by the Free Software Foundation, and\r
9  * may be copied, distributed, and modified under those terms.\r
10  *\r
11  * This program is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  */\r
16 \r
17 #include <asm/arch/tiger_lcd.h>\r
18 \r
19 #define printk printf\r
20 \r
21 //#define  LCD_DEBUG\r
22 #ifdef LCD_DEBUG\r
23 #define LCD_PRINT printk\r
24 #else\r
25 #define LCD_PRINT(...)\r
26 #endif\r
27 \r
28 #define MAX_DATA   56\r
29 \r
30 typedef struct LCM_Init_Code_tag {\r
31         unsigned int tag;\r
32         unsigned char data[MAX_DATA];\r
33 }LCM_Init_Code;\r
34 \r
35 #define LCM_TAG_SHIFT 24\r
36 #define LCM_TAG_MASK  ((1 << 24) -1)\r
37 #define LCM_SEND(len) ((1 << LCM_TAG_SHIFT)| len)\r
38 #define LCM_SLEEP(ms) ((2 << LCM_TAG_SHIFT)| ms)\r
39 //#define ARRAY_SIZE(array) ( sizeof(array) / sizeof(array[0]))\r
40 \r
41 #define LCM_TAG_SEND  (1<< 0)\r
42 #define LCM_TAG_SLEEP (1 << 1)\r
43 \r
44 static LCM_Init_Code init_data[] = {\r
45 \r
46 {LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x08,0x01}}, \r
47 \r
48 {LCM_SEND(6), {4, 0, 0xB0,0x09,0x09,0x09}}, \r
49 {LCM_SEND(6), {4, 0, 0xB6,0x34,0x34,0x34}}, \r
50 {LCM_SEND(6), {4, 0, 0xB1,0x09,0x09,0x09}}, \r
51 {LCM_SEND(6), {4, 0, 0xB7,0x24,0x24,0x24}}, \r
52 {LCM_SEND(6), {4, 0, 0xB3,0x05,0x05,0x05}}, \r
53 {LCM_SEND(6), {4, 0, 0xB9,0x24,0x24,0x24}}, \r
54 \r
55 {LCM_SEND(2), {0xBF,0x01}}, \r
56 \r
57 {LCM_SEND(6), {4, 0, 0xB5,0x03,0x03,0x03}}, \r
58 {LCM_SEND(6), {4, 0, 0xBA,0x24,0x24,0x24}}, \r
59 {LCM_SEND(2), {0xC2,0x01}}, \r
60 {LCM_SEND(6), {4, 0, 0xBC,0x00,0x90,0x00}}, \r
61 {LCM_SEND(6), {4, 0, 0xBD,0x00,0x90,0x00}}, \r
62 \r
63 {LCM_SEND(5), {3, 0, 0xBE,0x00,0x57}}, \r
64 \r
65 {LCM_SEND(55), {53, 0, 0xD1,0x00,0x01,0x00,0x1D,0x00,0x48,0x00,0x64,0x00,0x7E,0x00,0xB1,0x00,0xD3,0x01,0x07,0x01,0x35,0x01,0x7B,0x01,0xB3,0x02,0x03,0x02,0x48,0x02,0x49,0x02,0x88,0x02,0xC7,0x02,0xF3,0x03,0x21,0x03,0x46,0x03,0x74,0x03,0x8F,0x03,0xA3,0x03,0xAC,0x03,0xB7,0x03,0xBF,0x03,0xFE}}, \r
66 {LCM_SEND(55), {53, 0, 0xD2,0x00,0x01,0x00,0x1D,0x00,0x48,0x00,0x64,0x00,0x7E,0x00,0xB1,0x00,0xD3,0x01,0x07,0x01,0x35,0x01,0x7B,0x01,0xB3,0x02,0x03,0x02,0x48,0x02,0x49,0x02,0x88,0x02,0xC7,0x02,0xF3,0x03,0x21,0x03,0x46,0x03,0x74,0x03,0x8F,0x03,0xA3,0x03,0xAC,0x03,0xB7,0x03,0xBF,0x03,0xFE}}, \r
67 {LCM_SEND(55), {53, 0, 0xD3,0x00,0x01,0x00,0x1D,0x00,0x48,0x00,0x64,0x00,0x7E,0x00,0xB1,0x00,0xD3,0x01,0x07,0x01,0x35,0x01,0x7B,0x01,0xB3,0x02,0x03,0x02,0x48,0x02,0x49,0x02,0x88,0x02,0xC7,0x02,0xF3,0x03,0x21,0x03,0x46,0x03,0x74,0x03,0x8F,0x03,0xA3,0x03,0xAC,0x03,0xB7,0x03,0xBF,0x03,0xFE}}, \r
68 {LCM_SEND(55), {53, 0, 0xD4,0x00,0x01,0x00,0x1D,0x00,0x48,0x00,0x64,0x00,0x7E,0x00,0xB1,0x00,0xD3,0x01,0x07,0x01,0x35,0x01,0x7B,0x01,0xB3,0x02,0x03,0x02,0x48,0x02,0x49,0x02,0x88,0x02,0xC7,0x02,0xF3,0x03,0x21,0x03,0x46,0x03,0x74,0x03,0x8F,0x03,0xA3,0x03,0xAC,0x03,0xB7,0x03,0xBF,0x03,0xFE}}, \r
69 {LCM_SEND(55), {53, 0, 0xD5,0x00,0x01,0x00,0x1D,0x00,0x48,0x00,0x64,0x00,0x7E,0x00,0xB1,0x00,0xD3,0x01,0x07,0x01,0x35,0x01,0x7B,0x01,0xB3,0x02,0x03,0x02,0x48,0x02,0x49,0x02,0x88,0x02,0xC7,0x02,0xF3,0x03,0x21,0x03,0x46,0x03,0x74,0x03,0x8F,0x03,0xA3,0x03,0xAC,0x03,0xB7,0x03,0xBF,0x03,0xFE}}, \r
70 {LCM_SEND(55), {53, 0, 0xD6,0x00,0x01,0x00,0x1D,0x00,0x48,0x00,0x64,0x00,0x7E,0x00,0xB1,0x00,0xD3,0x01,0x07,0x01,0x35,0x01,0x7B,0x01,0xB3,0x02,0x03,0x02,0x48,0x02,0x49,0x02,0x88,0x02,0xC7,0x02,0xF3,0x03,0x21,0x03,0x46,0x03,0x74,0x03,0x8F,0x03,0xA3,0x03,0xAC,0x03,0xB7,0x03,0xBF,0x03,0xFE}}, \r
71 \r
72 {LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x08,0x00}},\r
73 \r
74 {LCM_SEND(2), {0xB6,0x0A}}, \r
75 {LCM_SEND(5), {3, 0, 0xB7,0x00,0x00}}, \r
76 {LCM_SEND(7), {5, 0, 0xB8,0x01,0x05,0x05,0x05}}, \r
77 {LCM_SEND(2), {0xBA,0x01}}, \r
78 {LCM_SEND(6), {4, 0, 0xBC,0x00,0x00,0x00}}, \r
79 //{LCM_SEND(8), {6, 0, 0xBD,0x01,0x4D,0x07,0x31,0x00}}, \r
80 //{LCM_SEND(8), {6, 0, 0xBE,0x01,0x84,0x07,0x31,0x00}}, \r
81 //{LCM_SEND(8), {6, 0, 0xBF,0x01,0x84,0x07,0x31,0x00}}, \r
82 {LCM_SEND(6), {4, 0, 0xCC,0x03,0x00,0x00}}, \r
83 {LCM_SEND(5), {3, 0, 0xB1,0xFC,0x00}}, \r
84 {LCM_SEND(2), {0x35,0x00}}, // Tearing Effect On \r
85 {LCM_SEND(2), {0x36,0xC2}}, \r
86 {LCM_SEND(2), {0x3A, 0x77}},\r
87 \r
88 \r
89 \r
90 {LCM_SEND(1), {0x11}}, // sleep out \r
91 {LCM_SLEEP(120),},\r
92 {LCM_SEND(1), {0x29}}, // display on \r
93 {LCM_SLEEP(100),},\r
94 {LCM_SEND(1), {0x2c}}, // normal on \r
95 \r
96 \r
97 };\r
98 \r
99 static LCM_Init_Code disp_on =  {LCM_SEND(1), {0x29}};\r
100 \r
101 static LCM_Init_Code sleep_in =  {LCM_SEND(1), {0x10}};\r
102 \r
103 static LCM_Init_Code sleep_out =  {LCM_SEND(1), {0x11}};\r
104 \r
105 static int32_t nt35512_mipi_init(struct panel_spec *self)\r
106 {\r
107         int32_t i;\r
108         LCM_Init_Code *init = init_data;\r
109         unsigned int tag;\r
110 \r
111         mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;\r
112         mipi_gen_write_t mipi_gen_write = self->info.mipi->ops->mipi_gen_write;\r
113 \r
114         LCD_PRINT("nt35512_init\n");\r
115 \r
116         mipi_set_cmd_mode();\r
117 \r
118         for(i = 0; i < ARRAY_SIZE(init_data); i++){\r
119                 tag = (init->tag >>24);\r
120                 if(tag & LCM_TAG_SEND){\r
121                         mipi_gen_write(init->data, (init->tag & LCM_TAG_MASK));\r
122                 }else if(tag & LCM_TAG_SLEEP){\r
123                         udelay((init->tag & LCM_TAG_MASK) * 1000);\r
124                 }\r
125                 init++;\r
126         }\r
127         return 0;\r
128 }\r
129 \r
130 static uint32_t nt35512_readid(struct panel_spec *self)\r
131 {\r
132         /*Jessica TODO: need read id*/\r
133         return 0x12;\r
134 }\r
135 \r
136 static struct panel_operations lcd_nt35512_mipi_operations = {\r
137         .panel_init = nt35512_mipi_init,\r
138         .panel_readid = nt35512_readid,\r
139 };\r
140 \r
141 static struct timing_rgb lcd_nt35512_mipi_timing = {\r
142         .hfp = 200,  /* unit: pixel */\r
143         .hbp = 200,\r
144         .hsync = 8,\r
145         .vfp = 10, /*unit: line*/\r
146         .vbp = 10,\r
147         .vsync = 6,\r
148 };\r
149 \r
150 static struct info_mipi lcd_nt35512_mipi_info = {\r
151         .work_mode  = SPRDFB_MIPI_MODE_VIDEO,\r
152         .video_bus_width = 24, /*18,16*/\r
153         .lan_number = 2,\r
154         .phy_feq = 500*1000,\r
155         //.h_sync_pol = SPRDFB_POLARITY_POS,\r
156         //.v_sync_pol = SPRDFB_POLARITY_POS,\r
157         //.de_pol = SPRDFB_POLARITY_POS,\r
158         .te_pol = SPRDFB_POLARITY_POS,\r
159         //.color_mode_pol = SPRDFB_POLARITY_NEG,\r
160         //.shut_down_pol = SPRDFB_POLARITY_NEG,\r
161         .timing = &lcd_nt35512_mipi_timing,\r
162         .ops = NULL,\r
163 };\r
164 \r
165 struct panel_spec lcd_nt35512_mipi_spec = {\r
166         .width = 480,\r
167         .height = 800,\r
168         .type = LCD_MODE_DSI,\r
169         .direction = LCD_DIRECT_NORMAL,\r
170         .info = {\r
171                 .mipi = &lcd_nt35512_mipi_info\r
172         },\r
173         .ops = &lcd_nt35512_mipi_operations,\r
174 };\r