ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ppc / boot / simple / embed_config.c
1 /* Board specific functions for those embedded 8xx boards that do
2  * not have boot monitor support for board information.
3  *
4  * This program is free software; you can redistribute  it and/or modify it
5  * under  the terms of  the GNU General  Public License as published by the
6  * Free Software Foundation;  either version 2 of the  License, or (at your
7  * option) any later version.
8  */
9
10 #include <linux/types.h>
11 #include <linux/config.h>
12 #include <linux/string.h>
13 #ifdef CONFIG_8xx
14 #include <asm/mpc8xx.h>
15 #endif
16 #ifdef CONFIG_8260
17 #include <asm/mpc8260.h>
18 #include <asm/immap_8260.h>
19 #endif
20 #ifdef CONFIG_40x
21 #include <asm/io.h>
22 #endif
23 extern unsigned long timebase_period_ns;
24
25 /* For those boards that don't provide one.
26 */
27 #if !defined(CONFIG_MBX)
28 static  bd_t    bdinfo;
29 #endif
30
31 /* IIC functions.
32  * These are just the basic master read/write operations so we can
33  * examine serial EEPROM.
34  */
35 extern void     iic_read(uint devaddr, u_char *buf, uint offset, uint count);
36
37 /* Supply a default Ethernet address for those eval boards that don't
38  * ship with one.  This is an address from the MBX board I have, so
39  * it is unlikely you will find it on your network.
40  */
41 static  ushort  def_enet_addr[] = { 0x0800, 0x3e26, 0x1559 };
42
43 #if defined(CONFIG_MBX)
44
45 /* The MBX hands us a pretty much ready to go board descriptor.  This
46  * is where the idea started in the first place.
47  */
48 void
49 embed_config(bd_t **bdp)
50 {
51         u_char  *mp;
52         u_char  eebuf[128];
53         int i = 8;
54         bd_t    *bd;
55
56         bd = *bdp;
57
58         /* Read the first 128 bytes of the EEPROM.  There is more,
59          * but this is all we need.
60          */
61         iic_read(0xa4, eebuf, 0, 128);
62
63         /* All we are looking for is the Ethernet MAC address.  The
64          * first 8 bytes are 'MOTOROLA', so check for part of that.
65          * Next, the VPD describes a MAC 'packet' as being of type 08
66          * and size 06.  So we look for that and the MAC must follow.
67          * If there are more than one, we still only care about the first.
68          * If it's there, assume we have a valid MAC address.  If not,
69          * grab our default one.
70          */
71         if ((*(uint *)eebuf) == 0x4d4f544f) {
72                 while (i < 127 && !(eebuf[i] == 0x08 && eebuf[i + 1] == 0x06))
73                          i += eebuf[i + 1] + 2;  /* skip this packet */
74
75                 if (i == 127)   /* Couldn't find. */
76                         mp = (u_char *)def_enet_addr;
77                 else
78                         mp = &eebuf[i + 2];
79         }
80         else
81                 mp = (u_char *)def_enet_addr;
82
83         for (i=0; i<6; i++)
84                 bd->bi_enetaddr[i] = *mp++;
85
86         /* The boot rom passes these to us in MHz.  Linux now expects
87          * them to be in Hz.
88          */
89         bd->bi_intfreq *= 1000000;
90         bd->bi_busfreq *= 1000000;
91
92         /* Stuff a baud rate here as well.
93         */
94         bd->bi_baudrate = 9600;
95 }
96 #endif /* CONFIG_MBX */
97
98 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC) || \
99         defined(CONFIG_RPX6) || defined(CONFIG_EP405)
100 /* Helper functions for Embedded Planet boards.
101 */
102 /* Because I didn't find anything that would do this.......
103 */
104 u_char
105 aschex_to_byte(u_char *cp)
106 {
107         u_char  byte, c;
108
109         c = *cp++;
110
111         if ((c >= 'A') && (c <= 'F')) {
112                 c -= 'A';
113                 c += 10;
114         } else if ((c >= 'a') && (c <= 'f')) {
115                 c -= 'a';
116                 c += 10;
117         } else
118                 c -= '0';
119
120         byte = c * 16;
121
122         c = *cp;
123
124         if ((c >= 'A') && (c <= 'F')) {
125                 c -= 'A';
126                 c += 10;
127         } else if ((c >= 'a') && (c <= 'f')) {
128                 c -= 'a';
129                 c += 10;
130         } else
131                 c -= '0';
132
133         byte += c;
134
135         return(byte);
136 }
137
138 static void
139 rpx_eth(bd_t *bd, u_char *cp)
140 {
141         int     i;
142
143         for (i=0; i<6; i++) {
144                 bd->bi_enetaddr[i] = aschex_to_byte(cp);
145                 cp += 2;
146         }
147 }
148
149 #ifdef CONFIG_RPX6
150 static uint
151 rpx_baseten(u_char *cp)
152 {
153         uint    retval;
154
155         retval = 0;
156
157         while (*cp != '\n') {
158                 retval *= 10;
159                 retval += (*cp) - '0';
160                 cp++;
161         }
162         return(retval);
163 }
164 #endif
165
166 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
167 static void
168 rpx_brate(bd_t *bd, u_char *cp)
169 {
170         uint    rate;
171
172         rate = 0;
173
174         while (*cp != '\n') {
175                 rate *= 10;
176                 rate += (*cp) - '0';
177                 cp++;
178         }
179
180         bd->bi_baudrate = rate * 100;
181 }
182
183 static void
184 rpx_cpuspeed(bd_t *bd, u_char *cp)
185 {
186         uint    num, den;
187
188         num = den = 0;
189
190         while (*cp != '\n') {
191                 num *= 10;
192                 num += (*cp) - '0';
193                 cp++;
194                 if (*cp == '/') {
195                         cp++;
196                         den = (*cp) - '0';
197                         break;
198                 }
199         }
200
201         /* I don't know why the RPX just can't state the actual
202          * CPU speed.....
203          */
204         if (den) {
205                 num /= den;
206                 num *= den;
207         }
208         bd->bi_intfreq = bd->bi_busfreq = num * 1000000;
209
210         /* The 8xx can only run a maximum 50 MHz bus speed (until
211          * Motorola changes this :-).  Greater than 50 MHz parts
212          * run internal/2 for bus speed.
213          */
214         if (num > 50)
215                 bd->bi_busfreq /= 2;
216 }
217 #endif
218
219 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC) || defined(CONFIG_EP405)
220 static void
221 rpx_memsize(bd_t *bd, u_char *cp)
222 {
223         uint    size;
224
225         size = 0;
226
227         while (*cp != '\n') {
228                 size *= 10;
229                 size += (*cp) - '0';
230                 cp++;
231         }
232
233         bd->bi_memsize = size * 1024 * 1024;
234 }
235 #endif /* LITE || CLASSIC || EP405 */
236 #if defined(CONFIG_EP405)
237 static void
238 rpx_nvramsize(bd_t *bd, u_char *cp)
239 {
240         uint    size;
241
242         size = 0;
243
244         while (*cp != '\n') {
245                 size *= 10;
246                 size += (*cp) - '0';
247                 cp++;
248         }
249
250         bd->bi_nvramsize = size * 1024;
251 }
252 #endif /* CONFIG_EP405 */
253
254 #endif  /* Embedded Planet boards */
255
256 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
257
258 /* Read the EEPROM on the RPX-Lite board.
259 */
260 void
261 embed_config(bd_t **bdp)
262 {
263         u_char  eebuf[256], *cp;
264         bd_t    *bd;
265
266         /* Read the first 256 bytes of the EEPROM.  I think this
267          * is really all there is, and I hope if it gets bigger the
268          * info we want is still up front.
269          */
270         bd = &bdinfo;
271         *bdp = bd;
272
273 #if 1
274         iic_read(0xa8, eebuf, 0, 128);
275         iic_read(0xa8, &eebuf[128], 128, 128);
276
277         /* We look for two things, the Ethernet address and the
278          * serial baud rate.  The records are separated by
279          * newlines.
280          */
281         cp = eebuf;
282         for (;;) {
283                 if (*cp == 'E') {
284                         cp++;
285                         if (*cp == 'A') {
286                                 cp += 2;
287                                 rpx_eth(bd, cp);
288                         }
289                 }
290                 if (*cp == 'S') {
291                         cp++;
292                         if (*cp == 'B') {
293                                 cp += 2;
294                                 rpx_brate(bd, cp);
295                         }
296                 }
297                 if (*cp == 'D') {
298                         cp++;
299                         if (*cp == '1') {
300                                 cp += 2;
301                                 rpx_memsize(bd, cp);
302                         }
303                 }
304                 if (*cp == 'H') {
305                         cp++;
306                         if (*cp == 'Z') {
307                                 cp += 2;
308                                 rpx_cpuspeed(bd, cp);
309                         }
310                 }
311
312                 /* Scan to the end of the record.
313                 */
314                 while ((*cp != '\n') && (*cp != 0xff))
315                         cp++;
316
317                 /* If the next character is a 0 or ff, we are done.
318                 */
319                 cp++;
320                 if ((*cp == 0) || (*cp == 0xff))
321                         break;
322         }
323         bd->bi_memstart = 0;
324 #else
325         /* For boards without initialized EEPROM.
326         */
327         bd->bi_memstart = 0;
328         bd->bi_memsize = (8 * 1024 * 1024);
329         bd->bi_intfreq = 48000000;
330         bd->bi_busfreq = 48000000;
331         bd->bi_baudrate = 9600;
332 #endif
333 }
334 #endif /* RPXLITE || RPXCLASSIC */
335
336 #ifdef CONFIG_BSEIP
337 /* Build a board information structure for the BSE ip-Engine.
338  * There is more to come since we will add some environment
339  * variables and a function to read them.
340  */
341 void
342 embed_config(bd_t **bdp)
343 {
344         u_char  *cp;
345         int     i;
346         bd_t    *bd;
347
348         bd = &bdinfo;
349         *bdp = bd;
350
351         /* Baud rate and processor speed will eventually come
352          * from the environment variables.
353          */
354         bd->bi_baudrate = 9600;
355
356         /* Get the Ethernet station address from the Flash ROM.
357         */
358         cp = (u_char *)0xfe003ffa;
359         for (i=0; i<6; i++) {
360                 bd->bi_enetaddr[i] = *cp++;
361         }
362
363         /* The rest of this should come from the environment as well.
364         */
365         bd->bi_memstart = 0;
366         bd->bi_memsize = (16 * 1024 * 1024);
367         bd->bi_intfreq = 48000000;
368         bd->bi_busfreq = 48000000;
369 }
370 #endif /* BSEIP */
371
372 #ifdef CONFIG_FADS
373 /* Build a board information structure for the FADS.
374  */
375 void
376 embed_config(bd_t **bdp)
377 {
378         u_char  *cp;
379         int     i;
380         bd_t    *bd;
381
382         bd = &bdinfo;
383         *bdp = bd;
384
385         /* Just fill in some known values.
386          */
387         bd->bi_baudrate = 9600;
388
389         /* Use default enet.
390         */
391         cp = (u_char *)def_enet_addr;
392         for (i=0; i<6; i++) {
393                 bd->bi_enetaddr[i] = *cp++;
394         }
395
396         bd->bi_memstart = 0;
397         bd->bi_memsize = (8 * 1024 * 1024);
398         bd->bi_intfreq = 40000000;
399         bd->bi_busfreq = 40000000;
400 }
401 #endif /* FADS */
402
403 #ifdef CONFIG_8260
404 /* Compute 8260 clock values if the rom doesn't provide them.
405  * We can't compute the internal core frequency (I don't know how to
406  * do that).
407  */
408 static void
409 clk_8260(bd_t *bd)
410 {
411         uint    scmr, vco_out, clkin;
412         uint    plldf, pllmf, busdf, brgdf, cpmdf;
413         volatile immap_t        *ip;
414
415         ip = (immap_t *)IMAP_ADDR;
416         scmr = ip->im_clkrst.car_scmr;
417
418         /* The clkin is always bus frequency.
419         */
420         clkin = bd->bi_busfreq;
421
422         /* Collect the bits from the scmr.
423         */
424         plldf = (scmr >> 12) & 1;
425         pllmf = scmr & 0xfff;
426         cpmdf = (scmr >> 16) & 0x0f;
427         busdf = (scmr >> 20) & 0x0f;
428
429         /* This is arithmetic from the 8260 manual.
430         */
431         vco_out = clkin / (plldf + 1);
432         vco_out *= 2 * (pllmf + 1);
433         bd->bi_vco = vco_out;           /* Save for later */
434
435         bd->bi_cpmfreq = vco_out / 2;   /* CPM Freq, in MHz */
436
437         /* Set Baud rate divisor.  The power up default is divide by 16,
438          * but we set it again here in case it was changed.
439          */
440         ip->im_clkrst.car_sccr = 1;     /* DIV 16 BRG */
441         bd->bi_brgfreq = vco_out / 16;
442 }
443 #endif
444
445 #if defined(CONFIG_EST8260) || defined(CONFIG_TQM8260)
446 void
447 embed_config(bd_t **bdp)
448 {
449         u_char  *cp;
450         int     i;
451         bd_t    *bd;
452
453         bd = *bdp;
454 #if 0
455         /* This is actually provided by my boot rom.  I have it
456          * here for those people that may load the kernel with
457          * a JTAG/COP tool and not the rom monitor.
458          */
459         bd->bi_baudrate = 115200;
460         bd->bi_intfreq = 200000000;
461         bd->bi_busfreq = 66666666;
462         bd->bi_cpmfreq = 66666666;
463         bd->bi_brgfreq = 33333333;
464         bd->bi_memsize = 16 * 1024 * 1024;
465 #else
466         /* The boot rom passes these to us in MHz.  Linux now expects
467          * them to be in Hz.
468          */
469         bd->bi_intfreq *= 1000000;
470         bd->bi_busfreq *= 1000000;
471         bd->bi_cpmfreq *= 1000000;
472         bd->bi_brgfreq *= 1000000;
473 #endif
474
475         cp = (u_char *)def_enet_addr;
476         for (i=0; i<6; i++) {
477                 bd->bi_enetaddr[i] = *cp++;
478         }
479 }
480 #endif /* EST8260 */
481
482 #ifdef CONFIG_SBS8260
483 void
484 embed_config(bd_t **bdp)
485 {
486         u_char  *cp;
487         int     i;
488         bd_t    *bd;
489
490         /* This should provided by the boot rom.
491          */
492         bd = &bdinfo;
493         *bdp = bd;
494         bd->bi_baudrate = 9600;
495         bd->bi_memsize = 64 * 1024 * 1024;
496
497         /* Set all of the clocks.  We have to know the speed of the
498          * external clock.  The development board had 66 MHz.
499          */
500         bd->bi_busfreq = 66666666;
501         clk_8260(bd);
502
503         /* I don't know how to compute this yet.
504         */
505         bd->bi_intfreq = 133000000;
506
507
508         cp = (u_char *)def_enet_addr;
509         for (i=0; i<6; i++) {
510                 bd->bi_enetaddr[i] = *cp++;
511         }
512 }
513 #endif /* SBS8260 */
514
515 #ifdef CONFIG_RPX6
516 void
517 embed_config(bd_t **bdp)
518 {
519         u_char  *cp, *keyvals;
520         int     i;
521         bd_t    *bd;
522
523         keyvals = (u_char *)*bdp;
524
525         bd = &bdinfo;
526         *bdp = bd;
527
528         /* This is almost identical to the RPX-Lite/Classic functions
529          * on the 8xx boards.  It would be nice to have a key lookup
530          * function in a string, but the format of all of the fields
531          * is slightly different.
532          */
533         cp = keyvals;
534         for (;;) {
535                 if (*cp == 'E') {
536                         cp++;
537                         if (*cp == 'A') {
538                                 cp += 2;
539                                 rpx_eth(bd, cp);
540                         }
541                 }
542                 if (*cp == 'S') {
543                         cp++;
544                         if (*cp == 'B') {
545                                 cp += 2;
546                                 bd->bi_baudrate = rpx_baseten(cp);
547                         }
548                 }
549                 if (*cp == 'D') {
550                         cp++;
551                         if (*cp == '1') {
552                                 cp += 2;
553                                 bd->bi_memsize = rpx_baseten(cp) * 1024 * 1024;
554                         }
555                 }
556                 if (*cp == 'X') {
557                         cp++;
558                         if (*cp == 'T') {
559                                 cp += 2;
560                                 bd->bi_busfreq = rpx_baseten(cp);
561                         }
562                 }
563                 if (*cp == 'N') {
564                         cp++;
565                         if (*cp == 'V') {
566                                 cp += 2;
567                                 bd->bi_nvsize = rpx_baseten(cp) * 1024 * 1024;
568                         }
569                 }
570
571                 /* Scan to the end of the record.
572                 */
573                 while ((*cp != '\n') && (*cp != 0xff))
574                         cp++;
575
576                 /* If the next character is a 0 or ff, we are done.
577                 */
578                 cp++;
579                 if ((*cp == 0) || (*cp == 0xff))
580                         break;
581         }
582         bd->bi_memstart = 0;
583
584         /* The memory size includes both the 60x and local bus DRAM.
585          * I don't want to use the local bus DRAM for real memory,
586          * so subtract it out.  It would be nice if they were separate
587          * keys.
588          */
589         bd->bi_memsize -= 32 * 1024 * 1024;
590
591         /* Set all of the clocks.  We have to know the speed of the
592          * external clock.
593          */
594         clk_8260(bd);
595
596         /* I don't know how to compute this yet.
597         */
598         bd->bi_intfreq = 200000000;
599 }
600 #endif /* RPX6 for testing */
601
602 #ifdef CONFIG_ADS8260
603 void
604 embed_config(bd_t **bdp)
605 {
606         u_char  *cp;
607         int     i;
608         bd_t    *bd;
609
610         /* This should provided by the boot rom.
611          */
612         bd = &bdinfo;
613         *bdp = bd;
614         bd->bi_baudrate = 9600;
615         bd->bi_memsize = 16 * 1024 * 1024;
616
617         /* Set all of the clocks.  We have to know the speed of the
618          * external clock.  The development board had 66 MHz.
619          */
620         bd->bi_busfreq = 66666666;
621         clk_8260(bd);
622
623         /* I don't know how to compute this yet.
624         */
625         bd->bi_intfreq = 200000000;
626
627
628         cp = (u_char *)def_enet_addr;
629         for (i=0; i<6; i++) {
630                 bd->bi_enetaddr[i] = *cp++;
631         }
632 }
633 #endif /* ADS8260 */
634
635 #ifdef CONFIG_WILLOW
636 void
637 embed_config(bd_t **bdp)
638 {
639         u_char  *cp;
640         int     i;
641         bd_t    *bd;
642
643         /* Willow has Open Firmware....I should learn how to get this
644          * information from it.
645          */
646         bd = &bdinfo;
647         *bdp = bd;
648         bd->bi_baudrate = 9600;
649         bd->bi_memsize = 32 * 1024 * 1024;
650
651         /* Set all of the clocks.  We have to know the speed of the
652          * external clock.  The development board had 66 MHz.
653          */
654         bd->bi_busfreq = 66666666;
655         clk_8260(bd);
656
657         /* I don't know how to compute this yet.
658         */
659         bd->bi_intfreq = 200000000;
660
661
662         cp = (u_char *)def_enet_addr;
663         for (i=0; i<6; i++) {
664                 bd->bi_enetaddr[i] = *cp++;
665         }
666 }
667 #endif /* WILLOW */
668
669 #ifdef CONFIG_XILINX_ML300
670 void
671 embed_config(bd_t ** bdp)
672 {
673         static const unsigned long line_size = 32;
674         static const unsigned long congruence_classes = 256;
675         unsigned long addr;
676         u_char *cp;
677         int i;
678         bd_t *bd;
679
680         /*
681          * At one point, we were getting machine checks.  Linux was not
682          * invalidating the data cache before it was enabled.  The
683          * following code was added to do that.  Soon after we had done
684          * that, we found the real reasons for the machine checks.  I've
685          * run the kernel a few times with the following code
686          * temporarily removed without any apparent problems.  However,
687          * I objdump'ed the kernel and boot code and found out that
688          * there were no other dccci's anywhere, so I put the code back
689          * in and have been reluctant to remove it.  It seems safer to
690          * just leave it here.
691          */
692         for (addr = 0;
693              addr < (congruence_classes * line_size); addr += line_size) {
694               __asm__("dccci 0,%0": :"b"(addr));
695         }
696
697         bd = &bdinfo;
698         *bdp = bd;
699         bd->bi_memsize = XPAR_DDR_0_SIZE;
700         bd->bi_intfreq = XPAR_CORE_CLOCK_FREQ_HZ;
701         bd->bi_busfreq = XPAR_PLB_CLOCK_FREQ_HZ;
702 }
703 #endif /* CONFIG_XILINX_ML300 */
704
705 #ifdef CONFIG_IBM_OPENBIOS
706 /* This could possibly work for all treeboot roms.
707 */
708 #if defined(CONFIG_ASH) || defined(CONFIG_BEECH)
709 #define BOARD_INFO_VECTOR       0xFFF80B50 /* openbios 1.19 moved this vector down  - armin */
710 #else
711 #define BOARD_INFO_VECTOR       0xFFFE0B50
712 #endif
713
714 #ifdef CONFIG_BEECH
715 static void
716 get_board_info(bd_t **bdp)
717 {
718         typedef void (*PFV)(bd_t *bd);
719         ((PFV)(*(unsigned long *)BOARD_INFO_VECTOR))(*bdp);
720         return;
721 }
722
723 void
724 embed_config(bd_t **bdp)
725 {
726         *bdp = &bdinfo;
727         get_board_info(bdp);
728 }
729 #else /* !CONFIG_BEECH */
730 void
731 embed_config(bd_t **bdp)
732 {
733         u_char  *cp;
734         int     i;
735         bd_t    *bd, *treeboot_bd;
736         bd_t *(*get_board_info)(void) =
737             (bd_t *(*)(void))(*(unsigned long *)BOARD_INFO_VECTOR);
738 #if !defined(CONFIG_STB03xxx)
739
740         /* shut down the Ethernet controller that the boot rom
741          * sometimes leaves running.
742          */
743         mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR);     /* 1st reset MAL */
744         while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* wait for the reset */      
745         out_be32(EMAC0_BASE,0x20000000);        /* then reset EMAC */
746 #endif
747
748         bd = &bdinfo;
749         *bdp = bd;
750         if ((treeboot_bd = get_board_info()) != NULL) {
751                 memcpy(bd, treeboot_bd, sizeof(bd_t));
752         }
753         else {
754                 /* Hmmm...better try to stuff some defaults.
755                 */
756                 bd->bi_memsize = 16 * 1024 * 1024;
757                 cp = (u_char *)def_enet_addr;
758                 for (i=0; i<6; i++) {
759                         /* I should probably put different ones here,
760                          * hopefully only one is used.
761                          */
762                         bd->BD_EMAC_ADDR(0,i) = *cp;
763
764 #ifdef CONFIG_PCI
765                         bd->bi_pci_enetaddr[i] = *cp++;
766 #endif
767                 }
768                 bd->bi_tbfreq = 200 * 1000 * 1000;
769                 bd->bi_intfreq = 200000000;
770                 bd->bi_busfreq = 100000000;
771 #ifdef CONFIG_PCI
772                 bd->bi_pci_busfreq = 66666666;
773 #endif
774         }
775         /* Yeah, this look weird, but on Redwood 4 they are
776          * different object in the structure.  Sincr Redwwood 5
777          * and Redwood 6 use OpenBIOS, it requires a special value.
778          */
779 #if defined(CONFIG_REDWOOD_5) || defined (CONFIG_REDWOOD_6)
780         bd->bi_tbfreq = 27 * 1000 * 1000;
781 #endif
782         timebase_period_ns = 1000000000 / bd->bi_tbfreq;
783 }
784 #endif /* CONFIG_BEECH */
785 #endif /* CONFIG_IBM_OPENBIOS */
786
787 #ifdef CONFIG_EP405
788 #include <linux/serial_reg.h>
789
790 void
791 embed_config(bd_t **bdp)
792 {
793         u32 chcr0;
794         u_char *cp;
795         bd_t    *bd;
796
797         /* Different versions of the PlanetCore firmware vary in how
798            they set up the serial port - in particular whether they
799            use the internal or external serial clock for UART0.  Make
800            sure the UART is in a known state. */
801         /* FIXME: We should use the board's 11.0592MHz external serial
802            clock - it will be more accurate for serial rates.  For
803            now, however the baud rates in ep405.h are for the internal
804            clock. */
805         chcr0 = mfdcr(DCRN_CHCR0);
806         if ( (chcr0 & 0x1fff) != 0x103e ) {
807                 mtdcr(DCRN_CHCR0, (chcr0 & 0xffffe000) | 0x103e);
808                 /* The following tricks serial_init() into resetting the baud rate */
809                 writeb(0, UART0_IO_BASE + UART_LCR);
810         }
811
812         /* We haven't seen actual problems with the EP405 leaving the
813          * EMAC running (as we have on Walnut).  But the registers
814          * suggest it may not be left completely quiescent.  Reset it
815          * just to be sure. */
816         mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR);     /* 1st reset MAL */
817         while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* wait for the reset */      
818         out_be32((unsigned *)EMAC0_BASE,0x20000000);        /* then reset EMAC */
819
820         bd = &bdinfo;
821         *bdp = bd;
822 #if 1
823                 cp = (u_char *)0xF0000EE0;
824                 for (;;) {
825                         if (*cp == 'E') {
826                                 cp++;
827                                 if (*cp == 'A') {
828                                   cp += 2;
829                                   rpx_eth(bd, cp);
830                                 }
831                          }
832
833                         if (*cp == 'D') {
834                                         cp++;
835                                         if (*cp == '1') {
836                                                 cp += 2;
837                                                 rpx_memsize(bd, cp);
838                                         }
839                         }
840
841                         if (*cp == 'N') {
842                                 cp++;
843                                 if (*cp == 'V') {
844                                         cp += 2;
845                                         rpx_nvramsize(bd, cp);
846                                 }
847                         }
848                         while ((*cp != '\n') && (*cp != 0xff))
849                               cp++;
850
851                         cp++;
852                         if ((*cp == 0) || (*cp == 0xff))
853                            break;
854                }
855         bd->bi_intfreq   = 200000000;
856         bd->bi_busfreq   = 100000000;
857         bd->bi_pci_busfreq= 33000000 ;
858 #else
859
860         bd->bi_memsize   = 64000000;
861         bd->bi_intfreq   = 200000000;
862         bd->bi_busfreq   = 100000000;
863         bd->bi_pci_busfreq= 33000000 ;
864 #endif
865 }
866 #endif
867
868 #ifdef CONFIG_RAINIER
869 /* Rainier uses vxworks bootrom */
870 void
871 embed_config(bd_t **bdp)
872 {
873         u_char  *cp;
874         int     i;
875         bd_t    *bd;
876         
877         bd = &bdinfo;
878         *bdp = bd;
879         
880         for(i=0;i<8192;i+=32) {
881                 __asm__("dccci 0,%0" :: "r" (i));
882         }
883         __asm__("iccci 0,0");
884         __asm__("sync;isync");
885
886         /* init ram for parity */
887         memset(0, 0,0x400000);  /* Lo memory */
888
889
890         bd->bi_memsize   = (32 * 1024 * 1024) ;
891         bd->bi_intfreq = 133000000; //the internal clock is 133 MHz
892         bd->bi_busfreq   = 100000000;
893         bd->bi_pci_busfreq= 33000000;
894
895         cp = (u_char *)def_enet_addr;
896         for (i=0; i<6; i++) {
897                 bd->bi_enetaddr[i] = *cp++;
898         }
899
900 }
901 #endif
902