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 "du405.h"
26#include <asm/processor.h>
27#include <ppc4xx.h>
28#include <4xx_i2c.h>
29#include <command.h>
30
31DECLARE_GLOBAL_DATA_PTR;
32
33
34
35extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
36extern void lxt971_no_sleep(void);
37
38
39#if 0
40#define FPGA_DEBUG
41#endif
42
43#if 0
44#define FPGA_DEBUG2
45#endif
46
47
48const unsigned char fpgadata[] = {
49#include "fpgadata.c"
50};
51
52
53
54
55#include "../common/fpga.c"
56
57
58int board_early_init_f (void)
59{
60 int index, len, i;
61 int status;
62
63#ifdef FPGA_DEBUG
64
65 (void) get_clocks ();
66 gd->baudrate = CONFIG_BAUDRATE;
67 serial_init ();
68 console_init_f ();
69#endif
70
71
72
73
74 status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata));
75 if (status != 0) {
76
77#ifndef FPGA_DEBUG
78
79 (void) get_clocks ();
80 gd->baudrate = CONFIG_BAUDRATE;
81 serial_init ();
82 console_init_f ();
83#endif
84 printf ("\nFPGA: Booting failed ");
85 switch (status) {
86 case ERROR_FPGA_PRG_INIT_LOW:
87 printf ("(Timeout: INIT not low after asserting PROGRAM*)\n ");
88 break;
89 case ERROR_FPGA_PRG_INIT_HIGH:
90 printf ("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
91 break;
92 case ERROR_FPGA_PRG_DONE:
93 printf ("(Timeout: DONE not high after programming FPGA)\n ");
94 break;
95 }
96
97
98 index = 15;
99 for (i = 0; i < 4; i++) {
100 len = fpgadata[index];
101 printf ("FPGA: %s\n", &(fpgadata[index + 1]));
102 index += len + 3;
103 }
104 putc ('\n');
105
106 for (i = 20; i > 0; i--) {
107 printf ("Rebooting in %2d seconds \r", i);
108 for (index = 0; index < 1000; index++)
109 udelay (1000);
110 }
111 putc ('\n');
112 do_reset (NULL, 0, 0, NULL);
113 }
114
115
116
117
118
119
120
121
122
123
124
125
126
127 mtdcr (uicsr, 0xFFFFFFFF);
128 mtdcr (uicer, 0x00000000);
129 mtdcr (uiccr, 0x00000000);
130 mtdcr (uicpr, 0xFFFFFFB1);
131 mtdcr (uictr, 0x10000000);
132 mtdcr (uicvcr, 0x00000001);
133 mtdcr (uicsr, 0xFFFFFFFF);
134
135
136
137
138 mtebc (epcr, 0xb8400000);
139
140 return 0;
141}
142
143
144int misc_init_r (void)
145{
146 unsigned long cntrl0Reg;
147
148
149
150
151 cntrl0Reg = mfdcr(cntrl0);
152 mtdcr(cntrl0, cntrl0Reg | 0x00001000);
153
154 return (0);
155}
156
157
158
159
160
161int checkboard (void)
162{
163 int index;
164 int len;
165 char str[64];
166 int i = getenv_r ("serial#", str, sizeof (str));
167
168 puts ("Board: ");
169
170 if (i == -1) {
171 puts ("### No HW ID - assuming DU405");
172 } else {
173 puts (str);
174 }
175
176 puts ("\nFPGA: ");
177
178
179 index = 15;
180 for (i = 0; i < 4; i++) {
181 len = fpgadata[index];
182 printf ("%s ", &(fpgadata[index + 1]));
183 index += len + 3;
184 }
185
186 putc ('\n');
187
188
189
190
191 out_8((void *)FPGA_MODE_REG, 0xff);
192 out_8((void *)FPGA_MODE_REG, 0x00);
193
194 return 0;
195}
196
197void reset_phy(void)
198{
199#if defined(CONFIG_LXT971_NO_SLEEP)
200
201
202
203
204 lxt971_no_sleep();
205#endif
206}
207