drm/connector: Change DRM card alias from underscore to hyphen
[platform/kernel/linux-rpi.git] / drivers / gpu / drm / panel / panel-ilitek-ili9881c.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2017-2018, Bootlin
4  * Copyright (C) 2021, Henson Li <henson@cutiepi.io>
5  * Copyright (C) 2021, Penk Chen <penk@cutiepi.io>
6  * Copyright (C) 2022, Mark Williams <mark@crystalfontz.com>
7  */
8
9 #include <linux/delay.h>
10 #include <linux/device.h>
11 #include <linux/err.h>
12 #include <linux/errno.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/of.h>
16
17 #include <linux/gpio/consumer.h>
18 #include <linux/regulator/consumer.h>
19
20 #include <drm/drm_mipi_dsi.h>
21 #include <drm/drm_modes.h>
22 #include <drm/drm_panel.h>
23
24 #include <video/mipi_display.h>
25
26 enum ili9881c_op {
27         ILI9881C_SWITCH_PAGE,
28         ILI9881C_COMMAND,
29 };
30
31 struct ili9881c_instr {
32         enum ili9881c_op        op;
33
34         union arg {
35                 struct cmd {
36                         u8      cmd;
37                         u8      data;
38                 } cmd;
39                 u8      page;
40         } arg;
41 };
42
43 struct ili9881c_desc {
44         const struct ili9881c_instr *init;
45         const size_t init_length;
46         const struct drm_display_mode *mode;
47         const unsigned long mode_flags;
48 };
49
50 struct ili9881c {
51         struct drm_panel        panel;
52         struct mipi_dsi_device  *dsi;
53         const struct ili9881c_desc      *desc;
54
55         struct regulator        *power;
56         struct gpio_desc        *reset;
57
58         enum drm_panel_orientation      orientation;
59 };
60
61 #define ILI9881C_SWITCH_PAGE_INSTR(_page)       \
62         {                                       \
63                 .op = ILI9881C_SWITCH_PAGE,     \
64                 .arg = {                        \
65                         .page = (_page),        \
66                 },                              \
67         }
68
69 #define ILI9881C_COMMAND_INSTR(_cmd, _data)             \
70         {                                               \
71                 .op = ILI9881C_COMMAND,         \
72                 .arg = {                                \
73                         .cmd = {                        \
74                                 .cmd = (_cmd),          \
75                                 .data = (_data),        \
76                         },                              \
77                 },                                      \
78         }
79
80 static const struct ili9881c_instr lhr050h41_init[] = {
81         ILI9881C_SWITCH_PAGE_INSTR(3),
82         ILI9881C_COMMAND_INSTR(0x01, 0x00),
83         ILI9881C_COMMAND_INSTR(0x02, 0x00),
84         ILI9881C_COMMAND_INSTR(0x03, 0x73),
85         ILI9881C_COMMAND_INSTR(0x04, 0x03),
86         ILI9881C_COMMAND_INSTR(0x05, 0x00),
87         ILI9881C_COMMAND_INSTR(0x06, 0x06),
88         ILI9881C_COMMAND_INSTR(0x07, 0x06),
89         ILI9881C_COMMAND_INSTR(0x08, 0x00),
90         ILI9881C_COMMAND_INSTR(0x09, 0x18),
91         ILI9881C_COMMAND_INSTR(0x0a, 0x04),
92         ILI9881C_COMMAND_INSTR(0x0b, 0x00),
93         ILI9881C_COMMAND_INSTR(0x0c, 0x02),
94         ILI9881C_COMMAND_INSTR(0x0d, 0x03),
95         ILI9881C_COMMAND_INSTR(0x0e, 0x00),
96         ILI9881C_COMMAND_INSTR(0x0f, 0x25),
97         ILI9881C_COMMAND_INSTR(0x10, 0x25),
98         ILI9881C_COMMAND_INSTR(0x11, 0x00),
99         ILI9881C_COMMAND_INSTR(0x12, 0x00),
100         ILI9881C_COMMAND_INSTR(0x13, 0x00),
101         ILI9881C_COMMAND_INSTR(0x14, 0x00),
102         ILI9881C_COMMAND_INSTR(0x15, 0x00),
103         ILI9881C_COMMAND_INSTR(0x16, 0x0C),
104         ILI9881C_COMMAND_INSTR(0x17, 0x00),
105         ILI9881C_COMMAND_INSTR(0x18, 0x00),
106         ILI9881C_COMMAND_INSTR(0x19, 0x00),
107         ILI9881C_COMMAND_INSTR(0x1a, 0x00),
108         ILI9881C_COMMAND_INSTR(0x1b, 0x00),
109         ILI9881C_COMMAND_INSTR(0x1c, 0x00),
110         ILI9881C_COMMAND_INSTR(0x1d, 0x00),
111         ILI9881C_COMMAND_INSTR(0x1e, 0xC0),
112         ILI9881C_COMMAND_INSTR(0x1f, 0x80),
113         ILI9881C_COMMAND_INSTR(0x20, 0x04),
114         ILI9881C_COMMAND_INSTR(0x21, 0x01),
115         ILI9881C_COMMAND_INSTR(0x22, 0x00),
116         ILI9881C_COMMAND_INSTR(0x23, 0x00),
117         ILI9881C_COMMAND_INSTR(0x24, 0x00),
118         ILI9881C_COMMAND_INSTR(0x25, 0x00),
119         ILI9881C_COMMAND_INSTR(0x26, 0x00),
120         ILI9881C_COMMAND_INSTR(0x27, 0x00),
121         ILI9881C_COMMAND_INSTR(0x28, 0x33),
122         ILI9881C_COMMAND_INSTR(0x29, 0x03),
123         ILI9881C_COMMAND_INSTR(0x2a, 0x00),
124         ILI9881C_COMMAND_INSTR(0x2b, 0x00),
125         ILI9881C_COMMAND_INSTR(0x2c, 0x00),
126         ILI9881C_COMMAND_INSTR(0x2d, 0x00),
127         ILI9881C_COMMAND_INSTR(0x2e, 0x00),
128         ILI9881C_COMMAND_INSTR(0x2f, 0x00),
129         ILI9881C_COMMAND_INSTR(0x30, 0x00),
130         ILI9881C_COMMAND_INSTR(0x31, 0x00),
131         ILI9881C_COMMAND_INSTR(0x32, 0x00),
132         ILI9881C_COMMAND_INSTR(0x33, 0x00),
133         ILI9881C_COMMAND_INSTR(0x34, 0x04),
134         ILI9881C_COMMAND_INSTR(0x35, 0x00),
135         ILI9881C_COMMAND_INSTR(0x36, 0x00),
136         ILI9881C_COMMAND_INSTR(0x37, 0x00),
137         ILI9881C_COMMAND_INSTR(0x38, 0x3C),
138         ILI9881C_COMMAND_INSTR(0x39, 0x00),
139         ILI9881C_COMMAND_INSTR(0x3a, 0x00),
140         ILI9881C_COMMAND_INSTR(0x3b, 0x00),
141         ILI9881C_COMMAND_INSTR(0x3c, 0x00),
142         ILI9881C_COMMAND_INSTR(0x3d, 0x00),
143         ILI9881C_COMMAND_INSTR(0x3e, 0x00),
144         ILI9881C_COMMAND_INSTR(0x3f, 0x00),
145         ILI9881C_COMMAND_INSTR(0x40, 0x00),
146         ILI9881C_COMMAND_INSTR(0x41, 0x00),
147         ILI9881C_COMMAND_INSTR(0x42, 0x00),
148         ILI9881C_COMMAND_INSTR(0x43, 0x00),
149         ILI9881C_COMMAND_INSTR(0x44, 0x00),
150         ILI9881C_COMMAND_INSTR(0x50, 0x01),
151         ILI9881C_COMMAND_INSTR(0x51, 0x23),
152         ILI9881C_COMMAND_INSTR(0x52, 0x45),
153         ILI9881C_COMMAND_INSTR(0x53, 0x67),
154         ILI9881C_COMMAND_INSTR(0x54, 0x89),
155         ILI9881C_COMMAND_INSTR(0x55, 0xab),
156         ILI9881C_COMMAND_INSTR(0x56, 0x01),
157         ILI9881C_COMMAND_INSTR(0x57, 0x23),
158         ILI9881C_COMMAND_INSTR(0x58, 0x45),
159         ILI9881C_COMMAND_INSTR(0x59, 0x67),
160         ILI9881C_COMMAND_INSTR(0x5a, 0x89),
161         ILI9881C_COMMAND_INSTR(0x5b, 0xab),
162         ILI9881C_COMMAND_INSTR(0x5c, 0xcd),
163         ILI9881C_COMMAND_INSTR(0x5d, 0xef),
164         ILI9881C_COMMAND_INSTR(0x5e, 0x11),
165         ILI9881C_COMMAND_INSTR(0x5f, 0x02),
166         ILI9881C_COMMAND_INSTR(0x60, 0x02),
167         ILI9881C_COMMAND_INSTR(0x61, 0x02),
168         ILI9881C_COMMAND_INSTR(0x62, 0x02),
169         ILI9881C_COMMAND_INSTR(0x63, 0x02),
170         ILI9881C_COMMAND_INSTR(0x64, 0x02),
171         ILI9881C_COMMAND_INSTR(0x65, 0x02),
172         ILI9881C_COMMAND_INSTR(0x66, 0x02),
173         ILI9881C_COMMAND_INSTR(0x67, 0x02),
174         ILI9881C_COMMAND_INSTR(0x68, 0x02),
175         ILI9881C_COMMAND_INSTR(0x69, 0x02),
176         ILI9881C_COMMAND_INSTR(0x6a, 0x0C),
177         ILI9881C_COMMAND_INSTR(0x6b, 0x02),
178         ILI9881C_COMMAND_INSTR(0x6c, 0x0F),
179         ILI9881C_COMMAND_INSTR(0x6d, 0x0E),
180         ILI9881C_COMMAND_INSTR(0x6e, 0x0D),
181         ILI9881C_COMMAND_INSTR(0x6f, 0x06),
182         ILI9881C_COMMAND_INSTR(0x70, 0x07),
183         ILI9881C_COMMAND_INSTR(0x71, 0x02),
184         ILI9881C_COMMAND_INSTR(0x72, 0x02),
185         ILI9881C_COMMAND_INSTR(0x73, 0x02),
186         ILI9881C_COMMAND_INSTR(0x74, 0x02),
187         ILI9881C_COMMAND_INSTR(0x75, 0x02),
188         ILI9881C_COMMAND_INSTR(0x76, 0x02),
189         ILI9881C_COMMAND_INSTR(0x77, 0x02),
190         ILI9881C_COMMAND_INSTR(0x78, 0x02),
191         ILI9881C_COMMAND_INSTR(0x79, 0x02),
192         ILI9881C_COMMAND_INSTR(0x7a, 0x02),
193         ILI9881C_COMMAND_INSTR(0x7b, 0x02),
194         ILI9881C_COMMAND_INSTR(0x7c, 0x02),
195         ILI9881C_COMMAND_INSTR(0x7d, 0x02),
196         ILI9881C_COMMAND_INSTR(0x7e, 0x02),
197         ILI9881C_COMMAND_INSTR(0x7f, 0x02),
198         ILI9881C_COMMAND_INSTR(0x80, 0x0C),
199         ILI9881C_COMMAND_INSTR(0x81, 0x02),
200         ILI9881C_COMMAND_INSTR(0x82, 0x0F),
201         ILI9881C_COMMAND_INSTR(0x83, 0x0E),
202         ILI9881C_COMMAND_INSTR(0x84, 0x0D),
203         ILI9881C_COMMAND_INSTR(0x85, 0x06),
204         ILI9881C_COMMAND_INSTR(0x86, 0x07),
205         ILI9881C_COMMAND_INSTR(0x87, 0x02),
206         ILI9881C_COMMAND_INSTR(0x88, 0x02),
207         ILI9881C_COMMAND_INSTR(0x89, 0x02),
208         ILI9881C_COMMAND_INSTR(0x8A, 0x02),
209         ILI9881C_SWITCH_PAGE_INSTR(4),
210         ILI9881C_COMMAND_INSTR(0x6C, 0x15),
211         ILI9881C_COMMAND_INSTR(0x6E, 0x22),
212         ILI9881C_COMMAND_INSTR(0x6F, 0x33),
213         ILI9881C_COMMAND_INSTR(0x3A, 0xA4),
214         ILI9881C_COMMAND_INSTR(0x8D, 0x0D),
215         ILI9881C_COMMAND_INSTR(0x87, 0xBA),
216         ILI9881C_COMMAND_INSTR(0x26, 0x76),
217         ILI9881C_COMMAND_INSTR(0xB2, 0xD1),
218         ILI9881C_SWITCH_PAGE_INSTR(1),
219         ILI9881C_COMMAND_INSTR(0x22, 0x0A),
220         ILI9881C_COMMAND_INSTR(0x53, 0xDC),
221         ILI9881C_COMMAND_INSTR(0x55, 0xA7),
222         ILI9881C_COMMAND_INSTR(0x50, 0x78),
223         ILI9881C_COMMAND_INSTR(0x51, 0x78),
224         ILI9881C_COMMAND_INSTR(0x31, 0x02),
225         ILI9881C_COMMAND_INSTR(0x60, 0x14),
226         ILI9881C_COMMAND_INSTR(0xA0, 0x2A),
227         ILI9881C_COMMAND_INSTR(0xA1, 0x39),
228         ILI9881C_COMMAND_INSTR(0xA2, 0x46),
229         ILI9881C_COMMAND_INSTR(0xA3, 0x0e),
230         ILI9881C_COMMAND_INSTR(0xA4, 0x12),
231         ILI9881C_COMMAND_INSTR(0xA5, 0x25),
232         ILI9881C_COMMAND_INSTR(0xA6, 0x19),
233         ILI9881C_COMMAND_INSTR(0xA7, 0x1d),
234         ILI9881C_COMMAND_INSTR(0xA8, 0xa6),
235         ILI9881C_COMMAND_INSTR(0xA9, 0x1C),
236         ILI9881C_COMMAND_INSTR(0xAA, 0x29),
237         ILI9881C_COMMAND_INSTR(0xAB, 0x85),
238         ILI9881C_COMMAND_INSTR(0xAC, 0x1C),
239         ILI9881C_COMMAND_INSTR(0xAD, 0x1B),
240         ILI9881C_COMMAND_INSTR(0xAE, 0x51),
241         ILI9881C_COMMAND_INSTR(0xAF, 0x22),
242         ILI9881C_COMMAND_INSTR(0xB0, 0x2d),
243         ILI9881C_COMMAND_INSTR(0xB1, 0x4f),
244         ILI9881C_COMMAND_INSTR(0xB2, 0x59),
245         ILI9881C_COMMAND_INSTR(0xB3, 0x3F),
246         ILI9881C_COMMAND_INSTR(0xC0, 0x2A),
247         ILI9881C_COMMAND_INSTR(0xC1, 0x3a),
248         ILI9881C_COMMAND_INSTR(0xC2, 0x45),
249         ILI9881C_COMMAND_INSTR(0xC3, 0x0e),
250         ILI9881C_COMMAND_INSTR(0xC4, 0x11),
251         ILI9881C_COMMAND_INSTR(0xC5, 0x24),
252         ILI9881C_COMMAND_INSTR(0xC6, 0x1a),
253         ILI9881C_COMMAND_INSTR(0xC7, 0x1c),
254         ILI9881C_COMMAND_INSTR(0xC8, 0xaa),
255         ILI9881C_COMMAND_INSTR(0xC9, 0x1C),
256         ILI9881C_COMMAND_INSTR(0xCA, 0x29),
257         ILI9881C_COMMAND_INSTR(0xCB, 0x96),
258         ILI9881C_COMMAND_INSTR(0xCC, 0x1C),
259         ILI9881C_COMMAND_INSTR(0xCD, 0x1B),
260         ILI9881C_COMMAND_INSTR(0xCE, 0x51),
261         ILI9881C_COMMAND_INSTR(0xCF, 0x22),
262         ILI9881C_COMMAND_INSTR(0xD0, 0x2b),
263         ILI9881C_COMMAND_INSTR(0xD1, 0x4b),
264         ILI9881C_COMMAND_INSTR(0xD2, 0x59),
265         ILI9881C_COMMAND_INSTR(0xD3, 0x3F),
266 };
267
268 static const struct ili9881c_instr k101_im2byl02_init[] = {
269         ILI9881C_SWITCH_PAGE_INSTR(3),
270         ILI9881C_COMMAND_INSTR(0x01, 0x00),
271         ILI9881C_COMMAND_INSTR(0x02, 0x00),
272         ILI9881C_COMMAND_INSTR(0x03, 0x73),
273         ILI9881C_COMMAND_INSTR(0x04, 0x00),
274         ILI9881C_COMMAND_INSTR(0x05, 0x00),
275         ILI9881C_COMMAND_INSTR(0x06, 0x08),
276         ILI9881C_COMMAND_INSTR(0x07, 0x00),
277         ILI9881C_COMMAND_INSTR(0x08, 0x00),
278         ILI9881C_COMMAND_INSTR(0x09, 0x00),
279         ILI9881C_COMMAND_INSTR(0x0A, 0x01),
280         ILI9881C_COMMAND_INSTR(0x0B, 0x01),
281         ILI9881C_COMMAND_INSTR(0x0C, 0x00),
282         ILI9881C_COMMAND_INSTR(0x0D, 0x01),
283         ILI9881C_COMMAND_INSTR(0x0E, 0x01),
284         ILI9881C_COMMAND_INSTR(0x0F, 0x00),
285         ILI9881C_COMMAND_INSTR(0x10, 0x00),
286         ILI9881C_COMMAND_INSTR(0x11, 0x00),
287         ILI9881C_COMMAND_INSTR(0x12, 0x00),
288         ILI9881C_COMMAND_INSTR(0x13, 0x00),
289         ILI9881C_COMMAND_INSTR(0x14, 0x00),
290         ILI9881C_COMMAND_INSTR(0x15, 0x00),
291         ILI9881C_COMMAND_INSTR(0x16, 0x00),
292         ILI9881C_COMMAND_INSTR(0x17, 0x00),
293         ILI9881C_COMMAND_INSTR(0x18, 0x00),
294         ILI9881C_COMMAND_INSTR(0x19, 0x00),
295         ILI9881C_COMMAND_INSTR(0x1A, 0x00),
296         ILI9881C_COMMAND_INSTR(0x1B, 0x00),
297         ILI9881C_COMMAND_INSTR(0x1C, 0x00),
298         ILI9881C_COMMAND_INSTR(0x1D, 0x00),
299         ILI9881C_COMMAND_INSTR(0x1E, 0x40),
300         ILI9881C_COMMAND_INSTR(0x1F, 0xC0),
301         ILI9881C_COMMAND_INSTR(0x20, 0x06),
302         ILI9881C_COMMAND_INSTR(0x21, 0x01),
303         ILI9881C_COMMAND_INSTR(0x22, 0x06),
304         ILI9881C_COMMAND_INSTR(0x23, 0x01),
305         ILI9881C_COMMAND_INSTR(0x24, 0x88),
306         ILI9881C_COMMAND_INSTR(0x25, 0x88),
307         ILI9881C_COMMAND_INSTR(0x26, 0x00),
308         ILI9881C_COMMAND_INSTR(0x27, 0x00),
309         ILI9881C_COMMAND_INSTR(0x28, 0x3B),
310         ILI9881C_COMMAND_INSTR(0x29, 0x03),
311         ILI9881C_COMMAND_INSTR(0x2A, 0x00),
312         ILI9881C_COMMAND_INSTR(0x2B, 0x00),
313         ILI9881C_COMMAND_INSTR(0x2C, 0x00),
314         ILI9881C_COMMAND_INSTR(0x2D, 0x00),
315         ILI9881C_COMMAND_INSTR(0x2E, 0x00),
316         ILI9881C_COMMAND_INSTR(0x2F, 0x00),
317         ILI9881C_COMMAND_INSTR(0x30, 0x00),
318         ILI9881C_COMMAND_INSTR(0x31, 0x00),
319         ILI9881C_COMMAND_INSTR(0x32, 0x00),
320         ILI9881C_COMMAND_INSTR(0x33, 0x00),
321         ILI9881C_COMMAND_INSTR(0x34, 0x00), /* GPWR1/2 non overlap time 2.62us */
322         ILI9881C_COMMAND_INSTR(0x35, 0x00),
323         ILI9881C_COMMAND_INSTR(0x36, 0x00),
324         ILI9881C_COMMAND_INSTR(0x37, 0x00),
325         ILI9881C_COMMAND_INSTR(0x38, 0x00),
326         ILI9881C_COMMAND_INSTR(0x39, 0x00),
327         ILI9881C_COMMAND_INSTR(0x3A, 0x00),
328         ILI9881C_COMMAND_INSTR(0x3B, 0x00),
329         ILI9881C_COMMAND_INSTR(0x3C, 0x00),
330         ILI9881C_COMMAND_INSTR(0x3D, 0x00),
331         ILI9881C_COMMAND_INSTR(0x3E, 0x00),
332         ILI9881C_COMMAND_INSTR(0x3F, 0x00),
333         ILI9881C_COMMAND_INSTR(0x40, 0x00),
334         ILI9881C_COMMAND_INSTR(0x41, 0x00),
335         ILI9881C_COMMAND_INSTR(0x42, 0x00),
336         ILI9881C_COMMAND_INSTR(0x43, 0x00),
337         ILI9881C_COMMAND_INSTR(0x44, 0x00),
338         ILI9881C_COMMAND_INSTR(0x50, 0x01),
339         ILI9881C_COMMAND_INSTR(0x51, 0x23),
340         ILI9881C_COMMAND_INSTR(0x52, 0x45),
341         ILI9881C_COMMAND_INSTR(0x53, 0x67),
342         ILI9881C_COMMAND_INSTR(0x54, 0x89),
343         ILI9881C_COMMAND_INSTR(0x55, 0xAB),
344         ILI9881C_COMMAND_INSTR(0x56, 0x01),
345         ILI9881C_COMMAND_INSTR(0x57, 0x23),
346         ILI9881C_COMMAND_INSTR(0x58, 0x45),
347         ILI9881C_COMMAND_INSTR(0x59, 0x67),
348         ILI9881C_COMMAND_INSTR(0x5A, 0x89),
349         ILI9881C_COMMAND_INSTR(0x5B, 0xAB),
350         ILI9881C_COMMAND_INSTR(0x5C, 0xCD),
351         ILI9881C_COMMAND_INSTR(0x5D, 0xEF),
352         ILI9881C_COMMAND_INSTR(0x5E, 0x00),
353         ILI9881C_COMMAND_INSTR(0x5F, 0x01),
354         ILI9881C_COMMAND_INSTR(0x60, 0x01),
355         ILI9881C_COMMAND_INSTR(0x61, 0x06),
356         ILI9881C_COMMAND_INSTR(0x62, 0x06),
357         ILI9881C_COMMAND_INSTR(0x63, 0x07),
358         ILI9881C_COMMAND_INSTR(0x64, 0x07),
359         ILI9881C_COMMAND_INSTR(0x65, 0x00),
360         ILI9881C_COMMAND_INSTR(0x66, 0x00),
361         ILI9881C_COMMAND_INSTR(0x67, 0x02),
362         ILI9881C_COMMAND_INSTR(0x68, 0x02),
363         ILI9881C_COMMAND_INSTR(0x69, 0x05),
364         ILI9881C_COMMAND_INSTR(0x6A, 0x05),
365         ILI9881C_COMMAND_INSTR(0x6B, 0x02),
366         ILI9881C_COMMAND_INSTR(0x6C, 0x0D),
367         ILI9881C_COMMAND_INSTR(0x6D, 0x0D),
368         ILI9881C_COMMAND_INSTR(0x6E, 0x0C),
369         ILI9881C_COMMAND_INSTR(0x6F, 0x0C),
370         ILI9881C_COMMAND_INSTR(0x70, 0x0F),
371         ILI9881C_COMMAND_INSTR(0x71, 0x0F),
372         ILI9881C_COMMAND_INSTR(0x72, 0x0E),
373         ILI9881C_COMMAND_INSTR(0x73, 0x0E),
374         ILI9881C_COMMAND_INSTR(0x74, 0x02),
375         ILI9881C_COMMAND_INSTR(0x75, 0x01),
376         ILI9881C_COMMAND_INSTR(0x76, 0x01),
377         ILI9881C_COMMAND_INSTR(0x77, 0x06),
378         ILI9881C_COMMAND_INSTR(0x78, 0x06),
379         ILI9881C_COMMAND_INSTR(0x79, 0x07),
380         ILI9881C_COMMAND_INSTR(0x7A, 0x07),
381         ILI9881C_COMMAND_INSTR(0x7B, 0x00),
382         ILI9881C_COMMAND_INSTR(0x7C, 0x00),
383         ILI9881C_COMMAND_INSTR(0x7D, 0x02),
384         ILI9881C_COMMAND_INSTR(0x7E, 0x02),
385         ILI9881C_COMMAND_INSTR(0x7F, 0x05),
386         ILI9881C_COMMAND_INSTR(0x80, 0x05),
387         ILI9881C_COMMAND_INSTR(0x81, 0x02),
388         ILI9881C_COMMAND_INSTR(0x82, 0x0D),
389         ILI9881C_COMMAND_INSTR(0x83, 0x0D),
390         ILI9881C_COMMAND_INSTR(0x84, 0x0C),
391         ILI9881C_COMMAND_INSTR(0x85, 0x0C),
392         ILI9881C_COMMAND_INSTR(0x86, 0x0F),
393         ILI9881C_COMMAND_INSTR(0x87, 0x0F),
394         ILI9881C_COMMAND_INSTR(0x88, 0x0E),
395         ILI9881C_COMMAND_INSTR(0x89, 0x0E),
396         ILI9881C_COMMAND_INSTR(0x8A, 0x02),
397         ILI9881C_SWITCH_PAGE_INSTR(4),
398         ILI9881C_COMMAND_INSTR(0x3B, 0xC0), /* ILI4003D sel */
399         ILI9881C_COMMAND_INSTR(0x6C, 0x15), /* Set VCORE voltage = 1.5V */
400         ILI9881C_COMMAND_INSTR(0x6E, 0x2A), /* di_pwr_reg=0 for power mode 2A, VGH clamp 18V */
401         ILI9881C_COMMAND_INSTR(0x6F, 0x33), /* pumping ratio VGH=5x VGL=-3x */
402         ILI9881C_COMMAND_INSTR(0x8D, 0x1B), /* VGL clamp -10V */
403         ILI9881C_COMMAND_INSTR(0x87, 0xBA), /* ESD */
404         ILI9881C_COMMAND_INSTR(0x3A, 0x24), /* POWER SAVING */
405         ILI9881C_COMMAND_INSTR(0x26, 0x76),
406         ILI9881C_COMMAND_INSTR(0xB2, 0xD1),
407         ILI9881C_SWITCH_PAGE_INSTR(1),
408         ILI9881C_COMMAND_INSTR(0x22, 0x0A), /* BGR, SS */
409         ILI9881C_COMMAND_INSTR(0x31, 0x00), /* Zigzag type3 inversion */
410         ILI9881C_COMMAND_INSTR(0x40, 0x53), /* ILI4003D sel */
411         ILI9881C_COMMAND_INSTR(0x43, 0x66),
412         ILI9881C_COMMAND_INSTR(0x53, 0x4C),
413         ILI9881C_COMMAND_INSTR(0x50, 0x87),
414         ILI9881C_COMMAND_INSTR(0x51, 0x82),
415         ILI9881C_COMMAND_INSTR(0x60, 0x15),
416         ILI9881C_COMMAND_INSTR(0x61, 0x01),
417         ILI9881C_COMMAND_INSTR(0x62, 0x0C),
418         ILI9881C_COMMAND_INSTR(0x63, 0x00),
419         ILI9881C_COMMAND_INSTR(0xA0, 0x00),
420         ILI9881C_COMMAND_INSTR(0xA1, 0x13), /* VP251 */
421         ILI9881C_COMMAND_INSTR(0xA2, 0x23), /* VP247 */
422         ILI9881C_COMMAND_INSTR(0xA3, 0x14), /* VP243 */
423         ILI9881C_COMMAND_INSTR(0xA4, 0x16), /* VP239 */
424         ILI9881C_COMMAND_INSTR(0xA5, 0x29), /* VP231 */
425         ILI9881C_COMMAND_INSTR(0xA6, 0x1E), /* VP219 */
426         ILI9881C_COMMAND_INSTR(0xA7, 0x1D), /* VP203 */
427         ILI9881C_COMMAND_INSTR(0xA8, 0x86), /* VP175 */
428         ILI9881C_COMMAND_INSTR(0xA9, 0x1E), /* VP144 */
429         ILI9881C_COMMAND_INSTR(0xAA, 0x29), /* VP111 */
430         ILI9881C_COMMAND_INSTR(0xAB, 0x74), /* VP80 */
431         ILI9881C_COMMAND_INSTR(0xAC, 0x19), /* VP52 */
432         ILI9881C_COMMAND_INSTR(0xAD, 0x17), /* VP36 */
433         ILI9881C_COMMAND_INSTR(0xAE, 0x4B), /* VP24 */
434         ILI9881C_COMMAND_INSTR(0xAF, 0x20), /* VP16 */
435         ILI9881C_COMMAND_INSTR(0xB0, 0x26), /* VP12 */
436         ILI9881C_COMMAND_INSTR(0xB1, 0x4C), /* VP8 */
437         ILI9881C_COMMAND_INSTR(0xB2, 0x5D), /* VP4 */
438         ILI9881C_COMMAND_INSTR(0xB3, 0x3F), /* VP0 */
439         ILI9881C_COMMAND_INSTR(0xC0, 0x00), /* VN255 GAMMA N */
440         ILI9881C_COMMAND_INSTR(0xC1, 0x13), /* VN251 */
441         ILI9881C_COMMAND_INSTR(0xC2, 0x23), /* VN247 */
442         ILI9881C_COMMAND_INSTR(0xC3, 0x14), /* VN243 */
443         ILI9881C_COMMAND_INSTR(0xC4, 0x16), /* VN239 */
444         ILI9881C_COMMAND_INSTR(0xC5, 0x29), /* VN231 */
445         ILI9881C_COMMAND_INSTR(0xC6, 0x1E), /* VN219 */
446         ILI9881C_COMMAND_INSTR(0xC7, 0x1D), /* VN203 */
447         ILI9881C_COMMAND_INSTR(0xC8, 0x86), /* VN175 */
448         ILI9881C_COMMAND_INSTR(0xC9, 0x1E), /* VN144 */
449         ILI9881C_COMMAND_INSTR(0xCA, 0x29), /* VN111 */
450         ILI9881C_COMMAND_INSTR(0xCB, 0x74), /* VN80 */
451         ILI9881C_COMMAND_INSTR(0xCC, 0x19), /* VN52 */
452         ILI9881C_COMMAND_INSTR(0xCD, 0x17), /* VN36 */
453         ILI9881C_COMMAND_INSTR(0xCE, 0x4B), /* VN24 */
454         ILI9881C_COMMAND_INSTR(0xCF, 0x20), /* VN16 */
455         ILI9881C_COMMAND_INSTR(0xD0, 0x26), /* VN12 */
456         ILI9881C_COMMAND_INSTR(0xD1, 0x4C), /* VN8 */
457         ILI9881C_COMMAND_INSTR(0xD2, 0x5D), /* VN4 */
458         ILI9881C_COMMAND_INSTR(0xD3, 0x3F), /* VN0 */
459 };
460
461 static const struct ili9881c_instr nwe080_init[] = {
462         ILI9881C_SWITCH_PAGE_INSTR(3),
463         //GIP_1
464         ILI9881C_COMMAND_INSTR(0x01, 0x00),
465         ILI9881C_COMMAND_INSTR(0x02, 0x00),
466         ILI9881C_COMMAND_INSTR(0x03, 0x73),
467         ILI9881C_COMMAND_INSTR(0x04, 0x00),
468         ILI9881C_COMMAND_INSTR(0x05, 0x00),
469         ILI9881C_COMMAND_INSTR(0x06, 0x0A),
470         ILI9881C_COMMAND_INSTR(0x07, 0x00),
471         ILI9881C_COMMAND_INSTR(0x08, 0x00),
472         ILI9881C_COMMAND_INSTR(0x09, 0x20),
473         ILI9881C_COMMAND_INSTR(0x0a, 0x20),
474         ILI9881C_COMMAND_INSTR(0x0b, 0x00),
475         ILI9881C_COMMAND_INSTR(0x0c, 0x00),
476         ILI9881C_COMMAND_INSTR(0x0d, 0x00),
477         ILI9881C_COMMAND_INSTR(0x0e, 0x00),
478         ILI9881C_COMMAND_INSTR(0x0f, 0x1E),
479         ILI9881C_COMMAND_INSTR(0x10, 0x1E),
480         ILI9881C_COMMAND_INSTR(0x11, 0x00),
481         ILI9881C_COMMAND_INSTR(0x12, 0x00),
482         ILI9881C_COMMAND_INSTR(0x13, 0x00),
483         ILI9881C_COMMAND_INSTR(0x14, 0x00),
484         ILI9881C_COMMAND_INSTR(0x15, 0x00),
485         ILI9881C_COMMAND_INSTR(0x16, 0x00),
486         ILI9881C_COMMAND_INSTR(0x17, 0x00),
487         ILI9881C_COMMAND_INSTR(0x18, 0x00),
488         ILI9881C_COMMAND_INSTR(0x19, 0x00),
489         ILI9881C_COMMAND_INSTR(0x1A, 0x00),
490         ILI9881C_COMMAND_INSTR(0x1B, 0x00),
491         ILI9881C_COMMAND_INSTR(0x1C, 0x00),
492         ILI9881C_COMMAND_INSTR(0x1D, 0x00),
493         ILI9881C_COMMAND_INSTR(0x1E, 0x40),
494         ILI9881C_COMMAND_INSTR(0x1F, 0x80),
495         ILI9881C_COMMAND_INSTR(0x20, 0x06),
496         ILI9881C_COMMAND_INSTR(0x21, 0x01),
497         ILI9881C_COMMAND_INSTR(0x22, 0x00),
498         ILI9881C_COMMAND_INSTR(0x23, 0x00),
499         ILI9881C_COMMAND_INSTR(0x24, 0x00),
500         ILI9881C_COMMAND_INSTR(0x25, 0x00),
501         ILI9881C_COMMAND_INSTR(0x26, 0x00),
502         ILI9881C_COMMAND_INSTR(0x27, 0x00),
503         ILI9881C_COMMAND_INSTR(0x28, 0x33),
504         ILI9881C_COMMAND_INSTR(0x29, 0x03),
505         ILI9881C_COMMAND_INSTR(0x2A, 0x00),
506         ILI9881C_COMMAND_INSTR(0x2B, 0x00),
507         ILI9881C_COMMAND_INSTR(0x2C, 0x00),
508         ILI9881C_COMMAND_INSTR(0x2D, 0x00),
509         ILI9881C_COMMAND_INSTR(0x2E, 0x00),
510         ILI9881C_COMMAND_INSTR(0x2F, 0x00),
511
512         ILI9881C_COMMAND_INSTR(0x30, 0x00),
513         ILI9881C_COMMAND_INSTR(0x31, 0x00),
514         ILI9881C_COMMAND_INSTR(0x32, 0x00),
515         ILI9881C_COMMAND_INSTR(0x33, 0x00),
516         ILI9881C_COMMAND_INSTR(0x34, 0x04),
517         ILI9881C_COMMAND_INSTR(0x35, 0x00),
518         ILI9881C_COMMAND_INSTR(0x36, 0x00),
519         ILI9881C_COMMAND_INSTR(0x37, 0x00),
520         ILI9881C_COMMAND_INSTR(0x38, 0x3C),
521         ILI9881C_COMMAND_INSTR(0x39, 0x00),
522         ILI9881C_COMMAND_INSTR(0x3A, 0x00),
523         ILI9881C_COMMAND_INSTR(0x3B, 0x00),
524         ILI9881C_COMMAND_INSTR(0x3C, 0x00),
525         ILI9881C_COMMAND_INSTR(0x3D, 0x00),
526         ILI9881C_COMMAND_INSTR(0x3E, 0x00),
527         ILI9881C_COMMAND_INSTR(0x3F, 0x00),
528
529         ILI9881C_COMMAND_INSTR(0x40, 0x00),
530         ILI9881C_COMMAND_INSTR(0x41, 0x00),
531         ILI9881C_COMMAND_INSTR(0x42, 0x00),
532         ILI9881C_COMMAND_INSTR(0x43, 0x00),
533         ILI9881C_COMMAND_INSTR(0x44, 0x00),
534
535         ILI9881C_COMMAND_INSTR(0x50, 0x10),
536         ILI9881C_COMMAND_INSTR(0x51, 0x32),
537         ILI9881C_COMMAND_INSTR(0x52, 0x54),
538         ILI9881C_COMMAND_INSTR(0x53, 0x76),
539         ILI9881C_COMMAND_INSTR(0x54, 0x98),
540         ILI9881C_COMMAND_INSTR(0x55, 0xba),
541         ILI9881C_COMMAND_INSTR(0x56, 0x10),
542         ILI9881C_COMMAND_INSTR(0x57, 0x32),
543         ILI9881C_COMMAND_INSTR(0x58, 0x54),
544         ILI9881C_COMMAND_INSTR(0x59, 0x76),
545         ILI9881C_COMMAND_INSTR(0x5A, 0x98),
546         ILI9881C_COMMAND_INSTR(0x5B, 0xba),
547         ILI9881C_COMMAND_INSTR(0x5C, 0xdc),
548         ILI9881C_COMMAND_INSTR(0x5D, 0xfe),
549
550         //GIP_3
551         ILI9881C_COMMAND_INSTR(0x5E, 0x00),
552         ILI9881C_COMMAND_INSTR(0x5F, 0x01),
553         ILI9881C_COMMAND_INSTR(0x60, 0x00),
554         ILI9881C_COMMAND_INSTR(0x61, 0x15),
555         ILI9881C_COMMAND_INSTR(0x62, 0x14),
556         ILI9881C_COMMAND_INSTR(0x63, 0x0E),
557         ILI9881C_COMMAND_INSTR(0x64, 0x0F),
558         ILI9881C_COMMAND_INSTR(0x65, 0x0C),
559         ILI9881C_COMMAND_INSTR(0x66, 0x0D),
560         ILI9881C_COMMAND_INSTR(0x67, 0x06),
561         ILI9881C_COMMAND_INSTR(0x68, 0x02),
562         ILI9881C_COMMAND_INSTR(0x69, 0x02),
563         ILI9881C_COMMAND_INSTR(0x6A, 0x02),
564         ILI9881C_COMMAND_INSTR(0x6B, 0x02),
565         ILI9881C_COMMAND_INSTR(0x6C, 0x02),
566         ILI9881C_COMMAND_INSTR(0x6D, 0x02),
567         ILI9881C_COMMAND_INSTR(0x6E, 0x07),
568         ILI9881C_COMMAND_INSTR(0x6F, 0x02),
569
570         ILI9881C_COMMAND_INSTR(0x70, 0x02),
571         ILI9881C_COMMAND_INSTR(0x71, 0x02),
572         ILI9881C_COMMAND_INSTR(0x72, 0x02),
573         ILI9881C_COMMAND_INSTR(0x73, 0x02),
574         ILI9881C_COMMAND_INSTR(0x74, 0x02),
575         ILI9881C_COMMAND_INSTR(0x75, 0x01),
576         ILI9881C_COMMAND_INSTR(0x76, 0x00),
577         ILI9881C_COMMAND_INSTR(0x77, 0x14),
578         ILI9881C_COMMAND_INSTR(0x78, 0x15),
579         ILI9881C_COMMAND_INSTR(0x79, 0x0E),
580         ILI9881C_COMMAND_INSTR(0x7A, 0x0F),
581         ILI9881C_COMMAND_INSTR(0x7B, 0x0C),
582         ILI9881C_COMMAND_INSTR(0x7C, 0x0D),
583         ILI9881C_COMMAND_INSTR(0x7D, 0x06),
584         ILI9881C_COMMAND_INSTR(0x7E, 0x02),
585         ILI9881C_COMMAND_INSTR(0x7F, 0x02),
586
587         ILI9881C_COMMAND_INSTR(0x80, 0x02),
588         ILI9881C_COMMAND_INSTR(0x81, 0x02),
589         ILI9881C_COMMAND_INSTR(0x82, 0x02),
590         ILI9881C_COMMAND_INSTR(0x83, 0x02),
591         ILI9881C_COMMAND_INSTR(0x84, 0x07),
592         ILI9881C_COMMAND_INSTR(0x85, 0x02),
593         ILI9881C_COMMAND_INSTR(0x86, 0x02),
594         ILI9881C_COMMAND_INSTR(0x87, 0x02),
595         ILI9881C_COMMAND_INSTR(0x88, 0x02),
596         ILI9881C_COMMAND_INSTR(0x89, 0x02),
597         ILI9881C_COMMAND_INSTR(0x8A, 0x02),
598
599         ILI9881C_SWITCH_PAGE_INSTR(4),
600         ILI9881C_COMMAND_INSTR(0x6C, 0x15),
601         ILI9881C_COMMAND_INSTR(0x6E, 0x2A),
602
603         //clamp 15V
604         ILI9881C_COMMAND_INSTR(0x6F, 0x35),
605         ILI9881C_COMMAND_INSTR(0x3A, 0x92),
606         ILI9881C_COMMAND_INSTR(0x8D, 0x1F),
607         ILI9881C_COMMAND_INSTR(0x87, 0xBA),
608         ILI9881C_COMMAND_INSTR(0x26, 0x76),
609         ILI9881C_COMMAND_INSTR(0xB2, 0xD1),
610         ILI9881C_COMMAND_INSTR(0xB5, 0x27),
611         ILI9881C_COMMAND_INSTR(0x31, 0x75),
612         ILI9881C_COMMAND_INSTR(0x30, 0x03),
613         ILI9881C_COMMAND_INSTR(0x3B, 0x98),
614         ILI9881C_COMMAND_INSTR(0x35, 0x17),
615         ILI9881C_COMMAND_INSTR(0x33, 0x14),
616         ILI9881C_COMMAND_INSTR(0x38, 0x01),
617         ILI9881C_COMMAND_INSTR(0x39, 0x00),
618
619         ILI9881C_SWITCH_PAGE_INSTR(1),
620         // direction rotate
621         //ILI9881C_COMMAND_INSTR(0x22, 0x0B),
622         ILI9881C_COMMAND_INSTR(0x22, 0x0A),
623         ILI9881C_COMMAND_INSTR(0x31, 0x00),
624         ILI9881C_COMMAND_INSTR(0x53, 0x63),
625         ILI9881C_COMMAND_INSTR(0x55, 0x69),
626         ILI9881C_COMMAND_INSTR(0x50, 0xC7),
627         ILI9881C_COMMAND_INSTR(0x51, 0xC2),
628         ILI9881C_COMMAND_INSTR(0x60, 0x26),
629
630         ILI9881C_COMMAND_INSTR(0xA0, 0x08),
631         ILI9881C_COMMAND_INSTR(0xA1, 0x0F),
632         ILI9881C_COMMAND_INSTR(0xA2, 0x25),
633         ILI9881C_COMMAND_INSTR(0xA3, 0x01),
634         ILI9881C_COMMAND_INSTR(0xA4, 0x23),
635         ILI9881C_COMMAND_INSTR(0xA5, 0x18),
636         ILI9881C_COMMAND_INSTR(0xA6, 0x11),
637         ILI9881C_COMMAND_INSTR(0xA7, 0x1A),
638         ILI9881C_COMMAND_INSTR(0xA8, 0x81),
639         ILI9881C_COMMAND_INSTR(0xA9, 0x19),
640         ILI9881C_COMMAND_INSTR(0xAA, 0x26),
641         ILI9881C_COMMAND_INSTR(0xAB, 0x7C),
642         ILI9881C_COMMAND_INSTR(0xAC, 0x24),
643         ILI9881C_COMMAND_INSTR(0xAD, 0x1E),
644         ILI9881C_COMMAND_INSTR(0xAE, 0x5C),
645         ILI9881C_COMMAND_INSTR(0xAF, 0x2A),
646         ILI9881C_COMMAND_INSTR(0xB0, 0x2B),
647         ILI9881C_COMMAND_INSTR(0xB1, 0x50),
648         ILI9881C_COMMAND_INSTR(0xB2, 0x5C),
649         ILI9881C_COMMAND_INSTR(0xB3, 0x39),
650
651         ILI9881C_COMMAND_INSTR(0xC0, 0x08),
652         ILI9881C_COMMAND_INSTR(0xC1, 0x1F),
653         ILI9881C_COMMAND_INSTR(0xC2, 0x24),
654         ILI9881C_COMMAND_INSTR(0xC3, 0x1D),
655         ILI9881C_COMMAND_INSTR(0xC4, 0x04),
656         ILI9881C_COMMAND_INSTR(0xC5, 0x32),
657         ILI9881C_COMMAND_INSTR(0xC6, 0x24),
658         ILI9881C_COMMAND_INSTR(0xC7, 0x1F),
659         ILI9881C_COMMAND_INSTR(0xC8, 0x90),
660         ILI9881C_COMMAND_INSTR(0xC9, 0x20),
661         ILI9881C_COMMAND_INSTR(0xCA, 0x2C),
662         ILI9881C_COMMAND_INSTR(0xCB, 0x82),
663         ILI9881C_COMMAND_INSTR(0xCC, 0x19),
664         ILI9881C_COMMAND_INSTR(0xCD, 0x22),
665         ILI9881C_COMMAND_INSTR(0xCE, 0x4E),
666         ILI9881C_COMMAND_INSTR(0xCF, 0x28),
667         ILI9881C_COMMAND_INSTR(0xD0, 0x2D),
668         ILI9881C_COMMAND_INSTR(0xD1, 0x51),
669         ILI9881C_COMMAND_INSTR(0xD2, 0x5D),
670         ILI9881C_COMMAND_INSTR(0xD3, 0x39),
671
672         ILI9881C_SWITCH_PAGE_INSTR(0),
673         //PWM
674         ILI9881C_COMMAND_INSTR(0x51, 0x0F),
675         ILI9881C_COMMAND_INSTR(0x52, 0xFF),
676         ILI9881C_COMMAND_INSTR(0x53, 0x2C),
677
678         ILI9881C_COMMAND_INSTR(0x11, 0x00),
679         ILI9881C_COMMAND_INSTR(0x29, 0x00),
680         ILI9881C_COMMAND_INSTR(0x35, 0x00),
681 };
682
683 static const struct ili9881c_instr tl050hdv35_init[] = {
684         ILI9881C_SWITCH_PAGE_INSTR(3),
685         ILI9881C_COMMAND_INSTR(0x01, 0x00),
686         ILI9881C_COMMAND_INSTR(0x02, 0x00),
687         ILI9881C_COMMAND_INSTR(0x03, 0x73),
688         ILI9881C_COMMAND_INSTR(0x04, 0x00),
689         ILI9881C_COMMAND_INSTR(0x05, 0x00),
690         ILI9881C_COMMAND_INSTR(0x06, 0x0a),
691         ILI9881C_COMMAND_INSTR(0x07, 0x00),
692         ILI9881C_COMMAND_INSTR(0x08, 0x00),
693         ILI9881C_COMMAND_INSTR(0x09, 0x01),
694         ILI9881C_COMMAND_INSTR(0x0a, 0x00),
695         ILI9881C_COMMAND_INSTR(0x0b, 0x00),
696         ILI9881C_COMMAND_INSTR(0x0c, 0x01),
697         ILI9881C_COMMAND_INSTR(0x0d, 0x00),
698         ILI9881C_COMMAND_INSTR(0x0e, 0x00),
699         ILI9881C_COMMAND_INSTR(0x0f, 0x1d),
700         ILI9881C_COMMAND_INSTR(0x10, 0x1d),
701         ILI9881C_COMMAND_INSTR(0x15, 0x00),
702         ILI9881C_COMMAND_INSTR(0x16, 0x00),
703         ILI9881C_COMMAND_INSTR(0x17, 0x00),
704         ILI9881C_COMMAND_INSTR(0x18, 0x00),
705         ILI9881C_COMMAND_INSTR(0x19, 0x00),
706         ILI9881C_COMMAND_INSTR(0x1a, 0x00),
707         ILI9881C_COMMAND_INSTR(0x1b, 0x00),
708         ILI9881C_COMMAND_INSTR(0x1c, 0x00),
709         ILI9881C_COMMAND_INSTR(0x1d, 0x00),
710         ILI9881C_COMMAND_INSTR(0x1e, 0x40),
711         ILI9881C_COMMAND_INSTR(0x1f, 0x80),
712         ILI9881C_COMMAND_INSTR(0x20, 0x06),
713         ILI9881C_COMMAND_INSTR(0x21, 0x02),
714         ILI9881C_COMMAND_INSTR(0x28, 0x33),
715         ILI9881C_COMMAND_INSTR(0x29, 0x03),
716         ILI9881C_COMMAND_INSTR(0x2a, 0x00),
717         ILI9881C_COMMAND_INSTR(0x2b, 0x00),
718         ILI9881C_COMMAND_INSTR(0x2c, 0x00),
719         ILI9881C_COMMAND_INSTR(0x2d, 0x00),
720         ILI9881C_COMMAND_INSTR(0x2e, 0x00),
721         ILI9881C_COMMAND_INSTR(0x2f, 0x00),
722         ILI9881C_COMMAND_INSTR(0x35, 0x00),
723         ILI9881C_COMMAND_INSTR(0x36, 0x00),
724         ILI9881C_COMMAND_INSTR(0x37, 0x00),
725         ILI9881C_COMMAND_INSTR(0x38, 0x3C),
726         ILI9881C_COMMAND_INSTR(0x39, 0x00),
727         ILI9881C_COMMAND_INSTR(0x3a, 0x40),
728         ILI9881C_COMMAND_INSTR(0x3b, 0x40),
729         ILI9881C_COMMAND_INSTR(0x3c, 0x00),
730         ILI9881C_COMMAND_INSTR(0x3d, 0x00),
731         ILI9881C_COMMAND_INSTR(0x3e, 0x00),
732         ILI9881C_COMMAND_INSTR(0x3f, 0x00),
733         ILI9881C_COMMAND_INSTR(0x40, 0x00),
734         ILI9881C_COMMAND_INSTR(0x41, 0x00),
735         ILI9881C_COMMAND_INSTR(0x42, 0x00),
736         ILI9881C_COMMAND_INSTR(0x43, 0x00),
737         ILI9881C_COMMAND_INSTR(0x44, 0x00),
738         ILI9881C_COMMAND_INSTR(0x55, 0xab),
739         ILI9881C_COMMAND_INSTR(0x5a, 0x89),
740         ILI9881C_COMMAND_INSTR(0x5b, 0xab),
741         ILI9881C_COMMAND_INSTR(0x5c, 0xcd),
742         ILI9881C_COMMAND_INSTR(0x5d, 0xef),
743         ILI9881C_COMMAND_INSTR(0x5e, 0x11),
744         ILI9881C_COMMAND_INSTR(0x5f, 0x01),
745         ILI9881C_COMMAND_INSTR(0x60, 0x00),
746         ILI9881C_COMMAND_INSTR(0x61, 0x15),
747         ILI9881C_COMMAND_INSTR(0x62, 0x14),
748         ILI9881C_COMMAND_INSTR(0x63, 0x0e),
749         ILI9881C_COMMAND_INSTR(0x64, 0x0f),
750         ILI9881C_COMMAND_INSTR(0x65, 0x0c),
751         ILI9881C_COMMAND_INSTR(0x66, 0x0d),
752         ILI9881C_COMMAND_INSTR(0x67, 0x06),
753         ILI9881C_COMMAND_INSTR(0x68, 0x02),
754         ILI9881C_COMMAND_INSTR(0x69, 0x07),
755         ILI9881C_COMMAND_INSTR(0x6a, 0x02),
756         ILI9881C_COMMAND_INSTR(0x6b, 0x02),
757         ILI9881C_COMMAND_INSTR(0x6c, 0x02),
758         ILI9881C_COMMAND_INSTR(0x6d, 0x02),
759         ILI9881C_COMMAND_INSTR(0x6e, 0x02),
760         ILI9881C_COMMAND_INSTR(0x6f, 0x02),
761         ILI9881C_COMMAND_INSTR(0x70, 0x02),
762         ILI9881C_COMMAND_INSTR(0x71, 0x02),
763         ILI9881C_COMMAND_INSTR(0x72, 0x02),
764         ILI9881C_COMMAND_INSTR(0x73, 0x02),
765         ILI9881C_COMMAND_INSTR(0x74, 0x02),
766         ILI9881C_COMMAND_INSTR(0x75, 0x01),
767         ILI9881C_COMMAND_INSTR(0x76, 0x00),
768         ILI9881C_COMMAND_INSTR(0x77, 0x14),
769         ILI9881C_COMMAND_INSTR(0x78, 0x15),
770         ILI9881C_COMMAND_INSTR(0x79, 0x0e),
771         ILI9881C_COMMAND_INSTR(0x7a, 0x0f),
772         ILI9881C_COMMAND_INSTR(0x7b, 0x0c),
773         ILI9881C_COMMAND_INSTR(0x7c, 0x0d),
774         ILI9881C_COMMAND_INSTR(0x7d, 0x06),
775         ILI9881C_COMMAND_INSTR(0x7e, 0x02),
776         ILI9881C_COMMAND_INSTR(0x7f, 0x07),
777         ILI9881C_COMMAND_INSTR(0x88, 0x02),
778         ILI9881C_COMMAND_INSTR(0x89, 0x02),
779         ILI9881C_COMMAND_INSTR(0x8A, 0x02),
780         ILI9881C_SWITCH_PAGE_INSTR(4),
781         ILI9881C_COMMAND_INSTR(0x38, 0x01),
782         ILI9881C_COMMAND_INSTR(0x39, 0x00),
783         ILI9881C_COMMAND_INSTR(0x6c, 0x15),
784         ILI9881C_COMMAND_INSTR(0x6e, 0x2b),
785         ILI9881C_COMMAND_INSTR(0x6f, 0x33),
786         ILI9881C_COMMAND_INSTR(0x8d, 0x18),
787         ILI9881C_COMMAND_INSTR(0x87, 0xba),
788         ILI9881C_COMMAND_INSTR(0x26, 0x76),
789         ILI9881C_COMMAND_INSTR(0xb2, 0xd1),
790         ILI9881C_COMMAND_INSTR(0xb5, 0x06),
791         ILI9881C_COMMAND_INSTR(0x3a, 0x24),
792         ILI9881C_COMMAND_INSTR(0x35, 0x1f),
793         ILI9881C_COMMAND_INSTR(0x33, 0x14),
794         ILI9881C_COMMAND_INSTR(0x3b, 0x98),
795         ILI9881C_SWITCH_PAGE_INSTR(1),
796         ILI9881C_COMMAND_INSTR(0x22, 0x0a),
797         ILI9881C_COMMAND_INSTR(0x31, 0x00),
798         ILI9881C_COMMAND_INSTR(0x40, 0x33),
799         ILI9881C_COMMAND_INSTR(0x53, 0xa2),
800         ILI9881C_COMMAND_INSTR(0x55, 0x92),
801         ILI9881C_COMMAND_INSTR(0x50, 0x96),
802         ILI9881C_COMMAND_INSTR(0x51, 0x96),
803         ILI9881C_COMMAND_INSTR(0x60, 0x22),
804         ILI9881C_COMMAND_INSTR(0x61, 0x00),
805         ILI9881C_COMMAND_INSTR(0x62, 0x19),
806         ILI9881C_COMMAND_INSTR(0x63, 0x00),
807         ILI9881C_COMMAND_INSTR(0xa0, 0x08),
808         ILI9881C_COMMAND_INSTR(0xa1, 0x11),
809         ILI9881C_COMMAND_INSTR(0xa2, 0x19),
810         ILI9881C_COMMAND_INSTR(0xa3, 0x0d),
811         ILI9881C_COMMAND_INSTR(0xa4, 0x0d),
812         ILI9881C_COMMAND_INSTR(0xa5, 0x1e),
813         ILI9881C_COMMAND_INSTR(0xa6, 0x14),
814         ILI9881C_COMMAND_INSTR(0xa7, 0x17),
815         ILI9881C_COMMAND_INSTR(0xa8, 0x4f),
816         ILI9881C_COMMAND_INSTR(0xa9, 0x1a),
817         ILI9881C_COMMAND_INSTR(0xaa, 0x27),
818         ILI9881C_COMMAND_INSTR(0xab, 0x49),
819         ILI9881C_COMMAND_INSTR(0xac, 0x1a),
820         ILI9881C_COMMAND_INSTR(0xad, 0x18),
821         ILI9881C_COMMAND_INSTR(0xae, 0x4c),
822         ILI9881C_COMMAND_INSTR(0xaf, 0x22),
823         ILI9881C_COMMAND_INSTR(0xb0, 0x27),
824         ILI9881C_COMMAND_INSTR(0xb1, 0x4b),
825         ILI9881C_COMMAND_INSTR(0xb2, 0x60),
826         ILI9881C_COMMAND_INSTR(0xb3, 0x39),
827         ILI9881C_COMMAND_INSTR(0xc0, 0x08),
828         ILI9881C_COMMAND_INSTR(0xc1, 0x11),
829         ILI9881C_COMMAND_INSTR(0xc2, 0x19),
830         ILI9881C_COMMAND_INSTR(0xc3, 0x0d),
831         ILI9881C_COMMAND_INSTR(0xc4, 0x0d),
832         ILI9881C_COMMAND_INSTR(0xc5, 0x1e),
833         ILI9881C_COMMAND_INSTR(0xc6, 0x14),
834         ILI9881C_COMMAND_INSTR(0xc7, 0x17),
835         ILI9881C_COMMAND_INSTR(0xc8, 0x4f),
836         ILI9881C_COMMAND_INSTR(0xc9, 0x1a),
837         ILI9881C_COMMAND_INSTR(0xca, 0x27),
838         ILI9881C_COMMAND_INSTR(0xcb, 0x49),
839         ILI9881C_COMMAND_INSTR(0xcc, 0x1a),
840         ILI9881C_COMMAND_INSTR(0xcd, 0x18),
841         ILI9881C_COMMAND_INSTR(0xce, 0x4c),
842         ILI9881C_COMMAND_INSTR(0xcf, 0x33),
843         ILI9881C_COMMAND_INSTR(0xd0, 0x27),
844         ILI9881C_COMMAND_INSTR(0xd1, 0x4b),
845         ILI9881C_COMMAND_INSTR(0xd2, 0x60),
846         ILI9881C_COMMAND_INSTR(0xd3, 0x39),
847         ILI9881C_SWITCH_PAGE_INSTR(0),
848         ILI9881C_COMMAND_INSTR(0x36, 0x03),
849 };
850
851 static const struct ili9881c_instr w552946ab_init[] = {
852         ILI9881C_SWITCH_PAGE_INSTR(3),
853         ILI9881C_COMMAND_INSTR(0x01, 0x00),
854         ILI9881C_COMMAND_INSTR(0x02, 0x00),
855         ILI9881C_COMMAND_INSTR(0x03, 0x53),
856         ILI9881C_COMMAND_INSTR(0x04, 0x53),
857         ILI9881C_COMMAND_INSTR(0x05, 0x13),
858         ILI9881C_COMMAND_INSTR(0x06, 0x04),
859         ILI9881C_COMMAND_INSTR(0x07, 0x02),
860         ILI9881C_COMMAND_INSTR(0x08, 0x02),
861         ILI9881C_COMMAND_INSTR(0x09, 0x00),
862         ILI9881C_COMMAND_INSTR(0x0A, 0x00),
863         ILI9881C_COMMAND_INSTR(0x0B, 0x00),
864         ILI9881C_COMMAND_INSTR(0x0C, 0x00),
865         ILI9881C_COMMAND_INSTR(0x0D, 0x00),
866         ILI9881C_COMMAND_INSTR(0x0E, 0x00),
867         ILI9881C_COMMAND_INSTR(0x0F, 0x00),
868
869         ILI9881C_COMMAND_INSTR(0x10, 0x00),
870         ILI9881C_COMMAND_INSTR(0x11, 0x00),
871         ILI9881C_COMMAND_INSTR(0x12, 0x00),
872         ILI9881C_COMMAND_INSTR(0x13, 0x00),
873         ILI9881C_COMMAND_INSTR(0x14, 0x00),
874         ILI9881C_COMMAND_INSTR(0x15, 0x08),
875         ILI9881C_COMMAND_INSTR(0x16, 0x10),
876         ILI9881C_COMMAND_INSTR(0x17, 0x00),
877         ILI9881C_COMMAND_INSTR(0x18, 0x08),
878         ILI9881C_COMMAND_INSTR(0x19, 0x00),
879         ILI9881C_COMMAND_INSTR(0x1A, 0x00),
880         ILI9881C_COMMAND_INSTR(0x1B, 0x00),
881         ILI9881C_COMMAND_INSTR(0x1C, 0x00),
882         ILI9881C_COMMAND_INSTR(0x1D, 0x00),
883         ILI9881C_COMMAND_INSTR(0x1E, 0xC0),
884         ILI9881C_COMMAND_INSTR(0x1F, 0x80),
885
886         ILI9881C_COMMAND_INSTR(0x20, 0x02),
887         ILI9881C_COMMAND_INSTR(0x21, 0x09),
888         ILI9881C_COMMAND_INSTR(0x22, 0x00),
889         ILI9881C_COMMAND_INSTR(0x23, 0x00),
890         ILI9881C_COMMAND_INSTR(0x24, 0x00),
891         ILI9881C_COMMAND_INSTR(0x25, 0x00),
892         ILI9881C_COMMAND_INSTR(0x26, 0x00),
893         ILI9881C_COMMAND_INSTR(0x27, 0x00),
894         ILI9881C_COMMAND_INSTR(0x28, 0x55),
895         ILI9881C_COMMAND_INSTR(0x29, 0x03),
896         ILI9881C_COMMAND_INSTR(0x2A, 0x00),
897         ILI9881C_COMMAND_INSTR(0x2B, 0x00),
898         ILI9881C_COMMAND_INSTR(0x2C, 0x00),
899         ILI9881C_COMMAND_INSTR(0x2D, 0x00),
900         ILI9881C_COMMAND_INSTR(0x2E, 0x00),
901         ILI9881C_COMMAND_INSTR(0x2F, 0x00),
902
903         ILI9881C_COMMAND_INSTR(0x30, 0x00),
904         ILI9881C_COMMAND_INSTR(0x31, 0x00),
905         ILI9881C_COMMAND_INSTR(0x32, 0x00),
906         ILI9881C_COMMAND_INSTR(0x33, 0x00),
907         ILI9881C_COMMAND_INSTR(0x34, 0x04),
908         ILI9881C_COMMAND_INSTR(0x35, 0x05),
909         ILI9881C_COMMAND_INSTR(0x36, 0x05),
910         ILI9881C_COMMAND_INSTR(0x37, 0x00),
911         ILI9881C_COMMAND_INSTR(0x38, 0x3C),
912         ILI9881C_COMMAND_INSTR(0x39, 0x35),
913         ILI9881C_COMMAND_INSTR(0x3A, 0x00),
914         ILI9881C_COMMAND_INSTR(0x3B, 0x40),
915         ILI9881C_COMMAND_INSTR(0x3C, 0x00),
916         ILI9881C_COMMAND_INSTR(0x3D, 0x00),
917         ILI9881C_COMMAND_INSTR(0x3E, 0x00),
918         ILI9881C_COMMAND_INSTR(0x3F, 0x00),
919
920         ILI9881C_COMMAND_INSTR(0x40, 0x00),
921         ILI9881C_COMMAND_INSTR(0x41, 0x88),
922         ILI9881C_COMMAND_INSTR(0x42, 0x00),
923         ILI9881C_COMMAND_INSTR(0x43, 0x00),
924         ILI9881C_COMMAND_INSTR(0x44, 0x1F),
925
926         ILI9881C_COMMAND_INSTR(0x50, 0x01),
927         ILI9881C_COMMAND_INSTR(0x51, 0x23),
928         ILI9881C_COMMAND_INSTR(0x52, 0x45),
929         ILI9881C_COMMAND_INSTR(0x53, 0x67),
930         ILI9881C_COMMAND_INSTR(0x54, 0x89),
931         ILI9881C_COMMAND_INSTR(0x55, 0xaB),
932         ILI9881C_COMMAND_INSTR(0x56, 0x01),
933         ILI9881C_COMMAND_INSTR(0x57, 0x23),
934         ILI9881C_COMMAND_INSTR(0x58, 0x45),
935         ILI9881C_COMMAND_INSTR(0x59, 0x67),
936         ILI9881C_COMMAND_INSTR(0x5A, 0x89),
937         ILI9881C_COMMAND_INSTR(0x5B, 0xAB),
938         ILI9881C_COMMAND_INSTR(0x5C, 0xCD),
939         ILI9881C_COMMAND_INSTR(0x5D, 0xEF),
940         ILI9881C_COMMAND_INSTR(0x5E, 0x03),
941         ILI9881C_COMMAND_INSTR(0x5F, 0x14),
942
943         ILI9881C_COMMAND_INSTR(0x60, 0x15),
944         ILI9881C_COMMAND_INSTR(0x61, 0x0C),
945         ILI9881C_COMMAND_INSTR(0x62, 0x0D),
946         ILI9881C_COMMAND_INSTR(0x63, 0x0E),
947         ILI9881C_COMMAND_INSTR(0x64, 0x0F),
948         ILI9881C_COMMAND_INSTR(0x65, 0x10),
949         ILI9881C_COMMAND_INSTR(0x66, 0x11),
950         ILI9881C_COMMAND_INSTR(0x67, 0x08),
951         ILI9881C_COMMAND_INSTR(0x68, 0x02),
952         ILI9881C_COMMAND_INSTR(0x69, 0x0A),
953         ILI9881C_COMMAND_INSTR(0x6A, 0x02),
954         ILI9881C_COMMAND_INSTR(0x6B, 0x02),
955         ILI9881C_COMMAND_INSTR(0x6C, 0x02),
956         ILI9881C_COMMAND_INSTR(0x6D, 0x02),
957         ILI9881C_COMMAND_INSTR(0x6E, 0x02),
958         ILI9881C_COMMAND_INSTR(0x6F, 0x02),
959
960         ILI9881C_COMMAND_INSTR(0x70, 0x02),
961         ILI9881C_COMMAND_INSTR(0x71, 0x02),
962         ILI9881C_COMMAND_INSTR(0x72, 0x06),
963         ILI9881C_COMMAND_INSTR(0x73, 0x02),
964         ILI9881C_COMMAND_INSTR(0x74, 0x02),
965         ILI9881C_COMMAND_INSTR(0x75, 0x14),
966         ILI9881C_COMMAND_INSTR(0x76, 0x15),
967         ILI9881C_COMMAND_INSTR(0x77, 0x0F),
968         ILI9881C_COMMAND_INSTR(0x78, 0x0E),
969         ILI9881C_COMMAND_INSTR(0x79, 0x0D),
970         ILI9881C_COMMAND_INSTR(0x7A, 0x0C),
971         ILI9881C_COMMAND_INSTR(0x7B, 0x11),
972         ILI9881C_COMMAND_INSTR(0x7C, 0x10),
973         ILI9881C_COMMAND_INSTR(0x7D, 0x06),
974         ILI9881C_COMMAND_INSTR(0x7E, 0x02),
975         ILI9881C_COMMAND_INSTR(0x7F, 0x0A),
976
977         ILI9881C_COMMAND_INSTR(0x80, 0x02),
978         ILI9881C_COMMAND_INSTR(0x81, 0x02),
979         ILI9881C_COMMAND_INSTR(0x82, 0x02),
980         ILI9881C_COMMAND_INSTR(0x83, 0x02),
981         ILI9881C_COMMAND_INSTR(0x84, 0x02),
982         ILI9881C_COMMAND_INSTR(0x85, 0x02),
983         ILI9881C_COMMAND_INSTR(0x86, 0x02),
984         ILI9881C_COMMAND_INSTR(0x87, 0x02),
985         ILI9881C_COMMAND_INSTR(0x88, 0x08),
986         ILI9881C_COMMAND_INSTR(0x89, 0x02),
987         ILI9881C_COMMAND_INSTR(0x8A, 0x02),
988
989         ILI9881C_SWITCH_PAGE_INSTR(4),
990         ILI9881C_COMMAND_INSTR(0x00, 0x80),
991         ILI9881C_COMMAND_INSTR(0x70, 0x00),
992         ILI9881C_COMMAND_INSTR(0x71, 0x00),
993         ILI9881C_COMMAND_INSTR(0x66, 0xFE),
994         ILI9881C_COMMAND_INSTR(0x82, 0x15),
995         ILI9881C_COMMAND_INSTR(0x84, 0x15),
996         ILI9881C_COMMAND_INSTR(0x85, 0x15),
997         ILI9881C_COMMAND_INSTR(0x3a, 0x24),
998         ILI9881C_COMMAND_INSTR(0x32, 0xAC),
999         ILI9881C_COMMAND_INSTR(0x8C, 0x80),
1000         ILI9881C_COMMAND_INSTR(0x3C, 0xF5),
1001         ILI9881C_COMMAND_INSTR(0x88, 0x33),
1002
1003         ILI9881C_SWITCH_PAGE_INSTR(1),
1004         ILI9881C_COMMAND_INSTR(0x22, 0x0A),
1005         ILI9881C_COMMAND_INSTR(0x31, 0x00),
1006         ILI9881C_COMMAND_INSTR(0x53, 0x78),
1007         ILI9881C_COMMAND_INSTR(0x50, 0x5B),
1008         ILI9881C_COMMAND_INSTR(0x51, 0x5B),
1009         ILI9881C_COMMAND_INSTR(0x60, 0x20),
1010         ILI9881C_COMMAND_INSTR(0x61, 0x00),
1011         ILI9881C_COMMAND_INSTR(0x62, 0x0D),
1012         ILI9881C_COMMAND_INSTR(0x63, 0x00),
1013
1014         ILI9881C_COMMAND_INSTR(0xA0, 0x00),
1015         ILI9881C_COMMAND_INSTR(0xA1, 0x10),
1016         ILI9881C_COMMAND_INSTR(0xA2, 0x1C),
1017         ILI9881C_COMMAND_INSTR(0xA3, 0x13),
1018         ILI9881C_COMMAND_INSTR(0xA4, 0x15),
1019         ILI9881C_COMMAND_INSTR(0xA5, 0x26),
1020         ILI9881C_COMMAND_INSTR(0xA6, 0x1A),
1021         ILI9881C_COMMAND_INSTR(0xA7, 0x1D),
1022         ILI9881C_COMMAND_INSTR(0xA8, 0x67),
1023         ILI9881C_COMMAND_INSTR(0xA9, 0x1C),
1024         ILI9881C_COMMAND_INSTR(0xAA, 0x29),
1025         ILI9881C_COMMAND_INSTR(0xAB, 0x5B),
1026         ILI9881C_COMMAND_INSTR(0xAC, 0x26),
1027         ILI9881C_COMMAND_INSTR(0xAD, 0x28),
1028         ILI9881C_COMMAND_INSTR(0xAE, 0x5C),
1029         ILI9881C_COMMAND_INSTR(0xAF, 0x30),
1030         ILI9881C_COMMAND_INSTR(0xB0, 0x31),
1031         ILI9881C_COMMAND_INSTR(0xB1, 0x2E),
1032         ILI9881C_COMMAND_INSTR(0xB2, 0x32),
1033         ILI9881C_COMMAND_INSTR(0xB3, 0x00),
1034
1035         ILI9881C_COMMAND_INSTR(0xC0, 0x00),
1036         ILI9881C_COMMAND_INSTR(0xC1, 0x10),
1037         ILI9881C_COMMAND_INSTR(0xC2, 0x1C),
1038         ILI9881C_COMMAND_INSTR(0xC3, 0x13),
1039         ILI9881C_COMMAND_INSTR(0xC4, 0x15),
1040         ILI9881C_COMMAND_INSTR(0xC5, 0x26),
1041         ILI9881C_COMMAND_INSTR(0xC6, 0x1A),
1042         ILI9881C_COMMAND_INSTR(0xC7, 0x1D),
1043         ILI9881C_COMMAND_INSTR(0xC8, 0x67),
1044         ILI9881C_COMMAND_INSTR(0xC9, 0x1C),
1045         ILI9881C_COMMAND_INSTR(0xCA, 0x29),
1046         ILI9881C_COMMAND_INSTR(0xCB, 0x5B),
1047         ILI9881C_COMMAND_INSTR(0xCC, 0x26),
1048         ILI9881C_COMMAND_INSTR(0xCD, 0x28),
1049         ILI9881C_COMMAND_INSTR(0xCE, 0x5C),
1050         ILI9881C_COMMAND_INSTR(0xCF, 0x30),
1051         ILI9881C_COMMAND_INSTR(0xD0, 0x31),
1052         ILI9881C_COMMAND_INSTR(0xD1, 0x2E),
1053         ILI9881C_COMMAND_INSTR(0xD2, 0x32),
1054         ILI9881C_COMMAND_INSTR(0xD3, 0x00),
1055         ILI9881C_SWITCH_PAGE_INSTR(0),
1056 };
1057
1058 static const struct ili9881c_instr cfaf7201280a0_050tx_init[] = {
1059         //ILI9881C PAGE3
1060         ILI9881C_SWITCH_PAGE_INSTR(3),
1061         //GIP_1
1062         ILI9881C_COMMAND_INSTR(0x01, 0x00), //added
1063         ILI9881C_COMMAND_INSTR(0x02, 0x00),
1064         ILI9881C_COMMAND_INSTR(0x03, 0x73),
1065         ILI9881C_COMMAND_INSTR(0x04, 0x00),
1066         ILI9881C_COMMAND_INSTR(0x05, 0x00),
1067         ILI9881C_COMMAND_INSTR(0x06, 0x0A),
1068         ILI9881C_COMMAND_INSTR(0x07, 0x00),
1069         ILI9881C_COMMAND_INSTR(0x08, 0x00),
1070         ILI9881C_COMMAND_INSTR(0x09, 0x01),
1071         ILI9881C_COMMAND_INSTR(0x0A, 0x00),
1072         ILI9881C_COMMAND_INSTR(0x0B, 0x00),
1073         ILI9881C_COMMAND_INSTR(0x0C, 0x01),
1074         ILI9881C_COMMAND_INSTR(0x0D, 0x00),
1075         ILI9881C_COMMAND_INSTR(0x0E, 0x00),
1076         ILI9881C_COMMAND_INSTR(0x0F, 0x1D),
1077         ILI9881C_COMMAND_INSTR(0x10, 0x1D),
1078         ILI9881C_COMMAND_INSTR(0x11, 0x00),
1079         ILI9881C_COMMAND_INSTR(0x12, 0x00),
1080         ILI9881C_COMMAND_INSTR(0x13, 0x00),
1081         ILI9881C_COMMAND_INSTR(0x14, 0x00),
1082         ILI9881C_COMMAND_INSTR(0x15, 0x00),
1083         ILI9881C_COMMAND_INSTR(0x16, 0x00),
1084         ILI9881C_COMMAND_INSTR(0x17, 0x00),
1085         ILI9881C_COMMAND_INSTR(0x18, 0x00),
1086         ILI9881C_COMMAND_INSTR(0x19, 0x00),
1087         ILI9881C_COMMAND_INSTR(0x1A, 0x00),
1088         ILI9881C_COMMAND_INSTR(0x1B, 0x00),
1089         ILI9881C_COMMAND_INSTR(0x1C, 0x00),
1090         ILI9881C_COMMAND_INSTR(0x1D, 0x00),
1091         ILI9881C_COMMAND_INSTR(0x1E, 0x40),
1092         ILI9881C_COMMAND_INSTR(0x1F, 0x80),
1093         ILI9881C_COMMAND_INSTR(0x20, 0x06),
1094         ILI9881C_COMMAND_INSTR(0x21, 0x02),
1095         ILI9881C_COMMAND_INSTR(0x22, 0x00),
1096         ILI9881C_COMMAND_INSTR(0x23, 0x00),
1097         ILI9881C_COMMAND_INSTR(0x24, 0x00),
1098         ILI9881C_COMMAND_INSTR(0x25, 0x00),
1099         ILI9881C_COMMAND_INSTR(0x26, 0x00),
1100         ILI9881C_COMMAND_INSTR(0x27, 0x00),
1101         ILI9881C_COMMAND_INSTR(0x28, 0x33),
1102         ILI9881C_COMMAND_INSTR(0x29, 0x03),
1103         ILI9881C_COMMAND_INSTR(0x2A, 0x00),
1104         ILI9881C_COMMAND_INSTR(0x2B, 0x00),
1105         ILI9881C_COMMAND_INSTR(0x2C, 0x00),
1106         ILI9881C_COMMAND_INSTR(0x2D, 0x00),
1107         ILI9881C_COMMAND_INSTR(0x2E, 0x00),
1108         ILI9881C_COMMAND_INSTR(0x2F, 0x00),
1109         ILI9881C_COMMAND_INSTR(0x30, 0x00),
1110         ILI9881C_COMMAND_INSTR(0x31, 0x00),
1111         ILI9881C_COMMAND_INSTR(0x32, 0x00),
1112         ILI9881C_COMMAND_INSTR(0x33, 0x00),
1113         ILI9881C_COMMAND_INSTR(0x34, 0x04),
1114         ILI9881C_COMMAND_INSTR(0x35, 0x00),
1115         ILI9881C_COMMAND_INSTR(0x36, 0x00),
1116         ILI9881C_COMMAND_INSTR(0x37, 0x00),
1117         ILI9881C_COMMAND_INSTR(0x38, 0x3C),
1118         ILI9881C_COMMAND_INSTR(0x39, 0x00),
1119         ILI9881C_COMMAND_INSTR(0x3A, 0x40),
1120         ILI9881C_COMMAND_INSTR(0x3B, 0x40),
1121         ILI9881C_COMMAND_INSTR(0x3C, 0x00),
1122         ILI9881C_COMMAND_INSTR(0x3D, 0x00),
1123         ILI9881C_COMMAND_INSTR(0x3E, 0x00),
1124         ILI9881C_COMMAND_INSTR(0x3F, 0x00),
1125         ILI9881C_COMMAND_INSTR(0x40, 0x00),
1126         ILI9881C_COMMAND_INSTR(0x41, 0x00),
1127         ILI9881C_COMMAND_INSTR(0x42, 0x00),
1128         ILI9881C_COMMAND_INSTR(0x43, 0x00),
1129         ILI9881C_COMMAND_INSTR(0x44, 0x00),
1130         //GIP_2
1131         ILI9881C_COMMAND_INSTR(0x50, 0x01),
1132         ILI9881C_COMMAND_INSTR(0x51, 0x23),
1133         ILI9881C_COMMAND_INSTR(0x52, 0x45),
1134         ILI9881C_COMMAND_INSTR(0x53, 0x67),
1135         ILI9881C_COMMAND_INSTR(0x54, 0x89),
1136         ILI9881C_COMMAND_INSTR(0x55, 0xAB),
1137         ILI9881C_COMMAND_INSTR(0x56, 0x01),
1138         ILI9881C_COMMAND_INSTR(0x57, 0x23),
1139         ILI9881C_COMMAND_INSTR(0x58, 0x45),
1140         ILI9881C_COMMAND_INSTR(0x59, 0x67),
1141         ILI9881C_COMMAND_INSTR(0x5A, 0x89),
1142         ILI9881C_COMMAND_INSTR(0x5B, 0xAB),
1143         ILI9881C_COMMAND_INSTR(0x5C, 0xCD),
1144         ILI9881C_COMMAND_INSTR(0x5D, 0xEF),
1145         //GIP_3
1146         ILI9881C_COMMAND_INSTR(0x5E, 0x11),
1147         ILI9881C_COMMAND_INSTR(0x5F, 0x01),
1148         ILI9881C_COMMAND_INSTR(0x60, 0x00),
1149         ILI9881C_COMMAND_INSTR(0x61, 0x15),
1150         ILI9881C_COMMAND_INSTR(0x62, 0x14),
1151         ILI9881C_COMMAND_INSTR(0x63, 0x0E),
1152         ILI9881C_COMMAND_INSTR(0x64, 0x0F),
1153         ILI9881C_COMMAND_INSTR(0x65, 0x0C),
1154         ILI9881C_COMMAND_INSTR(0x66, 0x0D),
1155         ILI9881C_COMMAND_INSTR(0x67, 0x06),
1156         ILI9881C_COMMAND_INSTR(0x68, 0x02),
1157         ILI9881C_COMMAND_INSTR(0x69, 0x07),
1158         ILI9881C_COMMAND_INSTR(0x6A, 0x02),
1159         ILI9881C_COMMAND_INSTR(0x6B, 0x02),
1160         ILI9881C_COMMAND_INSTR(0x6C, 0x02),
1161         ILI9881C_COMMAND_INSTR(0x6D, 0x02),
1162         ILI9881C_COMMAND_INSTR(0x6E, 0x02),
1163         ILI9881C_COMMAND_INSTR(0x6F, 0x02),
1164         ILI9881C_COMMAND_INSTR(0x70, 0x02),
1165         ILI9881C_COMMAND_INSTR(0x71, 0x02),
1166         ILI9881C_COMMAND_INSTR(0x72, 0x02),
1167         ILI9881C_COMMAND_INSTR(0x73, 0x02),
1168         ILI9881C_COMMAND_INSTR(0x74, 0x02),
1169         ILI9881C_COMMAND_INSTR(0x75, 0x01),
1170         ILI9881C_COMMAND_INSTR(0x76, 0x00),
1171         ILI9881C_COMMAND_INSTR(0x77, 0x14),
1172         ILI9881C_COMMAND_INSTR(0x78, 0x15),
1173         ILI9881C_COMMAND_INSTR(0x79, 0x0E),
1174         ILI9881C_COMMAND_INSTR(0x7A, 0x0F),
1175         ILI9881C_COMMAND_INSTR(0x7B, 0x0C),
1176         ILI9881C_COMMAND_INSTR(0x7C, 0x0D),
1177         ILI9881C_COMMAND_INSTR(0x7D, 0x06),
1178         ILI9881C_COMMAND_INSTR(0x7E, 0x02),
1179         ILI9881C_COMMAND_INSTR(0x7F, 0x07),
1180         ILI9881C_COMMAND_INSTR(0x80, 0x02),
1181         ILI9881C_COMMAND_INSTR(0x81, 0x02),
1182         ILI9881C_COMMAND_INSTR(0x82, 0x02),
1183         ILI9881C_COMMAND_INSTR(0x83, 0x02),
1184         ILI9881C_COMMAND_INSTR(0x84, 0x02),
1185         ILI9881C_COMMAND_INSTR(0x85, 0x02),
1186         ILI9881C_COMMAND_INSTR(0x86, 0x02),
1187         ILI9881C_COMMAND_INSTR(0x87, 0x02),
1188         ILI9881C_COMMAND_INSTR(0x88, 0x02),
1189         ILI9881C_COMMAND_INSTR(0x89, 0x02),
1190         ILI9881C_COMMAND_INSTR(0x8A, 0x02),
1191         //ILI9881C PAGE4
1192         ILI9881C_SWITCH_PAGE_INSTR(4),
1193         ILI9881C_COMMAND_INSTR(0x6C, 0x15),
1194         ILI9881C_COMMAND_INSTR(0x6E, 0x2B),
1195         // VGH & VGL OUTPUT
1196         ILI9881C_COMMAND_INSTR(0x6F, 0x33),
1197         ILI9881C_COMMAND_INSTR(0x8D, 0x18),
1198         ILI9881C_COMMAND_INSTR(0x87, 0xBA),
1199         ILI9881C_COMMAND_INSTR(0x26, 0x76),
1200         //Reload Gamma setting
1201         ILI9881C_COMMAND_INSTR(0xB2, 0xD1),
1202         ILI9881C_COMMAND_INSTR(0xB5, 0x06),
1203         ILI9881C_COMMAND_INSTR(0x3A, 0x24),
1204         ILI9881C_COMMAND_INSTR(0x35, 0x1F),
1205
1206         //ILI9881C PAGE1
1207         ILI9881C_SWITCH_PAGE_INSTR(1),
1208         ILI9881C_COMMAND_INSTR(0x22, 0x09),
1209         //Column inversion
1210         ILI9881C_COMMAND_INSTR(0x31, 0x00),
1211         ILI9881C_COMMAND_INSTR(0x40, 0x33),
1212         ILI9881C_COMMAND_INSTR(0x53, 0xA2),
1213         ILI9881C_COMMAND_INSTR(0x55, 0x92),
1214         ILI9881C_COMMAND_INSTR(0x50, 0x96),
1215         ILI9881C_COMMAND_INSTR(0x51, 0x96),
1216         ILI9881C_COMMAND_INSTR(0x60, 0x22),
1217         ILI9881C_COMMAND_INSTR(0x61, 0x00),
1218         ILI9881C_COMMAND_INSTR(0x62, 0x19),
1219         ILI9881C_COMMAND_INSTR(0x63, 0x00),
1220         //---P-GAMMA START---
1221         ILI9881C_COMMAND_INSTR(0xA0, 0x08),
1222         ILI9881C_COMMAND_INSTR(0xA1, 0x11),
1223         ILI9881C_COMMAND_INSTR(0xA2, 0x19),
1224         ILI9881C_COMMAND_INSTR(0xA3, 0x0D),
1225         ILI9881C_COMMAND_INSTR(0xA4, 0x0D),
1226         ILI9881C_COMMAND_INSTR(0xA5, 0x1E),
1227         ILI9881C_COMMAND_INSTR(0xA6, 0x14),
1228         ILI9881C_COMMAND_INSTR(0xA7, 0x17),
1229         ILI9881C_COMMAND_INSTR(0xA8, 0x4F),
1230         ILI9881C_COMMAND_INSTR(0xA9, 0x1A),
1231         ILI9881C_COMMAND_INSTR(0xAA, 0x27),
1232         ILI9881C_COMMAND_INSTR(0xAB, 0x49),
1233         ILI9881C_COMMAND_INSTR(0xAC, 0x1A),
1234         ILI9881C_COMMAND_INSTR(0xAD, 0x18),
1235         ILI9881C_COMMAND_INSTR(0xAE, 0x4C),
1236         ILI9881C_COMMAND_INSTR(0xAF, 0x22),
1237         ILI9881C_COMMAND_INSTR(0xB0, 0x27),
1238         ILI9881C_COMMAND_INSTR(0xB1, 0x4B),
1239         ILI9881C_COMMAND_INSTR(0xB2, 0x60),
1240         ILI9881C_COMMAND_INSTR(0xB3, 0x39),
1241         //--- N-GAMMA START---
1242         ILI9881C_COMMAND_INSTR(0xC0, 0x08),
1243         ILI9881C_COMMAND_INSTR(0xC1, 0x11),
1244         ILI9881C_COMMAND_INSTR(0xC2, 0x19),
1245         ILI9881C_COMMAND_INSTR(0xC3, 0x0D),
1246         ILI9881C_COMMAND_INSTR(0xC4, 0x0D),
1247         ILI9881C_COMMAND_INSTR(0xC5, 0x1E),
1248         ILI9881C_COMMAND_INSTR(0xC6, 0x14),
1249         ILI9881C_COMMAND_INSTR(0xC7, 0x17),
1250         ILI9881C_COMMAND_INSTR(0xC8, 0x4F),
1251         ILI9881C_COMMAND_INSTR(0xC9, 0x1A),
1252         ILI9881C_COMMAND_INSTR(0xCA, 0x27),
1253         ILI9881C_COMMAND_INSTR(0xCB, 0x49),
1254         ILI9881C_COMMAND_INSTR(0xCC, 0x1A),
1255         ILI9881C_COMMAND_INSTR(0xCD, 0x18),
1256         ILI9881C_COMMAND_INSTR(0xCE, 0x4C),
1257         ILI9881C_COMMAND_INSTR(0xCF, 0x33),
1258         ILI9881C_COMMAND_INSTR(0xD0, 0x27),
1259         ILI9881C_COMMAND_INSTR(0xD1, 0x4B),
1260         ILI9881C_COMMAND_INSTR(0xD2, 0x60),
1261         ILI9881C_COMMAND_INSTR(0xD3, 0x39),
1262 };
1263
1264 static inline struct ili9881c *panel_to_ili9881c(struct drm_panel *panel)
1265 {
1266         return container_of(panel, struct ili9881c, panel);
1267 }
1268
1269 /*
1270  * The panel seems to accept some private DCS commands that map
1271  * directly to registers.
1272  *
1273  * It is organised by page, with each page having its own set of
1274  * registers, and the first page looks like it's holding the standard
1275  * DCS commands.
1276  *
1277  * So before any attempt at sending a command or data, we have to be
1278  * sure if we're in the right page or not.
1279  */
1280 static int ili9881c_switch_page(struct ili9881c *ctx, u8 page)
1281 {
1282         u8 buf[4] = { 0xff, 0x98, 0x81, page };
1283         int ret;
1284
1285         ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
1286         if (ret < 0)
1287                 return ret;
1288
1289         return 0;
1290 }
1291
1292 static int ili9881c_send_cmd_data(struct ili9881c *ctx, u8 cmd, u8 data)
1293 {
1294         u8 buf[2] = { cmd, data };
1295         int ret;
1296
1297         ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
1298         if (ret < 0)
1299                 return ret;
1300
1301         return 0;
1302 }
1303
1304 static int ili9881c_prepare(struct drm_panel *panel)
1305 {
1306         struct ili9881c *ctx = panel_to_ili9881c(panel);
1307         unsigned int i;
1308         int ret;
1309
1310         /* Power the panel */
1311         ret = regulator_enable(ctx->power);
1312         if (ret)
1313                 return ret;
1314         msleep(5);
1315
1316         /* And reset it */
1317         gpiod_set_value_cansleep(ctx->reset, 1);
1318         msleep(20);
1319
1320         gpiod_set_value_cansleep(ctx->reset, 0);
1321         msleep(20);
1322
1323         for (i = 0; i < ctx->desc->init_length; i++) {
1324                 const struct ili9881c_instr *instr = &ctx->desc->init[i];
1325
1326                 if (instr->op == ILI9881C_SWITCH_PAGE)
1327                         ret = ili9881c_switch_page(ctx, instr->arg.page);
1328                 else if (instr->op == ILI9881C_COMMAND)
1329                         ret = ili9881c_send_cmd_data(ctx, instr->arg.cmd.cmd,
1330                                                       instr->arg.cmd.data);
1331
1332                 if (ret)
1333                         return ret;
1334         }
1335
1336         ret = ili9881c_switch_page(ctx, 0);
1337         if (ret)
1338                 return ret;
1339
1340         ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
1341         if (ret)
1342                 return ret;
1343
1344         ret = mipi_dsi_dcs_exit_sleep_mode(ctx->dsi);
1345         if (ret)
1346                 return ret;
1347
1348         return 0;
1349 }
1350
1351 static int ili9881c_enable(struct drm_panel *panel)
1352 {
1353         struct ili9881c *ctx = panel_to_ili9881c(panel);
1354
1355         msleep(120);
1356
1357         mipi_dsi_dcs_set_display_on(ctx->dsi);
1358
1359         return 0;
1360 }
1361
1362 static int ili9881c_disable(struct drm_panel *panel)
1363 {
1364         struct ili9881c *ctx = panel_to_ili9881c(panel);
1365
1366         return mipi_dsi_dcs_set_display_off(ctx->dsi);
1367 }
1368
1369 static int ili9881c_unprepare(struct drm_panel *panel)
1370 {
1371         struct ili9881c *ctx = panel_to_ili9881c(panel);
1372
1373         mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
1374         regulator_disable(ctx->power);
1375         gpiod_set_value_cansleep(ctx->reset, 1);
1376
1377         return 0;
1378 }
1379
1380 static const struct drm_display_mode lhr050h41_default_mode = {
1381         .clock          = 62000,
1382
1383         .hdisplay       = 720,
1384         .hsync_start    = 720 + 10,
1385         .hsync_end      = 720 + 10 + 20,
1386         .htotal         = 720 + 10 + 20 + 30,
1387
1388         .vdisplay       = 1280,
1389         .vsync_start    = 1280 + 10,
1390         .vsync_end      = 1280 + 10 + 10,
1391         .vtotal         = 1280 + 10 + 10 + 20,
1392
1393         .width_mm       = 62,
1394         .height_mm      = 110,
1395 };
1396
1397 static const struct drm_display_mode k101_im2byl02_default_mode = {
1398         .clock          = 69700,
1399
1400         .hdisplay       = 800,
1401         .hsync_start    = 800 + 52,
1402         .hsync_end      = 800 + 52 + 8,
1403         .htotal         = 800 + 52 + 8 + 48,
1404
1405         .vdisplay       = 1280,
1406         .vsync_start    = 1280 + 16,
1407         .vsync_end      = 1280 + 16 + 6,
1408         .vtotal         = 1280 + 16 + 6 + 15,
1409
1410         .width_mm       = 135,
1411         .height_mm      = 217,
1412 };
1413
1414 static const struct drm_display_mode nwe080_default_mode = {
1415         .clock          = 71750,
1416
1417         .hdisplay       = 800,
1418         .hsync_start    = 800 + 52,
1419         .hsync_end      = 800 + 52 + 8,
1420         .htotal         = 800 + 52 + 8 + 48,
1421
1422         .vdisplay       = 1280,
1423         .vsync_start    = 1280 + 16,
1424         .vsync_end      = 1280 + 16 + 6,
1425         .vtotal         = 1280 + 16 + 6 + 15,
1426
1427         .width_mm       = 107,
1428         .height_mm      = 170,
1429 };
1430
1431 static const struct drm_display_mode tl050hdv35_default_mode = {
1432         .clock          = 59400,
1433
1434         .hdisplay       = 720,
1435         .hsync_start    = 720 + 18,
1436         .hsync_end      = 720 + 18 + 3,
1437         .htotal         = 720 + 18 + 3 + 20,
1438
1439         .vdisplay       = 1280,
1440         .vsync_start    = 1280 + 26,
1441         .vsync_end      = 1280 + 26 + 6,
1442         .vtotal         = 1280 + 26 + 6 + 28,
1443
1444         .width_mm       = 62,
1445         .height_mm      = 110,
1446 };
1447
1448 static const struct drm_display_mode w552946aba_default_mode = {
1449         .clock          = 64000,
1450
1451         .hdisplay       = 720,
1452         .hsync_start    = 720 + 40,
1453         .hsync_end      = 720 + 40 + 10,
1454         .htotal         = 720 + 40 + 10 + 40,
1455
1456         .vdisplay       = 1280,
1457         .vsync_start    = 1280 + 22,
1458         .vsync_end      = 1280 + 22 + 4,
1459         .vtotal         = 1280 + 22 + 4 + 11,
1460
1461         .width_mm       = 68,
1462         .height_mm      = 121,
1463 };
1464
1465 static const struct drm_display_mode cfaf7201280a0_050tx_default_mode = {
1466         .clock          = 72830,
1467         .hdisplay       = 720,
1468         .hsync_start    = 720 + 87,
1469         .hsync_end      = 720 + 87 + 20,
1470         .htotal         = 720 + 87 + 20 + 87,
1471         .vdisplay       = 1280,
1472         .vsync_start    = 1280 + 16,
1473         .vsync_end      = 1280 + 16 + 8,
1474         .vtotal         = 1280 + 16 + 8 + 16,
1475         .width_mm       = 62,
1476         .height_mm      = 1108
1477 };
1478
1479 static int ili9881c_get_modes(struct drm_panel *panel,
1480                               struct drm_connector *connector)
1481 {
1482         struct ili9881c *ctx = panel_to_ili9881c(panel);
1483         struct drm_display_mode *mode;
1484
1485         mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
1486         if (!mode) {
1487                 dev_err(&ctx->dsi->dev, "failed to add mode %ux%ux@%u\n",
1488                         ctx->desc->mode->hdisplay,
1489                         ctx->desc->mode->vdisplay,
1490                         drm_mode_vrefresh(ctx->desc->mode));
1491                 return -ENOMEM;
1492         }
1493
1494         drm_mode_set_name(mode);
1495
1496         mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
1497         drm_mode_probed_add(connector, mode);
1498
1499         connector->display_info.width_mm = mode->width_mm;
1500         connector->display_info.height_mm = mode->height_mm;
1501
1502         /*
1503          * TODO: Remove once all drm drivers call
1504          * drm_connector_set_orientation_from_panel()
1505          */
1506         drm_connector_set_panel_orientation(connector, ctx->orientation);
1507
1508         return 1;
1509 }
1510
1511 static enum drm_panel_orientation ili9881c_get_orientation(struct drm_panel *panel)
1512 {
1513         struct ili9881c *ctx = panel_to_ili9881c(panel);
1514
1515         return ctx->orientation;
1516 }
1517
1518 static const struct drm_panel_funcs ili9881c_funcs = {
1519         .prepare        = ili9881c_prepare,
1520         .unprepare      = ili9881c_unprepare,
1521         .enable         = ili9881c_enable,
1522         .disable        = ili9881c_disable,
1523         .get_modes      = ili9881c_get_modes,
1524         .get_orientation = ili9881c_get_orientation,
1525 };
1526
1527 static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
1528 {
1529         struct ili9881c *ctx;
1530         int ret;
1531
1532         ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
1533         if (!ctx)
1534                 return -ENOMEM;
1535         mipi_dsi_set_drvdata(dsi, ctx);
1536         ctx->dsi = dsi;
1537         ctx->desc = of_device_get_match_data(&dsi->dev);
1538
1539         ctx->panel.prepare_prev_first = true;
1540         drm_panel_init(&ctx->panel, &dsi->dev, &ili9881c_funcs,
1541                        DRM_MODE_CONNECTOR_DSI);
1542
1543         ctx->power = devm_regulator_get(&dsi->dev, "power");
1544         if (IS_ERR(ctx->power))
1545                 return dev_err_probe(&dsi->dev, PTR_ERR(ctx->power),
1546                                      "Couldn't get our power regulator\n");
1547
1548         ctx->reset = devm_gpiod_get_optional(&dsi->dev, "reset", GPIOD_OUT_LOW);
1549         if (IS_ERR(ctx->reset))
1550                 return dev_err_probe(&dsi->dev, PTR_ERR(ctx->reset),
1551                                      "Couldn't get our reset GPIO\n");
1552
1553         ret = of_drm_get_panel_orientation(dsi->dev.of_node, &ctx->orientation);
1554         if (ret) {
1555                 dev_err(&dsi->dev, "%pOF: failed to get orientation: %d\n",
1556                         dsi->dev.of_node, ret);
1557                 return ret;
1558         }
1559
1560         ret = drm_panel_of_backlight(&ctx->panel);
1561         if (ret)
1562                 return ret;
1563
1564         drm_panel_add(&ctx->panel);
1565
1566         dsi->mode_flags = ctx->desc->mode_flags;
1567         dsi->format = MIPI_DSI_FMT_RGB888;
1568         dsi->lanes = 4;
1569
1570         ret = mipi_dsi_attach(dsi);
1571         if (ret)
1572                 drm_panel_remove(&ctx->panel);
1573
1574         return ret;
1575 }
1576
1577 static void ili9881c_dsi_remove(struct mipi_dsi_device *dsi)
1578 {
1579         struct ili9881c *ctx = mipi_dsi_get_drvdata(dsi);
1580
1581         mipi_dsi_detach(dsi);
1582         drm_panel_remove(&ctx->panel);
1583 }
1584
1585 static const struct ili9881c_desc lhr050h41_desc = {
1586         .init = lhr050h41_init,
1587         .init_length = ARRAY_SIZE(lhr050h41_init),
1588         .mode = &lhr050h41_default_mode,
1589         .mode_flags = MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1590 };
1591
1592 static const struct ili9881c_desc k101_im2byl02_desc = {
1593         .init = k101_im2byl02_init,
1594         .init_length = ARRAY_SIZE(k101_im2byl02_init),
1595         .mode = &k101_im2byl02_default_mode,
1596         .mode_flags = MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1597 };
1598
1599 static const struct ili9881c_desc nwe080_desc = {
1600         .init = nwe080_init,
1601         .init_length = ARRAY_SIZE(nwe080_init),
1602         .mode = &nwe080_default_mode,
1603         .mode_flags = MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_VIDEO,
1604 };
1605
1606 static const struct ili9881c_desc tl050hdv35_desc = {
1607         .init = tl050hdv35_init,
1608         .init_length = ARRAY_SIZE(tl050hdv35_init),
1609         .mode = &tl050hdv35_default_mode,
1610         .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1611                       MIPI_DSI_MODE_LPM,
1612 };
1613
1614 static const struct ili9881c_desc w552946aba_desc = {
1615         .init = w552946ab_init,
1616         .init_length = ARRAY_SIZE(w552946ab_init),
1617         .mode = &w552946aba_default_mode,
1618         .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
1619                       MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_NO_EOT_PACKET,
1620 };
1621
1622 static const struct ili9881c_desc cfaf7201280a0_050tx_desc = {
1623         .init = cfaf7201280a0_050tx_init,
1624         .init_length = ARRAY_SIZE(cfaf7201280a0_050tx_init),
1625         .mode = &cfaf7201280a0_050tx_default_mode,
1626         .mode_flags = MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_VIDEO,
1627 };
1628
1629 static const struct of_device_id ili9881c_of_match[] = {
1630         { .compatible = "bananapi,lhr050h41", .data = &lhr050h41_desc },
1631         { .compatible = "feixin,k101-im2byl02", .data = &k101_im2byl02_desc },
1632         { .compatible = "nwe,nwe080", .data = &nwe080_desc },
1633         { .compatible = "tdo,tl050hdv35", .data = &tl050hdv35_desc },
1634         { .compatible = "wanchanglong,w552946aba", .data = &w552946aba_desc },
1635         { .compatible = "crystalfontz,cfaf7201280a0_050tx", .data = &cfaf7201280a0_050tx_desc },
1636         { }
1637 };
1638 MODULE_DEVICE_TABLE(of, ili9881c_of_match);
1639
1640 static struct mipi_dsi_driver ili9881c_dsi_driver = {
1641         .probe          = ili9881c_dsi_probe,
1642         .remove         = ili9881c_dsi_remove,
1643         .driver = {
1644                 .name           = "ili9881c-dsi",
1645                 .of_match_table = ili9881c_of_match,
1646         },
1647 };
1648 module_mipi_dsi_driver(ili9881c_dsi_driver);
1649
1650 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
1651 MODULE_DESCRIPTION("Ilitek ILI9881C Controller Driver");
1652 MODULE_LICENSE("GPL v2");