1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2017-2018, Bootlin
4 */
5
6 #include <linux/delay.h>
7 #include <linux/device.h>
8 #include <linux/err.h>
9 #include <linux/errno.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/of.h>
13
14 #include <linux/gpio/consumer.h>
15 #include <linux/regulator/consumer.h>
16
17 #include <drm/drm_mipi_dsi.h>
18 #include <drm/drm_modes.h>
19 #include <drm/drm_panel.h>
20
21 #include <video/mipi_display.h>
22
23 enum ili9881c_op {
24 ILI9881C_SWITCH_PAGE,
25 ILI9881C_COMMAND,
26 };
27
28 struct ili9881c_instr {
29 enum ili9881c_op op;
30
31 union arg {
32 struct cmd {
33 u8 cmd;
34 u8 data;
35 } cmd;
36 u8 page;
37 } arg;
38 };
39
40 struct ili9881c_desc {
41 const struct ili9881c_instr *init;
42 const size_t init_length;
43 const struct drm_display_mode *mode;
44 const unsigned long mode_flags;
45 };
46
47 struct ili9881c {
48 struct drm_panel panel;
49 struct mipi_dsi_device *dsi;
50 const struct ili9881c_desc *desc;
51
52 struct regulator *power;
53 struct gpio_desc *reset;
54
55 enum drm_panel_orientation orientation;
56 };
57
58 #define ILI9881C_SWITCH_PAGE_INSTR(_page) \
59 { \
60 .op = ILI9881C_SWITCH_PAGE, \
61 .arg = { \
62 .page = (_page), \
63 }, \
64 }
65
66 #define ILI9881C_COMMAND_INSTR(_cmd, _data) \
67 { \
68 .op = ILI9881C_COMMAND, \
69 .arg = { \
70 .cmd = { \
71 .cmd = (_cmd), \
72 .data = (_data), \
73 }, \
74 }, \
75 }
76
77 static const struct ili9881c_instr lhr050h41_init[] = {
78 ILI9881C_SWITCH_PAGE_INSTR(3),
79 ILI9881C_COMMAND_INSTR(0x01, 0x00),
80 ILI9881C_COMMAND_INSTR(0x02, 0x00),
81 ILI9881C_COMMAND_INSTR(0x03, 0x73),
82 ILI9881C_COMMAND_INSTR(0x04, 0x03),
83 ILI9881C_COMMAND_INSTR(0x05, 0x00),
84 ILI9881C_COMMAND_INSTR(0x06, 0x06),
85 ILI9881C_COMMAND_INSTR(0x07, 0x06),
86 ILI9881C_COMMAND_INSTR(0x08, 0x00),
87 ILI9881C_COMMAND_INSTR(0x09, 0x18),
88 ILI9881C_COMMAND_INSTR(0x0a, 0x04),
89 ILI9881C_COMMAND_INSTR(0x0b, 0x00),
90 ILI9881C_COMMAND_INSTR(0x0c, 0x02),
91 ILI9881C_COMMAND_INSTR(0x0d, 0x03),
92 ILI9881C_COMMAND_INSTR(0x0e, 0x00),
93 ILI9881C_COMMAND_INSTR(0x0f, 0x25),
94 ILI9881C_COMMAND_INSTR(0x10, 0x25),
95 ILI9881C_COMMAND_INSTR(0x11, 0x00),
96 ILI9881C_COMMAND_INSTR(0x12, 0x00),
97 ILI9881C_COMMAND_INSTR(0x13, 0x00),
98 ILI9881C_COMMAND_INSTR(0x14, 0x00),
99 ILI9881C_COMMAND_INSTR(0x15, 0x00),
100 ILI9881C_COMMAND_INSTR(0x16, 0x0C),
101 ILI9881C_COMMAND_INSTR(0x17, 0x00),
102 ILI9881C_COMMAND_INSTR(0x18, 0x00),
103 ILI9881C_COMMAND_INSTR(0x19, 0x00),
104 ILI9881C_COMMAND_INSTR(0x1a, 0x00),
105 ILI9881C_COMMAND_INSTR(0x1b, 0x00),
106 ILI9881C_COMMAND_INSTR(0x1c, 0x00),
107 ILI9881C_COMMAND_INSTR(0x1d, 0x00),
108 ILI9881C_COMMAND_INSTR(0x1e, 0xC0),
109 ILI9881C_COMMAND_INSTR(0x1f, 0x80),
110 ILI9881C_COMMAND_INSTR(0x20, 0x04),
111 ILI9881C_COMMAND_INSTR(0x21, 0x01),
112 ILI9881C_COMMAND_INSTR(0x22, 0x00),
113 ILI9881C_COMMAND_INSTR(0x23, 0x00),
114 ILI9881C_COMMAND_INSTR(0x24, 0x00),
115 ILI9881C_COMMAND_INSTR(0x25, 0x00),
116 ILI9881C_COMMAND_INSTR(0x26, 0x00),
117 ILI9881C_COMMAND_INSTR(0x27, 0x00),
118 ILI9881C_COMMAND_INSTR(0x28, 0x33),
119 ILI9881C_COMMAND_INSTR(0x29, 0x03),
120 ILI9881C_COMMAND_INSTR(0x2a, 0x00),
121 ILI9881C_COMMAND_INSTR(0x2b, 0x00),
122 ILI9881C_COMMAND_INSTR(0x2c, 0x00),
123 ILI9881C_COMMAND_INSTR(0x2d, 0x00),
124 ILI9881C_COMMAND_INSTR(0x2e, 0x00),
125 ILI9881C_COMMAND_INSTR(0x2f, 0x00),
126 ILI9881C_COMMAND_INSTR(0x30, 0x00),
127 ILI9881C_COMMAND_INSTR(0x31, 0x00),
128 ILI9881C_COMMAND_INSTR(0x32, 0x00),
129 ILI9881C_COMMAND_INSTR(0x33, 0x00),
130 ILI9881C_COMMAND_INSTR(0x34, 0x04),
131 ILI9881C_COMMAND_INSTR(0x35, 0x00),
132 ILI9881C_COMMAND_INSTR(0x36, 0x00),
133 ILI9881C_COMMAND_INSTR(0x37, 0x00),
134 ILI9881C_COMMAND_INSTR(0x38, 0x3C),
135 ILI9881C_COMMAND_INSTR(0x39, 0x00),
136 ILI9881C_COMMAND_INSTR(0x3a, 0x00),
137 ILI9881C_COMMAND_INSTR(0x3b, 0x00),
138 ILI9881C_COMMAND_INSTR(0x3c, 0x00),
139 ILI9881C_COMMAND_INSTR(0x3d, 0x00),
140 ILI9881C_COMMAND_INSTR(0x3e, 0x00),
141 ILI9881C_COMMAND_INSTR(0x3f, 0x00),
142 ILI9881C_COMMAND_INSTR(0x40, 0x00),
143 ILI9881C_COMMAND_INSTR(0x41, 0x00),
144 ILI9881C_COMMAND_INSTR(0x42, 0x00),
145 ILI9881C_COMMAND_INSTR(0x43, 0x00),
146 ILI9881C_COMMAND_INSTR(0x44, 0x00),
147 ILI9881C_COMMAND_INSTR(0x50, 0x01),
148 ILI9881C_COMMAND_INSTR(0x51, 0x23),
149 ILI9881C_COMMAND_INSTR(0x52, 0x45),
150 ILI9881C_COMMAND_INSTR(0x53, 0x67),
151 ILI9881C_COMMAND_INSTR(0x54, 0x89),
152 ILI9881C_COMMAND_INSTR(0x55, 0xab),
153 ILI9881C_COMMAND_INSTR(0x56, 0x01),
154 ILI9881C_COMMAND_INSTR(0x57, 0x23),
155 ILI9881C_COMMAND_INSTR(0x58, 0x45),
156 ILI9881C_COMMAND_INSTR(0x59, 0x67),
157 ILI9881C_COMMAND_INSTR(0x5a, 0x89),
158 ILI9881C_COMMAND_INSTR(0x5b, 0xab),
159 ILI9881C_COMMAND_INSTR(0x5c, 0xcd),
160 ILI9881C_COMMAND_INSTR(0x5d, 0xef),
161 ILI9881C_COMMAND_INSTR(0x5e, 0x11),
162 ILI9881C_COMMAND_INSTR(0x5f, 0x02),
163 ILI9881C_COMMAND_INSTR(0x60, 0x02),
164 ILI9881C_COMMAND_INSTR(0x61, 0x02),
165 ILI9881C_COMMAND_INSTR(0x62, 0x02),
166 ILI9881C_COMMAND_INSTR(0x63, 0x02),
167 ILI9881C_COMMAND_INSTR(0x64, 0x02),
168 ILI9881C_COMMAND_INSTR(0x65, 0x02),
169 ILI9881C_COMMAND_INSTR(0x66, 0x02),
170 ILI9881C_COMMAND_INSTR(0x67, 0x02),
171 ILI9881C_COMMAND_INSTR(0x68, 0x02),
172 ILI9881C_COMMAND_INSTR(0x69, 0x02),
173 ILI9881C_COMMAND_INSTR(0x6a, 0x0C),
174 ILI9881C_COMMAND_INSTR(0x6b, 0x02),
175 ILI9881C_COMMAND_INSTR(0x6c, 0x0F),
176 ILI9881C_COMMAND_INSTR(0x6d, 0x0E),
177 ILI9881C_COMMAND_INSTR(0x6e, 0x0D),
178 ILI9881C_COMMAND_INSTR(0x6f, 0x06),
179 ILI9881C_COMMAND_INSTR(0x70, 0x07),
180 ILI9881C_COMMAND_INSTR(0x71, 0x02),
181 ILI9881C_COMMAND_INSTR(0x72, 0x02),
182 ILI9881C_COMMAND_INSTR(0x73, 0x02),
183 ILI9881C_COMMAND_INSTR(0x74, 0x02),
184 ILI9881C_COMMAND_INSTR(0x75, 0x02),
185 ILI9881C_COMMAND_INSTR(0x76, 0x02),
186 ILI9881C_COMMAND_INSTR(0x77, 0x02),
187 ILI9881C_COMMAND_INSTR(0x78, 0x02),
188 ILI9881C_COMMAND_INSTR(0x79, 0x02),
189 ILI9881C_COMMAND_INSTR(0x7a, 0x02),
190 ILI9881C_COMMAND_INSTR(0x7b, 0x02),
191 ILI9881C_COMMAND_INSTR(0x7c, 0x02),
192 ILI9881C_COMMAND_INSTR(0x7d, 0x02),
193 ILI9881C_COMMAND_INSTR(0x7e, 0x02),
194 ILI9881C_COMMAND_INSTR(0x7f, 0x02),
195 ILI9881C_COMMAND_INSTR(0x80, 0x0C),
196 ILI9881C_COMMAND_INSTR(0x81, 0x02),
197 ILI9881C_COMMAND_INSTR(0x82, 0x0F),
198 ILI9881C_COMMAND_INSTR(0x83, 0x0E),
199 ILI9881C_COMMAND_INSTR(0x84, 0x0D),
200 ILI9881C_COMMAND_INSTR(0x85, 0x06),
201 ILI9881C_COMMAND_INSTR(0x86, 0x07),
202 ILI9881C_COMMAND_INSTR(0x87, 0x02),
203 ILI9881C_COMMAND_INSTR(0x88, 0x02),
204 ILI9881C_COMMAND_INSTR(0x89, 0x02),
205 ILI9881C_COMMAND_INSTR(0x8A, 0x02),
206 ILI9881C_SWITCH_PAGE_INSTR(4),
207 ILI9881C_COMMAND_INSTR(0x6C, 0x15),
208 ILI9881C_COMMAND_INSTR(0x6E, 0x22),
209 ILI9881C_COMMAND_INSTR(0x6F, 0x33),
210 ILI9881C_COMMAND_INSTR(0x3A, 0xA4),
211 ILI9881C_COMMAND_INSTR(0x8D, 0x0D),
212 ILI9881C_COMMAND_INSTR(0x87, 0xBA),
213 ILI9881C_COMMAND_INSTR(0x26, 0x76),
214 ILI9881C_COMMAND_INSTR(0xB2, 0xD1),
215 ILI9881C_SWITCH_PAGE_INSTR(1),
216 ILI9881C_COMMAND_INSTR(0x22, 0x0A),
217 ILI9881C_COMMAND_INSTR(0x53, 0xDC),
218 ILI9881C_COMMAND_INSTR(0x55, 0xA7),
219 ILI9881C_COMMAND_INSTR(0x50, 0x78),
220 ILI9881C_COMMAND_INSTR(0x51, 0x78),
221 ILI9881C_COMMAND_INSTR(0x31, 0x02),
222 ILI9881C_COMMAND_INSTR(0x60, 0x14),
223 ILI9881C_COMMAND_INSTR(0xA0, 0x2A),
224 ILI9881C_COMMAND_INSTR(0xA1, 0x39),
225 ILI9881C_COMMAND_INSTR(0xA2, 0x46),
226 ILI9881C_COMMAND_INSTR(0xA3, 0x0e),
227 ILI9881C_COMMAND_INSTR(0xA4, 0x12),
228 ILI9881C_COMMAND_INSTR(0xA5, 0x25),
229 ILI9881C_COMMAND_INSTR(0xA6, 0x19),
230 ILI9881C_COMMAND_INSTR(0xA7, 0x1d),
231 ILI9881C_COMMAND_INSTR(0xA8, 0xa6),
232 ILI9881C_COMMAND_INSTR(0xA9, 0x1C),
233 ILI9881C_COMMAND_INSTR(0xAA, 0x29),
234 ILI9881C_COMMAND_INSTR(0xAB, 0x85),
235 ILI9881C_COMMAND_INSTR(0xAC, 0x1C),
236 ILI9881C_COMMAND_INSTR(0xAD, 0x1B),
237 ILI9881C_COMMAND_INSTR(0xAE, 0x51),
238 ILI9881C_COMMAND_INSTR(0xAF, 0x22),
239 ILI9881C_COMMAND_INSTR(0xB0, 0x2d),
240 ILI9881C_COMMAND_INSTR(0xB1, 0x4f),
241 ILI9881C_COMMAND_INSTR(0xB2, 0x59),
242 ILI9881C_COMMAND_INSTR(0xB3, 0x3F),
243 ILI9881C_COMMAND_INSTR(0xC0, 0x2A),
244 ILI9881C_COMMAND_INSTR(0xC1, 0x3a),
245 ILI9881C_COMMAND_INSTR(0xC2, 0x45),
246 ILI9881C_COMMAND_INSTR(0xC3, 0x0e),
247 ILI9881C_COMMAND_INSTR(0xC4, 0x11),
248 ILI9881C_COMMAND_INSTR(0xC5, 0x24),
249 ILI9881C_COMMAND_INSTR(0xC6, 0x1a),
250 ILI9881C_COMMAND_INSTR(0xC7, 0x1c),
251 ILI9881C_COMMAND_INSTR(0xC8, 0xaa),
252 ILI9881C_COMMAND_INSTR(0xC9, 0x1C),
253 ILI9881C_COMMAND_INSTR(0xCA, 0x29),
254 ILI9881C_COMMAND_INSTR(0xCB, 0x96),
255 ILI9881C_COMMAND_INSTR(0xCC, 0x1C),
256 ILI9881C_COMMAND_INSTR(0xCD, 0x1B),
257 ILI9881C_COMMAND_INSTR(0xCE, 0x51),
258 ILI9881C_COMMAND_INSTR(0xCF, 0x22),
259 ILI9881C_COMMAND_INSTR(0xD0, 0x2b),
260 ILI9881C_COMMAND_INSTR(0xD1, 0x4b),
261 ILI9881C_COMMAND_INSTR(0xD2, 0x59),
262 ILI9881C_COMMAND_INSTR(0xD3, 0x3F),
263 };
264
265 static const struct ili9881c_instr k101_im2byl02_init[] = {
266 ILI9881C_SWITCH_PAGE_INSTR(3),
267 ILI9881C_COMMAND_INSTR(0x01, 0x00),
268 ILI9881C_COMMAND_INSTR(0x02, 0x00),
269 ILI9881C_COMMAND_INSTR(0x03, 0x73),
270 ILI9881C_COMMAND_INSTR(0x04, 0x00),
271 ILI9881C_COMMAND_INSTR(0x05, 0x00),
272 ILI9881C_COMMAND_INSTR(0x06, 0x08),
273 ILI9881C_COMMAND_INSTR(0x07, 0x00),
274 ILI9881C_COMMAND_INSTR(0x08, 0x00),
275 ILI9881C_COMMAND_INSTR(0x09, 0x00),
276 ILI9881C_COMMAND_INSTR(0x0A, 0x01),
277 ILI9881C_COMMAND_INSTR(0x0B, 0x01),
278 ILI9881C_COMMAND_INSTR(0x0C, 0x00),
279 ILI9881C_COMMAND_INSTR(0x0D, 0x01),
280 ILI9881C_COMMAND_INSTR(0x0E, 0x01),
281 ILI9881C_COMMAND_INSTR(0x0F, 0x00),
282 ILI9881C_COMMAND_INSTR(0x10, 0x00),
283 ILI9881C_COMMAND_INSTR(0x11, 0x00),
284 ILI9881C_COMMAND_INSTR(0x12, 0x00),
285 ILI9881C_COMMAND_INSTR(0x13, 0x00),
286 ILI9881C_COMMAND_INSTR(0x14, 0x00),
287 ILI9881C_COMMAND_INSTR(0x15, 0x00),
288 ILI9881C_COMMAND_INSTR(0x16, 0x00),
289 ILI9881C_COMMAND_INSTR(0x17, 0x00),
290 ILI9881C_COMMAND_INSTR(0x18, 0x00),
291 ILI9881C_COMMAND_INSTR(0x19, 0x00),
292 ILI9881C_COMMAND_INSTR(0x1A, 0x00),
293 ILI9881C_COMMAND_INSTR(0x1B, 0x00),
294 ILI9881C_COMMAND_INSTR(0x1C, 0x00),
295 ILI9881C_COMMAND_INSTR(0x1D, 0x00),
296 ILI9881C_COMMAND_INSTR(0x1E, 0x40),
297 ILI9881C_COMMAND_INSTR(0x1F, 0xC0),
298 ILI9881C_COMMAND_INSTR(0x20, 0x06),
299 ILI9881C_COMMAND_INSTR(0x21, 0x01),
300 ILI9881C_COMMAND_INSTR(0x22, 0x06),
301 ILI9881C_COMMAND_INSTR(0x23, 0x01),
302 ILI9881C_COMMAND_INSTR(0x24, 0x88),
303 ILI9881C_COMMAND_INSTR(0x25, 0x88),
304 ILI9881C_COMMAND_INSTR(0x26, 0x00),
305 ILI9881C_COMMAND_INSTR(0x27, 0x00),
306 ILI9881C_COMMAND_INSTR(0x28, 0x3B),
307 ILI9881C_COMMAND_INSTR(0x29, 0x03),
308 ILI9881C_COMMAND_INSTR(0x2A, 0x00),
309 ILI9881C_COMMAND_INSTR(0x2B, 0x00),
310 ILI9881C_COMMAND_INSTR(0x2C, 0x00),
311 ILI9881C_COMMAND_INSTR(0x2D, 0x00),
312 ILI9881C_COMMAND_INSTR(0x2E, 0x00),
313 ILI9881C_COMMAND_INSTR(0x2F, 0x00),
314 ILI9881C_COMMAND_INSTR(0x30, 0x00),
315 ILI9881C_COMMAND_INSTR(0x31, 0x00),
316 ILI9881C_COMMAND_INSTR(0x32, 0x00),
317 ILI9881C_COMMAND_INSTR(0x33, 0x00),
318 ILI9881C_COMMAND_INSTR(0x34, 0x00), /* GPWR1/2 non overlap time 2.62us */
319 ILI9881C_COMMAND_INSTR(0x35, 0x00),
320 ILI9881C_COMMAND_INSTR(0x36, 0x00),
321 ILI9881C_COMMAND_INSTR(0x37, 0x00),
322 ILI9881C_COMMAND_INSTR(0x38, 0x00),
323 ILI9881C_COMMAND_INSTR(0x39, 0x00),
324 ILI9881C_COMMAND_INSTR(0x3A, 0x00),
325 ILI9881C_COMMAND_INSTR(0x3B, 0x00),
326 ILI9881C_COMMAND_INSTR(0x3C, 0x00),
327 ILI9881C_COMMAND_INSTR(0x3D, 0x00),
328 ILI9881C_COMMAND_INSTR(0x3E, 0x00),
329 ILI9881C_COMMAND_INSTR(0x3F, 0x00),
330 ILI9881C_COMMAND_INSTR(0x40, 0x00),
331 ILI9881C_COMMAND_INSTR(0x41, 0x00),
332 ILI9881C_COMMAND_INSTR(0x42, 0x00),
333 ILI9881C_COMMAND_INSTR(0x43, 0x00),
334 ILI9881C_COMMAND_INSTR(0x44, 0x00),
335 ILI9881C_COMMAND_INSTR(0x50, 0x01),
336 ILI9881C_COMMAND_INSTR(0x51, 0x23),
337 ILI9881C_COMMAND_INSTR(0x52, 0x45),
338 ILI9881C_COMMAND_INSTR(0x53, 0x67),
339 ILI9881C_COMMAND_INSTR(0x54, 0x89),
340 ILI9881C_COMMAND_INSTR(0x55, 0xAB),
341 ILI9881C_COMMAND_INSTR(0x56, 0x01),
342 ILI9881C_COMMAND_INSTR(0x57, 0x23),
343 ILI9881C_COMMAND_INSTR(0x58, 0x45),
344 ILI9881C_COMMAND_INSTR(0x59, 0x67),
345 ILI9881C_COMMAND_INSTR(0x5A, 0x89),
346 ILI9881C_COMMAND_INSTR(0x5B, 0xAB),
347 ILI9881C_COMMAND_INSTR(0x5C, 0xCD),
348 ILI9881C_COMMAND_INSTR(0x5D, 0xEF),
349 ILI9881C_COMMAND_INSTR(0x5E, 0x00),
350 ILI9881C_COMMAND_INSTR(0x5F, 0x01),
351 ILI9881C_COMMAND_INSTR(0x60, 0x01),
352 ILI9881C_COMMAND_INSTR(0x61, 0x06),
353 ILI9881C_COMMAND_INSTR(0x62, 0x06),
354 ILI9881C_COMMAND_INSTR(0x63, 0x07),
355 ILI9881C_COMMAND_INSTR(0x64, 0x07),
356 ILI9881C_COMMAND_INSTR(0x65, 0x00),
357 ILI9881C_COMMAND_INSTR(0x66, 0x00),
358 ILI9881C_COMMAND_INSTR(0x67, 0x02),
359 ILI9881C_COMMAND_INSTR(0x68, 0x02),
360 ILI9881C_COMMAND_INSTR(0x69, 0x05),
361 ILI9881C_COMMAND_INSTR(0x6A, 0x05),
362 ILI9881C_COMMAND_INSTR(0x6B, 0x02),
363 ILI9881C_COMMAND_INSTR(0x6C, 0x0D),
364 ILI9881C_COMMAND_INSTR(0x6D, 0x0D),
365 ILI9881C_COMMAND_INSTR(0x6E, 0x0C),
366 ILI9881C_COMMAND_INSTR(0x6F, 0x0C),
367 ILI9881C_COMMAND_INSTR(0x70, 0x0F),
368 ILI9881C_COMMAND_INSTR(0x71, 0x0F),
369 ILI9881C_COMMAND_INSTR(0x72, 0x0E),
370 ILI9881C_COMMAND_INSTR(0x73, 0x0E),
371 ILI9881C_COMMAND_INSTR(0x74, 0x02),
372 ILI9881C_COMMAND_INSTR(0x75, 0x01),
373 ILI9881C_COMMAND_INSTR(0x76, 0x01),
374 ILI9881C_COMMAND_INSTR(0x77, 0x06),
375 ILI9881C_COMMAND_INSTR(0x78, 0x06),
376 ILI9881C_COMMAND_INSTR(0x79, 0x07),
377 ILI9881C_COMMAND_INSTR(0x7A, 0x07),
378 ILI9881C_COMMAND_INSTR(0x7B, 0x00),
379 ILI9881C_COMMAND_INSTR(0x7C, 0x00),
380 ILI9881C_COMMAND_INSTR(0x7D, 0x02),
381 ILI9881C_COMMAND_INSTR(0x7E, 0x02),
382 ILI9881C_COMMAND_INSTR(0x7F, 0x05),
383 ILI9881C_COMMAND_INSTR(0x80, 0x05),
384 ILI9881C_COMMAND_INSTR(0x81, 0x02),
385 ILI9881C_COMMAND_INSTR(0x82, 0x0D),
386 ILI9881C_COMMAND_INSTR(0x83, 0x0D),
387 ILI9881C_COMMAND_INSTR(0x84, 0x0C),
388 ILI9881C_COMMAND_INSTR(0x85, 0x0C),
389 ILI9881C_COMMAND_INSTR(0x86, 0x0F),
390 ILI9881C_COMMAND_INSTR(0x87, 0x0F),
391 ILI9881C_COMMAND_INSTR(0x88, 0x0E),
392 ILI9881C_COMMAND_INSTR(0x89, 0x0E),
393 ILI9881C_COMMAND_INSTR(0x8A, 0x02),
394 ILI9881C_SWITCH_PAGE_INSTR(4),
395 ILI9881C_COMMAND_INSTR(0x3B, 0xC0), /* ILI4003D sel */
396 ILI9881C_COMMAND_INSTR(0x6C, 0x15), /* Set VCORE voltage = 1.5V */
397 ILI9881C_COMMAND_INSTR(0x6E, 0x2A), /* di_pwr_reg=0 for power mode 2A, VGH clamp 18V */
398 ILI9881C_COMMAND_INSTR(0x6F, 0x33), /* pumping ratio VGH=5x VGL=-3x */
399 ILI9881C_COMMAND_INSTR(0x8D, 0x1B), /* VGL clamp -10V */
400 ILI9881C_COMMAND_INSTR(0x87, 0xBA), /* ESD */
401 ILI9881C_COMMAND_INSTR(0x3A, 0x24), /* POWER SAVING */
402 ILI9881C_COMMAND_INSTR(0x26, 0x76),
403 ILI9881C_COMMAND_INSTR(0xB2, 0xD1),
404 ILI9881C_SWITCH_PAGE_INSTR(1),
405 ILI9881C_COMMAND_INSTR(0x22, 0x0A), /* BGR, SS */
406 ILI9881C_COMMAND_INSTR(0x31, 0x00), /* Zigzag type3 inversion */
407 ILI9881C_COMMAND_INSTR(0x40, 0x53), /* ILI4003D sel */
408 ILI9881C_COMMAND_INSTR(0x43, 0x66),
409 ILI9881C_COMMAND_INSTR(0x53, 0x4C),
410 ILI9881C_COMMAND_INSTR(0x50, 0x87),
411 ILI9881C_COMMAND_INSTR(0x51, 0x82),
412 ILI9881C_COMMAND_INSTR(0x60, 0x15),
413 ILI9881C_COMMAND_INSTR(0x61, 0x01),
414 ILI9881C_COMMAND_INSTR(0x62, 0x0C),
415 ILI9881C_COMMAND_INSTR(0x63, 0x00),
416 ILI9881C_COMMAND_INSTR(0xA0, 0x00),
417 ILI9881C_COMMAND_INSTR(0xA1, 0x13), /* VP251 */
418 ILI9881C_COMMAND_INSTR(0xA2, 0x23), /* VP247 */
419 ILI9881C_COMMAND_INSTR(0xA3, 0x14), /* VP243 */
420 ILI9881C_COMMAND_INSTR(0xA4, 0x16), /* VP239 */
421 ILI9881C_COMMAND_INSTR(0xA5, 0x29), /* VP231 */
422 ILI9881C_COMMAND_INSTR(0xA6, 0x1E), /* VP219 */
423 ILI9881C_COMMAND_INSTR(0xA7, 0x1D), /* VP203 */
424 ILI9881C_COMMAND_INSTR(0xA8, 0x86), /* VP175 */
425 ILI9881C_COMMAND_INSTR(0xA9, 0x1E), /* VP144 */
426 ILI9881C_COMMAND_INSTR(0xAA, 0x29), /* VP111 */
427 ILI9881C_COMMAND_INSTR(0xAB, 0x74), /* VP80 */
428 ILI9881C_COMMAND_INSTR(0xAC, 0x19), /* VP52 */
429 ILI9881C_COMMAND_INSTR(0xAD, 0x17), /* VP36 */
430 ILI9881C_COMMAND_INSTR(0xAE, 0x4B), /* VP24 */
431 ILI9881C_COMMAND_INSTR(0xAF, 0x20), /* VP16 */
432 ILI9881C_COMMAND_INSTR(0xB0, 0x26), /* VP12 */
433 ILI9881C_COMMAND_INSTR(0xB1, 0x4C), /* VP8 */
434 ILI9881C_COMMAND_INSTR(0xB2, 0x5D), /* VP4 */
435 ILI9881C_COMMAND_INSTR(0xB3, 0x3F), /* VP0 */
436 ILI9881C_COMMAND_INSTR(0xC0, 0x00), /* VN255 GAMMA N */
437 ILI9881C_COMMAND_INSTR(0xC1, 0x13), /* VN251 */
438 ILI9881C_COMMAND_INSTR(0xC2, 0x23), /* VN247 */
439 ILI9881C_COMMAND_INSTR(0xC3, 0x14), /* VN243 */
440 ILI9881C_COMMAND_INSTR(0xC4, 0x16), /* VN239 */
441 ILI9881C_COMMAND_INSTR(0xC5, 0x29), /* VN231 */
442 ILI9881C_COMMAND_INSTR(0xC6, 0x1E), /* VN219 */
443 ILI9881C_COMMAND_INSTR(0xC7, 0x1D), /* VN203 */
444 ILI9881C_COMMAND_INSTR(0xC8, 0x86), /* VN175 */
445 ILI9881C_COMMAND_INSTR(0xC9, 0x1E), /* VN144 */
446 ILI9881C_COMMAND_INSTR(0xCA, 0x29), /* VN111 */
447 ILI9881C_COMMAND_INSTR(0xCB, 0x74), /* VN80 */
448 ILI9881C_COMMAND_INSTR(0xCC, 0x19), /* VN52 */
449 ILI9881C_COMMAND_INSTR(0xCD, 0x17), /* VN36 */
450 ILI9881C_COMMAND_INSTR(0xCE, 0x4B), /* VN24 */
451 ILI9881C_COMMAND_INSTR(0xCF, 0x20), /* VN16 */
452 ILI9881C_COMMAND_INSTR(0xD0, 0x26), /* VN12 */
453 ILI9881C_COMMAND_INSTR(0xD1, 0x4C), /* VN8 */
454 ILI9881C_COMMAND_INSTR(0xD2, 0x5D), /* VN4 */
455 ILI9881C_COMMAND_INSTR(0xD3, 0x3F), /* VN0 */
456 };
457
458 static const struct ili9881c_instr tl050hdv35_init[] = {
459 ILI9881C_SWITCH_PAGE_INSTR(3),
460 ILI9881C_COMMAND_INSTR(0x01, 0x00),
461 ILI9881C_COMMAND_INSTR(0x02, 0x00),
462 ILI9881C_COMMAND_INSTR(0x03, 0x73),
463 ILI9881C_COMMAND_INSTR(0x04, 0x00),
464 ILI9881C_COMMAND_INSTR(0x05, 0x00),
465 ILI9881C_COMMAND_INSTR(0x06, 0x0a),
466 ILI9881C_COMMAND_INSTR(0x07, 0x00),
467 ILI9881C_COMMAND_INSTR(0x08, 0x00),
468 ILI9881C_COMMAND_INSTR(0x09, 0x01),
469 ILI9881C_COMMAND_INSTR(0x0a, 0x00),
470 ILI9881C_COMMAND_INSTR(0x0b, 0x00),
471 ILI9881C_COMMAND_INSTR(0x0c, 0x01),
472 ILI9881C_COMMAND_INSTR(0x0d, 0x00),
473 ILI9881C_COMMAND_INSTR(0x0e, 0x00),
474 ILI9881C_COMMAND_INSTR(0x0f, 0x1d),
475 ILI9881C_COMMAND_INSTR(0x10, 0x1d),
476 ILI9881C_COMMAND_INSTR(0x15, 0x00),
477 ILI9881C_COMMAND_INSTR(0x16, 0x00),
478 ILI9881C_COMMAND_INSTR(0x17, 0x00),
479 ILI9881C_COMMAND_INSTR(0x18, 0x00),
480 ILI9881C_COMMAND_INSTR(0x19, 0x00),
481 ILI9881C_COMMAND_INSTR(0x1a, 0x00),
482 ILI9881C_COMMAND_INSTR(0x1b, 0x00),
483 ILI9881C_COMMAND_INSTR(0x1c, 0x00),
484 ILI9881C_COMMAND_INSTR(0x1d, 0x00),
485 ILI9881C_COMMAND_INSTR(0x1e, 0x40),
486 ILI9881C_COMMAND_INSTR(0x1f, 0x80),
487 ILI9881C_COMMAND_INSTR(0x20, 0x06),
488 ILI9881C_COMMAND_INSTR(0x21, 0x02),
489 ILI9881C_COMMAND_INSTR(0x28, 0x33),
490 ILI9881C_COMMAND_INSTR(0x29, 0x03),
491 ILI9881C_COMMAND_INSTR(0x2a, 0x00),
492 ILI9881C_COMMAND_INSTR(0x2b, 0x00),
493 ILI9881C_COMMAND_INSTR(0x2c, 0x00),
494 ILI9881C_COMMAND_INSTR(0x2d, 0x00),
495 ILI9881C_COMMAND_INSTR(0x2e, 0x00),
496 ILI9881C_COMMAND_INSTR(0x2f, 0x00),
497 ILI9881C_COMMAND_INSTR(0x35, 0x00),
498 ILI9881C_COMMAND_INSTR(0x36, 0x00),
499 ILI9881C_COMMAND_INSTR(0x37, 0x00),
500 ILI9881C_COMMAND_INSTR(0x38, 0x3C),
501 ILI9881C_COMMAND_INSTR(0x39, 0x00),
502 ILI9881C_COMMAND_INSTR(0x3a, 0x40),
503 ILI9881C_COMMAND_INSTR(0x3b, 0x40),
504 ILI9881C_COMMAND_INSTR(0x3c, 0x00),
505 ILI9881C_COMMAND_INSTR(0x3d, 0x00),
506 ILI9881C_COMMAND_INSTR(0x3e, 0x00),
507 ILI9881C_COMMAND_INSTR(0x3f, 0x00),
508 ILI9881C_COMMAND_INSTR(0x40, 0x00),
509 ILI9881C_COMMAND_INSTR(0x41, 0x00),
510 ILI9881C_COMMAND_INSTR(0x42, 0x00),
511 ILI9881C_COMMAND_INSTR(0x43, 0x00),
512 ILI9881C_COMMAND_INSTR(0x44, 0x00),
513 ILI9881C_COMMAND_INSTR(0x55, 0xab),
514 ILI9881C_COMMAND_INSTR(0x5a, 0x89),
515 ILI9881C_COMMAND_INSTR(0x5b, 0xab),
516 ILI9881C_COMMAND_INSTR(0x5c, 0xcd),
517 ILI9881C_COMMAND_INSTR(0x5d, 0xef),
518 ILI9881C_COMMAND_INSTR(0x5e, 0x11),
519 ILI9881C_COMMAND_INSTR(0x5f, 0x01),
520 ILI9881C_COMMAND_INSTR(0x60, 0x00),
521 ILI9881C_COMMAND_INSTR(0x61, 0x15),
522 ILI9881C_COMMAND_INSTR(0x62, 0x14),
523 ILI9881C_COMMAND_INSTR(0x63, 0x0e),
524 ILI9881C_COMMAND_INSTR(0x64, 0x0f),
525 ILI9881C_COMMAND_INSTR(0x65, 0x0c),
526 ILI9881C_COMMAND_INSTR(0x66, 0x0d),
527 ILI9881C_COMMAND_INSTR(0x67, 0x06),
528 ILI9881C_COMMAND_INSTR(0x68, 0x02),
529 ILI9881C_COMMAND_INSTR(0x69, 0x07),
530 ILI9881C_COMMAND_INSTR(0x6a, 0x02),
531 ILI9881C_COMMAND_INSTR(0x6b, 0x02),
532 ILI9881C_COMMAND_INSTR(0x6c, 0x02),
533 ILI9881C_COMMAND_INSTR(0x6d, 0x02),
534 ILI9881C_COMMAND_INSTR(0x6e, 0x02),
535 ILI9881C_COMMAND_INSTR(0x6f, 0x02),
536 ILI9881C_COMMAND_INSTR(0x70, 0x02),
537 ILI9881C_COMMAND_INSTR(0x71, 0x02),
538 ILI9881C_COMMAND_INSTR(0x72, 0x02),
539 ILI9881C_COMMAND_INSTR(0x73, 0x02),
540 ILI9881C_COMMAND_INSTR(0x74, 0x02),
541 ILI9881C_COMMAND_INSTR(0x75, 0x01),
542 ILI9881C_COMMAND_INSTR(0x76, 0x00),
543 ILI9881C_COMMAND_INSTR(0x77, 0x14),
544 ILI9881C_COMMAND_INSTR(0x78, 0x15),
545 ILI9881C_COMMAND_INSTR(0x79, 0x0e),
546 ILI9881C_COMMAND_INSTR(0x7a, 0x0f),
547 ILI9881C_COMMAND_INSTR(0x7b, 0x0c),
548 ILI9881C_COMMAND_INSTR(0x7c, 0x0d),
549 ILI9881C_COMMAND_INSTR(0x7d, 0x06),
550 ILI9881C_COMMAND_INSTR(0x7e, 0x02),
551 ILI9881C_COMMAND_INSTR(0x7f, 0x07),
552 ILI9881C_COMMAND_INSTR(0x88, 0x02),
553 ILI9881C_COMMAND_INSTR(0x89, 0x02),
554 ILI9881C_COMMAND_INSTR(0x8A, 0x02),
555 ILI9881C_SWITCH_PAGE_INSTR(4),
556 ILI9881C_COMMAND_INSTR(0x38, 0x01),
557 ILI9881C_COMMAND_INSTR(0x39, 0x00),
558 ILI9881C_COMMAND_INSTR(0x6c, 0x15),
559 ILI9881C_COMMAND_INSTR(0x6e, 0x2b),
560 ILI9881C_COMMAND_INSTR(0x6f, 0x33),
561 ILI9881C_COMMAND_INSTR(0x8d, 0x18),
562 ILI9881C_COMMAND_INSTR(0x87, 0xba),
563 ILI9881C_COMMAND_INSTR(0x26, 0x76),
564 ILI9881C_COMMAND_INSTR(0xb2, 0xd1),
565 ILI9881C_COMMAND_INSTR(0xb5, 0x06),
566 ILI9881C_COMMAND_INSTR(0x3a, 0x24),
567 ILI9881C_COMMAND_INSTR(0x35, 0x1f),
568 ILI9881C_COMMAND_INSTR(0x33, 0x14),
569 ILI9881C_COMMAND_INSTR(0x3b, 0x98),
570 ILI9881C_SWITCH_PAGE_INSTR(1),
571 ILI9881C_COMMAND_INSTR(0x22, 0x0a),
572 ILI9881C_COMMAND_INSTR(0x31, 0x00),
573 ILI9881C_COMMAND_INSTR(0x40, 0x33),
574 ILI9881C_COMMAND_INSTR(0x53, 0xa2),
575 ILI9881C_COMMAND_INSTR(0x55, 0x92),
576 ILI9881C_COMMAND_INSTR(0x50, 0x96),
577 ILI9881C_COMMAND_INSTR(0x51, 0x96),
578 ILI9881C_COMMAND_INSTR(0x60, 0x22),
579 ILI9881C_COMMAND_INSTR(0x61, 0x00),
580 ILI9881C_COMMAND_INSTR(0x62, 0x19),
581 ILI9881C_COMMAND_INSTR(0x63, 0x00),
582 ILI9881C_COMMAND_INSTR(0xa0, 0x08),
583 ILI9881C_COMMAND_INSTR(0xa1, 0x11),
584 ILI9881C_COMMAND_INSTR(0xa2, 0x19),
585 ILI9881C_COMMAND_INSTR(0xa3, 0x0d),
586 ILI9881C_COMMAND_INSTR(0xa4, 0x0d),
587 ILI9881C_COMMAND_INSTR(0xa5, 0x1e),
588 ILI9881C_COMMAND_INSTR(0xa6, 0x14),
589 ILI9881C_COMMAND_INSTR(0xa7, 0x17),
590 ILI9881C_COMMAND_INSTR(0xa8, 0x4f),
591 ILI9881C_COMMAND_INSTR(0xa9, 0x1a),
592 ILI9881C_COMMAND_INSTR(0xaa, 0x27),
593 ILI9881C_COMMAND_INSTR(0xab, 0x49),
594 ILI9881C_COMMAND_INSTR(0xac, 0x1a),
595 ILI9881C_COMMAND_INSTR(0xad, 0x18),
596 ILI9881C_COMMAND_INSTR(0xae, 0x4c),
597 ILI9881C_COMMAND_INSTR(0xaf, 0x22),
598 ILI9881C_COMMAND_INSTR(0xb0, 0x27),
599 ILI9881C_COMMAND_INSTR(0xb1, 0x4b),
600 ILI9881C_COMMAND_INSTR(0xb2, 0x60),
601 ILI9881C_COMMAND_INSTR(0xb3, 0x39),
602 ILI9881C_COMMAND_INSTR(0xc0, 0x08),
603 ILI9881C_COMMAND_INSTR(0xc1, 0x11),
604 ILI9881C_COMMAND_INSTR(0xc2, 0x19),
605 ILI9881C_COMMAND_INSTR(0xc3, 0x0d),
606 ILI9881C_COMMAND_INSTR(0xc4, 0x0d),
607 ILI9881C_COMMAND_INSTR(0xc5, 0x1e),
608 ILI9881C_COMMAND_INSTR(0xc6, 0x14),
609 ILI9881C_COMMAND_INSTR(0xc7, 0x17),
610 ILI9881C_COMMAND_INSTR(0xc8, 0x4f),
611 ILI9881C_COMMAND_INSTR(0xc9, 0x1a),
612 ILI9881C_COMMAND_INSTR(0xca, 0x27),
613 ILI9881C_COMMAND_INSTR(0xcb, 0x49),
614 ILI9881C_COMMAND_INSTR(0xcc, 0x1a),
615 ILI9881C_COMMAND_INSTR(0xcd, 0x18),
616 ILI9881C_COMMAND_INSTR(0xce, 0x4c),
617 ILI9881C_COMMAND_INSTR(0xcf, 0x33),
618 ILI9881C_COMMAND_INSTR(0xd0, 0x27),
619 ILI9881C_COMMAND_INSTR(0xd1, 0x4b),
620 ILI9881C_COMMAND_INSTR(0xd2, 0x60),
621 ILI9881C_COMMAND_INSTR(0xd3, 0x39),
622 ILI9881C_SWITCH_PAGE_INSTR(0),
623 ILI9881C_COMMAND_INSTR(0x36, 0x03),
624 };
625
626 static const struct ili9881c_instr w552946ab_init[] = {
627 ILI9881C_SWITCH_PAGE_INSTR(3),
628 ILI9881C_COMMAND_INSTR(0x01, 0x00),
629 ILI9881C_COMMAND_INSTR(0x02, 0x00),
630 ILI9881C_COMMAND_INSTR(0x03, 0x53),
631 ILI9881C_COMMAND_INSTR(0x04, 0x53),
632 ILI9881C_COMMAND_INSTR(0x05, 0x13),
633 ILI9881C_COMMAND_INSTR(0x06, 0x04),
634 ILI9881C_COMMAND_INSTR(0x07, 0x02),
635 ILI9881C_COMMAND_INSTR(0x08, 0x02),
636 ILI9881C_COMMAND_INSTR(0x09, 0x00),
637 ILI9881C_COMMAND_INSTR(0x0A, 0x00),
638 ILI9881C_COMMAND_INSTR(0x0B, 0x00),
639 ILI9881C_COMMAND_INSTR(0x0C, 0x00),
640 ILI9881C_COMMAND_INSTR(0x0D, 0x00),
641 ILI9881C_COMMAND_INSTR(0x0E, 0x00),
642 ILI9881C_COMMAND_INSTR(0x0F, 0x00),
643
644 ILI9881C_COMMAND_INSTR(0x10, 0x00),
645 ILI9881C_COMMAND_INSTR(0x11, 0x00),
646 ILI9881C_COMMAND_INSTR(0x12, 0x00),
647 ILI9881C_COMMAND_INSTR(0x13, 0x00),
648 ILI9881C_COMMAND_INSTR(0x14, 0x00),
649 ILI9881C_COMMAND_INSTR(0x15, 0x08),
650 ILI9881C_COMMAND_INSTR(0x16, 0x10),
651 ILI9881C_COMMAND_INSTR(0x17, 0x00),
652 ILI9881C_COMMAND_INSTR(0x18, 0x08),
653 ILI9881C_COMMAND_INSTR(0x19, 0x00),
654 ILI9881C_COMMAND_INSTR(0x1A, 0x00),
655 ILI9881C_COMMAND_INSTR(0x1B, 0x00),
656 ILI9881C_COMMAND_INSTR(0x1C, 0x00),
657 ILI9881C_COMMAND_INSTR(0x1D, 0x00),
658 ILI9881C_COMMAND_INSTR(0x1E, 0xC0),
659 ILI9881C_COMMAND_INSTR(0x1F, 0x80),
660
661 ILI9881C_COMMAND_INSTR(0x20, 0x02),
662 ILI9881C_COMMAND_INSTR(0x21, 0x09),
663 ILI9881C_COMMAND_INSTR(0x22, 0x00),
664 ILI9881C_COMMAND_INSTR(0x23, 0x00),
665 ILI9881C_COMMAND_INSTR(0x24, 0x00),
666 ILI9881C_COMMAND_INSTR(0x25, 0x00),
667 ILI9881C_COMMAND_INSTR(0x26, 0x00),
668 ILI9881C_COMMAND_INSTR(0x27, 0x00),
669 ILI9881C_COMMAND_INSTR(0x28, 0x55),
670 ILI9881C_COMMAND_INSTR(0x29, 0x03),
671 ILI9881C_COMMAND_INSTR(0x2A, 0x00),
672 ILI9881C_COMMAND_INSTR(0x2B, 0x00),
673 ILI9881C_COMMAND_INSTR(0x2C, 0x00),
674 ILI9881C_COMMAND_INSTR(0x2D, 0x00),
675 ILI9881C_COMMAND_INSTR(0x2E, 0x00),
676 ILI9881C_COMMAND_INSTR(0x2F, 0x00),
677
678 ILI9881C_COMMAND_INSTR(0x30, 0x00),
679 ILI9881C_COMMAND_INSTR(0x31, 0x00),
680 ILI9881C_COMMAND_INSTR(0x32, 0x00),
681 ILI9881C_COMMAND_INSTR(0x33, 0x00),
682 ILI9881C_COMMAND_INSTR(0x34, 0x04),
683 ILI9881C_COMMAND_INSTR(0x35, 0x05),
684 ILI9881C_COMMAND_INSTR(0x36, 0x05),
685 ILI9881C_COMMAND_INSTR(0x37, 0x00),
686 ILI9881C_COMMAND_INSTR(0x38, 0x3C),
687 ILI9881C_COMMAND_INSTR(0x39, 0x35),
688 ILI9881C_COMMAND_INSTR(0x3A, 0x00),
689 ILI9881C_COMMAND_INSTR(0x3B, 0x40),
690 ILI9881C_COMMAND_INSTR(0x3C, 0x00),
691 ILI9881C_COMMAND_INSTR(0x3D, 0x00),
692 ILI9881C_COMMAND_INSTR(0x3E, 0x00),
693 ILI9881C_COMMAND_INSTR(0x3F, 0x00),
694
695 ILI9881C_COMMAND_INSTR(0x40, 0x00),
696 ILI9881C_COMMAND_INSTR(0x41, 0x88),
697 ILI9881C_COMMAND_INSTR(0x42, 0x00),
698 ILI9881C_COMMAND_INSTR(0x43, 0x00),
699 ILI9881C_COMMAND_INSTR(0x44, 0x1F),
700
701 ILI9881C_COMMAND_INSTR(0x50, 0x01),
702 ILI9881C_COMMAND_INSTR(0x51, 0x23),
703 ILI9881C_COMMAND_INSTR(0x52, 0x45),
704 ILI9881C_COMMAND_INSTR(0x53, 0x67),
705 ILI9881C_COMMAND_INSTR(0x54, 0x89),
706 ILI9881C_COMMAND_INSTR(0x55, 0xaB),
707 ILI9881C_COMMAND_INSTR(0x56, 0x01),
708 ILI9881C_COMMAND_INSTR(0x57, 0x23),
709 ILI9881C_COMMAND_INSTR(0x58, 0x45),
710 ILI9881C_COMMAND_INSTR(0x59, 0x67),
711 ILI9881C_COMMAND_INSTR(0x5A, 0x89),
712 ILI9881C_COMMAND_INSTR(0x5B, 0xAB),
713 ILI9881C_COMMAND_INSTR(0x5C, 0xCD),
714 ILI9881C_COMMAND_INSTR(0x5D, 0xEF),
715 ILI9881C_COMMAND_INSTR(0x5E, 0x03),
716 ILI9881C_COMMAND_INSTR(0x5F, 0x14),
717
718 ILI9881C_COMMAND_INSTR(0x60, 0x15),
719 ILI9881C_COMMAND_INSTR(0x61, 0x0C),
720 ILI9881C_COMMAND_INSTR(0x62, 0x0D),
721 ILI9881C_COMMAND_INSTR(0x63, 0x0E),
722 ILI9881C_COMMAND_INSTR(0x64, 0x0F),
723 ILI9881C_COMMAND_INSTR(0x65, 0x10),
724 ILI9881C_COMMAND_INSTR(0x66, 0x11),
725 ILI9881C_COMMAND_INSTR(0x67, 0x08),
726 ILI9881C_COMMAND_INSTR(0x68, 0x02),
727 ILI9881C_COMMAND_INSTR(0x69, 0x0A),
728 ILI9881C_COMMAND_INSTR(0x6A, 0x02),
729 ILI9881C_COMMAND_INSTR(0x6B, 0x02),
730 ILI9881C_COMMAND_INSTR(0x6C, 0x02),
731 ILI9881C_COMMAND_INSTR(0x6D, 0x02),
732 ILI9881C_COMMAND_INSTR(0x6E, 0x02),
733 ILI9881C_COMMAND_INSTR(0x6F, 0x02),
734
735 ILI9881C_COMMAND_INSTR(0x70, 0x02),
736 ILI9881C_COMMAND_INSTR(0x71, 0x02),
737 ILI9881C_COMMAND_INSTR(0x72, 0x06),
738 ILI9881C_COMMAND_INSTR(0x73, 0x02),
739 ILI9881C_COMMAND_INSTR(0x74, 0x02),
740 ILI9881C_COMMAND_INSTR(0x75, 0x14),
741 ILI9881C_COMMAND_INSTR(0x76, 0x15),
742 ILI9881C_COMMAND_INSTR(0x77, 0x0F),
743 ILI9881C_COMMAND_INSTR(0x78, 0x0E),
744 ILI9881C_COMMAND_INSTR(0x79, 0x0D),
745 ILI9881C_COMMAND_INSTR(0x7A, 0x0C),
746 ILI9881C_COMMAND_INSTR(0x7B, 0x11),
747 ILI9881C_COMMAND_INSTR(0x7C, 0x10),
748 ILI9881C_COMMAND_INSTR(0x7D, 0x06),
749 ILI9881C_COMMAND_INSTR(0x7E, 0x02),
750 ILI9881C_COMMAND_INSTR(0x7F, 0x0A),
751
752 ILI9881C_COMMAND_INSTR(0x80, 0x02),
753 ILI9881C_COMMAND_INSTR(0x81, 0x02),
754 ILI9881C_COMMAND_INSTR(0x82, 0x02),
755 ILI9881C_COMMAND_INSTR(0x83, 0x02),
756 ILI9881C_COMMAND_INSTR(0x84, 0x02),
757 ILI9881C_COMMAND_INSTR(0x85, 0x02),
758 ILI9881C_COMMAND_INSTR(0x86, 0x02),
759 ILI9881C_COMMAND_INSTR(0x87, 0x02),
760 ILI9881C_COMMAND_INSTR(0x88, 0x08),
761 ILI9881C_COMMAND_INSTR(0x89, 0x02),
762 ILI9881C_COMMAND_INSTR(0x8A, 0x02),
763
764 ILI9881C_SWITCH_PAGE_INSTR(4),
765 ILI9881C_COMMAND_INSTR(0x00, 0x80),
766 ILI9881C_COMMAND_INSTR(0x70, 0x00),
767 ILI9881C_COMMAND_INSTR(0x71, 0x00),
768 ILI9881C_COMMAND_INSTR(0x66, 0xFE),
769 ILI9881C_COMMAND_INSTR(0x82, 0x15),
770 ILI9881C_COMMAND_INSTR(0x84, 0x15),
771 ILI9881C_COMMAND_INSTR(0x85, 0x15),
772 ILI9881C_COMMAND_INSTR(0x3a, 0x24),
773 ILI9881C_COMMAND_INSTR(0x32, 0xAC),
774 ILI9881C_COMMAND_INSTR(0x8C, 0x80),
775 ILI9881C_COMMAND_INSTR(0x3C, 0xF5),
776 ILI9881C_COMMAND_INSTR(0x88, 0x33),
777
778 ILI9881C_SWITCH_PAGE_INSTR(1),
779 ILI9881C_COMMAND_INSTR(0x22, 0x0A),
780 ILI9881C_COMMAND_INSTR(0x31, 0x00),
781 ILI9881C_COMMAND_INSTR(0x53, 0x78),
782 ILI9881C_COMMAND_INSTR(0x50, 0x5B),
783 ILI9881C_COMMAND_INSTR(0x51, 0x5B),
784 ILI9881C_COMMAND_INSTR(0x60, 0x20),
785 ILI9881C_COMMAND_INSTR(0x61, 0x00),
786 ILI9881C_COMMAND_INSTR(0x62, 0x0D),
787 ILI9881C_COMMAND_INSTR(0x63, 0x00),
788
789 ILI9881C_COMMAND_INSTR(0xA0, 0x00),
790 ILI9881C_COMMAND_INSTR(0xA1, 0x10),
791 ILI9881C_COMMAND_INSTR(0xA2, 0x1C),
792 ILI9881C_COMMAND_INSTR(0xA3, 0x13),
793 ILI9881C_COMMAND_INSTR(0xA4, 0x15),
794 ILI9881C_COMMAND_INSTR(0xA5, 0x26),
795 ILI9881C_COMMAND_INSTR(0xA6, 0x1A),
796 ILI9881C_COMMAND_INSTR(0xA7, 0x1D),
797 ILI9881C_COMMAND_INSTR(0xA8, 0x67),
798 ILI9881C_COMMAND_INSTR(0xA9, 0x1C),
799 ILI9881C_COMMAND_INSTR(0xAA, 0x29),
800 ILI9881C_COMMAND_INSTR(0xAB, 0x5B),
801 ILI9881C_COMMAND_INSTR(0xAC, 0x26),
802 ILI9881C_COMMAND_INSTR(0xAD, 0x28),
803 ILI9881C_COMMAND_INSTR(0xAE, 0x5C),
804 ILI9881C_COMMAND_INSTR(0xAF, 0x30),
805 ILI9881C_COMMAND_INSTR(0xB0, 0x31),
806 ILI9881C_COMMAND_INSTR(0xB1, 0x2E),
807 ILI9881C_COMMAND_INSTR(0xB2, 0x32),
808 ILI9881C_COMMAND_INSTR(0xB3, 0x00),
809
810 ILI9881C_COMMAND_INSTR(0xC0, 0x00),
811 ILI9881C_COMMAND_INSTR(0xC1, 0x10),
812 ILI9881C_COMMAND_INSTR(0xC2, 0x1C),
813 ILI9881C_COMMAND_INSTR(0xC3, 0x13),
814 ILI9881C_COMMAND_INSTR(0xC4, 0x15),
815 ILI9881C_COMMAND_INSTR(0xC5, 0x26),
816 ILI9881C_COMMAND_INSTR(0xC6, 0x1A),
817 ILI9881C_COMMAND_INSTR(0xC7, 0x1D),
818 ILI9881C_COMMAND_INSTR(0xC8, 0x67),
819 ILI9881C_COMMAND_INSTR(0xC9, 0x1C),
820 ILI9881C_COMMAND_INSTR(0xCA, 0x29),
821 ILI9881C_COMMAND_INSTR(0xCB, 0x5B),
822 ILI9881C_COMMAND_INSTR(0xCC, 0x26),
823 ILI9881C_COMMAND_INSTR(0xCD, 0x28),
824 ILI9881C_COMMAND_INSTR(0xCE, 0x5C),
825 ILI9881C_COMMAND_INSTR(0xCF, 0x30),
826 ILI9881C_COMMAND_INSTR(0xD0, 0x31),
827 ILI9881C_COMMAND_INSTR(0xD1, 0x2E),
828 ILI9881C_COMMAND_INSTR(0xD2, 0x32),
829 ILI9881C_COMMAND_INSTR(0xD3, 0x00),
830 ILI9881C_SWITCH_PAGE_INSTR(0),
831 };
832
panel_to_ili9881c(struct drm_panel * panel)833 static inline struct ili9881c *panel_to_ili9881c(struct drm_panel *panel)
834 {
835 return container_of(panel, struct ili9881c, panel);
836 }
837
838 /*
839 * The panel seems to accept some private DCS commands that map
840 * directly to registers.
841 *
842 * It is organised by page, with each page having its own set of
843 * registers, and the first page looks like it's holding the standard
844 * DCS commands.
845 *
846 * So before any attempt at sending a command or data, we have to be
847 * sure if we're in the right page or not.
848 */
ili9881c_switch_page(struct ili9881c * ctx,u8 page)849 static int ili9881c_switch_page(struct ili9881c *ctx, u8 page)
850 {
851 u8 buf[4] = { 0xff, 0x98, 0x81, page };
852 int ret;
853
854 ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
855 if (ret < 0)
856 return ret;
857
858 return 0;
859 }
860
ili9881c_send_cmd_data(struct ili9881c * ctx,u8 cmd,u8 data)861 static int ili9881c_send_cmd_data(struct ili9881c *ctx, u8 cmd, u8 data)
862 {
863 u8 buf[2] = { cmd, data };
864 int ret;
865
866 ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
867 if (ret < 0)
868 return ret;
869
870 return 0;
871 }
872
ili9881c_prepare(struct drm_panel * panel)873 static int ili9881c_prepare(struct drm_panel *panel)
874 {
875 struct ili9881c *ctx = panel_to_ili9881c(panel);
876 unsigned int i;
877 int ret;
878
879 /* Power the panel */
880 ret = regulator_enable(ctx->power);
881 if (ret)
882 return ret;
883 msleep(5);
884
885 /* And reset it */
886 gpiod_set_value_cansleep(ctx->reset, 1);
887 msleep(20);
888
889 gpiod_set_value_cansleep(ctx->reset, 0);
890 msleep(20);
891
892 for (i = 0; i < ctx->desc->init_length; i++) {
893 const struct ili9881c_instr *instr = &ctx->desc->init[i];
894
895 if (instr->op == ILI9881C_SWITCH_PAGE)
896 ret = ili9881c_switch_page(ctx, instr->arg.page);
897 else if (instr->op == ILI9881C_COMMAND)
898 ret = ili9881c_send_cmd_data(ctx, instr->arg.cmd.cmd,
899 instr->arg.cmd.data);
900
901 if (ret)
902 return ret;
903 }
904
905 ret = ili9881c_switch_page(ctx, 0);
906 if (ret)
907 return ret;
908
909 ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
910 if (ret)
911 return ret;
912
913 ret = mipi_dsi_dcs_exit_sleep_mode(ctx->dsi);
914 if (ret)
915 return ret;
916
917 return 0;
918 }
919
ili9881c_enable(struct drm_panel * panel)920 static int ili9881c_enable(struct drm_panel *panel)
921 {
922 struct ili9881c *ctx = panel_to_ili9881c(panel);
923
924 msleep(120);
925
926 mipi_dsi_dcs_set_display_on(ctx->dsi);
927
928 return 0;
929 }
930
ili9881c_disable(struct drm_panel * panel)931 static int ili9881c_disable(struct drm_panel *panel)
932 {
933 struct ili9881c *ctx = panel_to_ili9881c(panel);
934
935 return mipi_dsi_dcs_set_display_off(ctx->dsi);
936 }
937
ili9881c_unprepare(struct drm_panel * panel)938 static int ili9881c_unprepare(struct drm_panel *panel)
939 {
940 struct ili9881c *ctx = panel_to_ili9881c(panel);
941
942 mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
943 regulator_disable(ctx->power);
944 gpiod_set_value_cansleep(ctx->reset, 1);
945
946 return 0;
947 }
948
949 static const struct drm_display_mode lhr050h41_default_mode = {
950 .clock = 62000,
951
952 .hdisplay = 720,
953 .hsync_start = 720 + 10,
954 .hsync_end = 720 + 10 + 20,
955 .htotal = 720 + 10 + 20 + 30,
956
957 .vdisplay = 1280,
958 .vsync_start = 1280 + 10,
959 .vsync_end = 1280 + 10 + 10,
960 .vtotal = 1280 + 10 + 10 + 20,
961
962 .width_mm = 62,
963 .height_mm = 110,
964 };
965
966 static const struct drm_display_mode k101_im2byl02_default_mode = {
967 .clock = 69700,
968
969 .hdisplay = 800,
970 .hsync_start = 800 + 52,
971 .hsync_end = 800 + 52 + 8,
972 .htotal = 800 + 52 + 8 + 48,
973
974 .vdisplay = 1280,
975 .vsync_start = 1280 + 16,
976 .vsync_end = 1280 + 16 + 6,
977 .vtotal = 1280 + 16 + 6 + 15,
978
979 .width_mm = 135,
980 .height_mm = 217,
981 };
982
983 static const struct drm_display_mode tl050hdv35_default_mode = {
984 .clock = 59400,
985
986 .hdisplay = 720,
987 .hsync_start = 720 + 18,
988 .hsync_end = 720 + 18 + 3,
989 .htotal = 720 + 18 + 3 + 20,
990
991 .vdisplay = 1280,
992 .vsync_start = 1280 + 26,
993 .vsync_end = 1280 + 26 + 6,
994 .vtotal = 1280 + 26 + 6 + 28,
995
996 .width_mm = 62,
997 .height_mm = 110,
998 };
999
1000 static const struct drm_display_mode w552946aba_default_mode = {
1001 .clock = 64000,
1002
1003 .hdisplay = 720,
1004 .hsync_start = 720 + 40,
1005 .hsync_end = 720 + 40 + 10,
1006 .htotal = 720 + 40 + 10 + 40,
1007
1008 .vdisplay = 1280,
1009 .vsync_start = 1280 + 22,
1010 .vsync_end = 1280 + 22 + 4,
1011 .vtotal = 1280 + 22 + 4 + 11,
1012
1013 .width_mm = 68,
1014 .height_mm = 121,
1015 };
1016
ili9881c_get_modes(struct drm_panel * panel,struct drm_connector * connector)1017 static int ili9881c_get_modes(struct drm_panel *panel,
1018 struct drm_connector *connector)
1019 {
1020 struct ili9881c *ctx = panel_to_ili9881c(panel);
1021 struct drm_display_mode *mode;
1022
1023 mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
1024 if (!mode) {
1025 dev_err(&ctx->dsi->dev, "failed to add mode %ux%ux@%u\n",
1026 ctx->desc->mode->hdisplay,
1027 ctx->desc->mode->vdisplay,
1028 drm_mode_vrefresh(ctx->desc->mode));
1029 return -ENOMEM;
1030 }
1031
1032 drm_mode_set_name(mode);
1033
1034 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
1035 drm_mode_probed_add(connector, mode);
1036
1037 connector->display_info.width_mm = mode->width_mm;
1038 connector->display_info.height_mm = mode->height_mm;
1039
1040 /*
1041 * TODO: Remove once all drm drivers call
1042 * drm_connector_set_orientation_from_panel()
1043 */
1044 drm_connector_set_panel_orientation(connector, ctx->orientation);
1045
1046 return 1;
1047 }
1048
ili9881c_get_orientation(struct drm_panel * panel)1049 static enum drm_panel_orientation ili9881c_get_orientation(struct drm_panel *panel)
1050 {
1051 struct ili9881c *ctx = panel_to_ili9881c(panel);
1052
1053 return ctx->orientation;
1054 }
1055
1056 static const struct drm_panel_funcs ili9881c_funcs = {
1057 .prepare = ili9881c_prepare,
1058 .unprepare = ili9881c_unprepare,
1059 .enable = ili9881c_enable,
1060 .disable = ili9881c_disable,
1061 .get_modes = ili9881c_get_modes,
1062 .get_orientation = ili9881c_get_orientation,
1063 };
1064
ili9881c_dsi_probe(struct mipi_dsi_device * dsi)1065 static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
1066 {
1067 struct ili9881c *ctx;
1068 int ret;
1069
1070 ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
1071 if (!ctx)
1072 return -ENOMEM;
1073 mipi_dsi_set_drvdata(dsi, ctx);
1074 ctx->dsi = dsi;
1075 ctx->desc = of_device_get_match_data(&dsi->dev);
1076
1077 drm_panel_init(&ctx->panel, &dsi->dev, &ili9881c_funcs,
1078 DRM_MODE_CONNECTOR_DSI);
1079
1080 ctx->power = devm_regulator_get(&dsi->dev, "power");
1081 if (IS_ERR(ctx->power))
1082 return dev_err_probe(&dsi->dev, PTR_ERR(ctx->power),
1083 "Couldn't get our power regulator\n");
1084
1085 ctx->reset = devm_gpiod_get_optional(&dsi->dev, "reset", GPIOD_OUT_LOW);
1086 if (IS_ERR(ctx->reset))
1087 return dev_err_probe(&dsi->dev, PTR_ERR(ctx->reset),
1088 "Couldn't get our reset GPIO\n");
1089
1090 ret = of_drm_get_panel_orientation(dsi->dev.of_node, &ctx->orientation);
1091 if (ret) {
1092 dev_err(&dsi->dev, "%pOF: failed to get orientation: %d\n",
1093 dsi->dev.of_node, ret);
1094 return ret;
1095 }
1096
1097 ret = drm_panel_of_backlight(&ctx->panel);
1098 if (ret)
1099 return ret;
1100
1101 drm_panel_add(&ctx->panel);
1102
1103 dsi->mode_flags = ctx->desc->mode_flags;
1104 dsi->format = MIPI_DSI_FMT_RGB888;
1105 dsi->lanes = 4;
1106
1107 return mipi_dsi_attach(dsi);
1108 }
1109
ili9881c_dsi_remove(struct mipi_dsi_device * dsi)1110 static void ili9881c_dsi_remove(struct mipi_dsi_device *dsi)
1111 {
1112 struct ili9881c *ctx = mipi_dsi_get_drvdata(dsi);
1113
1114 mipi_dsi_detach(dsi);
1115 drm_panel_remove(&ctx->panel);
1116 }
1117
1118 static const struct ili9881c_desc lhr050h41_desc = {
1119 .init = lhr050h41_init,
1120 .init_length = ARRAY_SIZE(lhr050h41_init),
1121 .mode = &lhr050h41_default_mode,
1122 .mode_flags = MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1123 };
1124
1125 static const struct ili9881c_desc k101_im2byl02_desc = {
1126 .init = k101_im2byl02_init,
1127 .init_length = ARRAY_SIZE(k101_im2byl02_init),
1128 .mode = &k101_im2byl02_default_mode,
1129 .mode_flags = MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
1130 };
1131
1132 static const struct ili9881c_desc tl050hdv35_desc = {
1133 .init = tl050hdv35_init,
1134 .init_length = ARRAY_SIZE(tl050hdv35_init),
1135 .mode = &tl050hdv35_default_mode,
1136 .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
1137 MIPI_DSI_MODE_LPM,
1138 };
1139
1140 static const struct ili9881c_desc w552946aba_desc = {
1141 .init = w552946ab_init,
1142 .init_length = ARRAY_SIZE(w552946ab_init),
1143 .mode = &w552946aba_default_mode,
1144 .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
1145 MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_NO_EOT_PACKET,
1146 };
1147
1148 static const struct of_device_id ili9881c_of_match[] = {
1149 { .compatible = "bananapi,lhr050h41", .data = &lhr050h41_desc },
1150 { .compatible = "feixin,k101-im2byl02", .data = &k101_im2byl02_desc },
1151 { .compatible = "tdo,tl050hdv35", .data = &tl050hdv35_desc },
1152 { .compatible = "wanchanglong,w552946aba", .data = &w552946aba_desc },
1153 { }
1154 };
1155 MODULE_DEVICE_TABLE(of, ili9881c_of_match);
1156
1157 static struct mipi_dsi_driver ili9881c_dsi_driver = {
1158 .probe = ili9881c_dsi_probe,
1159 .remove = ili9881c_dsi_remove,
1160 .driver = {
1161 .name = "ili9881c-dsi",
1162 .of_match_table = ili9881c_of_match,
1163 },
1164 };
1165 module_mipi_dsi_driver(ili9881c_dsi_driver);
1166
1167 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
1168 MODULE_DESCRIPTION("Ilitek ILI9881C Controller Driver");
1169 MODULE_LICENSE("GPL v2");
1170