2 * (C) Copyright 2001-2004
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/processor.h>
14 /* ------------------------------------------------------------------------- */
20 extern void lxt971_no_sleep(void);
22 /* fpga configuration data - gzip compressed and generated by bin2c */
23 const unsigned char fpgadata[] =
29 * include common fpga code (for esd boards)
31 #include "../common/fpga.c"
34 /* logo bitmap data - gzip compressed and generated by bin2c */
35 unsigned char logo_bmp_320[] =
37 #include "logo_320_240_4bpp.c"
40 unsigned char logo_bmp_640[] =
42 #include "logo_640_480_24bpp.c"
47 * include common lcd code (for esd boards)
49 #include "../common/lcd.c"
51 #include "../common/s1d13704_320_240_4bpp.h"
52 #include "../common/s1d13806_320_240_4bpp.h"
53 #include "../common/s1d13806_640_480_16bpp.h"
56 int board_early_init_f (void)
59 * IRQ 0-15 405GP internally generated; active high; level sensitive
60 * IRQ 16 405GP internally generated; active low; level sensitive
62 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
63 * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
64 * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
65 * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
66 * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
67 * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
68 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
70 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
71 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
72 mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
73 mtdcr(UIC0PR, 0xFFFFFFB5); /* set int polarities */
74 mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
75 mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority*/
76 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
79 * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
81 mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */
86 int misc_init_r (void)
88 unsigned char *duart0_mcr = (unsigned char *)((ulong)DUART0_BA + 4);
89 unsigned char *duart1_mcr = (unsigned char *)((ulong)DUART1_BA + 4);
90 unsigned short *lcd_contrast =
91 (unsigned short *)((ulong)CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL + 4);
92 unsigned short *lcd_backlight =
93 (unsigned short *)((ulong)CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL + 6);
95 ulong len = sizeof(fpgadata);
101 dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
102 if (gunzip (dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
103 printf ("GUNZIP ERROR - must RESET board to recover\n");
104 do_reset (NULL, 0, 0, NULL);
107 status = fpga_boot(dst, len);
109 printf("\nFPGA: Booting failed ");
111 case ERROR_FPGA_PRG_INIT_LOW:
112 printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
114 case ERROR_FPGA_PRG_INIT_HIGH:
115 printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
117 case ERROR_FPGA_PRG_DONE:
118 printf("(Timeout: DONE not high after programming FPGA)\n ");
122 /* display infos on fpgaimage */
124 for (i=0; i<4; i++) {
126 printf("FPGA: %s\n", &(dst[index+1]));
131 for (i=20; i>0; i--) {
132 printf("Rebooting in %2d seconds \r",i);
133 for (index=0;index<1000;index++)
137 do_reset(NULL, 0, 0, NULL);
142 /* display infos on fpgaimage */
144 for (i=0; i<4; i++) {
146 printf("%s ", &(dst[index+1]));
154 * Reset FPGA via FPGA_INIT pin
156 out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) | FPGA_INIT); /* setup FPGA_INIT as output */
157 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~FPGA_INIT); /* reset low */
158 udelay(1000); /* wait 1ms */
159 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | FPGA_INIT); /* reset high */
160 udelay(1000); /* wait 1ms */
163 * Reset external DUARTs
165 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CONFIG_SYS_DUART_RST); /* set reset to high */
166 udelay(10); /* wait 10us */
167 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~CONFIG_SYS_DUART_RST); /* set reset to low */
168 udelay(1000); /* wait 1ms */
171 * Set NAND-FLASH GPIO signals to default
173 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~(CONFIG_SYS_NAND_CLE | CONFIG_SYS_NAND_ALE));
174 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CONFIG_SYS_NAND_CE);
177 * Setup EEPROM write protection
179 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
180 out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) | CONFIG_SYS_EEPROM_WP);
183 * Enable interrupts in exar duart mcr[3]
185 out_8(duart0_mcr, 0x08);
186 out_8(duart1_mcr, 0x08);
189 * Init lcd interface and display logo
191 str = getenv("bd_type");
192 if (strcmp(str, "voh405_bw") == 0) {
194 lcd_init((uchar *)CONFIG_SYS_LCD_SMALL_REG, (uchar *)CONFIG_SYS_LCD_SMALL_MEM,
195 regs_13704_320_240_4bpp,
196 sizeof(regs_13704_320_240_4bpp)/sizeof(regs_13704_320_240_4bpp[0]),
197 logo_bmp_320, sizeof(logo_bmp_320));
198 } else if (strcmp(str, "voh405_bwbw") == 0) {
200 lcd_init((uchar *)CONFIG_SYS_LCD_SMALL_REG, (uchar *)CONFIG_SYS_LCD_SMALL_MEM,
201 regs_13704_320_240_4bpp,
202 sizeof(regs_13704_320_240_4bpp)/sizeof(regs_13704_320_240_4bpp[0]),
203 logo_bmp_320, sizeof(logo_bmp_320));
205 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG, (uchar *)CONFIG_SYS_LCD_BIG_MEM,
206 regs_13806_320_240_4bpp,
207 sizeof(regs_13806_320_240_4bpp)/sizeof(regs_13806_320_240_4bpp[0]),
208 logo_bmp_320, sizeof(logo_bmp_320));
209 } else if (strcmp(str, "voh405_bwc") == 0) {
211 lcd_init((uchar *)CONFIG_SYS_LCD_SMALL_REG, (uchar *)CONFIG_SYS_LCD_SMALL_MEM,
212 regs_13704_320_240_4bpp,
213 sizeof(regs_13704_320_240_4bpp)/sizeof(regs_13704_320_240_4bpp[0]),
214 logo_bmp_320, sizeof(logo_bmp_320));
216 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG, (uchar *)CONFIG_SYS_LCD_BIG_MEM,
217 regs_13806_640_480_16bpp,
218 sizeof(regs_13806_640_480_16bpp)/sizeof(regs_13806_640_480_16bpp[0]),
219 logo_bmp_640, sizeof(logo_bmp_640));
221 printf("Unsupported bd_type defined (%s) -> No display configured!\n", str);
226 * Set invert bit in small lcd controller
228 out_8((unsigned char *)(CONFIG_SYS_LCD_SMALL_REG + 2),
229 in_8((unsigned char *)(CONFIG_SYS_LCD_SMALL_REG + 2)) | 0x01);
232 * Set default contrast voltage on epson vga controller
234 out_be16(lcd_contrast, 0x4646);
239 out_be16(lcd_backlight, 0xffff);
242 * Enable external I2C bus
244 out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) | CONFIG_SYS_IIC_ON);
251 * Check Board Identity:
254 int checkboard (void)
257 int i = getenv_f("serial#", str, sizeof(str));
262 puts ("### No HW ID - assuming VOH405");
267 if (getenv_f("bd_type", str, sizeof(str)) != -1) {
268 printf(" (%s)", str);
270 puts(" (Missing bd_type!)");
278 #ifdef CONFIG_IDE_RESET
279 #define FPGA_MODE (CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL)
280 void ide_set_reset(int on)
283 * Assert or deassert CompactFlash Reset Pin
285 if (on) { /* assert RESET */
286 out_be16((void *)FPGA_MODE,
287 in_be16((void *)FPGA_MODE) & ~CONFIG_SYS_FPGA_CTRL_CF_RESET);
288 } else { /* release RESET */
289 out_be16((void *)FPGA_MODE,
290 in_be16((void *)FPGA_MODE) | CONFIG_SYS_FPGA_CTRL_CF_RESET);
293 #endif /* CONFIG_IDE_RESET */
295 #if defined(CONFIG_RESET_PHY_R)
298 #ifdef CONFIG_LXT971_NO_SLEEP
301 * Disable sleep mode in LXT971
308 #if defined(CONFIG_SYS_EEPROM_WREN)
309 /* Input: <dev_addr> I2C address of EEPROM device to enable.
310 * <state> -1: deliver current state
313 * Returns: -1: wrong device address
314 * 0: dis-/en- able done
315 * 0/1: current state if <state> was -1.
317 int eeprom_write_enable (unsigned dev_addr, int state)
319 if (CONFIG_SYS_I2C_EEPROM_ADDR != dev_addr) {
324 /* Enable write access, clear bit GPIO0. */
325 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~CONFIG_SYS_EEPROM_WP);
329 /* Disable write access, set bit GPIO0. */
330 out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
334 /* Read current status back. */
335 state = (0 == (in_be32((void*)GPIO0_OR) & CONFIG_SYS_EEPROM_WP));
342 int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
344 int query = argc == 1;
348 /* Query write access state. */
349 state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, -1);
351 puts ("Query of write access state failed.\n");
353 printf ("Write access for device 0x%0x is %sabled.\n",
354 CONFIG_SYS_I2C_EEPROM_ADDR, state ? "en" : "dis");
358 if ('0' == argv[1][0]) {
359 /* Disable write access. */
360 state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 0);
362 /* Enable write access. */
363 state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 1);
366 puts ("Setup of write access state failed.\n");
373 U_BOOT_CMD(eepwren, 2, 0, do_eep_wren,
374 "Enable / disable / query EEPROM write access",
377 #endif /* #if defined(CONFIG_SYS_EEPROM_WREN) */