tizen 2.4 release
[kernel/u-boot-tm1.git] / drivers / video / sc8825fb / lcd_nt35510_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,0x0B,0x0B,0x0B}}, \r
58 {LCM_SEND(6), {4, 0, 0xBA,0x24,0x24,0x24}}, \r
59 {LCM_SEND(6), {4, 0, 0xBC,0x00,0xA3,0x00}}, \r
60 {LCM_SEND(6), {4, 0, 0xBD,0x00,0xA3,0x00}}, \r
61 \r
62 {LCM_SEND(5), {3, 0, 0xBE,0x00,0x58}}, \r
63 \r
64 {LCM_SEND(55), {53, 0, 0xD1,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,\r
65 0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,\r
66 0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,\r
67 0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}}, \r
68 {LCM_SEND(55), {53, 0, 0xD2,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,\r
69 0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,\r
70 0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,\r
71 0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}}, \r
72 {LCM_SEND(55), {53, 0, 0xD3,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,\r
73 0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,\r
74 0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,\r
75 0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}}, \r
76 {LCM_SEND(55), {53, 0, 0xD4,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,\r
77 0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,\r
78 0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,\r
79 0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}}, \r
80 {LCM_SEND(55), {53, 0, 0xD5,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,\r
81 0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,\r
82 0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,\r
83 0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}}, \r
84 {LCM_SEND(55), {53, 0, 0xD6,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,\r
85 0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,\r
86 0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,\r
87 0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}},\r
88 \r
89 {LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x08,0x00}},\r
90 \r
91 {LCM_SEND(5), {3, 0, 0xB1,0xFC,0x04}}, \r
92 {LCM_SEND(2), {0x36,0x02}},\r
93 {LCM_SEND(2), {0xB6,0x0A}},\r
94 {LCM_SEND(5), {3, 0, 0xB7,0x00,0x00}}, \r
95 {LCM_SEND(7), {5, 0, 0xB8,0x01,0x05,0x05,0x05}}, \r
96 {LCM_SEND(2), {0xBA,0x01}}, \r
97 {LCM_SEND(6), {4, 0, 0xBC,0x00,0x00,0x00}}, \r
98 {LCM_SEND(8), {6, 0, 0xBD,0x01,0x84,0x07,0x32,0x00}}, \r
99 {LCM_SEND(8), {6, 0, 0xBE,0x01,0x84,0x07,0x31,0x00}}, \r
100 {LCM_SEND(8), {6, 0, 0xBF,0x01,0x84,0x07,0x31,0x00}}, \r
101 {LCM_SEND(2), {0x35,0x00}},// Tearing Effect On \r
102 {LCM_SEND(6), {4, 0, 0xCC,0x03,0x00,0x00}}, \r
103 {LCM_SEND(2), {0x3A, 0x77}},\r
104 \r
105 {LCM_SEND(1), {0x11}}, // sleep out \r
106 {LCM_SLEEP(120),},\r
107 {LCM_SEND(1), {0x29}}, // display on \r
108 {LCM_SLEEP(100),},\r
109 {LCM_SEND(1), {0x2c}}, // normal on \r
110 \r
111 \r
112 };\r
113 \r
114 static LCM_Init_Code disp_on =  {LCM_SEND(1), {0x29}};\r
115 \r
116 static LCM_Init_Code sleep_in =  {LCM_SEND(1), {0x10}};\r
117 \r
118 static LCM_Init_Code sleep_out =  {LCM_SEND(1), {0x11}};\r
119 \r
120 static int32_t nt35510_mipi_init(struct panel_spec *self)\r
121 {\r
122         int32_t i;\r
123         LCM_Init_Code *init = init_data;\r
124         unsigned int tag;\r
125 \r
126         mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;\r
127         mipi_gen_write_t mipi_gen_write = self->info.mipi->ops->mipi_gen_write;\r
128 \r
129         LCD_PRINT("nt35510_init\n");\r
130 \r
131         mipi_set_cmd_mode();\r
132 \r
133         for(i = 0; i < ARRAY_SIZE(init_data); i++){\r
134                 tag = (init->tag >>24);\r
135                 if(tag & LCM_TAG_SEND){\r
136                         mipi_gen_write(init->data, (init->tag & LCM_TAG_MASK));\r
137                 }else if(tag & LCM_TAG_SLEEP){\r
138                         udelay((init->tag & LCM_TAG_MASK) * 1000);\r
139                 }\r
140                 init++;\r
141         }\r
142         return 0;\r
143 }\r
144 \r
145 static uint32_t nt35510_readid(struct panel_spec *self)\r
146 {\r
147         /*Jessica TODO: need read id*/\r
148         return 0x10;\r
149 }\r
150 \r
151 static struct panel_operations lcd_nt35510_mipi_operations = {\r
152         .panel_init = nt35510_mipi_init,\r
153         .panel_readid = nt35510_readid,\r
154 };\r
155 \r
156 static struct timing_rgb lcd_nt35510_mipi_timing = {\r
157         .hfp = 20,  /* unit: pixel */\r
158         .hbp = 20,\r
159         .hsync = 4,\r
160         .vfp = 10, /*unit: line*/\r
161         .vbp = 10,\r
162         .vsync = 6,\r
163 };\r
164 \r
165 static struct info_mipi lcd_nt35510_mipi_info = {\r
166         .work_mode  = SPRDFB_MIPI_MODE_CMD,\r
167         .video_bus_width = 24, /*18,16*/\r
168         .lan_number = 2,\r
169         .phy_feq = 500*1000,\r
170         //.h_sync_pol = SPRDFB_POLARITY_POS,\r
171         //.v_sync_pol = SPRDFB_POLARITY_POS,\r
172         //.de_pol = SPRDFB_POLARITY_POS,\r
173         .te_pol = SPRDFB_POLARITY_POS,\r
174         //.color_mode_pol = SPRDFB_POLARITY_NEG,\r
175         //.shut_down_pol = SPRDFB_POLARITY_NEG,\r
176         .timing = &lcd_nt35510_mipi_timing,\r
177         .ops = NULL,\r
178 };\r
179 \r
180 struct panel_spec lcd_nt35510_mipi_spec = {\r
181         .width = 480,\r
182         .height = 800,\r
183         .type = LCD_MODE_DSI,\r
184         .direction = LCD_DIRECT_NORMAL,\r
185         .info = {\r
186                 .mipi = &lcd_nt35510_mipi_info\r
187         },\r
188         .ops = &lcd_nt35510_mipi_operations,\r
189 };\r