/
panel-jinglitai-jlt4013a.c
532 lines (435 loc) · 17 KB
/
panel-jinglitai-jlt4013a.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
// SPDX-License-Identifier: GPL-2.0
/*
* Driver for the Jinglitai JLT4013A LCD Panel.
*
* Copyright (C) Rui Oliveira 2022
* Copyright (C) Oleg Belousov 2022
*/
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <drm/drm_panel.h>
#include <drm/drm_modes.h>
#include <drm/drm_device.h>
#include <drm/drm_connector.h>
#include <linux/spi/spi.h>
#include <linux/regulator/consumer.h>
#include <linux/gpio/consumer.h>
#include <linux/media-bus-format.h>
#include <linux/version.h>
#define ST7701S_SWRESET 0x01
#define ST7701S_SLPOUT 0x11
#define ST7701S_DISPOFF 0x28
#define ST7701S_DISPON 0x29
#define ST7701S_COLMOD 0x3A
#define ST7701S_CN2BKxSEL 0xFF
/* BK0 */
#define ST7701S_LNESET 0xC0
#define ST7701S_PORCTRL 0xC1
#define ST7701S_INVSET 0xC2
#define ST7701S_PVGAMCTRL 0xB0
#define ST7701S_NVGAMCTRL 0xB1
/* BK1 */
#define ST7701S_VRHS 0xB0
#define ST7701S_VCOM 0xB1
#define ST7701S_VGHSS 0xB2
#define ST7701S_TESTCMD 0xB3
#define ST7701S_VGLS 0xB5
#define ST7701S_PWCTRL1 0xB7
#define ST7701S_PWCTRL2 0xB8
#define ST7701S_PWCTRL3 0xB9
#define ST7701S_SPD1 0xC1
#define ST7701S_SPD2 0xC2
#define ST7701S_MIPISET1 0xD0
#define ST7701S_TRY(val, func) \
do { \
if ((val = (func))) { \
pr_warn("Jinglitai JLT4013A: SPI write failed with error %d\n", \
val); \
return val; \
} \
} while (0)
static const struct of_device_id jlt4013a_of_match[] = {
{ .compatible = "sitronix,st7701s" },
{ .compatible = "jinglitai,jlt4013a" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, jlt4013a_of_match);
struct jlt4013a {
struct drm_panel panel;
struct spi_device *spi;
struct gpio_desc *reset;
struct gpio_desc *dcx;
struct regulator *supply;
};
static int st7701s_spi_write(struct jlt4013a *ctx, u8 data)
{
struct spi_transfer xfer = {};
struct spi_message msg;
spi_message_init(&msg);
xfer.tx_buf = &data;
xfer.bits_per_word = 8;
xfer.len = sizeof(data);
spi_message_add_tail(&xfer, &msg);
return spi_sync(ctx->spi, &msg);
}
static int st7701s_write_command(struct jlt4013a *ctx, u8 cmd)
{
pr_info("Jinglitai JLT4013A: Writing SPI command with value %x\n", cmd);
gpiod_set_value(ctx->dcx, 0);
return st7701s_spi_write(ctx, cmd);
}
static int st7701s_write_data(struct jlt4013a *ctx, u8 cmd)
{
pr_info("Jinglitai JLT4013A: Writing SPI data with value %x\n", cmd);
gpiod_set_value(ctx->dcx, 1);
return st7701s_spi_write(ctx, cmd);
}
static inline struct jlt4013a *panel_to_jlt4013a(struct drm_panel *panel)
{
return container_of(panel, struct jlt4013a, panel);
}
static int jlt4013a_prepare(struct drm_panel *panel)
{
int ret;
struct jlt4013a *ctx = panel_to_jlt4013a(panel);
/* Enable power supply */
pr_info("Jinglitai JLT4013A: Trying to enable power supply\n");
ret = regulator_enable(ctx->supply);
if (ret) {
pr_err("Jinglitai JLT4013A: Failed to enable power supply\n");
return ret;
}
msleep(120);
pr_info("Jinglitai JLT4013A: Enabled power supply\n");
/* Reset routine */
pr_info("Jinglitai JLT4013A: Doing the reset routine\n");
gpiod_set_value(ctx->reset, 1);
msleep(120);
gpiod_set_value(ctx->reset, 0);
msleep(120); // Sleep mandated by the datasheet
pr_info("Jinglitai JLT4013A: Panel is reset\n");
/* Initialization routine */
pr_info("Jinglitai JLT4013A: Doing the initialization routine\n");
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_SLPOUT));
msleep(120);
/* BK0 */
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_CN2BKxSEL));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x77));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x01));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x10));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_PORCTRL));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x11));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x02));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_INVSET));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x31));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x03));
/* Something strange */
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xCC));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x10));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_PVGAMCTRL));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x40));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x01));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x46));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x13));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x05));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x1B));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x07));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x15));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x12));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x4C));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x10));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xC8));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_NVGAMCTRL));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x40));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x02));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x86));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x13));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x05));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x1F));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x07));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x15));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x12));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x15));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x19));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x08));
/* BK1 */
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_CN2BKxSEL));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x77));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x01));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x11));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_VRHS));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x50));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_VCOM));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x68));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_VGHSS));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x07));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_TESTCMD));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x80));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_VGLS));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x47));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_PWCTRL1));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x85));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_PWCTRL2));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x21));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_PWCTRL3));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x10));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_SPD1));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x21));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x36));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_SPD2));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x78));
msleep(120);
/* Something strange */
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x02));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE1));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x08));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0A));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x07));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x33));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x33));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE2));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE3));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x33));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x33));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE4));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x44));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x44));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE5));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0E));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x10));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0A));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0C));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE6));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x33));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x33));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE7));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x44));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x44));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xE8));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0F));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x09));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x0B));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x2D));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xA0));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xEB));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x02));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x01));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xE4));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xE4));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x44));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x40));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xEC));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x02));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x01));
ST7701S_TRY(ret, st7701s_write_command(ctx, 0xED));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xAB));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x89));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x76));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x54));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x01));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xFF));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xFF));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xFF));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xFF));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xFF));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xFF));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x10));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x45));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x67));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x98));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0xBA));
/* BK disable */
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_CN2BKxSEL));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x77));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x01));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x00));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_COLMOD));
ST7701S_TRY(ret, st7701s_write_data(ctx, 0x77));
ST7701S_TRY(ret, st7701s_write_command(ctx, ST7701S_DISPON));
msleep(120);
pr_info("Jinglitai JLT4013A: Panel is initialized\n");
return ret;
}
static int jlt4013a_unprepare(struct drm_panel *panel)
{
struct jlt4013a *ctx = panel_to_jlt4013a(panel);
int ret = regulator_disable(ctx->supply);
return ret;
}
static const struct drm_display_mode jlt4013a_default_display_mode = {
.clock = 27000,
.hdisplay = 480,
.hsync_start = 480 + 32, // 512
.hsync_end = 480 + 32 + 11, // 523
.htotal = 480 + 32 + 11 + 2, // 525
.vdisplay = 800,
.vsync_start = 800 + 54, // 854
.vsync_end = 800 + 54 + 41, // 895
.vtotal = 800 + 54 + 41 + 33, // 928
.width_mm = 52,
.height_mm = 86,
};
static int jlt4013a_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
static const u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
struct drm_display_mode *mode = drm_mode_duplicate(
connector->dev, &jlt4013a_default_display_mode);
if (mode == NULL) {
dev_err(panel->dev,
"Jinglitai JLT4013A: Failed to add default mode\n");
return -EAGAIN;
}
drm_mode_set_name(mode);
mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
connector->display_info.width_mm = mode->width_mm;
connector->display_info.height_mm = mode->height_mm;
connector->display_info.bpc = 8;
connector->display_info.bus_flags = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE;
drm_mode_probed_add(connector, mode);
drm_display_info_set_bus_formats(&connector->display_info, &bus_format,
1);
return 1;
}
static int jlt4013a_enable(struct drm_panel *panel)
{
return 0;
}
static int jlt4013a_disable(struct drm_panel *panel)
{
return 0;
}
static const struct drm_panel_funcs jlt4013afuncs = {
.prepare = jlt4013a_prepare,
.unprepare = jlt4013a_unprepare,
.get_modes = jlt4013a_get_modes,
.enable = jlt4013a_enable,
.disable = jlt4013a_disable,
};
static int jlt4013a_probe(struct spi_device *spi)
{
int err;
struct device *dev = &spi->dev;
struct jlt4013a *ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
if (ctx == NULL) {
return -EAGAIN;
}
ctx->spi = spi;
spi_set_drvdata(spi, ctx);
ctx->supply = devm_regulator_get(dev, "power");
if (IS_ERR(ctx->supply)) {
dev_err(dev,
"Jinglitai JLT4013A: Failed to get power supply\n");
return PTR_ERR(ctx->supply);
}
ctx->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(ctx->reset)) {
dev_err(dev, "Jinglitai JLT4013A: Failed to get reset GPIO\n");
return PTR_ERR(ctx->reset);
}
ctx->dcx = devm_gpiod_get(dev, "dcx", GPIOD_OUT_LOW);
if (IS_ERR(ctx->dcx)) {
dev_err(dev, "Jinglitai JLT4013A: Failed to get dcx GPIO\n");
return PTR_ERR(ctx->dcx);
}
drm_panel_init(&ctx->panel, dev, &jlt4013afuncs,
DRM_MODE_CONNECTOR_DPI);
err = drm_panel_of_backlight(&ctx->panel);
if (err)
return err;
drm_panel_add(&ctx->panel);
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0)
static void jlt4013a_remove(struct spi_device *spi)
{
struct jlt4013a *ctx = spi_get_drvdata(spi);
drm_panel_remove(&(ctx->panel));
}
#else
static int jlt4013a_remove(struct spi_device *spi)
{
struct jlt4013a *ctx = spi_get_drvdata(spi);
drm_panel_remove(&(ctx->panel));
return 0;
}
#endif
static struct spi_driver jlt4013a_driver = {
.probe = jlt4013a_probe,
.remove = jlt4013a_remove,
.driver = {
.name = "jlt4013a",
.of_match_table = jlt4013a_of_match,
},
};
module_spi_driver(jlt4013a_driver);
MODULE_AUTHOR("Rui Oliveira <ruimail24@gmail.com>");
MODULE_AUTHOR("Oleg Belousov <www.strijar.ru>");
MODULE_DESCRIPTION("Driver for the Jinglitai JLT4013A LCD Panel");
MODULE_LICENSE("GPL v2");