1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <asm/processor.h>
26#include <command.h>
27#include <malloc.h>
28
29
30
31#if 0
32#define FPGA_DEBUG
33#endif
34
35extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
36
37
38const unsigned char fpgadata[] =
39{
40#include "fpgadata.c"
41};
42
43
44
45
46#include "../common/fpga.c"
47
48
49
50int gunzip(void *, int, unsigned char *, unsigned long *);
51
52
53int board_early_init_f (void)
54{
55
56
57
58
59
60
61
62
63
64
65
66
67 mtdcr(uicsr, 0xFFFFFFFF);
68 mtdcr(uicer, 0x00000000);
69 mtdcr(uiccr, 0x00000000);
70 mtdcr(uicpr, 0xFFFFFF9F);
71 mtdcr(uictr, 0x10000000);
72 mtdcr(uicvcr, 0x00000001);
73 mtdcr(uicsr, 0xFFFFFFFF);
74
75
76
77
78 mtebc (epcr, 0xa8400000);
79
80 return 0;
81}
82
83int misc_init_r (void)
84{
85 volatile unsigned char *duart0_mcr = (unsigned char *)((ulong)DUART0_BA + 4);
86 volatile unsigned char *duart1_mcr = (unsigned char *)((ulong)DUART1_BA + 4);
87 volatile unsigned char *duart2_mcr = (unsigned char *)((ulong)DUART2_BA + 4);
88 volatile unsigned char *duart3_mcr = (unsigned char *)((ulong)DUART3_BA + 4);
89 unsigned char *dst;
90 ulong len = sizeof(fpgadata);
91 int status;
92 int index;
93 int i;
94
95 dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
96 if (gunzip (dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
97 printf ("GUNZIP ERROR - must RESET board to recover\n");
98 do_reset (NULL, 0, 0, NULL);
99 }
100
101 status = fpga_boot(dst, len);
102 if (status != 0) {
103 printf("\nFPGA: Booting failed ");
104 switch (status) {
105 case ERROR_FPGA_PRG_INIT_LOW:
106 printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
107 break;
108 case ERROR_FPGA_PRG_INIT_HIGH:
109 printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
110 break;
111 case ERROR_FPGA_PRG_DONE:
112 printf("(Timeout: DONE not high after programming FPGA)\n ");
113 break;
114 }
115
116
117 index = 15;
118 for (i=0; i<4; i++) {
119 len = dst[index];
120 printf("FPGA: %s\n", &(dst[index+1]));
121 index += len+3;
122 }
123 putc ('\n');
124
125 for (i=20; i>0; i--) {
126 printf("Rebooting in %2d seconds \r",i);
127 for (index=0;index<1000;index++)
128 udelay(1000);
129 }
130 putc ('\n');
131 do_reset(NULL, 0, 0, NULL);
132 }
133
134 puts("FPGA: ");
135
136
137 index = 15;
138 for (i=0; i<4; i++) {
139 len = dst[index];
140 printf("%s ", &(dst[index+1]));
141 index += len+3;
142 }
143 putc ('\n');
144
145 free(dst);
146
147
148
149
150 SET_FPGA(FPGA_PRG | FPGA_CLK);
151 udelay(1000);
152 SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
153 udelay(1000);
154
155
156
157
158 out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_DUART_RST);
159 udelay(10);
160 out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_DUART_RST);
161 udelay(1000);
162
163
164
165
166 *duart0_mcr = 0x08;
167 *duart1_mcr = 0x08;
168 *duart2_mcr = 0x08;
169 *duart3_mcr = 0x08;
170
171 return (0);
172}
173
174
175
176
177
178
179int checkboard (void)
180{
181 char str[64];
182 int i = getenv_r ("serial#", str, sizeof(str));
183
184 puts ("Board: ");
185
186 if (i == -1) {
187 puts ("### No HW ID - assuming WUH405");
188 } else {
189 puts(str);
190 }
191
192 putc ('\n');
193
194 return 0;
195}
196