blob: 67a0c30e2c7048f8825d4b529f12986d5b761423 [file] [log] [blame]
stroese1f54ce62004-12-16 18:23:14 +00001/*
2 * (C) Copyright 2001-2004
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
4 *
Stefan Roese98f4a3d2005-09-22 09:04:17 +02005 * (C) Copyright 2005
6 * Stefan Roese, DENX Software Engineering, sr@denx.de.
7 *
stroese1f54ce62004-12-16 18:23:14 +00008 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA
25 */
26
27#include <common.h>
28#include <asm/processor.h>
29#include <command.h>
30#include <malloc.h>
Stefan Roese98f4a3d2005-09-22 09:04:17 +020031#include <pci.h>
32#include <sm501.h>
stroese1f54ce62004-12-16 18:23:14 +000033
Stefan Roese98f4a3d2005-09-22 09:04:17 +020034
35#ifdef CONFIG_VIDEO_SM501
36
37#define SWAP32(x) ((((x) & 0x000000ff) << 24) | (((x) & 0x0000ff00) << 8)|\
38 (((x) & 0x00ff0000) >> 8) | (((x) & 0xff000000) >> 24) )
39
40#ifdef CONFIG_VIDEO_SM501_8BPP
41#error CONFIG_VIDEO_SM501_8BPP not supported.
42#endif /* CONFIG_VIDEO_SM501_8BPP */
43
44#ifdef CONFIG_VIDEO_SM501_16BPP
45#define BPP 16
46
47/*
48 * 800x600 display B084SN03: PCLK = 40MHz
49 * => 2*PCLK = 80MHz
50 * 336/4 = 84MHz
51 * => PCLK = 84MHz
52 */
53static const SMI_REGS init_regs_800x600 [] =
54{
55#if 1 /* test-only */
56 {0x0005c, SWAP32(0xffffffff)}, /* set endianess to big endian */
57#else
58 {0x0005c, SWAP32(0x00000000)}, /* set endianess to little endian */
59#endif
60 {0x00004, SWAP32(0x00000000)},
61 /* clocks for pm1... */
62 {0x00048, SWAP32(0x00021807)},
63 {0x0004C, SWAP32(0x221a0a01)},
64 {0x00054, SWAP32(0x00000001)},
65 /* clocks for pm0... */
66 {0x00040, SWAP32(0x00021807)},
67 {0x00044, SWAP32(0x221a0a01)},
68 {0x00054, SWAP32(0x00000000)},
69 /* panel control regs... */
70 {0x80000, SWAP32(0x0f013105)}, /* panel display control: 16-bit RGB 5:6:5 mode */
71 {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
72 {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
73 {0x80010, SWAP32(0x06400640)}, /* panel fb offset/window width */
74 {0x80014, SWAP32(0x03200000)}, /* panel fb width (0x320=800) */
75 {0x80018, SWAP32(0x02580000)}, /* panel fb height (0x258=600) */
76 {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
77 {0x80020, SWAP32(0x02580320)}, /* panel plane br location */
78 {0x80024, SWAP32(0x041f031f)}, /* panel horizontal total */
79 {0x80028, SWAP32(0x00800347)}, /* panel horizontal sync */
80 {0x8002C, SWAP32(0x02730257)}, /* panel vertical total */
81 {0x80030, SWAP32(0x00040258)}, /* panel vertical sync */
82 {0x80200, SWAP32(0x00010000)}, /* crt display control */
83 {0, 0}
84};
85
86/*
87 * 1024x768 display G150XG02: PCLK = 65MHz
88 * => 2*PCLK = 130MHz
89 * 288/2 = 144MHz
90 * => PCLK = 72MHz
91 */
92static const SMI_REGS init_regs_1024x768 [] =
93{
94 {0x00004, SWAP32(0x00000000)},
95 /* clocks for pm1... */
96 {0x00048, SWAP32(0x00021807)},
97 {0x0004C, SWAP32(0x011a0a01)},
98 {0x00054, SWAP32(0x00000001)},
99 /* clocks for pm0... */
100 {0x00040, SWAP32(0x00021807)},
101 {0x00044, SWAP32(0x011a0a01)},
102 {0x00054, SWAP32(0x00000000)},
103 /* panel control regs... */
104 {0x80000, SWAP32(0x0f013105)}, /* panel display control: 16-bit RGB 5:6:5 mode */
105 {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
106 {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
107 {0x80010, SWAP32(0x08000800)}, /* panel fb offset/window width */
108 {0x80014, SWAP32(0x04000000)}, /* panel fb width (0x400=1024) */
109 {0x80018, SWAP32(0x03000000)}, /* panel fb height (0x300=768) */
110 {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
111 {0x80020, SWAP32(0x03000400)}, /* panel plane br location */
112 {0x80024, SWAP32(0x053f03ff)}, /* panel horizontal total */
113 {0x80028, SWAP32(0x0140040f)}, /* panel horizontal sync */
114 {0x8002C, SWAP32(0x032502ff)}, /* panel vertical total */
115 {0x80030, SWAP32(0x00260301)}, /* panel vertical sync */
116 {0x80200, SWAP32(0x00010000)}, /* crt display control */
117 {0, 0}
118};
119
120#endif /* CONFIG_VIDEO_SM501_16BPP */
121
122#ifdef CONFIG_VIDEO_SM501_32BPP
123#define BPP 32
124
125/*
126 * 800x600 display B084SN03: PCLK = 40MHz
127 * => 2*PCLK = 80MHz
128 * 336/4 = 84MHz
129 * => PCLK = 84MHz
130 */
131static const SMI_REGS init_regs_800x600 [] =
132{
133#if 0 /* test-only */
134 {0x0005c, SWAP32(0xffffffff)}, /* set endianess to big endian */
135#else
136 {0x0005c, SWAP32(0x00000000)}, /* set endianess to little endian */
137#endif
138 {0x00004, SWAP32(0x00000000)},
139 /* clocks for pm1... */
140 {0x00048, SWAP32(0x00021807)},
141 {0x0004C, SWAP32(0x221a0a01)},
142 {0x00054, SWAP32(0x00000001)},
143 /* clocks for pm0... */
144 {0x00040, SWAP32(0x00021807)},
145 {0x00044, SWAP32(0x221a0a01)},
146 {0x00054, SWAP32(0x00000000)},
147 /* panel control regs... */
148 {0x80000, SWAP32(0x0f013106)}, /* panel display control: 32-bit RGB 8:8:8 mode */
149 {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
150 {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
151 {0x80010, SWAP32(0x0c800c80)}, /* panel fb offset/window width */
152 {0x80014, SWAP32(0x03200000)}, /* panel fb width (0x320=800) */
153 {0x80018, SWAP32(0x02580000)}, /* panel fb height (0x258=600) */
154 {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
155 {0x80020, SWAP32(0x02580320)}, /* panel plane br location */
156 {0x80024, SWAP32(0x041f031f)}, /* panel horizontal total */
157 {0x80028, SWAP32(0x00800347)}, /* panel horizontal sync */
158 {0x8002C, SWAP32(0x02730257)}, /* panel vertical total */
159 {0x80030, SWAP32(0x00040258)}, /* panel vertical sync */
160 {0x80200, SWAP32(0x00010000)}, /* crt display control */
161 {0, 0}
162};
163
164/*
165 * 1024x768 display G150XG02: PCLK = 65MHz
166 * => 2*PCLK = 130MHz
167 * 288/2 = 144MHz
168 * => PCLK = 72MHz
169 */
170static const SMI_REGS init_regs_1024x768 [] =
171{
172 {0x00004, SWAP32(0x00000000)},
173 /* clocks for pm1... */
174 {0x00048, SWAP32(0x00021807)},
175 {0x0004C, SWAP32(0x011a0a01)},
176 {0x00054, SWAP32(0x00000001)},
177 /* clocks for pm0... */
178 {0x00040, SWAP32(0x00021807)},
179 {0x00044, SWAP32(0x011a0a01)},
180 {0x00054, SWAP32(0x00000000)},
181 /* panel control regs... */
182 {0x80000, SWAP32(0x0f013106)}, /* panel display control: 32-bit RGB 8:8:8 mode */
183 {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
184 {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
185 {0x80010, SWAP32(0x10001000)}, /* panel fb offset/window width */
186 {0x80014, SWAP32(0x04000000)}, /* panel fb width (0x400=1024) */
187 {0x80018, SWAP32(0x03000000)}, /* panel fb height (0x300=768) */
188 {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
189 {0x80020, SWAP32(0x03000400)}, /* panel plane br location */
190 {0x80024, SWAP32(0x053f03ff)}, /* panel horizontal total */
191 {0x80028, SWAP32(0x0140040f)}, /* panel horizontal sync */
192 {0x8002C, SWAP32(0x032502ff)}, /* panel vertical total */
193 {0x80030, SWAP32(0x00260301)}, /* panel vertical sync */
194 {0x80200, SWAP32(0x00010000)}, /* crt display control */
195 {0, 0}
196};
197
198#endif /* CONFIG_VIDEO_SM501_32BPP */
199
200#endif /* CONFIG_VIDEO_SM501 */
stroese1f54ce62004-12-16 18:23:14 +0000201
202#if 0
203#define FPGA_DEBUG
204#endif
205
206extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
207extern void lxt971_no_sleep(void);
208
209/* fpga configuration data - gzip compressed and generated by bin2c */
210const unsigned char fpgadata[] =
211{
212#include "fpgadata.c"
213};
214
215/*
216 * include common fpga code (for esd boards)
217 */
218#include "../common/fpga.c"
219
220
221/* Prototypes */
222int gunzip(void *, int, unsigned char *, unsigned long *);
223
224
225/* logo bitmap data - gzip compressed and generated by bin2c */
226unsigned char logo_bmp_320[] =
227{
228#include "logo_320_240_4bpp.c"
229};
230
231unsigned char logo_bmp_320_8bpp[] =
232{
233#include "logo_320_240_8bpp.c"
234};
235
236unsigned char logo_bmp_640[] =
237{
238#include "logo_640_480_24bpp.c"
239};
240
241unsigned char logo_bmp_1024[] =
242{
243#include "logo_1024_768_8bpp.c"
244};
245
246
247/*
248 * include common lcd code (for esd boards)
249 */
250#include "../common/lcd.c"
251
252#include "../common/s1d13704_320_240_4bpp.h"
253#include "../common/s1d13705_320_240_8bpp.h"
254#include "../common/s1d13806_640_480_16bpp.h"
255#include "../common/s1d13806_1024_768_8bpp.h"
256
257
258/*
259 * include common auto-update code (for esd boards)
260 */
261#include "../common/auto_update.h"
262
263au_image_t au_image[] = {
264 {"hh405/preinst.img", 0, -1, AU_SCRIPT},
265 {"hh405/u-boot.img", 0xfff80000, 0x00080000, AU_FIRMWARE},
266 {"hh405/pImage_$(bd_type)", 0x00000000, 0x00100000, AU_NAND},
267 {"hh405/pImage.initrd", 0x00100000, 0x00200000, AU_NAND},
268 {"hh405/yaffsmt2.img", 0x00300000, 0x01c00000, AU_NAND},
269 {"hh405/postinst.img", 0, 0, AU_SCRIPT},
270};
271
272int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0]));
273
274
275int board_revision(void)
276{
277 unsigned long osrh_reg;
278 unsigned long isr1h_reg;
279 unsigned long tcr_reg;
280 unsigned long value;
281
282 /*
283 * Get version of HH405 board from GPIO's
284 */
285
286 /*
287 * Setup GPIO pins (BLAST/GPIO0 and GPIO9 as GPIO)
288 */
289 osrh_reg = in32(GPIO0_OSRH);
290 isr1h_reg = in32(GPIO0_ISR1H);
291 tcr_reg = in32(GPIO0_TCR);
292 out32(GPIO0_OSRH, osrh_reg & ~0xC0003000); /* output select */
293 out32(GPIO0_ISR1H, isr1h_reg | 0xC0003000); /* input select */
294 out32(GPIO0_TCR, tcr_reg & ~0x80400000); /* select input */
295
296 udelay(1000); /* wait some time before reading input */
297 value = in32(GPIO0_IR) & 0x80400000; /* get config bits */
298
299 /*
300 * Restore GPIO settings
301 */
302 out32(GPIO0_OSRH, osrh_reg); /* output select */
303 out32(GPIO0_ISR1H, isr1h_reg); /* input select */
304 out32(GPIO0_TCR, tcr_reg); /* enable output driver for outputs */
305
306 if (value & 0x80000000) {
307 /* Revision 1.0 or 1.1 detected */
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200308 return 0x0101;
stroese1f54ce62004-12-16 18:23:14 +0000309 } else {
310 if (value & 0x00400000) {
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200311 /* unused */
312 return 0x0103;
stroese1f54ce62004-12-16 18:23:14 +0000313 } else {
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200314 /* Revision >= 2.0 detected */
315 /* rev. 2.x uses four SM501 GPIOs for revision coding */
316 return 0x0200;
stroese1f54ce62004-12-16 18:23:14 +0000317 }
318 }
319}
320
321
322int board_early_init_f (void)
323{
324 /*
325 * IRQ 0-15 405GP internally generated; active high; level sensitive
326 * IRQ 16 405GP internally generated; active low; level sensitive
327 * IRQ 17-24 RESERVED
328 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
329 * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
330 * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
331 * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
332 * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
333 * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
334 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
335 */
336 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
337 mtdcr(uicer, 0x00000000); /* disable all ints */
338 mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
339 mtdcr(uicpr, CFG_UIC0_POLARITY);/* set int polarities */
340 mtdcr(uictr, 0x10000000); /* set int trigger levels */
341 mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
342 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
343
344 /*
345 * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
346 */
347 mtebc (epcr, 0xa8400000); /* ebc always driven */
348
349 return 0;
350}
351
352
353int misc_init_r (void)
354{
355 DECLARE_GLOBAL_DATA_PTR;
356
357 volatile unsigned short *fpga_ctrl =
358 (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
359 volatile unsigned short *lcd_contrast =
360 (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL + 4);
361 volatile unsigned short *lcd_backlight =
362 (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL + 6);
363 unsigned char *dst;
364 ulong len = sizeof(fpgadata);
365 int status;
366 int index;
367 int i;
368 char *str;
369 unsigned long contrast0 = 0xffffffff;
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200370 pci_dev_t devbusfn;
stroese1f54ce62004-12-16 18:23:14 +0000371
372 dst = malloc(CFG_FPGA_MAX_SIZE);
373 if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
374 printf ("GUNZIP ERROR - must RESET board to recover\n");
375 do_reset (NULL, 0, 0, NULL);
376 }
377
378 status = fpga_boot(dst, len);
379 if (status != 0) {
380 printf("\nFPGA: Booting failed ");
381 switch (status) {
382 case ERROR_FPGA_PRG_INIT_LOW:
383 printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
384 break;
385 case ERROR_FPGA_PRG_INIT_HIGH:
386 printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
387 break;
388 case ERROR_FPGA_PRG_DONE:
389 printf("(Timeout: DONE not high after programming FPGA)\n ");
390 break;
391 }
392
393 /* display infos on fpgaimage */
394 index = 15;
395 for (i=0; i<4; i++) {
396 len = dst[index];
397 printf("FPGA: %s\n", &(dst[index+1]));
398 index += len+3;
399 }
400 putc ('\n');
401 /* delayed reboot */
402 for (i=20; i>0; i--) {
403 printf("Rebooting in %2d seconds \r",i);
404 for (index=0;index<1000;index++)
405 udelay(1000);
406 }
407 putc ('\n');
408 do_reset(NULL, 0, 0, NULL);
409 }
410
411 puts("FPGA: ");
412
413 /* display infos on fpgaimage */
414 index = 15;
415 for (i=0; i<4; i++) {
416 len = dst[index];
417 printf("%s ", &(dst[index+1]));
418 index += len+3;
419 }
420 putc ('\n');
421
422 free(dst);
423
424 /*
425 * Reset FPGA via FPGA_INIT pin
426 */
427 out32(GPIO0_TCR, in32(GPIO0_TCR) | FPGA_INIT); /* setup FPGA_INIT as output */
428 out32(GPIO0_OR, in32(GPIO0_OR) & ~FPGA_INIT); /* reset low */
429 udelay(1000); /* wait 1ms */
430 out32(GPIO0_OR, in32(GPIO0_OR) | FPGA_INIT); /* reset high */
431 udelay(1000); /* wait 1ms */
432
433 /*
434 * Write Board revision into FPGA
435 */
436 *fpga_ctrl |= gd->board_type & 0x0003;
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200437 if (gd->board_type >= 0x0200) {
stroese1f54ce62004-12-16 18:23:14 +0000438 *fpga_ctrl |= CFG_FPGA_CTRL_CF_BUS_EN;
439 }
440
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200441 /*
442 * Setup and enable EEPROM write protection
443 */
444 out32(GPIO0_OR, in32(GPIO0_OR) | CFG_EEPROM_WP);
445
stroese1f54ce62004-12-16 18:23:14 +0000446 /*
447 * Set NAND-FLASH GPIO signals to default
448 */
449 out32(GPIO0_OR, in32(GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
450 out32(GPIO0_OR, in32(GPIO0_OR) | CFG_NAND_CE);
451
452 /*
453 * Reset touch-screen controller
454 */
455 out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_TOUCH_RST);
456 udelay(1000);
457 out32(GPIO0_OR, in32(GPIO0_OR) | CFG_TOUCH_RST);
458
wdenkefe2a4d2004-12-16 21:44:03 +0000459 /*
460 * Enable power on PS/2 interface (with reset)
461 */
462 *fpga_ctrl &= ~(CFG_FPGA_CTRL_PS2_PWR);
463 for (i=0;i<500;i++)
464 udelay(1000);
465 *fpga_ctrl |= (CFG_FPGA_CTRL_PS2_PWR);
stroese1f54ce62004-12-16 18:23:14 +0000466
467 /*
468 * Get contrast value from environment variable
469 */
470 str = getenv("contrast0");
471 if (str) {
472 contrast0 = simple_strtol(str, NULL, 16);
473 if (contrast0 > 255) {
474 printf("ERROR: contrast0 value too high (0x%lx)!\n", contrast0);
475 contrast0 = 0;
476 }
477 }
478
479 /*
480 * Init lcd interface and display logo
481 */
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200482
stroese1f54ce62004-12-16 18:23:14 +0000483 str = getenv("bd_type");
484 if (strcmp(str, "ppc230") == 0) {
485 /*
486 * Switch backlight on
487 */
488 *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL;
489 *lcd_backlight = 0x0000;
490
491 lcd_setup(1, 0);
492 lcd_init((uchar *)CFG_LCD_BIG_REG, (uchar *)CFG_LCD_BIG_MEM,
493 regs_13806_1024_768_8bpp,
494 sizeof(regs_13806_1024_768_8bpp)/sizeof(regs_13806_1024_768_8bpp[0]),
495 logo_bmp_1024, sizeof(logo_bmp_1024));
496 } else if (strcmp(str, "ppc220") == 0) {
497 /*
498 * Switch backlight on
499 */
500 *fpga_ctrl &= ~CFG_FPGA_CTRL_VGA0_BL;
501 *lcd_backlight = 0x0000;
502
503 lcd_setup(1, 0);
504 lcd_init((uchar *)CFG_LCD_BIG_REG, (uchar *)CFG_LCD_BIG_MEM,
505 regs_13806_640_480_16bpp,
506 sizeof(regs_13806_640_480_16bpp)/sizeof(regs_13806_640_480_16bpp[0]),
507 logo_bmp_640, sizeof(logo_bmp_640));
508 } else if (strcmp(str, "ppc215") == 0) {
509 /*
510 * Set default display contrast voltage
511 */
512 if (contrast0 == 0xffffffff) {
513 *lcd_contrast = 0x0082;
514 } else {
515 *lcd_contrast = contrast0;
516 }
517 *lcd_backlight = 0xffff;
518 /*
519 * Switch backlight on
520 */
521 *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL | CFG_FPGA_CTRL_VGA0_BL_MODE;
522 /*
523 * Set lcd clock (small epson)
524 */
525 *fpga_ctrl |= LCD_CLK_06250;
526 udelay(100); /* wait for 100 us */
527
528 lcd_setup(0, 1);
529 lcd_init((uchar *)CFG_LCD_SMALL_REG, (uchar *)CFG_LCD_SMALL_MEM,
530 regs_13705_320_240_8bpp,
531 sizeof(regs_13705_320_240_8bpp)/sizeof(regs_13705_320_240_8bpp[0]),
532 logo_bmp_320_8bpp, sizeof(logo_bmp_320_8bpp));
533 } else if (strcmp(str, "ppc210") == 0) {
534 /*
535 * Set default display contrast voltage
536 */
537 if (contrast0 == 0xffffffff) {
538 *lcd_contrast = 0x0060;
539 } else {
540 *lcd_contrast = contrast0;
541 }
542 *lcd_backlight = 0xffff;
543 /*
544 * Switch backlight on
545 */
546 *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL | CFG_FPGA_CTRL_VGA0_BL_MODE;
547 /*
548 * Set lcd clock (small epson)
549 */
550 *fpga_ctrl |= LCD_CLK_08330;
551
552 lcd_setup(0, 1);
553 lcd_init((uchar *)CFG_LCD_SMALL_REG, (uchar *)CFG_LCD_SMALL_MEM,
554 regs_13704_320_240_4bpp,
555 sizeof(regs_13704_320_240_4bpp)/sizeof(regs_13704_320_240_4bpp[0]),
556 logo_bmp_320, sizeof(logo_bmp_320));
557 } else {
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200558 /*
559 * Is SM501 connected (ppc221/ppc231)?
560 */
561 devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
562 if (devbusfn != -1) {
563 puts("VGA: SM501 with 8 MB ");
564 if (strcmp(str, "ppc221") == 0) {
565 printf("(800*600, %dbpp)\n", BPP);
566 } else if (strcmp(str, "ppc231") == 0) {
567 printf("(1024*768, %dbpp)\n", BPP);
568 } else {
569 printf("Unsupported bd_type defined (%s) -> No display configured!\n", str);
570 return 0;
571 }
572 } else {
573 printf("Unsupported bd_type defined (%s) -> No display configured!\n", str);
574 return 0;
575 }
stroese1f54ce62004-12-16 18:23:14 +0000576 }
577
578 return (0);
579}
580
581
582/*
583 * Check Board Identity:
584 */
585
586int checkboard (void)
587{
588 DECLARE_GLOBAL_DATA_PTR;
589
590 unsigned char str[64];
591 int i = getenv_r ("serial#", str, sizeof(str));
592
593 puts ("Board: ");
594
595 if (i == -1) {
596 puts ("### No HW ID - assuming HH405");
597 } else {
598 puts(str);
599 }
600
601 if (getenv_r("bd_type", str, sizeof(str)) != -1) {
602 printf(" (%s", str);
603 } else {
604 puts(" (Missing bd_type!");
605 }
606
607 gd->board_type = board_revision();
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200608 printf(", Rev %ld.%ld)\n",
609 (gd->board_type >> 8) & 0xff,
610 gd->board_type & 0xff);
stroese1f54ce62004-12-16 18:23:14 +0000611
612 /*
613 * Disable sleep mode in LXT971
614 */
615 lxt971_no_sleep();
616
617 return 0;
618}
619
stroese1f54ce62004-12-16 18:23:14 +0000620
621long int initdram (int board_type)
622{
623 unsigned long val;
624
625 mtdcr(memcfga, mem_mb0cf);
626 val = mfdcr(memcfgd);
627
628#if 0
629 printf("\nmb0cf=%x\n", val); /* test-only */
630 printf("strap=%x\n", mfdcr(strap)); /* test-only */
631#endif
632
633 return (4*1024*1024 << ((val & 0x000e0000) >> 17));
634}
635
stroese1f54ce62004-12-16 18:23:14 +0000636
637int testdram (void)
638{
639 /* TODO: XXX XXX XXX */
640 printf ("test: 16 MB - ok\n");
641
642 return (0);
643}
644
stroese1f54ce62004-12-16 18:23:14 +0000645
646#ifdef CONFIG_IDE_RESET
647void ide_set_reset(int on)
648{
649 volatile unsigned short *fpga_mode =
650 (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
651
652 /*
653 * Assert or deassert CompactFlash Reset Pin
654 */
655 if (on) { /* assert RESET */
656 *fpga_mode &= ~(CFG_FPGA_CTRL_CF_RESET);
657 } else { /* release RESET */
658 *fpga_mode |= CFG_FPGA_CTRL_CF_RESET;
659 }
660}
661#endif /* CONFIG_IDE_RESET */
662
663
664#if (CONFIG_COMMANDS & CFG_CMD_NAND)
665#include <linux/mtd/nand.h>
666extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
667
668void nand_init(void)
669{
670 nand_probe(CFG_NAND_BASE);
671 if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
672 print_size(nand_dev_desc[0].totlen, "\n");
673 }
674}
675#endif
Stefan Roese98f4a3d2005-09-22 09:04:17 +0200676
677
678#if defined(CFG_EEPROM_WREN)
679/* Input: <dev_addr> I2C address of EEPROM device to enable.
680 * <state> -1: deliver current state
681 * 0: disable write
682 * 1: enable write
683 * Returns: -1: wrong device address
684 * 0: dis-/en- able done
685 * 0/1: current state if <state> was -1.
686 */
687int eeprom_write_enable (unsigned dev_addr, int state)
688{
689 if (CFG_I2C_EEPROM_ADDR != dev_addr) {
690 return -1;
691 } else {
692 switch (state) {
693 case 1:
694 /* Enable write access, clear bit GPIO_SINT2. */
695 out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_EEPROM_WP);
696 state = 0;
697 break;
698 case 0:
699 /* Disable write access, set bit GPIO_SINT2. */
700 out32(GPIO0_OR, in32(GPIO0_OR) | CFG_EEPROM_WP);
701 state = 0;
702 break;
703 default:
704 /* Read current status back. */
705 state = (0 == (in32(GPIO0_OR) & CFG_EEPROM_WP));
706 break;
707 }
708 }
709 return state;
710}
711
712int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
713{
714 int query = argc == 1;
715 int state = 0;
716
717 if (query) {
718 /* Query write access state. */
719 state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, -1);
720 if (state < 0) {
721 puts ("Query of write access state failed.\n");
722 } else {
723 printf ("Write access for device 0x%0x is %sabled.\n",
724 CFG_I2C_EEPROM_ADDR, state ? "en" : "dis");
725 state = 0;
726 }
727 } else {
728 if ('0' == argv[1][0]) {
729 /* Disable write access. */
730 state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, 0);
731 } else {
732 /* Enable write access. */
733 state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, 1);
734 }
735 if (state < 0) {
736 puts ("Setup of write access state failed.\n");
737 }
738 }
739
740 return state;
741}
742
743U_BOOT_CMD(eepwren, 2, 0, do_eep_wren,
744 "eepwren - Enable / disable / query EEPROM write access\n",
745 NULL);
746#endif /* #if defined(CFG_EEPROM_WREN) */
747
748
749#ifdef CONFIG_VIDEO_SM501
750#ifdef CONFIG_CONSOLE_EXTRA_INFO
751/*
752 * Return text to be printed besides the logo.
753 */
754void video_get_info_str (int line_number, char *info)
755{
756 DECLARE_GLOBAL_DATA_PTR;
757
758 char str[64];
759 char str2[64];
760 int i = getenv_r("serial#", str2, sizeof(str));
761
762 if (line_number == 1) {
763 sprintf(str, " Board: ");
764
765 if (i == -1) {
766 strcat(str, "### No HW ID - assuming HH405");
767 } else {
768 strcat(str, str2);
769 }
770
771 if (getenv_r("bd_type", str2, sizeof(str2)) != -1) {
772 strcat(str, " (");
773 strcat(str, str2);
774 } else {
775 strcat(str, " (Missing bd_type!");
776 }
777
778 sprintf(str2, ", Rev %ld.%ld)",
779 (gd->board_type >> 8) & 0xff, gd->board_type & 0xff);
780 strcat(str, str2);
781 strcpy(info, str);
782 } else {
783 info [0] = '\0';
784 }
785}
786#endif /* CONFIG_CONSOLE_EXTRA_INFO */
787
788/*
789 * Returns SM501 register base address. First thing called in the driver.
790 */
791unsigned int board_video_init (void)
792{
793 pci_dev_t devbusfn;
794 u32 addr;
795
796 /*
797 * Is SM501 connected (ppc221/ppc231)?
798 */
799 devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
800 if (devbusfn != -1) {
801 pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, (u32 *)&addr);
802 return (addr & 0xfffffffe);
803 }
804
805 return 0;
806}
807
808/*
809 * Returns SM501 framebuffer address
810 */
811unsigned int board_video_get_fb (void)
812{
813 pci_dev_t devbusfn;
814 u32 addr;
815
816 /*
817 * Is SM501 connected (ppc221/ppc231)?
818 */
819 devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
820 if (devbusfn != -1) {
821 pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_0, (u32 *)&addr);
822 return (addr & 0xfffffffe);
823 }
824
825 return 0;
826}
827
828/*
829 * Called after initializing the SM501 and before clearing the screen.
830 */
831void board_validate_screen (unsigned int base)
832{
833}
834
835/*
836 * Return a pointer to the initialization sequence.
837 */
838const SMI_REGS *board_get_regs (void)
839{
840 char *str;
841
842 str = getenv("bd_type");
843 if (strcmp(str, "ppc221") == 0) {
844 return init_regs_800x600;
845 } else {
846 return init_regs_1024x768;
847 }
848}
849
850int board_get_width (void)
851{
852 char *str;
853
854 str = getenv("bd_type");
855 if (strcmp(str, "ppc221") == 0) {
856 return 800;
857 } else {
858 return 1024;
859 }
860}
861
862int board_get_height (void)
863{
864 char *str;
865
866 str = getenv("bd_type");
867 if (strcmp(str, "ppc221") == 0) {
868 return 600;
869 } else {
870 return 768;
871 }
872}
873
874#endif /* CONFIG_VIDEO_SM501 */