This source file includes following definitions.
- init_display
- set_addr_win
- set_var
1
2
3
4
5
6
7
8
9
10
11
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/gpio/consumer.h>
16 #include <linux/delay.h>
17
18 #include "fbtft.h"
19
20 #define DRVNAME "fb_upd161704"
21 #define WIDTH 240
22 #define HEIGHT 320
23 #define BPP 16
24
25 static int init_display(struct fbtft_par *par)
26 {
27 par->fbtftops.reset(par);
28
29 if (par->gpio.cs)
30 gpiod_set_value(par->gpio.cs, 0);
31
32
33
34
35 write_reg(par, 0x0003, 0x0001);
36
37
38 write_reg(par, 0x003A, 0x0001);
39 udelay(100);
40
41
42 write_reg(par, 0x0024, 0x007B);
43 udelay(10);
44 write_reg(par, 0x0025, 0x003B);
45 write_reg(par, 0x0026, 0x0034);
46 udelay(10);
47 write_reg(par, 0x0027, 0x0004);
48 write_reg(par, 0x0052, 0x0025);
49 udelay(10);
50 write_reg(par, 0x0053, 0x0033);
51 write_reg(par, 0x0061, 0x001C);
52 udelay(10);
53 write_reg(par, 0x0062, 0x002C);
54 write_reg(par, 0x0063, 0x0022);
55 udelay(10);
56 write_reg(par, 0x0064, 0x0027);
57 udelay(10);
58 write_reg(par, 0x0065, 0x0014);
59 udelay(10);
60 write_reg(par, 0x0066, 0x0010);
61
62
63 write_reg(par, 0x002E, 0x002D);
64
65
66 write_reg(par, 0x0019, 0x0000);
67 udelay(200);
68 write_reg(par, 0x001A, 0x1000);
69 write_reg(par, 0x001B, 0x0023);
70 write_reg(par, 0x001C, 0x0C01);
71 write_reg(par, 0x001D, 0x0000);
72 write_reg(par, 0x001E, 0x0009);
73 write_reg(par, 0x001F, 0x0035);
74 write_reg(par, 0x0020, 0x0015);
75 write_reg(par, 0x0018, 0x1E7B);
76
77
78 write_reg(par, 0x0008, 0x0000);
79 write_reg(par, 0x0009, 0x00EF);
80 write_reg(par, 0x000a, 0x0000);
81 write_reg(par, 0x000b, 0x013F);
82
83
84 write_reg(par, 0x0029, 0x0000);
85 write_reg(par, 0x002A, 0x0000);
86 write_reg(par, 0x002B, 0x00EF);
87 write_reg(par, 0x002C, 0x013F);
88
89
90 write_reg(par, 0x0032, 0x0002);
91
92
93 write_reg(par, 0x0033, 0x0000);
94
95
96 write_reg(par, 0x0037, 0x0000);
97
98
99 write_reg(par, 0x003B, 0x0001);
100
101
102
103 write_reg(par, 0x0004, 0x0000);
104
105
106 write_reg(par, 0x0005, 0x0000);
107
108
109 write_reg(par, 0x0001, 0x0000);
110
111
112 write_reg(par, 0x0000, 0x0000);
113
114 return 0;
115 }
116
117 static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
118 {
119 switch (par->info->var.rotate) {
120
121
122 case 0:
123 write_reg(par, 0x0006, xs);
124 write_reg(par, 0x0007, ys);
125 break;
126 case 180:
127 write_reg(par, 0x0006, WIDTH - 1 - xs);
128 write_reg(par, 0x0007, HEIGHT - 1 - ys);
129 break;
130 case 270:
131 write_reg(par, 0x0006, WIDTH - 1 - ys);
132 write_reg(par, 0x0007, xs);
133 break;
134 case 90:
135 write_reg(par, 0x0006, ys);
136 write_reg(par, 0x0007, HEIGHT - 1 - xs);
137 break;
138 }
139
140 write_reg(par, 0x0e);
141 }
142
143 static int set_var(struct fbtft_par *par)
144 {
145 switch (par->info->var.rotate) {
146
147 case 0:
148 write_reg(par, 0x01, 0x0000);
149 write_reg(par, 0x05, 0x0000);
150 break;
151 case 180:
152 write_reg(par, 0x01, 0x00C0);
153 write_reg(par, 0x05, 0x0000);
154 break;
155 case 270:
156 write_reg(par, 0x01, 0x0080);
157 write_reg(par, 0x05, 0x0001);
158 break;
159 case 90:
160 write_reg(par, 0x01, 0x0040);
161 write_reg(par, 0x05, 0x0001);
162 break;
163 }
164
165 return 0;
166 }
167
168 static struct fbtft_display display = {
169 .regwidth = 16,
170 .width = WIDTH,
171 .height = HEIGHT,
172 .fbtftops = {
173 .init_display = init_display,
174 .set_addr_win = set_addr_win,
175 .set_var = set_var,
176 },
177 };
178
179 FBTFT_REGISTER_DRIVER(DRVNAME, "nec,upd161704", &display);
180
181 MODULE_ALIAS("spi:" DRVNAME);
182 MODULE_ALIAS("platform:" DRVNAME);
183 MODULE_ALIAS("spi:upd161704");
184 MODULE_ALIAS("platform:upd161704");
185
186 MODULE_DESCRIPTION("FB driver for the uPD161704 LCD Controller");
187 MODULE_AUTHOR("Seong-Woo Kim");
188 MODULE_LICENSE("GPL");