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