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