[NETFILTER]: PPTP conntrack: simplify expectation handling
[hh.org.git] / arch / ppc / boot / simple / embed_config.c
blob840bff2a45fb8bcaf2c06eb252bb0dbe769ae303
1 /* Board specific functions for those embedded 8xx boards that do
2 * not have boot monitor support for board information.
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 */
10 #include <linux/types.h>
11 #include <linux/string.h>
12 #include <asm/reg.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_cpm2.h>
19 #endif
20 #ifdef CONFIG_40x
21 #include <asm/io.h>
22 #endif
23 #ifdef CONFIG_XILINX_VIRTEX
24 #include <platforms/4xx/xparameters/xparameters.h>
25 #endif
26 extern unsigned long timebase_period_ns;
28 /* For those boards that don't provide one.
30 #if !defined(CONFIG_MBX)
31 static bd_t bdinfo;
32 #endif
34 /* IIC functions.
35 * These are just the basic master read/write operations so we can
36 * examine serial EEPROM.
38 extern void iic_read(uint devaddr, u_char *buf, uint offset, uint count);
40 /* Supply a default Ethernet address for those eval boards that don't
41 * ship with one. This is an address from the MBX board I have, so
42 * it is unlikely you will find it on your network.
44 static ushort def_enet_addr[] = { 0x0800, 0x3e26, 0x1559 };
46 #if defined(CONFIG_MBX)
48 /* The MBX hands us a pretty much ready to go board descriptor. This
49 * is where the idea started in the first place.
51 void
52 embed_config(bd_t **bdp)
54 u_char *mp;
55 u_char eebuf[128];
56 int i = 8;
57 bd_t *bd;
59 bd = *bdp;
61 /* Read the first 128 bytes of the EEPROM. There is more,
62 * but this is all we need.
64 iic_read(0xa4, eebuf, 0, 128);
66 /* All we are looking for is the Ethernet MAC address. The
67 * first 8 bytes are 'MOTOROLA', so check for part of that.
68 * Next, the VPD describes a MAC 'packet' as being of type 08
69 * and size 06. So we look for that and the MAC must follow.
70 * If there are more than one, we still only care about the first.
71 * If it's there, assume we have a valid MAC address. If not,
72 * grab our default one.
74 if ((*(uint *)eebuf) == 0x4d4f544f) {
75 while (i < 127 && !(eebuf[i] == 0x08 && eebuf[i + 1] == 0x06))
76 i += eebuf[i + 1] + 2; /* skip this packet */
78 if (i == 127) /* Couldn't find. */
79 mp = (u_char *)def_enet_addr;
80 else
81 mp = &eebuf[i + 2];
83 else
84 mp = (u_char *)def_enet_addr;
86 for (i=0; i<6; i++)
87 bd->bi_enetaddr[i] = *mp++;
89 /* The boot rom passes these to us in MHz. Linux now expects
90 * them to be in Hz.
92 bd->bi_intfreq *= 1000000;
93 bd->bi_busfreq *= 1000000;
95 /* Stuff a baud rate here as well.
97 bd->bi_baudrate = 9600;
99 #endif /* CONFIG_MBX */
101 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC) || \
102 defined(CONFIG_RPX8260) || defined(CONFIG_EP405)
103 /* Helper functions for Embedded Planet boards.
105 /* Because I didn't find anything that would do this.......
107 u_char
108 aschex_to_byte(u_char *cp)
110 u_char byte, c;
112 c = *cp++;
114 if ((c >= 'A') && (c <= 'F')) {
115 c -= 'A';
116 c += 10;
117 } else if ((c >= 'a') && (c <= 'f')) {
118 c -= 'a';
119 c += 10;
120 } else
121 c -= '0';
123 byte = c * 16;
125 c = *cp;
127 if ((c >= 'A') && (c <= 'F')) {
128 c -= 'A';
129 c += 10;
130 } else if ((c >= 'a') && (c <= 'f')) {
131 c -= 'a';
132 c += 10;
133 } else
134 c -= '0';
136 byte += c;
138 return(byte);
141 static void
142 rpx_eth(bd_t *bd, u_char *cp)
144 int i;
146 for (i=0; i<6; i++) {
147 bd->bi_enetaddr[i] = aschex_to_byte(cp);
148 cp += 2;
152 #ifdef CONFIG_RPX8260
153 static uint
154 rpx_baseten(u_char *cp)
156 uint retval;
158 retval = 0;
160 while (*cp != '\n') {
161 retval *= 10;
162 retval += (*cp) - '0';
163 cp++;
165 return(retval);
167 #endif
169 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
170 static void
171 rpx_brate(bd_t *bd, u_char *cp)
173 uint rate;
175 rate = 0;
177 while (*cp != '\n') {
178 rate *= 10;
179 rate += (*cp) - '0';
180 cp++;
183 bd->bi_baudrate = rate * 100;
186 static void
187 rpx_cpuspeed(bd_t *bd, u_char *cp)
189 uint num, den;
191 num = den = 0;
193 while (*cp != '\n') {
194 num *= 10;
195 num += (*cp) - '0';
196 cp++;
197 if (*cp == '/') {
198 cp++;
199 den = (*cp) - '0';
200 break;
204 /* I don't know why the RPX just can't state the actual
205 * CPU speed.....
207 if (den) {
208 num /= den;
209 num *= den;
211 bd->bi_intfreq = bd->bi_busfreq = num * 1000000;
213 /* The 8xx can only run a maximum 50 MHz bus speed (until
214 * Motorola changes this :-). Greater than 50 MHz parts
215 * run internal/2 for bus speed.
217 if (num > 50)
218 bd->bi_busfreq /= 2;
220 #endif
222 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC) || defined(CONFIG_EP405)
223 static void
224 rpx_memsize(bd_t *bd, u_char *cp)
226 uint size;
228 size = 0;
230 while (*cp != '\n') {
231 size *= 10;
232 size += (*cp) - '0';
233 cp++;
236 bd->bi_memsize = size * 1024 * 1024;
238 #endif /* LITE || CLASSIC || EP405 */
239 #if defined(CONFIG_EP405)
240 static void
241 rpx_nvramsize(bd_t *bd, u_char *cp)
243 uint size;
245 size = 0;
247 while (*cp != '\n') {
248 size *= 10;
249 size += (*cp) - '0';
250 cp++;
253 bd->bi_nvramsize = size * 1024;
255 #endif /* CONFIG_EP405 */
257 #endif /* Embedded Planet boards */
259 #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
261 /* Read the EEPROM on the RPX-Lite board.
263 void
264 embed_config(bd_t **bdp)
266 u_char eebuf[256], *cp;
267 bd_t *bd;
269 /* Read the first 256 bytes of the EEPROM. I think this
270 * is really all there is, and I hope if it gets bigger the
271 * info we want is still up front.
273 bd = &bdinfo;
274 *bdp = bd;
276 #if 1
277 iic_read(0xa8, eebuf, 0, 128);
278 iic_read(0xa8, &eebuf[128], 128, 128);
280 /* We look for two things, the Ethernet address and the
281 * serial baud rate. The records are separated by
282 * newlines.
284 cp = eebuf;
285 for (;;) {
286 if (*cp == 'E') {
287 cp++;
288 if (*cp == 'A') {
289 cp += 2;
290 rpx_eth(bd, cp);
293 if (*cp == 'S') {
294 cp++;
295 if (*cp == 'B') {
296 cp += 2;
297 rpx_brate(bd, cp);
300 if (*cp == 'D') {
301 cp++;
302 if (*cp == '1') {
303 cp += 2;
304 rpx_memsize(bd, cp);
307 if (*cp == 'H') {
308 cp++;
309 if (*cp == 'Z') {
310 cp += 2;
311 rpx_cpuspeed(bd, cp);
315 /* Scan to the end of the record.
317 while ((*cp != '\n') && (*cp != 0xff))
318 cp++;
320 /* If the next character is a 0 or ff, we are done.
322 cp++;
323 if ((*cp == 0) || (*cp == 0xff))
324 break;
326 bd->bi_memstart = 0;
327 #else
328 /* For boards without initialized EEPROM.
330 bd->bi_memstart = 0;
331 bd->bi_memsize = (8 * 1024 * 1024);
332 bd->bi_intfreq = 48000000;
333 bd->bi_busfreq = 48000000;
334 bd->bi_baudrate = 9600;
335 #endif
337 #endif /* RPXLITE || RPXCLASSIC */
339 #ifdef CONFIG_BSEIP
340 /* Build a board information structure for the BSE ip-Engine.
341 * There is more to come since we will add some environment
342 * variables and a function to read them.
344 void
345 embed_config(bd_t **bdp)
347 u_char *cp;
348 int i;
349 bd_t *bd;
351 bd = &bdinfo;
352 *bdp = bd;
354 /* Baud rate and processor speed will eventually come
355 * from the environment variables.
357 bd->bi_baudrate = 9600;
359 /* Get the Ethernet station address from the Flash ROM.
361 cp = (u_char *)0xfe003ffa;
362 for (i=0; i<6; i++) {
363 bd->bi_enetaddr[i] = *cp++;
366 /* The rest of this should come from the environment as well.
368 bd->bi_memstart = 0;
369 bd->bi_memsize = (16 * 1024 * 1024);
370 bd->bi_intfreq = 48000000;
371 bd->bi_busfreq = 48000000;
373 #endif /* BSEIP */
375 #ifdef CONFIG_FADS
376 /* Build a board information structure for the FADS.
378 void
379 embed_config(bd_t **bdp)
381 u_char *cp;
382 int i;
383 bd_t *bd;
385 bd = &bdinfo;
386 *bdp = bd;
388 /* Just fill in some known values.
390 bd->bi_baudrate = 9600;
392 /* Use default enet.
394 cp = (u_char *)def_enet_addr;
395 for (i=0; i<6; i++) {
396 bd->bi_enetaddr[i] = *cp++;
399 bd->bi_memstart = 0;
400 bd->bi_memsize = (8 * 1024 * 1024);
401 bd->bi_intfreq = 40000000;
402 bd->bi_busfreq = 40000000;
404 #endif /* FADS */
406 #ifdef CONFIG_8260
407 /* Compute 8260 clock values if the rom doesn't provide them.
409 static unsigned char bus2core_8260[] = {
410 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
411 3, 2, 2, 2, 4, 4, 5, 9, 6, 11, 8, 10, 3, 12, 7, 2,
412 6, 5, 13, 2, 14, 4, 15, 2, 3, 11, 8, 10, 16, 12, 7, 2,
415 static void
416 clk_8260(bd_t *bd)
418 uint scmr, vco_out, clkin;
419 uint plldf, pllmf, corecnf;
420 volatile cpm2_map_t *ip;
422 ip = (cpm2_map_t *)CPM_MAP_ADDR;
423 scmr = ip->im_clkrst.car_scmr;
425 /* The clkin is always bus frequency.
427 clkin = bd->bi_busfreq;
429 /* Collect the bits from the scmr.
431 plldf = (scmr >> 12) & 1;
432 pllmf = scmr & 0xfff;
433 corecnf = (scmr >> 24) &0x1f;
435 /* This is arithmetic from the 8260 manual.
437 vco_out = clkin / (plldf + 1);
438 vco_out *= 2 * (pllmf + 1);
439 bd->bi_vco = vco_out; /* Save for later */
441 bd->bi_cpmfreq = vco_out / 2; /* CPM Freq, in MHz */
442 bd->bi_intfreq = bd->bi_busfreq * bus2core_8260[corecnf] / 2;
444 /* Set Baud rate divisor. The power up default is divide by 16,
445 * but we set it again here in case it was changed.
447 ip->im_clkrst.car_sccr = 1; /* DIV 16 BRG */
448 bd->bi_brgfreq = vco_out / 16;
451 static unsigned char bus2core_8280[] = {
452 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
453 3, 2, 2, 2, 4, 4, 5, 9, 6, 11, 8, 10, 3, 12, 7, 2,
454 6, 5, 13, 2, 14, 2, 15, 2, 3, 2, 2, 2, 16, 2, 2, 2,
457 static void
458 clk_8280(bd_t *bd)
460 uint scmr, main_clk, clkin;
461 uint pllmf, corecnf;
462 volatile cpm2_map_t *ip;
464 ip = (cpm2_map_t *)CPM_MAP_ADDR;
465 scmr = ip->im_clkrst.car_scmr;
467 /* The clkin is always bus frequency.
469 clkin = bd->bi_busfreq;
471 /* Collect the bits from the scmr.
473 pllmf = scmr & 0xf;
474 corecnf = (scmr >> 24) & 0x1f;
476 /* This is arithmetic from the 8280 manual.
478 main_clk = clkin * (pllmf + 1);
480 bd->bi_cpmfreq = main_clk / 2; /* CPM Freq, in MHz */
481 bd->bi_intfreq = bd->bi_busfreq * bus2core_8280[corecnf] / 2;
483 /* Set Baud rate divisor. The power up default is divide by 16,
484 * but we set it again here in case it was changed.
486 ip->im_clkrst.car_sccr = (ip->im_clkrst.car_sccr & 0x3) | 0x1;
487 bd->bi_brgfreq = main_clk / 16;
489 #endif
491 #ifdef CONFIG_SBC82xx
492 void
493 embed_config(bd_t **bdp)
495 u_char *cp;
496 int i;
497 bd_t *bd;
498 unsigned long pvr;
500 bd = *bdp;
502 bd = &bdinfo;
503 *bdp = bd;
504 bd->bi_baudrate = 9600;
505 bd->bi_memsize = 256 * 1024 * 1024; /* just a guess */
507 cp = (void*)SBC82xx_MACADDR_NVRAM_SCC1;
508 memcpy(bd->bi_enetaddr, cp, 6);
510 /* can busfreq be calculated? */
511 pvr = mfspr(SPRN_PVR);
512 if ((pvr & 0xffff0000) == 0x80820000) {
513 bd->bi_busfreq = 100000000;
514 clk_8280(bd);
515 } else {
516 bd->bi_busfreq = 66000000;
517 clk_8260(bd);
521 #endif /* SBC82xx */
523 #if defined(CONFIG_EST8260) || defined(CONFIG_TQM8260)
524 void
525 embed_config(bd_t **bdp)
527 u_char *cp;
528 int i;
529 bd_t *bd;
531 bd = *bdp;
532 #if 0
533 /* This is actually provided by my boot rom. I have it
534 * here for those people that may load the kernel with
535 * a JTAG/COP tool and not the rom monitor.
537 bd->bi_baudrate = 115200;
538 bd->bi_intfreq = 200000000;
539 bd->bi_busfreq = 66666666;
540 bd->bi_cpmfreq = 66666666;
541 bd->bi_brgfreq = 33333333;
542 bd->bi_memsize = 16 * 1024 * 1024;
543 #else
544 /* The boot rom passes these to us in MHz. Linux now expects
545 * them to be in Hz.
547 bd->bi_intfreq *= 1000000;
548 bd->bi_busfreq *= 1000000;
549 bd->bi_cpmfreq *= 1000000;
550 bd->bi_brgfreq *= 1000000;
551 #endif
553 cp = (u_char *)def_enet_addr;
554 for (i=0; i<6; i++) {
555 bd->bi_enetaddr[i] = *cp++;
558 #endif /* EST8260 */
560 #ifdef CONFIG_SBS8260
561 void
562 embed_config(bd_t **bdp)
564 u_char *cp;
565 int i;
566 bd_t *bd;
568 /* This should provided by the boot rom.
570 bd = &bdinfo;
571 *bdp = bd;
572 bd->bi_baudrate = 9600;
573 bd->bi_memsize = 64 * 1024 * 1024;
575 /* Set all of the clocks. We have to know the speed of the
576 * external clock. The development board had 66 MHz.
578 bd->bi_busfreq = 66666666;
579 clk_8260(bd);
581 /* I don't know how to compute this yet.
583 bd->bi_intfreq = 133000000;
586 cp = (u_char *)def_enet_addr;
587 for (i=0; i<6; i++) {
588 bd->bi_enetaddr[i] = *cp++;
591 #endif /* SBS8260 */
593 #ifdef CONFIG_RPX8260
594 void
595 embed_config(bd_t **bdp)
597 u_char *cp, *keyvals;
598 int i;
599 bd_t *bd;
601 keyvals = (u_char *)*bdp;
603 bd = &bdinfo;
604 *bdp = bd;
606 /* This is almost identical to the RPX-Lite/Classic functions
607 * on the 8xx boards. It would be nice to have a key lookup
608 * function in a string, but the format of all of the fields
609 * is slightly different.
611 cp = keyvals;
612 for (;;) {
613 if (*cp == 'E') {
614 cp++;
615 if (*cp == 'A') {
616 cp += 2;
617 rpx_eth(bd, cp);
620 if (*cp == 'S') {
621 cp++;
622 if (*cp == 'B') {
623 cp += 2;
624 bd->bi_baudrate = rpx_baseten(cp);
627 if (*cp == 'D') {
628 cp++;
629 if (*cp == '1') {
630 cp += 2;
631 bd->bi_memsize = rpx_baseten(cp) * 1024 * 1024;
634 if (*cp == 'X') {
635 cp++;
636 if (*cp == 'T') {
637 cp += 2;
638 bd->bi_busfreq = rpx_baseten(cp);
641 if (*cp == 'N') {
642 cp++;
643 if (*cp == 'V') {
644 cp += 2;
645 bd->bi_nvsize = rpx_baseten(cp) * 1024 * 1024;
649 /* Scan to the end of the record.
651 while ((*cp != '\n') && (*cp != 0xff))
652 cp++;
654 /* If the next character is a 0 or ff, we are done.
656 cp++;
657 if ((*cp == 0) || (*cp == 0xff))
658 break;
660 bd->bi_memstart = 0;
662 /* The memory size includes both the 60x and local bus DRAM.
663 * I don't want to use the local bus DRAM for real memory,
664 * so subtract it out. It would be nice if they were separate
665 * keys.
667 bd->bi_memsize -= 32 * 1024 * 1024;
669 /* Set all of the clocks. We have to know the speed of the
670 * external clock.
672 clk_8260(bd);
674 /* I don't know how to compute this yet.
676 bd->bi_intfreq = 200000000;
678 #endif /* RPX6 for testing */
680 #ifdef CONFIG_ADS8260
681 void
682 embed_config(bd_t **bdp)
684 u_char *cp;
685 int i;
686 bd_t *bd;
688 /* This should provided by the boot rom.
690 bd = &bdinfo;
691 *bdp = bd;
692 bd->bi_baudrate = 9600;
693 bd->bi_memsize = 16 * 1024 * 1024;
695 /* Set all of the clocks. We have to know the speed of the
696 * external clock. The development board had 66 MHz.
698 bd->bi_busfreq = 66666666;
699 clk_8260(bd);
701 /* I don't know how to compute this yet.
703 bd->bi_intfreq = 200000000;
706 cp = (u_char *)def_enet_addr;
707 for (i=0; i<6; i++) {
708 bd->bi_enetaddr[i] = *cp++;
711 #endif /* ADS8260 */
713 #ifdef CONFIG_WILLOW
714 void
715 embed_config(bd_t **bdp)
717 u_char *cp;
718 int i;
719 bd_t *bd;
721 /* Willow has Open Firmware....I should learn how to get this
722 * information from it.
724 bd = &bdinfo;
725 *bdp = bd;
726 bd->bi_baudrate = 9600;
727 bd->bi_memsize = 32 * 1024 * 1024;
729 /* Set all of the clocks. We have to know the speed of the
730 * external clock. The development board had 66 MHz.
732 bd->bi_busfreq = 66666666;
733 clk_8260(bd);
735 /* I don't know how to compute this yet.
737 bd->bi_intfreq = 200000000;
740 cp = (u_char *)def_enet_addr;
741 for (i=0; i<6; i++) {
742 bd->bi_enetaddr[i] = *cp++;
745 #endif /* WILLOW */
747 #if defined(CONFIG_XILINX_ML300) || defined(CONFIG_XILINX_ML403)
748 void
749 embed_config(bd_t ** bdp)
751 static const unsigned long line_size = 32;
752 static const unsigned long congruence_classes = 256;
753 unsigned long addr;
754 unsigned long dccr;
755 bd_t *bd;
758 * Invalidate the data cache if the data cache is turned off.
759 * - The 405 core does not invalidate the data cache on power-up
760 * or reset but does turn off the data cache. We cannot assume
761 * that the cache contents are valid.
762 * - If the data cache is turned on this must have been done by
763 * a bootloader and we assume that the cache contents are
764 * valid.
766 __asm__("mfdccr %0": "=r" (dccr));
767 if (dccr == 0) {
768 for (addr = 0;
769 addr < (congruence_classes * line_size);
770 addr += line_size) {
771 __asm__("dccci 0,%0": :"b"(addr));
775 bd = &bdinfo;
776 *bdp = bd;
777 bd->bi_memsize = XPAR_DDR_0_SIZE;
778 bd->bi_intfreq = XPAR_CORE_CLOCK_FREQ_HZ;
779 bd->bi_busfreq = XPAR_PLB_CLOCK_FREQ_HZ;
780 bd->bi_pci_busfreq = XPAR_PCI_0_CLOCK_FREQ_HZ;
781 timebase_period_ns = 1000000000 / bd->bi_tbfreq;
782 /* see bi_tbfreq definition in arch/ppc/platforms/4xx/xilinx_ml300.h */
784 #endif /* CONFIG_XILINX_ML300 || CONFIG_XILINX_ML403 */
786 #ifdef CONFIG_IBM_OPENBIOS
787 /* This could possibly work for all treeboot roms.
789 #if defined(CONFIG_BUBINGA)
790 #define BOARD_INFO_VECTOR 0xFFF80B50 /* openbios 1.19 moved this vector down - armin */
791 #else
792 #define BOARD_INFO_VECTOR 0xFFFE0B50
793 #endif
795 void
796 embed_config(bd_t **bdp)
798 u_char *cp;
799 int i;
800 bd_t *bd, *treeboot_bd;
801 bd_t *(*get_board_info)(void) =
802 (bd_t *(*)(void))(*(unsigned long *)BOARD_INFO_VECTOR);
803 #if !defined(CONFIG_STB03xxx)
805 /* shut down the Ethernet controller that the boot rom
806 * sometimes leaves running.
808 mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR); /* 1st reset MAL */
809 while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* wait for the reset */
810 out_be32((volatile u32*)EMAC0_BASE,0x20000000); /* then reset EMAC */
811 #endif
813 bd = &bdinfo;
814 *bdp = bd;
815 if ((treeboot_bd = get_board_info()) != NULL) {
816 memcpy(bd, treeboot_bd, sizeof(bd_t));
818 else {
819 /* Hmmm...better try to stuff some defaults.
821 bd->bi_memsize = 16 * 1024 * 1024;
822 cp = (u_char *)def_enet_addr;
823 for (i=0; i<6; i++) {
824 /* I should probably put different ones here,
825 * hopefully only one is used.
827 bd->BD_EMAC_ADDR(0,i) = *cp;
829 #ifdef CONFIG_PCI
830 bd->bi_pci_enetaddr[i] = *cp++;
831 #endif
833 bd->bi_tbfreq = 200 * 1000 * 1000;
834 bd->bi_intfreq = 200000000;
835 bd->bi_busfreq = 100000000;
836 #ifdef CONFIG_PCI
837 bd->bi_pci_busfreq = 66666666;
838 #endif
840 /* Yeah, this look weird, but on Redwood 4 they are
841 * different object in the structure. Sincr Redwwood 5
842 * and Redwood 6 use OpenBIOS, it requires a special value.
844 #if defined(CONFIG_REDWOOD_5) || defined (CONFIG_REDWOOD_6)
845 bd->bi_tbfreq = 27 * 1000 * 1000;
846 #endif
847 timebase_period_ns = 1000000000 / bd->bi_tbfreq;
849 #endif /* CONFIG_IBM_OPENBIOS */
851 #ifdef CONFIG_EP405
852 #include <linux/serial_reg.h>
854 void
855 embed_config(bd_t **bdp)
857 u32 chcr0;
858 u_char *cp;
859 bd_t *bd;
861 /* Different versions of the PlanetCore firmware vary in how
862 they set up the serial port - in particular whether they
863 use the internal or external serial clock for UART0. Make
864 sure the UART is in a known state. */
865 /* FIXME: We should use the board's 11.0592MHz external serial
866 clock - it will be more accurate for serial rates. For
867 now, however the baud rates in ep405.h are for the internal
868 clock. */
869 chcr0 = mfdcr(DCRN_CHCR0);
870 if ( (chcr0 & 0x1fff) != 0x103e ) {
871 mtdcr(DCRN_CHCR0, (chcr0 & 0xffffe000) | 0x103e);
872 /* The following tricks serial_init() into resetting the baud rate */
873 writeb(0, UART0_IO_BASE + UART_LCR);
876 /* We haven't seen actual problems with the EP405 leaving the
877 * EMAC running (as we have on Walnut). But the registers
878 * suggest it may not be left completely quiescent. Reset it
879 * just to be sure. */
880 mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR); /* 1st reset MAL */
881 while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* wait for the reset */
882 out_be32((unsigned *)EMAC0_BASE,0x20000000); /* then reset EMAC */
884 bd = &bdinfo;
885 *bdp = bd;
886 #if 1
887 cp = (u_char *)0xF0000EE0;
888 for (;;) {
889 if (*cp == 'E') {
890 cp++;
891 if (*cp == 'A') {
892 cp += 2;
893 rpx_eth(bd, cp);
897 if (*cp == 'D') {
898 cp++;
899 if (*cp == '1') {
900 cp += 2;
901 rpx_memsize(bd, cp);
905 if (*cp == 'N') {
906 cp++;
907 if (*cp == 'V') {
908 cp += 2;
909 rpx_nvramsize(bd, cp);
912 while ((*cp != '\n') && (*cp != 0xff))
913 cp++;
915 cp++;
916 if ((*cp == 0) || (*cp == 0xff))
917 break;
919 bd->bi_intfreq = 200000000;
920 bd->bi_busfreq = 100000000;
921 bd->bi_pci_busfreq= 33000000 ;
922 #else
924 bd->bi_memsize = 64000000;
925 bd->bi_intfreq = 200000000;
926 bd->bi_busfreq = 100000000;
927 bd->bi_pci_busfreq= 33000000 ;
928 #endif
930 #endif