wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Gary Jennejohn, DENX Software Engineering, <gj@denx.de> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* #define DEBUG */ |
| 25 | |
| 26 | #include <common.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 27 | #include <malloc.h> |
| 28 | #include <s3c2400.h> |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 29 | #include <command.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 30 | |
| 31 | /* ------------------------------------------------------------------------- */ |
| 32 | |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 33 | #ifdef CFG_BRIGHTNESS |
| 34 | static void spi_init(void); |
| 35 | static void wait_transmit_done(void); |
wdenk | 2699155 | 2003-05-20 20:49:01 +0000 | [diff] [blame] | 36 | static void tsc2000_write(unsigned int page, unsigned int reg, |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 37 | unsigned int data); |
| 38 | static void tsc2000_set_brightness(void); |
| 39 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 40 | #ifdef CONFIG_MODEM_SUPPORT |
| 41 | static int key_pressed(void); |
| 42 | extern void disable_putc(void); |
| 43 | extern int do_mdm_init; /* defined in common/main.c */ |
| 44 | |
| 45 | /* |
| 46 | * We need a delay of at least 500 us after turning on the VFD clock |
| 47 | * before we can read any useful information for the CPLD controlling |
| 48 | * the keyboard switches. Let's play safe and wait 5 ms. The problem |
| 49 | * is that timers are not available yet, so we use a manually timed |
| 50 | * loop. |
| 51 | */ |
wdenk | e95b61c | 2002-11-04 16:02:40 +0000 | [diff] [blame] | 52 | #define KBD_MDELAY 5000 |
| 53 | static void udelay_no_timer (int usec) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 54 | { |
| 55 | DECLARE_GLOBAL_DATA_PTR; |
| 56 | |
| 57 | int i; |
wdenk | e95b61c | 2002-11-04 16:02:40 +0000 | [diff] [blame] | 58 | int delay = usec * 3; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 59 | |
| 60 | for (i = 0; i < delay; i ++) gd->bd->bi_arch_number = 145; |
| 61 | } |
| 62 | #endif /* CONFIG_MODEM_SUPPORT */ |
| 63 | |
| 64 | /* |
| 65 | * Miscellaneous platform dependent initialisations |
| 66 | */ |
| 67 | |
| 68 | int board_init () |
| 69 | { |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 70 | #if defined(CONFIG_VFD) |
| 71 | extern int vfd_init_clocks(void); |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 72 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 73 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 74 | S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER(); |
| 75 | S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 76 | |
| 77 | /* memory and cpu-speed are setup before relocation */ |
| 78 | #ifdef CONFIG_TRAB_50MHZ |
| 79 | /* change the clock to be 50 MHz 1:1:1 */ |
| 80 | /* MDIV:0x5c PDIV:4 SDIV:2 */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 81 | clk_power->MPLLCON = 0x5c042; |
| 82 | clk_power->CLKDIVN = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 83 | #else |
| 84 | /* change the clock to be 133 MHz 1:2:4 */ |
| 85 | /* MDIV:0x7d PDIV:4 SDIV:1 */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 86 | clk_power->MPLLCON = 0x7d041; |
| 87 | clk_power->CLKDIVN = 3; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | #endif |
| 89 | |
| 90 | /* set up the I/O ports */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 91 | gpio->PACON = 0x3ffff; |
| 92 | gpio->PBCON = 0xaaaaaaaa; |
| 93 | gpio->PBUP = 0xffff; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 94 | /* INPUT nCTS0 nRTS0 TXD[1] TXD[0] RXD[1] RXD[0] */ |
| 95 | /* 00, 10, 10, 10, 10, 10, 10 */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 96 | gpio->PFCON = (2<<0) | (2<<2) | (2<<4) | (2<<6) | (2<<8) | (2<<10); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 97 | #ifdef CONFIG_HWFLOW |
| 98 | /* do not pull up RXD0, RXD1, TXD0, TXD1, CTS0, RTS0 */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 99 | gpio->PFUP = (1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 100 | #else |
| 101 | /* do not pull up RXD0, RXD1, TXD0, TXD1 */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 102 | gpio->PFUP = (1<<0) | (1<<1) | (1<<2) | (1<<3); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 103 | #endif |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 104 | gpio->PGCON = 0x0; |
| 105 | gpio->PGUP = 0x0; |
| 106 | gpio->OPENCR= 0x0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 107 | |
| 108 | /* arch number of SAMSUNG-Board */ |
| 109 | /* MACH_TYPE_SMDK2400 */ |
| 110 | /* XXX this isn't really correct, but keep it for now */ |
| 111 | gd->bd->bi_arch_number = 145; |
| 112 | |
| 113 | /* adress of boot parameters */ |
| 114 | gd->bd->bi_boot_params = 0x0c000100; |
| 115 | |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 116 | /* Make sure both buzzers are turned off */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 117 | gpio->PDCON |= 0x5400; |
| 118 | gpio->PDDAT &= ~0xE0; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 119 | |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 120 | #ifdef CONFIG_VFD |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 121 | vfd_init_clocks(); |
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 122 | #endif /* CONFIG_VFD */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 123 | |
wdenk | 4fc9569 | 2003-02-28 00:49:47 +0000 | [diff] [blame] | 124 | #ifdef CONFIG_MODEM_SUPPORT |
wdenk | e95b61c | 2002-11-04 16:02:40 +0000 | [diff] [blame] | 125 | udelay_no_timer (KBD_MDELAY); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 126 | |
| 127 | if (key_pressed()) { |
| 128 | disable_putc(); /* modem doesn't understand banner etc */ |
| 129 | do_mdm_init = 1; |
| 130 | } |
| 131 | #endif /* CONFIG_MODEM_SUPPORT */ |
| 132 | |
wdenk | ca9bc76 | 2003-07-15 07:45:49 +0000 | [diff] [blame] | 133 | #ifdef CONFIG_DRIVER_S3C24X0_I2C |
| 134 | /* Configure I/O ports PG5 und PG6 for I2C */ |
| 135 | gpio->PGCON = (gpio->PGCON & 0x003c00) | 0x003c00; |
| 136 | #endif /* CONFIG_DRIVER_S3C24X0_I2C */ |
| 137 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | int dram_init (void) |
| 142 | { |
| 143 | DECLARE_GLOBAL_DATA_PTR; |
| 144 | |
| 145 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 146 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | /*----------------------------------------------------------------------- |
| 151 | * Keyboard Controller |
| 152 | */ |
| 153 | |
| 154 | /* Maximum key number */ |
| 155 | #define KEYBD_KEY_NUM 4 |
| 156 | |
| 157 | #define KBD_DATA (((*(volatile ulong *)0x04020000) >> 16) & 0xF) |
| 158 | |
| 159 | static uchar *key_match (ulong); |
| 160 | |
| 161 | int misc_init_r (void) |
| 162 | { |
| 163 | ulong kbd_data = KBD_DATA; |
| 164 | uchar keybd_env[KEYBD_KEY_NUM + 1]; |
| 165 | uchar *str; |
| 166 | int i; |
| 167 | |
| 168 | for (i = 0; i < KEYBD_KEY_NUM; ++i) { |
| 169 | keybd_env[i] = '0' + ((kbd_data >> i) & 1); |
| 170 | } |
| 171 | keybd_env[i] = '\0'; |
| 172 | debug ("** Setting keybd=\"%s\"\n", keybd_env); |
| 173 | setenv ("keybd", keybd_env); |
| 174 | |
| 175 | str = strdup (key_match (kbd_data)); /* decode keys */ |
| 176 | |
| 177 | #ifdef CONFIG_PREBOOT /* automatically configure "preboot" command on key match */ |
| 178 | debug ("** Setting preboot=\"%s\"\n", str); |
| 179 | setenv ("preboot", str); /* set or delete definition */ |
| 180 | #endif /* CONFIG_PREBOOT */ |
| 181 | if (str != NULL) { |
| 182 | free (str); |
| 183 | } |
| 184 | |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 185 | #ifdef CFG_BRIGHTNESS |
| 186 | tsc2000_set_brightness(); |
| 187 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 188 | return (0); |
| 189 | } |
| 190 | |
| 191 | #ifdef CONFIG_PREBOOT |
| 192 | |
| 193 | static uchar kbd_magic_prefix[] = "key_magic"; |
| 194 | static uchar kbd_command_prefix[] = "key_cmd"; |
| 195 | |
| 196 | static int compare_magic (ulong kbd_data, uchar *str) |
| 197 | { |
| 198 | uchar key_mask; |
| 199 | |
| 200 | debug ("compare_magic: kbd: %04lx str: \"%s\"\n",kbd_data,str); |
| 201 | for (; *str; str++) |
| 202 | { |
| 203 | uchar c = *str - '1'; |
| 204 | |
| 205 | if (c >= KEYBD_KEY_NUM) /* bad key number */ |
| 206 | return -1; |
| 207 | |
| 208 | key_mask = 1 << c; |
| 209 | |
| 210 | if (!(kbd_data & key_mask)) { /* key not pressed */ |
| 211 | debug ( "compare_magic: " |
| 212 | "kbd: %04lx mask: %04lx - key not pressed\n", |
| 213 | kbd_data, key_mask ); |
| 214 | return -1; |
| 215 | } |
| 216 | |
| 217 | kbd_data &= ~key_mask; |
| 218 | } |
| 219 | |
| 220 | if (kbd_data) { /* key(s) not released */ |
| 221 | debug ( "compare_magic: " |
| 222 | "kbd: %04lx - key(s) not released\n", kbd_data); |
| 223 | return -1; |
| 224 | } |
| 225 | |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | /*----------------------------------------------------------------------- |
| 230 | * Check if pressed key(s) match magic sequence, |
| 231 | * and return the command string associated with that key(s). |
| 232 | * |
| 233 | * If no key press was decoded, NULL is returned. |
| 234 | * |
| 235 | * Note: the first character of the argument will be overwritten with |
| 236 | * the "magic charcter code" of the decoded key(s), or '\0'. |
| 237 | * |
| 238 | * |
| 239 | * Note: the string points to static environment data and must be |
| 240 | * saved before you call any function that modifies the environment. |
| 241 | */ |
| 242 | static uchar *key_match (ulong kbd_data) |
| 243 | { |
| 244 | uchar magic[sizeof (kbd_magic_prefix) + 1]; |
| 245 | uchar cmd_name[sizeof (kbd_command_prefix) + 1]; |
| 246 | uchar *suffix; |
| 247 | uchar *kbd_magic_keys; |
| 248 | |
| 249 | /* |
| 250 | * The following string defines the characters that can pe appended |
| 251 | * to "key_magic" to form the names of environment variables that |
| 252 | * hold "magic" key codes, i. e. such key codes that can cause |
| 253 | * pre-boot actions. If the string is empty (""), then only |
| 254 | * "key_magic" is checked (old behaviour); the string "125" causes |
| 255 | * checks for "key_magic1", "key_magic2" and "key_magic5", etc. |
| 256 | */ |
| 257 | if ((kbd_magic_keys = getenv ("magic_keys")) == NULL) |
| 258 | kbd_magic_keys = ""; |
| 259 | |
| 260 | debug ("key_match: magic_keys=\"%s\"\n", kbd_magic_keys); |
| 261 | |
| 262 | /* loop over all magic keys; |
| 263 | * use '\0' suffix in case of empty string |
| 264 | */ |
| 265 | for (suffix=kbd_magic_keys; *suffix || suffix==kbd_magic_keys; ++suffix) |
| 266 | { |
| 267 | sprintf (magic, "%s%c", kbd_magic_prefix, *suffix); |
| 268 | |
| 269 | debug ("key_match: magic=\"%s\"\n", |
| 270 | getenv(magic) ? getenv(magic) : "<UNDEFINED>"); |
| 271 | |
| 272 | if (compare_magic(kbd_data, getenv(magic)) == 0) |
| 273 | { |
| 274 | sprintf (cmd_name, "%s%c", kbd_command_prefix, *suffix); |
| 275 | debug ("key_match: cmdname %s=\"%s\"\n", |
| 276 | cmd_name, |
| 277 | getenv (cmd_name) ? |
| 278 | getenv (cmd_name) : |
| 279 | "<UNDEFINED>"); |
| 280 | return (getenv (cmd_name)); |
| 281 | } |
| 282 | } |
| 283 | debug ("key_match: no match\n"); |
| 284 | return (NULL); |
| 285 | } |
| 286 | #endif /* CONFIG_PREBOOT */ |
| 287 | |
| 288 | /* Read Keyboard status */ |
| 289 | int do_kbd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 290 | { |
| 291 | ulong kbd_data = KBD_DATA; |
| 292 | uchar keybd_env[KEYBD_KEY_NUM + 1]; |
| 293 | int i; |
| 294 | |
| 295 | puts ("Keys:"); |
| 296 | for (i = 0; i < KEYBD_KEY_NUM; ++i) { |
| 297 | keybd_env[i] = '0' + ((kbd_data >> i) & 1); |
| 298 | printf (" %c", keybd_env[i]); |
| 299 | } |
| 300 | keybd_env[i] = '\0'; |
| 301 | putc ('\n'); |
| 302 | setenv ("keybd", keybd_env); |
| 303 | return 0; |
| 304 | } |
| 305 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 306 | U_BOOT_CMD( |
| 307 | kbd, 1, 1, do_kbd, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 308 | "kbd - read keyboard status\n", |
| 309 | NULL |
| 310 | ); |
| 311 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 312 | #ifdef CONFIG_MODEM_SUPPORT |
| 313 | static int key_pressed(void) |
| 314 | { |
| 315 | return (compare_magic(KBD_DATA, CONFIG_MODEM_KEY_MAGIC) == 0); |
| 316 | } |
| 317 | #endif /* CONFIG_MODEM_SUPPORT */ |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 318 | |
| 319 | #ifdef CFG_BRIGHTNESS |
| 320 | |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 321 | static inline void SET_CS_TOUCH(void) |
| 322 | { |
| 323 | S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); |
| 324 | |
| 325 | gpio->PDDAT &= 0x5FF; |
| 326 | } |
| 327 | |
| 328 | static inline void CLR_CS_TOUCH(void) |
| 329 | { |
| 330 | S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); |
| 331 | |
| 332 | gpio->PDDAT |= 0x200; |
| 333 | } |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 334 | |
| 335 | static void spi_init(void) |
| 336 | { |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 337 | S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); |
| 338 | S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 339 | int i; |
| 340 | |
| 341 | /* Configure I/O ports. */ |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 342 | gpio->PDCON = (gpio->PDCON & 0xF3FFFF) | 0x040000; |
| 343 | gpio->PGCON = (gpio->PGCON & 0x0F3FFF) | 0x008000; |
| 344 | gpio->PGCON = (gpio->PGCON & 0x0CFFFF) | 0x020000; |
| 345 | gpio->PGCON = (gpio->PGCON & 0x03FFFF) | 0x080000; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 346 | |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 347 | CLR_CS_TOUCH(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 348 | |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 349 | spi->ch[0].SPPRE = 0x1F; /* Baudrate ca. 514kHz */ |
| 350 | spi->ch[0].SPPIN = 0x01; /* SPI-MOSI holds Level after last bit */ |
| 351 | spi->ch[0].SPCON = 0x1A; /* Polling, Prescaler, Master, CPOL=0, CPHA=1 */ |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 352 | |
| 353 | /* Dummy byte ensures clock to be low. */ |
| 354 | for (i = 0; i < 10; i++) { |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 355 | spi->ch[0].SPTDAT = 0xFF; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 356 | } |
wdenk | 2699155 | 2003-05-20 20:49:01 +0000 | [diff] [blame] | 357 | wait_transmit_done(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | static void wait_transmit_done(void) |
| 361 | { |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 362 | S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI(); |
| 363 | |
| 364 | while (!(spi->ch[0].SPSTA & 0x01)); /* wait until transfer is done */ |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 365 | } |
| 366 | |
wdenk | 2699155 | 2003-05-20 20:49:01 +0000 | [diff] [blame] | 367 | static void tsc2000_write(unsigned int page, unsigned int reg, |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 368 | unsigned int data) |
| 369 | { |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 370 | S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 371 | unsigned int command; |
| 372 | |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 373 | SET_CS_TOUCH(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 374 | command = 0x0000; |
| 375 | command |= (page << 11); |
| 376 | command |= (reg << 5); |
| 377 | |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 378 | spi->ch[0].SPTDAT = (command & 0xFF00) >> 8; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 379 | wait_transmit_done(); |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 380 | spi->ch[0].SPTDAT = (command & 0x00FF); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 381 | wait_transmit_done(); |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 382 | spi->ch[0].SPTDAT = (data & 0xFF00) >> 8; |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 383 | wait_transmit_done(); |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 384 | spi->ch[0].SPTDAT = (data & 0x00FF); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 385 | wait_transmit_done(); |
| 386 | |
wdenk | 7539dea | 2003-06-19 23:01:32 +0000 | [diff] [blame] | 387 | CLR_CS_TOUCH(); |
wdenk | 1fe2c70 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | static void tsc2000_set_brightness(void) |
| 391 | { |
| 392 | uchar tmp[10]; |
| 393 | int i, br; |
| 394 | |
| 395 | spi_init(); |
| 396 | tsc2000_write(1, 2, 0x0); /* Power up DAC */ |
| 397 | |
| 398 | i = getenv_r("brightness", tmp, sizeof(tmp)); |
| 399 | br = (i > 0) |
| 400 | ? (int) simple_strtoul (tmp, NULL, 10) |
| 401 | : CFG_BRIGHTNESS; |
| 402 | |
| 403 | tsc2000_write(0, 0xb, br & 0xff); |
| 404 | } |
| 405 | #endif |