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 <asm/ppc4xx.h>
28#include <asm/ppc4xx-i2c.h>
29#include <command.h>
30
31DECLARE_GLOBAL_DATA_PTR;
32
33extern void lxt971_no_sleep(void);
34
35
36#if 0
37#define FPGA_DEBUG
38#endif
39
40#if 0
41#define FPGA_DEBUG2
42#endif
43
44
45const unsigned char fpgadata[] = {
46#include "fpgadata.c"
47};
48
49
50
51
52#include "../common/fpga.c"
53
54
55int board_early_init_f (void)
56{
57 int index, len, i;
58 int status;
59
60#ifdef FPGA_DEBUG
61
62 (void) get_clocks ();
63 gd->baudrate = CONFIG_BAUDRATE;
64 serial_init ();
65 console_init_f ();
66#endif
67
68
69
70
71 status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata));
72 if (status != 0) {
73
74#ifndef FPGA_DEBUG
75
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
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
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
114
115
116
117
118
119
120
121
122
123
124 mtdcr (UIC0SR, 0xFFFFFFFF);
125 mtdcr (UIC0ER, 0x00000000);
126 mtdcr (UIC0CR, 0x00000000);
127 mtdcr (UIC0PR, 0xFFFFFFB1);
128 mtdcr (UIC0TR, 0x10000000);
129 mtdcr (UIC0VCR, 0x00000001);
130 mtdcr (UIC0SR, 0xFFFFFFFF);
131
132
133
134
135 mtebc (EBC0_CFG, 0xb8400000);
136
137 return 0;
138}
139
140
141int misc_init_r (void)
142{
143 unsigned long CPC0_CR0Reg;
144
145
146
147
148 CPC0_CR0Reg = mfdcr(CPC0_CR0);
149 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00001000);
150
151 return (0);
152}
153
154
155
156
157
158int checkboard (void)
159{
160 int index;
161 int len;
162 char str[64];
163 int i = getenv_f("serial#", str, sizeof (str));
164
165 puts ("Board: ");
166
167 if (i == -1) {
168 puts ("### No HW ID - assuming DU405");
169 } else {
170 puts (str);
171 }
172
173 puts ("\nFPGA: ");
174
175
176 index = 15;
177 for (i = 0; i < 4; i++) {
178 len = fpgadata[index];
179 printf ("%s ", &(fpgadata[index + 1]));
180 index += len + 3;
181 }
182
183 putc ('\n');
184
185
186
187
188 out_8((void *)FPGA_MODE_REG, 0xff);
189 out_8((void *)FPGA_MODE_REG, 0x00);
190
191 return 0;
192}
193
194void reset_phy(void)
195{
196#if defined(CONFIG_LXT971_NO_SLEEP)
197
198
199
200
201 lxt971_no_sleep();
202#endif
203}
204