1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <common.h>
24#include <ioports.h>
25#include <mpc8260.h>
26#include <asm/m8260_pci.h>
27#include <miiphy.h>
28
29#include "m88e6060.h"
30
31
32
33
34
35
36
37
38const iop_conf_t iop_conf_tab[4][32] = {
39
40 {
41 { 1, 0, 0, 1, 0, 0 },
42 { 1, 0, 0, 0, 0, 0 },
43 { 1, 0, 0, 1, 0, 0 },
44 { 1, 1, 1, 1, 0, 0 },
45 { 1, 1, 1, 0, 0, 0 },
46 { 1, 1, 1, 0, 0, 0 },
47 { 1, 0, 0, 0, 0, 0 },
48 { 1, 0, 0, 0, 0, 0 },
49 { 1, 0, 0, 0, 0, 0 },
50 { 1, 0, 0, 0, 0, 0 },
51 { 1, 0, 0, 0, 0, 0 },
52 { 1, 0, 0, 1, 0, 1 },
53 { 1, 1, 0, 1, 0, 0 },
54 { 1, 1, 0, 1, 0, 0 },
55 { 1, 1, 0, 0, 0, 0 },
56 { 1, 1, 0, 0, 0, 0 },
57 { 1, 0, 0, 1, 0, 0 },
58 { 1, 0, 0, 1, 0, 0 },
59 { 1, 0, 0, 1, 0, 1 },
60 { 1, 0, 0, 1, 0, 0 },
61 { 1, 0, 0, 1, 0, 0 },
62 { 1, 0, 0, 1, 0, 0 },
63 { 1, 1, 0, 1, 0, 0 },
64 { 1, 1, 0, 0, 0, 0 },
65 { 0, 0, 0, 0, 0, 0 },
66 { 0, 0, 0, 0, 0, 0 },
67 { 0, 0, 0, 0, 0, 0 },
68 { 0, 0, 0, 0, 0, 0 },
69 { 0, 0, 0, 0, 0, 0 },
70 { 0, 0, 0, 0, 0, 0 },
71 { 0, 0, 0, 0, 0, 0 },
72 { 0, 0, 0, 0, 0, 0 }
73 },
74
75
76 {
77 { 1, 0, 0, 1, 0, 0 },
78 { 1, 1, 0, 0, 0, 0 },
79 { 1, 1, 1, 1, 0, 0 },
80 { 1, 1, 0, 0, 0, 0 },
81 { 1, 1, 1, 0, 1, 0 },
82 { 1, 1, 1, 0, 1, 0 },
83 { 1, 0, 0, 1, 0, 0 },
84 { 1, 1, 1, 0, 0, 0 },
85 { 1, 1, 0, 1, 0, 0 },
86 { 1, 1, 0, 1, 0, 0 },
87 { 1, 1, 0, 0, 0, 0 },
88 { 1, 1, 0, 0, 0, 0 },
89 { 1, 0, 0, 1, 0, 1 },
90 { 1, 0, 0, 0, 0, 0 },
91 { 0, 0, 0, 0, 0, 0 },
92 { 0, 0, 0, 0, 0, 0 },
93 { 0, 0, 0, 0, 0, 0 },
94 { 0, 0, 0, 0, 0, 0 },
95 { 0, 0, 0, 0, 0, 0 },
96 { 0, 0, 0, 0, 0, 0 },
97 { 0, 0, 0, 0, 0, 0 },
98 { 0, 0, 0, 0, 0, 0 },
99 { 0, 0, 0, 0, 0, 0 },
100 { 0, 0, 0, 0, 0, 0 },
101 { 0, 0, 0, 0, 0, 0 },
102 { 0, 0, 0, 0, 0, 0 },
103 { 0, 0, 0, 0, 0, 0 },
104 { 0, 0, 0, 0, 0, 0 },
105 { 0, 0, 0, 0, 0, 0 },
106 { 0, 0, 0, 0, 0, 0 },
107 { 0, 0, 0, 0, 0, 0 },
108 { 0, 0, 0, 0, 0, 0 }
109 },
110
111
112 {
113 { 0, 0, 0, 0, 0, 0 },
114 { 0, 0, 0, 0, 0, 0 },
115 { 1, 0, 0, 1, 0, 0 },
116 { 1, 0, 0, 1, 0, 0 },
117 { 1, 1, 0, 0, 0, 0 },
118 { 1, 0, 0, 1, 0, 0 },
119 { 1, 0, 0, 1, 0, 0 },
120 { 1, 0, 0, 1, 0, 0 },
121 { 1, 1, 0, 0, 0, 0 },
122 { 1, 1, 0, 0, 0, 0 },
123 { 1, 0, 0, 1, 0, 0 },
124 { 1, 0, 0, 1, 0, 0 },
125 { 1, 0, 0, 1, 0, 0 },
126 { 1, 0, 0, 1, 0, 0 },
127 { 1, 1, 0, 1, 0, 0 },
128 { 1, 1, 0, 0, 0, 0 },
129 { 1, 0, 0, 0, 0, 0 },
130 { 1, 0, 0, 0, 0, 0 },
131 { 1, 0, 0, 0, 0, 0 },
132 { 1, 0, 0, 0, 0, 0 },
133 { 1, 0, 0, 1, 0, 0 },
134 { 1, 0, 0, 1, 0, 0 },
135 { 1, 0, 0, 0, 0, 0 },
136 { 1, 0, 0, 0, 0, 0 },
137 { 1, 0, 0, 0, 0, 0 },
138 { 1, 0, 0, 0, 0, 0 },
139 { 1, 1, 0, 1, 0, 0 },
140 { 1, 1, 0, 0, 0, 0 },
141 { 0, 0, 0, 0, 0, 0 },
142 { 0, 0, 0, 0, 0, 0 },
143 { 1, 0, 0, 1, 0, 0 },
144 { 1, 0, 0, 0, 0, 0 },
145 },
146
147
148 {
149 { 1, 0, 0, 1, 0, 0 },
150 { 1, 0, 0, 1, 0, 0 },
151 { 1, 0, 0, 1, 0, 0 },
152 { 0, 0, 0, 0, 0, 0 },
153 { 0, 0, 0, 0, 0, 0 },
154 { 0, 0, 0, 0, 0, 0 },
155 { 1, 0, 0, 1, 0, 0 },
156 { 1, 0, 0, 1, 0, 0 },
157 { 1, 0, 0, 1, 0, 0 },
158 { 1, 1, 1, 0, 1, 0 },
159 { 1, 1, 1, 0, 1, 0 },
160 { 1, 1, 1, 0, 0, 0 },
161 { 1, 0, 0, 1, 0, 0 },
162 { 1, 0, 0, 1, 0, 0 },
163 { 1, 0, 0, 1, 0, 0 },
164 { 1, 0, 0, 1, 0, 0 },
165 { 1, 0, 0, 1, 0, 0 },
166 { 1, 0, 0, 1, 0, 0 },
167 { 0, 0, 0, 0, 0, 0 },
168 { 0, 0, 0, 0, 0, 0 },
169 { 0, 0, 0, 0, 0, 0 },
170 { 0, 0, 0, 0, 0, 0 },
171 { 0, 0, 0, 0, 0, 0 },
172 { 0, 0, 0, 0, 0, 0 },
173 { 0, 0, 0, 1, 0, 0 },
174 { 0, 0, 0, 0, 0, 0 },
175 { 0, 0, 0, 0, 0, 0 },
176 { 0, 0, 0, 0, 0, 0 },
177 { 0, 0, 0, 0, 0, 0 },
178 { 0, 0, 0, 0, 0, 0 },
179 { 0, 0, 0, 0, 0, 0 },
180 { 0, 0, 0, 0, 0, 0 }
181 }
182};
183
184void reset_phy (void)
185{
186 volatile ioport_t *iop;
187#if defined(CONFIG_CMD_NET)
188 int i;
189 unsigned short val;
190#endif
191
192 iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 0);
193
194
195 iop->pdat &= 0xfff7ffff;
196#if defined(CONFIG_CMD_NET)
197 udelay(20000);
198 iop->pdat |= 0x00080000;
199 for (i=0; i<100; i++) {
200 udelay(20000);
201 if (bb_miiphy_read("FCC1 ETHERNET", CONFIG_SYS_PHY_ADDR,2,&val ) == 0) {
202 break;
203 }
204 }
205
206 m88e6060_initialize( CONFIG_SYS_PHY_ADDR );
207#endif
208}
209
210static unsigned long UPMATable[] = {
211 0x8fffec00, 0x0ffcfc00, 0x0ffcfc00, 0x0ffcfc00,
212 0x0ffcfc04, 0x3ffdfc00, 0xfffffc01, 0xfffffc01,
213 0xfffffc00, 0xfffffc04, 0xfffffc01, 0xfffffc00,
214 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
215 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
216 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
217 0x8fffec00, 0x00fffc00, 0x00fffc00, 0x00fffc00,
218 0x0ffffc04, 0xfffffc01, 0xfffffc01, 0xfffffc01,
219 0xfffffc00, 0xfffffc01, 0xfffffc01, 0xfffffc00,
220 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
221 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
222 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
223 0xfffffc00, 0xfffffc04, 0xfffffc01, 0xfffffc00,
224 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
225 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
226 0xffffec00, 0xffffec04, 0xffffec00, 0xfffffc01
227};
228
229int board_early_init_f (void)
230{
231 volatile immap_t *immap;
232 volatile memctl8260_t *memctl;
233 volatile unsigned char *dummy;
234 int i;
235
236 immap = (immap_t *) CONFIG_SYS_IMMR;
237 memctl = &immap->im_memctl;
238
239#if 0
240
241 dummy = (volatile unsigned char *) (memctl->memc_br2 & BRx_BA_MSK);
242 memctl->memc_mar = 0;
243 memctl->memc_mamr = MxMR_OP_WARR;
244 for (i = 0; i < 64; i++) {
245 memctl->memc_mdr = UPMATable[i];
246 *dummy = 0;
247 }
248 memctl->memc_mamr = 0x00044440;
249#else
250
251 dummy = (volatile unsigned char *) (memctl->memc_br7 & BRx_BA_MSK);
252 memctl->memc_mar = 0;
253 memctl->memc_mamr = MxMR_OP_WARR;
254 for (i = 0; i < 64; i++) {
255 memctl->memc_mdr = UPMATable[i];
256 *dummy = 0;
257 }
258 memctl->memc_mamr = 0x00044440;
259#endif
260 return 0;
261}
262
263int misc_init_r (void)
264{
265 volatile ioport_t *iop;
266 unsigned char temp;
267#if 0
268
269 volatile immap_t *immap;
270 volatile memctl8260_t *memctl;
271 volatile unsigned char *dummy;
272 unsigned char c;
273 int i;
274
275 immap = (immap_t *) CONFIG_SYS_IMMR;
276 memctl = &immap->im_memctl;
277
278
279 dummy = (volatile unsigned char *) (memctl->memc_br7 & BRx_BA_MSK);
280 memctl->memc_mar = 0;
281 memctl->memc_mamr = MxMR_OP_RARR;
282 for (i = 0; i < 64; i++) {
283 c = *dummy;
284 printf( "UPMA[%02d]: 0x%08lx,0x%08lx: 0x%08lx\n",i,
285 memctl->memc_mamr,
286 memctl->memc_mar,
287 memctl->memc_mdr );
288 }
289 memctl->memc_mamr = 0x00044440;
290#endif
291
292 iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 0);
293 iop->pdat &= 0xfffbffff;
294
295
296 *(volatile unsigned char *)0xf0500000 = 0x00;
297
298
299 temp = *(volatile unsigned char *)0xf05003ff;
300
301
302 *(volatile unsigned char *)0xf0500201 = 0x50;
303
304 return 0;
305}
306
307#if defined(CONFIG_HAVE_OWN_RESET)
308int
309do_reset (void *cmdtp, int flag, int argc, char *argv[])
310{
311 volatile ioport_t *iop;
312
313 iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 2);
314 iop->pdat |= 0x00002000;
315 return 1;
316}
317#endif
318
319#define ns2clk(ns) (ns / (1000000000 / CONFIG_8260_CLKIN) + 1)
320
321phys_size_t initdram (int board_type)
322{
323#ifndef CONFIG_SYS_RAMBOOT
324 volatile immap_t *immap;
325 volatile memctl8260_t *memctl;
326 volatile uchar *ramaddr;
327 int i;
328 uchar c;
329
330 immap = (immap_t *) CONFIG_SYS_IMMR;
331 memctl = &immap->im_memctl;
332 ramaddr = (uchar *) CONFIG_SYS_SDRAM_BASE;
333 c = 0xff;
334
335 immap->im_siu_conf.sc_ppc_acr = 0x02;
336 immap->im_siu_conf.sc_ppc_alrh = 0x01267893;
337 immap->im_siu_conf.sc_ppc_alrl = 0x89abcdef;
338 immap->im_siu_conf.sc_tescr1 = 0x00000000;
339 immap->im_siu_conf.sc_tescr2 = 0x00000000;
340
341 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
342 memctl->memc_psrt = CONFIG_SYS_PSRT;
343 memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
344 memctl->memc_br1 = CONFIG_SYS_SDRAM_BASE | CONFIG_SYS_BR1_PRELIM;
345
346
347 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x28000000;
348 *ramaddr = c;
349
350
351 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x08000000;
352 for (i = 0; i < 8; i++)
353 *ramaddr = c;
354
355
356 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x18000000;
357 *ramaddr = c;
358
359
360 memctl->memc_psdmr = CONFIG_SYS_PSDMR | 0x40000000;
361 *ramaddr = c;
362#endif
363
364 return (CONFIG_SYS_SDRAM_SIZE);
365}
366
367int checkboard (void)
368{
369#ifdef CONFIG_CLKIN_66MHz
370 puts ("Board: Elmeg VoVPN Gateway Module (66MHz)\n");
371#else
372 puts ("Board: Elmeg VoVPN Gateway Module (100MHz)\n");
373#endif
374 return 0;
375}
376