blob: 52477d72c1f30a72cc445aad36d4d6f7402c1725 [file] [log] [blame]
stroese27a0ddc2004-12-16 18:20:14 +00001/*
Matthias Fuchs814f5372008-04-21 14:42:11 +02002 * (C) Copyright 2005-2008
3 * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
4 *
stroese27a0ddc2004-12-16 18:20:14 +00005 * (C) Copyright 2001-2003
6 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
7 *
8 * 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>
Matthias Fuchs814f5372008-04-21 14:42:11 +020029#include <asm/io.h>
stroese27a0ddc2004-12-16 18:20:14 +000030#include <command.h>
31#include <malloc.h>
Matthias Fuchs814f5372008-04-21 14:42:11 +020032#include <flash.h>
Stefan Roesefb9a7302010-08-31 10:00:10 +020033#include <mtd/cfi_flash.h>
Matthias Fuchs814f5372008-04-21 14:42:11 +020034#include <asm/4xx_pci.h>
35#include <pci.h>
stroese27a0ddc2004-12-16 18:20:14 +000036
Wolfgang Denk6405a152006-03-31 18:32:53 +020037DECLARE_GLOBAL_DATA_PTR;
stroese27a0ddc2004-12-16 18:20:14 +000038
Matthias Fuchs814f5372008-04-21 14:42:11 +020039#undef FPGA_DEBUG
stroese27a0ddc2004-12-16 18:20:14 +000040
Wolfgang Denk6262d0212010-06-28 22:00:46 +020041extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
stroese27a0ddc2004-12-16 18:20:14 +000042extern void lxt971_no_sleep(void);
43
44/* fpga configuration data - gzip compressed and generated by bin2c */
45const unsigned char fpgadata[] =
46{
47#include "fpgadata.c"
48};
49
50/*
51 * include common fpga code (for esd boards)
52 */
53#include "../common/fpga.c"
54
stroese27a0ddc2004-12-16 18:20:14 +000055#ifdef CONFIG_LCD_USED
56/* logo bitmap data - gzip compressed and generated by bin2c */
57unsigned char logo_bmp[] =
58{
Matthias Fuchs814f5372008-04-21 14:42:11 +020059#include "logo_640_480_24bpp.c"
stroese27a0ddc2004-12-16 18:20:14 +000060};
61
62/*
63 * include common lcd code (for esd boards)
64 */
65#include "../common/lcd.c"
Matthias Fuchs814f5372008-04-21 14:42:11 +020066#include "../common/s1d13505_640_480_16bpp.h"
67#include "../common/s1d13806_640_480_16bpp.h"
stroese27a0ddc2004-12-16 18:20:14 +000068#endif /* CONFIG_LCD_USED */
69
Matthias Fuchs814f5372008-04-21 14:42:11 +020070/*
71 * include common auto-update code (for esd boards)
72 */
73#include "../common/auto_update.h"
74
75au_image_t au_image[] = {
76 {"preinst.img", 0, -1, AU_SCRIPT},
77 {"u-boot.img", 0xfff80000, 0x00080000, AU_FIRMWARE | AU_PROTECT},
78 {"pImage", 0xfe000000, 0x00100000, AU_NOR | AU_PROTECT},
79 {"pImage.initrd", 0xfe100000, 0x00400000, AU_NOR | AU_PROTECT},
80 {"work.img", 0xfe500000, 0x01400000, AU_NOR},
81 {"data.img", 0xff900000, 0x00580000, AU_NOR},
82 {"logo.img", 0xffe80000, 0x00100000, AU_NOR | AU_PROTECT},
83 {"postinst.img", 0, 0, AU_SCRIPT},
84};
85
86int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0]));
stroese27a0ddc2004-12-16 18:20:14 +000087
stroese63268872005-04-13 10:06:07 +000088int board_revision(void)
89{
Stefan Roese918010a2009-09-09 16:25:29 +020090 unsigned long CPC0_CR0Reg;
Matthias Fuchsfaac7432009-02-20 10:19:18 +010091 unsigned long value;
stroese63268872005-04-13 10:06:07 +000092
93 /*
94 * Get version of APC405 board from GPIO's
95 */
96
Matthias Fuchs814f5372008-04-21 14:42:11 +020097 /* Setup GPIO pins (CS2/GPIO11, CS3/GPIO12 and CS4/GPIO13 as GPIO) */
Stefan Roese918010a2009-09-09 16:25:29 +020098 CPC0_CR0Reg = mfdcr(CPC0_CR0);
99 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x03800000);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200100 out_be32((void*)GPIO0_ODR, in_be32((void*)GPIO0_ODR) & ~0x001c0000);
101 out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) & ~0x001c0000);
102
103 /* wait some time before reading input */
104 udelay(1000);
stroese63268872005-04-13 10:06:07 +0000105
Matthias Fuchs814f5372008-04-21 14:42:11 +0200106 /* get config bits */
107 value = in_be32((void*)GPIO0_IR) & 0x001c0000;
stroese63268872005-04-13 10:06:07 +0000108 /*
109 * Restore GPIO settings
110 */
Stefan Roese918010a2009-09-09 16:25:29 +0200111 mtdcr(CPC0_CR0, CPC0_CR0Reg);
stroese63268872005-04-13 10:06:07 +0000112
113 switch (value) {
Matthias Fuchs814f5372008-04-21 14:42:11 +0200114 case 0x001c0000:
115 /* CS2==1 && CS3==1 && CS4==1 -> version <= 1.2 */
stroese63268872005-04-13 10:06:07 +0000116 return 2;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200117 case 0x000c0000:
118 /* CS2==0 && CS3==1 && CS4==1 -> version 1.3 */
stroese63268872005-04-13 10:06:07 +0000119 return 3;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200120 case 0x00180000:
121 /* CS2==1 && CS3==1 && CS4==0 -> version 1.6 */
122 return 6;
123 case 0x00140000:
124 /* CS2==1 && CS3==0 && CS4==1 -> version 1.8 */
125 return 8;
stroese63268872005-04-13 10:06:07 +0000126 default:
127 /* should not be reached! */
128 return 0;
129 }
130}
131
stroese27a0ddc2004-12-16 18:20:14 +0000132int board_early_init_f (void)
133{
134 /*
Matthias Fuchs814f5372008-04-21 14:42:11 +0200135 * First pull fpga-prg pin low, to disable fpga logic
stroese27a0ddc2004-12-16 18:20:14 +0000136 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200137 out_be32((void*)GPIO0_ODR, 0x00000000); /* no open drain pins */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200138 out_be32((void*)GPIO0_TCR, CONFIG_SYS_FPGA_PRG); /* setup for output */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200139 out_be32((void*)GPIO0_OR, 0); /* pull prg low */
stroese27a0ddc2004-12-16 18:20:14 +0000140
141 /*
142 * IRQ 0-15 405GP internally generated; active high; level sensitive
143 * IRQ 16 405GP internally generated; active low; level sensitive
144 * IRQ 17-24 RESERVED
145 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
146 * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
147 * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
148 * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
149 * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
150 * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
151 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
152 */
Stefan Roese707fd362009-09-24 09:55:50 +0200153 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
154 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
155 mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
156 mtdcr(UIC0PR, 0xFFFFFF81); /* set int polarities */
157 mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
158 mtdcr(UIC0VCR, 0x00000001); /* set vect base=0 */
159 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
stroese27a0ddc2004-12-16 18:20:14 +0000160
161 /*
Matthias Fuchs814f5372008-04-21 14:42:11 +0200162 * EBC Configuration Register: set ready timeout to 512 ebc-clks
stroese27a0ddc2004-12-16 18:20:14 +0000163 */
Stefan Roese918010a2009-09-09 16:25:29 +0200164 mtebc(EBC0_CFG, 0xa8400000); /* ebc always driven */
stroese27a0ddc2004-12-16 18:20:14 +0000165
Matthias Fuchs814f5372008-04-21 14:42:11 +0200166 /*
167 * New boards have a single 32MB flash connected to CS0
168 * instead of two 16MB flashes on CS0+1.
169 */
170 if (board_revision() >= 8) {
171 /* disable CS1 */
Stefan Roese918010a2009-09-09 16:25:29 +0200172 mtebc(PB1AP, 0);
173 mtebc(PB1CR, 0);
stroese27a0ddc2004-12-16 18:20:14 +0000174
Matthias Fuchs814f5372008-04-21 14:42:11 +0200175 /* resize CS0 to 32MB */
Stefan Roese918010a2009-09-09 16:25:29 +0200176 mtebc(PB0AP, CONFIG_SYS_EBC_PB0AP_HWREV8);
177 mtebc(PB0CR, CONFIG_SYS_EBC_PB0CR_HWREV8);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200178 }
stroese27a0ddc2004-12-16 18:20:14 +0000179
Matthias Fuchs814f5372008-04-21 14:42:11 +0200180 return 0;
181}
stroese27a0ddc2004-12-16 18:20:14 +0000182
Matthias Fuchs814f5372008-04-21 14:42:11 +0200183int board_early_init_r(void)
stroese27a0ddc2004-12-16 18:20:14 +0000184{
Matthias Fuchs814f5372008-04-21 14:42:11 +0200185 if (gd->board_type >= 8)
Stefan Roesefb9a7302010-08-31 10:00:10 +0200186 cfi_flash_num_flash_banks = 1;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200187
188 return 0;
stroese27a0ddc2004-12-16 18:20:14 +0000189}
190
Matthias Fuchs814f5372008-04-21 14:42:11 +0200191#define FUJI_BASE 0xf0100200
192#define LCDBL_PWM 0xa0
193#define LCDBL_PWMMIN 0xa4
194#define LCDBL_PWMMAX 0xa8
stroese27a0ddc2004-12-16 18:20:14 +0000195
Matthias Fuchs814f5372008-04-21 14:42:11 +0200196int misc_init_r(void)
stroese27a0ddc2004-12-16 18:20:14 +0000197{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200198 u16 *fpga_mode = (u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL);
199 u16 *fpga_ctrl2 =(u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL2);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200200 u8 *duart0_mcr = (u8 *)(DUART0_BA + 4);
201 u8 *duart1_mcr = (u8 *)(DUART1_BA + 4);
stroese27a0ddc2004-12-16 18:20:14 +0000202 unsigned char *dst;
203 ulong len = sizeof(fpgadata);
204 int status;
205 int index;
206 int i;
Stefan Roese918010a2009-09-09 16:25:29 +0200207 unsigned long CPC0_CR0Reg;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200208 char *str;
209 uchar *logo_addr;
210 ulong logo_size;
211 ushort minb, maxb;
212 int result;
stroese27a0ddc2004-12-16 18:20:14 +0000213
214 /*
215 * Setup GPIO pins (CS6+CS7 as GPIO)
216 */
Stefan Roese918010a2009-09-09 16:25:29 +0200217 CPC0_CR0Reg = mfdcr(CPC0_CR0);
218 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00300000);
stroese27a0ddc2004-12-16 18:20:14 +0000219
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200220 dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
221 if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
Matthias Fuchs814f5372008-04-21 14:42:11 +0200222 printf("GUNZIP ERROR - must RESET board to recover\n");
223 do_reset(NULL, 0, 0, NULL);
stroese27a0ddc2004-12-16 18:20:14 +0000224 }
225
226 status = fpga_boot(dst, len);
227 if (status != 0) {
228 printf("\nFPGA: Booting failed ");
229 switch (status) {
230 case ERROR_FPGA_PRG_INIT_LOW:
Matthias Fuchs814f5372008-04-21 14:42:11 +0200231 printf("(Timeout: "
232 "INIT not low after asserting PROGRAM*)\n ");
stroese27a0ddc2004-12-16 18:20:14 +0000233 break;
234 case ERROR_FPGA_PRG_INIT_HIGH:
Matthias Fuchs814f5372008-04-21 14:42:11 +0200235 printf("(Timeout: "
236 "INIT not high after deasserting PROGRAM*)\n ");
stroese27a0ddc2004-12-16 18:20:14 +0000237 break;
238 case ERROR_FPGA_PRG_DONE:
Matthias Fuchs814f5372008-04-21 14:42:11 +0200239 printf("(Timeout: "
240 "DONE not high after programming FPGA)\n ");
stroese27a0ddc2004-12-16 18:20:14 +0000241 break;
242 }
243
244 /* display infos on fpgaimage */
245 index = 15;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200246 for (i = 0; i < 4; i++) {
stroese27a0ddc2004-12-16 18:20:14 +0000247 len = dst[index];
248 printf("FPGA: %s\n", &(dst[index+1]));
Matthias Fuchs814f5372008-04-21 14:42:11 +0200249 index += len + 3;
stroese27a0ddc2004-12-16 18:20:14 +0000250 }
Matthias Fuchs814f5372008-04-21 14:42:11 +0200251 putc('\n');
stroese27a0ddc2004-12-16 18:20:14 +0000252 /* delayed reboot */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200253 for (i = 20; i > 0; i--) {
stroese27a0ddc2004-12-16 18:20:14 +0000254 printf("Rebooting in %2d seconds \r",i);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200255 for (index = 0; index < 1000; index++)
stroese27a0ddc2004-12-16 18:20:14 +0000256 udelay(1000);
257 }
Matthias Fuchs814f5372008-04-21 14:42:11 +0200258 putc('\n');
stroese27a0ddc2004-12-16 18:20:14 +0000259 do_reset(NULL, 0, 0, NULL);
260 }
261
262 /* restore gpio/cs settings */
Stefan Roese918010a2009-09-09 16:25:29 +0200263 mtdcr(CPC0_CR0, CPC0_CR0Reg);
stroese27a0ddc2004-12-16 18:20:14 +0000264
265 puts("FPGA: ");
266
267 /* display infos on fpgaimage */
268 index = 15;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200269 for (i = 0; i < 4; i++) {
stroese27a0ddc2004-12-16 18:20:14 +0000270 len = dst[index];
Matthias Fuchs814f5372008-04-21 14:42:11 +0200271 printf("%s ", &(dst[index + 1]));
272 index += len + 3;
stroese27a0ddc2004-12-16 18:20:14 +0000273 }
Matthias Fuchs814f5372008-04-21 14:42:11 +0200274 putc('\n');
stroese27a0ddc2004-12-16 18:20:14 +0000275
276 free(dst);
277
278 /*
279 * Reset FPGA via FPGA_DATA pin
280 */
281 SET_FPGA(FPGA_PRG | FPGA_CLK);
282 udelay(1000); /* wait 1ms */
283 SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
284 udelay(1000); /* wait 1ms */
285
286 /*
stroese63268872005-04-13 10:06:07 +0000287 * Write board revision in FPGA
288 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200289 out_be16(fpga_ctrl2,
290 (in_be16(fpga_ctrl2) & 0xfff0) | (gd->board_type & 0x000f));
stroese63268872005-04-13 10:06:07 +0000291
292 /*
stroese27a0ddc2004-12-16 18:20:14 +0000293 * Enable power on PS/2 interface (with reset)
294 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200295 out_be16(fpga_mode, in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_PS2_RESET);
stroese27a0ddc2004-12-16 18:20:14 +0000296 for (i=0;i<100;i++)
297 udelay(1000);
298 udelay(1000);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200299 out_be16(fpga_mode, in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_PS2_RESET);
stroese27a0ddc2004-12-16 18:20:14 +0000300
301 /*
302 * Enable interrupts in exar duart mcr[3]
303 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200304 out_8(duart0_mcr, 0x08);
305 out_8(duart1_mcr, 0x08);
stroese27a0ddc2004-12-16 18:20:14 +0000306
307 /*
308 * Init lcd interface and display logo
309 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200310 str = getenv("splashimage");
311 if (str) {
312 logo_addr = (uchar *)simple_strtoul(str, NULL, 16);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200313 logo_size = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200314 } else {
315 logo_addr = logo_bmp;
316 logo_size = sizeof(logo_bmp);
317 }
318
319 if (gd->board_type >= 6) {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200320 result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
321 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200322 regs_13505_640_480_16bpp,
323 sizeof(regs_13505_640_480_16bpp) /
324 sizeof(regs_13505_640_480_16bpp[0]),
325 logo_addr, logo_size);
326 if (result && str) {
327 /* retry with internal image */
328 logo_addr = logo_bmp;
329 logo_size = sizeof(logo_bmp);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200330 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
331 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200332 regs_13505_640_480_16bpp,
333 sizeof(regs_13505_640_480_16bpp) /
334 sizeof(regs_13505_640_480_16bpp[0]),
335 logo_addr, logo_size);
336 }
337 } else {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200338 result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
339 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200340 regs_13806_640_480_16bpp,
341 sizeof(regs_13806_640_480_16bpp) /
342 sizeof(regs_13806_640_480_16bpp[0]),
343 logo_addr, logo_size);
344 if (result && str) {
345 /* retry with internal image */
346 logo_addr = logo_bmp;
347 logo_size = sizeof(logo_bmp);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200348 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
349 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200350 regs_13806_640_480_16bpp,
351 sizeof(regs_13806_640_480_16bpp) /
352 sizeof(regs_13806_640_480_16bpp[0]),
353 logo_addr, logo_size);
354 }
355 }
stroese27a0ddc2004-12-16 18:20:14 +0000356
357 /*
stroese63268872005-04-13 10:06:07 +0000358 * Reset microcontroller and setup backlight PWM controller
stroese27a0ddc2004-12-16 18:20:14 +0000359 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200360 out_be16(fpga_mode, in_be16(fpga_mode) | 0x0014);
stroese63268872005-04-13 10:06:07 +0000361 for (i=0;i<10;i++)
362 udelay(1000);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200363 out_be16(fpga_mode, in_be16(fpga_mode) | 0x001c);
364
365 minb = 0;
366 maxb = 0xff;
367 str = getenv("lcdbl");
368 if (str) {
369 minb = (ushort)simple_strtoul(str, &str, 16) & 0x00ff;
370 if (str && (*str=',')) {
371 str++;
372 maxb = (ushort)simple_strtoul(str, NULL, 16) & 0x00ff;
373 } else
374 minb = 0;
375
376 out_be16((u16 *)(FUJI_BASE + LCDBL_PWMMIN), minb);
377 out_be16((u16 *)(FUJI_BASE + LCDBL_PWMMAX), maxb);
378
379 printf("LCDBL: min=0x%02x, max=0x%02x\n", minb, maxb);
380 }
381 out_be16((u16 *)(FUJI_BASE + LCDBL_PWM), 0xff);
382
Matthias Fuchs68cea642008-04-25 12:01:39 +0200383 /*
384 * fix environment for field updated units
385 */
386 if (getenv("altbootcmd") == NULL) {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200387 setenv("usb_load", CONFIG_SYS_USB_LOAD_COMMAND);
388 setenv("usbargs", CONFIG_SYS_USB_ARGS);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200389 setenv("bootcmd", CONFIG_BOOTCOMMAND);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200390 setenv("usb_self", CONFIG_SYS_USB_SELF_COMMAND);
391 setenv("bootlimit", CONFIG_SYS_BOOTLIMIT);
392 setenv("altbootcmd", CONFIG_SYS_ALT_BOOTCOMMAND);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200393 saveenv();
394 }
stroese27a0ddc2004-12-16 18:20:14 +0000395
396 return (0);
397}
398
stroese27a0ddc2004-12-16 18:20:14 +0000399/*
400 * Check Board Identity:
401 */
stroese27a0ddc2004-12-16 18:20:14 +0000402int checkboard (void)
403{
Matthias Fuchs814f5372008-04-21 14:42:11 +0200404 char str[64];
Wolfgang Denk76af2782010-07-24 21:55:43 +0200405 int i = getenv_f("serial#", str, sizeof(str));
stroese27a0ddc2004-12-16 18:20:14 +0000406
407 puts ("Board: ");
408
409 if (i == -1) {
410 puts ("### No HW ID - assuming APC405");
411 } else {
412 puts(str);
413 }
414
stroese63268872005-04-13 10:06:07 +0000415 gd->board_type = board_revision();
Matthias Fuchs814f5372008-04-21 14:42:11 +0200416 printf(", Rev. 1.%ld\n", gd->board_type);
stroese27a0ddc2004-12-16 18:20:14 +0000417
418 return 0;
419}
420
Matthias Fuchs814f5372008-04-21 14:42:11 +0200421#ifdef CONFIG_IDE_RESET
422void ide_set_reset(int on)
stroese27a0ddc2004-12-16 18:20:14 +0000423{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200424 u16 *fpga_mode = (u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL);
stroese27a0ddc2004-12-16 18:20:14 +0000425
Matthias Fuchs814f5372008-04-21 14:42:11 +0200426 /*
427 * Assert or deassert CompactFlash Reset Pin
428 */
429 if (on) {
430 out_be16(fpga_mode,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200431 in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_CF_RESET);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200432 } else {
433 out_be16(fpga_mode,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200434 in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_CF_RESET);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200435 }
stroese27a0ddc2004-12-16 18:20:14 +0000436}
Matthias Fuchs814f5372008-04-21 14:42:11 +0200437#endif /* CONFIG_IDE_RESET */
stroese27a0ddc2004-12-16 18:20:14 +0000438
Matthias Fuchs814f5372008-04-21 14:42:11 +0200439void reset_phy(void)
440{
441 /*
442 * Disable sleep mode in LXT971
443 */
444 lxt971_no_sleep();
445}
stroese27a0ddc2004-12-16 18:20:14 +0000446
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200447#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT)
Matthias Fuchs814f5372008-04-21 14:42:11 +0200448int usb_board_init(void)
449{
450 return 0;
451}
stroese27a0ddc2004-12-16 18:20:14 +0000452
Matthias Fuchs814f5372008-04-21 14:42:11 +0200453int usb_board_stop(void)
stroese27a0ddc2004-12-16 18:20:14 +0000454{
Matthias Fuchs814f5372008-04-21 14:42:11 +0200455 unsigned short tmp;
456 int i;
stroese27a0ddc2004-12-16 18:20:14 +0000457
458 /*
Matthias Fuchs814f5372008-04-21 14:42:11 +0200459 * reset PCI bus
460 * This is required to make some very old Linux OHCI driver
461 * work after U-Boot has used the OHCI controller.
stroese27a0ddc2004-12-16 18:20:14 +0000462 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200463 pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &tmp);
464 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (tmp | 0x1000));
stroese27a0ddc2004-12-16 18:20:14 +0000465
Matthias Fuchs814f5372008-04-21 14:42:11 +0200466 for (i = 0; i < 100; i++)
467 udelay(1000);
468
469 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, tmp);
470 return 0;
471}
stroese27a0ddc2004-12-16 18:20:14 +0000472
Matthias Fuchs814f5372008-04-21 14:42:11 +0200473int usb_board_init_fail(void)
474{
475 usb_board_stop();
476 return 0;
477}
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200478#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */