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