blob: f13f088d5515e67b618f743070933f2691caea2b [file] [log] [blame]
stroese1bc0f142004-12-16 18:20:14 +00001/*
Matthias Fuchs0b987252008-04-21 14:42:11 +02002 * (C) Copyright 2005-2008
3 * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
4 *
stroese1bc0f142004-12-16 18:20:14 +00005 * (C) Copyright 2001-2003
6 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
stroese1bc0f142004-12-16 18:20:14 +00009 */
10
11#include <common.h>
12#include <asm/processor.h>
Matthias Fuchs0b987252008-04-21 14:42:11 +020013#include <asm/io.h>
stroese1bc0f142004-12-16 18:20:14 +000014#include <command.h>
15#include <malloc.h>
Matthias Fuchs0b987252008-04-21 14:42:11 +020016#include <flash.h>
Stefan Roeseca5def32010-08-31 10:00:10 +020017#include <mtd/cfi_flash.h>
Matthias Fuchs0b987252008-04-21 14:42:11 +020018#include <asm/4xx_pci.h>
19#include <pci.h>
stroese1bc0f142004-12-16 18:20:14 +000020
Wolfgang Denkd87080b2006-03-31 18:32:53 +020021DECLARE_GLOBAL_DATA_PTR;
stroese1bc0f142004-12-16 18:20:14 +000022
Matthias Fuchs0b987252008-04-21 14:42:11 +020023#undef FPGA_DEBUG
stroese1bc0f142004-12-16 18:20:14 +000024
stroese1bc0f142004-12-16 18:20:14 +000025extern void lxt971_no_sleep(void);
26
27/* fpga configuration data - gzip compressed and generated by bin2c */
28const unsigned char fpgadata[] =
29{
30#include "fpgadata.c"
31};
32
33/*
34 * include common fpga code (for esd boards)
35 */
36#include "../common/fpga.c"
37
stroese1bc0f142004-12-16 18:20:14 +000038#ifdef CONFIG_LCD_USED
39/* logo bitmap data - gzip compressed and generated by bin2c */
40unsigned char logo_bmp[] =
41{
Matthias Fuchs0b987252008-04-21 14:42:11 +020042#include "logo_640_480_24bpp.c"
stroese1bc0f142004-12-16 18:20:14 +000043};
44
45/*
46 * include common lcd code (for esd boards)
47 */
48#include "../common/lcd.c"
Matthias Fuchs0b987252008-04-21 14:42:11 +020049#include "../common/s1d13505_640_480_16bpp.h"
50#include "../common/s1d13806_640_480_16bpp.h"
stroese1bc0f142004-12-16 18:20:14 +000051#endif /* CONFIG_LCD_USED */
52
Matthias Fuchs0b987252008-04-21 14:42:11 +020053/*
54 * include common auto-update code (for esd boards)
55 */
56#include "../common/auto_update.h"
57
58au_image_t au_image[] = {
59 {"preinst.img", 0, -1, AU_SCRIPT},
60 {"u-boot.img", 0xfff80000, 0x00080000, AU_FIRMWARE | AU_PROTECT},
61 {"pImage", 0xfe000000, 0x00100000, AU_NOR | AU_PROTECT},
62 {"pImage.initrd", 0xfe100000, 0x00400000, AU_NOR | AU_PROTECT},
63 {"work.img", 0xfe500000, 0x01400000, AU_NOR},
64 {"data.img", 0xff900000, 0x00580000, AU_NOR},
65 {"logo.img", 0xffe80000, 0x00100000, AU_NOR | AU_PROTECT},
66 {"postinst.img", 0, 0, AU_SCRIPT},
67};
68
69int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0]));
stroese1bc0f142004-12-16 18:20:14 +000070
stroese04e93ec2005-04-13 10:06:07 +000071int board_revision(void)
72{
Stefan Roesed1c3b272009-09-09 16:25:29 +020073 unsigned long CPC0_CR0Reg;
Matthias Fuchs049216f2009-02-20 10:19:18 +010074 unsigned long value;
stroese04e93ec2005-04-13 10:06:07 +000075
76 /*
77 * Get version of APC405 board from GPIO's
78 */
79
Matthias Fuchs0b987252008-04-21 14:42:11 +020080 /* Setup GPIO pins (CS2/GPIO11, CS3/GPIO12 and CS4/GPIO13 as GPIO) */
Stefan Roesed1c3b272009-09-09 16:25:29 +020081 CPC0_CR0Reg = mfdcr(CPC0_CR0);
82 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x03800000);
Matthias Fuchs0b987252008-04-21 14:42:11 +020083 out_be32((void*)GPIO0_ODR, in_be32((void*)GPIO0_ODR) & ~0x001c0000);
84 out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) & ~0x001c0000);
stroese04e93ec2005-04-13 10:06:07 +000085
Matthias Fuchs0b987252008-04-21 14:42:11 +020086 /* wait some time before reading input */
87 udelay(1000);
88
89 /* get config bits */
90 value = in_be32((void*)GPIO0_IR) & 0x001c0000;
stroese04e93ec2005-04-13 10:06:07 +000091 /*
92 * Restore GPIO settings
93 */
Stefan Roesed1c3b272009-09-09 16:25:29 +020094 mtdcr(CPC0_CR0, CPC0_CR0Reg);
stroese04e93ec2005-04-13 10:06:07 +000095
96 switch (value) {
Matthias Fuchs0b987252008-04-21 14:42:11 +020097 case 0x001c0000:
98 /* CS2==1 && CS3==1 && CS4==1 -> version <= 1.2 */
stroese04e93ec2005-04-13 10:06:07 +000099 return 2;
Matthias Fuchs0b987252008-04-21 14:42:11 +0200100 case 0x000c0000:
101 /* CS2==0 && CS3==1 && CS4==1 -> version 1.3 */
stroese04e93ec2005-04-13 10:06:07 +0000102 return 3;
Matthias Fuchs0b987252008-04-21 14:42:11 +0200103 case 0x00180000:
104 /* CS2==1 && CS3==1 && CS4==0 -> version 1.6 */
105 return 6;
106 case 0x00140000:
107 /* CS2==1 && CS3==0 && CS4==1 -> version 1.8 */
108 return 8;
stroese04e93ec2005-04-13 10:06:07 +0000109 default:
110 /* should not be reached! */
111 return 0;
112 }
113}
114
stroese1bc0f142004-12-16 18:20:14 +0000115int board_early_init_f (void)
116{
117 /*
Matthias Fuchs0b987252008-04-21 14:42:11 +0200118 * First pull fpga-prg pin low, to disable fpga logic
stroese1bc0f142004-12-16 18:20:14 +0000119 */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200120 out_be32((void*)GPIO0_ODR, 0x00000000); /* no open drain pins */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200121 out_be32((void*)GPIO0_TCR, CONFIG_SYS_FPGA_PRG); /* setup for output */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200122 out_be32((void*)GPIO0_OR, 0); /* pull prg low */
stroese1bc0f142004-12-16 18:20:14 +0000123
124 /*
125 * IRQ 0-15 405GP internally generated; active high; level sensitive
126 * IRQ 16 405GP internally generated; active low; level sensitive
127 * IRQ 17-24 RESERVED
128 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
129 * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
130 * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
131 * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
132 * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
133 * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
134 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
135 */
Stefan Roese952e7762009-09-24 09:55:50 +0200136 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
137 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
138 mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
139 mtdcr(UIC0PR, 0xFFFFFF81); /* set int polarities */
140 mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
141 mtdcr(UIC0VCR, 0x00000001); /* set vect base=0 */
142 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
stroese1bc0f142004-12-16 18:20:14 +0000143
144 /*
Matthias Fuchs0b987252008-04-21 14:42:11 +0200145 * EBC Configuration Register: set ready timeout to 512 ebc-clks
stroese1bc0f142004-12-16 18:20:14 +0000146 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200147 mtebc(EBC0_CFG, 0xa8400000); /* ebc always driven */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200148
149 /*
150 * New boards have a single 32MB flash connected to CS0
151 * instead of two 16MB flashes on CS0+1.
152 */
153 if (board_revision() >= 8) {
154 /* disable CS1 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200155 mtebc(PB1AP, 0);
156 mtebc(PB1CR, 0);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200157
158 /* resize CS0 to 32MB */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200159 mtebc(PB0AP, CONFIG_SYS_EBC_PB0AP_HWREV8);
160 mtebc(PB0CR, CONFIG_SYS_EBC_PB0CR_HWREV8);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200161 }
stroese1bc0f142004-12-16 18:20:14 +0000162
163 return 0;
164}
165
Matthias Fuchs0b987252008-04-21 14:42:11 +0200166int board_early_init_r(void)
stroese1bc0f142004-12-16 18:20:14 +0000167{
Matthias Fuchs0b987252008-04-21 14:42:11 +0200168 if (gd->board_type >= 8)
Stefan Roeseca5def32010-08-31 10:00:10 +0200169 cfi_flash_num_flash_banks = 1;
Matthias Fuchs0b987252008-04-21 14:42:11 +0200170
171 return 0;
stroese1bc0f142004-12-16 18:20:14 +0000172}
173
Matthias Fuchs0b987252008-04-21 14:42:11 +0200174#define FUJI_BASE 0xf0100200
175#define LCDBL_PWM 0xa0
176#define LCDBL_PWMMIN 0xa4
177#define LCDBL_PWMMAX 0xa8
stroese1bc0f142004-12-16 18:20:14 +0000178
Matthias Fuchs0b987252008-04-21 14:42:11 +0200179int misc_init_r(void)
stroese1bc0f142004-12-16 18:20:14 +0000180{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200181 u16 *fpga_mode = (u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL);
182 u16 *fpga_ctrl2 =(u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL2);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200183 u8 *duart0_mcr = (u8 *)(DUART0_BA + 4);
184 u8 *duart1_mcr = (u8 *)(DUART1_BA + 4);
stroese1bc0f142004-12-16 18:20:14 +0000185 unsigned char *dst;
186 ulong len = sizeof(fpgadata);
187 int status;
188 int index;
189 int i;
Stefan Roesed1c3b272009-09-09 16:25:29 +0200190 unsigned long CPC0_CR0Reg;
Matthias Fuchs0b987252008-04-21 14:42:11 +0200191 char *str;
192 uchar *logo_addr;
193 ulong logo_size;
194 ushort minb, maxb;
195 int result;
stroese1bc0f142004-12-16 18:20:14 +0000196
197 /*
198 * Setup GPIO pins (CS6+CS7 as GPIO)
199 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200200 CPC0_CR0Reg = mfdcr(CPC0_CR0);
201 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00300000);
stroese1bc0f142004-12-16 18:20:14 +0000202
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200203 dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
204 if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
Matthias Fuchs0b987252008-04-21 14:42:11 +0200205 printf("GUNZIP ERROR - must RESET board to recover\n");
206 do_reset(NULL, 0, 0, NULL);
stroese1bc0f142004-12-16 18:20:14 +0000207 }
208
209 status = fpga_boot(dst, len);
210 if (status != 0) {
211 printf("\nFPGA: Booting failed ");
212 switch (status) {
213 case ERROR_FPGA_PRG_INIT_LOW:
Matthias Fuchs0b987252008-04-21 14:42:11 +0200214 printf("(Timeout: "
215 "INIT not low after asserting PROGRAM*)\n ");
stroese1bc0f142004-12-16 18:20:14 +0000216 break;
217 case ERROR_FPGA_PRG_INIT_HIGH:
Matthias Fuchs0b987252008-04-21 14:42:11 +0200218 printf("(Timeout: "
219 "INIT not high after deasserting PROGRAM*)\n ");
stroese1bc0f142004-12-16 18:20:14 +0000220 break;
221 case ERROR_FPGA_PRG_DONE:
Matthias Fuchs0b987252008-04-21 14:42:11 +0200222 printf("(Timeout: "
223 "DONE not high after programming FPGA)\n ");
stroese1bc0f142004-12-16 18:20:14 +0000224 break;
225 }
226
227 /* display infos on fpgaimage */
228 index = 15;
Matthias Fuchs0b987252008-04-21 14:42:11 +0200229 for (i = 0; i < 4; i++) {
stroese1bc0f142004-12-16 18:20:14 +0000230 len = dst[index];
231 printf("FPGA: %s\n", &(dst[index+1]));
Matthias Fuchs0b987252008-04-21 14:42:11 +0200232 index += len + 3;
stroese1bc0f142004-12-16 18:20:14 +0000233 }
Matthias Fuchs0b987252008-04-21 14:42:11 +0200234 putc('\n');
stroese1bc0f142004-12-16 18:20:14 +0000235 /* delayed reboot */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200236 for (i = 20; i > 0; i--) {
stroese1bc0f142004-12-16 18:20:14 +0000237 printf("Rebooting in %2d seconds \r",i);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200238 for (index = 0; index < 1000; index++)
stroese1bc0f142004-12-16 18:20:14 +0000239 udelay(1000);
240 }
Matthias Fuchs0b987252008-04-21 14:42:11 +0200241 putc('\n');
stroese1bc0f142004-12-16 18:20:14 +0000242 do_reset(NULL, 0, 0, NULL);
243 }
244
245 /* restore gpio/cs settings */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200246 mtdcr(CPC0_CR0, CPC0_CR0Reg);
stroese1bc0f142004-12-16 18:20:14 +0000247
248 puts("FPGA: ");
249
250 /* display infos on fpgaimage */
251 index = 15;
Matthias Fuchs0b987252008-04-21 14:42:11 +0200252 for (i = 0; i < 4; i++) {
stroese1bc0f142004-12-16 18:20:14 +0000253 len = dst[index];
Matthias Fuchs0b987252008-04-21 14:42:11 +0200254 printf("%s ", &(dst[index + 1]));
255 index += len + 3;
stroese1bc0f142004-12-16 18:20:14 +0000256 }
Matthias Fuchs0b987252008-04-21 14:42:11 +0200257 putc('\n');
stroese1bc0f142004-12-16 18:20:14 +0000258
259 free(dst);
260
261 /*
262 * Reset FPGA via FPGA_DATA pin
263 */
264 SET_FPGA(FPGA_PRG | FPGA_CLK);
265 udelay(1000); /* wait 1ms */
266 SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
267 udelay(1000); /* wait 1ms */
268
269 /*
stroese04e93ec2005-04-13 10:06:07 +0000270 * Write board revision in FPGA
271 */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200272 out_be16(fpga_ctrl2,
273 (in_be16(fpga_ctrl2) & 0xfff0) | (gd->board_type & 0x000f));
stroese04e93ec2005-04-13 10:06:07 +0000274
275 /*
stroese1bc0f142004-12-16 18:20:14 +0000276 * Enable power on PS/2 interface (with reset)
277 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200278 out_be16(fpga_mode, in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_PS2_RESET);
stroese1bc0f142004-12-16 18:20:14 +0000279 for (i=0;i<100;i++)
280 udelay(1000);
281 udelay(1000);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200282 out_be16(fpga_mode, in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_PS2_RESET);
stroese1bc0f142004-12-16 18:20:14 +0000283
284 /*
285 * Enable interrupts in exar duart mcr[3]
286 */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200287 out_8(duart0_mcr, 0x08);
288 out_8(duart1_mcr, 0x08);
stroese1bc0f142004-12-16 18:20:14 +0000289
290 /*
291 * Init lcd interface and display logo
292 */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200293 str = getenv("splashimage");
294 if (str) {
295 logo_addr = (uchar *)simple_strtoul(str, NULL, 16);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200296 logo_size = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
Matthias Fuchs0b987252008-04-21 14:42:11 +0200297 } else {
298 logo_addr = logo_bmp;
299 logo_size = sizeof(logo_bmp);
300 }
301
302 if (gd->board_type >= 6) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200303 result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
304 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs0b987252008-04-21 14:42:11 +0200305 regs_13505_640_480_16bpp,
306 sizeof(regs_13505_640_480_16bpp) /
307 sizeof(regs_13505_640_480_16bpp[0]),
308 logo_addr, logo_size);
309 if (result && str) {
310 /* retry with internal image */
311 logo_addr = logo_bmp;
312 logo_size = sizeof(logo_bmp);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200313 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
314 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs0b987252008-04-21 14:42:11 +0200315 regs_13505_640_480_16bpp,
316 sizeof(regs_13505_640_480_16bpp) /
317 sizeof(regs_13505_640_480_16bpp[0]),
318 logo_addr, logo_size);
319 }
320 } else {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200321 result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
322 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs0b987252008-04-21 14:42:11 +0200323 regs_13806_640_480_16bpp,
324 sizeof(regs_13806_640_480_16bpp) /
325 sizeof(regs_13806_640_480_16bpp[0]),
326 logo_addr, logo_size);
327 if (result && str) {
328 /* retry with internal image */
329 logo_addr = logo_bmp;
330 logo_size = sizeof(logo_bmp);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200331 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
332 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs0b987252008-04-21 14:42:11 +0200333 regs_13806_640_480_16bpp,
334 sizeof(regs_13806_640_480_16bpp) /
335 sizeof(regs_13806_640_480_16bpp[0]),
336 logo_addr, logo_size);
337 }
338 }
stroese1bc0f142004-12-16 18:20:14 +0000339
340 /*
stroese04e93ec2005-04-13 10:06:07 +0000341 * Reset microcontroller and setup backlight PWM controller
stroese1bc0f142004-12-16 18:20:14 +0000342 */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200343 out_be16(fpga_mode, in_be16(fpga_mode) | 0x0014);
stroese04e93ec2005-04-13 10:06:07 +0000344 for (i=0;i<10;i++)
345 udelay(1000);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200346 out_be16(fpga_mode, in_be16(fpga_mode) | 0x001c);
347
348 minb = 0;
349 maxb = 0xff;
350 str = getenv("lcdbl");
351 if (str) {
352 minb = (ushort)simple_strtoul(str, &str, 16) & 0x00ff;
353 if (str && (*str=',')) {
354 str++;
355 maxb = (ushort)simple_strtoul(str, NULL, 16) & 0x00ff;
356 } else
357 minb = 0;
358
359 out_be16((u16 *)(FUJI_BASE + LCDBL_PWMMIN), minb);
360 out_be16((u16 *)(FUJI_BASE + LCDBL_PWMMAX), maxb);
361
362 printf("LCDBL: min=0x%02x, max=0x%02x\n", minb, maxb);
363 }
364 out_be16((u16 *)(FUJI_BASE + LCDBL_PWM), 0xff);
365
Matthias Fuchs8e048c42008-04-25 12:01:39 +0200366 /*
367 * fix environment for field updated units
368 */
369 if (getenv("altbootcmd") == NULL) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200370 setenv("usb_load", CONFIG_SYS_USB_LOAD_COMMAND);
371 setenv("usbargs", CONFIG_SYS_USB_ARGS);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200372 setenv("bootcmd", CONFIG_BOOTCOMMAND);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200373 setenv("usb_self", CONFIG_SYS_USB_SELF_COMMAND);
374 setenv("bootlimit", CONFIG_SYS_BOOTLIMIT);
375 setenv("altbootcmd", CONFIG_SYS_ALT_BOOTCOMMAND);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200376 saveenv();
377 }
stroese1bc0f142004-12-16 18:20:14 +0000378
379 return (0);
380}
381
stroese1bc0f142004-12-16 18:20:14 +0000382/*
383 * Check Board Identity:
384 */
stroese1bc0f142004-12-16 18:20:14 +0000385int checkboard (void)
386{
Matthias Fuchs0b987252008-04-21 14:42:11 +0200387 char str[64];
Wolfgang Denkcdb74972010-07-24 21:55:43 +0200388 int i = getenv_f("serial#", str, sizeof(str));
stroese1bc0f142004-12-16 18:20:14 +0000389
390 puts ("Board: ");
391
392 if (i == -1) {
393 puts ("### No HW ID - assuming APC405");
394 } else {
395 puts(str);
396 }
397
stroese04e93ec2005-04-13 10:06:07 +0000398 gd->board_type = board_revision();
Matthias Fuchs0b987252008-04-21 14:42:11 +0200399 printf(", Rev. 1.%ld\n", gd->board_type);
stroese1bc0f142004-12-16 18:20:14 +0000400
401 return 0;
402}
403
stroese1bc0f142004-12-16 18:20:14 +0000404#ifdef CONFIG_IDE_RESET
stroese1bc0f142004-12-16 18:20:14 +0000405void ide_set_reset(int on)
406{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200407 u16 *fpga_mode = (u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL);
stroese1bc0f142004-12-16 18:20:14 +0000408
409 /*
410 * Assert or deassert CompactFlash Reset Pin
411 */
Matthias Fuchs0b987252008-04-21 14:42:11 +0200412 if (on) {
413 out_be16(fpga_mode,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200414 in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_CF_RESET);
Matthias Fuchs0b987252008-04-21 14:42:11 +0200415 } else {
416 out_be16(fpga_mode,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200417 in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_CF_RESET);
stroese1bc0f142004-12-16 18:20:14 +0000418 }
419}
stroese1bc0f142004-12-16 18:20:14 +0000420#endif /* CONFIG_IDE_RESET */
421
Matthias Fuchs0b987252008-04-21 14:42:11 +0200422void reset_phy(void)
423{
424 /*
425 * Disable sleep mode in LXT971
426 */
427 lxt971_no_sleep();
428}
429
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200430#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT)
Matthias Fuchs0b987252008-04-21 14:42:11 +0200431int usb_board_init(void)
432{
433 return 0;
434}
435
436int usb_board_stop(void)
437{
438 unsigned short tmp;
439 int i;
440
441 /*
442 * reset PCI bus
443 * This is required to make some very old Linux OHCI driver
444 * work after U-Boot has used the OHCI controller.
445 */
446 pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &tmp);
447 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (tmp | 0x1000));
448
449 for (i = 0; i < 100; i++)
450 udelay(1000);
451
452 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, tmp);
453 return 0;
454}
455
456int usb_board_init_fail(void)
457{
458 usb_board_stop();
459 return 0;
460}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200461#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */