blob: 138315843f816e69d66d86829f9866faf645f46b [file] [log] [blame]
Heiko Schocherb26354c2013-08-19 16:39:00 +02001/*
2 * LCD: Formike, TFT 4.3", 480x800, RGB24, KWH043ST20-F01, DriverIC NT35510-16
3 * LCD initialization via SPI
4 *
5 * SPDX-License-Identifier: GPL-2.0
6 * Based on:
7 *
8 */
9#include <common.h>
10#include <errno.h>
11#include <spi.h>
12
13#define TAG_READ 0x80
14#define TAG_WRITE 0x00
15
16#define TAG_DATA 0x40
17#define TAG_COMMAND 0x00
18
19#define TAG_ADDR_H 0x20
20#define TAG_ADDR_L 0x00
21
22static int spi_write_tag_val(struct spi_slave *spi, unsigned char tag,
23 unsigned char val)
24{
25 unsigned long flags = SPI_XFER_BEGIN;
26 u8 buf[2];
27 int ret;
28
29 buf[0] = tag;
Heiko Schocher1c6e9de2013-10-22 11:06:24 +020030 ret = spi_xfer(spi, 8, buf, NULL, flags);
31 buf[0] = val;
32 flags = SPI_XFER_END;
33 ret = spi_xfer(spi, 8, buf, NULL, flags);
Heiko Schocherb26354c2013-08-19 16:39:00 +020034
Heiko Schocherb26354c2013-08-19 16:39:00 +020035#ifdef KWH043ST20_F01_SPI_DEBUG
36 printf("spi_write_tag_val: tag=%02X, val=%02X ret: %d\n",
37 tag, val, ret);
38#endif /* KWH043ST20_F01_SPI_DEBUG */
39 if (ret)
40 debug("%s: Failed to send: %d\n", __func__, ret);
41
42 return ret;
43}
44
45static void spi_write_dat(struct spi_slave *spi, unsigned int val)
46{
47 spi_write_tag_val(spi, TAG_WRITE|TAG_DATA, val);
48}
49
50static void spi_write_com(struct spi_slave *spi, unsigned int addr)
51{
52 spi_write_tag_val(spi, TAG_WRITE|TAG_COMMAND|TAG_ADDR_H,
53 (addr & 0xff00) >> 8);
54 spi_write_tag_val(spi, TAG_WRITE|TAG_COMMAND|TAG_ADDR_L,
55 (addr & 0x00ff) >> 0);
56}
57
58int kwh043st20_f01_spi_startup(unsigned int bus, unsigned int cs,
59 unsigned int max_hz, unsigned int spi_mode)
60{
61 struct spi_slave *spi;
62 int ret;
63
64 spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
65 if (!spi) {
66 debug("%s: Failed to set up slave\n", __func__);
67 return -1;
68 }
69
70 ret = spi_claim_bus(spi);
71 if (ret) {
72 debug("%s: Failed to claim SPI bus: %d\n", __func__, ret);
73 goto err_claim_bus;
74 }
75
76
77 /* LV2 Page 1 enable */
78 spi_write_com(spi, 0xF000); spi_write_dat(spi, 0x55);
79 spi_write_com(spi, 0xF001); spi_write_dat(spi, 0xAA);
80 spi_write_com(spi, 0xF002); spi_write_dat(spi, 0x52);
81 spi_write_com(spi, 0xF003); spi_write_dat(spi, 0x08);
82 spi_write_com(spi, 0xF004); spi_write_dat(spi, 0x01);
83
84 /* AVDD Set AVDD 5.2V */
85 spi_write_com(spi, 0xB000); spi_write_dat(spi, 0x0D);
86 spi_write_com(spi, 0xB001); spi_write_dat(spi, 0x0D);
87 spi_write_com(spi, 0xB002); spi_write_dat(spi, 0x0D);
88
89 /* AVDD ratio */
90 spi_write_com(spi, 0xB600); spi_write_dat(spi, 0x34);
91 spi_write_com(spi, 0xB601); spi_write_dat(spi, 0x34);
92 spi_write_com(spi, 0xB602); spi_write_dat(spi, 0x34);
93
94 /* AVEE -5.2V */
95 spi_write_com(spi, 0xB100); spi_write_dat(spi, 0x0D);
96 spi_write_com(spi, 0xB101); spi_write_dat(spi, 0x0D);
97 spi_write_com(spi, 0xB102); spi_write_dat(spi, 0x0D);
98
99 /* AVEE ratio */
100 spi_write_com(spi, 0xB700); spi_write_dat(spi, 0x35);
101 spi_write_com(spi, 0xB701); spi_write_dat(spi, 0x35);
102 spi_write_com(spi, 0xB702); spi_write_dat(spi, 0x35);
103
104 /* VCL -2.5V */
105 spi_write_com(spi, 0xB200); spi_write_dat(spi, 0x00);
106 spi_write_com(spi, 0xB201); spi_write_dat(spi, 0x00);
107 spi_write_com(spi, 0xB202); spi_write_dat(spi, 0x00);
108
109 /* VCL ratio */
110 spi_write_com(spi, 0xB800); spi_write_dat(spi, 0x24);
111 spi_write_com(spi, 0xB801); spi_write_dat(spi, 0x24);
112 spi_write_com(spi, 0xB802); spi_write_dat(spi, 0x24);
113
114 /* VGH 15V */
115 spi_write_com(spi, 0xBF00); spi_write_dat(spi, 0x01);
116 spi_write_com(spi, 0xB300); spi_write_dat(spi, 0x08);
117 spi_write_com(spi, 0xB301); spi_write_dat(spi, 0x08);
118 spi_write_com(spi, 0xB302); spi_write_dat(spi, 0x08);
119
120 /* VGH ratio */
121 spi_write_com(spi, 0xB900); spi_write_dat(spi, 0x34);
122 spi_write_com(spi, 0xB901); spi_write_dat(spi, 0x34);
123 spi_write_com(spi, 0xB902); spi_write_dat(spi, 0x34);
124
125 /* VGLX ratio */
126 spi_write_com(spi, 0xBA00); spi_write_dat(spi, 0x24);
127 spi_write_com(spi, 0xBA01); spi_write_dat(spi, 0x24);
128 spi_write_com(spi, 0xBA02); spi_write_dat(spi, 0x24);
129
130 /* VGMP/VGSP 4.7V/0V */
131 spi_write_com(spi, 0xBC00); spi_write_dat(spi, 0x00);
132 spi_write_com(spi, 0xBC01); spi_write_dat(spi, 0x88);
133 spi_write_com(spi, 0xBC02); spi_write_dat(spi, 0x00);
134
135 /* VGMN/VGSN -4.7V/0V */
136 spi_write_com(spi, 0xBD00); spi_write_dat(spi, 0x00);
137 spi_write_com(spi, 0xBD01); spi_write_dat(spi, 0x88);
138 spi_write_com(spi, 0xBD02); spi_write_dat(spi, 0x00);
139
140 /* VCOM 1.525V */
141 spi_write_com(spi, 0xBE00); spi_write_dat(spi, 0x00);
142 spi_write_com(spi, 0xBE01); spi_write_dat(spi, 0x7A);
143
144 /* Gamma Setting */
145 spi_write_com(spi, 0xD100); spi_write_dat(spi, 0x00);
146 spi_write_com(spi, 0xD101); spi_write_dat(spi, 0x05);
147 spi_write_com(spi, 0xD102); spi_write_dat(spi, 0x00);
148 spi_write_com(spi, 0xD103); spi_write_dat(spi, 0x15);
149 spi_write_com(spi, 0xD104); spi_write_dat(spi, 0x00);
150 spi_write_com(spi, 0xD105); spi_write_dat(spi, 0x30);
151 spi_write_com(spi, 0xD106); spi_write_dat(spi, 0x00);
152 spi_write_com(spi, 0xD107); spi_write_dat(spi, 0x47);
153 spi_write_com(spi, 0xD108); spi_write_dat(spi, 0x00);
154 spi_write_com(spi, 0xD109); spi_write_dat(spi, 0x5B);
155 spi_write_com(spi, 0xD10A); spi_write_dat(spi, 0x00);
156 spi_write_com(spi, 0xD10B); spi_write_dat(spi, 0x7D);
157 spi_write_com(spi, 0xD10C); spi_write_dat(spi, 0x00);
158 spi_write_com(spi, 0xD10D); spi_write_dat(spi, 0x9D);
159 spi_write_com(spi, 0xD10E); spi_write_dat(spi, 0x00);
160 spi_write_com(spi, 0xD10F); spi_write_dat(spi, 0xCC);
161 spi_write_com(spi, 0xD110); spi_write_dat(spi, 0x00);
162 spi_write_com(spi, 0xD111); spi_write_dat(spi, 0xF3);
163 spi_write_com(spi, 0xD112); spi_write_dat(spi, 0x01);
164 spi_write_com(spi, 0xD113); spi_write_dat(spi, 0x32);
165 spi_write_com(spi, 0xD114); spi_write_dat(spi, 0x01);
166 spi_write_com(spi, 0xD115); spi_write_dat(spi, 0x63);
167 spi_write_com(spi, 0xD116); spi_write_dat(spi, 0x01);
168 spi_write_com(spi, 0xD117); spi_write_dat(spi, 0xB1);
169 spi_write_com(spi, 0xD118); spi_write_dat(spi, 0x01);
170 spi_write_com(spi, 0xD119); spi_write_dat(spi, 0xF0);
171 spi_write_com(spi, 0xD11A); spi_write_dat(spi, 0x01);
172 spi_write_com(spi, 0xD11B); spi_write_dat(spi, 0xF2);
173 spi_write_com(spi, 0xD11C); spi_write_dat(spi, 0x02);
174 spi_write_com(spi, 0xD11D); spi_write_dat(spi, 0x2A);
175 spi_write_com(spi, 0xD11E); spi_write_dat(spi, 0x02);
176 spi_write_com(spi, 0xD11F); spi_write_dat(spi, 0x67);
177 spi_write_com(spi, 0xD120); spi_write_dat(spi, 0x02);
178 spi_write_com(spi, 0xD121); spi_write_dat(spi, 0x90);
179 spi_write_com(spi, 0xD122); spi_write_dat(spi, 0x02);
180 spi_write_com(spi, 0xD123); spi_write_dat(spi, 0xCB);
181 spi_write_com(spi, 0xD124); spi_write_dat(spi, 0x02);
182 spi_write_com(spi, 0xD125); spi_write_dat(spi, 0xF2);
183 spi_write_com(spi, 0xD126); spi_write_dat(spi, 0x03);
184 spi_write_com(spi, 0xD127); spi_write_dat(spi, 0x2A);
185 spi_write_com(spi, 0xD128); spi_write_dat(spi, 0x03);
186 spi_write_com(spi, 0xD129); spi_write_dat(spi, 0x51);
187 spi_write_com(spi, 0xD12A); spi_write_dat(spi, 0x03);
188 spi_write_com(spi, 0xD12B); spi_write_dat(spi, 0x80);
189 spi_write_com(spi, 0xD12C); spi_write_dat(spi, 0x03);
190 spi_write_com(spi, 0xD12D); spi_write_dat(spi, 0x9F);
191 spi_write_com(spi, 0xD12E); spi_write_dat(spi, 0x03);
192 spi_write_com(spi, 0xD12F); spi_write_dat(spi, 0xBE);
193 spi_write_com(spi, 0xD130); spi_write_dat(spi, 0x03);
194 spi_write_com(spi, 0xD131); spi_write_dat(spi, 0xF9);
195 spi_write_com(spi, 0xD132); spi_write_dat(spi, 0x03);
196 spi_write_com(spi, 0xD133); spi_write_dat(spi, 0xFF);
197
198 spi_write_com(spi, 0xD200); spi_write_dat(spi, 0x00);
199 spi_write_com(spi, 0xD201); spi_write_dat(spi, 0x05);
200 spi_write_com(spi, 0xD202); spi_write_dat(spi, 0x00);
201 spi_write_com(spi, 0xD203); spi_write_dat(spi, 0x15);
202 spi_write_com(spi, 0xD204); spi_write_dat(spi, 0x00);
203 spi_write_com(spi, 0xD205); spi_write_dat(spi, 0x30);
204 spi_write_com(spi, 0xD206); spi_write_dat(spi, 0x00);
205 spi_write_com(spi, 0xD207); spi_write_dat(spi, 0x47);
206 spi_write_com(spi, 0xD208); spi_write_dat(spi, 0x00);
207 spi_write_com(spi, 0xD209); spi_write_dat(spi, 0x5B);
208 spi_write_com(spi, 0xD20A); spi_write_dat(spi, 0x00);
209 spi_write_com(spi, 0xD20B); spi_write_dat(spi, 0x7D);
210 spi_write_com(spi, 0xD20C); spi_write_dat(spi, 0x00);
211 spi_write_com(spi, 0xD20D); spi_write_dat(spi, 0x9D);
212 spi_write_com(spi, 0xD20E); spi_write_dat(spi, 0x00);
213 spi_write_com(spi, 0xD20F); spi_write_dat(spi, 0xCC);
214 spi_write_com(spi, 0xD210); spi_write_dat(spi, 0x00);
215 spi_write_com(spi, 0xD211); spi_write_dat(spi, 0xF3);
216 spi_write_com(spi, 0xD212); spi_write_dat(spi, 0x01);
217 spi_write_com(spi, 0xD213); spi_write_dat(spi, 0x32);
218 spi_write_com(spi, 0xD214); spi_write_dat(spi, 0x01);
219 spi_write_com(spi, 0xD215); spi_write_dat(spi, 0x63);
220 spi_write_com(spi, 0xD216); spi_write_dat(spi, 0x01);
221 spi_write_com(spi, 0xD217); spi_write_dat(spi, 0xB1);
222 spi_write_com(spi, 0xD218); spi_write_dat(spi, 0x01);
223 spi_write_com(spi, 0xD219); spi_write_dat(spi, 0xF0);
224 spi_write_com(spi, 0xD21A); spi_write_dat(spi, 0x01);
225 spi_write_com(spi, 0xD21B); spi_write_dat(spi, 0xF2);
226 spi_write_com(spi, 0xD21C); spi_write_dat(spi, 0x02);
227 spi_write_com(spi, 0xD21D); spi_write_dat(spi, 0x2A);
228 spi_write_com(spi, 0xD21E); spi_write_dat(spi, 0x02);
229 spi_write_com(spi, 0xD21F); spi_write_dat(spi, 0x67);
230 spi_write_com(spi, 0xD220); spi_write_dat(spi, 0x02);
231 spi_write_com(spi, 0xD221); spi_write_dat(spi, 0x90);
232 spi_write_com(spi, 0xD222); spi_write_dat(spi, 0x02);
233 spi_write_com(spi, 0xD223); spi_write_dat(spi, 0xCB);
234 spi_write_com(spi, 0xD224); spi_write_dat(spi, 0x02);
235 spi_write_com(spi, 0xD225); spi_write_dat(spi, 0xF2);
236 spi_write_com(spi, 0xD226); spi_write_dat(spi, 0x03);
237 spi_write_com(spi, 0xD227); spi_write_dat(spi, 0x2A);
238 spi_write_com(spi, 0xD228); spi_write_dat(spi, 0x03);
239 spi_write_com(spi, 0xD229); spi_write_dat(spi, 0x51);
240 spi_write_com(spi, 0xD22A); spi_write_dat(spi, 0x03);
241 spi_write_com(spi, 0xD22B); spi_write_dat(spi, 0x80);
242 spi_write_com(spi, 0xD22C); spi_write_dat(spi, 0x03);
243 spi_write_com(spi, 0xD22D); spi_write_dat(spi, 0x9F);
244 spi_write_com(spi, 0xD22E); spi_write_dat(spi, 0x03);
245 spi_write_com(spi, 0xD22F); spi_write_dat(spi, 0xBE);
246 spi_write_com(spi, 0xD230); spi_write_dat(spi, 0x03);
247 spi_write_com(spi, 0xD231); spi_write_dat(spi, 0xF9);
248 spi_write_com(spi, 0xD232); spi_write_dat(spi, 0x03);
249 spi_write_com(spi, 0xD233); spi_write_dat(spi, 0xFF);
250
251 spi_write_com(spi, 0xD300); spi_write_dat(spi, 0x00);
252 spi_write_com(spi, 0xD301); spi_write_dat(spi, 0x05);
253 spi_write_com(spi, 0xD302); spi_write_dat(spi, 0x00);
254 spi_write_com(spi, 0xD303); spi_write_dat(spi, 0x15);
255 spi_write_com(spi, 0xD304); spi_write_dat(spi, 0x00);
256 spi_write_com(spi, 0xD305); spi_write_dat(spi, 0x30);
257 spi_write_com(spi, 0xD306); spi_write_dat(spi, 0x00);
258 spi_write_com(spi, 0xD307); spi_write_dat(spi, 0x47);
259 spi_write_com(spi, 0xD308); spi_write_dat(spi, 0x00);
260 spi_write_com(spi, 0xD309); spi_write_dat(spi, 0x5B);
261 spi_write_com(spi, 0xD30A); spi_write_dat(spi, 0x00);
262 spi_write_com(spi, 0xD30B); spi_write_dat(spi, 0x7D);
263 spi_write_com(spi, 0xD30C); spi_write_dat(spi, 0x00);
264 spi_write_com(spi, 0xD30D); spi_write_dat(spi, 0x9D);
265 spi_write_com(spi, 0xD30E); spi_write_dat(spi, 0x00);
266 spi_write_com(spi, 0xD30F); spi_write_dat(spi, 0xCC);
267 spi_write_com(spi, 0xD310); spi_write_dat(spi, 0x00);
268 spi_write_com(spi, 0xD311); spi_write_dat(spi, 0xF3);
269 spi_write_com(spi, 0xD312); spi_write_dat(spi, 0x01);
270 spi_write_com(spi, 0xD313); spi_write_dat(spi, 0x32);
271 spi_write_com(spi, 0xD314); spi_write_dat(spi, 0x01);
272 spi_write_com(spi, 0xD315); spi_write_dat(spi, 0x63);
273 spi_write_com(spi, 0xD316); spi_write_dat(spi, 0x01);
274 spi_write_com(spi, 0xD317); spi_write_dat(spi, 0xB1);
275 spi_write_com(spi, 0xD318); spi_write_dat(spi, 0x01);
276 spi_write_com(spi, 0xD319); spi_write_dat(spi, 0xF0);
277 spi_write_com(spi, 0xD31A); spi_write_dat(spi, 0x01);
278 spi_write_com(spi, 0xD31B); spi_write_dat(spi, 0xF2);
279 spi_write_com(spi, 0xD31C); spi_write_dat(spi, 0x02);
280 spi_write_com(spi, 0xD31D); spi_write_dat(spi, 0x2A);
281 spi_write_com(spi, 0xD31E); spi_write_dat(spi, 0x02);
282 spi_write_com(spi, 0xD31F); spi_write_dat(spi, 0x67);
283 spi_write_com(spi, 0xD320); spi_write_dat(spi, 0x02);
284 spi_write_com(spi, 0xD321); spi_write_dat(spi, 0x90);
285 spi_write_com(spi, 0xD322); spi_write_dat(spi, 0x02);
286 spi_write_com(spi, 0xD323); spi_write_dat(spi, 0xCB);
287 spi_write_com(spi, 0xD324); spi_write_dat(spi, 0x02);
288 spi_write_com(spi, 0xD325); spi_write_dat(spi, 0xF2);
289 spi_write_com(spi, 0xD326); spi_write_dat(spi, 0x03);
290 spi_write_com(spi, 0xD327); spi_write_dat(spi, 0x2A);
291 spi_write_com(spi, 0xD328); spi_write_dat(spi, 0x03);
292 spi_write_com(spi, 0xD329); spi_write_dat(spi, 0x51);
293 spi_write_com(spi, 0xD32A); spi_write_dat(spi, 0x03);
294 spi_write_com(spi, 0xD32B); spi_write_dat(spi, 0x80);
295 spi_write_com(spi, 0xD32C); spi_write_dat(spi, 0x03);
296 spi_write_com(spi, 0xD32D); spi_write_dat(spi, 0x9F);
297 spi_write_com(spi, 0xD32E); spi_write_dat(spi, 0x03);
298 spi_write_com(spi, 0xD32F); spi_write_dat(spi, 0xBE);
299 spi_write_com(spi, 0xD330); spi_write_dat(spi, 0x03);
300 spi_write_com(spi, 0xD331); spi_write_dat(spi, 0xF9);
301 spi_write_com(spi, 0xD332); spi_write_dat(spi, 0x03);
302 spi_write_com(spi, 0xD333); spi_write_dat(spi, 0xFF);
303
304 spi_write_com(spi, 0xD400); spi_write_dat(spi, 0x00);
305 spi_write_com(spi, 0xD401); spi_write_dat(spi, 0x05);
306 spi_write_com(spi, 0xD402); spi_write_dat(spi, 0x00);
307 spi_write_com(spi, 0xD403); spi_write_dat(spi, 0x15);
308 spi_write_com(spi, 0xD404); spi_write_dat(spi, 0x00);
309 spi_write_com(spi, 0xD405); spi_write_dat(spi, 0x30);
310 spi_write_com(spi, 0xD406); spi_write_dat(spi, 0x00);
311 spi_write_com(spi, 0xD407); spi_write_dat(spi, 0x47);
312 spi_write_com(spi, 0xD408); spi_write_dat(spi, 0x00);
313 spi_write_com(spi, 0xD409); spi_write_dat(spi, 0x5B);
314 spi_write_com(spi, 0xD40A); spi_write_dat(spi, 0x00);
315 spi_write_com(spi, 0xD40B); spi_write_dat(spi, 0x7D);
316 spi_write_com(spi, 0xD40C); spi_write_dat(spi, 0x00);
317 spi_write_com(spi, 0xD40D); spi_write_dat(spi, 0x9D);
318 spi_write_com(spi, 0xD40E); spi_write_dat(spi, 0x00);
319 spi_write_com(spi, 0xD40F); spi_write_dat(spi, 0xCC);
320 spi_write_com(spi, 0xD410); spi_write_dat(spi, 0x00);
321 spi_write_com(spi, 0xD411); spi_write_dat(spi, 0xF3);
322 spi_write_com(spi, 0xD412); spi_write_dat(spi, 0x01);
323 spi_write_com(spi, 0xD413); spi_write_dat(spi, 0x32);
324 spi_write_com(spi, 0xD414); spi_write_dat(spi, 0x01);
325 spi_write_com(spi, 0xD415); spi_write_dat(spi, 0x63);
326 spi_write_com(spi, 0xD416); spi_write_dat(spi, 0x01);
327 spi_write_com(spi, 0xD417); spi_write_dat(spi, 0xB1);
328 spi_write_com(spi, 0xD418); spi_write_dat(spi, 0x01);
329 spi_write_com(spi, 0xD419); spi_write_dat(spi, 0xF0);
330 spi_write_com(spi, 0xD41A); spi_write_dat(spi, 0x01);
331 spi_write_com(spi, 0xD41B); spi_write_dat(spi, 0xF2);
332 spi_write_com(spi, 0xD41C); spi_write_dat(spi, 0x02);
333 spi_write_com(spi, 0xD41D); spi_write_dat(spi, 0x2A);
334 spi_write_com(spi, 0xD41E); spi_write_dat(spi, 0x02);
335 spi_write_com(spi, 0xD41F); spi_write_dat(spi, 0x67);
336 spi_write_com(spi, 0xD420); spi_write_dat(spi, 0x02);
337 spi_write_com(spi, 0xD421); spi_write_dat(spi, 0x90);
338 spi_write_com(spi, 0xD422); spi_write_dat(spi, 0x02);
339 spi_write_com(spi, 0xD423); spi_write_dat(spi, 0xCB);
340 spi_write_com(spi, 0xD424); spi_write_dat(spi, 0x02);
341 spi_write_com(spi, 0xD425); spi_write_dat(spi, 0xF2);
342 spi_write_com(spi, 0xD426); spi_write_dat(spi, 0x03);
343 spi_write_com(spi, 0xD427); spi_write_dat(spi, 0x2A);
344 spi_write_com(spi, 0xD428); spi_write_dat(spi, 0x03);
345 spi_write_com(spi, 0xD429); spi_write_dat(spi, 0x51);
346 spi_write_com(spi, 0xD42A); spi_write_dat(spi, 0x03);
347 spi_write_com(spi, 0xD42B); spi_write_dat(spi, 0x80);
348 spi_write_com(spi, 0xD42C); spi_write_dat(spi, 0x03);
349 spi_write_com(spi, 0xD42D); spi_write_dat(spi, 0x9F);
350 spi_write_com(spi, 0xD42E); spi_write_dat(spi, 0x03);
351 spi_write_com(spi, 0xD42F); spi_write_dat(spi, 0xBE);
352 spi_write_com(spi, 0xD430); spi_write_dat(spi, 0x03);
353 spi_write_com(spi, 0xD431); spi_write_dat(spi, 0xF9);
354 spi_write_com(spi, 0xD432); spi_write_dat(spi, 0x03);
355 spi_write_com(spi, 0xD433); spi_write_dat(spi, 0xFF);
356
357 spi_write_com(spi, 0xD500); spi_write_dat(spi, 0x00);
358 spi_write_com(spi, 0xD501); spi_write_dat(spi, 0x05);
359 spi_write_com(spi, 0xD502); spi_write_dat(spi, 0x00);
360 spi_write_com(spi, 0xD503); spi_write_dat(spi, 0x15);
361 spi_write_com(spi, 0xD504); spi_write_dat(spi, 0x00);
362 spi_write_com(spi, 0xD505); spi_write_dat(spi, 0x30);
363 spi_write_com(spi, 0xD506); spi_write_dat(spi, 0x00);
364 spi_write_com(spi, 0xD507); spi_write_dat(spi, 0x47);
365 spi_write_com(spi, 0xD508); spi_write_dat(spi, 0x00);
366 spi_write_com(spi, 0xD509); spi_write_dat(spi, 0x5B);
367 spi_write_com(spi, 0xD50A); spi_write_dat(spi, 0x00);
368 spi_write_com(spi, 0xD50B); spi_write_dat(spi, 0x7D);
369 spi_write_com(spi, 0xD50C); spi_write_dat(spi, 0x00);
370 spi_write_com(spi, 0xD50D); spi_write_dat(spi, 0x9D);
371 spi_write_com(spi, 0xD50E); spi_write_dat(spi, 0x00);
372 spi_write_com(spi, 0xD50F); spi_write_dat(spi, 0xCC);
373 spi_write_com(spi, 0xD510); spi_write_dat(spi, 0x00);
374 spi_write_com(spi, 0xD511); spi_write_dat(spi, 0xF3);
375 spi_write_com(spi, 0xD512); spi_write_dat(spi, 0x01);
376 spi_write_com(spi, 0xD513); spi_write_dat(spi, 0x32);
377 spi_write_com(spi, 0xD514); spi_write_dat(spi, 0x01);
378 spi_write_com(spi, 0xD515); spi_write_dat(spi, 0x63);
379 spi_write_com(spi, 0xD516); spi_write_dat(spi, 0x01);
380 spi_write_com(spi, 0xD517); spi_write_dat(spi, 0xB1);
381 spi_write_com(spi, 0xD518); spi_write_dat(spi, 0x01);
382 spi_write_com(spi, 0xD519); spi_write_dat(spi, 0xF0);
383 spi_write_com(spi, 0xD51A); spi_write_dat(spi, 0x01);
384 spi_write_com(spi, 0xD51B); spi_write_dat(spi, 0xF2);
385 spi_write_com(spi, 0xD51C); spi_write_dat(spi, 0x02);
386 spi_write_com(spi, 0xD51D); spi_write_dat(spi, 0x2A);
387 spi_write_com(spi, 0xD51E); spi_write_dat(spi, 0x02);
388 spi_write_com(spi, 0xD51F); spi_write_dat(spi, 0x67);
389 spi_write_com(spi, 0xD520); spi_write_dat(spi, 0x02);
390 spi_write_com(spi, 0xD521); spi_write_dat(spi, 0x90);
391 spi_write_com(spi, 0xD522); spi_write_dat(spi, 0x02);
392 spi_write_com(spi, 0xD523); spi_write_dat(spi, 0xCB);
393 spi_write_com(spi, 0xD524); spi_write_dat(spi, 0x02);
394 spi_write_com(spi, 0xD525); spi_write_dat(spi, 0xF2);
395 spi_write_com(spi, 0xD526); spi_write_dat(spi, 0x03);
396 spi_write_com(spi, 0xD527); spi_write_dat(spi, 0x2A);
397 spi_write_com(spi, 0xD528); spi_write_dat(spi, 0x03);
398 spi_write_com(spi, 0xD529); spi_write_dat(spi, 0x51);
399 spi_write_com(spi, 0xD52A); spi_write_dat(spi, 0x03);
400 spi_write_com(spi, 0xD52B); spi_write_dat(spi, 0x80);
401 spi_write_com(spi, 0xD52C); spi_write_dat(spi, 0x03);
402 spi_write_com(spi, 0xD52D); spi_write_dat(spi, 0x9F);
403 spi_write_com(spi, 0xD52E); spi_write_dat(spi, 0x03);
404 spi_write_com(spi, 0xD52F); spi_write_dat(spi, 0xBE);
405 spi_write_com(spi, 0xD530); spi_write_dat(spi, 0x03);
406 spi_write_com(spi, 0xD531); spi_write_dat(spi, 0xF9);
407 spi_write_com(spi, 0xD532); spi_write_dat(spi, 0x03);
408 spi_write_com(spi, 0xD533); spi_write_dat(spi, 0xFF);
409
410 spi_write_com(spi, 0xD600); spi_write_dat(spi, 0x00);
411 spi_write_com(spi, 0xD601); spi_write_dat(spi, 0x05);
412 spi_write_com(spi, 0xD602); spi_write_dat(spi, 0x00);
413 spi_write_com(spi, 0xD603); spi_write_dat(spi, 0x15);
414 spi_write_com(spi, 0xD604); spi_write_dat(spi, 0x00);
415 spi_write_com(spi, 0xD605); spi_write_dat(spi, 0x30);
416 spi_write_com(spi, 0xD606); spi_write_dat(spi, 0x00);
417 spi_write_com(spi, 0xD607); spi_write_dat(spi, 0x47);
418 spi_write_com(spi, 0xD608); spi_write_dat(spi, 0x00);
419 spi_write_com(spi, 0xD609); spi_write_dat(spi, 0x5B);
420 spi_write_com(spi, 0xD60A); spi_write_dat(spi, 0x00);
421 spi_write_com(spi, 0xD60B); spi_write_dat(spi, 0x7D);
422 spi_write_com(spi, 0xD60C); spi_write_dat(spi, 0x00);
423 spi_write_com(spi, 0xD60D); spi_write_dat(spi, 0x9D);
424 spi_write_com(spi, 0xD60E); spi_write_dat(spi, 0x00);
425 spi_write_com(spi, 0xD60F); spi_write_dat(spi, 0xCC);
426 spi_write_com(spi, 0xD610); spi_write_dat(spi, 0x00);
427 spi_write_com(spi, 0xD611); spi_write_dat(spi, 0xF3);
428 spi_write_com(spi, 0xD612); spi_write_dat(spi, 0x01);
429 spi_write_com(spi, 0xD613); spi_write_dat(spi, 0x32);
430 spi_write_com(spi, 0xD614); spi_write_dat(spi, 0x01);
431 spi_write_com(spi, 0xD615); spi_write_dat(spi, 0x63);
432 spi_write_com(spi, 0xD616); spi_write_dat(spi, 0x01);
433 spi_write_com(spi, 0xD617); spi_write_dat(spi, 0xB1);
434 spi_write_com(spi, 0xD618); spi_write_dat(spi, 0x01);
435 spi_write_com(spi, 0xD619); spi_write_dat(spi, 0xF0);
436 spi_write_com(spi, 0xD61A); spi_write_dat(spi, 0x01);
437 spi_write_com(spi, 0xD61B); spi_write_dat(spi, 0xF2);
438 spi_write_com(spi, 0xD61C); spi_write_dat(spi, 0x02);
439 spi_write_com(spi, 0xD61D); spi_write_dat(spi, 0x2A);
440 spi_write_com(spi, 0xD61E); spi_write_dat(spi, 0x02);
441 spi_write_com(spi, 0xD61F); spi_write_dat(spi, 0x67);
442 spi_write_com(spi, 0xD620); spi_write_dat(spi, 0x02);
443 spi_write_com(spi, 0xD621); spi_write_dat(spi, 0x90);
444 spi_write_com(spi, 0xD622); spi_write_dat(spi, 0x02);
445 spi_write_com(spi, 0xD623); spi_write_dat(spi, 0xCB);
446 spi_write_com(spi, 0xD624); spi_write_dat(spi, 0x02);
447 spi_write_com(spi, 0xD625); spi_write_dat(spi, 0xF2);
448 spi_write_com(spi, 0xD626); spi_write_dat(spi, 0x03);
449 spi_write_com(spi, 0xD627); spi_write_dat(spi, 0x2A);
450 spi_write_com(spi, 0xD628); spi_write_dat(spi, 0x03);
451 spi_write_com(spi, 0xD629); spi_write_dat(spi, 0x51);
452 spi_write_com(spi, 0xD62A); spi_write_dat(spi, 0x03);
453 spi_write_com(spi, 0xD62B); spi_write_dat(spi, 0x80);
454 spi_write_com(spi, 0xD62C); spi_write_dat(spi, 0x03);
455 spi_write_com(spi, 0xD62D); spi_write_dat(spi, 0x9F);
456 spi_write_com(spi, 0xD62E); spi_write_dat(spi, 0x03);
457 spi_write_com(spi, 0xD62F); spi_write_dat(spi, 0xBE);
458 spi_write_com(spi, 0xD630); spi_write_dat(spi, 0x03);
459 spi_write_com(spi, 0xD631); spi_write_dat(spi, 0xF9);
460 spi_write_com(spi, 0xD632); spi_write_dat(spi, 0x03);
461 spi_write_com(spi, 0xD633); spi_write_dat(spi, 0xFF);
462
463 /* LV2 Page 0 enable */
464 spi_write_com(spi, 0xF000); spi_write_dat(spi, 0x55);
465 spi_write_com(spi, 0xF001); spi_write_dat(spi, 0xAA);
466 spi_write_com(spi, 0xF002); spi_write_dat(spi, 0x52);
467 spi_write_com(spi, 0xF003); spi_write_dat(spi, 0x08);
468 spi_write_com(spi, 0xF004); spi_write_dat(spi, 0x00);
469
470 /* Display control */
471 spi_write_com(spi, 0xB100); spi_write_dat(spi, 0xFC);
472 spi_write_com(spi, 0xB101); spi_write_dat(spi, 0x00);
473
474 /* Source hold time */
475 spi_write_com(spi, 0xB600); spi_write_dat(spi, 0x05);
476
477 /* Gate EQ control */
478 spi_write_com(spi, 0xB700); spi_write_dat(spi, 0x70);
479 spi_write_com(spi, 0xB701); spi_write_dat(spi, 0x70);
480
481 /* Source EQ control (Mode 2) */
482 spi_write_com(spi, 0xB800); spi_write_dat(spi, 0x01);
483 spi_write_com(spi, 0xB801); spi_write_dat(spi, 0x05);
484 spi_write_com(spi, 0xB802); spi_write_dat(spi, 0x05);
485 spi_write_com(spi, 0xB803); spi_write_dat(spi, 0x05);
486
487 /* Inversion mode (Column) */
488 spi_write_com(spi, 0xBC00); spi_write_dat(spi, 0x00);
489 spi_write_com(spi, 0xBC01); spi_write_dat(spi, 0x00);
490 spi_write_com(spi, 0xBC02); spi_write_dat(spi, 0x00);
491
492 /* Timing control 8phase dual side/4H/4delay/RST_EN */
493 spi_write_com(spi, 0xC900); spi_write_dat(spi, 0xD0);
494 spi_write_com(spi, 0xC901); spi_write_dat(spi, 0x82);
495 spi_write_com(spi, 0xC902); spi_write_dat(spi, 0x50);
496 spi_write_com(spi, 0xC903); spi_write_dat(spi, 0x50);
497 spi_write_com(spi, 0xC904); spi_write_dat(spi, 0x50);
498
499 spi_write_com(spi, 0x3A00); spi_write_dat(spi, 0x55);
500 mdelay(120);
501 spi_write_com(spi, 0x1100);
502 mdelay(120);
503 spi_write_com(spi, 0x2900);
504 mdelay(120);
505 /* spi_write_com(spi, 0x2100); spi_write_dat(spi, 0x00); */
506 spi_write_com(spi, 0x2C00);
507
508 return 0;
509err_claim_bus:
510 spi_free_slave(spi);
511 return -1;
512}