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