This source file includes following definitions.
- init_display
- set_addr_win
- set_var
1
2
3
4
5
6
7
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/gpio/consumer.h>
12 #include <linux/delay.h>
13 #include <video/mipi_display.h>
14
15 #include "fbtft.h"
16
17 #define DRVNAME "fb_ili9340"
18 #define WIDTH 240
19 #define HEIGHT 320
20
21
22 static int init_display(struct fbtft_par *par)
23 {
24 par->fbtftops.reset(par);
25
26 write_reg(par, 0xEF, 0x03, 0x80, 0x02);
27 write_reg(par, 0xCF, 0x00, 0XC1, 0X30);
28 write_reg(par, 0xED, 0x64, 0x03, 0X12, 0X81);
29 write_reg(par, 0xE8, 0x85, 0x00, 0x78);
30 write_reg(par, 0xCB, 0x39, 0x2C, 0x00, 0x34, 0x02);
31 write_reg(par, 0xF7, 0x20);
32 write_reg(par, 0xEA, 0x00, 0x00);
33
34
35 write_reg(par, 0xC0, 0x23);
36
37
38 write_reg(par, 0xC1, 0x10);
39
40
41 write_reg(par, 0xC5, 0x3e, 0x28);
42
43
44 write_reg(par, 0xC7, 0x86);
45
46
47
48 write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, 0x55);
49
50
51
52 write_reg(par, 0xB1, 0x00, 0x18);
53
54
55 write_reg(par, 0xB6, 0x08, 0x82, 0x27);
56
57
58 write_reg(par, 0xF2, 0x00);
59
60
61 write_reg(par, MIPI_DCS_SET_GAMMA_CURVE, 0x01);
62
63
64 write_reg(par, 0xE0,
65 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1,
66 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00);
67
68
69 write_reg(par, 0xE1,
70 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1,
71 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F);
72
73 write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
74
75 mdelay(120);
76
77 write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
78
79 return 0;
80 }
81
82 static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
83 {
84 write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
85 xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
86
87 write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,
88 ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
89
90 write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
91 }
92
93 #define ILI9340_MADCTL_MV 0x20
94 #define ILI9340_MADCTL_MX 0x40
95 #define ILI9340_MADCTL_MY 0x80
96 static int set_var(struct fbtft_par *par)
97 {
98 u8 val;
99
100 switch (par->info->var.rotate) {
101 case 270:
102 val = ILI9340_MADCTL_MV;
103 break;
104 case 180:
105 val = ILI9340_MADCTL_MY;
106 break;
107 case 90:
108 val = ILI9340_MADCTL_MV | ILI9340_MADCTL_MY | ILI9340_MADCTL_MX;
109 break;
110 default:
111 val = ILI9340_MADCTL_MX;
112 break;
113 }
114
115 write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, val | (par->bgr << 3));
116
117 return 0;
118 }
119
120 static struct fbtft_display display = {
121 .regwidth = 8,
122 .width = WIDTH,
123 .height = HEIGHT,
124 .fbtftops = {
125 .init_display = init_display,
126 .set_addr_win = set_addr_win,
127 .set_var = set_var,
128 },
129 };
130
131 FBTFT_REGISTER_DRIVER(DRVNAME, "ilitek,ili9340", &display);
132
133 MODULE_ALIAS("spi:" DRVNAME);
134 MODULE_ALIAS("platform:" DRVNAME);
135 MODULE_ALIAS("spi:ili9340");
136 MODULE_ALIAS("platform:ili9340");
137
138 MODULE_DESCRIPTION("FB driver for the ILI9340 LCD Controller");
139 MODULE_AUTHOR("Noralf Tronnes");
140 MODULE_LICENSE("GPL");