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