blob: f23b822665cd293d6a9453051661e8b737745a61 [file] [log] [blame]
wdenk153d5112002-08-30 11:07:04 +00001/*
2 * (C) Copyright 2001
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
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#include <common.h>
25#include "ar405.h"
26#include <asm/processor.h>
27#include <command.h>
28#include <cmd_boot.h>
29
30
31/* ------------------------------------------------------------------------- */
32
33#if 0
34#define FPGA_DEBUG
35#endif
36
37/* fpga configuration data - generated by bin2cc */
38const unsigned char fpgadata[] = {
39#include "fpgadata.c"
40};
41
42/*
43 * include common fpga code (for esd boards)
44 */
45#include "../common/fpga.c"
46
47
48int board_pre_init (void)
49{
50 DECLARE_GLOBAL_DATA_PTR;
51
52 int index, len, i;
53 int status;
54
55#ifdef FPGA_DEBUG
56 /* set up serial port with default baudrate */
57 (void) get_clocks ();
58 gd->baudrate = CONFIG_BAUDRATE;
59 serial_init ();
60 console_init_f ();
61#endif
62
63 /*
64 * Boot onboard FPGA
65 */
66 status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata));
67 if (status != 0) {
68 /* booting FPGA failed */
69#ifndef FPGA_DEBUG
70 /* set up serial port with default baudrate */
71 (void) get_clocks ();
72 gd->baudrate = CONFIG_BAUDRATE;
73 serial_init ();
74 console_init_f ();
75#endif
76 printf ("\nFPGA: Booting failed ");
77 switch (status) {
78 case ERROR_FPGA_PRG_INIT_LOW:
79 printf ("(Timeout: INIT not low after asserting PROGRAM*)\n ");
80 break;
81 case ERROR_FPGA_PRG_INIT_HIGH:
82 printf ("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
83 break;
84 case ERROR_FPGA_PRG_DONE:
85 printf ("(Timeout: DONE not high after programming FPGA)\n ");
86 break;
87 }
88
89 /* display infos on fpgaimage */
90 index = 15;
91 for (i = 0; i < 4; i++) {
92 len = fpgadata[index];
93 printf ("FPGA: %s\n", &(fpgadata[index + 1]));
94 index += len + 3;
95 }
96 putc ('\n');
97 /* delayed reboot */
98 for (i = 20; i > 0; i--) {
99 printf ("Rebooting in %2d seconds \r", i);
100 for (index = 0; index < 1000; index++)
101 udelay (1000);
102 }
103 putc ('\n');
104 do_reset (NULL, 0, 0, NULL);
105 }
106
107 /*
108 * IRQ 0-15 405GP internally generated; active high; level sensitive
109 * IRQ 16 405GP internally generated; active low; level sensitive
110 * IRQ 17-24 RESERVED
111 * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
112 * IRQ 26 (EXT IRQ 1) CAN1; active low; level sensitive
113 * IRQ 27 (EXT IRQ 2) PCI SLOT 0; active low; level sensitive
114 * IRQ 28 (EXT IRQ 3) PCI SLOT 1; active low; level sensitive
115 * IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
116 * IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive
117 * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
118 */
119 mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
120 mtdcr (uicer, 0x00000000); /* disable all ints */
121 mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
122 mtdcr (uicpr, 0xFFFFFF81); /* set int polarities */
123 mtdcr (uictr, 0x10000000); /* set int trigger levels */
124 mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
125 mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
126
127 *(ushort *) 0xf03000ec = 0x0fff; /* enable all interrupts in fpga */
128
129 return 0;
130}
131
132
133/* ------------------------------------------------------------------------- */
134
135/*
136 * Check Board Identity:
137 */
138
139int checkboard (void)
140{
141 int index;
142 int len;
143 unsigned char str[64];
144 int i = getenv_r ("serial#", str, sizeof (str));
145
146 puts ("Board: ");
147
148 if (!i || strncmp (str, "AR405", 5)) {
149 puts ("### No HW ID - assuming AR405\n");
150 return (0);
151 }
152
153 puts (str);
154
155 puts ("\nFPGA: ");
156
157 /* display infos on fpgaimage */
158 index = 15;
159 for (i = 0; i < 4; i++) {
160 len = fpgadata[index];
161 printf ("%s ", &(fpgadata[index + 1]));
162 index += len + 3;
163 }
164
165 putc ('\n');
166
167 return 0;
168}
169
170/* ------------------------------------------------------------------------- */
171
172long int initdram (int board_type)
173{
174 return (16 * 1024 * 1024);
175}
176
177/* ------------------------------------------------------------------------- */
178
179int testdram (void)
180{
181 /* TODO: XXX XXX XXX */
182 printf ("test: 16 MB - ok\n");
183
184 return (0);
185}
186
187/* ------------------------------------------------------------------------- */