Commit 7c7a23bd5a0bc149d2edd665ec46381726b24e0c

Authored by wdenk
1 parent 1f53a41603

* Patch by Hans-Joerg Frieden, 06 Dec 2002

Fix misc problems with AmigaOne support

* Patch by Chris Hallinan, 3 Dec 2002:
  minor cleanup to the MPC8245 EPIC driver

* Patch by Pierre Aubert , 28 Nov 2002
  Add support for external (SIU) interrupts on MPC8xx

* Patch by Pierre Aubert , 28 Nov 2002
  Fix nested syscalls bug in standalone applications

* Patch by David Müller, 27 Nov 2002:
  fix output of "pciinfo" command for CardBus bridge devices.

* Fix bug in TQM8260 board detection - boards got stuck when board ID
  was not readable

Showing 30 changed files with 589 additions and 262 deletions Inline Diff

1 ====================================================================== 1 ======================================================================
2 Changes since for U-Boot 0.1.0: 2 Changes since for U-Boot 0.1.0:
3 ====================================================================== 3 ======================================================================
4 4
5 * Patch by Hans-Joerg Frieden, 06 Dec 2002
6 Fix misc problems with AmigaOne support
7
8 * Patch by Chris Hallinan, 3 Dec 2002:
9 minor cleanup to the MPC8245 EPIC driver
10
11 * Patch by Pierre Aubert , 28 Nov 2002
12 Add support for external (SIU) interrupts on MPC8xx
13
14 * Patch by Pierre Aubert , 28 Nov 2002
15 Fix nested syscalls bug in standalone applications
16
17 * Patch by David Müller, 27 Nov 2002:
18 fix output of "pciinfo" command for CardBus bridge devices.
19
20 * Fix bug in TQM8260 board detection - boards got stuck when board ID
21 was not readable
22
5 * Add LED indication for IDE activity on KUP4K board 23 * Add LED indication for IDE activity on KUP4K board
6 24
7 * Fix startup problems with VFD display on TRAB 25 * Fix startup problems with VFD display on TRAB
8 26
9 * Patch by Pierre Aubert, 20 Nov 2002 27 * Patch by Pierre Aubert, 20 Nov 2002
10 Add driver for Epson SED13806 graphic controller. 28 Add driver for Epson SED13806 graphic controller.
11 Add support for BMP logos in cfb_console driver. 29 Add support for BMP logos in cfb_console driver.
12 30
13 * Added support for both PCMCIA slots (at the same time!) on MPC8xx 31 * Added support for both PCMCIA slots (at the same time!) on MPC8xx
14 32
15 * Patch by Rod Boyce, 21 Nov 2002: 33 * Patch by Rod Boyce, 21 Nov 2002:
16 fix PCMCIA on MBX8xx board 34 fix PCMCIA on MBX8xx board
17 35
18 * Patch by Pierre Aubert , 21 Nov 2002 36 * Patch by Pierre Aubert , 21 Nov 2002
19 Add CFG_CPM_POST_WORD_ADDR to make the offset of the 37 Add CFG_CPM_POST_WORD_ADDR to make the offset of the
20 bootmode word in DPRAM configurable 38 bootmode word in DPRAM configurable
21 39
22 * Patch by Daniel Engström, 18 Nov 2002: 40 * Patch by Daniel Engström, 18 Nov 2002:
23 Fixes for x86 port (mostly strings issues) 41 Fixes for x86 port (mostly strings issues)
24 42
25 * Patch by Ken Chou, 18 Nov 2002: 43 * Patch by Ken Chou, 18 Nov 2002:
26 Fix for natsemi NIC cards (DP83815) 44 Fix for natsemi NIC cards (DP83815)
27 45
28 * Patch by Pierre Aubert, 19 Nov 2002: 46 * Patch by Pierre Aubert, 19 Nov 2002:
29 fix a bug for the MII configuration, and some warnings 47 fix a bug for the MII configuration, and some warnings
30 48
31 * Patch by Thomas Frieden, 13 Nov 2002: 49 * Patch by Thomas Frieden, 13 Nov 2002:
32 Add code for AmigaOne board 50 Add code for AmigaOne board
33 (preliminary merge to U-Boot, still WIP) 51 (preliminary merge to U-Boot, still WIP)
34 52
35 * Patch by Jon Diekema, 12 Nov 2002: 53 * Patch by Jon Diekema, 12 Nov 2002:
36 - Adding URL for IEEE OUI lookup 54 - Adding URL for IEEE OUI lookup
37 - Making the autoboot #defines dependent on CONFIG_AUTOBOOT_KEYED 55 - Making the autoboot #defines dependent on CONFIG_AUTOBOOT_KEYED
38 being defined. 56 being defined.
39 - In the CONFIG_EXTRA_ENV_SETTINGS #define, the root-on-initrd and 57 - In the CONFIG_EXTRA_ENV_SETTINGS #define, the root-on-initrd and
40 root-on-nfs macros are designed to switch how the default boot 58 root-on-nfs macros are designed to switch how the default boot
41 method gets defined. 59 method gets defined.
42 60
43 * Patch by Daniel Engström, 13 Nov 2002: 61 * Patch by Daniel Engström, 13 Nov 2002:
44 Add support for i386 architecture and AMD SC520 board 62 Add support for i386 architecture and AMD SC520 board
45 63
46 * Patch by Pierre Aubert, 12 Nov 2002: 64 * Patch by Pierre Aubert, 12 Nov 2002:
47 Add support for DOS filesystem and booting from DOS floppy disk 65 Add support for DOS filesystem and booting from DOS floppy disk
48 66
49 * Patch by Jim Sandoz, 07 Nov 2002: 67 * Patch by Jim Sandoz, 07 Nov 2002:
50 Increase number of network RX buffers (PKTBUFSRX in 68 Increase number of network RX buffers (PKTBUFSRX in
51 "include/net.h") for EEPRO100 based boards (especially SP8240) 69 "include/net.h") for EEPRO100 based boards (especially SP8240)
52 which showed "Receiver is not ready" errors when U-Boot was 70 which showed "Receiver is not ready" errors when U-Boot was
53 processing the receive buffers slower than the network controller 71 processing the receive buffers slower than the network controller
54 was filling them. 72 was filling them.
55 73
56 * Patch by Andreas Oberritter, 09 Nov 2002: 74 * Patch by Andreas Oberritter, 09 Nov 2002:
57 Change behaviour of NetLoop(): return -1 for errors, filesize 75 Change behaviour of NetLoop(): return -1 for errors, filesize
58 otherwise; return code 0 is valid an means no file loaded - in this 76 otherwise; return code 0 is valid an means no file loaded - in this
59 case the environment still gets updated! 77 case the environment still gets updated!
60 78
61 * Patches by Jon Diekema, 9 Nov 2002: 79 * Patches by Jon Diekema, 9 Nov 2002:
62 - improve ADC/DAC clocking on the SACSng board to align 80 - improve ADC/DAC clocking on the SACSng board to align
63 the failing edges of LRCLK and SCLK 81 the failing edges of LRCLK and SCLK
64 - sbc8260 configuration tweaks 82 - sbc8260 configuration tweaks
65 - add status LED support for 82xx systems 83 - add status LED support for 82xx systems
66 - wire sspi/sspo commands into command handler; improved error 84 - wire sspi/sspo commands into command handler; improved error
67 handlering 85 handlering
68 - add timestamp support and alternate memory test to the 86 - add timestamp support and alternate memory test to the
69 SACSng configuration 87 SACSng configuration
70 88
71 * Patch by Vince Husovsky, 7 Nov 2002: 89 * Patch by Vince Husovsky, 7 Nov 2002:
72 Add "-n" to linker options to get rid of "Not enough room for 90 Add "-n" to linker options to get rid of "Not enough room for
73 program headers" problem 91 program headers" problem
74 92
75 * Patch by David Müller, 05 Nov 2002 93 * Patch by David Müller, 05 Nov 2002
76 Rename CONFIG_PLL_INPUT_FREQ to CONFIG_SYS_CLK_FREQ 94 Rename CONFIG_PLL_INPUT_FREQ to CONFIG_SYS_CLK_FREQ
77 so we can use an already existing name 95 so we can use an already existing name
78 96
79 * Patch by Pierre Aubert, 05 Nov 2002 97 * Patch by Pierre Aubert, 05 Nov 2002
80 Hardware relatied improvments in FDC boot code 98 Hardware relatied improvments in FDC boot code
81 99
82 * Patch by Holger Schurig, 5 Nov 2002: 100 * Patch by Holger Schurig, 5 Nov 2002:
83 Make the PXA really change it's frequency 101 Make the PXA really change it's frequency
84 102
85 * Patch by Pierre Aubert, 05 Nov 2002 103 * Patch by Pierre Aubert, 05 Nov 2002
86 Add support for slave serial Spartan 2 FPGAs 104 Add support for slave serial Spartan 2 FPGAs
87 105
88 * Fix uninitialized memory (MAC address) in 8xx SCC/FEC ethernet 106 * Fix uninitialized memory (MAC address) in 8xx SCC/FEC ethernet
89 drivers 107 drivers
90 108
91 * Add support for log buffer which can be passed to Linux kernel's 109 * Add support for log buffer which can be passed to Linux kernel's
92 syslog mechanism; used especially for POST results. 110 syslog mechanism; used especially for POST results.
93 111
94 * Patch by Klaus Heydeck, 31 Oct 2002: 112 * Patch by Klaus Heydeck, 31 Oct 2002:
95 Add initial support for kup4k board 113 Add initial support for kup4k board
96 114
97 * Patch by Robert Schwebel, 04 Nov 2002: 115 * Patch by Robert Schwebel, 04 Nov 2002:
98 - use watchdog to reset PXA250 systems 116 - use watchdog to reset PXA250 systems
99 - added progress callbacks to (some of the) ARM code 117 - added progress callbacks to (some of the) ARM code
100 - update for Cogent CSB226 board 118 - update for Cogent CSB226 board
101 119
102 * Add support for FPS860 board 120 * Add support for FPS860 board
103 121
104 * Patch by Guillaume Alexandre,, 04 Nov 2002: 122 * Patch by Guillaume Alexandre,, 04 Nov 2002:
105 Improve PCI access on 32-bits Compact PCI bus 123 Improve PCI access on 32-bits Compact PCI bus
106 124
107 * Fix mdelay() on TRAB - this was still the debugging version with 125 * Fix mdelay() on TRAB - this was still the debugging version with
108 seconds instead of ms. 126 seconds instead of ms.
109 127
110 * Patch by Robert Schwebel, 1 Nov 2002: 128 * Patch by Robert Schwebel, 1 Nov 2002:
111 XScale related cleanup (affects all ARM boards) 129 XScale related cleanup (affects all ARM boards)
112 130
113 * Cleanup of names and README. 131 * Cleanup of names and README.
114 132
115 ====================================================================== 133 ======================================================================
116 Notes for U-Boot 0.1.0: 134 Notes for U-Boot 0.1.0:
117 ====================================================================== 135 ======================================================================
118 136
119 This is the initial version of "Das U-Boot", the Universal Boot Loader. 137 This is the initial version of "Das U-Boot", the Universal Boot Loader.
120 138
121 It is based on version 2.0.0 (the "Halloween Release") of PPCBoot. 139 It is based on version 2.0.0 (the "Halloween Release") of PPCBoot.
122 For information about the history of the project please see the 140 For information about the history of the project please see the
123 PPCBoot project page at http://sourceforge.net/projects/ppcboot 141 PPCBoot project page at http://sourceforge.net/projects/ppcboot
124 142
125 ====================================================================== 143 ======================================================================
126 144
board/MAI/AmigaOneG3SE/AmigaOneG3SE.c
1 /* 1 /*
2 * (C) Copyright 2002 2 * (C) Copyright 2002
3 * Hyperion Entertainment, ThomasF@hyperion-entertainment.com 3 * Hyperion Entertainment, ThomasF@hyperion-entertainment.com
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * 5 *
6 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
7 * project. 7 * project.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA 22 * MA 02111-1307 USA
23 */ 23 */
24 24
25 #include <common.h> 25 #include <common.h>
26 #include <command.h> 26 #include <command.h>
27 #include <pci.h> 27 #include <pci.h>
28 #include "articiaS.h" 28 #include "articiaS.h"
29 #include "memio.h" 29 #include "memio.h"
30 #include "via686.h" 30 #include "via686.h"
31 31
32 __asm(" .globl send_kb \n 32 __asm(" .globl send_kb \n
33 send_kb: \n 33 send_kb: \n
34 lis r9, 0xfe00 \n 34 lis r9, 0xfe00 \n
35 \n 35 \n
36 li r4, 0x10 # retries \n 36 li r4, 0x10 # retries \n
37 mtctr r4 \n 37 mtctr r4 \n
38 \n 38 \n
39 idle: \n 39 idle: \n
40 lbz r4, 0x64(r9) \n 40 lbz r4, 0x64(r9) \n
41 andi. r4, r4, 0x02 \n 41 andi. r4, r4, 0x02 \n
42 bne idle \n 42 bne idle \n
43 \n 43 \n
44 ready: \n 44 ready: \n
45 stb r3, 0x60(r9) \n 45 stb r3, 0x60(r9) \n
46 \n 46 \n
47 check: \n 47 check: \n
48 lbz r4, 0x64(r9) \n 48 lbz r4, 0x64(r9) \n
49 andi. r4, r4, 0x01 \n 49 andi. r4, r4, 0x01 \n
50 beq check \n 50 beq check \n
51 \n 51 \n
52 lbz r4, 0x60(r9) \n 52 lbz r4, 0x60(r9) \n
53 cmpwi r4, 0xfa \n 53 cmpwi r4, 0xfa \n
54 beq done \n 54 beq done \n
55 \n 55 \n
56 bdnz idle \n 56 bdnz idle \n
57 \n 57 \n
58 li r3, 0 \n 58 li r3, 0 \n
59 blr \n 59 blr \n
60 \n 60 \n
61 done: \n 61 done: \n
62 li r3, 1 \n 62 li r3, 1 \n
63 blr \n 63 blr \n
64 \n 64 \n
65 .globl test_kb \n 65 .globl test_kb \n
66 test_kb: \n 66 test_kb: \n
67 mflr r10 \n 67 mflr r10 \n
68 li r3, 0xed \n 68 li r3, 0xed \n
69 bl send_kb \n 69 bl send_kb \n
70 li r3, 0x01 \n 70 li r3, 0x01 \n
71 bl send_kb \n 71 bl send_kb \n
72 mtlr r10 \n 72 mtlr r10 \n
73 blr \n 73 blr \n
74 "); 74 ");
75 75
76 76
77 int checkboard (void) 77 int checkboard (void)
78 { 78 {
79 printf ("AmigaOneG3SE\n"); 79 printf ("Board: AmigaOneG3SE\n");
80 80 return 0;
81 return 1;
82 } 81 }
83 82
84 long initdram (int board_type) 83 long initdram (int board_type)
85 { 84 {
86 return articiaS_ram_init (); 85 return articiaS_ram_init ();
87 } 86 }
88 87
89 88
90 89
91 void after_reloc (ulong dest_addr) 90 void after_reloc (ulong dest_addr, gd_t *gd)
92 { 91 {
93 DECLARE_GLOBAL_DATA_PTR; 92 /* HJF: DECLARE_GLOBAL_DATA_PTR; */
94 93
95 board_init_r (gd, dest_addr); 94 board_init_r (gd, dest_addr);
96 } 95 }
97 96
98 97
99 int misc_init_r (void) 98 int misc_init_r (void)
100 { 99 {
101 extern pci_dev_t video_dev; 100 extern pci_dev_t video_dev;
102 extern void drv_video_init (void); 101 extern void drv_video_init (void);
103 102
104 if (video_dev != ~0) 103 if (video_dev != ~0)
105 drv_video_init (); 104 drv_video_init ();
106 105
107 return (0); 106 return (0);
108 } 107 }
109 108
110 109
111 void pci_init (void) 110 void pci_init (void)
112 { 111 {
113 #ifndef CONFIG_RAMBOOT 112 #ifndef CONFIG_RAMBOOT
114 articiaS_pci_init (); 113 articiaS_pci_init ();
115 #endif 114 #endif
116 } 115 }
117 116
board/MAI/AmigaOneG3SE/Makefile
1 # 1 #
2 # (C) Copyright 2002 2 # (C) Copyright 2002
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 # 4 #
5 # See file CREDITS for list of people who contributed to this 5 # See file CREDITS for list of people who contributed to this
6 # project. 6 # project.
7 # 7 #
8 # This program is free software; you can redistribute it and/or 8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as 9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of 10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version. 11 # the License, or (at your option) any later version.
12 # 12 #
13 # This program is distributed in the hope that it will be useful, 13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details. 16 # GNU General Public License for more details.
17 # 17 #
18 # You should have received a copy of the GNU General Public License 18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software 19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 # MA 02111-1307 USA 21 # MA 02111-1307 USA
22 # 22 #
23 23
24 include $(TOPDIR)/config.mk 24 include $(TOPDIR)/config.mk
25 25
26 LIB = lib$(BOARD).a 26 LIB = lib$(BOARD).a
27 27
28 COBJS = $(BOARD).o articiaS.o flash.o serial.o smbus.o articiaS_pci.o \ 28 COBJS = $(BOARD).o articiaS.o flash.o serial.o smbus.o articiaS_pci.o \
29 via686.o i8259.o ../bios_emulator/x86interface.o \ 29 via686.o i8259.o ../bios_emulator/x86interface.o \
30 ../bios_emulator/bios.o ../bios_emulator/glue.o \ 30 ../bios_emulator/bios.o ../bios_emulator/glue.o \
31 interrupts.o ps2kbd.o video.o usb_uhci.o enet.o \ 31 interrupts.o ps2kbd.o video.o usb_uhci.o enet.o \
32 ../menu/cmd_menu.o cmd_boota.o nvram.o 32 ../menu/cmd_menu.o cmd_boota.o nvram.o
33 33
34 AOBJS = board_asm_init.o memio.o 34 AOBJS = board_asm_init.o memio.o
35 35
36 OBJS = $(COBJS) $(AOBJS) 36 OBJS = $(COBJS) $(AOBJS)
37 37
38 ## FIXME !!! 38 EMUDIR = ../bios_emulator/scitech/src/x86emu/
39 # EMUOBJS = ../bios_emulator/scitech/src/x86emu/*.o 39 EMUOBJ = $(EMUDIR)decode.o $(EMUDIR)ops2.o $(EMUDIR)fpu.o $(EMUDIR)prim_ops.o \
40 $(EMUDIR)ops.o $(EMUDIR)sys.o
41 EMUSRC = $(EMUOBJ:.o=.c)
40 42
41 43 $(LIB): .depend $(OBJS) $(EMUSRC)
42 $(LIB): .depend $(OBJS) $(EMUOBJS) 44 make libx86emu.a -C ../bios_emulator/scitech/src/x86emu -f makefile.uboot CROSS_COMPILE=$(CROSS_COMPILE)
43 -rm $(LIB) 45 -rm $(LIB)
44 $(AR) crv $@ $(OBJS) $(EMUOBJS) 46 $(AR) crv $@ $(OBJS) $(EMUOBJ)
47
45 48
46 ######################################################################### 49 #########################################################################
47 50
48 .depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c) 51 .depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
49 $(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@ 52 $(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
50 53
51 sinclude .depend 54 sinclude .depend
52 55
53 ######################################################################### 56 #########################################################################
54 57
board/MAI/AmigaOneG3SE/articiaS.c
1 /* 1 /*
2 * (C) Copyright 2002 2 * (C) Copyright 2002
3 * Hyperion Entertainment, ThomasF@hyperion-entertainment.com 3 * Hyperion Entertainment, ThomasF@hyperion-entertainment.com
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 #include <common.h> 24 #include <common.h>
25 #include <pci.h> 25 #include <pci.h>
26 #include <asm/processor.h> 26 #include <asm/processor.h>
27 #include "memio.h" 27 #include "memio.h"
28 #include "articiaS.h" 28 #include "articiaS.h"
29 #include "smbus.h" 29 #include "smbus.h"
30 #include "via686.h" 30 #include "via686.h"
31 31
32 #undef DEBUG 32 #undef DEBUG
33 33
34 struct dimm_bank { 34 struct dimm_bank {
35 uint8 used; /* Bank is populated */ 35 uint8 used; /* Bank is populated */
36 uint32 rows; /* Number of row addresses */ 36 uint32 rows; /* Number of row addresses */
37 uint32 columns; /* Number of column addresses */ 37 uint32 columns; /* Number of column addresses */
38 uint8 registered; /* SIMM is registered */ 38 uint8 registered; /* SIMM is registered */
39 uint8 ecc; /* SIMM has ecc */ 39 uint8 ecc; /* SIMM has ecc */
40 uint8 burst_len; /* Supported burst lengths */ 40 uint8 burst_len; /* Supported burst lengths */
41 uint32 cas_lat; /* Supported CAS latencies */ 41 uint32 cas_lat; /* Supported CAS latencies */
42 uint32 cas_used; /* CAS to use (not set by user) */ 42 uint32 cas_used; /* CAS to use (not set by user) */
43 uint32 trcd; /* RAS to CAS latency */ 43 uint32 trcd; /* RAS to CAS latency */
44 uint32 trp; /* Precharge latency */ 44 uint32 trp; /* Precharge latency */
45 uint32 tclk_hi; /* SDRAM cycle time (highest CAS latency) */ 45 uint32 tclk_hi; /* SDRAM cycle time (highest CAS latency) */
46 uint32 tclk_2hi; /* SDRAM second highest CAS latency */ 46 uint32 tclk_2hi; /* SDRAM second highest CAS latency */
47 uint32 size; /* Size of bank in bytes */ 47 uint32 size; /* Size of bank in bytes */
48 uint8 auto_refresh; /* Module supports auto refresh */ 48 uint8 auto_refresh; /* Module supports auto refresh */
49 uint32 refresh_time; /* Refresh time (in ns) */ 49 uint32 refresh_time; /* Refresh time (in ns) */
50 }; 50 };
51 51
52 52
53 /* 53 /*
54 ** Based in part on the evb64260 code 54 ** Based in part on the evb64260 code
55 */ 55 */
56 56
57 /* 57 /*
58 * translate ns.ns/10 coding of SPD timing values 58 * translate ns.ns/10 coding of SPD timing values
59 * into 10 ps unit values 59 * into 10 ps unit values
60 */ 60 */
61 static inline unsigned short NS10to10PS (unsigned char spd_byte) 61 static inline unsigned short NS10to10PS (unsigned char spd_byte)
62 { 62 {
63 unsigned short ns, ns10; 63 unsigned short ns, ns10;
64 64
65 /* isolate upper nibble */ 65 /* isolate upper nibble */
66 ns = (spd_byte >> 4) & 0x0F; 66 ns = (spd_byte >> 4) & 0x0F;
67 /* isolate lower nibble */ 67 /* isolate lower nibble */
68 ns10 = (spd_byte & 0x0F); 68 ns10 = (spd_byte & 0x0F);
69 69
70 return (ns * 100 + ns10 * 10); 70 return (ns * 100 + ns10 * 10);
71 } 71 }
72 72
73 /* 73 /*
74 * translate ns coding of SPD timing values 74 * translate ns coding of SPD timing values
75 * into 10 ps unit values 75 * into 10 ps unit values
76 */ 76 */
77 static inline unsigned short NSto10PS (unsigned char spd_byte) 77 static inline unsigned short NSto10PS (unsigned char spd_byte)
78 { 78 {
79 return (spd_byte * 100); 79 return (spd_byte * 100);
80 } 80 }
81 81
82 82
83 long detect_sdram (uint8 * rom, int dimmNum, struct dimm_bank *banks) 83 long detect_sdram (uint8 * rom, int dimmNum, struct dimm_bank *banks)
84 { 84 {
85 DECLARE_GLOBAL_DATA_PTR;
85 int dimm_address = (dimmNum == 0) ? SM_DIMM0_ADDR : SM_DIMM1_ADDR; 86 int dimm_address = (dimmNum == 0) ? SM_DIMM0_ADDR : SM_DIMM1_ADDR;
86 uint32 busclock = get_bus_freq (0); 87 uint32 busclock = gd->bus_clk;
87 uint32 memclock = busclock; 88 uint32 memclock = busclock;
88 uint32 tmemclock = 1000000000 / (memclock / 100); 89 uint32 tmemclock = 1000000000 / (memclock / 100);
89 uint32 datawidth; 90 uint32 datawidth;
90 91
91 if (sm_get_data (rom, dimm_address) == 0) { 92 if (sm_get_data (rom, dimm_address) == 0) {
92 /* Nothing in slot, make both banks empty */ 93 /* Nothing in slot, make both banks empty */
93 debug ("Slot %d: vacant\n", dimmNum); 94 debug ("Slot %d: vacant\n", dimmNum);
94 banks[0].used = 0; 95 banks[0].used = 0;
95 banks[1].used = 0; 96 banks[1].used = 0;
96 return 0; 97 return 0;
97 } 98 }
98 99
99 if (rom[2] != 0x04) { 100 if (rom[2] != 0x04) {
100 debug ("Slot %d: No SDRAM\n", dimmNum); 101 debug ("Slot %d: No SDRAM\n", dimmNum);
101 banks[0].used = 0; 102 banks[0].used = 0;
102 banks[1].used = 0; 103 banks[1].used = 0;
103 return 0; 104 return 0;
104 } 105 }
105 106
106 /* Determine number of banks/rows */ 107 /* Determine number of banks/rows */
107 if (rom[5] == 1) { 108 if (rom[5] == 1) {
108 banks[0].used = 1; 109 banks[0].used = 1;
109 banks[1].used = 0; 110 banks[1].used = 0;
110 } else { 111 } else {
111 banks[0].used = 1; 112 banks[0].used = 1;
112 banks[1].used = 1; 113 banks[1].used = 1;
113 } 114 }
114 115
115 /* Determine number of row addresses */ 116 /* Determine number of row addresses */
116 if (rom[3] & 0xf0) { 117 if (rom[3] & 0xf0) {
117 /* Different banks sizes */ 118 /* Different banks sizes */
118 banks[0].rows = rom[3] & 0x0f; 119 banks[0].rows = rom[3] & 0x0f;
119 banks[1].rows = (rom[3] & 0xf0) >> 4; 120 banks[1].rows = (rom[3] & 0xf0) >> 4;
120 } else { 121 } else {
121 /* Equal sized banks */ 122 /* Equal sized banks */
122 banks[0].rows = rom[3] & 0x0f; 123 banks[0].rows = rom[3] & 0x0f;
123 banks[1].rows = banks[0].rows; 124 banks[1].rows = banks[0].rows;
124 } 125 }
125 126
126 /* Determine number of column addresses */ 127 /* Determine number of column addresses */
127 if (rom[4] & 0xf0) { 128 if (rom[4] & 0xf0) {
128 /* Different bank sizes */ 129 /* Different bank sizes */
129 banks[0].columns = rom[4] & 0x0f; 130 banks[0].columns = rom[4] & 0x0f;
130 banks[1].columns = (rom[4] & 0xf0) >> 4; 131 banks[1].columns = (rom[4] & 0xf0) >> 4;
131 } else { 132 } else {
132 banks[0].columns = rom[4] & 0x0f; 133 banks[0].columns = rom[4] & 0x0f;
133 banks[1].columns = banks[0].columns; 134 banks[1].columns = banks[0].columns;
134 } 135 }
135 136
136 /* Check Jedec revision, and modify row/column accordingly */ 137 /* Check Jedec revision, and modify row/column accordingly */
137 if (rom[62] > 0x10) { 138 if (rom[62] > 0x10) {
138 if (banks[0].rows <= 3) 139 if (banks[0].rows <= 3)
139 banks[0].rows += 15; 140 banks[0].rows += 15;
140 if (banks[1].rows <= 3) 141 if (banks[1].rows <= 3)
141 banks[1].rows += 15; 142 banks[1].rows += 15;
142 if (banks[0].columns <= 3) 143 if (banks[0].columns <= 3)
143 banks[0].columns += 15; 144 banks[0].columns += 15;
144 if (banks[0].columns <= 3) 145 if (banks[0].columns <= 3)
145 banks[0].columns += 15; 146 banks[0].columns += 15;
146 } 147 }
147 148
148 /* Check registered/unregisterd */ 149 /* Check registered/unregisterd */
149 if (rom[21] & 0x12) { 150 if (rom[21] & 0x12) {
150 banks[0].registered = 1; 151 banks[0].registered = 1;
151 banks[1].registered = 1; 152 banks[1].registered = 1;
152 } else { 153 } else {
153 banks[0].registered = 0; 154 banks[0].registered = 0;
154 banks[1].registered = 0; 155 banks[1].registered = 0;
155 } 156 }
156 157
157 #ifdef CONFIG_ECC 158 #ifdef CONFIG_ECC
158 /* Check parity/ECC */ 159 /* Check parity/ECC */
159 banks[0].ecc = (rom[11] == 0x02); 160 banks[0].ecc = (rom[11] == 0x02);
160 banks[1].ecc = (rom[11] == 0x02); 161 banks[1].ecc = (rom[11] == 0x02);
161 #endif 162 #endif
162 163
163 /* Find burst lengths supported */ 164 /* Find burst lengths supported */
164 banks[0].burst_len = rom[16] & 0x8f; 165 banks[0].burst_len = rom[16] & 0x8f;
165 banks[1].burst_len = rom[16] & 0x8f; 166 banks[1].burst_len = rom[16] & 0x8f;
166 167
167 /* Find possible cas latencies */ 168 /* Find possible cas latencies */
168 banks[0].cas_lat = rom[18] & 0x7F; 169 banks[0].cas_lat = rom[18] & 0x7F;
169 banks[1].cas_lat = rom[18] & 0x7F; 170 banks[1].cas_lat = rom[18] & 0x7F;
170 171
171 /* RAS/CAS latency */ 172 /* RAS/CAS latency */
172 banks[0].trcd = (NSto10PS (rom[29]) + (tmemclock - 1)) / tmemclock; 173 banks[0].trcd = (NSto10PS (rom[29]) + (tmemclock - 1)) / tmemclock;
173 banks[1].trcd = (NSto10PS (rom[29]) + (tmemclock - 1)) / tmemclock; 174 banks[1].trcd = (NSto10PS (rom[29]) + (tmemclock - 1)) / tmemclock;
174 175
175 /* Precharge latency */ 176 /* Precharge latency */
176 banks[0].trp = (NSto10PS (rom[27]) + (tmemclock - 1)) / tmemclock; 177 banks[0].trp = (NSto10PS (rom[27]) + (tmemclock - 1)) / tmemclock;
177 banks[1].trp = (NSto10PS (rom[27]) + (tmemclock - 1)) / tmemclock; 178 banks[1].trp = (NSto10PS (rom[27]) + (tmemclock - 1)) / tmemclock;
178 179
179 /* highest CAS latency */ 180 /* highest CAS latency */
180 banks[0].tclk_hi = NS10to10PS (rom[9]); 181 banks[0].tclk_hi = NS10to10PS (rom[9]);
181 banks[1].tclk_hi = NS10to10PS (rom[9]); 182 banks[1].tclk_hi = NS10to10PS (rom[9]);
182 183
183 /* second highest CAS latency */ 184 /* second highest CAS latency */
184 banks[0].tclk_2hi = NS10to10PS (rom[23]); 185 banks[0].tclk_2hi = NS10to10PS (rom[23]);
185 banks[1].tclk_2hi = NS10to10PS (rom[23]); 186 banks[1].tclk_2hi = NS10to10PS (rom[23]);
186 187
187 /* bank sizes */ 188 /* bank sizes */
188 datawidth = rom[13] & 0x7f; 189 datawidth = rom[13] & 0x7f;
189 banks[0].size = 190 banks[0].size =
190 (1L << (banks[0].rows + banks[0].columns)) * 191 (1L << (banks[0].rows + banks[0].columns)) *
191 /* FIXME datawidth */ 8 * rom[17]; 192 /* FIXME datawidth */ 8 * rom[17];
192 if (rom[13] & 0x80) 193 if (rom[13] & 0x80)
193 banks[1].size = 2 * banks[0].size; 194 banks[1].size = 2 * banks[0].size;
194 else 195 else
195 banks[1].size = (1L << (banks[1].rows + banks[1].columns)) * 196 banks[1].size = (1L << (banks[1].rows + banks[1].columns)) *
196 /* FIXME datawidth */ 8 * rom[17]; 197 /* FIXME datawidth */ 8 * rom[17];
197 198
198 /* Refresh */ 199 /* Refresh */
199 if (rom[12] & 0x80) { 200 if (rom[12] & 0x80) {
200 banks[0].auto_refresh = 1; 201 banks[0].auto_refresh = 1;
201 banks[1].auto_refresh = 1; 202 banks[1].auto_refresh = 1;
202 } else { 203 } else {
203 banks[0].auto_refresh = 0; 204 banks[0].auto_refresh = 0;
204 banks[1].auto_refresh = 0; 205 banks[1].auto_refresh = 0;
205 } 206 }
206 207
207 switch (rom[12] & 0x7f) { 208 switch (rom[12] & 0x7f) {
208 case 0: 209 case 0:
209 banks[0].refresh_time = (1562500 + (tmemclock - 1)) / tmemclock; 210 banks[0].refresh_time = (1562500 + (tmemclock - 1)) / tmemclock;
210 banks[1].refresh_time = (1562500 + (tmemclock - 1)) / tmemclock; 211 banks[1].refresh_time = (1562500 + (tmemclock - 1)) / tmemclock;
211 break; 212 break;
212 case 1: 213 case 1:
213 banks[0].refresh_time = (390600 + (tmemclock - 1)) / tmemclock; 214 banks[0].refresh_time = (390600 + (tmemclock - 1)) / tmemclock;
214 banks[1].refresh_time = (390600 + (tmemclock - 1)) / tmemclock; 215 banks[1].refresh_time = (390600 + (tmemclock - 1)) / tmemclock;
215 break; 216 break;
216 case 2: 217 case 2:
217 banks[0].refresh_time = (781200 + (tmemclock - 1)) / tmemclock; 218 banks[0].refresh_time = (781200 + (tmemclock - 1)) / tmemclock;
218 banks[1].refresh_time = (781200 + (tmemclock - 1)) / tmemclock; 219 banks[1].refresh_time = (781200 + (tmemclock - 1)) / tmemclock;
219 break; 220 break;
220 case 3: 221 case 3:
221 banks[0].refresh_time = (3125000 + (tmemclock - 1)) / tmemclock; 222 banks[0].refresh_time = (3125000 + (tmemclock - 1)) / tmemclock;
222 banks[1].refresh_time = (3125000 + (tmemclock - 1)) / tmemclock; 223 banks[1].refresh_time = (3125000 + (tmemclock - 1)) / tmemclock;
223 break; 224 break;
224 case 4: 225 case 4:
225 banks[0].refresh_time = (6250000 + (tmemclock - 1)) / tmemclock; 226 banks[0].refresh_time = (6250000 + (tmemclock - 1)) / tmemclock;
226 banks[1].refresh_time = (6250000 + (tmemclock - 1)) / tmemclock; 227 banks[1].refresh_time = (6250000 + (tmemclock - 1)) / tmemclock;
227 break; 228 break;
228 case 5: 229 case 5:
229 banks[0].refresh_time = (12500000 + (tmemclock - 1)) / tmemclock; 230 banks[0].refresh_time = (12500000 + (tmemclock - 1)) / tmemclock;
230 banks[1].refresh_time = (12500000 + (tmemclock - 1)) / tmemclock; 231 banks[1].refresh_time = (12500000 + (tmemclock - 1)) / tmemclock;
231 break; 232 break;
232 default: 233 default:
233 banks[0].refresh_time = 0x100; /* Default of Articia S */ 234 banks[0].refresh_time = 0x100; /* Default of Articia S */
234 banks[1].refresh_time = 0x100; 235 banks[1].refresh_time = 0x100;
235 break; 236 break;
236 } 237 }
237 238
238 #ifdef DEBUG 239 #ifdef DEBUG
239 printf ("\nInformation for SIMM bank %ld:\n", dimmNum); 240 printf ("\nInformation for SIMM bank %ld:\n", dimmNum);
240 printf ("Number of banks: %ld\n", banks[0].used + banks[1].used); 241 printf ("Number of banks: %ld\n", banks[0].used + banks[1].used);
241 printf ("Number of row addresses: %ld\n", banks[0].rows); 242 printf ("Number of row addresses: %ld\n", banks[0].rows);
242 printf ("Number of coumns addresses: %ld\n", banks[0].columns); 243 printf ("Number of coumns addresses: %ld\n", banks[0].columns);
243 printf ("SIMM is %sregistered\n", 244 printf ("SIMM is %sregistered\n",
244 banks[0].registered == 0 ? "not " : ""); 245 banks[0].registered == 0 ? "not " : "");
245 #ifdef CONFIG_ECC 246 #ifdef CONFIG_ECC
246 printf ("SIMM %s ECC\n", 247 printf ("SIMM %s ECC\n",
247 banks[0].ecc == 1 ? "supports" : "doesn't support"); 248 banks[0].ecc == 1 ? "supports" : "doesn't support");
248 #endif 249 #endif
249 printf ("Supported burst lenghts: %s %s %s %s %s\n", 250 printf ("Supported burst lenghts: %s %s %s %s %s\n",
250 banks[0].burst_len & 0x08 ? "8" : " ", 251 banks[0].burst_len & 0x08 ? "8" : " ",
251 banks[0].burst_len & 0x04 ? "4" : " ", 252 banks[0].burst_len & 0x04 ? "4" : " ",
252 banks[0].burst_len & 0x02 ? "2" : " ", 253 banks[0].burst_len & 0x02 ? "2" : " ",
253 banks[0].burst_len & 0x01 ? "1" : " ", 254 banks[0].burst_len & 0x01 ? "1" : " ",
254 banks[0].burst_len & 0x80 ? "PAGE" : " "); 255 banks[0].burst_len & 0x80 ? "PAGE" : " ");
255 printf ("Supported CAS latencies: %s %s %s\n", 256 printf ("Supported CAS latencies: %s %s %s\n",
256 banks[0].cas_lat & 0x04 ? "CAS 3" : " ", 257 banks[0].cas_lat & 0x04 ? "CAS 3" : " ",
257 banks[0].cas_lat & 0x02 ? "CAS 2" : " ", 258 banks[0].cas_lat & 0x02 ? "CAS 2" : " ",
258 banks[0].cas_lat & 0x01 ? "CAS 1" : " "); 259 banks[0].cas_lat & 0x01 ? "CAS 1" : " ");
259 printf ("RAS to CAS latency: %ld\n", banks[0].trcd); 260 printf ("RAS to CAS latency: %ld\n", banks[0].trcd);
260 printf ("Precharge latency: %ld\n", banks[0].trp); 261 printf ("Precharge latency: %ld\n", banks[0].trp);
261 printf ("SDRAM highest CAS latency: %ld\n", banks[0].tclk_hi); 262 printf ("SDRAM highest CAS latency: %ld\n", banks[0].tclk_hi);
262 printf ("SDRAM 2nd highest CAS latency: %ld\n", banks[0].tclk_2hi); 263 printf ("SDRAM 2nd highest CAS latency: %ld\n", banks[0].tclk_2hi);
263 printf ("SDRAM data width: %ld\n", datawidth); 264 printf ("SDRAM data width: %ld\n", datawidth);
264 printf ("Auto Refresh %ssupported\n", 265 printf ("Auto Refresh %ssupported\n",
265 banks[0].auto_refresh ? "" : "not "); 266 banks[0].auto_refresh ? "" : "not ");
266 printf ("Refresh time: %ld clocks\n", banks[0].refresh_time); 267 printf ("Refresh time: %ld clocks\n", banks[0].refresh_time);
267 if (banks[0].used) 268 if (banks[0].used)
268 printf ("Bank 0 size: %ld MB\n", banks[0].size / 1024 / 1024); 269 printf ("Bank 0 size: %ld MB\n", banks[0].size / 1024 / 1024);
269 if (banks[1].used) 270 if (banks[1].used)
270 printf ("Bank 1 size: %ld MB\n", banks[1].size / 1024 / 1024); 271 printf ("Bank 1 size: %ld MB\n", banks[1].size / 1024 / 1024);
271 272
272 printf ("\n"); 273 printf ("\n");
273 #endif 274 #endif
274 275
275 sm_term (); 276 sm_term ();
276 return 1; 277 return 1;
277 } 278 }
278 279
279 void select_cas (struct dimm_bank *banks, uint8 fast) 280 void select_cas (struct dimm_bank *banks, uint8 fast)
280 { 281 {
281 if (!banks[0].used) { 282 if (!banks[0].used) {
282 banks[0].cas_used = 0; 283 banks[0].cas_used = 0;
283 banks[0].cas_used = 0; 284 banks[0].cas_used = 0;
284 return; 285 return;
285 } 286 }
286 287
287 if (fast) { 288 if (fast) {
288 /* Search for fast CAS */ 289 /* Search for fast CAS */
289 uint32 i; 290 uint32 i;
290 uint32 c = 0x01; 291 uint32 c = 0x01;
291 292
292 for (i = 1; i < 5; i++) { 293 for (i = 1; i < 5; i++) {
293 if (banks[0].cas_lat & c) { 294 if (banks[0].cas_lat & c) {
294 banks[0].cas_used = i; 295 banks[0].cas_used = i;
295 banks[1].cas_used = i; 296 banks[1].cas_used = i;
296 debug ("Using CAS %d (fast)\n", i); 297 debug ("Using CAS %d (fast)\n", i);
297 return; 298 return;
298 } 299 }
299 c <<= 1; 300 c <<= 1;
300 } 301 }
301 302
302 /* Default to CAS 3 */ 303 /* Default to CAS 3 */
303 banks[0].cas_used = 3; 304 banks[0].cas_used = 3;
304 banks[1].cas_used = 3; 305 banks[1].cas_used = 3;
305 debug ("Using CAS 3 (fast)\n"); 306 debug ("Using CAS 3 (fast)\n");
306 307
307 return; 308 return;
308 } else { 309 } else {
309 /* Search for slow cas */ 310 /* Search for slow cas */
310 uint32 i; 311 uint32 i;
311 uint32 c = 0x08; 312 uint32 c = 0x08;
312 313
313 for (i = 4; i > 1; i--) { 314 for (i = 4; i > 1; i--) {
314 if (banks[0].cas_lat & c) { 315 if (banks[0].cas_lat & c) {
315 banks[0].cas_used = i; 316 banks[0].cas_used = i;
316 banks[1].cas_used = i; 317 banks[1].cas_used = i;
317 debug ("Using CAS %d (slow)\n", i); 318 debug ("Using CAS %d (slow)\n", i);
318 return; 319 return;
319 } 320 }
320 c >>= 1; 321 c >>= 1;
321 } 322 }
322 323
323 /* Default to CAS 3 */ 324 /* Default to CAS 3 */
324 banks[0].cas_used = 3; 325 banks[0].cas_used = 3;
325 banks[1].cas_used = 3; 326 banks[1].cas_used = 3;
326 debug ("Using CAS 3 (slow)\n"); 327 debug ("Using CAS 3 (slow)\n");
327 328
328 return; 329 return;
329 } 330 }
330 331
331 banks[0].cas_used = 3; 332 banks[0].cas_used = 3;
332 banks[1].cas_used = 3; 333 banks[1].cas_used = 3;
333 debug ("Using CAS 3\n"); 334 debug ("Using CAS 3\n");
334 335
335 return; 336 return;
336 } 337 }
337 338
338 uint32 get_reg_setting (uint32 banks, uint32 rows, uint32 columns, uint32 size) 339 uint32 get_reg_setting (uint32 banks, uint32 rows, uint32 columns, uint32 size)
339 { 340 {
340 uint32 i; 341 uint32 i;
341 342
342 struct RowColumnSize { 343 struct RowColumnSize {
343 uint32 banks; 344 uint32 banks;
344 uint32 rows; 345 uint32 rows;
345 uint32 columns; 346 uint32 columns;
346 uint32 size; 347 uint32 size;
347 uint32 register_value; 348 uint32 register_value;
348 }; 349 };
349 350
350 struct RowColumnSize rcs_map[] = { 351 struct RowColumnSize rcs_map[] = {
351 /* Sbk Radr Cadr MB Value */ 352 /* Sbk Radr Cadr MB Value */
352 {1, 11, 8, 8, 0x00840f00}, 353 {1, 11, 8, 8, 0x00840f00},
353 {1, 11, 9, 16, 0x00925f00}, 354 {1, 11, 9, 16, 0x00925f00},
354 {1, 11, 10, 32, 0x00a64f00}, 355 {1, 11, 10, 32, 0x00a64f00},
355 {2, 12, 8, 32, 0x00c55f00}, 356 {2, 12, 8, 32, 0x00c55f00},
356 {2, 12, 9, 64, 0x00d66f00}, 357 {2, 12, 9, 64, 0x00d66f00},
357 {2, 12, 10, 128, 0x00e77f00}, 358 {2, 12, 10, 128, 0x00e77f00},
358 {2, 12, 11, 256, 0x00ff8f00}, 359 {2, 12, 11, 256, 0x00ff8f00},
359 {2, 13, 11, 512, 0x00ff9f00}, 360 {2, 13, 11, 512, 0x00ff9f00},
360 {0, 0, 0, 0, 0x00000000} 361 {0, 0, 0, 0, 0x00000000}
361 }; 362 };
362 363
363 364
364 i = 0; 365 i = 0;
365 366
366 while (rcs_map[i].banks != 0) { 367 while (rcs_map[i].banks != 0) {
367 if (rows == rcs_map[i].rows 368 if (rows == rcs_map[i].rows
368 && columns == rcs_map[i].columns 369 && columns == rcs_map[i].columns
369 && (size / 1024 / 1024) == rcs_map[i].size) 370 && (size / 1024 / 1024) == rcs_map[i].size)
370 return rcs_map[i].register_value; 371 return rcs_map[i].register_value;
371 372
372 i++; 373 i++;
373 } 374 }
374 375
375 return 0; 376 return 0;
376 } 377 }
377 378
378 uint32 burst_to_len (uint32 support) 379 uint32 burst_to_len (uint32 support)
379 { 380 {
380 if (support & 0x80) 381 if (support & 0x80)
381 return 0x7; 382 return 0x7;
382 else if (support & 0x8) 383 else if (support & 0x8)
383 return 0x3; 384 return 0x3;
384 else if (support & 0x4) 385 else if (support & 0x4)
385 return 0x2; 386 return 0x2;
386 else if (support & 0x2) 387 else if (support & 0x2)
387 return 0x1; 388 return 0x1;
388 else if (support & 0x1) 389 else if (support & 0x1)
389 return 0x0; 390 return 0x0;
390 391
391 return 0; 392 return 0;
392 } 393 }
393 394
394 long articiaS_ram_init (void) 395 long articiaS_ram_init (void)
395 { 396 {
396 DECLARE_GLOBAL_DATA_PTR; 397 DECLARE_GLOBAL_DATA_PTR;
397 398
398 register uint32 i; 399 register uint32 i;
399 register uint32 value1; 400 register uint32 value1;
400 register uint32 value2; 401 register uint32 value2;
401 uint8 rom[128]; 402 uint8 rom[128];
402 uint32 burst_len; 403 uint32 burst_len;
403 uint32 burst_support; 404 uint32 burst_support;
404 uint32 total_ram = 0; 405 uint32 total_ram = 0;
405 406
406 struct dimm_bank banks[4]; /* FIXME: Move to initram */ 407 struct dimm_bank banks[4]; /* FIXME: Move to initram */
407 uint32 busclock = get_bus_freq (0); 408 uint32 busclock = gd->bus_clk;
408 uint32 memclock = busclock; 409 uint32 memclock = busclock;
409 uint32 reg32; 410 uint32 reg32;
410 uint32 refresh_clocks; 411 uint32 refresh_clocks;
411 uint8 auto_refresh; 412 uint8 auto_refresh;
412 413
413 memset (banks, 0, sizeof (struct dimm_bank) * 4); 414 memset (banks, 0, sizeof (struct dimm_bank) * 4);
414 415
415 detect_sdram (rom, 0, &banks[0]); 416 detect_sdram (rom, 0, &banks[0]);
416 detect_sdram (rom, 1, &banks[2]); 417 detect_sdram (rom, 1, &banks[2]);
417 418
418 for (i = 0; i < 4; i++) { 419 for (i = 0; i < 4; i++) {
419 total_ram = total_ram + (banks[i].used * banks[i].size); 420 total_ram = total_ram + (banks[i].used * banks[i].size);
420 } 421 }
421 422
422 pci_write_cfg_long (0, 0, GLOBALINFO0, 0x117430c0); 423 pci_write_cfg_long (0, 0, GLOBALINFO0, 0x117430c0);
423 pci_write_cfg_long (0, 0, HBUSACR0, 0x1f0100b0); 424 pci_write_cfg_long (0, 0, HBUSACR0, 0x1f0100b0);
424 pci_write_cfg_long (0, 0, SRAM_CR, 0x00f12000); /* Note: Might also try 0x00f10000 (original: 0x00f12000) */ 425 pci_write_cfg_long (0, 0, SRAM_CR, 0x00f12000); /* Note: Might also try 0x00f10000 (original: 0x00f12000) */
425 pci_write_cfg_byte (0, 0, DRAM_RAS_CTL0, 0x3f); 426 pci_write_cfg_byte (0, 0, DRAM_RAS_CTL0, 0x3f);
426 pci_write_cfg_byte (0, 0, DRAM_RAS_CTL1, 0x00); /* was: 0x04); */ 427 pci_write_cfg_byte (0, 0, DRAM_RAS_CTL1, 0x00); /* was: 0x04); */
427 pci_write_cfg_word (0, 0, DRAM_ECC0, 0x2020); /* was: 0x2400); No ECC yet */ 428 pci_write_cfg_word (0, 0, DRAM_ECC0, 0x2020); /* was: 0x2400); No ECC yet */
428 429
429 /* FIXME: Move this stuff to seperate function, like setup_dimm_bank */ 430 /* FIXME: Move this stuff to seperate function, like setup_dimm_bank */
430 if (banks[0].used) { 431 if (banks[0].used) {
431 value1 = get_reg_setting (banks[0].used + banks[1].used, 432 value1 = get_reg_setting (banks[0].used + banks[1].used,
432 banks[0].rows, banks[0].columns, 433 banks[0].rows, banks[0].columns,
433 banks[0].size); 434 banks[0].size);
434 } else { 435 } else {
435 value1 = 0; 436 value1 = 0;
436 } 437 }
437 438
438 if (banks[1].used) { 439 if (banks[1].used) {
439 value2 = get_reg_setting (banks[0].used + banks[1].used, 440 value2 = get_reg_setting (banks[0].used + banks[1].used,
440 banks[1].rows, banks[1].columns, 441 banks[1].rows, banks[1].columns,
441 banks[1].size); 442 banks[1].size);
442 } else { 443 } else {
443 value2 = 0; 444 value2 = 0;
444 } 445 }
445 446
446 pci_write_cfg_long (0, 0, DIMM0_B0_SCR0, value1); 447 pci_write_cfg_long (0, 0, DIMM0_B0_SCR0, value1);
447 pci_write_cfg_long (0, 0, DIMM0_B1_SCR0, value2); 448 pci_write_cfg_long (0, 0, DIMM0_B1_SCR0, value2);
448 449
449 debug ("DIMM0_B0_SCR0 = 0x%08x\n", value1); 450 debug ("DIMM0_B0_SCR0 = 0x%08x\n", value1);
450 debug ("DIMM0_B1_SCR0 = 0x%08x\n", value2); 451 debug ("DIMM0_B1_SCR0 = 0x%08x\n", value2);
451 452
452 if (banks[2].used) { 453 if (banks[2].used) {
453 value1 = get_reg_setting (banks[2].used + banks[3].used, 454 value1 = get_reg_setting (banks[2].used + banks[3].used,
454 banks[2].rows, banks[2].columns, 455 banks[2].rows, banks[2].columns,
455 banks[2].size); 456 banks[2].size);
456 } else { 457 } else {
457 value1 = 0; 458 value1 = 0;
458 } 459 }
459 460
460 if (banks[3].used) { 461 if (banks[3].used) {
461 value2 = get_reg_setting (banks[2].used + banks[3].used, 462 value2 = get_reg_setting (banks[2].used + banks[3].used,
462 banks[3].rows, banks[3].columns, 463 banks[3].rows, banks[3].columns,
463 banks[3].size); 464 banks[3].size);
464 } else { 465 } else {
465 value2 = 0; 466 value2 = 0;
466 } 467 }
467 468
468 pci_write_cfg_long (0, 0, DIMM1_B2_SCR0, value1); 469 pci_write_cfg_long (0, 0, DIMM1_B2_SCR0, value1);
469 pci_write_cfg_long (0, 0, DIMM1_B3_SCR0, value2); 470 pci_write_cfg_long (0, 0, DIMM1_B3_SCR0, value2);
470 471
471 debug ("DIMM0_B2_SCR0 = 0x%08x\n", value1); 472 debug ("DIMM0_B2_SCR0 = 0x%08x\n", value1);
472 debug ("DIMM0_B3_SCR0 = 0x%08x\n", value2); 473 debug ("DIMM0_B3_SCR0 = 0x%08x\n", value2);
473 474
474 pci_write_cfg_long (0, 0, DIMM2_B4_SCR0, 0); 475 pci_write_cfg_long (0, 0, DIMM2_B4_SCR0, 0);
475 pci_write_cfg_long (0, 0, DIMM2_B5_SCR0, 0); 476 pci_write_cfg_long (0, 0, DIMM2_B5_SCR0, 0);
476 pci_write_cfg_long (0, 0, DIMM3_B6_SCR0, 0); 477 pci_write_cfg_long (0, 0, DIMM3_B6_SCR0, 0);
477 pci_write_cfg_long (0, 0, DIMM3_B7_SCR0, 0); 478 pci_write_cfg_long (0, 0, DIMM3_B7_SCR0, 0);
478 479
479 /* Determine timing */ 480 /* Determine timing */
480 select_cas (&banks[0], 0); 481 select_cas (&banks[0], 0);
481 select_cas (&banks[2], 0); 482 select_cas (&banks[2], 0);
482 483
483 /* FIXME: What about write recovery */ 484 /* FIXME: What about write recovery */
484 /* Auto refresh Precharge */ 485 /* Auto refresh Precharge */
485 #if 0 486 #if 0
486 reg32 = (0x3 << 13) | (0x7 << 10) | ((banks[0].trp - 2) << 8) | 487 reg32 = (0x3 << 13) | (0x7 << 10) | ((banks[0].trp - 2) << 8) |
487 /* Write recovery CAS Latency */ 488 /* Write recovery CAS Latency */
488 (0x1 << 6) | (banks[0].cas_used << 4) | 489 (0x1 << 6) | (banks[0].cas_used << 4) |
489 /* RAS/CAS latency */ 490 /* RAS/CAS latency */
490 ((banks[0].trcd - 1) << 0); 491 ((banks[0].trcd - 1) << 0);
491 492
492 reg32 |= ((0x3 << 13) | (0x7 << 10) | ((banks[2].trp - 2) << 8) | 493 reg32 |= ((0x3 << 13) | (0x7 << 10) | ((banks[2].trp - 2) << 8) |
493 (0x1 << 6) | (banks[2].cas_used << 4) | 494 (0x1 << 6) | (banks[2].cas_used << 4) |
494 ((banks[2].trcd - 1) << 0)) << 16; 495 ((banks[2].trcd - 1) << 0)) << 16;
495 #else 496 #else
496 if (100000000 == gd->bus_clk) 497 if (100000000 == gd->bus_clk)
497 reg32 = 0x71737173; 498 reg32 = 0x71737173;
498 else 499 else
499 reg32 = 0x69736973; 500 reg32 = 0x69736973;
500 #endif 501 #endif
501 pci_write_cfg_long (0, 0, DIMM0_TCR0, reg32); 502 pci_write_cfg_long (0, 0, DIMM0_TCR0, reg32);
502 debug ("DIMM0_TCR0 = 0x%08x\n", reg32); 503 debug ("DIMM0_TCR0 = 0x%08x\n", reg32);
503 504
504 /* Write default in DIMM2/3 (not used on A1) */ 505 /* Write default in DIMM2/3 (not used on A1) */
505 pci_write_cfg_long (0, 0, DIMM2_TCR0, 0x7d737d73); 506 pci_write_cfg_long (0, 0, DIMM2_TCR0, 0x7d737d73);
506 507
507 508
508 /* Determine buffered/unbuffered mode for each SIMM. Uses first bank as reference (second, if present, uses the same) */ 509 /* Determine buffered/unbuffered mode for each SIMM. Uses first bank as reference (second, if present, uses the same) */
509 reg32 = pci_read_cfg_long (0, 0, DRAM_GCR0); 510 reg32 = pci_read_cfg_long (0, 0, DRAM_GCR0);
510 reg32 &= 0xFF00FFFF; 511 reg32 &= 0xFF00FFFF;
511 512
512 #if 0 513 #if 0
513 if (banks[0].used && banks[0].registered) 514 if (banks[0].used && banks[0].registered)
514 reg32 |= 0x1 << 16; 515 reg32 |= 0x1 << 16;
515 516
516 if (banks[2].used && banks[2].registered) 517 if (banks[2].used && banks[2].registered)
517 reg32 |= 0x1 << 18; 518 reg32 |= 0x1 << 18;
518 #else 519 #else
519 if (banks[0].registered || banks[2].registered) 520 if (banks[0].registered || banks[2].registered)
520 reg32 |= 0x55 << 16; 521 reg32 |= 0x55 << 16;
521 #endif 522 #endif
522 pci_write_cfg_long (0, 0, DRAM_GCR0, reg32); 523 pci_write_cfg_long (0, 0, DRAM_GCR0, reg32);
523 debug ("DRAM_GCR0 = 0x%08x\n", reg32); 524 debug ("DRAM_GCR0 = 0x%08x\n", reg32);
524 525
525 /* Determine refresh */ 526 /* Determine refresh */
526 refresh_clocks = 0xffffffff; 527 refresh_clocks = 0xffffffff;
527 auto_refresh = 1; 528 auto_refresh = 1;
528 529
529 for (i = 0; i < 4; i++) { 530 for (i = 0; i < 4; i++) {
530 if (banks[i].used) { 531 if (banks[i].used) {
531 if (banks[i].auto_refresh == 0) 532 if (banks[i].auto_refresh == 0)
532 auto_refresh = 0; 533 auto_refresh = 0;
533 if (banks[i].refresh_time < refresh_clocks) 534 if (banks[i].refresh_time < refresh_clocks)
534 refresh_clocks = banks[i].refresh_time; 535 refresh_clocks = banks[i].refresh_time;
535 } 536 }
536 } 537 }
537 538
538 539
539 #if 1 540 #if 1
540 /* It seems this is suggested by the ArticiaS data book */ 541 /* It seems this is suggested by the ArticiaS data book */
541 if (100000000 == gd->bus_clk) 542 if (100000000 == gd->bus_clk)
542 refresh_clocks = 1561; 543 refresh_clocks = 1561;
543 else 544 else
544 refresh_clocks = 2083; 545 refresh_clocks = 2083;
545 #endif 546 #endif
546 547
547 548
548 debug ("Refresh set to %ld clocks, auto refresh %s\n", 549 debug ("Refresh set to %ld clocks, auto refresh %s\n",
549 refresh_clocks, auto_refresh ? "on" : "off"); 550 refresh_clocks, auto_refresh ? "on" : "off");
550 551
551 pci_write_cfg_long (0, 0, DRAM_REFRESH0, 552 pci_write_cfg_long (0, 0, DRAM_REFRESH0,
552 (1 << 16) | (1 << 15) | (auto_refresh << 12) | 553 (1 << 16) | (1 << 15) | (auto_refresh << 12) |
553 (refresh_clocks)); 554 (refresh_clocks));
554 debug ("DRAM_REFRESH0 = 0x%08x\n", 555 debug ("DRAM_REFRESH0 = 0x%08x\n",
555 (1 << 16) | (1 << 15) | (auto_refresh << 12) | 556 (1 << 16) | (1 << 15) | (auto_refresh << 12) |
556 (refresh_clocks)); 557 (refresh_clocks));
557 558
558 /* pci_write_cfg_long(0, 0, DRAM_REFRESH0, 0x00019400); */ 559 /* pci_write_cfg_long(0, 0, DRAM_REFRESH0, 0x00019400); */
559 560
560 /* Set mode registers */ 561 /* Set mode registers */
561 /* FIXME: For now, set same burst len for all modules. Dunno if that's necessary */ 562 /* FIXME: For now, set same burst len for all modules. Dunno if that's necessary */
562 /* Find a common burst len */ 563 /* Find a common burst len */
563 burst_support = 0xff; 564 burst_support = 0xff;
564 565
565 if (banks[0].used) 566 if (banks[0].used)
566 burst_support = banks[0].burst_len; 567 burst_support = banks[0].burst_len;
567 if (banks[1].used) 568 if (banks[1].used)
568 burst_support = banks[1].burst_len; 569 burst_support = banks[1].burst_len;
569 if (banks[2].used) 570 if (banks[2].used)
570 burst_support = banks[2].burst_len; 571 burst_support = banks[2].burst_len;
571 if (banks[3].used) 572 if (banks[3].used)
572 burst_support = banks[3].burst_len; 573 burst_support = banks[3].burst_len;
573 574
574 /* 575 /*
575 ** Mode register: 576 ** Mode register:
576 ** Bits Use 577 ** Bits Use
577 ** 0-2 Burst len 578 ** 0-2 Burst len
578 ** 3 Burst type (0 = sequential, 1 = interleave) 579 ** 3 Burst type (0 = sequential, 1 = interleave)
579 ** 4-6 CAS latency 580 ** 4-6 CAS latency
580 ** 7-8 Operation mode (0 = default, all others invalid) 581 ** 7-8 Operation mode (0 = default, all others invalid)
581 ** 9 Write burst 582 ** 9 Write burst
582 ** 10-11 Reserved 583 ** 10-11 Reserved
583 ** 584 **
584 ** Mode register burst table: 585 ** Mode register burst table:
585 ** A2 A1 A0 lenght 586 ** A2 A1 A0 lenght
586 ** 0 0 0 1 587 ** 0 0 0 1
587 ** 0 0 1 2 588 ** 0 0 1 2
588 ** 0 1 0 4 589 ** 0 1 0 4
589 ** 0 1 1 8 590 ** 0 1 1 8
590 ** 1 0 0 invalid 591 ** 1 0 0 invalid
591 ** 1 0 1 invalid 592 ** 1 0 1 invalid
592 ** 1 1 0 invalid 593 ** 1 1 0 invalid
593 ** 1 1 1 page (only valid for non-interleaved) 594 ** 1 1 1 page (only valid for non-interleaved)
594 */ 595 */
595 596
596 burst_len = burst_to_len (burst_support); 597 burst_len = burst_to_len (burst_support);
597 burst_len = 2; /* FIXME */ 598 burst_len = 2; /* FIXME */
598 599
599 if (banks[0].used) { 600 if (banks[0].used) {
600 pci_write_cfg_word (0, 0, DRAM_PCR0, 601 pci_write_cfg_word (0, 0, DRAM_PCR0,
601 0x8000 | burst_len | (banks[0].cas_used << 4)); 602 0x8000 | burst_len | (banks[0].cas_used << 4));
602 debug ("Mode bank 0: 0x%08x\n", 603 debug ("Mode bank 0: 0x%08x\n",
603 0x8000 | burst_len | (banks[0].cas_used << 4)); 604 0x8000 | burst_len | (banks[0].cas_used << 4));
604 } else { 605 } else {
605 /* Seems to be needed to disable the bank */ 606 /* Seems to be needed to disable the bank */
606 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x0000 | 0x032); 607 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x0000 | 0x032);
607 } 608 }
608 609
609 if (banks[1].used) { 610 if (banks[1].used) {
610 pci_write_cfg_word (0, 0, DRAM_PCR0, 611 pci_write_cfg_word (0, 0, DRAM_PCR0,
611 0x9000 | burst_len | (banks[1].cas_used << 4)); 612 0x9000 | burst_len | (banks[1].cas_used << 4));
612 debug ("Mode bank 1: 0x%08x\n", 613 debug ("Mode bank 1: 0x%08x\n",
613 0x8000 | burst_len | (banks[1].cas_used << 4)); 614 0x8000 | burst_len | (banks[1].cas_used << 4));
614 } else { 615 } else {
615 /* Seems to be needed to disable the bank */ 616 /* Seems to be needed to disable the bank */
616 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x1000 | 0x032); 617 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x1000 | 0x032);
617 } 618 }
618 619
619 620
620 if (banks[2].used) { 621 if (banks[2].used) {
621 pci_write_cfg_word (0, 0, DRAM_PCR0, 622 pci_write_cfg_word (0, 0, DRAM_PCR0,
622 0xa000 | burst_len | (banks[2].cas_used << 4)); 623 0xa000 | burst_len | (banks[2].cas_used << 4));
623 debug ("Mode bank 2: 0x%08x\n", 624 debug ("Mode bank 2: 0x%08x\n",
624 0x8000 | burst_len | (banks[2].cas_used << 4)); 625 0x8000 | burst_len | (banks[2].cas_used << 4));
625 } else { 626 } else {
626 /* Seems to be needed to disable the bank */ 627 /* Seems to be needed to disable the bank */
627 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x2000 | 0x032); 628 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x2000 | 0x032);
628 } 629 }
629 630
630 631
631 if (banks[3].used) { 632 if (banks[3].used) {
632 pci_write_cfg_word (0, 0, DRAM_PCR0, 633 pci_write_cfg_word (0, 0, DRAM_PCR0,
633 0xb000 | burst_len | (banks[3].cas_used << 4)); 634 0xb000 | burst_len | (banks[3].cas_used << 4));
634 debug ("Mode bank 3: 0x%08x\n", 635 debug ("Mode bank 3: 0x%08x\n",
635 0x8000 | burst_len | (banks[3].cas_used << 4)); 636 0x8000 | burst_len | (banks[3].cas_used << 4));
636 } else { 637 } else {
637 /* Seems to be needed to disable the bank */ 638 /* Seems to be needed to disable the bank */
638 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x3000 | 0x032); 639 pci_write_cfg_word (0, 0, DRAM_PCR0, 0x3000 | 0x032);
639 } 640 }
640 641
641 642
642 pci_write_cfg_word (0, 0, 0xba, 0x00); 643 pci_write_cfg_word (0, 0, 0xba, 0x00);
643 644
644 return total_ram; 645 return total_ram;
645 } 646 }
646 647
647 extern int drv_isa_kbd_init (void); 648 extern int drv_isa_kbd_init (void);
648 649
649 int last_stage_init (void) 650 int last_stage_init (void)
650 { 651 {
651 drv_isa_kbd_init (); 652 drv_isa_kbd_init ();
652 return 0; 653 return 0;
653 } 654 }
654 655
655 int overwrite_console (void) 656 int overwrite_console (void)
656 { 657 {
657 return (0); 658 return (0);
658 } 659 }
659 660
660 #define in_8 read_byte 661 #define in_8 read_byte
661 #define out_8 write_byte 662 #define out_8 write_byte
662 663
663 static __inline__ unsigned long get_msr (void) 664 static __inline__ unsigned long get_msr (void)
664 { 665 {
665 unsigned long msr; 666 unsigned long msr;
666 667
667 asm volatile ("mfmsr %0":"=r" (msr):); 668 asm volatile ("mfmsr %0":"=r" (msr):);
668 669
669 return msr; 670 return msr;
670 } 671 }
671 672
672 static __inline__ void set_msr (unsigned long msr) 673 static __inline__ void set_msr (unsigned long msr)
673 { 674 {
674 asm volatile ("mtmsr %0"::"r" (msr)); 675 asm volatile ("mtmsr %0"::"r" (msr));
675 } 676 }
676 677
677 int board_pre_init (void) 678 int board_pre_init (void)
678 { 679 {
679 unsigned char c_value = 0; 680 unsigned char c_value = 0;
680 unsigned long msr; 681 unsigned long msr;
681 682
682 /* Basic init of PS/2 keyboard (needed for some reason)... */ 683 /* Basic init of PS/2 keyboard (needed for some reason)... */
683 /* Ripped from John's code */ 684 /* Ripped from John's code */
684 while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0); 685 while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0);
685 out_8 ((unsigned char *) 0xfe000064, 0xaa); 686 out_8 ((unsigned char *) 0xfe000064, 0xaa);
686 while ((in_8 ((unsigned char *) 0xfe000064) & 0x01) == 0); 687 while ((in_8 ((unsigned char *) 0xfe000064) & 0x01) == 0);
687 c_value = in_8 ((unsigned char *) 0xfe000060); 688 c_value = in_8 ((unsigned char *) 0xfe000060);
688 while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0); 689 while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0);
689 out_8 ((unsigned char *) 0xfe000064, 0xab); 690 out_8 ((unsigned char *) 0xfe000064, 0xab);
690 while ((in_8 ((unsigned char *) 0xfe000064) & 0x01) == 0); 691 while ((in_8 ((unsigned char *) 0xfe000064) & 0x01) == 0);
691 c_value = in_8 ((unsigned char *) 0xfe000060); 692 c_value = in_8 ((unsigned char *) 0xfe000060);
692 while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0); 693 while ((in_8 ((unsigned char *) 0xfe000064) & 0x02) != 0);
693 out_8 ((unsigned char *) 0xfe000064, 0xae); 694 out_8 ((unsigned char *) 0xfe000064, 0xae);
694 /* while ((in_8((unsigned char *)0xfe000064) & 0x01) == 0); */ 695 /* while ((in_8((unsigned char *)0xfe000064) & 0x01) == 0); */
695 /* c_value = in_8((unsigned char *)0xfe000060); */ 696 /* c_value = in_8((unsigned char *)0xfe000060); */
696 697
697 /* Enable FPU */ 698 /* Enable FPU */
698 msr = get_msr (); 699 msr = get_msr ();
699 set_msr (msr | MSR_FP); 700 set_msr (msr | MSR_FP);
700 701
701 via_calibrate_bus_freq (); 702 via_calibrate_bus_freq ();
702 703
703 return 0; 704 return 0;
704 } 705 }
705 706
board/MAI/AmigaOneG3SE/articiaS_pci.c
1 /* 1 /*
2 * (C) Copyright 2002 2 * (C) Copyright 2002
3 * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com 3 * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 #include <common.h> 24 #include <common.h>
25 #include <pci.h> 25 #include <pci.h>
26 #include "memio.h" 26 #include "memio.h"
27 #include "articiaS.h" 27 #include "articiaS.h"
28 28
29 //#define ARTICIA_PCI_DEBUG 29 #undef ARTICIA_PCI_DEBUG
30 30
31 #ifdef ARTICIA_PCI_DEBUG 31 #ifdef ARTICIA_PCI_DEBUG
32 #define PRINTF(fmt,args...) printf (fmt ,##args) 32 #define PRINTF(fmt,args...) printf (fmt ,##args)
33 #else 33 #else
34 #define PRINTF(fmt,args...) 34 #define PRINTF(fmt,args...)
35 #endif 35 #endif
36 36
37 struct pci_controller articiaS_hose; 37 struct pci_controller articiaS_hose;
38 38
39 long irq_alloc(long wanted); 39 long irq_alloc(long wanted);
40 40
41 static pci_dev_t pci_hose_find_class(struct pci_controller *hose, int bus, short find_class, int index); 41 static pci_dev_t pci_hose_find_class(struct pci_controller *hose, int bus, short find_class, int index);
42 static int articiaS_init_vga(void); 42 static int articiaS_init_vga(void);
43 static void pci_cfgfunc_dummy(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table); 43 static void pci_cfgfunc_dummy(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table);
44 unsigned char pci_irq_alloc(void); 44 unsigned char pci_irq_alloc(void);
45 45
46 extern void via_cfgfunc_via686(struct pci_controller * host, pci_dev_t dev, struct pci_config_table *table); 46 extern void via_cfgfunc_via686(struct pci_controller * host, pci_dev_t dev, struct pci_config_table *table);
47 extern void via_cfgfunc_ide_init(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table); 47 extern void via_cfgfunc_ide_init(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table);
48 extern void via_init_irq_routing(uint8 []); 48 extern void via_init_irq_routing(uint8 []);
49 extern void via_init_afterscan(void); 49 extern void via_init_afterscan(void);
50 50
51 #define cfgfunc_via686 1 51 #define cfgfunc_via686 1
52 #define cfgfunc_dummy 2 52 #define cfgfunc_dummy 2
53 #define cfgfunc_ide_init 3 53 #define cfgfunc_ide_init 3
54 54
55 static struct pci_config_table config_table[] = 55 static struct pci_config_table config_table[] =
56 { 56 {
57 { 57 {
58 0x1106, PCI_ANY_ID, PCI_CLASS_BRIDGE_ISA, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 58 0x1106, PCI_ANY_ID, PCI_CLASS_BRIDGE_ISA, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
59 (void *)cfgfunc_via686, {0, 0, 0} 59 (void *)cfgfunc_via686, {0, 0, 0}
60 }, 60 },
61 { 61 {
62 0x1106, PCI_ANY_ID, PCI_ANY_ID, 0,7,4, 62 0x1106, PCI_ANY_ID, PCI_ANY_ID, 0,7,4,
63 (void *)cfgfunc_dummy, {0,0,0} 63 (void *)cfgfunc_dummy, {0,0,0}
64 }, 64 },
65 { 65 {
66 0x1106, 0x3068, PCI_ANY_ID, 0, 7, PCI_ANY_ID, 66 0x1106, 0x3068, PCI_ANY_ID, 0, 7, PCI_ANY_ID,
67 (void *)cfgfunc_dummy, {0,0,0} 67 (void *)cfgfunc_dummy, {0,0,0}
68 }, 68 },
69 { 69 {
70 0x1106, PCI_ANY_ID, PCI_ANY_ID, 0,7,1, 70 0x1106, PCI_ANY_ID, PCI_ANY_ID, 0,7,1,
71 (void *)cfgfunc_ide_init, {0,0,0} 71 (void *)cfgfunc_ide_init, {0,0,0}
72 }, 72 },
73 { 73 {
74 0, 74 0,
75 } 75 }
76 }; 76 };
77 77
78 78
79 void pci_cfgfunc_dummy(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table) 79 void pci_cfgfunc_dummy(struct pci_controller *host, pci_dev_t dev, struct pci_config_table *table)
80 { 80 {
81 81
82 82
83 } 83 }
84 84
85 unsigned long irq_penalties[16] = 85 unsigned long irq_penalties[16] =
86 { 86 {
87 1000, /* 0:timer */ 87 1000, /* 0:timer */
88 1000, /* 1:keyboard */ 88 1000, /* 1:keyboard */
89 1000, /* 2:cascade */ 89 1000, /* 2:cascade */
90 50, /* 3:serial (COM2) */ 90 50, /* 3:serial (COM2) */
91 50, /* 4:serial (COM1) */ 91 50, /* 4:serial (COM1) */
92 4, /* 5:USB2 */ 92 4, /* 5:USB2 */
93 100, /* 6:floppy */ 93 100, /* 6:floppy */
94 3, /* 7:parallel */ 94 3, /* 7:parallel */
95 50, /* 8:AC97/MC97 */ 95 50, /* 8:AC97/MC97 */
96 0, /* 9: */ 96 0, /* 9: */
97 3, /* 10:: */ 97 3, /* 10:: */
98 0, /* 11: */ 98 0, /* 11: */
99 3, /* 12: USB1 */ 99 3, /* 12: USB1 */
100 0, /* 13: */ 100 0, /* 13: */
101 100, /* 14: ide0 */ 101 100, /* 14: ide0 */
102 100, /* 15: ide1 */ 102 100, /* 15: ide1 */
103 }; 103 };
104 104
105 105
106 /* 106 /*
107 * The following defines a hard-coded interrupt mapping for the 107 * The following defines a hard-coded interrupt mapping for the
108 * know devices on the board. 108 * know devices on the board.
109 * If a device isn't found here, assumed to be a device that's 109 * If a device isn't found here, assumed to be a device that's
110 * plugged into a PCI or AGP slot 110 * plugged into a PCI or AGP slot
111 * NOTE: This table is machine dependant. 111 * NOTE: This table is machine dependant.
112 */ 112 */
113 113
114 struct pci_irq_fixup_table 114 struct pci_irq_fixup_table
115 { 115 {
116 uint8 bus; /* Bus number */ 116 uint8 bus; /* Bus number */
117 uint8 device; /* Device number */ 117 uint8 device; /* Device number */
118 uint8 func; /* Function number */ 118 uint8 func; /* Function number */
119 uint8 interrupt; /* Interrupt to use (0xff to disable) */ 119 uint8 interrupt; /* Interrupt to use (0xff to disable) */
120 }; 120 };
121 121
122 struct pci_irq_fixup_table fixuptab [] = 122 struct pci_irq_fixup_table fixuptab [] =
123 { 123 {
124 { 0, 0, 0, 0xff}, /* Articia S host bridge */ 124 { 0, 0, 0, 0xff}, /* Articia S host bridge */
125 { 0, 1, 0, 0xff}, /* Articia S AGP bridge */ 125 { 0, 1, 0, 0xff}, /* Articia S AGP bridge */
126 // { 0, 6, 0, 0x05}, /* 3COM ethernet */ 126 // { 0, 6, 0, 0x05}, /* 3COM ethernet */
127 { 0, 7, 0, 0xff}, /* VIA southbridge */ 127 { 0, 7, 0, 0xff}, /* VIA southbridge */
128 { 0, 7, 1, 0x0e}, /* IDE controller in legacy mode */ 128 { 0, 7, 1, 0x0e}, /* IDE controller in legacy mode */
129 // { 0, 7, 2, 0x05}, /* First USB controller */ 129 // { 0, 7, 2, 0x05}, /* First USB controller */
130 // { 0, 7, 3, 0x0c}, /* Second USB controller (shares interrupt with ethernet) */ 130 // { 0, 7, 3, 0x0c}, /* Second USB controller (shares interrupt with ethernet) */
131 { 0, 7, 4, 0xff}, /* ACPI Power Management */ 131 { 0, 7, 4, 0xff}, /* ACPI Power Management */
132 // { 0, 7, 5, 0x08}, /* AC97 */ 132 // { 0, 7, 5, 0x08}, /* AC97 */
133 // { 0, 7, 6, 0x08}, /* MC97 */ 133 // { 0, 7, 6, 0x08}, /* MC97 */
134 { 0xff, 0xff, 0xff, 0xff} 134 { 0xff, 0xff, 0xff, 0xff}
135 }; 135 };
136 136
137 137
138 /* 138 /*
139 * This table maps IRQ's to PCI interrupts 139 * This table maps IRQ's to PCI interrupts
140 */ 140 */
141 141
142 uint8 pci_intmap[4] = {0, 0, 0, 0}; 142 uint8 pci_intmap[4] = {0, 0, 0, 0};
143 143
144 /* 144 /*
145 * Map PCI slots to interrupt routings 145 * Map PCI slots to interrupt routings
146 * This table lists the device number assigned to a card inserted 146 * This table lists the device number assigned to a card inserted
147 * into the slot, along with a permutation for the slot's IRQ routing. 147 * into the slot, along with a permutation for the slot's IRQ routing.
148 * NOTE: This table is machine dependant. 148 * NOTE: This table is machine dependant.
149 */ 149 */
150 150
151 struct pci_slot_irq_routing 151 struct pci_slot_irq_routing
152 { 152 {
153 uint8 bus; 153 uint8 bus;
154 uint8 device; 154 uint8 device;
155 155
156 uint8 ints[4]; 156 uint8 ints[4];
157 }; 157 };
158 158
159 struct pci_slot_irq_routing amigaone_pci_routing[] = 159 struct pci_slot_irq_routing amigaone_pci_routing[] =
160 { 160 {
161 {0, 8, {0, 1, 2, 3}}, /* Slot 1 (left of riser slot) */ 161 {0, 8, {0, 1, 2, 3}}, /* Slot 1 (left of riser slot) */
162 {0, 9, {1, 2, 3, 0}}, /* Slot 2 (middle slot) */ 162 {0, 9, {1, 2, 3, 0}}, /* Slot 2 (middle slot) */
163 {0, 10, {2, 3, 0, 1}}, /* Slot 3 (leftmost slot) */ 163 {0, 10, {2, 3, 0, 1}}, /* Slot 3 (leftmost slot) */
164 {1, 0, {1, 0, 2, 3}}, /* AGP slot (only IRQA and IRQB) */ 164 {1, 0, {1, 0, 2, 3}}, /* AGP slot (only IRQA and IRQB) */
165 {1, 1, {1, 2, 3, 0}}, /* PCI slot on AGP bus */ 165 {1, 1, {1, 2, 3, 0}}, /* PCI slot on AGP bus */
166 {0, 6, {3, 3, 3, 3}}, /* On board ethernet */ 166 {0, 6, {3, 3, 3, 3}}, /* On board ethernet */
167 {0, 7, {0, 1, 2, 3}}, /* Southbridge */ 167 {0, 7, {0, 1, 2, 3}}, /* Southbridge */
168 {0xff, 0, {0, 0, 0, 0}} 168 {0xff, 0, {0, 0, 0, 0}}
169 }; 169 };
170 170
171 void articiaS_pci_irq_init(void) 171 void articiaS_pci_irq_init(void)
172 { 172 {
173 char *s; 173 char *s;
174 174
175 s = getenv("pci_irqa"); 175 s = getenv("pci_irqa");
176 if (s) 176 if (s)
177 pci_intmap[0] = simple_strtoul (s, NULL, 10); 177 pci_intmap[0] = simple_strtoul (s, NULL, 10);
178 else 178 else
179 pci_intmap[0] = pci_irq_alloc(); 179 pci_intmap[0] = pci_irq_alloc();
180 180
181 s = getenv("pci_irqb"); 181 s = getenv("pci_irqb");
182 if (s) 182 if (s)
183 pci_intmap[1] = simple_strtoul (s, NULL, 10); 183 pci_intmap[1] = simple_strtoul (s, NULL, 10);
184 else 184 else
185 pci_intmap[1] = pci_irq_alloc(); 185 pci_intmap[1] = pci_irq_alloc();
186 186
187 s = getenv("pci_irqc"); 187 s = getenv("pci_irqc");
188 if (s) 188 if (s)
189 pci_intmap[2] = simple_strtoul (s, NULL, 10); 189 pci_intmap[2] = simple_strtoul (s, NULL, 10);
190 else 190 else
191 pci_intmap[2] = pci_irq_alloc(); 191 pci_intmap[2] = pci_irq_alloc();
192 192
193 s = getenv("pci_irqd"); 193 s = getenv("pci_irqd");
194 if (s) 194 if (s)
195 pci_intmap[3] = simple_strtoul (s, NULL, 10); 195 pci_intmap[3] = simple_strtoul (s, NULL, 10);
196 else 196 else
197 pci_intmap[3] = pci_irq_alloc(); 197 pci_intmap[3] = pci_irq_alloc();
198 } 198 }
199 199
200 200
201 unsigned char pci_irq_alloc(void) 201 unsigned char pci_irq_alloc(void)
202 { 202 {
203 int i; 203 int i;
204 int interrupt = 10; 204 int interrupt = 10;
205 unsigned long min_penalty = 1000; 205 unsigned long min_penalty = 1000;
206 206
207 /* Search for the minimal penalty, favoring interrupts at the end */ 207 /* Search for the minimal penalty, favoring interrupts at the end */
208 for (i = 0; i < 16; i++) 208 for (i = 0; i < 16; i++)
209 { 209 {
210 if (irq_penalties[i] <= min_penalty) 210 if (irq_penalties[i] <= min_penalty)
211 { 211 {
212 interrupt = i; 212 interrupt = i;
213 min_penalty = irq_penalties[i]; 213 min_penalty = irq_penalties[i];
214 } 214 }
215 } 215 }
216 216
217 PRINTF("pci_irq_alloc: Minimal penalty is %ld for %d\n", min_penalty, interrupt); 217 PRINTF("pci_irq_alloc: Minimal penalty is %ld for %d\n", min_penalty, interrupt);
218 218
219 irq_penalties[interrupt]++; 219 irq_penalties[interrupt]++;
220 220
221 return interrupt; 221 return interrupt;
222 } 222 }
223 223
224 224
225 void articiaS_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev) 225 void articiaS_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
226 { 226 {
227 int8 bus, device, func, pin, line; 227 int8 bus, device, func, pin, line;
228 int i; 228 int i;
229 229
230 bus = PCI_BUS(dev); 230 bus = PCI_BUS(dev);
231 device = PCI_DEV(dev); 231 device = PCI_DEV(dev);
232 func = PCI_FUNC(dev); 232 func = PCI_FUNC(dev);
233 233
234 PRINTF("Fixup irq of %d:%d.%d\n", bus, device, func); 234 PRINTF("Fixup irq of %d:%d.%d\n", bus, device, func);
235 235
236 /* Search for the device in the table */ 236 /* Search for the device in the table */
237 for (i = 0; fixuptab[i].bus != 0xff; i++) 237 for (i = 0; fixuptab[i].bus != 0xff; i++)
238 { 238 {
239 if (bus == fixuptab[i].bus && device == fixuptab[i].device && func == fixuptab[i].func) 239 if (bus == fixuptab[i].bus && device == fixuptab[i].device && func == fixuptab[i].func)
240 { 240 {
241 /* If the device needs an interrupt, write it */ 241 /* If the device needs an interrupt, write it */
242 if (fixuptab[i].interrupt != 0xff) 242 if (fixuptab[i].interrupt != 0xff)
243 { 243 {
244 PRINTF("Assigning IRQ %d (fixed)\n", fixuptab[i].interrupt); 244 PRINTF("Assigning IRQ %d (fixed)\n", fixuptab[i].interrupt);
245 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, fixuptab[i].interrupt); 245 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, fixuptab[i].interrupt);
246 } 246 }
247 else 247 else
248 { 248 {
249 /* Otherwise, see if it wants an interrupt, and disable it if needed */ 249 /* Otherwise, see if it wants an interrupt, and disable it if needed */
250 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 250 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
251 if (pin) 251 if (pin)
252 { 252 {
253 PRINTF("Disabling IRQ\n"); 253 PRINTF("Disabling IRQ\n");
254 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 0xff); 254 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 0xff);
255 } 255 }
256 } 256 }
257 257
258 return; 258 return;
259 } 259 }
260 } 260 }
261 261
262 /* If we get here, we have another PCI device in a slot... find the appropriate IRQ */ 262 /* If we get here, we have another PCI device in a slot... find the appropriate IRQ */
263 263
264 /* Find matching pin */ 264 /* Find matching pin */
265 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 265 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
266 pin--; 266 pin--;
267 267
268 /* Search for it's map */ 268 /* Search for it's map */
269 for (i = 0; amigaone_pci_routing[i].bus != 0xff; i++) 269 for (i = 0; amigaone_pci_routing[i].bus != 0xff; i++)
270 { 270 {
271 if (bus == amigaone_pci_routing[i].bus && device == amigaone_pci_routing[i].device) 271 if (bus == amigaone_pci_routing[i].bus && device == amigaone_pci_routing[i].device)
272 { 272 {
273 line = pci_intmap[amigaone_pci_routing[i].ints[pin]]; 273 line = pci_intmap[amigaone_pci_routing[i].ints[pin]];
274 PRINTF("Assigning IRQ %d (pin %d)\n", line, pin); 274 PRINTF("Assigning IRQ %d (pin %d)\n", line, pin);
275 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, line); 275 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, line);
276 return; 276 return;
277 } 277 }
278 } 278 }
279 279
280 PRINTF("Unkonwn PCI device found\n"); 280 PRINTF("Unkonwn PCI device found\n");
281 } 281 }
282 282
283 void articiaS_pci_init (void) 283 void articiaS_pci_init (void)
284 { 284 {
285 int i; 285 int i;
286 char *s; 286 char *s;
287 287
288 PRINTF("atriciaS_pci_init\n"); 288 PRINTF("atriciaS_pci_init\n");
289 289
290 // Why aren't these relocated?? 290 // Why aren't these relocated??
291 for (i=0; config_table[i].config_device; i++) 291 for (i=0; config_table[i].config_device; i++)
292 { 292 {
293 switch((int)config_table[i].config_device) 293 switch((int)config_table[i].config_device)
294 { 294 {
295 case cfgfunc_via686: config_table[i].config_device = via_cfgfunc_via686; break; 295 case cfgfunc_via686: config_table[i].config_device = via_cfgfunc_via686; break;
296 case cfgfunc_dummy: config_table[i].config_device = pci_cfgfunc_dummy; break; 296 case cfgfunc_dummy: config_table[i].config_device = pci_cfgfunc_dummy; break;
297 case cfgfunc_ide_init: config_table[i].config_device = via_cfgfunc_ide_init; break; 297 case cfgfunc_ide_init: config_table[i].config_device = via_cfgfunc_ide_init; break;
298 default: PRINTF("Error: Unknown constant\n"); 298 default: PRINTF("Error: Unknown constant\n");
299 } 299 }
300 } 300 }
301 301
302 articiaS_hose.first_busno = 0; 302 articiaS_hose.first_busno = 0;
303 articiaS_hose.last_busno = 0xff; 303 articiaS_hose.last_busno = 0xff;
304 articiaS_hose.config_table = config_table; 304 articiaS_hose.config_table = config_table;
305 articiaS_hose.fixup_irq = articiaS_pci_fixup_irq; 305 articiaS_hose.fixup_irq = articiaS_pci_fixup_irq;
306 306
307 articiaS_pci_irq_init(); 307 articiaS_pci_irq_init();
308 308
309 /* System memory */ 309 /* System memory */
310 pci_set_region(articiaS_hose.regions + 0, 310 pci_set_region(articiaS_hose.regions + 0,
311 ARTICIAS_SYS_BUS, 311 ARTICIAS_SYS_BUS,
312 ARTICIAS_SYS_PHYS, 312 ARTICIAS_SYS_PHYS,
313 ARTICIAS_SYS_MAXSIZE, 313 ARTICIAS_SYS_MAXSIZE,
314 PCI_REGION_MEM | PCI_REGION_MEMORY); 314 PCI_REGION_MEM | PCI_REGION_MEMORY);
315 315
316 /* PCI memory space */ 316 /* PCI memory space */
317 pci_set_region(articiaS_hose.regions + 1, 317 pci_set_region(articiaS_hose.regions + 1,
318 ARTICIAS_PCI_BUS, 318 ARTICIAS_PCI_BUS,
319 ARTICIAS_PCI_PHYS, 319 ARTICIAS_PCI_PHYS,
320 ARTICIAS_PCI_MAXSIZE, 320 ARTICIAS_PCI_MAXSIZE,
321 PCI_REGION_MEM); 321 PCI_REGION_MEM);
322 322
323 /* PCI io space */ 323 /* PCI io space */
324 pci_set_region(articiaS_hose.regions + 2, 324 pci_set_region(articiaS_hose.regions + 2,
325 ARTICIAS_PCIIO_BUS, 325 ARTICIAS_PCIIO_BUS,
326 ARTICIAS_PCIIO_PHYS, 326 ARTICIAS_PCIIO_PHYS,
327 ARTICIAS_PCIIO_MAXSIZE, 327 ARTICIAS_PCIIO_MAXSIZE,
328 PCI_REGION_IO); 328 PCI_REGION_IO);
329 329
330 /* PCI/ISA io space */ 330 /* PCI/ISA io space */
331 pci_set_region(articiaS_hose.regions + 3, 331 pci_set_region(articiaS_hose.regions + 3,
332 ARTICIAS_ISAIO_BUS, 332 ARTICIAS_ISAIO_BUS,
333 ARTICIAS_ISAIO_PHYS, 333 ARTICIAS_ISAIO_PHYS,
334 ARTICIAS_ISAIO_MAXSIZE, 334 ARTICIAS_ISAIO_MAXSIZE,
335 PCI_REGION_IO); 335 PCI_REGION_IO);
336 336
337 337
338 338
339 articiaS_hose.region_count = 4; 339 articiaS_hose.region_count = 4;
340 340
341 pci_setup_indirect(&articiaS_hose, ARTICIAS_PCI_CFGADDR, ARTICIAS_PCI_CFGDATA); 341 pci_setup_indirect(&articiaS_hose, ARTICIAS_PCI_CFGADDR, ARTICIAS_PCI_CFGDATA);
342 PRINTF("Registering articia hose...\n"); 342 PRINTF("Registering articia hose...\n");
343 pci_register_hose(&articiaS_hose); 343 pci_register_hose(&articiaS_hose);
344 PRINTF("Enabling AGP...\n"); 344 PRINTF("Enabling AGP...\n");
345 pci_write_config_byte(PCI_BDF(0,0,0), 0x58, 0x01); 345 pci_write_config_byte(PCI_BDF(0,0,0), 0x58, 0x01);
346 PRINTF("Scanning bus...\n"); 346 PRINTF("Scanning bus...\n");
347 articiaS_hose.last_busno = pci_hose_scan(&articiaS_hose); 347 articiaS_hose.last_busno = pci_hose_scan(&articiaS_hose);
348 348
349 via_init_irq_routing(pci_intmap); 349 via_init_irq_routing(pci_intmap);
350 350
351 PRINTF("After-Scan results:\n"); 351 PRINTF("After-Scan results:\n");
352 PRINTF("Bus range: %d - %d\n", articiaS_hose.first_busno , articiaS_hose.last_busno); 352 PRINTF("Bus range: %d - %d\n", articiaS_hose.first_busno , articiaS_hose.last_busno);
353 353
354 via_init_afterscan(); 354 via_init_afterscan();
355 355
356 pci_write_config_byte(PCI_BDF(0,1,0), PCI_INTERRUPT_LINE, 0xFF); 356 pci_write_config_byte(PCI_BDF(0,1,0), PCI_INTERRUPT_LINE, 0xFF);
357 357
358 s = getenv("as_irq"); 358 s = getenv("as_irq");
359 if (s) 359 if (s)
360 { 360 {
361 pci_write_config_byte(PCI_BDF(0,0,0), PCI_INTERRUPT_LINE, simple_strtoul (s, NULL, 10)); 361 pci_write_config_byte(PCI_BDF(0,0,0), PCI_INTERRUPT_LINE, simple_strtoul (s, NULL, 10));
362 } 362 }
363 363
364 s = getenv("x86_run_bios"); 364 s = getenv("x86_run_bios");
365 if (!s || (s && strcmp(s, "on")==0)) 365 if (!s || (s && strcmp(s, "on")==0))
366 { 366 {
367 if (articiaS_init_vga() == -1) 367 if (articiaS_init_vga() == -1)
368 { 368 {
369 /* If the VGA didn't init and we have stdout set to VGA, reset to serial */ 369 /* If the VGA didn't init and we have stdout set to VGA, reset to serial */
370 /* s = getenv("stdout"); */ 370 /* s = getenv("stdout"); */
371 /* if (s && strcmp(s, "vga") == 0) */ 371 /* if (s && strcmp(s, "vga") == 0) */
372 /* { */ 372 /* { */
373 /* setenv("stdout", "serial"); */ 373 /* setenv("stdout", "serial"); */
374 /* } */ 374 /* } */
375 } 375 }
376 } 376 }
377 pci_write_config_byte(PCI_BDF(0,1,0), PCI_INTERRUPT_LINE, 0xFF); 377 pci_write_config_byte(PCI_BDF(0,1,0), PCI_INTERRUPT_LINE, 0xFF);
378 378
379 } 379 }
380 380
381 pci_dev_t pci_hose_find_class(struct pci_controller *hose, int bus, short find_class, int index) 381 pci_dev_t pci_hose_find_class(struct pci_controller *hose, int bus, short find_class, int index)
382 { 382 {
383 unsigned int sub_bus, found_multi=0; 383 unsigned int sub_bus, found_multi=0;
384 unsigned short vendor, class; 384 unsigned short vendor, class;
385 unsigned char header_type; 385 unsigned char header_type;
386 pci_dev_t dev; 386 pci_dev_t dev;
387 u8 c1, c2; 387 u8 c1, c2;
388 388
389 sub_bus = bus; 389 sub_bus = bus;
390 390
391 for (dev = PCI_BDF(bus,0,0); 391 for (dev = PCI_BDF(bus,0,0);
392 dev < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1); 392 dev < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1);
393 dev += PCI_BDF(0,0,1)) 393 dev += PCI_BDF(0,0,1))
394 { 394 {
395 if ( dev == PCI_BDF(hose->first_busno,0,0) ) 395 if ( dev == PCI_BDF(hose->first_busno,0,0) )
396 continue; 396 continue;
397 397
398 if (PCI_FUNC(dev) && !found_multi) 398 if (PCI_FUNC(dev) && !found_multi)
399 continue; 399 continue;
400 400
401 pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type); 401 pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type);
402 402
403 pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor); 403 pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor);
404 404
405 if (vendor != 0xffff && vendor != 0x0000) 405 if (vendor != 0xffff && vendor != 0x0000)
406 { 406 {
407 407
408 if (!PCI_FUNC(dev)) 408 if (!PCI_FUNC(dev))
409 found_multi = header_type & 0x80; 409 found_multi = header_type & 0x80;
410 pci_hose_read_config_byte(hose, dev, 0x0B, &c1); 410 pci_hose_read_config_byte(hose, dev, 0x0B, &c1);
411 pci_hose_read_config_byte(hose, dev, 0x0A, &c2); 411 pci_hose_read_config_byte(hose, dev, 0x0A, &c2);
412 class = c1<<8 | c2; 412 class = c1<<8 | c2;
413 //printf("At %02x:%02x:%02x: class %x\n", 413 //printf("At %02x:%02x:%02x: class %x\n",
414 // PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), class); 414 // PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev), class);
415 if (class == find_class) 415 if (class == find_class)
416 { 416 {
417 if (index == 0) 417 if (index == 0)
418 return dev; 418 return dev;
419 else index--; 419 else index--;
420 } 420 }
421 } 421 }
422 } 422 }
423 423
424 return ~0; 424 return ~0;
425 } 425 }
426 426
427 427
428 /* 428 /*
429 * For a given bus number, find the bridge on this hose that provides this 429 * For a given bus number, find the bridge on this hose that provides this
430 * bus number. The function scans for bridges and peeks config space offset 430 * bus number. The function scans for bridges and peeks config space offset
431 * 0x19 (PCI_SECONDARY_BUS). 431 * 0x19 (PCI_SECONDARY_BUS).
432 */ 432 */
433 pci_dev_t pci_find_bridge_for_bus(struct pci_controller *hose, int busnr) 433 pci_dev_t pci_find_bridge_for_bus(struct pci_controller *hose, int busnr)
434 { 434 {
435 pci_dev_t dev; 435 pci_dev_t dev;
436 int bus; 436 int bus;
437 unsigned int found_multi=0; 437 unsigned int found_multi=0;
438 unsigned char header_type; 438 unsigned char header_type;
439 unsigned short vendor; 439 unsigned short vendor;
440 unsigned char secondary_bus; 440 unsigned char secondary_bus;
441 441
442 if (hose == NULL) hose = &articiaS_hose; 442 if (hose == NULL) hose = &articiaS_hose;
443 443
444 if (busnr < hose->first_busno || busnr > hose->last_busno) return PCI_ANY_ID; // Not in range 444 if (busnr < hose->first_busno || busnr > hose->last_busno) return PCI_ANY_ID; // Not in range
445 445
446 /* 446 /*
447 * The bridge must be on a lower bus number 447 * The bridge must be on a lower bus number
448 */ 448 */
449 for (bus = hose->first_busno; bus < busnr; bus++) 449 for (bus = hose->first_busno; bus < busnr; bus++)
450 { 450 {
451 for (dev = PCI_BDF(bus,0,0); 451 for (dev = PCI_BDF(bus,0,0);
452 dev < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1); 452 dev < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1);
453 dev += PCI_BDF(0,0,1)) 453 dev += PCI_BDF(0,0,1))
454 { 454 {
455 if ( dev == PCI_BDF(hose->first_busno,0,0) ) 455 if ( dev == PCI_BDF(hose->first_busno,0,0) )
456 continue; 456 continue;
457 457
458 if (PCI_FUNC(dev) && !found_multi) 458 if (PCI_FUNC(dev) && !found_multi)
459 continue; 459 continue;
460 460
461 pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type); 461 pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type);
462 462
463 pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor); 463 pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor);
464 464
465 if (vendor != 0xffff && vendor != 0x0000) 465 if (vendor != 0xffff && vendor != 0x0000)
466 { 466 {
467 467
468 if (!PCI_FUNC(dev)) 468 if (!PCI_FUNC(dev))
469 found_multi = header_type & 0x80; 469 found_multi = header_type & 0x80;
470 if (header_type == 1) // Bridge device header 470 if (header_type == 1) // Bridge device header
471 { 471 {
472 pci_hose_read_config_byte(hose, dev, PCI_SECONDARY_BUS, &secondary_bus); 472 pci_hose_read_config_byte(hose, dev, PCI_SECONDARY_BUS, &secondary_bus);
473 if ((int)secondary_bus == busnr) return dev; 473 if ((int)secondary_bus == busnr) return dev;
474 } 474 }
475 475
476 } 476 }
477 } 477 }
478 } 478 }
479 return PCI_ANY_ID; 479 return PCI_ANY_ID;
480 } 480 }
481 481
482 static short classes[] = 482 static short classes[] =
483 { 483 {
484 PCI_CLASS_DISPLAY_VGA, 484 PCI_CLASS_DISPLAY_VGA,
485 PCI_CLASS_DISPLAY_XGA, 485 PCI_CLASS_DISPLAY_XGA,
486 PCI_CLASS_DISPLAY_3D, 486 PCI_CLASS_DISPLAY_3D,
487 PCI_CLASS_DISPLAY_OTHER, 487 PCI_CLASS_DISPLAY_OTHER,
488 ~0 488 ~0
489 }; 489 };
490 490
491 extern int execute_bios(pci_dev_t gr_dev, void *); 491 extern int execute_bios(pci_dev_t gr_dev, void *);
492 492
493 pci_dev_t video_dev; 493 pci_dev_t video_dev;
494 494
495 int articiaS_init_vga (void) 495 int articiaS_init_vga (void)
496 { 496 {
497 DECLARE_GLOBAL_DATA_PTR; 497 DECLARE_GLOBAL_DATA_PTR;
498 498
499 extern void shutdown_bios(void); 499 extern void shutdown_bios(void);
500 pci_dev_t dev = ~0; 500 pci_dev_t dev = ~0;
501 int busnr = 0; 501 int busnr = 0;
502 int classnr = 0; 502 int classnr = 0;
503 503
504 video_dev = PCI_ANY_ID; 504 video_dev = PCI_ANY_ID;
505 505
506 printf("VGA: "); 506 printf("VGA: ");
507 507
508 PRINTF("Trying to initialize x86 VGA Card(s)\n"); 508 PRINTF("Trying to initialize x86 VGA Card(s)\n");
509 509
510 while (dev == ~0) 510 while (dev == ~0)
511 { 511 {
512 PRINTF("Searching for class 0x%x on bus %d\n", classes[classnr], busnr); 512 PRINTF("Searching for class 0x%x on bus %d\n", classes[classnr], busnr);
513 /* Find the first of this class on this bus */ 513 /* Find the first of this class on this bus */
514 dev = pci_hose_find_class(&articiaS_hose, busnr, classes[classnr], 0); 514 dev = pci_hose_find_class(&articiaS_hose, busnr, classes[classnr], 0);
515 if (dev != ~0) break; 515 if (dev != ~0)
516 {
517 PRINTF("Found VGA Card at %02x:%02x:%02x\n", PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev));
518 break;
519 }
516 busnr++; 520 busnr++;
517 if (busnr > articiaS_hose.last_busno) 521 if (busnr > articiaS_hose.last_busno)
518 { 522 {
519 busnr = 0; 523 busnr = 0;
520 classnr ++; 524 classnr ++;
521 if (classes[classnr] == ~0) 525 if (classes[classnr] == ~0)
522 { 526 {
523 printf("NOT PRESENT\n"); 527 printf("NOT PRESENT\n");
524 return -1; 528 return -1;
525 } 529 }
526 } 530 }
527 } 531 }
528 532
529 /* 533 /*
530 * If we get here we have found the first graphics card. 534 * If we get here we have found the first graphics card.
531 * If the bus number is not 0, then it is probably behind a bridge, and the 535 * If the bus number is not 0, then it is probably behind a bridge, and the
532 * bridge needs to be told to forward VGA access. 536 * bridge needs to be told to forward VGA access.
533 */ 537 */
534 538
535 if (PCI_BUS(dev) != 0) 539 if (PCI_BUS(dev) != 0)
536 { 540 {
537 pci_dev_t bridge; 541 pci_dev_t bridge;
538 PRINTF("Behind bridge, looking for bridge\n"); 542 PRINTF("Behind bridge, looking for bridge\n");
539 bridge = pci_find_bridge_for_bus(&articiaS_hose, PCI_BUS(dev)); 543 bridge = pci_find_bridge_for_bus(&articiaS_hose, PCI_BUS(dev));
540 if (dev != PCI_ANY_ID) 544 if (dev != PCI_ANY_ID)
541 { 545 {
542 unsigned char agp_control_0; 546 unsigned char agp_control_0;
543 PRINTF("Got the bridge at %02x:%02x:%02x\n", 547 PRINTF("Got the bridge at %02x:%02x:%02x\n",
544 PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge)); 548 PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge));
545 pci_hose_read_config_byte(&articiaS_hose, bridge, 0x3E, &agp_control_0); 549 pci_hose_read_config_byte(&articiaS_hose, bridge, 0x3E, &agp_control_0);
546 agp_control_0 |= 0x18; 550 agp_control_0 |= 0x18;
547 pci_hose_write_config_byte(&articiaS_hose, bridge, 0x3E, agp_control_0); 551 pci_hose_write_config_byte(&articiaS_hose, bridge, 0x3E, agp_control_0);
548 PRINTF("Configured for VGA forwarding\n"); 552 PRINTF("Configured for VGA forwarding\n");
549 } 553 }
550 } 554 }
551 555
552 /* 556 /*
553 * Now try to run the bios 557 * Now try to run the bios
554 */ 558 */
555 559 PRINTF("Trying to run bios now\n");
556 if (execute_bios(dev, gd->relocaddr)) 560 if (execute_bios(dev, gd->relocaddr))
557 { 561 {
558 printf("OK\n"); 562 printf("OK\n");
559 video_dev = dev; 563 video_dev = dev;
560 } 564 }
561 else 565 else
562 { 566 {
563 printf("ERROR\n"); 567 printf("ERROR\n");
564 } 568 }
565 569
566 PRINTF("Done scanning.\n"); 570 PRINTF("Done scanning.\n");
567 571
568 shutdown_bios(); 572 shutdown_bios();
569 573
570 if (dev == PCI_ANY_ID) return -1; 574 if (dev == PCI_ANY_ID) return -1;
571 else return 0; 575 else return 0;
572 576
573 } 577 }
574 578
board/MAI/AmigaOneG3SE/config.mk
1 # 1 #
2 # (C) Copyright 2002 2 # (C) Copyright 2002
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 # 4 #
5 # See file CREDITS for list of people who contributed to this 5 # See file CREDITS for list of people who contributed to this
6 # project. 6 # project.
7 # 7 #
8 # This program is free software; you can redistribute it and/or 8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as 9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of 10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version. 11 # the License, or (at your option) any later version.
12 # 12 #
13 # This program is distributed in the hope that it will be useful, 13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details. 16 # GNU General Public License for more details.
17 # 17 #
18 # You should have received a copy of the GNU General Public License 18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software 19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 # MA 02111-1307 USA 21 # MA 02111-1307 USA
22 # 22 #
23 23
24 # 24 #
25 # AmigaOneG3SE boards 25 # AmigaOneG3SE boards
26 # 26 #
27 27
28 X86EMU = -I../bios_emulator/scitech/include -I../bios_emulator/scitech/src/x86emu 28 X86EMU = -I../bios_emulator/scitech/include -I../bios_emulator/scitech/src/x86emu
29 29
30 TEXT_BASE = 0xfff00000 30 TEXT_BASE = 0xfff00000
31 31
32 PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) -Wa,-mregnames -DEASTEREGG $(X86EMU) #-DDEBUG 32 PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) -Wa,-mregnames -DEASTEREGG $(X86EMU) -Dprintk=printf #-DDEBUG
33 33
34 34
board/MAI/AmigaOneG3SE/video.c
1 /* 1 /*
2 * (C) Copyright 2002 2 * (C) Copyright 2002
3 * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com 3 * Hyperion Entertainment, Hans-JoergF@hyperion-entertainment.com
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 #include <common.h> 24 #include <common.h>
25 #include <devices.h> 25 #include <devices.h>
26 #include "memio.h" 26 #include "memio.h"
27 #include <part.h> 27 #include <part.h>
28 28
29 unsigned char *cursor_position; 29 unsigned char *cursor_position;
30 unsigned int cursor_row; 30 unsigned int cursor_row;
31 unsigned int cursor_col; 31 unsigned int cursor_col;
32 32
33 unsigned char current_attr; 33 unsigned char current_attr;
34 34
35 unsigned int video_numrows = 25; 35 unsigned int video_numrows = 25;
36 unsigned int video_numcols = 80; 36 unsigned int video_numcols = 80;
37 unsigned int video_scrolls = 0; 37 unsigned int video_scrolls = 0;
38 38
39 #define VIDEO_BASE (unsigned char *)0xFD0B8000 39 #define VIDEO_BASE (unsigned char *)0xFD0B8000
40 #define VIDEO_ROWS video_numrows 40 #define VIDEO_ROWS video_numrows
41 #define VIDEO_COLS video_numcols 41 #define VIDEO_COLS video_numcols
42 #define VIDEO_PITCH (2 * video_numcols) 42 #define VIDEO_PITCH (2 * video_numcols)
43 #define VIDEO_SIZE (video_numrows * video_numcols * 2) 43 #define VIDEO_SIZE (video_numrows * video_numcols * 2)
44 #define VIDEO_NAME "vga" 44 #define VIDEO_NAME "vga"
45 45
46 void video_test(void); 46 void video_test(void);
47 void video_putc(char ch); 47 void video_putc(char ch);
48 void video_puts(char *string); 48 void video_puts(char *string);
49 void video_scroll(int rows); 49 void video_scroll(int rows);
50 void video_banner(void); 50 void video_banner(void);
51 int video_init(void); 51 int video_init(void);
52 int video_start(void); 52 int video_start(void);
53 int video_rows(void); 53 int video_rows(void);
54 int video_cols(void); 54 int video_cols(void);
55 55
56 char *prompt_string = "=>"; 56 char *prompt_string = "=>";
57 57
58 void video_set_color(unsigned char attr) 58 void video_set_color(unsigned char attr)
59 { 59 {
60 unsigned char *fb = (unsigned char *)VIDEO_BASE; 60 unsigned char *fb = (unsigned char *)VIDEO_BASE;
61 int i; 61 int i;
62 62
63 current_attr = video_get_attr(); 63 current_attr = video_get_attr();
64 64
65 for (i=0; i<VIDEO_SIZE; i+=2) 65 for (i=0; i<VIDEO_SIZE; i+=2)
66 { 66 {
67 *(fb+i+1) = current_attr; 67 *(fb+i+1) = current_attr;
68 } 68 }
69 } 69 }
70 70
71 unsigned char video_get_attr(void) 71 unsigned char video_get_attr(void)
72 { 72 {
73 char *s; 73 char *s;
74 unsigned char attr; 74 unsigned char attr;
75 75
76 attr = 0x0f; 76 attr = 0x0f;
77 77
78 s = getenv("vga_fg_color"); 78 s = getenv("vga_fg_color");
79 if (s) 79 if (s)
80 { 80 {
81 attr = atoi(s); 81 attr = atoi(s);
82 } 82 }
83 83
84 s = getenv("vga_bg_color"); 84 s = getenv("vga_bg_color");
85 if (s) 85 if (s)
86 { 86 {
87 attr |= atoi(s)<<4; 87 attr |= atoi(s)<<4;
88 } 88 }
89 89
90 return attr; 90 return attr;
91 } 91 }
92 92
93 int video_inited = 0; 93 int video_inited = 0;
94 94
95 int drv_video_init(void) 95 int drv_video_init(void)
96 { 96 {
97 int error, devices = 1 ; 97 int error, devices = 1 ;
98 device_t vgadev ; 98 device_t vgadev ;
99 if (video_inited) return 1; 99 if (video_inited) return 1;
100 video_inited = 1; 100 video_inited = 1;
101 video_init(); 101 video_init();
102 memset (&vgadev, 0, sizeof(vgadev)); 102 memset (&vgadev, 0, sizeof(vgadev));
103 103
104 strcpy(vgadev.name, VIDEO_NAME); 104 strcpy(vgadev.name, VIDEO_NAME);
105 vgadev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM; 105 vgadev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
106 vgadev.putc = video_putc; 106 vgadev.putc = video_putc;
107 vgadev.puts = video_puts; 107 vgadev.puts = video_puts;
108 vgadev.getc = NULL; 108 vgadev.getc = NULL;
109 vgadev.tstc = NULL; 109 vgadev.tstc = NULL;
110 vgadev.start = video_start; 110 vgadev.start = video_start;
111 111
112 error = device_register (&vgadev); 112 error = device_register (&vgadev);
113 113
114 if (error == 0) 114 if (error == 0)
115 { 115 {
116 char *s = getenv("stdout"); 116 char *s = getenv("stdout");
117 if (s && strcmp(s, VIDEO_NAME)==0) 117 if (s && strcmp(s, VIDEO_NAME)==0)
118 { 118 {
119 if (overwrite_console()) return 1; 119 if (overwrite_console()) return 1;
120 error = console_assign(stdout, VIDEO_NAME); 120 error = console_assign(stdout, VIDEO_NAME);
121 if (error == 0) return 1; 121 if (error == 0) return 1;
122 else return error; 122 else return error;
123 } 123 }
124 return 1; 124 return 1;
125 } 125 }
126 126
127 return error; 127 return error;
128 } 128 }
129 129
130 int video_init(void) 130 int video_init(void)
131 { 131 {
132 cursor_position = VIDEO_BASE; // Color text display base 132 cursor_position = VIDEO_BASE; // Color text display base
133 cursor_row = 0; 133 cursor_row = 0;
134 cursor_col = 0; 134 cursor_col = 0;
135 current_attr = video_get_attr(); // Currently selected value for attribute. 135 current_attr = video_get_attr(); // Currently selected value for attribute.
136 // video_test(); 136 // video_test();
137 video_set_color(current_attr); 137 video_set_color(current_attr);
138 138
139 return 0; 139 return 0;
140 } 140 }
141 141
142 void video_set_cursor(int line, int column) 142 void video_set_cursor(int line, int column)
143 { 143 {
144 unsigned short offset = line*video_numcols + column; 144 unsigned short offset = line*video_numcols + column;
145 cursor_position = VIDEO_BASE + line*VIDEO_PITCH + column*2; 145 cursor_position = VIDEO_BASE + line*VIDEO_PITCH + column*2;
146 out_byte(0x3D4, 0x0E); 146 out_byte(0x3D4, 0x0E);
147 out_byte(0x3D5, offset/256); 147 out_byte(0x3D5, offset/256);
148 out_byte(0x3D4, 0x0F); 148 out_byte(0x3D4, 0x0F);
149 out_byte(0x3D5, offset%256); 149 out_byte(0x3D5, offset%256);
150 } 150 }
151 151
152 void video_write_char(int character) 152 void video_write_char(int character)
153 { 153 {
154 *cursor_position = character; 154 *cursor_position = character;
155 *(cursor_position+1) = current_attr; 155 *(cursor_position+1) = current_attr;
156 } 156 }
157 157
158 void video_test(void) 158 void video_test(void)
159 { 159 {
160 160
161 } 161 }
162 162
163 void video_putc(char ch) 163 void video_putc(char ch)
164 { 164 {
165 switch(ch) 165 switch(ch)
166 { 166 {
167 case '\n': 167 case '\n':
168 cursor_col = 0; 168 cursor_col = 0;
169 cursor_row += 1; 169 cursor_row += 1;
170 break; 170 break;
171 case '\r': 171 case '\r':
172 cursor_col = 0; 172 cursor_col = 0;
173 break; 173 break;
174 case '\b': 174 case '\b':
175 if (cursor_col) cursor_col--; 175 if (cursor_col) cursor_col--;
176 else return; 176 else return;
177 break; 177 break;
178 case '\t': 178 case '\t':
179 cursor_col = (cursor_col/8+1)*8; 179 cursor_col = (cursor_col/8+1)*8;
180 break; 180 break;
181 default: 181 default:
182 video_write_char(ch); 182 video_write_char(ch);
183 cursor_col++; 183 cursor_col++;
184 if (cursor_col > VIDEO_COLS-1) 184 if (cursor_col > VIDEO_COLS-1)
185 { 185 {
186 cursor_row++; 186 cursor_row++;
187 cursor_col=0; 187 cursor_col=0;
188 } 188 }
189 } 189 }
190 190
191 if (cursor_row > VIDEO_ROWS-1) 191 if (cursor_row > VIDEO_ROWS-1)
192 video_scroll(1); 192 video_scroll(1);
193 video_set_cursor(cursor_row, cursor_col); 193 video_set_cursor(cursor_row, cursor_col);
194 } 194 }
195 195
196 void video_scroll(int rows) 196 void video_scroll(int rows)
197 { 197 {
198 unsigned short clear = ((unsigned short)current_attr) | (' '<<8); 198 unsigned short clear = ((unsigned short)current_attr) | (' '<<8);
199 unsigned short* addr16 = &((unsigned short *)VIDEO_BASE)[(VIDEO_ROWS-rows)*VIDEO_COLS]; 199 unsigned short* addr16 = &((unsigned short *)VIDEO_BASE)[(VIDEO_ROWS-rows)*VIDEO_COLS];
200 int i; 200 int i;
201 char *s; 201 char *s;
202 202
203 s = getenv("vga_askscroll"); 203 s = getenv("vga_askscroll");
204 video_scrolls += rows; 204 video_scrolls += rows;
205 205
206 if (video_scrolls >= video_numrows) 206 if (video_scrolls >= video_numrows)
207 { 207 {
208 if (s && strcmp(s, "yes")) 208 if (s && strcmp(s, "yes"))
209 { 209 {
210 while (-1 == tstc()); 210 while (-1 == tstc());
211 } 211 }
212 212
213 video_scrolls = 0; 213 video_scrolls = 0;
214 } 214 }
215 215
216 216
217 memcpy(VIDEO_BASE, VIDEO_BASE+rows*(VIDEO_COLS*2), (VIDEO_ROWS-rows)*(VIDEO_COLS*2)); 217 memcpy(VIDEO_BASE, VIDEO_BASE+rows*(VIDEO_COLS*2), (VIDEO_ROWS-rows)*(VIDEO_COLS*2));
218 for (i = 0 ; i < rows * VIDEO_COLS ; i++) 218 for (i = 0 ; i < rows * VIDEO_COLS ; i++)
219 addr16[i] = clear; 219 addr16[i] = clear;
220 cursor_row-=rows; 220 cursor_row-=rows;
221 cursor_col=0; 221 cursor_col=0;
222 } 222 }
223 223
224 void video_puts(char *string) 224 void video_puts(char *string)
225 { 225 {
226 while (*string) 226 while (*string)
227 { 227 {
228 video_putc(*string); 228 video_putc(*string);
229 string++; 229 string++;
230 } 230 }
231 } 231 }
232 232
233 int video_start(void) 233 int video_start(void)
234 { 234 {
235 return 0; 235 return 0;
236 } 236 }
237 237
238 unsigned char video_single_box[] = 238 unsigned char video_single_box[] =
239 { 239 {
240 218, 196, 191, 240 218, 196, 191,
241 179, 179, 241 179, 179,
242 192, 196, 217 242 192, 196, 217
243 }; 243 };
244 244
245 unsigned char video_double_box[] = 245 unsigned char video_double_box[] =
246 { 246 {
247 201, 205, 187, 247 201, 205, 187,
248 186, 186, 248 186, 186,
249 200, 205, 188 249 200, 205, 188
250 }; 250 };
251 251
252 unsigned char video_single_title[] = 252 unsigned char video_single_title[] =
253 { 253 {
254 195, 196, 180, 180, 195 254 195, 196, 180, 180, 195
255 }; 255 };
256 256
257 unsigned char video_double_title[] = 257 unsigned char video_double_title[] =
258 { 258 {
259 204, 205, 185, 181, 198 259 204, 205, 185, 181, 198
260 }; 260 };
261 261
262 #define SINGLE_BOX 0 262 #define SINGLE_BOX 0
263 #define DOUBLE_BOX 1 263 #define DOUBLE_BOX 1
264 264
265 unsigned char *video_addr(int x, int y) 265 unsigned char *video_addr(int x, int y)
266 { 266 {
267 return VIDEO_BASE + 2*(VIDEO_COLS*y) + 2*x; 267 return VIDEO_BASE + 2*(VIDEO_COLS*y) + 2*x;
268 } 268 }
269 269
270 void video_bios_print_string(char *s, int x, int y, int attr, int count) 270 void video_bios_print_string(char *s, int x, int y, int attr, int count)
271 { 271 {
272 int cattr = current_attr; 272 int cattr = current_attr;
273 if (attr != -1) current_attr = attr; 273 if (attr != -1) current_attr = attr;
274 video_set_cursor(x,y); 274 video_set_cursor(x,y);
275 while (count) 275 while (count)
276 { 276 {
277 char c = *s++; 277 char c = *s++;
278 if (attr == -1) current_attr = *s++; 278 if (attr == -1) current_attr = *s++;
279 video_putc(c); 279 video_putc(c);
280 count--; 280 count--;
281 } 281 }
282 } 282 }
283 283
284 void video_draw_box(int style, int attr, char *title, int separate, int x, int y, int w, int h) 284 void video_draw_box(int style, int attr, char *title, int separate, int x, int y, int w, int h)
285 { 285 {
286 unsigned char *fb, *fb2; 286 unsigned char *fb, *fb2;
287 unsigned char *st = (style == SINGLE_BOX)?video_single_box : video_double_box; 287 unsigned char *st = (style == SINGLE_BOX)?video_single_box : video_double_box;
288 unsigned char *ti = (style == SINGLE_BOX)?video_single_title : video_double_title; 288 unsigned char *ti = (style == SINGLE_BOX)?video_single_title : video_double_title;
289 int i; 289 int i;
290 290
291 fb = video_addr(x,y); 291 fb = video_addr(x,y);
292 *(fb) = st[0]; 292 *(fb) = st[0];
293 *(fb+1) = attr; 293 *(fb+1) = attr;
294 fb += 2; 294 fb += 2;
295 295
296 fb2 = video_addr(x,y+h-1); 296 fb2 = video_addr(x,y+h-1);
297 *(fb2) = st[5]; 297 *(fb2) = st[5];
298 *(fb2+1) = attr; 298 *(fb2+1) = attr;
299 fb2 += 2; 299 fb2 += 2;
300 300
301 for (i=0; i<w-2;i++) 301 for (i=0; i<w-2;i++)
302 { 302 {
303 *fb = st[1]; 303 *fb = st[1];
304 fb++; 304 fb++;
305 *fb = attr; 305 *fb = attr;
306 fb++; 306 fb++;
307 307
308 *fb2 = st[6]; 308 *fb2 = st[6];
309 fb2++; 309 fb2++;
310 *fb2 = attr; 310 *fb2 = attr;
311 fb2++; 311 fb2++;
312 312
313 } 313 }
314 *fb = st[2]; 314 *fb = st[2];
315 *(fb+1) = attr; 315 *(fb+1) = attr;
316 316
317 *fb2 = st[7]; 317 *fb2 = st[7];
318 *(fb2+1) = attr; 318 *(fb2+1) = attr;
319 319
320 fb = video_addr(x, y+1); 320 fb = video_addr(x, y+1);
321 fb2 = video_addr(x+w-1, y+1); 321 fb2 = video_addr(x+w-1, y+1);
322 for (i=0; i<h-2; i++) 322 for (i=0; i<h-2; i++)
323 { 323 {
324 *fb = st[3]; 324 *fb = st[3];
325 *(fb+1) = attr; fb += 2*VIDEO_COLS; 325 *(fb+1) = attr; fb += 2*VIDEO_COLS;
326 326
327 *fb2 = st[4]; 327 *fb2 = st[4];
328 *(fb2+1) = attr; fb2 += 2*VIDEO_COLS; 328 *(fb2+1) = attr; fb2 += 2*VIDEO_COLS;
329 } 329 }
330 330
331 // Draw title 331 // Draw title
332 if (title) 332 if (title)
333 { 333 {
334 if (separate == 0) 334 if (separate == 0)
335 { 335 {
336 fb = video_addr(x+1, y); 336 fb = video_addr(x+1, y);
337 *fb = ti[3]; 337 *fb = ti[3];
338 fb += 2; 338 fb += 2;
339 *fb = ' '; 339 *fb = ' ';
340 fb += 2; 340 fb += 2;
341 while (*title) 341 while (*title)
342 { 342 {
343 *fb = *title; 343 *fb = *title;
344 fb ++; 344 fb ++;
345 *fb = attr; 345 *fb = attr;
346 fb++; title++; 346 fb++; title++;
347 } 347 }
348 *fb = ' '; 348 *fb = ' ';
349 fb += 2; 349 fb += 2;
350 *fb = ti[4]; 350 *fb = ti[4];
351 } 351 }
352 else 352 else
353 { 353 {
354 fb = video_addr(x, y+2); 354 fb = video_addr(x, y+2);
355 *fb = ti[0]; 355 *fb = ti[0];
356 fb += 2; 356 fb += 2;
357 for (i=0; i<w-2; i++) 357 for (i=0; i<w-2; i++)
358 { 358 {
359 *fb = ti[1]; 359 *fb = ti[1];
360 *(fb+1) = attr; 360 *(fb+1) = attr;
361 fb += 2; 361 fb += 2;
362 } 362 }
363 *fb = ti[2]; 363 *fb = ti[2];
364 *(fb+1) = attr; 364 *(fb+1) = attr;
365 fb = video_addr(x+1, y+1); 365 fb = video_addr(x+1, y+1);
366 for (i=0; i<w-2; i++) 366 for (i=0; i<w-2; i++)
367 { 367 {
368 *fb = ' '; 368 *fb = ' ';
369 *(fb+1) = attr; 369 *(fb+1) = attr;
370 fb += 2; 370 fb += 2;
371 } 371 }
372 fb = video_addr(x+2, y+1); 372 fb = video_addr(x+2, y+1);
373 373
374 while (*title) 374 while (*title)
375 { 375 {
376 *fb = *title; 376 *fb = *title;
377 *(fb+1) = attr; 377 *(fb+1) = attr;
378 fb += 2; 378 fb += 2;
379 title++; 379 title++;
380 } 380 }
381 } 381 }
382 } 382 }
383 383
384 } 384 }
385 385
386 void video_draw_text(int x, int y, int attr, char *text) 386 void video_draw_text(int x, int y, int attr, char *text)
387 { 387 {
388 unsigned char *fb = video_addr(x,y); 388 unsigned char *fb = video_addr(x,y);
389 while (*text) 389 while (*text)
390 { 390 {
391 *fb++ = *text++; 391 *fb++ = *text++;
392 *fb++ = attr; 392 *fb++ = attr;
393 } 393 }
394 } 394 }
395 395
396 void video_save_rect(int x, int y, int w, int h, void *save_area, int clearchar, int clearattr) 396 void video_save_rect(int x, int y, int w, int h, void *save_area, int clearchar, int clearattr)
397 { 397 {
398 unsigned char *save = (unsigned char *)save_area; 398 unsigned char *save = (unsigned char *)save_area;
399 unsigned char *fb = video_addr(x,y); 399 unsigned char *fb = video_addr(x,y);
400 int i,j; 400 int i,j;
401 for (i=0; i<h; i++) 401 for (i=0; i<h; i++)
402 { 402 {
403 unsigned char *fbb = fb; 403 unsigned char *fbb = fb;
404 for (j=0; j<w; j++) 404 for (j=0; j<w; j++)
405 { 405 {
406 *save ++ = *fb; 406 *save ++ = *fb;
407 if (clearchar > 0) *fb = clearchar; 407 if (clearchar > 0) *fb = clearchar;
408 fb ++; 408 fb ++;
409 *save ++ = *fb; 409 *save ++ = *fb;
410 if (clearattr > 0) *fb = clearattr; 410 if (clearattr > 0) *fb = clearattr;
411 } 411 }
412 fb = fbb + 2*VIDEO_COLS; 412 fb = fbb + 2*VIDEO_COLS;
413 } 413 }
414 } 414 }
415 415
416 void video_restore_rect(int x, int y, int w, int h, void *save_area) 416 void video_restore_rect(int x, int y, int w, int h, void *save_area)
417 { 417 {
418 unsigned char *save = (unsigned char *)save_area; 418 unsigned char *save = (unsigned char *)save_area;
419 unsigned char *fb = video_addr(x,y); 419 unsigned char *fb = video_addr(x,y);
420 int i,j; 420 int i,j;
421 for (i=0; i<h; i++) 421 for (i=0; i<h; i++)
422 { 422 {
423 unsigned char *fbb = fb; 423 unsigned char *fbb = fb;
424 for (j=0; j<w; j++) 424 for (j=0; j<w; j++)
425 { 425 {
426 *fb ++ = *save ++; 426 *fb ++ = *save ++;
427 *fb ++ = *save ++; 427 *fb ++ = *save ++;
428 } 428 }
429 fb = fbb + 2*VIDEO_COLS; 429 fb = fbb + 2*VIDEO_COLS;
430 } 430 }
431 431
432 } 432 }
433 433
434 int video_rows(void) 434 int video_rows(void)
435 { 435 {
436 return VIDEO_ROWS; 436 return VIDEO_ROWS;
437 } 437 }
438 438
439 int video_cols(void) 439 int video_cols(void)
440 { 440 {
441 return VIDEO_COLS; 441 return VIDEO_COLS;
442 } 442 }
443 443
444 void video_size(int cols, int rows) 444 void video_size(int cols, int rows)
445 { 445 {
446 video_numrows = rows; 446 video_numrows = rows;
447 video_numcols = cols; 447 video_numcols = cols;
448 } 448 }
449 449
450 void video_clear(void) 450 void video_clear(void)
451 { 451 {
452 unsigned short *fbb = (unsigned short *)0xFD0B8000; 452 unsigned short *fbb = (unsigned short *)0xFD0B8000;
453 int i,j; 453 int i,j;
454 unsigned short val = 0x2000 | current_attr; 454 unsigned short val = 0x2000 | current_attr;
455 455
456 for (i=0; i<video_rows(); i++) 456 for (i=0; i<video_rows(); i++)
457 { 457 {
458 for (j=0; j<video_cols(); j++) 458 for (j=0; j<video_cols(); j++)
459 { 459 {
460 *fbb++ = val; 460 *fbb++ = val;
461 } 461 }
462 } 462 }
463 video_set_cursor(0,0); 463 video_set_cursor(0,0);
464 cursor_row = 0; 464 cursor_row = 0;
465 cursor_col = 0; 465 cursor_col = 0;
466 } 466 }
467 467
468 #ifdef EASTEREGG 468 #ifdef EASTEREGG
469 int video_easteregg_active = 0; 469 int video_easteregg_active = 0;
470 470
471 void video_easteregg(void) 471 void video_easteregg(void)
472 { 472 {
473 video_easteregg_active = 1; 473 video_easteregg_active = 1;
474 } 474 }
475 #endif 475 #endif
476 476
477 extern bd_t *bd_global;
478 extern block_dev_desc_t * ide_get_dev(int dev); 477 extern block_dev_desc_t * ide_get_dev(int dev);
479 extern char version_string[]; 478 extern char version_string[];
480 479
481 void video_banner(void) 480 void video_banner(void)
482 { 481 {
483 block_dev_desc_t *ide; 482 block_dev_desc_t *ide;
483 DECLARE_GLOBAL_DATA_PTR;
484 int i; 484 int i;
485 char *s; 485 char *s;
486 int maxdev; 486 int maxdev;
487 487
488 488
489 if (video_inited == 0) return; 489 if (video_inited == 0) return;
490 #ifdef EASTEREGG 490 #ifdef EASTEREGG
491 if (video_easteregg_active) 491 if (video_easteregg_active)
492 { 492 {
493 prompt_string=""; 493 prompt_string="";
494 video_clear(); 494 video_clear();
495 printf("\n"); 495 printf("\n");
496 printf(" **** COMMODORE 64 BASIC X2 ****\n\n"); 496 printf(" **** COMMODORE 64 BASIC X2 ****\n\n");
497 printf(" 64K RAM SYSTEM 38911 BASIC BYTES FREE\n\n"); 497 printf(" 64K RAM SYSTEM 38911 BASIC BYTES FREE\n\n");
498 printf("READY\n"); 498 printf("READY\n");
499 } 499 }
500 else 500 else
501 { 501 {
502 #endif 502 #endif
503 s = getenv("ide_maxbus"); 503 s = getenv("ide_maxbus");
504 if (s) 504 if (s)
505 maxdev = atoi(s) * 2; 505 maxdev = atoi(s) * 2;
506 else 506 else
507 maxdev = 4; 507 maxdev = 4;
508 508
509 s = getenv("stdout"); 509 s = getenv("stdout");
510 if (s && strcmp(s, "serial") == 0) 510 if (s && strcmp(s, "serial") == 0)
511 return; 511 return;
512 512
513 video_clear(); 513 video_clear();
514 printf("%s\n\nCPU: ", version_string); 514 printf("%s\n\nCPU: ", version_string);
515 checkcpu(); 515 checkcpu();
516 printf("DRAM: %ld MB\n", bd_global->bi_memsize/(1024*1024)); 516 printf("DRAM: %ld MB\n", gd->bd->bi_memsize/(1024*1024));
517 printf("FSB: %ld MHz\n", bd_global->bi_busfreq/1000000); 517 printf("FSB: %ld MHz\n", gd->bd->bi_busfreq/1000000);
518 518
519 printf("\n---- Disk summary ----\n"); 519 printf("\n---- Disk summary ----\n");
520 for (i = 0; i < maxdev; i++) 520 for (i = 0; i < maxdev; i++)
521 { 521 {
522 ide = ide_get_dev(i); 522 ide = ide_get_dev(i);
523 printf("Device %d: ", i); 523 printf("Device %d: ", i);
524 dev_print(ide); 524 dev_print(ide);
525 } 525 }
526 526
527 /* 527 /*
528 video_draw_box(SINGLE_BOX, 0x0F, "Test 1", 0, 0,18, 72, 4); 528 video_draw_box(SINGLE_BOX, 0x0F, "Test 1", 0, 0,18, 72, 4);
529 video_draw_box(DOUBLE_BOX, 0x0F, "Test 2", 1, 4,10, 50, 6); 529 video_draw_box(DOUBLE_BOX, 0x0F, "Test 2", 1, 4,10, 50, 6);
530 video_draw_box(DOUBLE_BOX, 0x0F, "Test 3", 0, 40, 3, 20, 5); 530 video_draw_box(DOUBLE_BOX, 0x0F, "Test 3", 0, 40, 3, 20, 5);
531 531
532 video_draw_text(1, 4, 0x2F, "Highlighted options"); 532 video_draw_text(1, 4, 0x2F, "Highlighted options");
533 video_draw_text(1, 5, 0x0F, "Non-selected option"); 533 video_draw_text(1, 5, 0x0F, "Non-selected option");
534 video_draw_text(1, 6, 0x07, "disabled option"); 534 video_draw_text(1, 6, 0x07, "disabled option");
535 */ 535 */
536 #ifdef EASTEREGG 536 #ifdef EASTEREGG
537 } 537 }
538 #endif 538 #endif
539 } 539 }
board/MAI/bios_emulator/glue.c
1 #include <common.h> 1 #include <common.h>
2 #include <pci.h> 2 #include <pci.h>
3 #include <74xx_7xx.h> 3 #include <74xx_7xx.h>
4 4
5 5
6 #ifdef DEBUG 6 #ifdef DEBUG
7 #undef DEBUG 7 #undef DEBUG
8 #endif 8 #endif
9 9
10 #ifdef DEBUG 10 #ifdef DEBUG
11 #define PRINTF(format, args...) _printf(format , ## args) 11 #define PRINTF(format, args...) _printf(format , ## args)
12 #else 12 #else
13 #define PRINTF(format, argc...) 13 #define PRINTF(format, argc...)
14 #endif 14 #endif
15 15
16 static pci_dev_t to_pci(int bus, int devfn) 16 static pci_dev_t to_pci(int bus, int devfn)
17 { 17 {
18 return PCI_BDF(bus, (devfn>>3), devfn&3); 18 return PCI_BDF(bus, (devfn>>3), devfn&3);
19 } 19 }
20 20
21 int mypci_find_device(int vendor, int product, int index) 21 int mypci_find_device(int vendor, int product, int index)
22 { 22 {
23 return pci_find_device(vendor, product, index); 23 return pci_find_device(vendor, product, index);
24 } 24 }
25 25
26 int mypci_bus(int device) 26 int mypci_bus(int device)
27 { 27 {
28 return PCI_BUS(device); 28 return PCI_BUS(device);
29 } 29 }
30 30
31 int mypci_devfn(int device) 31 int mypci_devfn(int device)
32 { 32 {
33 return (PCI_DEV(device)<<3) | PCI_FUNC(device); 33 return (PCI_DEV(device)<<3) | PCI_FUNC(device);
34 } 34 }
35 35
36 36
37 #define mypci_read_func(type, size) \ 37 #define mypci_read_func(type, size) \
38 type mypci_read_cfg_##size##(int bus, int devfn, int offset) \ 38 type mypci_read_cfg_##size##(int bus, int devfn, int offset) \
39 { \ 39 { \
40 type c; \ 40 type c; \
41 pci_read_config_##size##(to_pci(bus, devfn), offset, &c); \ 41 pci_read_config_##size##(to_pci(bus, devfn), offset, &c); \
42 return c; \ 42 return c; \
43 } 43 }
44 44
45 #define mypci_write_func(type, size) \ 45 #define mypci_write_func(type, size) \
46 void mypci_write_cfg_##size##(int bus, int devfn, int offset, int value) \ 46 void mypci_write_cfg_##size##(int bus, int devfn, int offset, int value) \
47 { \ 47 { \
48 pci_write_config_##size##(to_pci(bus, devfn), offset, value); \ 48 pci_write_config_##size##(to_pci(bus, devfn), offset, value); \
49 } 49 }
50 50
51 mypci_read_func(u8,byte); 51 mypci_read_func(u8,byte);
52 mypci_read_func(u16,word); 52 mypci_read_func(u16,word);
53 53
54 mypci_write_func(u8,byte); 54 mypci_write_func(u8,byte);
55 mypci_write_func(u16,word); 55 mypci_write_func(u16,word);
56 56
57 u32 mypci_read_cfg_long(int bus, int devfn, int offset) 57 u32 mypci_read_cfg_long(int bus, int devfn, int offset)
58 { 58 {
59 u32 c; 59 u32 c;
60 pci_read_config_dword(to_pci(bus, devfn), offset, &c); 60 pci_read_config_dword(to_pci(bus, devfn), offset, &c);
61 return c; 61 return c;
62 } 62 }
63 63
64 void mypci_write_cfg_long(int bus, int devfn, int offset, int value) 64 void mypci_write_cfg_long(int bus, int devfn, int offset, int value)
65 { 65 {
66 pci_write_config_dword(to_pci(bus, devfn), offset, value); 66 pci_write_config_dword(to_pci(bus, devfn), offset, value);
67 } 67 }
68 68
69 void _printf(const char *fmt, ...) 69 void _printf(const char *fmt, ...)
70 { 70 {
71 va_list args; 71 va_list args;
72 char buf[CFG_PBSIZE]; 72 char buf[CFG_PBSIZE];
73 73
74 va_start(args, fmt); 74 va_start(args, fmt);
75 (void)vsprintf(buf, fmt, args); 75 (void)vsprintf(buf, fmt, args);
76 va_end(args); 76 va_end(args);
77 77
78 printf(buf); 78 printf(buf);
79 } 79 }
80 80
81 char *_getenv(char *name) 81 char *_getenv(char *name)
82 { 82 {
83 return getenv(name); 83 return getenv(name);
84 } 84 }
85 85
86 unsigned long get_bar_size(pci_dev_t dev, int offset) 86 unsigned long get_bar_size(pci_dev_t dev, int offset)
87 { 87 {
88 u32 bar_back, bar_value; 88 u32 bar_back, bar_value;
89 89
90 /* Save old BAR value */ 90 /* Save old BAR value */
91 pci_read_config_dword(dev, offset, &bar_back); 91 pci_read_config_dword(dev, offset, &bar_back);
92 92
93 /* Write all 1's. */ 93 /* Write all 1's. */
94 pci_write_config_dword(dev, offset, ~0); 94 pci_write_config_dword(dev, offset, ~0);
95 95
96 /* Now read back the relevant bits */ 96 /* Now read back the relevant bits */
97 pci_read_config_dword(dev, offset, &bar_value); 97 pci_read_config_dword(dev, offset, &bar_value);
98 98
99 /* Restore original value */ 99 /* Restore original value */
100 pci_write_config_dword(dev, offset, bar_back); 100 pci_write_config_dword(dev, offset, bar_back);
101 101
102 if (bar_value == 0) return 0xFFFFFFFF; /* This BAR is disabled */ 102 if (bar_value == 0) return 0xFFFFFFFF; /* This BAR is disabled */
103 103
104 if ((bar_value & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) 104 if ((bar_value & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY)
105 { 105 {
106 /* This is a memory space BAR. Mask it out so we get the size of it */ 106 /* This is a memory space BAR. Mask it out so we get the size of it */
107 return ~(bar_value & PCI_BASE_ADDRESS_MEM_MASK) + 1; 107 return ~(bar_value & PCI_BASE_ADDRESS_MEM_MASK) + 1;
108 } 108 }
109 109
110 /* Not suitable */ 110 /* Not suitable */
111 return 0xFFFFFFFF; 111 return 0xFFFFFFFF;
112 } 112 }
113 113
114 void enable_compatibility_hole(void) 114 void enable_compatibility_hole(void)
115 { 115 {
116 u8 cfg; 116 u8 cfg;
117 pci_dev_t art = PCI_BDF(0,0,0); 117 pci_dev_t art = PCI_BDF(0,0,0);
118 118
119 pci_read_config_byte(art, 0x54, &cfg); 119 pci_read_config_byte(art, 0x54, &cfg);
120 /* cfg |= 0x08; */ 120 /* cfg |= 0x08; */
121 cfg |= 0x20; 121 cfg |= 0x20;
122 pci_write_config_byte(art, 0x54, cfg); 122 pci_write_config_byte(art, 0x54, cfg);
123 } 123 }
124 124
125 void disable_compatibility_hole(void) 125 void disable_compatibility_hole(void)
126 { 126 {
127 u8 cfg; 127 u8 cfg;
128 pci_dev_t art = PCI_BDF(0,0,0); 128 pci_dev_t art = PCI_BDF(0,0,0);
129 129
130 pci_read_config_byte(art, 0x54, &cfg); 130 pci_read_config_byte(art, 0x54, &cfg);
131 /* cfg &= ~0x08; */ 131 /* cfg &= ~0x08; */
132 cfg &= ~0x20; 132 cfg &= ~0x20;
133 pci_write_config_byte(art, 0x54, cfg); 133 pci_write_config_byte(art, 0x54, cfg);
134 } 134 }
135 135
136 void map_rom(pci_dev_t dev, u32 address) 136 void map_rom(pci_dev_t dev, u32 address)
137 { 137 {
138 pci_write_config_dword(dev, PCI_ROM_ADDRESS, address|PCI_ROM_ADDRESS_ENABLE); 138 pci_write_config_dword(dev, PCI_ROM_ADDRESS, address|PCI_ROM_ADDRESS_ENABLE);
139 } 139 }
140 140
141 void unmap_rom(pci_dev_t dev) 141 void unmap_rom(pci_dev_t dev)
142 { 142 {
143 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0); 143 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0);
144 } 144 }
145 145
146 void bat_map(u8 batnum, u32 address, u32 length) 146 void bat_map(u8 batnum, u32 address, u32 length)
147 { 147 {
148 u32 temp = address; 148 u32 temp = address;
149 address &= 0xFFFE0000; 149 address &= 0xFFFE0000;
150 temp &= 0x0001FFFF; 150 temp &= 0x0001FFFF;
151 length = (length - 1 ) >> 17; 151 length = (length - 1 ) >> 17;
152 length <<= 2; 152 length <<= 2;
153 153
154 switch (batnum) 154 switch (batnum)
155 { 155 {
156 case 0: 156 case 0:
157 __asm volatile ("mtdbatu 0, %0" : : "r" (address | length | 3)); 157 __asm volatile ("mtdbatu 0, %0" : : "r" (address | length | 3));
158 __asm volatile ("mtdbatl 0, %0" : : "r" (address | 0x22)); 158 __asm volatile ("mtdbatl 0, %0" : : "r" (address | 0x22));
159 break; 159 break;
160 case 1: 160 case 1:
161 __asm volatile ("mtdbatu 1, %0" : : "r" (address | length | 3)); 161 __asm volatile ("mtdbatu 1, %0" : : "r" (address | length | 3));
162 __asm volatile ("mtdbatl 1, %0" : : "r" (address | 0x22)); 162 __asm volatile ("mtdbatl 1, %0" : : "r" (address | 0x22));
163 break; 163 break;
164 case 2: 164 case 2:
165 __asm volatile ("mtdbatu 2, %0" : : "r" (address | length | 3)); 165 __asm volatile ("mtdbatu 2, %0" : : "r" (address | length | 3));
166 __asm volatile ("mtdbatl 2, %0" : : "r" (address | 0x22)); 166 __asm volatile ("mtdbatl 2, %0" : : "r" (address | 0x22));
167 break; 167 break;
168 case 3: 168 case 3:
169 __asm volatile ("mtdbatu 3, %0" : : "r" (address | length | 3)); 169 __asm volatile ("mtdbatu 3, %0" : : "r" (address | length | 3));
170 __asm volatile ("mtdbatl 3, %0" : : "r" (address | 0x22)); 170 __asm volatile ("mtdbatl 3, %0" : : "r" (address | 0x22));
171 break; 171 break;
172 } 172 }
173 } 173 }
174 174
175 int find_image(u32 rom_address, u32 rom_size, void **image, u32 *image_size); 175 int find_image(u32 rom_address, u32 rom_size, void **image, u32 *image_size);
176 176
177 int attempt_map_rom(pci_dev_t dev, void *copy_address) 177 int attempt_map_rom(pci_dev_t dev, void *copy_address)
178 { 178 {
179 u32 rom_size = 0; 179 u32 rom_size = 0;
180 u32 rom_address = 0; 180 u32 rom_address = 0;
181 u32 bar_size = 0; 181 u32 bar_size = 0;
182 u32 bar_backup = 0; 182 u32 bar_backup = 0;
183 int i,j; 183 int i,j;
184 void *image = 0; 184 void *image = 0;
185 u32 image_size = 0; 185 u32 image_size = 0;
186 int did_correct = 0; 186 int did_correct = 0;
187 u32 prefetch_addr = 0; 187 u32 prefetch_addr = 0;
188 u32 prefetch_size = 0; 188 u32 prefetch_size = 0;
189 u32 prefetch_idx = 0; 189 u32 prefetch_idx = 0;
190 190
191 /* Get the size of the expansion rom */ 191 /* Get the size of the expansion rom */
192 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0xFFFFFFFF); 192 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0xFFFFFFFF);
193 pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_size); 193 pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_size);
194 if ((rom_size & 0x01) == 0) 194 if ((rom_size & 0x01) == 0)
195 { 195 {
196 PRINTF("No ROM\n"); 196 PRINTF("No ROM\n");
197 return 0; 197 return 0;
198 } 198 }
199 199
200 rom_size &= 0xFFFFF800; 200 rom_size &= 0xFFFFF800;
201 rom_size = (~rom_size)+1; 201 rom_size = (~rom_size)+1;
202 202
203 PRINTF("ROM Size is %dK\n", rom_size/1024); 203 PRINTF("ROM Size is %dK\n", rom_size/1024);
204 204
205 /* 205 /*
206 * Try to find a place for the ROM. We always attempt to use 206 * Try to find a place for the ROM. We always attempt to use
207 * one of the card's bases for this, as this will be in any 207 * one of the card's bases for this, as this will be in any
208 * bridge's resource range as well as being free of conflicts 208 * bridge's resource range as well as being free of conflicts
209 * with other cards. In a graphics card it is very unlikely 209 * with other cards. In a graphics card it is very unlikely
210 * that there won't be any base address that is large enough to 210 * that there won't be any base address that is large enough to
211 * hold the rom. 211 * hold the rom.
212 * 212 *
213 * FIXME: To work around this, theoretically the largest base 213 * FIXME: To work around this, theoretically the largest base
214 * could be used if none is found in the loop below. 214 * could be used if none is found in the loop below.
215 */ 215 */
216 216
217 for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4) 217 for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4)
218 { 218 {
219 bar_size = get_bar_size(dev, i); 219 bar_size = get_bar_size(dev, i);
220 PRINTF("PCI_BASE_ADDRESS_%d is %dK large\n", 220 PRINTF("PCI_BASE_ADDRESS_%d is %dK large\n",
221 (i - PCI_BASE_ADDRESS_0)/4, 221 (i - PCI_BASE_ADDRESS_0)/4,
222 bar_size/1024); 222 bar_size/1024);
223 if (bar_size != 0xFFFFFFFF && bar_size >= rom_size) 223 if (bar_size != 0xFFFFFFFF && bar_size >= rom_size)
224 { 224 {
225 PRINTF("Found a match for rom size\n"); 225 PRINTF("Found a match for rom size\n");
226 pci_read_config_dword(dev, i, &rom_address); 226 pci_read_config_dword(dev, i, &rom_address);
227 rom_address &= 0xFFFFFFF0; 227 rom_address &= 0xFFFFFFF0;
228 if (rom_address != 0 && rom_address != 0xFFFFFFF0) break; 228 if (rom_address != 0 && rom_address != 0xFFFFFFF0) break;
229 } 229 }
230 } 230 }
231 231
232 if (rom_address == 0 || rom_address == 0xFFFFFFF0) 232 if (rom_address == 0 || rom_address == 0xFFFFFFF0)
233 { 233 {
234 PRINTF("No suitable rom address found\n"); 234 PRINTF("No suitable rom address found\n");
235 return 0; 235 return 0;
236 } 236 }
237 237
238 /* Disable the BAR */ 238 /* Disable the BAR */
239 pci_read_config_dword(dev, i, &bar_backup); 239 pci_read_config_dword(dev, i, &bar_backup);
240 pci_write_config_dword(dev, i, 0); 240 pci_write_config_dword(dev, i, 0);
241 241
242 /* Map ROM */ 242 /* Map ROM */
243 pci_write_config_dword(dev, PCI_ROM_ADDRESS, rom_address | PCI_ROM_ADDRESS_ENABLE); 243 pci_write_config_dword(dev, PCI_ROM_ADDRESS, rom_address | PCI_ROM_ADDRESS_ENABLE);
244 244
245 /* Copy the rom to a place in the emulator space */ 245 /* Copy the rom to a place in the emulator space */
246 PRINTF("Claiming BAT 2\n"); 246 PRINTF("Claiming BAT 2\n");
247 bat_map(2, rom_address, rom_size); 247 bat_map(2, rom_address, rom_size);
248 /* show_bat_mapping(); */ 248 /* show_bat_mapping(); */
249 249
250 if (0 == find_image(rom_address, rom_size, &image, &image_size)) 250 if (0 == find_image(rom_address, rom_size, &image, &image_size))
251 { 251 {
252 PRINTF("No x86 BIOS image found\n"); 252 PRINTF("No x86 BIOS image found\n");
253 return 0; 253 return 0;
254 } 254 }
255 255
256 PRINTF("Copying %ld bytes from 0x%lx to 0x%lx\n", (long)image_size, (long)image, (long)copy_address); 256 PRINTF("Copying %ld bytes from 0x%lx to 0x%lx\n", (long)image_size, (long)image, (long)copy_address);
257 257
258 /* memcpy(copy_address, rom_address, rom_size); */ 258 /* memcpy(copy_address, rom_address, rom_size); */
259 { 259 {
260 unsigned char *from = (unsigned char *)image; /* rom_address; */ 260 unsigned char *from = (unsigned char *)image; /* rom_address; */
261 unsigned char *to = (unsigned char *)copy_address; 261 unsigned char *to = (unsigned char *)copy_address;
262 for (j=0; j<image_size /*rom_size*/; j++) 262 for (j=0; j<image_size /*rom_size*/; j++)
263 { 263 {
264 *to++ = *from++; 264 *to++ = *from++;
265 } 265 }
266 } 266 }
267 267
268 PRINTF("Copy is done\n"); 268 PRINTF("Copy is done\n");
269 269
270 /* Unmap the ROM and restore the BAR */ 270 /* Unmap the ROM and restore the BAR */
271 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0); 271 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 0);
272 pci_write_config_dword(dev, i, bar_backup); 272 pci_write_config_dword(dev, i, bar_backup);
273 273
274 /* FIXME: */ 274 /* FIXME: Shouldn't be needed anymore*/
275 bat_map(2, 0x80000000, 256*1024*1024); 275 /* bat_map(2, 0x80000000, 256*1024*1024);
276 show_bat_mapping(); 276 show_bat_mapping(); */
277 277
278 /* 278 /*
279 * Since most cards can probably only do 16 bit IO addressing, we 279 * Since most cards can probably only do 16 bit IO addressing, we
280 * correct their IO base into an appropriate value. 280 * correct their IO base into an appropriate value.
281 * This should do for most. 281 * This should do for most.
282 */ 282 */
283 for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4) 283 for (i = PCI_BASE_ADDRESS_0; i <= PCI_BASE_ADDRESS_5; i += 4)
284 { 284 {
285 unsigned long value; 285 unsigned long value;
286 pci_read_config_dword(dev, i, &value); 286 pci_read_config_dword(dev, i, &value);
287 if (value & 0x01) /* IO */ 287 if (value & 0x01) /* IO */
288 { 288 {
289 did_correct = 1; 289 did_correct = 1;
290 pci_write_config_dword(dev, i, 0x1001); 290 pci_write_config_dword(dev, i, 0x1001);
291 break; 291 break;
292 } 292 }
293 293
294 if (value & PCI_BASE_ADDRESS_MEM_PREFETCH) 294 if (value & PCI_BASE_ADDRESS_MEM_PREFETCH)
295 { 295 {
296 prefetch_idx = i; 296 prefetch_idx = i;
297 prefetch_addr = value & PCI_BASE_ADDRESS_MEM_MASK; 297 prefetch_addr = value & PCI_BASE_ADDRESS_MEM_MASK;
298 prefetch_size = get_bar_size(dev, i); 298 prefetch_size = get_bar_size(dev, i);
299 } 299 }
300 } 300 }
301 301
302 if (1) /* did_correct) */ 302 if (1) /* did_correct) */
303 { 303 {
304 extern pci_dev_t pci_find_bridge_for_bus(struct pci_controller *hose, int busnr); 304 extern pci_dev_t pci_find_bridge_for_bus(struct pci_controller *hose, int busnr);
305 int busnr = PCI_BUS(dev); 305 int busnr = PCI_BUS(dev);
306 if (busnr) 306 if (busnr)
307 { 307 {
308 pci_dev_t bridge; 308 pci_dev_t bridge;
309 PRINTF("Need to correct bridge device for IO range change\n"); 309 PRINTF("Need to correct bridge device for IO range change\n");
310 bridge = pci_find_bridge_for_bus(NULL, busnr); 310 bridge = pci_find_bridge_for_bus(NULL, busnr);
311 if (bridge == PCI_ANY_ID) 311 if (bridge == PCI_ANY_ID)
312 { 312 {
313 PRINTF("Didn't find bridge. Hope that's OK\n"); 313 PRINTF("Didn't find bridge. Hope that's OK\n");
314 } 314 }
315 else 315 else
316 { 316 {
317 /* 317 /*
318 * Set upper I/O base/limit to 0 318 * Set upper I/O base/limit to 0
319 */ 319 */
320 pci_write_config_byte(bridge, 0x30, 0x00); 320 pci_write_config_byte(bridge, 0x30, 0x00);
321 pci_write_config_byte(bridge, 0x31, 0x00); 321 pci_write_config_byte(bridge, 0x31, 0x00);
322 pci_write_config_byte(bridge, 0x32, 0x00); 322 pci_write_config_byte(bridge, 0x32, 0x00);
323 pci_write_config_byte(bridge, 0x33, 0x00); 323 pci_write_config_byte(bridge, 0x33, 0x00);
324 if (did_correct) 324 if (did_correct)
325 { 325 {
326 /* 326 /*
327 * set lower I/O base to 1000 327 * set lower I/O base to 1000
328 * That is, bits 0:3 are set to 0001 by default. 328 * That is, bits 0:3 are set to 0001 by default.
329 * bits 7:4 contain I/O address bits 15:12 329 * bits 7:4 contain I/O address bits 15:12
330 * all others are assumed 0. 330 * all others are assumed 0.
331 */ 331 */
332 pci_write_config_byte(bridge, 0x1C, 0x11); 332 pci_write_config_byte(bridge, 0x1C, 0x11);
333 /* 333 /*
334 * Set lower I/O limit to 1FFF 334 * Set lower I/O limit to 1FFF
335 * That is, bits 0:3 are reserved and always 0000 335 * That is, bits 0:3 are reserved and always 0000
336 * Bits 7:4 contain I/O address bits 15:12 336 * Bits 7:4 contain I/O address bits 15:12
337 * All others are assumed F. 337 * All others are assumed F.
338 */ 338 */
339 pci_write_config_byte(bridge, 0x1D, 0x10); 339 pci_write_config_byte(bridge, 0x1D, 0x10);
340 pci_write_config_byte(bridge, 0x0D, 0x20); 340 pci_write_config_byte(bridge, 0x0D, 0x20);
341 PRINTF("Corrected bridge resource range of bridge at %02x:%02x:%02x\n", 341 PRINTF("Corrected bridge resource range of bridge at %02x:%02x:%02x\n",
342 PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge)); 342 PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge));
343 343
344 } 344 }
345 else 345 else
346 { 346 {
347 /* 347 /*
348 * This card doesn't have I/O, we disable I/O forwarding 348 * This card doesn't have I/O, we disable I/O forwarding
349 */ 349 */
350 pci_write_config_byte(bridge, 0x1C, 0x11); 350 pci_write_config_byte(bridge, 0x1C, 0x11);
351 pci_write_config_byte(bridge, 0x1D, 0x00); 351 pci_write_config_byte(bridge, 0x1D, 0x00);
352 pci_write_config_byte(bridge, PCI_INTERRUPT_LINE, 0); 352 pci_write_config_byte(bridge, PCI_INTERRUPT_LINE, 0);
353 pci_write_config_byte(bridge, PCI_INTERRUPT_PIN, 0); 353 pci_write_config_byte(bridge, PCI_INTERRUPT_PIN, 0);
354 pci_write_config_dword(bridge, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_IO); 354 pci_write_config_dword(bridge, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_IO);
355 PRINTF("Disabled bridge resource range of bridge at %02x:%02x:%02x\n", 355 PRINTF("Disabled bridge resource range of bridge at %02x:%02x:%02x\n",
356 PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge)); 356 PCI_BUS(bridge), PCI_DEV(bridge), PCI_FUNC(bridge));
357 357
358 } 358 }
359 } 359 }
360 /* 360 /*
361 * Correct the prefetchable memory base, which is not set correctly by 361 * Correct the prefetchable memory base, which is not set correctly by
362 * the U-Boot autoconfig stuff 362 * the U-Boot autoconfig stuff
363 */ 363 */
364 if (prefetch_idx) 364 if (prefetch_idx)
365 { 365 {
366 /* PRINTF("Setting prefetchable range to %x, %x (%x and %x)\n", */ 366 /* PRINTF("Setting prefetchable range to %x, %x (%x and %x)\n", */
367 /* prefetch_addr, prefetch_addr+prefetch_size, */ 367 /* prefetch_addr, prefetch_addr+prefetch_size, */
368 /* prefetch_addr>>16, (prefetch_addr+prefetch_size)>>16); */ 368 /* prefetch_addr>>16, (prefetch_addr+prefetch_size)>>16); */
369 /* pci_write_config_word(bridge, PCI_PREF_MEMORY_BASE, (prefetch_addr>>16)); */ 369 /* pci_write_config_word(bridge, PCI_PREF_MEMORY_BASE, (prefetch_addr>>16)); */
370 /* pci_write_config_word(bridge, PCI_PREF_MEMORY_LIMIT, (prefetch_addr+prefetch_size)>>16); */ 370 /* pci_write_config_word(bridge, PCI_PREF_MEMORY_LIMIT, (prefetch_addr+prefetch_size)>>16); */
371 } 371 }
372 372
373 pci_write_config_word(bridge, PCI_PREF_MEMORY_BASE, 0x1000); 373 pci_write_config_word(bridge, PCI_PREF_MEMORY_BASE, 0x1000);
374 pci_write_config_word(bridge, PCI_PREF_MEMORY_LIMIT, 0x0000); 374 pci_write_config_word(bridge, PCI_PREF_MEMORY_LIMIT, 0x0000);
375 375
376 pci_write_config_byte(bridge, 0xD0, 0x0A); 376 pci_write_config_byte(bridge, 0xD0, 0x0A);
377 pci_write_config_byte(bridge, 0xD3, 0x04); 377 pci_write_config_byte(bridge, 0xD3, 0x04);
378 378
379 /* 379 /*
380 * Set the interrupt pin to 0 380 * Set the interrupt pin to 0
381 */ 381 */
382 #if 0 382 #if 0
383 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 0); 383 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 0);
384 pci_write_config_byte(dev, PCI_INTERRUPT_PIN, 0); 384 pci_write_config_byte(dev, PCI_INTERRUPT_PIN, 0);
385 #endif 385 #endif
386 pci_write_config_byte(bridge, PCI_INTERRUPT_LINE, 0); 386 pci_write_config_byte(bridge, PCI_INTERRUPT_LINE, 0);
387 pci_write_config_byte(bridge, PCI_INTERRUPT_PIN, 0); 387 pci_write_config_byte(bridge, PCI_INTERRUPT_PIN, 0);
388 388
389 } 389 }
390 } 390 }
391 391
392 /* Finally, enable the card's IO and memory response */ 392 /* Finally, enable the card's IO and memory response */
393 pci_write_config_dword(dev, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_IO); 393 pci_write_config_dword(dev, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
394 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0); 394 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0);
395 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0); 395 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0);
396 396
397 return 1; 397 return 1;
398 } 398 }
399 399
400 int find_image(u32 rom_address, u32 rom_size, void **image, u32 *image_size) 400 int find_image(u32 rom_address, u32 rom_size, void **image, u32 *image_size)
401 { 401 {
402 int i = 0; 402 int i = 0;
403 unsigned char *rom = (unsigned char *)rom_address; 403 unsigned char *rom = (unsigned char *)rom_address;
404 /* if (*rom != 0x55 || *(rom+1) != 0xAA) return 0; // No bios rom this is, yes. */ 404 /* if (*rom != 0x55 || *(rom+1) != 0xAA) return 0; // No bios rom this is, yes. */
405 405
406 for (;;) 406 for (;;)
407 { 407 {
408 unsigned short pci_data_offset = *(rom+0x18) + 256 * *(rom+0x19); 408 unsigned short pci_data_offset = *(rom+0x18) + 256 * *(rom+0x19);
409 unsigned short pci_image_length = (*(rom+pci_data_offset+0x10) + 256 * *(rom+pci_data_offset+0x11)) * 512; 409 unsigned short pci_image_length = (*(rom+pci_data_offset+0x10) + 256 * *(rom+pci_data_offset+0x11)) * 512;
410 unsigned char pci_image_type = *(rom+pci_data_offset+0x14); 410 unsigned char pci_image_type = *(rom+pci_data_offset+0x14);
411 if (*rom != 0x55 || *(rom+1) != 0xAA) 411 if (*rom != 0x55 || *(rom+1) != 0xAA)
412 { 412 {
413 PRINTF("Invalid header this is\n"); 413 PRINTF("Invalid header this is\n");
414 return 0; 414 return 0;
415 } 415 }
416 PRINTF("Image %i: Type %d (%s)\n", i++, pci_image_type, 416 PRINTF("Image %i: Type %d (%s)\n", i++, pci_image_type,
417 pci_image_type==0 ? "x86" : 417 pci_image_type==0 ? "x86" :
418 pci_image_type==1 ? "OpenFirmware" : 418 pci_image_type==1 ? "OpenFirmware" :
419 "Unknown"); 419 "Unknown");
420 if (pci_image_type == 0) 420 if (pci_image_type == 0)
421 { 421 {
422 *image = rom; 422 *image = rom;
423 *image_size = pci_image_length; 423 *image_size = pci_image_length;
424 return 1; 424 return 1;
425 } 425 }
426 426
427 if (*(rom+pci_data_offset+0x15) & 0x80) 427 if (*(rom+pci_data_offset+0x15) & 0x80)
428 { 428 {
429 PRINTF("LAST image encountered, no image found\n"); 429 PRINTF("LAST image encountered, no image found\n");
430 return 0; 430 return 0;
431 } 431 }
432 432
433 rom += pci_image_length; 433 rom += pci_image_length;
434 } 434 }
435 } 435 }
436 436
437 void show_bat_mapping(void) 437 void show_bat_mapping(void)
438 { 438 {
439 #ifdef DEBUG
440 u32 dbat0u, dbat0l, ibat0u, ibat0l; 439 u32 dbat0u, dbat0l, ibat0u, ibat0l;
441 u32 dbat1u, dbat1l, ibat1u, ibat1l; 440 u32 dbat1u, dbat1l, ibat1u, ibat1l;
442 u32 dbat2u, dbat2l, ibat2u, ibat2l; 441 u32 dbat2u, dbat2l, ibat2u, ibat2l;
443 u32 dbat3u, dbat3l, ibat3u, ibat3l; 442 u32 dbat3u, dbat3l, ibat3u, ibat3l;
444 u32 msr, hid0, l2cr_reg; 443 u32 msr, hid0, l2cr_reg;
445 444
446 __asm volatile ("mfdbatu %0,0" : "=r" (dbat0u)); 445 __asm volatile ("mfdbatu %0,0" : "=r" (dbat0u));
447 __asm volatile ("mfdbatl %0,0" : "=r" (dbat0l)); 446 __asm volatile ("mfdbatl %0,0" : "=r" (dbat0l));
448 __asm volatile ("mfibatu %0,0" : "=r" (ibat0u)); 447 __asm volatile ("mfibatu %0,0" : "=r" (ibat0u));
449 __asm volatile ("mfibatl %0,0" : "=r" (ibat0l)); 448 __asm volatile ("mfibatl %0,0" : "=r" (ibat0l));
450 449
451 __asm volatile ("mfdbatu %0,1" : "=r" (dbat1u)); 450 __asm volatile ("mfdbatu %0,1" : "=r" (dbat1u));
452 __asm volatile ("mfdbatl %0,1" : "=r" (dbat1l)); 451 __asm volatile ("mfdbatl %0,1" : "=r" (dbat1l));
453 __asm volatile ("mfibatu %0,1" : "=r" (ibat1u)); 452 __asm volatile ("mfibatu %0,1" : "=r" (ibat1u));
454 __asm volatile ("mfibatl %0,1" : "=r" (ibat1l)); 453 __asm volatile ("mfibatl %0,1" : "=r" (ibat1l));
455 454
456 __asm volatile ("mfdbatu %0,2" : "=r" (dbat2u)); 455 __asm volatile ("mfdbatu %0,2" : "=r" (dbat2u));
457 __asm volatile ("mfdbatl %0,2" : "=r" (dbat2l)); 456 __asm volatile ("mfdbatl %0,2" : "=r" (dbat2l));
458 __asm volatile ("mfibatu %0,2" : "=r" (ibat2u)); 457 __asm volatile ("mfibatu %0,2" : "=r" (ibat2u));
459 __asm volatile ("mfibatl %0,2" : "=r" (ibat2l)); 458 __asm volatile ("mfibatl %0,2" : "=r" (ibat2l));
460 459
461 __asm volatile ("mfdbatu %0,3" : "=r" (dbat3u)); 460 __asm volatile ("mfdbatu %0,3" : "=r" (dbat3u));
462 __asm volatile ("mfdbatl %0,3" : "=r" (dbat3l)); 461 __asm volatile ("mfdbatl %0,3" : "=r" (dbat3l));
463 __asm volatile ("mfibatu %0,3" : "=r" (ibat3u)); 462 __asm volatile ("mfibatu %0,3" : "=r" (ibat3u));
464 __asm volatile ("mfibatl %0,3" : "=r" (ibat3l)); 463 __asm volatile ("mfibatl %0,3" : "=r" (ibat3l));
465 464
466 __asm volatile ("mfmsr %0" : "=r" (msr)); 465 __asm volatile ("mfmsr %0" : "=r" (msr));
467 __asm volatile ("mfspr %0,1008": "=r" (hid0)); 466 __asm volatile ("mfspr %0,1008": "=r" (hid0));
468 __asm volatile ("mfspr %0,1017": "=r" (l2cr_reg)); 467 __asm volatile ("mfspr %0,1017": "=r" (l2cr_reg));
469 468
470 printf("dbat0u: %08x dbat0l: %08x ibat0u: %08x ibat0l: %08x\n", 469 printf("dbat0u: %08x dbat0l: %08x ibat0u: %08x ibat0l: %08x\n",
471 dbat0u, dbat0l, ibat0u, ibat0l); 470 dbat0u, dbat0l, ibat0u, ibat0l);
472 printf("dbat1u: %08x dbat1l: %08x ibat1u: %08x ibat1l: %08x\n", 471 printf("dbat1u: %08x dbat1l: %08x ibat1u: %08x ibat1l: %08x\n",
473 dbat1u, dbat1l, ibat1u, ibat1l); 472 dbat1u, dbat1l, ibat1u, ibat1l);
474 printf("dbat2u: %08x dbat2l: %08x ibat2u: %08x ibat2l: %08x\n", 473 printf("dbat2u: %08x dbat2l: %08x ibat2u: %08x ibat2l: %08x\n",
475 dbat2u, dbat2l, ibat2u, ibat2l); 474 dbat2u, dbat2l, ibat2u, ibat2l);
476 printf("dbat3u: %08x dbat3l: %08x ibat3u: %08x ibat3l: %08x\n", 475 printf("dbat3u: %08x dbat3l: %08x ibat3u: %08x ibat3l: %08x\n",
477 dbat3u, dbat3l, ibat3u, ibat3l); 476 dbat3u, dbat3l, ibat3u, ibat3l);
478 477
479 printf("\nMSR: %08x HID0: %08x L2CR: %08x \n", msr,hid0, l2cr_reg); 478 printf("\nMSR: %08x HID0: %08x L2CR: %08x \n", msr,hid0, l2cr_reg);
480 #endif
481 } 479 }
482 480
483 481
484 482
485 void remove_init_data(void) 483 void remove_init_data(void)
486 { 484 {
487 char *s; 485 char *s;
488 u32 batl = ((CFG_SDRAM_BASE+0x100000) | BATL_PP_RW);
489 u32 batu =((CFG_SDRAM_BASE+0x100000) | BATU_BL_256M | BATU_VS | BATU_VP);
490 #if 0 /* already done in board_init_r() */
491 void *data = (void *)(CFG_INIT_RAM_ADDR+CFG_INIT_DATA_OFFSET);
492 unsigned char data2[CFG_INIT_DATA_SIZE];
493 486
494 /* Make a copy of the data */
495 memcpy(data2, data, CFG_INIT_DATA_SIZE);
496 #endif /* 0 */
497
498 /* Invalidate and disable data cache */ 487 /* Invalidate and disable data cache */
499 invalidate_l1_data_cache(); 488 invalidate_l1_data_cache();
500 dcache_disable(); 489 dcache_disable();
501 490
502 #if 0
503 /* Copy to the real RAM address */
504 memcpy(data, data2, CFG_INIT_DATA_SIZE);
505 #endif
506
507 /*printf("Before ICache enable\n");
508 show_bat_mapping();*/
509
510 __asm volatile ("isync \n"
511 "mtdbatu 2,%2 \n"
512 "mtdbatl 2,%2 \n"
513 "mtdbatu 1,%0 \n"
514 "mtdbatl 1,%1 \n"
515 "sync \n"
516 "isync \n"
517 : : "r" (batu), "r" (batl), "r" (0));
518
519 /* show_bat_mapping(); */
520 s = getenv("x86_cache"); 491 s = getenv("x86_cache");
521 492
522 if (!s || (s && strcmp(s, "on")==0)) 493 if (!s)
523 { 494 {
524 icache_enable(); 495 icache_enable();
525 dcache_enable(); 496 dcache_enable();
526 } 497 }
498 else if (s)
499 {
500 if (strcmp(s, "dcache")==0)
board/MAI/bios_emulator/scitech/src/x86emu/makefile.uboot
File was created 1 #############################################################################
2 #
3 # Realmode X86 Emulator Library
4 #
5 # Copyright (C) 1996-1999 SciTech Software, Inc.
6 #
7 # ========================================================================
8 #
9 # Permission to use, copy, modify, distribute, and sell this software and
10 # its documentation for any purpose is hereby granted without fee,
11 # provided that the above copyright notice appear in all copies and that
12 # both that copyright notice and this permission notice appear in
13 # supporting documentation, and that the name of the authors not be used
14 # in advertising or publicity pertaining to distribution of the software
15 # without specific, written prior permission. The authors makes no
16 # representations about the suitability of this software for any purpose.
17 # It is provided "as is" without express or implied warranty.
18 #
19 # THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
21 # EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
23 # USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25 # PERFORMANCE OF THIS SOFTWARE.
26 #
27 # ========================================================================
28 #
29 # Descripton: Linux specific makefile for the x86emu library.
30 #
31 #############################################################################
32 CC = $(CROSS_COMPILE)gcc
33 AR = $(CROSS_COMPILE)ar
34 TARGETLIB = libx86emu.a
35 TARGETDEBUGLIB =libx86emud.a
36
37 OBJS=\
38 decode.o \
39 fpu.o \
40 ops.o \
41 ops2.o \
42 prim_ops.o \
43 sys.o
44
45 DEBUGOBJS=debug.d \
46 decode.d \
47 fpu.d \
48 ops.d \
49 ops2.d \
50 prim_ops.d \
51 sys.d
52
53 .SUFFIXES: .d
54
55 all: $(TARGETLIB) $(TARGETDEBUGLIB)
56
57 $(TARGETLIB): $(OBJS)
58 $(AR) rv $(TARGETLIB) $(OBJS)
59
60 $(TARGETDEBUGLIB): $(DEBUGOBJS)
61 $(AR) rv $(TARGETDEBUGLIB) $(DEBUGOBJS)
62
63 INCS = -I. -Ix86emu -I../../include
64 CFLAGS = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG -Dprintk=printf -fsigned-char -fomit-frame-pointer -mrelocatable -ffixed-r14 -meabi -mrelocatable -ffixed-r14 -meabi
65 CDEBUGFLAGS = -DDEBUG
66
67 .c.o:
68 $(CC) -g -O2 -Wall -c $(CFLAGS) $(INCS) $*.c
69
70 .c.d:
71 $(CC) -g -O2 -Wall -c -o$*.d $(CFLAGS) $(CDEBUGFLAGS) $(INCS) $*.c
72
73 .cpp.o:
74 $(CC) -c $(CFLAGS) $(INCS) $*.cpp
75
76 clean:
77 rm -f *.a *.o *.d
78
79 validate: validate.o libx86emu.a
80 $(CC) -o validate validate.o -lx86emu -L.
81
board/MAI/bios_emulator/x86interface.c
1 #include "x86emu.h" 1 #include "x86emu.h"
2 #include "glue.h" 2 #include "glue.h"
3 3
4 4
5 /* 5 /*
6 * This isn't nice, but there are a lot of incompatibilities in the U-Boot and scitech include 6 * This isn't nice, but there are a lot of incompatibilities in the U-Boot and scitech include
7 * files that this is the only really workable solution. 7 * files that this is the only really workable solution.
8 * Might be cleaned out later. 8 * Might be cleaned out later.
9 */ 9 */
10 10
11 #ifdef DEBUG 11 #ifdef DEBUG
12 #undef DEBUG 12 #undef DEBUG
13 #endif 13 #endif
14 14
15 #undef IO_LOGGING 15 #undef IO_LOGGING
16 #undef MEM_LOGGING 16 #undef MEM_LOGGING
17 17
18 #ifdef IO_LOGGING 18 #ifdef IO_LOGGING
19 #define LOGIO(port, format, args...) if (dolog(port)) _printf(format , ## args) 19 #define LOGIO(port, format, args...) if (dolog(port)) _printf(format , ## args)
20 #else 20 #else
21 #define LOGIO(port, format, args...) 21 #define LOGIO(port, format, args...)
22 #endif 22 #endif
23 23
24 #ifdef MEM_LOGGIN 24 #ifdef MEM_LOGGIN
25 #define LOGMEM(format, args...) _printf(format , ## args) 25 #define LOGMEM(format, args...) _printf(format , ## args)
26 #else 26 #else
27 #define LOGMEM(format, args...) 27 #define LOGMEM(format, args...)
28 #endif 28 #endif
29 29
30 #ifdef DEBUG 30 #ifdef DEBUG
31 #define PRINTF(format, args...) _printf(format , ## args) 31 #define PRINTF(format, args...) _printf(format , ## args)
32 #else 32 #else
33 #define PRINTF(format, argc...) 33 #define PRINTF(format, argc...)
34 #endif 34 #endif
35 35
36 typedef unsigned char UBYTE; 36 typedef unsigned char UBYTE;
37 typedef unsigned short UWORD; 37 typedef unsigned short UWORD;
38 typedef unsigned long ULONG; 38 typedef unsigned long ULONG;
39 39
40 typedef char BYTE; 40 typedef char BYTE;
41 typedef short WORT; 41 typedef short WORT;
42 typedef long LONG; 42 typedef long LONG;
43 43
44 #define EMULATOR_MEM_SIZE (1024*1024) 44 #define EMULATOR_MEM_SIZE (1024*1024)
45 #define EMULATOR_BIOS_OFFSET 0xC0000 45 #define EMULATOR_BIOS_OFFSET 0xC0000
46 #define EMULATOR_STRAP_OFFSET 0x30000 46 #define EMULATOR_STRAP_OFFSET 0x30000
47 #define EMULATOR_STACK_OFFSET 0x20000 47 #define EMULATOR_STACK_OFFSET 0x20000
48 #define EMULATOR_LOGO_OFFSET 0x40000 // If you change this, change the strap code, too 48 #define EMULATOR_LOGO_OFFSET 0x40000 // If you change this, change the strap code, too
49 #define VIDEO_BASE (void *)0xFD0B8000 49 #define VIDEO_BASE (void *)0xFD0B8000
50 50
51 extern char *getenv(char *); 51 extern char *getenv(char *);
52 extern int tstc(void); 52 extern int tstc(void);
53 extern int getc(void); 53 extern int getc(void);
54 extern unsigned char video_get_attr(void); 54 extern unsigned char video_get_attr(void);
55 55
56 int atoi(char *string) 56 int atoi(char *string)
57 { 57 {
58 int res = 0; 58 int res = 0;
59 while (*string>='0' && *string <='9') 59 while (*string>='0' && *string <='9')
60 { 60 {
61 res *= 10; 61 res *= 10;
62 res += *string-'0'; 62 res += *string-'0';
63 string++; 63 string++;
64 } 64 }
65 65
66 return res; 66 return res;
67 } 67 }
68 68
69 void cons_gets(char *buffer) 69 void cons_gets(char *buffer)
70 { 70 {
71 int i = 0; 71 int i = 0;
72 char c = 0; 72 char c = 0;
73 73
74 buffer[0] = 0; 74 buffer[0] = 0;
75 if (getenv("x86_runthru")) return; //FIXME: 75 if (getenv("x86_runthru")) return; //FIXME:
76 while (c != 0x0D && c != 0x0A) 76 while (c != 0x0D && c != 0x0A)
77 { 77 {
78 while (!tstc()); 78 while (!tstc());
79 c = getc(); 79 c = getc();
80 if (c>=32 && c < 127) 80 if (c>=32 && c < 127)
81 { 81 {
82 buffer[i] = c; 82 buffer[i] = c;
83 i++; 83 i++;
84 buffer[i] = 0; 84 buffer[i] = 0;
85 putc(c); 85 putc(c);
86 } 86 }
87 else 87 else
88 { 88 {
89 if (c == 0x08) 89 if (c == 0x08)
90 { 90 {
91 if (i>0) i--; 91 if (i>0) i--;
92 buffer[i] = 0; 92 buffer[i] = 0;
93 } 93 }
94 } 94 }
95 } 95 }
96 buffer[i] = '\n'; 96 buffer[i] = '\n';
97 buffer[i+1] = 0; 97 buffer[i+1] = 0;
98 } 98 }
99 99
100 char *bios_date = "08/14/02"; 100 char *bios_date = "08/14/02";
101 UBYTE model = 0xFC; 101 UBYTE model = 0xFC;
102 UBYTE submodel = 0x00; 102 UBYTE submodel = 0x00;
103 103
104 static inline UBYTE read_byte(volatile UBYTE* from) 104 static inline UBYTE read_byte(volatile UBYTE* from)
105 { 105 {
106 int x; 106 int x;
107 asm volatile ("lbz %0,%1\n eieio" : "=r" (x) : "m" (*from)); 107 asm volatile ("lbz %0,%1\n eieio" : "=r" (x) : "m" (*from));
108 return (UBYTE)x; 108 return (UBYTE)x;
109 } 109 }
110 110
111 static inline void write_byte(volatile UBYTE *to, int x) 111 static inline void write_byte(volatile UBYTE *to, int x)
112 { 112 {
113 asm volatile ("stb %1,%0\n eieio" : "=m" (*to) : "r" (x)); 113 asm volatile ("stb %1,%0\n eieio" : "=m" (*to) : "r" (x));
114 } 114 }
115 115
116 static inline UWORD read_word_little(volatile UWORD *from) 116 static inline UWORD read_word_little(volatile UWORD *from)
117 { 117 {
118 int x; 118 int x;
119 asm volatile ("lhbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m" (*from)); 119 asm volatile ("lhbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m" (*from));
120 return (UWORD)x; 120 return (UWORD)x;
121 } 121 }
122 122
123 static inline UWORD read_word_big(volatile UWORD *from) 123 static inline UWORD read_word_big(volatile UWORD *from)
124 { 124 {
125 int x; 125 int x;
126 asm volatile ("lhz %0,%1\n eieio" : "=r" (x) : "m" (*from)); 126 asm volatile ("lhz %0,%1\n eieio" : "=r" (x) : "m" (*from));
127 return (UWORD)x; 127 return (UWORD)x;
128 } 128 }
129 129
130 static inline void write_word_little(volatile UWORD *to, int x) 130 static inline void write_word_little(volatile UWORD *to, int x)
131 { 131 {
132 asm volatile ("sthbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to)); 132 asm volatile ("sthbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to));
133 } 133 }
134 134
135 static inline void write_word_big(volatile UWORD *to, int x) 135 static inline void write_word_big(volatile UWORD *to, int x)
136 { 136 {
137 asm volatile ("sth %1,%0\n eieio" : "=m" (*to) : "r" (x)); 137 asm volatile ("sth %1,%0\n eieio" : "=m" (*to) : "r" (x));
138 } 138 }
139 139
140 static inline ULONG read_long_little(volatile ULONG *from) 140 static inline ULONG read_long_little(volatile ULONG *from)
141 { 141 {
142 unsigned long x; 142 unsigned long x;
143 asm volatile ("lwbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m"(*from)); 143 asm volatile ("lwbrx %0,0,%1\n eieio" : "=r" (x) : "r" (from), "m"(*from));
144 return (ULONG)x; 144 return (ULONG)x;
145 } 145 }
146 146
147 static inline ULONG read_long_big(volatile ULONG *from) 147 static inline ULONG read_long_big(volatile ULONG *from)
148 { 148 {
149 unsigned long x; 149 unsigned long x;
150 asm volatile ("lwz %0,%1\n eieio" : "=r" (x) : "m" (*from)); 150 asm volatile ("lwz %0,%1\n eieio" : "=r" (x) : "m" (*from));
151 return (ULONG)x; 151 return (ULONG)x;
152 } 152 }
153 153
154 static inline void write_long_little(volatile ULONG *to, ULONG x) 154 static inline void write_long_little(volatile ULONG *to, ULONG x)
155 { 155 {
156 asm volatile ("stwbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to)); 156 asm volatile ("stwbrx %1,0,%2\n eieio" : "=m" (*to) : "r" (x), "r" (to));
157 } 157 }
158 158
159 static inline void write_long_big(volatile ULONG *to, ULONG x) 159 static inline void write_long_big(volatile ULONG *to, ULONG x)
160 { 160 {
161 asm volatile ("stw %1,%0\n eieio" : "=m" (*to) : "r" (x)); 161 asm volatile ("stw %1,%0\n eieio" : "=m" (*to) : "r" (x));
162 } 162 }
163 163
164 static int log_init = 0; 164 static int log_init = 0;
165 static int log_do = 0; 165 static int log_do = 0;
166 static int log_low = 0; 166 static int log_low = 0;
167 167
168 int dolog(int port) 168 int dolog(int port)
169 { 169 {
170 if (log_init && log_do) 170 if (log_init && log_do)
171 { 171 {
172 if (log_low && port > 0x400) return 0; 172 if (log_low && port > 0x400) return 0;
173 return 1; 173 return 1;
174 } 174 }
175 175
176 if (!log_init) 176 if (!log_init)
177 { 177 {
178 log_init = 1; 178 log_init = 1;
179 log_do = (getenv("x86_logio") != (char *)0); 179 log_do = (getenv("x86_logio") != (char *)0);
180 log_low = (getenv("x86_loglow") != (char *)0); 180 log_low = (getenv("x86_loglow") != (char *)0);
181 if (log_do) 181 if (log_do)
182 { 182 {
183 if (log_low && port > 0x400) return 0; 183 if (log_low && port > 0x400) return 0;
184 return 1; 184 return 1;
185 } 185 }
186 } 186 }
187 return 0; 187 return 0;
188 } 188 }
189 189
190 // Converts an emulator address to a physical address. 190 // Converts an emulator address to a physical address.
191 // Handles all special cases (bios date, model etc), and might need work 191 // Handles all special cases (bios date, model etc), and might need work
192 u32 memaddr(u32 addr) 192 u32 memaddr(u32 addr)
193 { 193 {
194 // if (addr >= 0xF0000 && addr < 0xFFFFF) printf("WARNING: Segment F access (0x%x)\n", addr); 194 // if (addr >= 0xF0000 && addr < 0xFFFFF) printf("WARNING: Segment F access (0x%x)\n", addr);
195 // printf("MemAddr=%p\n", addr); 195 // printf("MemAddr=%p\n", addr);
196 if (addr >= 0xA0000 && addr < 0xC0000) 196 if (addr >= 0xA0000 && addr < 0xC0000)
197 return 0xFD000000 + addr; 197 return 0xFD000000 + addr;
198 else if (addr >= 0xFFFF5 && addr < 0xFFFFE) 198 else if (addr >= 0xFFFF5 && addr < 0xFFFFE)
199 { 199 {
200 return (u32)bios_date+addr-0xFFFF5; 200 return (u32)bios_date+addr-0xFFFF5;
201 } 201 }
202 else if (addr == 0xFFFFE) 202 else if (addr == 0xFFFFE)
203 return (u32)&model; 203 return (u32)&model;
204 else if (addr == 0xFFFFF) 204 else if (addr == 0xFFFFF)
205 return (u32)&submodel; 205 return (u32)&submodel;
206 else if (addr >= 0x80000000) 206 else if (addr >= 0x80000000)
207 { 207 {
208 //printf("Warning: High memory access at 0x%x\n", addr); 208 //printf("Warning: High memory access at 0x%x\n", addr);
209 return addr; 209 return addr;
210 } 210 }
211 else 211 else
212 return (u32)M.mem_base+addr; 212 return (u32)M.mem_base+addr;
213 } 213 }
214 214
215 u8 A1_rdb(u32 addr) 215 u8 A1_rdb(u32 addr)
216 { 216 {
217 u8 a = read_byte((UBYTE *)memaddr(addr)); 217 u8 a = read_byte((UBYTE *)memaddr(addr));
218 LOGMEM("rdb: %x -> %x\n", addr, a); 218 LOGMEM("rdb: %x -> %x\n", addr, a);
219 return a; 219 return a;
220 } 220 }
221 221
222 u16 A1_rdw(u32 addr) 222 u16 A1_rdw(u32 addr)
223 { 223 {
224 u16 a = read_word_little((UWORD *)memaddr(addr)); 224 u16 a = read_word_little((UWORD *)memaddr(addr));
225 LOGMEM("rdw: %x -> %x\n", addr, a); 225 LOGMEM("rdw: %x -> %x\n", addr, a);
226 return a; 226 return a;
227 } 227 }
228 228
229 u32 A1_rdl(u32 addr) 229 u32 A1_rdl(u32 addr)
230 { 230 {
231 u32 a = read_long_little((ULONG *)memaddr(addr)); 231 u32 a = read_long_little((ULONG *)memaddr(addr));
232 LOGMEM("rdl: %x -> %x\n", addr, a); 232 LOGMEM("rdl: %x -> %x\n", addr, a);
233 return a; 233 return a;
234 } 234 }
235 235
236 void A1_wrb(u32 addr, u8 val) 236 void A1_wrb(u32 addr, u8 val)
237 { 237 {
238 LOGMEM("wrb: %x <- %x\n", addr, val); 238 LOGMEM("wrb: %x <- %x\n", addr, val);
239 write_byte((UBYTE *)memaddr(addr), val); 239 write_byte((UBYTE *)memaddr(addr), val);
240 } 240 }
241 241
242 void A1_wrw(u32 addr, u16 val) 242 void A1_wrw(u32 addr, u16 val)
243 { 243 {
244 LOGMEM("wrw: %x <- %x\n", addr, val); 244 LOGMEM("wrw: %x <- %x\n", addr, val);
245 write_word_little((UWORD *)memaddr(addr), val); 245 write_word_little((UWORD *)memaddr(addr), val);
246 } 246 }
247 247
248 void A1_wrl(u32 addr, u32 val) 248 void A1_wrl(u32 addr, u32 val)
249 { 249 {
250 LOGMEM("wrl: %x <- %x\n", addr, val); 250 LOGMEM("wrl: %x <- %x\n", addr, val);
251 write_long_little((ULONG *)memaddr(addr), val); 251 write_long_little((ULONG *)memaddr(addr), val);
252 } 252 }
253 253
254 X86EMU_memFuncs _A1_mem = 254 X86EMU_memFuncs _A1_mem =
255 { 255 {
256 A1_rdb, 256 A1_rdb,
257 A1_rdw, 257 A1_rdw,
258 A1_rdl, 258 A1_rdl,
259 A1_wrb, 259 A1_wrb,
260 A1_wrw, 260 A1_wrw,
261 A1_wrl, 261 A1_wrl,
262 }; 262 };
263 263
264 #define ARTICIAS_PCI_CFGADDR 0xfec00cf8 264 #define ARTICIAS_PCI_CFGADDR 0xfec00cf8
265 #define ARTICIAS_PCI_CFGDATA 0xfee00cfc 265 #define ARTICIAS_PCI_CFGDATA 0xfee00cfc
266 #define IOBASE 0xFE000000 266 #define IOBASE 0xFE000000
267 267
268 #define in_byte(from) read_byte( (UBYTE *)port_to_mem(from)) 268 #define in_byte(from) read_byte( (UBYTE *)port_to_mem(from))
269 #define in_word(from) read_word_little((UWORD *)port_to_mem(from)) 269 #define in_word(from) read_word_little((UWORD *)port_to_mem(from))
270 #define in_long(from) read_long_little((ULONG *)port_to_mem(from)) 270 #define in_long(from) read_long_little((ULONG *)port_to_mem(from))
271 #define out_byte(to, val) write_byte((UBYTE *)port_to_mem(to), val) 271 #define out_byte(to, val) write_byte((UBYTE *)port_to_mem(to), val)
272 #define out_word(to, val) write_word_little((UWORD *)port_to_mem(to), val) 272 #define out_word(to, val) write_word_little((UWORD *)port_to_mem(to), val)
273 #define out_long(to, val) write_long_little((ULONG *)port_to_mem(to), val) 273 #define out_long(to, val) write_long_little((ULONG *)port_to_mem(to), val)
274 274
275 u32 port_to_mem(int port) 275 u32 port_to_mem(int port)
276 { 276 {
277 if (port >= 0xCFC && port <= 0xCFF) return 0xFEE00000+port; 277 if (port >= 0xCFC && port <= 0xCFF) return 0xFEE00000+port;
278 else if (port >= 0xCF8 && port <= 0xCFB) return 0xFEC00000+port; 278 else if (port >= 0xCF8 && port <= 0xCFB) return 0xFEC00000+port;
279 else return IOBASE + port; 279 else return IOBASE + port;
280 } 280 }
281 281
282 u8 A1_inb(int port) 282 u8 A1_inb(int port)
283 { 283 {
284 u8 a; 284 u8 a;
285 //if (port == 0x3BA) return 0; 285 //if (port == 0x3BA) return 0;
286 a = in_byte(port); 286 a = in_byte(port);
287 LOGIO(port, "inb: %Xh -> %d (%Xh)\n", port, a, a); 287 LOGIO(port, "inb: %Xh -> %d (%Xh)\n", port, a, a);
288 return a; 288 return a;
289 } 289 }
290 290
291 u16 A1_inw(int port) 291 u16 A1_inw(int port)
292 { 292 {
293 u16 a = in_word(port); 293 u16 a = in_word(port);
294 LOGIO(port, "inw: %Xh -> %d (%Xh)\n", port, a, a); 294 LOGIO(port, "inw: %Xh -> %d (%Xh)\n", port, a, a);
295 return a; 295 return a;
296 } 296 }
297 297
298 u32 A1_inl(int port) 298 u32 A1_inl(int port)
299 { 299 {
300 u32 a = in_long(port); 300 u32 a = in_long(port);
301 LOGIO(port, "inl: %Xh -> %d (%Xh)\n", port, a, a); 301 LOGIO(port, "inl: %Xh -> %d (%Xh)\n", port, a, a);
302 return a; 302 return a;
303 } 303 }
304 304
305 void A1_outb(int port, u8 val) 305 void A1_outb(int port, u8 val)
306 { 306 {
307 LOGIO(port, "outb: %Xh <- %d (%Xh)\n", port, val, val); 307 LOGIO(port, "outb: %Xh <- %d (%Xh)\n", port, val, val);
308 /* if (port == 0xCF8) port = 0xCFB; 308 /* if (port == 0xCF8) port = 0xCFB;
309 else if (port == 0xCF9) port = 0xCFA; 309 else if (port == 0xCF9) port = 0xCFA;
310 else if (port == 0xCFA) port = 0xCF9; 310 else if (port == 0xCFA) port = 0xCF9;
311 else if (port == 0xCFB) port = 0xCF8;*/ 311 else if (port == 0xCFB) port = 0xCF8;*/
312 out_byte(port, val); 312 out_byte(port, val);
313 } 313 }
314 314
315 void A1_outw(int port, u16 val) 315 void A1_outw(int port, u16 val)
316 { 316 {
317 LOGIO(port, "outw: %Xh <- %d (%Xh)\n", port, val, val); 317 LOGIO(port, "outw: %Xh <- %d (%Xh)\n", port, val, val);
318 out_word(port, val); 318 out_word(port, val);
319 } 319 }
320 320
321 void A1_outl(int port, u32 val) 321 void A1_outl(int port, u32 val)
322 { 322 {
323 LOGIO(port, "outl: %Xh <- %d (%Xh)\n", port, val, val); 323 LOGIO(port, "outl: %Xh <- %d (%Xh)\n", port, val, val);
324 out_long(port, val); 324 out_long(port, val);
325 } 325 }
326 326
327 X86EMU_pioFuncs _A1_pio = 327 X86EMU_pioFuncs _A1_pio =
328 { 328 {
329 A1_inb, 329 A1_inb,
330 A1_inw, 330 A1_inw,
331 A1_inl, 331 A1_inl,
332 A1_outb, 332 A1_outb,
333 A1_outw, 333 A1_outw,
334 A1_outl, 334 A1_outl,
335 }; 335 };
336 336
337 static int reloced_ops = 0; 337 static int reloced_ops = 0;
338 338
339 void reloc_ops(void *reloc_addr) 339 void reloc_ops(void *reloc_addr)
340 { 340 {
341 extern void (*x86emu_optab[256])(u8); 341 extern void (*x86emu_optab[256])(u8);
342 extern void (*x86emu_optab2[256])(u8); 342 extern void (*x86emu_optab2[256])(u8);
343 extern void tables_relocate(unsigned int offset); 343 extern void tables_relocate(unsigned int offset);
344 int i; 344 int i;
345 unsigned long delta; 345 unsigned long delta;
346 if (reloced_ops == 1) return; 346 if (reloced_ops == 1) return;
347 reloced_ops = 1; 347 reloced_ops = 1;
348 348
349 delta = TEXT_BASE - (unsigned long)reloc_addr; 349 delta = TEXT_BASE - (unsigned long)reloc_addr;
350 350
351 for (i=0; i<256; i++) 351 for (i=0; i<256; i++)
352 { 352 {
353 x86emu_optab[i] -= delta; 353 x86emu_optab[i] -= delta;
354 x86emu_optab2[i] -= delta; 354 x86emu_optab2[i] -= delta;
355 } 355 }
356 356
357 _A1_mem.rdb = A1_rdb; 357 _A1_mem.rdb = A1_rdb;
358 _A1_mem.rdw = A1_rdw; 358 _A1_mem.rdw = A1_rdw;
359 _A1_mem.rdl = A1_rdl; 359 _A1_mem.rdl = A1_rdl;
360 _A1_mem.wrb = A1_wrb; 360 _A1_mem.wrb = A1_wrb;
361 _A1_mem.wrw = A1_wrw; 361 _A1_mem.wrw = A1_wrw;
362 _A1_mem.wrl = A1_wrl; 362 _A1_mem.wrl = A1_wrl;
363 363
364 _A1_pio.inb = A1_inb; 364 _A1_pio.inb = A1_inb;
365 _A1_pio.inw = A1_inw; 365 _A1_pio.inw = A1_inw;
366 _A1_pio.inl = A1_inl; 366 _A1_pio.inl = A1_inl;
367 _A1_pio.outb = A1_outb; 367 _A1_pio.outb = A1_outb;
368 _A1_pio.outw = A1_outw; 368 _A1_pio.outw = A1_outw;
369 _A1_pio.outl = A1_outl; 369 _A1_pio.outl = A1_outl;
370 370
371 tables_relocate(delta); 371 tables_relocate(delta);
372 372
373 } 373 }
374 374
375 375
376 #define ANY_KEY(text) \ 376 #define ANY_KEY(text) \
377 printf(text); \ 377 printf(text); \
378 while (!tstc()); 378 while (!tstc());
379 379
380 380
381 unsigned char more_strap[] = { 381 unsigned char more_strap[] = {
382 0xb4, 0x0, 0xb0, 0x2, 0xcd, 0x10, 382 0xb4, 0x0, 0xb0, 0x2, 0xcd, 0x10,
383 }; 383 };
384 #define MORE_STRAP_BYTES 6 // Additional bytes of strap code 384 #define MORE_STRAP_BYTES 6 // Additional bytes of strap code
385 385
386 386
387 unsigned char *done_msg="VGA Initialized\0"; 387 unsigned char *done_msg="VGA Initialized\0";
388 388
389 int execute_bios(pci_dev_t gr_dev, void *reloc_addr) 389 int execute_bios(pci_dev_t gr_dev, void *reloc_addr)
390 { 390 {
391 extern void bios_init(void); 391 extern void bios_init(void);
392 extern void remove_init_data(void); 392 extern void remove_init_data(void);
393 extern int video_rows(void); 393 extern int video_rows(void);
394 extern int video_cols(void); 394 extern int video_cols(void);
395 extern int video_size(int, int); 395 extern int video_size(int, int);
396 u8 *strap; 396 u8 *strap;
397 unsigned char *logo; 397 unsigned char *logo;
398 u8 cfg; 398 u8 cfg;
399 int i; 399 int i;
400 char c; 400 char c;
401 #ifdef DEBUG
402 char *s; 401 char *s;
403 #endif
404 #ifdef EASTEREGG 402 #ifdef EASTEREGG
405 int easteregg_active = 0; 403 int easteregg_active = 0;
406 #endif 404 #endif
407 char *pal_reset; 405 char *pal_reset;
408 u8 *fb; 406 u8 *fb;
409 unsigned char *msg; 407 unsigned char *msg;
410 unsigned char current_attr; 408 unsigned char current_attr;
411 409
410 PRINTF("Trying to remove init data\n");
412 remove_init_data(); 411 remove_init_data();
413 PRINTF("Removed init data from cache, now in RAM\n"); 412 PRINTF("Removed init data from cache, now in RAM\n");
414 413
415 reloc_ops(reloc_addr); 414 reloc_ops(reloc_addr);
416 PRINTF("Attempting to run emulator on %02x:%02x:%02x\n", 415 PRINTF("Attempting to run emulator on %02x:%02x:%02x\n",
417 PCI_BUS(gr_dev), PCI_DEV(gr_dev), PCI_FUNC(gr_dev)); 416 PCI_BUS(gr_dev), PCI_DEV(gr_dev), PCI_FUNC(gr_dev));
418 417
419 // Enable compatibility hole for emulator access to frame buffer 418 // Enable compatibility hole for emulator access to frame buffer
420 PRINTF("Enabling compatibility hole\n"); 419 PRINTF("Enabling compatibility hole\n");
421 enable_compatibility_hole(); 420 enable_compatibility_hole();
422 421
423 // Allocate memory 422 // Allocate memory
424 // FIXME: We shouldn't use this much memory really. 423 // FIXME: We shouldn't use this much memory really.
425 memset(&M, 0, sizeof(X86EMU_sysEnv)); 424 memset(&M, 0, sizeof(X86EMU_sysEnv));
426 M.mem_base = malloc(EMULATOR_MEM_SIZE); 425 M.mem_base = malloc(EMULATOR_MEM_SIZE);
427 M.mem_size = EMULATOR_MEM_SIZE; 426 M.mem_size = EMULATOR_MEM_SIZE;
428 427
429 if (!M.mem_base) 428 if (!M.mem_base)
430 { 429 {
431 PRINTF("Unable to allocate one megabyte for emulator\n"); 430 PRINTF("Unable to allocate one megabyte for emulator\n");
432 return 0; 431 return 0;
433 } 432 }
434 433
435 if (attempt_map_rom(gr_dev, M.mem_base + EMULATOR_BIOS_OFFSET) == 0) 434 if (attempt_map_rom(gr_dev, M.mem_base + EMULATOR_BIOS_OFFSET) == 0)
436 { 435 {
437 PRINTF("Error mapping rom. Emulation terminated\n"); 436 PRINTF("Error mapping rom. Emulation terminated\n");
438 return 0; 437 return 0;
439 } 438 }
440 439
441 #ifdef DEBUG 440 #if 1 /*def DEBUG*/
442 s = getenv("x86_ask_start"); 441 s = getenv("x86_ask_start");
443 if (s) 442 if (s)
444 { 443 {
445 printf("Press 'q' to skip initialization, 'd' for dry init\n'i' for i/o session"); 444 printf("Press 'q' to skip initialization, 'd' for dry init\n'i' for i/o session");
446 while (!tstc()); 445 while (!tstc());
447 c = getc(); 446 c = getc();
448 if (c == 'q') return 0; 447 if (c == 'q') return 0;
449 if (c == 'd') 448 if (c == 'd')
450 { 449 {
451 extern void bios_set_mode(int mode); 450 extern void bios_set_mode(int mode);
452 bios_set_mode(0x03); 451 bios_set_mode(0x03);
453 return 0; 452 return 0;
454 } 453 }
455 if (c == 'i') do_inout(); 454 if (c == 'i') do_inout();
456 } 455 }
457 456
458 457
459 #endif 458 #endif
460 459
461 #ifdef EASTEREGG 460 #ifdef EASTEREGG
462 /* if (tstc()) 461 /* if (tstc())
463 { 462 {
464 if (getc() == 'c') 463 if (getc() == 'c')
465 { 464 {
466 easteregg_active = 1; 465 easteregg_active = 1;
467 } 466 }
468 } 467 }
469 */ 468 */
470 if (getenv("easteregg")) 469 if (getenv("easteregg"))
471 { 470 {
472 easteregg_active = 1; 471 easteregg_active = 1;
473 } 472 }
474 473
475 if (easteregg_active) 474 if (easteregg_active)
476 { 475 {
477 // Yay! 476 // Yay!
478 setenv("x86_mode", "1"); 477 setenv("x86_mode", "1");
479 setenv("vga_fg_color", "11"); 478 setenv("vga_fg_color", "11");
480 setenv("vga_bg_color", "1"); 479 setenv("vga_bg_color", "1");
481 easteregg_active = 1; 480 easteregg_active = 1;
482 } 481 }
483 #endif 482 #endif
484 483
485 strap = (u8*)M.mem_base + EMULATOR_STRAP_OFFSET; 484 strap = (u8*)M.mem_base + EMULATOR_STRAP_OFFSET;
486 485
487 { 486 {
488 char *m = getenv("x86_mode"); 487 char *m = getenv("x86_mode");
489 if (m) 488 if (m)
490 { 489 {
491 more_strap[3] = atoi(m); 490 more_strap[3] = atoi(m);
492 if (more_strap[3] == 1) video_size(40, 25); 491 if (more_strap[3] == 1) video_size(40, 25);
493 else video_size(80, 25); 492 else video_size(80, 25);
494 } 493 }
495 } 494 }
496 495
497 /* 496 /*
498 * Poke the strap routine. This might need a bit of extending 497 * Poke the strap routine. This might need a bit of extending
499 * if there is a mode switch involved, i.e. we want to int10 498 * if there is a mode switch involved, i.e. we want to int10
500 * afterwards to set a different graphics mode, or alternatively 499 * afterwards to set a different graphics mode, or alternatively
501 * there might be a different start address requirement if the 500 * there might be a different start address requirement if the
502 * ROM doesn't have an x86 image in its first image. 501 * ROM doesn't have an x86 image in its first image.
503 */ 502 */
504 503
505 PRINTF("Poking strap...\n"); 504 PRINTF("Poking strap...\n");
506 505
507 // FAR CALL c000:0003 506 // FAR CALL c000:0003
508 *strap++ = 0x9A; *strap++ = 0x03; *strap++ = 0x00; 507 *strap++ = 0x9A; *strap++ = 0x03; *strap++ = 0x00;
509 *strap++ = 0x00; *strap++ = 0xC0; 508 *strap++ = 0x00; *strap++ = 0xC0;
510 509
511 #if 1 510 #if 1
512 // insert additional strap code 511 // insert additional strap code
513 for (i=0; i < MORE_STRAP_BYTES; i++) 512 for (i=0; i < MORE_STRAP_BYTES; i++)
514 { 513 {
515 *strap++ = more_strap[i]; 514 *strap++ = more_strap[i];
516 } 515 }
517 #endif 516 #endif
518 // HALT 517 // HALT
519 *strap++ = 0xF4; 518 *strap++ = 0xF4;
520 519
521 PRINTF("Setting up logo data\n"); 520 PRINTF("Setting up logo data\n");
522 logo = (unsigned char *)M.mem_base + EMULATOR_LOGO_OFFSET; 521 logo = (unsigned char *)M.mem_base + EMULATOR_LOGO_OFFSET;
523 for (i=0; i<16; i++) 522 for (i=0; i<16; i++)
524 { 523 {
525 *logo++ = 0xFF; 524 *logo++ = 0xFF;
526 } 525 }
527 526
528 /* 527 /*
529 * Setup the init parameters. 528 * Setup the init parameters.
530 * Per PCI specs, AH must contain the bus and AL 529 * Per PCI specs, AH must contain the bus and AL
531 * must contain the devfn, encoded as (dev<<3)|fn 530 * must contain the devfn, encoded as (dev<<3)|fn
532 */ 531 */
533 532
534 // Execution starts here 533 // Execution starts here
535 M.x86.R_CS = SEG(EMULATOR_STRAP_OFFSET); 534 M.x86.R_CS = SEG(EMULATOR_STRAP_OFFSET);
536 M.x86.R_IP = OFF(EMULATOR_STRAP_OFFSET); 535 M.x86.R_IP = OFF(EMULATOR_STRAP_OFFSET);
537 536
538 // Stack at top of ram 537 // Stack at top of ram
539 M.x86.R_SS = SEG(EMULATOR_STACK_OFFSET); 538 M.x86.R_SS = SEG(EMULATOR_STACK_OFFSET);
540 M.x86.R_SP = OFF(EMULATOR_STACK_OFFSET); 539 M.x86.R_SP = OFF(EMULATOR_STACK_OFFSET);
541 540
542 // Input parameters 541 // Input parameters
543 M.x86.R_AH = PCI_BUS(gr_dev); 542 M.x86.R_AH = PCI_BUS(gr_dev);
544 M.x86.R_AL = (PCI_DEV(gr_dev)<<3) | PCI_FUNC(gr_dev); 543 M.x86.R_AL = (PCI_DEV(gr_dev)<<3) | PCI_FUNC(gr_dev);
545 544
546 // Set the I/O and memory access functions 545 // Set the I/O and memory access functions
547 X86EMU_setupMemFuncs(&_A1_mem); 546 X86EMU_setupMemFuncs(&_A1_mem);
548 X86EMU_setupPioFuncs(&_A1_pio); 547 X86EMU_setupPioFuncs(&_A1_pio);
549 548
550 // Enable timer 2 549 // Enable timer 2
551 cfg = in_byte(0x61); // Get Misc control 550 cfg = in_byte(0x61); // Get Misc control
552 cfg |= 0x01; // Enable timer 2 551 cfg |= 0x01; // Enable timer 2
553 out_byte(0x61, cfg); // output again 552 out_byte(0x61, cfg); // output again
554 553
555 // Set up the timers 554 // Set up the timers
556 out_byte(0x43, 0x54); 555 out_byte(0x43, 0x54);
557 out_byte(0x41, 0x18); 556 out_byte(0x41, 0x18);
558 557
559 out_byte(0x43, 0x36); 558 out_byte(0x43, 0x36);
560 out_byte(0x40, 0x00); 559 out_byte(0x40, 0x00);
561 out_byte(0x40, 0x00); 560 out_byte(0x40, 0x00);
562 561
563 out_byte(0x43, 0xb6); 562 out_byte(0x43, 0xb6);
564 out_byte(0x42, 0x31); 563 out_byte(0x42, 0x31);
565 out_byte(0x42, 0x13); 564 out_byte(0x42, 0x13);
566 565
567 // Init the "BIOS". 566 // Init the "BIOS".
568 bios_init(); 567 bios_init();
569 568
570 // Video Card Reset 569 // Video Card Reset
571 out_byte(0x3D8, 0); 570 out_byte(0x3D8, 0);
572 out_byte(0x3B8, 1); 571 out_byte(0x3B8, 1);
573 (void)in_byte(0x3BA); 572 (void)in_byte(0x3BA);
574 (void)in_byte(0x3DA); 573 (void)in_byte(0x3DA);
575 out_byte(0x3C0, 0); 574 out_byte(0x3C0, 0);
576 out_byte(0x61, 0xFC); 575 out_byte(0x61, 0xFC);
577 576
578 #ifdef DEBUG 577 #ifdef DEBUG
579 s = _getenv("x86_singlestep"); 578 s = _getenv("x86_singlestep");
580 if (s && strcmp(s, "on")==0) 579 if (s && strcmp(s, "on")==0)
581 { 580 {
582 PRINTF("Enabling single stepping for debug\n"); 581 PRINTF("Enabling single stepping for debug\n");
583 X86EMU_trace_on(); 582 X86EMU_trace_on();
584 } 583 }
585 #endif 584 #endif
586 585
587 // Ready set go... 586 // Ready set go...
588 PRINTF("Running emulator\n"); 587 PRINTF("Running emulator\n");
589 X86EMU_exec(); 588 X86EMU_exec();
590 PRINTF("Done running emulator\n"); 589 PRINTF("Done running emulator\n");
591 590
592 /* FIXME: Remove me */ 591 /* FIXME: Remove me */
593 pal_reset = getenv("x86_palette_reset"); 592 pal_reset = getenv("x86_palette_reset");
594 if (pal_reset && strcmp(pal_reset, "on") == 0) 593 if (pal_reset && strcmp(pal_reset, "on") == 0)
595 { 594 {
596 PRINTF("Palette reset\n"); 595 PRINTF("Palette reset\n");
597 //(void)in_byte(0x3da); 596 //(void)in_byte(0x3da);
598 //out_byte(0x3c0, 0); 597 //out_byte(0x3c0, 0);
599 598
600 out_byte(0x3C8, 0); 599 out_byte(0x3C8, 0);
601 out_byte(0x3C9, 0); 600 out_byte(0x3C9, 0);
602 out_byte(0x3C9, 0); 601 out_byte(0x3C9, 0);
603 out_byte(0x3C9, 0); 602 out_byte(0x3C9, 0);
604 for (i=0; i<254; i++) 603 for (i=0; i<254; i++)
605 { 604 {
606 out_byte(0x3C9, 63); 605 out_byte(0x3C9, 63);
607 out_byte(0x3C9, 63); 606 out_byte(0x3C9, 63);
608 out_byte(0x3C9, 63); 607 out_byte(0x3C9, 63);
609 } 608 }
610 609
611 out_byte(0x3c0, 0x20); 610 out_byte(0x3c0, 0x20);
612 } 611 }
613 /* FIXME: remove me */ 612 /* FIXME: remove me */
614 #ifdef EASTEREGG 613 #ifdef EASTEREGG
615 if (easteregg_active) 614 if (easteregg_active)
616 { 615 {
617 extern void video_easteregg(void); 616 extern void video_easteregg(void);
618 video_easteregg(); 617 video_easteregg();
619 } 618 }
620 #endif 619 #endif
621 /* 620 /*
622 current_attr = video_get_attr(); 621 current_attr = video_get_attr();
623 fb = (u8 *)VIDEO_BASE; 622 fb = (u8 *)VIDEO_BASE;
624 for (i=0; i<video_rows()*video_cols()*2; i+=2) 623 for (i=0; i<video_rows()*video_cols()*2; i+=2)
625 { 624 {
626 *(fb+i) = ' '; 625 *(fb+i) = ' ';
627 *(fb+i+1) = current_attr; 626 *(fb+i+1) = current_attr;
628 } 627 }
629 628
630 fb = (u8 *)VIDEO_BASE + (video_rows())-1*(video_cols()*2); 629 fb = (u8 *)VIDEO_BASE + (video_rows())-1*(video_cols()*2);
631 for (i=0; i<video_cols(); i++) 630 for (i=0; i<video_cols(); i++)
632 { 631 {
633 *(fb + 2*i) = 32; 632 *(fb + 2*i) = 32;
634 *(fb + 2*i + 1) = 0x17; 633 *(fb + 2*i + 1) = 0x17;
635 } 634 }
636 635
637 msg = done_msg; 636 msg = done_msg;
638 while (*msg) 637 while (*msg)
639 { 638 {
640 *fb = *msg; 639 *fb = *msg;
641 fb += 2; 640 fb += 2;
642 msg ++; 641 msg ++;
643 } 642 }
644 */ 643 */
645 #ifdef DEBUG 644 #ifdef DEBUG
646 if (getenv("x86_do_inout")) do_inout(); 645 if (getenv("x86_do_inout")) do_inout();
647 #endif 646 #endif
648 647
649 dcache_disable(); 648 //FIXME: dcache_disable();
650 return 1; 649 return 1;
651 } 650 }
652 651
653 // Clean up the x86 mess 652 // Clean up the x86 mess
654 void shutdown_bios(void) 653 void shutdown_bios(void)
655 { 654 {
656 // disable_compatibility_hole(); 655 // disable_compatibility_hole();
657 // Free the memory associated 656 // Free the memory associated
658 free(M.mem_base); 657 free(M.mem_base);
659 658
660 } 659 }
661 660
662 int to_int(char *buffer) 661 int to_int(char *buffer)
663 { 662 {
664 int base = 0; 663 int base = 0;
665 int res = 0; 664 int res = 0;
666 665
667 if (*buffer == '$') 666 if (*buffer == '$')
668 { 667 {
669 base = 16; 668 base = 16;
670 buffer++; 669 buffer++;
671 } 670 }
672 else base = 10; 671 else base = 10;
673 672
674 for (;;) 673 for (;;)
675 { 674 {
676 switch(*buffer) 675 switch(*buffer)
677 { 676 {
678 case '0' ... '9': 677 case '0' ... '9':
679 res *= base; 678 res *= base;
680 res += *buffer - '0'; 679 res += *buffer - '0';
681 break; 680 break;
682 case 'A': 681 case 'A':
683 case 'a': 682 case 'a':
684 res *= base; 683 res *= base;
685 res += 10; 684 res += 10;
686 break; 685 break;
687 case 'B': 686 case 'B':
688 case 'b': 687 case 'b':
689 res *= base; 688 res *= base;
690 res += 11; 689 res += 11;
691 break; 690 break;
692 case 'C': 691 case 'C':
693 case 'c': 692 case 'c':
694 res *= base; 693 res *= base;
695 res += 12; 694 res += 12;
696 break; 695 break;
697 case 'D': 696 case 'D':
698 case 'd': 697 case 'd':
699 res *= base; 698 res *= base;
700 res += 13; 699 res += 13;
701 break; 700 break;
702 case 'E': 701 case 'E':
703 case 'e': 702 case 'e':
704 res *= base; 703 res *= base;
705 res += 14; 704 res += 14;
706 break; 705 break;
707 case 'F': 706 case 'F':
708 case 'f': 707 case 'f':
709 res *= base; 708 res *= base;
710 res += 15; 709 res += 15;
711 break; 710 break;
712 default: 711 default:
713 return res; 712 return res;
714 } 713 }
715 buffer++; 714 buffer++;
716 } 715 }
717 return res; 716 return res;
718 } 717 }
719 718
720 void one_arg(char *buffer, int *a) 719 void one_arg(char *buffer, int *a)
721 { 720 {
722 while (*buffer && *buffer != '\n') 721 while (*buffer && *buffer != '\n')
723 { 722 {
724 if (*buffer == ' ') buffer++; 723 if (*buffer == ' ') buffer++;
725 else break; 724 else break;
726 } 725 }
727 726
728 *a = to_int(buffer); 727 *a = to_int(buffer);
729 } 728 }
730 729
731 void two_args(char *buffer, int *a, int *b) 730 void two_args(char *buffer, int *a, int *b)
732 { 731 {
733 while (*buffer && *buffer != '\n') 732 while (*buffer && *buffer != '\n')
734 { 733 {
735 if (*buffer == ' ') buffer++; 734 if (*buffer == ' ') buffer++;
736 else break; 735 else break;
737 } 736 }
738 737
739 *a = to_int(buffer); 738 *a = to_int(buffer);
740 739
741 while (*buffer && *buffer != '\n') 740 while (*buffer && *buffer != '\n')
742 { 741 {
743 if (*buffer != ' ') buffer++; 742 if (*buffer != ' ') buffer++;
744 else break; 743 else break;
745 } 744 }
746 745
747 while (*buffer && *buffer != '\n') 746 while (*buffer && *buffer != '\n')
748 { 747 {
749 if (*buffer == ' ') buffer++; 748 if (*buffer == ' ') buffer++;
750 else break; 749 else break;
751 } 750 }
752 751
753 *b = to_int(buffer); 752 *b = to_int(buffer);
754 } 753 }
755 754
756 void do_inout(void) 755 void do_inout(void)
757 { 756 {
758 char buffer[256]; 757 char buffer[256];
759 char *arg1, *arg2; 758 char *arg1, *arg2;
760 int a,b; 759 int a,b;
761 760
762 printf("In/Out Session\nUse 'i[bwl]' for in, 'o[bwl]' for out and 'q' to quit\n"); 761 printf("In/Out Session\nUse 'i[bwl]' for in, 'o[bwl]' for out and 'q' to quit\n");
763 762
764 do 763 do
765 { 764 {
766 cons_gets(buffer); 765 cons_gets(buffer);
767 printf("\n"); 766 printf("\n");
768 767
769 *arg1 = buffer; 768 *arg1 = buffer;
770 while (*arg1 != ' ' ) arg1++; 769 while (*arg1 != ' ' ) arg1++;
771 while (*arg1 == ' ') arg1++; 770 while (*arg1 == ' ') arg1++;
772 771
773 if (buffer[0] == 'i') 772 if (buffer[0] == 'i')
774 { 773 {
775 one_arg(buffer+2, &a); 774 one_arg(buffer+2, &a);
776 switch (buffer[1]) 775 switch (buffer[1])
777 { 776 {
778 case 'b': 777 case 'b':
779 printf("in_byte(%xh) = %xh\n", a, A1_inb(a)); 778 printf("in_byte(%xh) = %xh\n", a, A1_inb(a));
780 break; 779 break;
781 case 'w': 780 case 'w':
782 printf("in_word(%xh) = %xh\n", a, A1_inw(a)); 781 printf("in_word(%xh) = %xh\n", a, A1_inw(a));
783 break; 782 break;
784 case 'l': 783 case 'l':
785 printf("in_dword(%xh) = %xh\n", a, A1_inl(a)); 784 printf("in_dword(%xh) = %xh\n", a, A1_inl(a));
786 break; 785 break;
787 default: 786 default:
788 printf("Invalid length '%c'\n", buffer[1]); 787 printf("Invalid length '%c'\n", buffer[1]);
789 break; 788 break;
790 } 789 }
791 } 790 }
792 else if (buffer[0] == 'o') 791 else if (buffer[0] == 'o')
793 { 792 {
794 two_args(buffer+2, &a, &b); 793 two_args(buffer+2, &a, &b);
795 switch (buffer[1]) 794 switch (buffer[1])
796 { 795 {
797 case 'b': 796 case 'b':
798 printf("out_byte(%d, %d)\n", a, b); 797 printf("out_byte(%d, %d)\n", a, b);
799 A1_outb(a,b); 798 A1_outb(a,b);
800 break; 799 break;
801 case 'w': 800 case 'w':
802 printf("out_word(%d, %d)\n", a, b); 801 printf("out_word(%d, %d)\n", a, b);
803 A1_outw(a, b); 802 A1_outw(a, b);
804 break; 803 break;
805 case 'l': 804 case 'l':
806 printf("out_long(%d, %d)\n", a, b); 805 printf("out_long(%d, %d)\n", a, b);
807 A1_outl(a, b); 806 A1_outl(a, b);
808 break; 807 break;
809 default: 808 default:
810 printf("Invalid length '%c'\n", buffer[1]); 809 printf("Invalid length '%c'\n", buffer[1]);
811 break; 810 break;
812 } 811 }
813 } else if (buffer[0] == 'q') return; 812 } else if (buffer[0] == 'q') return;
814 } while (1); 813 } while (1);
815 } 814 }
board/MAI/menu/cmd_menu.c
1 #include <common.h> 1 #include <common.h>
2 #include <command.h> 2 #include <command.h>
3 #include <cmd_menu.h> 3 #include <cmd_menu.h>
4 4
5 int do_menu( cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[] ) 5 int do_menu( cmd_tbl_t *cmdtp, /*bd_t *bd,*/ int flag, int argc, char *argv[] )
6 { 6 {
7 // printf("<NOT YET IMPLEMENTED>\n"); 7 // printf("<NOT YET IMPLEMENTED>\n");
8 return 0; 8 return 0;
9 } 9 }
10 10
board/hermes/u-boot.lds
1 /* 1 /*
2 * (C) Copyright 2000 2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 OUTPUT_ARCH(powerpc) 24 OUTPUT_ARCH(powerpc)
25 SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib); 25 SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
26 /* Do we need any of these for elf? 26 /* Do we need any of these for elf?
27 __DYNAMIC = 0; */ 27 __DYNAMIC = 0; */
28 SECTIONS 28 SECTIONS
29 { 29 {
30 /* Read-only sections, merged into text segment: */ 30 /* Read-only sections, merged into text segment: */
31 . = + SIZEOF_HEADERS; 31 . = + SIZEOF_HEADERS;
32 .interp : { *(.interp) } 32 .interp : { *(.interp) }
33 .hash : { *(.hash) } 33 .hash : { *(.hash) }
34 .dynsym : { *(.dynsym) } 34 .dynsym : { *(.dynsym) }
35 .dynstr : { *(.dynstr) } 35 .dynstr : { *(.dynstr) }
36 .rel.text : { *(.rel.text) } 36 .rel.text : { *(.rel.text) }
37 .rela.text : { *(.rela.text) } 37 .rela.text : { *(.rela.text) }
38 .rel.data : { *(.rel.data) } 38 .rel.data : { *(.rel.data) }
39 .rela.data : { *(.rela.data) } 39 .rela.data : { *(.rela.data) }
40 .rel.rodata : { *(.rel.rodata) } 40 .rel.rodata : { *(.rel.rodata) }
41 .rela.rodata : { *(.rela.rodata) } 41 .rela.rodata : { *(.rela.rodata) }
42 .rel.got : { *(.rel.got) } 42 .rel.got : { *(.rel.got) }
43 .rela.got : { *(.rela.got) } 43 .rela.got : { *(.rela.got) }
44 .rel.ctors : { *(.rel.ctors) } 44 .rel.ctors : { *(.rel.ctors) }
45 .rela.ctors : { *(.rela.ctors) } 45 .rela.ctors : { *(.rela.ctors) }
46 .rel.dtors : { *(.rel.dtors) } 46 .rel.dtors : { *(.rel.dtors) }
47 .rela.dtors : { *(.rela.dtors) } 47 .rela.dtors : { *(.rela.dtors) }
48 .rel.bss : { *(.rel.bss) } 48 .rel.bss : { *(.rel.bss) }
49 .rela.bss : { *(.rela.bss) } 49 .rela.bss : { *(.rela.bss) }
50 .rel.plt : { *(.rel.plt) } 50 .rel.plt : { *(.rel.plt) }
51 .rela.plt : { *(.rela.plt) } 51 .rela.plt : { *(.rela.plt) }
52 .init : { *(.init) } 52 .init : { *(.init) }
53 .plt : { *(.plt) } 53 .plt : { *(.plt) }
54 .text : 54 .text :
55 { 55 {
56 /* WARNING - the following is hand-optimized to fit within */ 56 /* WARNING - the following is hand-optimized to fit within */
57 /* the sector layout of our flash chips! XXX FIXME XXX */ 57 /* the sector layout of our flash chips! XXX FIXME XXX */
58 58
59 cpu/mpc8xx/start.o (.text) 59 cpu/mpc8xx/start.o (.text)
60 common/dlmalloc.o (.text) 60 common/dlmalloc.o (.text)
61 lib_ppc/ppcstring.o (.text) 61 cpu/mpc8xx/interrupts.o (.text)
62 cpu/mpc8xx/interrupts.o (.text)
63 lib_ppc/time.o (.text) 62 lib_ppc/time.o (.text)
63 lib_ppc/ticks.o (.text)
64 lib_ppc/cache.o (.text)
65 lib_generic/crc32.o (.text)
64 . = env_offset; 66 . = env_offset;
65 common/environment.o(.text) 67 common/environment.o(.text)
66 68
67 *(.text) 69 *(.text)
68 *(.fixup) 70 *(.fixup)
69 *(.got1) 71 *(.got1)
70 } 72 }
71 _etext = .; 73 _etext = .;
72 PROVIDE (etext = .); 74 PROVIDE (etext = .);
73 .rodata : 75 .rodata :
74 { 76 {
75 *(.rodata) 77 *(.rodata)
76 *(.rodata1) 78 *(.rodata1)
77 } 79 }
78 .fini : { *(.fini) } =0 80 .fini : { *(.fini) } =0
79 .ctors : { *(.ctors) } 81 .ctors : { *(.ctors) }
80 .dtors : { *(.dtors) } 82 .dtors : { *(.dtors) }
81 83
82 /* Read-write section, merged into data segment: */ 84 /* Read-write section, merged into data segment: */
83 . = (. + 0x00FF) & 0xFFFFFF00; 85 . = (. + 0x00FF) & 0xFFFFFF00;
84 _erotext = .; 86 _erotext = .;
85 PROVIDE (erotext = .); 87 PROVIDE (erotext = .);
86 .reloc : 88 .reloc :
87 { 89 {
88 *(.got) 90 *(.got)
89 _GOT2_TABLE_ = .; 91 _GOT2_TABLE_ = .;
90 *(.got2) 92 *(.got2)
91 _FIXUP_TABLE_ = .; 93 _FIXUP_TABLE_ = .;
92 *(.fixup) 94 *(.fixup)
93 } 95 }
94 __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2; 96 __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
95 __fixup_entries = (. - _FIXUP_TABLE_)>>2; 97 __fixup_entries = (. - _FIXUP_TABLE_)>>2;
96 98
97 .data : 99 .data :
98 { 100 {
99 *(.data) 101 *(.data)
100 *(.data1) 102 *(.data1)
101 *(.sdata) 103 *(.sdata)
102 *(.sdata2) 104 *(.sdata2)
103 *(.dynamic) 105 *(.dynamic)
104 CONSTRUCTORS 106 CONSTRUCTORS
105 } 107 }
106 _edata = .; 108 _edata = .;
107 PROVIDE (edata = .); 109 PROVIDE (edata = .);
108 110
109 __start___ex_table = .; 111 __start___ex_table = .;
110 __ex_table : { *(__ex_table) } 112 __ex_table : { *(__ex_table) }
111 __stop___ex_table = .; 113 __stop___ex_table = .;
112 114
113 . = ALIGN(256); 115 . = ALIGN(256);
114 __init_begin = .; 116 __init_begin = .;
115 .text.init : { *(.text.init) } 117 .text.init : { *(.text.init) }
116 .data.init : { *(.data.init) } 118 .data.init : { *(.data.init) }
117 . = ALIGN(256); 119 . = ALIGN(256);
118 __init_end = .; 120 __init_end = .;
119 121
120 __bss_start = .; 122 __bss_start = .;
121 .bss : 123 .bss :
122 { 124 {
123 *(.sbss) *(.scommon) 125 *(.sbss) *(.scommon)
124 *(.dynbss) 126 *(.dynbss)
125 *(.bss) 127 *(.bss)
126 *(COMMON) 128 *(COMMON)
127 } 129 }
128 _end = . ; 130 _end = . ;
129 PROVIDE (end = .); 131 PROVIDE (end = .);
130 } 132 }
board/tqm8260/tqm8260.c
1 /* 1 /*
2 * (C) Copyright 2001 2 * (C) Copyright 2001
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 #include <common.h> 24 #include <common.h>
25 #include <ioports.h> 25 #include <ioports.h>
26 #include <mpc8260.h> 26 #include <mpc8260.h>
27 27
28 /* 28 /*
29 * I/O Port configuration table 29 * I/O Port configuration table
30 * 30 *
31 * if conf is 1, then that port pin will be configured at boot time 31 * if conf is 1, then that port pin will be configured at boot time
32 * according to the five values podr/pdir/ppar/psor/pdat for that entry 32 * according to the five values podr/pdir/ppar/psor/pdat for that entry
33 */ 33 */
34 34
35 const iop_conf_t iop_conf_tab[4][32] = { 35 const iop_conf_t iop_conf_tab[4][32] = {
36 36
37 /* Port A configuration */ 37 /* Port A configuration */
38 { /* conf ppar psor pdir podr pdat */ 38 { /* conf ppar psor pdir podr pdat */
39 /* PA31 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMTXEN */ 39 /* PA31 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMTXEN */
40 /* PA30 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTCA */ 40 /* PA30 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTCA */
41 /* PA29 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTSOC */ 41 /* PA29 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTSOC */
42 /* PA28 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMRXEN */ 42 /* PA28 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMRXEN */
43 /* PA27 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRSOC */ 43 /* PA27 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRSOC */
44 /* PA26 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRCA */ 44 /* PA26 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRCA */
45 /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */ 45 /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
46 /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */ 46 /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
47 /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */ 47 /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
48 /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */ 48 /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
49 /* PA21 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */ 49 /* PA21 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
50 /* PA20 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */ 50 /* PA20 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
51 /* PA19 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */ 51 /* PA19 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
52 /* PA18 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */ 52 /* PA18 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
53 /* PA17 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[7] */ 53 /* PA17 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[7] */
54 /* PA16 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[6] */ 54 /* PA16 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[6] */
55 /* PA15 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[5] */ 55 /* PA15 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[5] */
56 /* PA14 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[4] */ 56 /* PA14 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[4] */
57 /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[3] */ 57 /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[3] */
58 /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[2] */ 58 /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[2] */
59 /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[1] */ 59 /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[1] */
60 /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[0] */ 60 /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[0] */
61 /* PA9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */ 61 /* PA9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
62 /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RXD */ 62 /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
63 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */ 63 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
64 /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */ 64 /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
65 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */ 65 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
66 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */ 66 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
67 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */ 67 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
68 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */ 68 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
69 /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */ 69 /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
70 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */ 70 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
71 }, 71 },
72 72
73 /* Port B configuration */ 73 /* Port B configuration */
74 { /* conf ppar psor pdir podr pdat */ 74 { /* conf ppar psor pdir podr pdat */
75 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */ 75 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
76 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */ 76 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
77 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */ 77 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
78 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */ 78 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
79 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */ 79 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
80 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */ 80 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
81 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */ 81 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
82 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */ 82 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
83 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */ 83 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
84 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */ 84 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
85 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */ 85 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
86 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */ 86 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
87 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */ 87 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
88 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */ 88 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
89 /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */ 89 /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
90 /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */ 90 /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
91 /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* PB15 */ 91 /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* PB15 */
92 /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* PB14 */ 92 /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* PB14 */
93 /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */ 93 /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
94 /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */ 94 /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
95 /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */ 95 /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
96 /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */ 96 /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
97 /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */ 97 /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
98 /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* PB8 */ 98 /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* PB8 */
99 /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */ 99 /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
100 /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */ 100 /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
101 /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */ 101 /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
102 /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */ 102 /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
103 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 103 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
104 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 104 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
105 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 105 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
106 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ 106 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
107 }, 107 },
108 108
109 /* Port C */ 109 /* Port C */
110 { /* conf ppar psor pdir podr pdat */ 110 { /* conf ppar psor pdir podr pdat */
111 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */ 111 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
112 /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */ 112 /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
113 /* PC29 */ { 1, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */ 113 /* PC29 */ { 1, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
114 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */ 114 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
115 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */ 115 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */
116 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */ 116 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
117 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */ 117 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
118 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */ 118 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
119 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */ 119 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
120 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */ 120 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
121 /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */ 121 /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
122 /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */ 122 /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
123 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */ 123 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */
124 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */ 124 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */
125 /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */ 125 /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
126 /* PC16 */ { 0, 0, 0, 1, 0, 0 }, /* PC16 */ 126 /* PC16 */ { 0, 0, 0, 1, 0, 0 }, /* PC16 */
127 /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */ 127 /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
128 /* PC14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */ 128 /* PC14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
129 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */ 129 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
130 /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* PC12 */ 130 /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* PC12 */
131 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* PC11 */ 131 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* PC11 */
132 /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC2 MDC */ 132 /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC2 MDC */
133 /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* FCC2 MDIO */ 133 /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* FCC2 MDIO */
134 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */ 134 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
135 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */ 135 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
136 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */ 136 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
137 /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */ 137 /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
138 /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */ 138 /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
139 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */ 139 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
140 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */ 140 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
141 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */ 141 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
142 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */ 142 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
143 }, 143 },
144 144
145 /* Port D */ 145 /* Port D */
146 { /* conf ppar psor pdir podr pdat */ 146 { /* conf ppar psor pdir podr pdat */
147 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */ 147 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
148 /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */ 148 /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
149 /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */ 149 /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
150 /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */ 150 /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
151 /* PD27 */ { 0, 0, 0, 1, 0, 0 }, /* PD27 */ 151 /* PD27 */ { 0, 0, 0, 1, 0, 0 }, /* PD27 */
152 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */ 152 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
153 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */ 153 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
154 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */ 154 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
155 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */ 155 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
156 /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */ 156 /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
157 /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */ 157 /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
158 /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */ 158 /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
159 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */ 159 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
160 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */ 160 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
161 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */ 161 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
162 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */ 162 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
163 #if defined(CONFIG_SOFT_I2C) 163 #if defined(CONFIG_SOFT_I2C)
164 /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */ 164 /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
165 /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */ 165 /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
166 #else 166 #else
167 #if defined(CONFIG_HARD_I2C) 167 #if defined(CONFIG_HARD_I2C)
168 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */ 168 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
169 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */ 169 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
170 #else /* normal I/O port pins */ 170 #else /* normal I/O port pins */
171 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */ 171 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
172 /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */ 172 /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
173 #endif 173 #endif
174 #endif 174 #endif
175 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */ 175 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
176 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */ 176 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
177 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */ 177 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
178 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */ 178 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
179 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */ 179 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
180 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */ 180 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
181 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */ 181 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
182 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */ 182 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
183 /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */ 183 /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
184 /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */ 184 /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
185 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 185 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
186 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 186 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
187 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 187 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
188 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ 188 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
189 } 189 }
190 }; 190 };
191 191
192 /* ------------------------------------------------------------------------- */ 192 /* ------------------------------------------------------------------------- */
193 193
194 /* Check Board Identity: 194 /* Check Board Identity:
195 */ 195 */
196 int checkboard (void) 196 int checkboard (void)
197 { 197 {
198 unsigned char str[64]; 198 unsigned char str[64];
199 int i = getenv_r ("serial#", str, sizeof (str)); 199 int i = getenv_r ("serial#", str, sizeof (str));
200 200
201 puts ("Board: "); 201 puts ("Board: ");
202 202
203 if (!i || strncmp (str, "TQM8260", 7)) { 203 if (!i || strncmp (str, "TQM8260", 7)) {
204 puts ("### No HW ID - assuming TQM8260\n"); 204 puts ("### No HW ID - assuming TQM8260\n");
205 return (1); 205 return (0);
206 } 206 }
207 207
208 puts (str); 208 puts (str);
209 putc ('\n'); 209 putc ('\n');
210 210
211 return 0; 211 return 0;
212 } 212 }
213 213
214 /* ------------------------------------------------------------------------- */ 214 /* ------------------------------------------------------------------------- */
215 215
216 /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx 216 /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
217 * 217 *
218 * This routine performs standard 8260 initialization sequence 218 * This routine performs standard 8260 initialization sequence
219 * and calculates the available memory size. It may be called 219 * and calculates the available memory size. It may be called
220 * several times to try different SDRAM configurations on both 220 * several times to try different SDRAM configurations on both
221 * 60x and local buses. 221 * 60x and local buses.
222 */ 222 */
223 static long int try_init (volatile memctl8260_t * memctl, ulong sdmr, 223 static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
224 ulong orx, volatile uchar * base) 224 ulong orx, volatile uchar * base)
225 { 225 {
226 volatile uchar c = 0xff; 226 volatile uchar c = 0xff;
227 ulong cnt, val; 227 ulong cnt, val;
228 volatile ulong *addr; 228 volatile ulong *addr;
229 volatile uint *sdmr_ptr; 229 volatile uint *sdmr_ptr;
230 volatile uint *orx_ptr; 230 volatile uint *orx_ptr;
231 int i; 231 int i;
232 ulong save[32]; /* to make test non-destructive */ 232 ulong save[32]; /* to make test non-destructive */
233 ulong maxsize; 233 ulong maxsize;
234 234
235 /* We must be able to test a location outsize the maximum legal size 235 /* We must be able to test a location outsize the maximum legal size
236 * to find out THAT we are outside; but this address still has to be 236 * to find out THAT we are outside; but this address still has to be
237 * mapped by the controller. That means, that the initial mapping has 237 * mapped by the controller. That means, that the initial mapping has
238 * to be (at least) twice as large as the maximum expected size. 238 * to be (at least) twice as large as the maximum expected size.
239 */ 239 */
240 maxsize = (1 + (~orx | 0x7fff)) / 2; 240 maxsize = (1 + (~orx | 0x7fff)) / 2;
241 241
242 /* Since CFG_SDRAM_BASE is always 0 (??), we assume that 242 /* Since CFG_SDRAM_BASE is always 0 (??), we assume that
243 * we are configuring CS1 if base != 0 243 * we are configuring CS1 if base != 0
244 */ 244 */
245 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr; 245 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
246 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1; 246 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
247 247
248 *orx_ptr = orx; 248 *orx_ptr = orx;
249 249
250 /* 250 /*
251 * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35): 251 * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
252 * 252 *
253 * "At system reset, initialization software must set up the 253 * "At system reset, initialization software must set up the
254 * programmable parameters in the memory controller banks registers 254 * programmable parameters in the memory controller banks registers
255 * (ORx, BRx, P/LSDMR). After all memory parameters are configured, 255 * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
256 * system software should execute the following initialization sequence 256 * system software should execute the following initialization sequence
257 * for each SDRAM device. 257 * for each SDRAM device.
258 * 258 *
259 * 1. Issue a PRECHARGE-ALL-BANKS command 259 * 1. Issue a PRECHARGE-ALL-BANKS command
260 * 2. Issue eight CBR REFRESH commands 260 * 2. Issue eight CBR REFRESH commands
261 * 3. Issue a MODE-SET command to initialize the mode register 261 * 3. Issue a MODE-SET command to initialize the mode register
262 * 262 *
263 * The initial commands are executed by setting P/LSDMR[OP] and 263 * The initial commands are executed by setting P/LSDMR[OP] and
264 * accessing the SDRAM with a single-byte transaction." 264 * accessing the SDRAM with a single-byte transaction."
265 * 265 *
266 * The appropriate BRx/ORx registers have already been set when we 266 * The appropriate BRx/ORx registers have already been set when we
267 * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE. 267 * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
268 */ 268 */
269 269
270 *sdmr_ptr = sdmr | PSDMR_OP_PREA; 270 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
271 *base = c; 271 *base = c;
272 272
273 *sdmr_ptr = sdmr | PSDMR_OP_CBRR; 273 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
274 for (i = 0; i < 8; i++) 274 for (i = 0; i < 8; i++)
275 *base = c; 275 *base = c;
276 276
277 *sdmr_ptr = sdmr | PSDMR_OP_MRW; 277 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
278 *(base + CFG_MRS_OFFS) = c; /* setting MR on address lines */ 278 *(base + CFG_MRS_OFFS) = c; /* setting MR on address lines */
279 279
280 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN; 280 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
281 *base = c; 281 *base = c;
282 282
283 /* 283 /*
284 * Check memory range for valid RAM. A simple memory test determines 284 * Check memory range for valid RAM. A simple memory test determines
285 * the actually available RAM size between addresses `base' and 285 * the actually available RAM size between addresses `base' and
286 * `base + maxsize'. Some (not all) hardware errors are detected: 286 * `base + maxsize'. Some (not all) hardware errors are detected:
287 * - short between address lines 287 * - short between address lines
288 * - short between data lines 288 * - short between data lines
289 */ 289 */
290 i = 0; 290 i = 0;
291 for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) { 291 for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) {
292 addr = (volatile ulong *) base + cnt; /* pointer arith! */ 292 addr = (volatile ulong *) base + cnt; /* pointer arith! */
293 save[i++] = *addr; 293 save[i++] = *addr;
294 *addr = ~cnt; 294 *addr = ~cnt;
295 } 295 }
296 296
297 addr = (volatile ulong *) base; 297 addr = (volatile ulong *) base;
298 save[i] = *addr; 298 save[i] = *addr;
299 *addr = 0; 299 *addr = 0;
300 300
301 if ((val = *addr) != 0) { 301 if ((val = *addr) != 0) {
302 *addr = save[i]; 302 *addr = save[i];
303 return (0); 303 return (0);
304 } 304 }
305 305
306 for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) { 306 for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) {
307 addr = (volatile ulong *) base + cnt; /* pointer arith! */ 307 addr = (volatile ulong *) base + cnt; /* pointer arith! */
308 val = *addr; 308 val = *addr;
309 *addr = save[--i]; 309 *addr = save[--i];
310 if (val != ~cnt) { 310 if (val != ~cnt) {
311 /* Write the actual size to ORx 311 /* Write the actual size to ORx
312 */ 312 */
313 *orx_ptr = orx | ~(cnt * sizeof (long) - 1); 313 *orx_ptr = orx | ~(cnt * sizeof (long) - 1);
314 return (cnt * sizeof (long)); 314 return (cnt * sizeof (long));
315 } 315 }
316 } 316 }
317 return (maxsize); 317 return (maxsize);
318 } 318 }
319 319
320 long int initdram (int board_type) 320 long int initdram (int board_type)
321 { 321 {
322 volatile immap_t *immap = (immap_t *) CFG_IMMR; 322 volatile immap_t *immap = (immap_t *) CFG_IMMR;
323 volatile memctl8260_t *memctl = &immap->im_memctl; 323 volatile memctl8260_t *memctl = &immap->im_memctl;
324 324
325 #ifndef CFG_RAMBOOT 325 #ifndef CFG_RAMBOOT
326 long size8, size9; 326 long size8, size9;
327 #endif 327 #endif
328 long psize, lsize; 328 long psize, lsize;
329 329
330 psize = 16 * 1024 * 1024; 330 psize = 16 * 1024 * 1024;
331 lsize = 0; 331 lsize = 0;
332 332
333 memctl->memc_psrt = CFG_PSRT; 333 memctl->memc_psrt = CFG_PSRT;
334 memctl->memc_mptpr = CFG_MPTPR; 334 memctl->memc_mptpr = CFG_MPTPR;
335 335
336 #if 0 /* Just for debugging */ 336 #if 0 /* Just for debugging */
337 #define prt_br_or(brX,orX) do { \ 337 #define prt_br_or(brX,orX) do { \
338 ulong start = memctl->memc_ ## brX & 0xFFFF8000; \ 338 ulong start = memctl->memc_ ## brX & 0xFFFF8000; \
339 ulong sizem = ~memctl->memc_ ## orX | 0x00007FFF; \ 339 ulong sizem = ~memctl->memc_ ## orX | 0x00007FFF; \
340 printf ("\n" \ 340 printf ("\n" \
341 #brX " 0x%08x " #orX " 0x%08x " \ 341 #brX " 0x%08x " #orX " 0x%08x " \
342 "==> 0x%08lx ... 0x%08lx = %ld MB\n", \ 342 "==> 0x%08lx ... 0x%08lx = %ld MB\n", \
343 memctl->memc_ ## brX, memctl->memc_ ## orX, \ 343 memctl->memc_ ## brX, memctl->memc_ ## orX, \
344 start, start+sizem, (sizem+1)>>20); \ 344 start, start+sizem, (sizem+1)>>20); \
345 } while (0) 345 } while (0)
346 prt_br_or (br0, or0); 346 prt_br_or (br0, or0);
347 prt_br_or (br1, or1); 347 prt_br_or (br1, or1);
348 prt_br_or (br2, or2); 348 prt_br_or (br2, or2);
349 prt_br_or (br3, or3); 349 prt_br_or (br3, or3);
350 #endif 350 #endif
351 351
352 #ifndef CFG_RAMBOOT 352 #ifndef CFG_RAMBOOT
353 /* 60x SDRAM setup: 353 /* 60x SDRAM setup:
354 */ 354 */
355 size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL, 355 size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
356 (uchar *) CFG_SDRAM_BASE); 356 (uchar *) CFG_SDRAM_BASE);
357 size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR1_9COL, 357 size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR1_9COL,
358 (uchar *) CFG_SDRAM_BASE); 358 (uchar *) CFG_SDRAM_BASE);
359 359
360 if (size8 < size9) { 360 if (size8 < size9) {
361 psize = size9; 361 psize = size9;
362 printf ("(60x:9COL - %ld MB, ", psize >> 20); 362 printf ("(60x:9COL - %ld MB, ", psize >> 20);
363 } else { 363 } else {
364 psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL, 364 psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
365 (uchar *) CFG_SDRAM_BASE); 365 (uchar *) CFG_SDRAM_BASE);
366 printf ("(60x:8COL - %ld MB, ", psize >> 20); 366 printf ("(60x:8COL - %ld MB, ", psize >> 20);
367 } 367 }
368 368
369 /* Local SDRAM setup: 369 /* Local SDRAM setup:
370 */ 370 */
371 #ifdef CFG_INIT_LOCAL_SDRAM 371 #ifdef CFG_INIT_LOCAL_SDRAM
372 memctl->memc_lsrt = CFG_LSRT; 372 memctl->memc_lsrt = CFG_LSRT;
373 size8 = try_init (memctl, CFG_LSDMR_8COL, CFG_OR2_8COL, 373 size8 = try_init (memctl, CFG_LSDMR_8COL, CFG_OR2_8COL,
374 (uchar *) SDRAM_BASE2_PRELIM); 374 (uchar *) SDRAM_BASE2_PRELIM);
375 size9 = try_init (memctl, CFG_LSDMR_9COL, CFG_OR2_9COL, 375 size9 = try_init (memctl, CFG_LSDMR_9COL, CFG_OR2_9COL,
376 (uchar *) SDRAM_BASE2_PRELIM); 376 (uchar *) SDRAM_BASE2_PRELIM);
377 377
378 if (size8 < size9) { 378 if (size8 < size9) {
379 lsize = size9; 379 lsize = size9;
380 printf ("Local:9COL - %ld MB) using ", lsize >> 20); 380 printf ("Local:9COL - %ld MB) using ", lsize >> 20);
381 } else { 381 } else {
382 lsize = try_init (memctl, CFG_LSDMR_8COL, CFG_OR2_8COL, 382 lsize = try_init (memctl, CFG_LSDMR_8COL, CFG_OR2_8COL,
383 (uchar *) SDRAM_BASE2_PRELIM); 383 (uchar *) SDRAM_BASE2_PRELIM);
384 printf ("Local:8COL - %ld MB) using ", lsize >> 20); 384 printf ("Local:8COL - %ld MB) using ", lsize >> 20);
385 } 385 }
386 386
387 #if 0 387 #if 0
388 /* Set up BR2 so that the local SDRAM goes 388 /* Set up BR2 so that the local SDRAM goes
389 * right after the 60x SDRAM 389 * right after the 60x SDRAM
390 */ 390 */
391 memctl->memc_br2 = (CFG_BR2_PRELIM & ~BRx_BA_MSK) | 391 memctl->memc_br2 = (CFG_BR2_PRELIM & ~BRx_BA_MSK) |
392 (CFG_SDRAM_BASE + psize); 392 (CFG_SDRAM_BASE + psize);
393 #endif 393 #endif
394 #endif /* CFG_INIT_LOCAL_SDRAM */ 394 #endif /* CFG_INIT_LOCAL_SDRAM */
395 #endif /* CFG_RAMBOOT */ 395 #endif /* CFG_RAMBOOT */
396 396
397 icache_enable (); 397 icache_enable ();
398 398
399 return (psize); 399 return (psize);
400 } 400 }
401 401
402 /* ------------------------------------------------------------------------- */ 402 /* ------------------------------------------------------------------------- */
403 403
1 /* 1 /*
2 * (C) Copyright 2001 2 * (C) Copyright 2001
3 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de 3 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 /************************************************************************/ 24 /************************************************************************/
25 /* ** DEBUG SETTINGS */ 25 /* ** DEBUG SETTINGS */
26 /************************************************************************/ 26 /************************************************************************/
27 27
28 /* #define DEBUG */ 28 /* #define DEBUG */
29 29
30 /************************************************************************/ 30 /************************************************************************/
31 /* ** HEADER FILES */ 31 /* ** HEADER FILES */
32 /************************************************************************/ 32 /************************************************************************/
33 33
34 #include <config.h> 34 #include <config.h>
35 #include <common.h> 35 #include <common.h>
36 #include <version.h> 36 #include <version.h>
37 #include <stdarg.h> 37 #include <stdarg.h>
38 #include <linux/types.h> 38 #include <linux/types.h>
39 #include <devices.h> 39 #include <devices.h>
40 #include <s3c2400.h> 40 #include <s3c2400.h>
41 41
42 #ifdef CONFIG_VFD 42 #ifdef CONFIG_VFD
43 43
44 /************************************************************************/ 44 /************************************************************************/
45 /* ** CONFIG STUFF -- should be moved to board config file */ 45 /* ** CONFIG STUFF -- should be moved to board config file */
46 /************************************************************************/ 46 /************************************************************************/
47 47
48 /************************************************************************/ 48 /************************************************************************/
49 49
50 #ifndef PAGE_SIZE 50 #ifndef PAGE_SIZE
51 #define PAGE_SIZE 4096 51 #define PAGE_SIZE 4096
52 #endif 52 #endif
53 53
54 #define ROT 0x09 54 #define ROT 0x09
55 #define BLAU 0x0C 55 #define BLAU 0x0C
56 #define VIOLETT 0X0D 56 #define VIOLETT 0X0D
57 57
58 ulong vfdbase; 58 ulong vfdbase;
59 ulong frame_buf_size; 59 ulong frame_buf_size;
60 #define frame_buf_offs 4 60 #define frame_buf_offs 4
61 61
62 /* taken from armboot/common/vfd.c */ 62 /* taken from armboot/common/vfd.c */
63 ulong adr_vfd_table[112][18][2][4][2]; 63 ulong adr_vfd_table[112][18][2][4][2];
64 unsigned char bit_vfd_table[112][18][2][4][2]; 64 unsigned char bit_vfd_table[112][18][2][4][2];
65 65
66 /* 66 /*
67 * initialize the values for the VFD-grid-control in the framebuffer 67 * initialize the values for the VFD-grid-control in the framebuffer
68 */ 68 */
69 void init_grid_ctrl(void) 69 void init_grid_ctrl(void)
70 { 70 {
71 ulong adr, grid_cycle; 71 ulong adr, grid_cycle;
72 unsigned int bit, display; 72 unsigned int bit, display;
73 unsigned char temp, bit_nr; 73 unsigned char temp, bit_nr;
74 74
75 for (adr=vfdbase; adr<=(vfdbase+7168); adr+=4) /*clear frame buffer */ 75 for (adr=vfdbase; adr<=(vfdbase+7168); adr+=4) /*clear frame buffer */
76 (*(volatile ulong*)(adr))=0; 76 (*(volatile ulong*)(adr))=0;
77 77
78 for(display=0;display<=3;display++) 78 for(display=0;display<=3;display++)
79 { 79 {
80 for(grid_cycle=0;grid_cycle<=55;grid_cycle++) 80 for(grid_cycle=0;grid_cycle<=55;grid_cycle++)
81 { 81 {
82 bit = grid_cycle*256*4+(grid_cycle+200)*4+frame_buf_offs+display; 82 bit = grid_cycle*256*4+(grid_cycle+200)*4+frame_buf_offs+display;
83 /* wrap arround if offset (see manual S3C2400) */ 83 /* wrap arround if offset (see manual S3C2400) */
84 if (bit>=frame_buf_size*8) 84 if (bit>=frame_buf_size*8)
85 bit = bit-(frame_buf_size*8); 85 bit = bit-(frame_buf_size*8);
86 adr = vfdbase+(bit/32)*4+(3-(bit%32)/8); 86 adr = vfdbase+(bit/32)*4+(3-(bit%32)/8);
87 bit_nr = bit%8; 87 bit_nr = bit%8;
88 bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4; 88 bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;
89 temp=(*(volatile unsigned char*)(adr)); 89 temp=(*(volatile unsigned char*)(adr));
90 temp|=(1<<bit_nr); 90 temp|=(1<<bit_nr);
91 (*(volatile unsigned char*)(adr))=temp; 91 (*(volatile unsigned char*)(adr))=temp;
92 92
93 if(grid_cycle<55) 93 if(grid_cycle<55)
94 bit = grid_cycle*256*4+(grid_cycle+201)*4+frame_buf_offs+display; 94 bit = grid_cycle*256*4+(grid_cycle+201)*4+frame_buf_offs+display;
95 else 95 else
96 bit = grid_cycle*256*4+200*4+frame_buf_offs+display-4; /* grid nr. 0 */ 96 bit = grid_cycle*256*4+200*4+frame_buf_offs+display-4; /* grid nr. 0 */
97 /* wrap arround if offset (see manual S3C2400) */ 97 /* wrap arround if offset (see manual S3C2400) */
98 if (bit>=frame_buf_size*8) 98 if (bit>=frame_buf_size*8)
99 bit = bit-(frame_buf_size*8); 99 bit = bit-(frame_buf_size*8);
100 adr = vfdbase+(bit/32)*4+(3-(bit%32)/8); 100 adr = vfdbase+(bit/32)*4+(3-(bit%32)/8);
101 bit_nr = bit%8; 101 bit_nr = bit%8;
102 bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4; 102 bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;
103 temp=(*(volatile unsigned char*)(adr)); 103 temp=(*(volatile unsigned char*)(adr));
104 temp|=(1<<bit_nr); 104 temp|=(1<<bit_nr);
105 (*(volatile unsigned char*)(adr))=temp; 105 (*(volatile unsigned char*)(adr))=temp;
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 /* 110 /*
111 *create translation table for getting easy the right position in the 111 *create translation table for getting easy the right position in the
112 *physical framebuffer for some x/y-coordinates of the VFDs 112 *physical framebuffer for some x/y-coordinates of the VFDs
113 */ 113 */
114 void create_vfd_table(void) 114 void create_vfd_table(void)
115 { 115 {
116 unsigned int vfd_table[112][18][2][4][2]; 116 unsigned int vfd_table[112][18][2][4][2];
117 ulong adr; 117 ulong adr;
118 unsigned int x, y, color, display, entry, pixel, bit_nr; 118 unsigned int x, y, color, display, entry, pixel, bit_nr;
119 119
120 /* 120 /*
121 * Create translation table for Noritake-T119C-VFD-specific 121 * Create translation table for Noritake-T119C-VFD-specific
122 * organized frame-buffer. 122 * organized frame-buffer.
123 * Created is the number of the bit in the framebuffer (the 123 * Created is the number of the bit in the framebuffer (the
124 * first transferred pixel of each frame is bit 0). 124 * first transferred pixel of each frame is bit 0).
125 */ 125 */
126 for(y=0;y<=17;y++) /* Zeile */ 126 for(y=0;y<=17;y++) /* Zeile */
127 { 127 {
128 for(x=0;x<=111;x++) /* Spalten */ 128 for(x=0;x<=111;x++) /* Spalten */
129 { 129 {
130 /*Display 0 blaue Pixel Eintrag 1 */ 130 /*Display 0 blaue Pixel Eintrag 1 */
131 vfd_table[x][y][0][0][0]=((x%4)*4+y*16+(x/4)*2048); 131 vfd_table[x][y][0][0][0]=((x%4)*4+y*16+(x/4)*2048);
132 /*Display 0 rote Pixel Eintrag 1 */ 132 /*Display 0 rote Pixel Eintrag 1 */
133 vfd_table[x][y][1][0][0]=((x%4)*4+y*16+(x/4)*2048+512); 133 vfd_table[x][y][1][0][0]=((x%4)*4+y*16+(x/4)*2048+512);
134 if(x<=1) 134 if(x<=1)
135 { 135 {
136 /*Display 0 blaue Pixel Eintrag 2 */ 136 /*Display 0 blaue Pixel Eintrag 2 */
137 vfd_table[x][y][0][0][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+1024); 137 vfd_table[x][y][0][0][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+1024);
138 /*Display 0 rote Pixel Eintrag 2 */ 138 /*Display 0 rote Pixel Eintrag 2 */
139 vfd_table[x][y][1][0][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+1024); 139 vfd_table[x][y][1][0][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+1024);
140 } 140 }
141 else 141 else
142 { 142 {
143 /*Display 0 blaue Pixel Eintrag 2 */ 143 /*Display 0 blaue Pixel Eintrag 2 */
144 vfd_table[x][y][0][0][1]=((x%4)*4+y*16+((x-2)/4)*2048+1024); 144 vfd_table[x][y][0][0][1]=((x%4)*4+y*16+((x-2)/4)*2048+1024);
145 /*Display 0 rote Pixel Eintrag 2 */ 145 /*Display 0 rote Pixel Eintrag 2 */
146 vfd_table[x][y][1][0][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+1024); 146 vfd_table[x][y][1][0][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+1024);
147 } 147 }
148 /*Display 1 blaue Pixel Eintrag 1 */ 148 /*Display 1 blaue Pixel Eintrag 1 */
149 vfd_table[x][y][0][1][0]=((x%4)*4+y*16+(x/4)*2048+1); 149 vfd_table[x][y][0][1][0]=((x%4)*4+y*16+(x/4)*2048+1);
150 /*Display 1 rote Pixel Eintrag 1 */ 150 /*Display 1 rote Pixel Eintrag 1 */
151 vfd_table[x][y][1][1][0]=((x%4)*4+y*16+(x/4)*2048+512+1); 151 vfd_table[x][y][1][1][0]=((x%4)*4+y*16+(x/4)*2048+512+1);
152 if(x<=1) 152 if(x<=1)
153 { 153 {
154 /*Display 1 blaue Pixel Eintrag 2 */ 154 /*Display 1 blaue Pixel Eintrag 2 */
155 vfd_table[x][y][0][1][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+1+1024); 155 vfd_table[x][y][0][1][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+1+1024);
156 /*Display 1 rote Pixel Eintrag 2 */ 156 /*Display 1 rote Pixel Eintrag 2 */
157 vfd_table[x][y][1][1][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+1+1024); 157 vfd_table[x][y][1][1][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+1+1024);
158 } 158 }
159 else 159 else
160 { 160 {
161 /*Display 1 blaue Pixel Eintrag 2 */ 161 /*Display 1 blaue Pixel Eintrag 2 */
162 vfd_table[x][y][0][1][1]=((x%4)*4+y*16+((x-2)/4)*2048+1+1024); 162 vfd_table[x][y][0][1][1]=((x%4)*4+y*16+((x-2)/4)*2048+1+1024);
163 /*Display 1 rote Pixel Eintrag 2 */ 163 /*Display 1 rote Pixel Eintrag 2 */
164 vfd_table[x][y][1][1][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+1+1024); 164 vfd_table[x][y][1][1][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+1+1024);
165 } 165 }
166 /*Display 2 blaue Pixel Eintrag 1 */ 166 /*Display 2 blaue Pixel Eintrag 1 */
167 vfd_table[x][y][0][2][0]=((x%4)*4+y*16+(x/4)*2048+2); 167 vfd_table[x][y][0][2][0]=((x%4)*4+y*16+(x/4)*2048+2);
168 /*Display 2 rote Pixel Eintrag 1 */ 168 /*Display 2 rote Pixel Eintrag 1 */
169 vfd_table[x][y][1][2][0]=((x%4)*4+y*16+(x/4)*2048+512+2); 169 vfd_table[x][y][1][2][0]=((x%4)*4+y*16+(x/4)*2048+512+2);
170 if(x<=1) 170 if(x<=1)
171 { 171 {
172 /*Display 2 blaue Pixel Eintrag 2 */ 172 /*Display 2 blaue Pixel Eintrag 2 */
173 vfd_table[x][y][0][2][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+2+1024); 173 vfd_table[x][y][0][2][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+2+1024);
174 /*Display 2 rote Pixel Eintrag 2 */ 174 /*Display 2 rote Pixel Eintrag 2 */
175 vfd_table[x][y][1][2][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+2+1024); 175 vfd_table[x][y][1][2][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+2+1024);
176 } 176 }
177 else 177 else
178 { 178 {
179 /*Display 2 blaue Pixel Eintrag 2 */ 179 /*Display 2 blaue Pixel Eintrag 2 */
180 vfd_table[x][y][0][2][1]=((x%4)*4+y*16+((x-2)/4)*2048+2+1024); 180 vfd_table[x][y][0][2][1]=((x%4)*4+y*16+((x-2)/4)*2048+2+1024);
181 /*Display 2 rote Pixel Eintrag 2 */ 181 /*Display 2 rote Pixel Eintrag 2 */
182 vfd_table[x][y][1][2][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+2+1024); 182 vfd_table[x][y][1][2][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+2+1024);
183 } 183 }
184 /*Display 3 blaue Pixel Eintrag 1 */ 184 /*Display 3 blaue Pixel Eintrag 1 */
185 vfd_table[x][y][0][3][0]=((x%4)*4+y*16+(x/4)*2048+3); 185 vfd_table[x][y][0][3][0]=((x%4)*4+y*16+(x/4)*2048+3);
186 /*Display 3 rote Pixel Eintrag 1 */ 186 /*Display 3 rote Pixel Eintrag 1 */
187 vfd_table[x][y][1][3][0]=((x%4)*4+y*16+(x/4)*2048+512+3); 187 vfd_table[x][y][1][3][0]=((x%4)*4+y*16+(x/4)*2048+512+3);
188 if(x<=1) 188 if(x<=1)
189 { 189 {
190 /*Display 3 blaue Pixel Eintrag 2 */ 190 /*Display 3 blaue Pixel Eintrag 2 */
191 vfd_table[x][y][0][3][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+3+1024); 191 vfd_table[x][y][0][3][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+3+1024);
192 /*Display 3 rote Pixel Eintrag 2 */ 192 /*Display 3 rote Pixel Eintrag 2 */
193 vfd_table[x][y][1][3][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+3+1024); 193 vfd_table[x][y][1][3][1]=(((x+112)%4)*4+y*16+((x+110)/4)*2048+512+3+1024);
194 } 194 }
195 else 195 else
196 { 196 {
197 /*Display 3 blaue Pixel Eintrag 2 */ 197 /*Display 3 blaue Pixel Eintrag 2 */
198 vfd_table[x][y][0][3][1]=((x%4)*4+y*16+((x-2)/4)*2048+3+1024); 198 vfd_table[x][y][0][3][1]=((x%4)*4+y*16+((x-2)/4)*2048+3+1024);
199 /*Display 3 rote Pixel Eintrag 2 */ 199 /*Display 3 rote Pixel Eintrag 2 */
200 vfd_table[x][y][1][3][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+3+1024); 200 vfd_table[x][y][1][3][1]=((x%4)*4+y*16+((x-2)/4)*2048+512+3+1024);
201 } 201 }
202 } 202 }
203 } 203 }
204 204
205 /* 205 /*
206 * Create translation table for Noritake-T119C-VFD-specific 206 * Create translation table for Noritake-T119C-VFD-specific
207 * organized frame-buffer 207 * organized frame-buffer
208 * Create table with entries for physical byte adresses and 208 * Create table with entries for physical byte adresses and
209 * bit-number within the byte 209 * bit-number within the byte
210 * from table with bit-numbers within the total framebuffer 210 * from table with bit-numbers within the total framebuffer
211 */ 211 */
212 for(y=0;y<=17;y++) 212 for(y=0;y<=17;y++)
213 { 213 {
214 for(x=0;x<=111;x++) 214 for(x=0;x<=111;x++)
215 { 215 {
216 for(color=0;color<=1;color++) 216 for(color=0;color<=1;color++)
217 { 217 {
218 for(display=0;display<=3;display++) 218 for(display=0;display<=3;display++)
219 { 219 {
220 for(entry=0;entry<=1;entry++) 220 for(entry=0;entry<=1;entry++)
221 { 221 {
222 pixel = vfd_table[x][y][color][display][entry] + frame_buf_offs; 222 pixel = vfd_table[x][y][color][display][entry] + frame_buf_offs;
223 /* 223 /*
224 * wrap arround if offset 224 * wrap arround if offset
225 * (see manual S3C2400) 225 * (see manual S3C2400)
226 */ 226 */
227 if (pixel>=frame_buf_size*8) 227 if (pixel>=frame_buf_size*8)
228 pixel = pixel-(frame_buf_size*8); 228 pixel = pixel-(frame_buf_size*8);
229 adr = vfdbase+(pixel/32)*4+(3-(pixel%32)/8); 229 adr = vfdbase+(pixel/32)*4+(3-(pixel%32)/8);
230 bit_nr = pixel%8; 230 bit_nr = pixel%8;
231 bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4; 231 bit_nr = (bit_nr>3)?bit_nr-4:bit_nr+4;
232 adr_vfd_table[x][y][color][display][entry] = adr; 232 adr_vfd_table[x][y][color][display][entry] = adr;
233 bit_vfd_table[x][y][color][display][entry] = bit_nr; 233 bit_vfd_table[x][y][color][display][entry] = bit_nr;
234 } 234 }
235 } 235 }
236 } 236 }
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 /* 241 /*
242 * Set/clear pixel of the VFDs 242 * Set/clear pixel of the VFDs
243 */ 243 */
244 void set_vfd_pixel(unsigned char x, unsigned char y, unsigned char color, unsigned char display, unsigned char value) 244 void set_vfd_pixel(unsigned char x, unsigned char y, unsigned char color, unsigned char display, unsigned char value)
245 { 245 {
246 ulong adr; 246 ulong adr;
247 unsigned char bit_nr, temp; 247 unsigned char bit_nr, temp;
248 248
249 if (value!=0) 249 if (value!=0)
250 { 250 {
251 /* Pixel-Eintrag Nr. 1 */ 251 /* Pixel-Eintrag Nr. 1 */
252 adr = adr_vfd_table[x][y][color][display][0]; 252 adr = adr_vfd_table[x][y][color][display][0];
253 /* Pixel-Eintrag Nr. 1 */ 253 /* Pixel-Eintrag Nr. 1 */
254 bit_nr = bit_vfd_table[x][y][color][display][0]; 254 bit_nr = bit_vfd_table[x][y][color][display][0];
255 temp=(*(volatile unsigned char*)(adr)); 255 temp=(*(volatile unsigned char*)(adr));
256 temp|=1<<bit_nr; 256 temp|=1<<bit_nr;
257 (*(volatile unsigned char*)(adr))=temp; 257 (*(volatile unsigned char*)(adr))=temp;
258 258
259 /* Pixel-Eintrag Nr. 2 */ 259 /* Pixel-Eintrag Nr. 2 */
260 adr = adr_vfd_table[x][y][color][display][1]; 260 adr = adr_vfd_table[x][y][color][display][1];
261 /* Pixel-Eintrag Nr. 2 */ 261 /* Pixel-Eintrag Nr. 2 */
262 bit_nr = bit_vfd_table[x][y][color][display][1]; 262 bit_nr = bit_vfd_table[x][y][color][display][1];
263 temp=(*(volatile unsigned char*)(adr)); 263 temp=(*(volatile unsigned char*)(adr));
264 temp|=1<<bit_nr; 264 temp|=1<<bit_nr;
265 (*(volatile unsigned char*)(adr))=temp; 265 (*(volatile unsigned char*)(adr))=temp;
266 } 266 }
267 else 267 else
268 { 268 {
269 /* Pixel-Eintrag Nr. 1 */ 269 /* Pixel-Eintrag Nr. 1 */
270 adr = adr_vfd_table[x][y][color][display][0]; 270 adr = adr_vfd_table[x][y][color][display][0];
271 /* Pixel-Eintrag Nr. 1 */ 271 /* Pixel-Eintrag Nr. 1 */
272 bit_nr = bit_vfd_table[x][y][color][display][0]; 272 bit_nr = bit_vfd_table[x][y][color][display][0];
273 temp=(*(volatile unsigned char*)(adr)); 273 temp=(*(volatile unsigned char*)(adr));
274 temp&=~(1<<bit_nr); 274 temp&=~(1<<bit_nr);
275 (*(volatile unsigned char*)(adr))=temp; 275 (*(volatile unsigned char*)(adr))=temp;
276 276
277 /* Pixel-Eintrag Nr. 2 */ 277 /* Pixel-Eintrag Nr. 2 */
278 adr = adr_vfd_table[x][y][color][display][1]; 278 adr = adr_vfd_table[x][y][color][display][1];
279 /* Pixel-Eintrag Nr. 2 */ 279 /* Pixel-Eintrag Nr. 2 */
280 bit_nr = bit_vfd_table[x][y][color][display][1]; 280 bit_nr = bit_vfd_table[x][y][color][display][1];
281 temp=(*(volatile unsigned char*)(adr)); 281 temp=(*(volatile unsigned char*)(adr));
282 temp&=~(1<<bit_nr); 282 temp&=~(1<<bit_nr);
283 (*(volatile unsigned char*)(adr))=temp; 283 (*(volatile unsigned char*)(adr))=temp;
284 } 284 }
285 } 285 }
286 286
287 /* 287 /*
288 * transfer image from BMP-File 288 * transfer image from BMP-File
289 */ 289 */
290 void transfer_pic(int display, unsigned char *adr, int height, int width) 290 void transfer_pic(int display, unsigned char *adr, int height, int width)
291 { 291 {
292 int x, y; 292 int x, y;
293 unsigned char temp; 293 unsigned char temp;
294 294
295 for (; height > 0; height -= 18) 295 for (; height > 0; height -= 18)
296 { 296 {
297 if (height > 18) 297 if (height > 18)
298 y = 18; 298 y = 18;
299 else 299 else
300 y = height; 300 y = height;
301 for (; y > 0; y--) 301 for (; y > 0; y--)
302 { 302 {
303 for (x = 0; x < width; x += 2) 303 for (x = 0; x < width; x += 2)
304 { 304 {
305 temp = *adr++; 305 temp = *adr++;
306 set_vfd_pixel(x, y-1, 0, display, 0); 306 set_vfd_pixel(x, y-1, 0, display, 0);
307 set_vfd_pixel(x, y-1, 1, display, 0); 307 set_vfd_pixel(x, y-1, 1, display, 0);
308 if ((temp >> 4) == BLAU) 308 if ((temp >> 4) == BLAU)
309 set_vfd_pixel(x, y-1, 0, display, 1); 309 set_vfd_pixel(x, y-1, 0, display, 1);
310 else if ((temp >> 4) == ROT) 310 else if ((temp >> 4) == ROT)
311 set_vfd_pixel(x, y-1, 1, display, 1); 311 set_vfd_pixel(x, y-1, 1, display, 1);
312 else if ((temp >> 4) == VIOLETT) 312 else if ((temp >> 4) == VIOLETT)
313 { 313 {
314 set_vfd_pixel(x, y-1, 0, display, 1); 314 set_vfd_pixel(x, y-1, 0, display, 1);
315 set_vfd_pixel(x, y-1, 1, display, 1); 315 set_vfd_pixel(x, y-1, 1, display, 1);
316 } 316 }
317 set_vfd_pixel(x+1, y-1, 0, display, 0); 317 set_vfd_pixel(x+1, y-1, 0, display, 0);
318 set_vfd_pixel(x+1, y-1, 1, display, 0); 318 set_vfd_pixel(x+1, y-1, 1, display, 0);
319 if ((temp & 0x0F) == BLAU) 319 if ((temp & 0x0F) == BLAU)
320 set_vfd_pixel(x+1, y-1, 0, display, 1); 320 set_vfd_pixel(x+1, y-1, 0, display, 1);
321 else if ((temp & 0x0F) == ROT) 321 else if ((temp & 0x0F) == ROT)
322 set_vfd_pixel(x+1, y-1, 1, display, 1); 322 set_vfd_pixel(x+1, y-1, 1, display, 1);
323 else if ((temp & 0x0F) == VIOLETT) 323 else if ((temp & 0x0F) == VIOLETT)
324 { 324 {
325 set_vfd_pixel(x+1, y-1, 0, display, 1); 325 set_vfd_pixel(x+1, y-1, 0, display, 1);
326 set_vfd_pixel(x+1, y-1, 1, display, 1); 326 set_vfd_pixel(x+1, y-1, 1, display, 1);
327 } 327 }
328 } 328 }
329 } 329 }
330 display++; 330 display++;
331 if (display > 3) 331 if (display > 3)
332 display = 0; 332 display = 0;
333 } 333 }
334 } 334 }
335 335
336 /* 336 /*
337 * initialize LCD-Controller of the S3C2400 for using VFDs 337 * initialize LCD-Controller of the S3C2400 for using VFDs
338 */ 338 */
339 int drv_vfd_init(void) 339 int drv_vfd_init(void)
340 { 340 {
341 ulong palette; 341 ulong palette;
342 static int vfd_init_done = 0; 342 static int vfd_init_done = 0;
343 343
344 DECLARE_GLOBAL_DATA_PTR; 344 DECLARE_GLOBAL_DATA_PTR;
345 345
346 if (vfd_init_done != 0) 346 if (vfd_init_done != 0)
347 return; 347 return (0);
348 vfd_init_done = 1; 348 vfd_init_done = 1;
349 349
350 vfdbase = gd->fb_base; 350 vfdbase = gd->fb_base;
351 create_vfd_table(); 351 create_vfd_table();
352 init_grid_ctrl(); 352 init_grid_ctrl();
353 353
354 /* 354 /*
355 * Hinweis: Der Framebuffer ist um genau ein Nibble verschoben 355 * Hinweis: Der Framebuffer ist um genau ein Nibble verschoben
356 * Das erste angezeigte Pixel wird aus dem zweiten Nibble geholt 356 * Das erste angezeigte Pixel wird aus dem zweiten Nibble geholt
357 * das letzte angezeigte Pixel wird aus dem ersten Nibble geholt 357 * das letzte angezeigte Pixel wird aus dem ersten Nibble geholt
358 * (wrap around) 358 * (wrap around)
359 * see manual S3C2400 359 * see manual S3C2400
360 */ 360 */
361 /* frame buffer startadr */ 361 /* frame buffer startadr */
362 rLCDSADDR1 = vfdbase >> 1; 362 rLCDSADDR1 = vfdbase >> 1;
363 /* frame buffer endadr */ 363 /* frame buffer endadr */
364 rLCDSADDR2 = (vfdbase + frame_buf_size) >> 1; 364 rLCDSADDR2 = (vfdbase + frame_buf_size) >> 1;
365 rLCDSADDR3 = ((256/4)); 365 rLCDSADDR3 = ((256/4));
366 366
367 /* Port-Pins als LCD-Ausgang */ 367 /* Port-Pins als LCD-Ausgang */
368 rPCCON = (rPCCON & 0xFFFFFF00)| 0x000000AA; 368 rPCCON = (rPCCON & 0xFFFFFF00)| 0x000000AA;
369 /* Port-Pins als LCD-Ausgang */ 369 /* Port-Pins als LCD-Ausgang */
370 rPDCON = (rPDCON & 0xFFFFFF03)| 0x000000A8; 370 rPDCON = (rPDCON & 0xFFFFFF03)| 0x000000A8;
371 #ifdef WITH_VFRAME 371 #ifdef WITH_VFRAME
372 /* mit VFRAME zum Messen */ 372 /* mit VFRAME zum Messen */
373 rPDCON = (rPDCON & 0xFFFFFF00)| 0x000000AA; 373 rPDCON = (rPDCON & 0xFFFFFF00)| 0x000000AA;
374 #endif 374 #endif
375 375
376 rLCDCON2 = 0x000DC000; 376 rLCDCON2 = 0x000DC000;
377 rLCDCON3 = 0x0051000A; 377 rLCDCON3 = 0x0051000A;
378 rLCDCON4 = 0x00000001; 378 rLCDCON4 = 0x00000001;
379 rLCDCON5 = 0x00000440; 379 rLCDCON5 = 0x00000440;
380 rLCDCON1 = 0x00000B75; 380 rLCDCON1 = 0x00000B75;
381 381
382 debug ("LCDSADDR1: %lX\n", rLCDSADDR1); 382 debug ("LCDSADDR1: %lX\n", rLCDSADDR1);
383 debug ("LCDSADDR2: %lX\n", rLCDSADDR2); 383 debug ("LCDSADDR2: %lX\n", rLCDSADDR2);
384 debug ("LCDSADDR3: %lX\n", rLCDSADDR3); 384 debug ("LCDSADDR3: %lX\n", rLCDSADDR3);
385 385
386 for(palette=0;palette<=15;palette++) 386 for(palette=0;palette<=15;palette++)
387 (*(volatile unsigned int*)(PALETTE+(palette*4)))=palette; 387 (*(volatile unsigned int*)(PALETTE+(palette*4)))=palette;
388 for(palette=16;palette<=255;palette++) 388 for(palette=16;palette<=255;palette++)
389 (*(volatile unsigned int*)(PALETTE+(palette*4)))=0x00; 389 (*(volatile unsigned int*)(PALETTE+(palette*4)))=0x00;
390 390
391 return 0; 391 return 0;
392 } 392 }
393 393
394 /************************************************************************/ 394 /************************************************************************/
395 /* ** ROM capable initialization part - needed to reserve FB memory */ 395 /* ** ROM capable initialization part - needed to reserve FB memory */
396 /************************************************************************/ 396 /************************************************************************/
397 397
398 /* 398 /*
399 * This is called early in the system initialization to grab memory 399 * This is called early in the system initialization to grab memory
400 * for the VFD controller. 400 * for the VFD controller.
401 * 401 *
402 * Note that this is running from ROM, so no write access to global data. 402 * Note that this is running from ROM, so no write access to global data.
403 */ 403 */
404 ulong vfd_setmem (ulong addr) 404 ulong vfd_setmem (ulong addr)
405 { 405 {
406 ulong size; 406 ulong size;
407 407
408 /* MAGIC */ 408 /* MAGIC */
409 frame_buf_size = (256*4*56)/8; 409 frame_buf_size = (256*4*56)/8;
410 410
411 /* Round up to nearest full page */ 411 /* Round up to nearest full page */
412 size = (frame_buf_size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); 412 size = (frame_buf_size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
413 413
414 debug ("Reserving %ldk for VFD Framebuffer at: %08lx\n", size>>10, addr); 414 debug ("Reserving %ldk for VFD Framebuffer at: %08lx\n", size>>10, addr);
415 415
416 return (size); 416 return (size);
417 } 417 }
418 418
419 #endif /* CONFIG_VFD */ 419 #endif /* CONFIG_VFD */
420 420
1 /* 1 /*
2 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> 2 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
3 * Andreas Heppel <aheppel@sysgo.de> 3 * Andreas Heppel <aheppel@sysgo.de>
4 * 4 *
5 * (C) Copyright 2002 5 * (C) Copyright 2002
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de. 7 * Wolfgang Grandegger, DENX Software Engineering, wg@denx.de.
8 * 8 *
9 * See file CREDITS for list of people who contributed to this 9 * See file CREDITS for list of people who contributed to this
10 * project. 10 * project.
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as 13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of 14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version. 15 * the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU General Public License 22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software 23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA 25 * MA 02111-1307 USA
26 */ 26 */
27 27
28 /* 28 /*
29 * PCI routines 29 * PCI routines
30 */ 30 */
31 31
32 #include <common.h> 32 #include <common.h>
33 33
34 #ifdef CONFIG_PCI 34 #ifdef CONFIG_PCI
35 35
36 #include <command.h> 36 #include <command.h>
37 #include <cmd_boot.h> 37 #include <cmd_boot.h>
38 #include <asm/processor.h> 38 #include <asm/processor.h>
39 #include <asm/io.h> 39 #include <asm/io.h>
40 #include <cmd_pci.h> 40 #include <cmd_pci.h>
41 #include <pci.h> 41 #include <pci.h>
42 42
43 #if (CONFIG_COMMANDS & CFG_CMD_PCI) 43 #if (CONFIG_COMMANDS & CFG_CMD_PCI)
44 44
45 extern int cmd_get_data_size(char* arg, int default_size); 45 extern int cmd_get_data_size(char* arg, int default_size);
46 46
47 unsigned char ShortPCIListing = 1; 47 unsigned char ShortPCIListing = 1;
48 48
49 /* 49 /*
50 * Follows routines for the output of infos about devices on PCI bus. 50 * Follows routines for the output of infos about devices on PCI bus.
51 */ 51 */
52 52
53 void pci_header_show(pci_dev_t dev); 53 void pci_header_show(pci_dev_t dev);
54 void pci_header_show_brief(pci_dev_t dev); 54 void pci_header_show_brief(pci_dev_t dev);
55 55
56 /* 56 /*
57 * Subroutine: pciinfo 57 * Subroutine: pciinfo
58 * 58 *
59 * Description: Show information about devices on PCI bus. 59 * Description: Show information about devices on PCI bus.
60 * Depending on the define CFG_SHORT_PCI_LISTING 60 * Depending on the define CFG_SHORT_PCI_LISTING
61 * the output will be more or less exhaustive. 61 * the output will be more or less exhaustive.
62 * 62 *
63 * Inputs: bus_no the number of the bus to be scanned. 63 * Inputs: bus_no the number of the bus to be scanned.
64 * 64 *
65 * Return: None 65 * Return: None
66 * 66 *
67 */ 67 */
68 void pciinfo(int BusNum, int ShortPCIListing) 68 void pciinfo(int BusNum, int ShortPCIListing)
69 { 69 {
70 int Device; 70 int Device;
71 int Function; 71 int Function;
72 unsigned char HeaderType; 72 unsigned char HeaderType;
73 unsigned short VendorID; 73 unsigned short VendorID;
74 pci_dev_t dev; 74 pci_dev_t dev;
75 75
76 printf("Scanning PCI devices on bus %d\n", BusNum); 76 printf("Scanning PCI devices on bus %d\n", BusNum);
77 77
78 if (ShortPCIListing) { 78 if (ShortPCIListing) {
79 printf("BusDevFun VendorId DeviceId Device Class Sub-Class\n"); 79 printf("BusDevFun VendorId DeviceId Device Class Sub-Class\n");
80 printf("_____________________________________________________________\n"); 80 printf("_____________________________________________________________\n");
81 } 81 }
82 82
83 for (Device = 0; Device < PCI_MAX_PCI_DEVICES; Device++) { 83 for (Device = 0; Device < PCI_MAX_PCI_DEVICES; Device++) {
84 HeaderType = 0; 84 HeaderType = 0;
85 VendorID = 0; 85 VendorID = 0;
86 for (Function = 0; Function < PCI_MAX_PCI_FUNCTIONS; Function++) { 86 for (Function = 0; Function < PCI_MAX_PCI_FUNCTIONS; Function++) {
87 /* 87 /*
88 * If this is not a multi-function device, we skip the rest. 88 * If this is not a multi-function device, we skip the rest.
89 */ 89 */
90 if (Function && !(HeaderType & 0x80)) 90 if (Function && !(HeaderType & 0x80))
91 break; 91 break;
92 92
93 dev = PCI_BDF(BusNum, Device, Function); 93 dev = PCI_BDF(BusNum, Device, Function);
94 94
95 pci_read_config_word(dev, PCI_VENDOR_ID, &VendorID); 95 pci_read_config_word(dev, PCI_VENDOR_ID, &VendorID);
96 if ((VendorID == 0xFFFF) || (VendorID == 0x0000)) 96 if ((VendorID == 0xFFFF) || (VendorID == 0x0000))
97 continue; 97 continue;
98 98
99 if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType); 99 if (!Function) pci_read_config_byte(dev, PCI_HEADER_TYPE, &HeaderType);
100 100
101 if (ShortPCIListing) 101 if (ShortPCIListing)
102 { 102 {
103 printf("%02x.%02x.%02x ", BusNum, Device, Function); 103 printf("%02x.%02x.%02x ", BusNum, Device, Function);
104 pci_header_show_brief(dev); 104 pci_header_show_brief(dev);
105 } 105 }
106 else 106 else
107 { 107 {
108 printf("\nFound PCI device %02x.%02x.%02x:\n", 108 printf("\nFound PCI device %02x.%02x.%02x:\n",
109 BusNum, Device, Function); 109 BusNum, Device, Function);
110 pci_header_show(dev); 110 pci_header_show(dev);
111 } 111 }
112 } 112 }
113 } 113 }
114 } 114 }
115 115
116 char* pci_classes_str(u8 class) 116 char* pci_classes_str(u8 class)
117 { 117 {
118 static char *pci_classes[] = { 118 static char *pci_classes[] = {
119 "Build before PCI Rev2.0", 119 "Build before PCI Rev2.0",
120 "Mass storage controller", 120 "Mass storage controller",
121 "Network controller ", 121 "Network controller ",
122 "Display controller ", 122 "Display controller ",
123 "Multimedia device ", 123 "Multimedia device ",
124 "Memory controller ", 124 "Memory controller ",
125 "Bridge device ", 125 "Bridge device ",
126 "Simple comm. controller", 126 "Simple comm. controller",
127 "Base system peripheral ", 127 "Base system peripheral ",
128 "Input device ", 128 "Input device ",
129 "Docking station ", 129 "Docking station ",
130 "Processor ", 130 "Processor ",
131 "Serial bus controller ", 131 "Serial bus controller ",
132 "Reserved entry ", 132 "Reserved entry ",
133 "Does not fit any class " 133 "Does not fit any class "
134 }; 134 };
135 135
136 if (class < (sizeof pci_classes / sizeof *pci_classes)) 136 if (class < (sizeof pci_classes / sizeof *pci_classes))
137 return pci_classes[(int) class]; 137 return pci_classes[(int) class];
138 138
139 return "??? "; 139 return "??? ";
140 } 140 }
141 141
142 /* 142 /*
143 * Subroutine: pci_header_show_brief 143 * Subroutine: pci_header_show_brief
144 * 144 *
145 * Description: Reads and prints the header of the 145 * Description: Reads and prints the header of the
146 * specified PCI device in short form. 146 * specified PCI device in short form.
147 * 147 *
148 * Inputs: dev Bus+Device+Function number 148 * Inputs: dev Bus+Device+Function number
149 * 149 *
150 * Return: None 150 * Return: None
151 * 151 *
152 */ 152 */
153 void pci_header_show_brief(pci_dev_t dev) 153 void pci_header_show_brief(pci_dev_t dev)
154 { 154 {
155 u16 vendor, device; 155 u16 vendor, device;
156 u8 class, subclass; 156 u8 class, subclass;
157 157
158 pci_read_config_word(dev, PCI_VENDOR_ID, &vendor); 158 pci_read_config_word(dev, PCI_VENDOR_ID, &vendor);
159 pci_read_config_word(dev, PCI_DEVICE_ID, &device); 159 pci_read_config_word(dev, PCI_DEVICE_ID, &device);
160 pci_read_config_byte(dev, PCI_CLASS_CODE, &class); 160 pci_read_config_byte(dev, PCI_CLASS_CODE, &class);
161 pci_read_config_byte(dev, PCI_CLASS_SUB_CODE, &subclass); 161 pci_read_config_byte(dev, PCI_CLASS_SUB_CODE, &subclass);
162 162
163 printf("0x%.4x 0x%.4x %s 0x%.2x\n", 163 printf("0x%.4x 0x%.4x %s 0x%.2x\n",
164 vendor, device, 164 vendor, device,
165 pci_classes_str(class), subclass); 165 pci_classes_str(class), subclass);
166 } 166 }
167 167
168 /* 168 /*
169 * Subroutine: PCI_Header_Show 169 * Subroutine: PCI_Header_Show
170 * 170 *
171 * Description: Reads the header of the specified PCI device. 171 * Description: Reads the header of the specified PCI device.
172 * 172 *
173 * Inputs: BusDevFunc Bus+Device+Function number 173 * Inputs: BusDevFunc Bus+Device+Function number
174 * 174 *
175 * Return: None 175 * Return: None
176 * 176 *
177 */ 177 */
178 void pci_header_show(pci_dev_t dev) 178 void pci_header_show(pci_dev_t dev)
179 { 179 {
180 u8 _byte, header_type; 180 u8 _byte, header_type;
181 u16 _word; 181 u16 _word;
182 u32 _dword; 182 u32 _dword;
183 183
184 #define PRINT(msg, type, reg) \ 184 #define PRINT(msg, type, reg) \
185 pci_read_config_##type(dev, reg, &_##type); \ 185 pci_read_config_##type(dev, reg, &_##type); \
186 printf(msg, _##type) 186 printf(msg, _##type)
187 187
188 #define PRINT2(msg, type, reg, func) \ 188 #define PRINT2(msg, type, reg, func) \
189 pci_read_config_##type(dev, reg, &_##type); \ 189 pci_read_config_##type(dev, reg, &_##type); \
190 printf(msg, _##type, func(_##type)) 190 printf(msg, _##type, func(_##type))
191 191
192 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type); 192 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
193 193
194 PRINT (" vendor ID = 0x%.4x\n", word, PCI_VENDOR_ID); 194 PRINT (" vendor ID = 0x%.4x\n", word, PCI_VENDOR_ID);
195 PRINT (" device ID = 0x%.4x\n", word, PCI_DEVICE_ID); 195 PRINT (" device ID = 0x%.4x\n", word, PCI_DEVICE_ID);
196 PRINT (" command register = 0x%.4x\n", word, PCI_COMMAND); 196 PRINT (" command register = 0x%.4x\n", word, PCI_COMMAND);
197 PRINT (" status register = 0x%.4x\n", word, PCI_STATUS); 197 PRINT (" status register = 0x%.4x\n", word, PCI_STATUS);
198 PRINT (" revision ID = 0x%.2x\n", byte, PCI_REVISION_ID); 198 PRINT (" revision ID = 0x%.2x\n", byte, PCI_REVISION_ID);
199 PRINT2(" class code = 0x%.2x (%s)\n", byte, PCI_CLASS_CODE, 199 PRINT2(" class code = 0x%.2x (%s)\n", byte, PCI_CLASS_CODE,
200 pci_classes_str); 200 pci_classes_str);
201 PRINT (" sub class code = 0x%.2x\n", byte, PCI_CLASS_SUB_CODE); 201 PRINT (" sub class code = 0x%.2x\n", byte, PCI_CLASS_SUB_CODE);
202 PRINT (" programming interface = 0x%.2x\n", byte, PCI_CLASS_PROG); 202 PRINT (" programming interface = 0x%.2x\n", byte, PCI_CLASS_PROG);
203 PRINT (" cache line = 0x%.2x\n", byte, PCI_CACHE_LINE_SIZE); 203 PRINT (" cache line = 0x%.2x\n", byte, PCI_CACHE_LINE_SIZE);
204 PRINT (" latency time = 0x%.2x\n", byte, PCI_LATENCY_TIMER); 204 PRINT (" latency time = 0x%.2x\n", byte, PCI_LATENCY_TIMER);
205 PRINT (" header type = 0x%.2x\n", byte, PCI_HEADER_TYPE); 205 PRINT (" header type = 0x%.2x\n", byte, PCI_HEADER_TYPE);
206 PRINT (" BIST = 0x%.2x\n", byte, PCI_BIST); 206 PRINT (" BIST = 0x%.2x\n", byte, PCI_BIST);
207 PRINT (" base address 0 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_0); 207 PRINT (" base address 0 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_0);
208 PRINT (" base address 1 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_1);
209 208
210 if (header_type & 0x01) { /* PCI-to-PCI bridge */ 209 switch (header_type & 0x03) {
210 case PCI_HEADER_TYPE_NORMAL: /* "normal" PCI device */
211 PRINT (" base address 1 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_1);
212 PRINT (" base address 2 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_2);
213 PRINT (" base address 3 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_3);
214 PRINT (" base address 4 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_4);
215 PRINT (" base address 5 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_5);
216 PRINT (" cardBus CIS pointer = 0x%.8x\n", dword, PCI_CARDBUS_CIS);
217 PRINT (" sub system vendor ID = 0x%.4x\n", word, PCI_SUBSYSTEM_VENDOR_ID);
218 PRINT (" sub system ID = 0x%.4x\n", word, PCI_SUBSYSTEM_ID);
219 PRINT (" expansion ROM base address = 0x%.8x\n", dword, PCI_ROM_ADDRESS);
220 PRINT (" interrupt line = 0x%.2x\n", byte, PCI_INTERRUPT_LINE);
221 PRINT (" interrupt pin = 0x%.2x\n", byte, PCI_INTERRUPT_PIN);
222 PRINT (" min Grant = 0x%.2x\n", byte, PCI_MIN_GNT);
223 PRINT (" max Latency = 0x%.2x\n", byte, PCI_MAX_LAT);
224 break;
225
226 case PCI_HEADER_TYPE_BRIDGE: /* PCI-to-PCI bridge */
227
228 PRINT (" base address 1 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_1);
211 PRINT (" primary bus number = 0x%.2x\n", byte, PCI_PRIMARY_BUS); 229 PRINT (" primary bus number = 0x%.2x\n", byte, PCI_PRIMARY_BUS);
212 PRINT (" secondary bus number = 0x%.2x\n", byte, PCI_SECONDARY_BUS); 230 PRINT (" secondary bus number = 0x%.2x\n", byte, PCI_SECONDARY_BUS);
213 PRINT (" subordinate bus number = 0x%.2x\n", byte, PCI_SUBORDINATE_BUS); 231 PRINT (" subordinate bus number = 0x%.2x\n", byte, PCI_SUBORDINATE_BUS);
214 PRINT (" secondary latency timer = 0x%.2x\n", byte, PCI_SEC_LATENCY_TIMER); 232 PRINT (" secondary latency timer = 0x%.2x\n", byte, PCI_SEC_LATENCY_TIMER);
215 PRINT (" IO base = 0x%.2x\n", byte, PCI_IO_BASE); 233 PRINT (" IO base = 0x%.2x\n", byte, PCI_IO_BASE);
216 PRINT (" IO limit = 0x%.2x\n", byte, PCI_IO_LIMIT); 234 PRINT (" IO limit = 0x%.2x\n", byte, PCI_IO_LIMIT);
217 PRINT (" secondary status = 0x%.4x\n", word, PCI_SEC_STATUS); 235 PRINT (" secondary status = 0x%.4x\n", word, PCI_SEC_STATUS);
218 PRINT (" memory base = 0x%.4x\n", word, PCI_MEMORY_BASE); 236 PRINT (" memory base = 0x%.4x\n", word, PCI_MEMORY_BASE);
219 PRINT (" memory limit = 0x%.4x\n", word, PCI_MEMORY_LIMIT); 237 PRINT (" memory limit = 0x%.4x\n", word, PCI_MEMORY_LIMIT);
220 PRINT (" prefetch memory base = 0x%.4x\n", word, PCI_PREF_MEMORY_BASE); 238 PRINT (" prefetch memory base = 0x%.4x\n", word, PCI_PREF_MEMORY_BASE);
221 PRINT (" prefetch memory limit = 0x%.4x\n", word, PCI_PREF_MEMORY_LIMIT); 239 PRINT (" prefetch memory limit = 0x%.4x\n", word, PCI_PREF_MEMORY_LIMIT);
222 PRINT (" prefetch memory base upper = 0x%.8x\n", dword, PCI_PREF_BASE_UPPER32); 240 PRINT (" prefetch memory base upper = 0x%.8x\n", dword, PCI_PREF_BASE_UPPER32);
223 PRINT (" prefetch memory limit upper = 0x%.8x\n", dword, PCI_PREF_LIMIT_UPPER32); 241 PRINT (" prefetch memory limit upper = 0x%.8x\n", dword, PCI_PREF_LIMIT_UPPER32);
224 PRINT (" IO base upper 16 bits = 0x%.4x\n", word, PCI_IO_BASE_UPPER16); 242 PRINT (" IO base upper 16 bits = 0x%.4x\n", word, PCI_IO_BASE_UPPER16);
225 PRINT (" IO limit upper 16 bits = 0x%.4x\n", word, PCI_IO_LIMIT_UPPER16); 243 PRINT (" IO limit upper 16 bits = 0x%.4x\n", word, PCI_IO_LIMIT_UPPER16);
226 PRINT (" expansion ROM base address = 0x%.8x\n", dword, PCI_ROM_ADDRESS1); 244 PRINT (" expansion ROM base address = 0x%.8x\n", dword, PCI_ROM_ADDRESS1);
227 PRINT (" interrupt line = 0x%.2x\n", byte, PCI_INTERRUPT_LINE); 245 PRINT (" interrupt line = 0x%.2x\n", byte, PCI_INTERRUPT_LINE);
228 PRINT (" interrupt pin = 0x%.2x\n", byte, PCI_INTERRUPT_PIN); 246 PRINT (" interrupt pin = 0x%.2x\n", byte, PCI_INTERRUPT_PIN);
229 PRINT (" bridge control = 0x%.4x\n", word, PCI_BRIDGE_CONTROL); 247 PRINT (" bridge control = 0x%.4x\n", word, PCI_BRIDGE_CONTROL);
230 } else { /* PCI device */ 248 break;
231 PRINT(" base address 2 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_2); 249
232 PRINT(" base address 3 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_3); 250 case PCI_HEADER_TYPE_CARDBUS: /* PCI-to-CardBus bridge */
233 PRINT(" base address 4 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_4); 251
234 PRINT(" base address 5 = 0x%.8x\n", dword, PCI_BASE_ADDRESS_5); 252 PRINT (" capabilities = 0x%.2x\n", byte, PCI_CB_CAPABILITY_LIST);
235 PRINT(" cardBus CIS pointer = 0x%.8x\n", dword, PCI_CARDBUS_CIS); 253 PRINT (" secondary status = 0x%.4x\n", word, PCI_CB_SEC_STATUS);
236 PRINT(" sub system vendor ID = 0x%.4x\n", word, PCI_SUBSYSTEM_VENDOR_ID); 254 PRINT (" primary bus number = 0x%.2x\n", byte, PCI_CB_PRIMARY_BUS);
237 PRINT(" sub system ID = 0x%.4x\n", word, PCI_SUBSYSTEM_ID); 255 PRINT (" CardBus number = 0x%.2x\n", byte, PCI_CB_CARD_BUS);
238 PRINT(" expansion ROM base address = 0x%.8x\n", dword, PCI_ROM_ADDRESS); 256 PRINT (" subordinate bus number = 0x%.2x\n", byte, PCI_CB_SUBORDINATE_BUS);
239 PRINT(" interrupt line = 0x%.2x\n", byte, PCI_INTERRUPT_LINE); 257 PRINT (" CardBus latency timer = 0x%.2x\n", byte, PCI_CB_LATENCY_TIMER);
240 PRINT(" interrupt pin = 0x%.2x\n", byte, PCI_INTERRUPT_PIN); 258 PRINT (" CardBus memory base 0 = 0x%.8x\n", dword, PCI_CB_MEMORY_BASE_0);
241 PRINT(" min Grant = 0x%.2x\n", byte, PCI_MIN_GNT); 259 PRINT (" CardBus memory limit 0 = 0x%.8x\n", dword, PCI_CB_MEMORY_LIMIT_0);
242 PRINT(" max Latency = 0x%.2x\n", byte, PCI_MAX_LAT); 260 PRINT (" CardBus memory base 1 = 0x%.8x\n", dword, PCI_CB_MEMORY_BASE_1);
261 PRINT (" CardBus memory limit 1 = 0x%.8x\n", dword, PCI_CB_MEMORY_LIMIT_1);
262 PRINT (" CardBus IO base 0 = 0x%.4x\n", word, PCI_CB_IO_BASE_0);
263 PRINT (" CardBus IO base high 0 = 0x%.4x\n", word, PCI_CB_IO_BASE_0_HI);
264 PRINT (" CardBus IO limit 0 = 0x%.4x\n", word, PCI_CB_IO_LIMIT_0);
265 PRINT (" CardBus IO limit high 0 = 0x%.4x\n", word, PCI_CB_IO_LIMIT_0_HI);
266 PRINT (" CardBus IO base 1 = 0x%.4x\n", word, PCI_CB_IO_BASE_1);
267 PRINT (" CardBus IO base high 1 = 0x%.4x\n", word, PCI_CB_IO_BASE_1_HI);
268 PRINT (" CardBus IO limit 1 = 0x%.4x\n", word, PCI_CB_IO_LIMIT_1);
269 PRINT (" CardBus IO limit high 1 = 0x%.4x\n", word, PCI_CB_IO_LIMIT_1_HI);
270 PRINT (" interrupt line = 0x%.2x\n", byte, PCI_INTERRUPT_LINE);
271 PRINT (" interrupt pin = 0x%.2x\n", byte, PCI_INTERRUPT_PIN);
272 PRINT (" bridge control = 0x%.4x\n", word, PCI_CB_BRIDGE_CONTROL);
273 PRINT (" subvendor ID = 0x%.4x\n", word, PCI_CB_SUBSYSTEM_VENDOR_ID);
274 PRINT (" subdevice ID = 0x%.4x\n", word, PCI_CB_SUBSYSTEM_ID);
275 PRINT (" PC Card 16bit base address = 0x%.8x\n", dword, PCI_CB_LEGACY_MODE_BASE);
276 break;
277
278 default:
279 printf("unknown header\n");
280 break;
243 } 281 }
244 282
245 #undef PRINT 283 #undef PRINT
246 #undef PRINT2 284 #undef PRINT2
247 } 285 }
248 286
249 /* Convert the "bus.device.function" identifier into a number. 287 /* Convert the "bus.device.function" identifier into a number.
250 */ 288 */
251 static pci_dev_t get_pci_dev(char* name) 289 static pci_dev_t get_pci_dev(char* name)
252 { 290 {
253 char cnum[12]; 291 char cnum[12];
254 int len, i, iold, n; 292 int len, i, iold, n;
255 int bdfs[3] = {0,0,0}; 293 int bdfs[3] = {0,0,0};
256 294
257 len = strlen(name); 295 len = strlen(name);
258 if (len > 8) 296 if (len > 8)
259 return -1; 297 return -1;
260 for (i = 0, iold = 0, n = 0; i < len; i++) { 298 for (i = 0, iold = 0, n = 0; i < len; i++) {
261 if (name[i] == '.') { 299 if (name[i] == '.') {
262 memcpy(cnum, &name[iold], i - iold); 300 memcpy(cnum, &name[iold], i - iold);
263 cnum[i - iold] = '\0'; 301 cnum[i - iold] = '\0';
264 bdfs[n++] = simple_strtoul(cnum, NULL, 16); 302 bdfs[n++] = simple_strtoul(cnum, NULL, 16);
265 iold = i + 1; 303 iold = i + 1;
266 } 304 }
267 } 305 }
268 strcpy(cnum, &name[iold]); 306 strcpy(cnum, &name[iold]);
269 if (n == 0) 307 if (n == 0)
270 n = 1; 308 n = 1;
271 bdfs[n] = simple_strtoul(cnum, NULL, 16); 309 bdfs[n] = simple_strtoul(cnum, NULL, 16);
272 return PCI_BDF(bdfs[0], bdfs[1], bdfs[2]); 310 return PCI_BDF(bdfs[0], bdfs[1], bdfs[2]);
273 } 311 }
274 312
275 static int pci_cfg_display(pci_dev_t bdf, ulong addr, ulong size, ulong length) 313 static int pci_cfg_display(pci_dev_t bdf, ulong addr, ulong size, ulong length)
276 { 314 {
277 #define DISP_LINE_LEN 16 315 #define DISP_LINE_LEN 16
278 ulong i, nbytes, linebytes; 316 ulong i, nbytes, linebytes;
279 int rc = 0; 317 int rc = 0;
280 318
281 if (length == 0) 319 if (length == 0)
282 length = 0x40 / size; /* Standard PCI configuration space */ 320 length = 0x40 / size; /* Standard PCI configuration space */
283 321
284 /* Print the lines. 322 /* Print the lines.
285 * once, and all accesses are with the specified bus width. 323 * once, and all accesses are with the specified bus width.
286 */ 324 */
287 nbytes = length * size; 325 nbytes = length * size;
288 do { 326 do {
289 uint val4; 327 uint val4;
290 ushort val2; 328 ushort val2;
291 u_char val1; 329 u_char val1;
292 330
293 printf("%08lx:", addr); 331 printf("%08lx:", addr);
294 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes; 332 linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes;
295 for (i=0; i<linebytes; i+= size) { 333 for (i=0; i<linebytes; i+= size) {
296 if (size == 4) { 334 if (size == 4) {
297 pci_read_config_dword(bdf, addr, &val4); 335 pci_read_config_dword(bdf, addr, &val4);
298 printf(" %08x", val4); 336 printf(" %08x", val4);
299 } else if (size == 2) { 337 } else if (size == 2) {
300 pci_read_config_word(bdf, addr, &val2); 338 pci_read_config_word(bdf, addr, &val2);
301 printf(" %04x", val2); 339 printf(" %04x", val2);
302 } else { 340 } else {
303 pci_read_config_byte(bdf, addr, &val1); 341 pci_read_config_byte(bdf, addr, &val1);
304 printf(" %02x", val1); 342 printf(" %02x", val1);
305 } 343 }
306 addr += size; 344 addr += size;
307 } 345 }
308 printf("\n"); 346 printf("\n");
309 nbytes -= linebytes; 347 nbytes -= linebytes;
310 if (ctrlc()) { 348 if (ctrlc()) {
311 rc = 1; 349 rc = 1;
312 break; 350 break;
313 } 351 }
314 } while (nbytes > 0); 352 } while (nbytes > 0);
315 353
316 return (rc); 354 return (rc);
317 } 355 }
318 356
319 static int pci_cfg_write (pci_dev_t bdf, ulong addr, ulong size, ulong value) 357 static int pci_cfg_write (pci_dev_t bdf, ulong addr, ulong size, ulong value)
320 { 358 {
321 if (size == 4) { 359 if (size == 4) {
322 pci_write_config_dword(bdf, addr, value); 360 pci_write_config_dword(bdf, addr, value);
323 } 361 }
324 else if (size == 2) { 362 else if (size == 2) {
325 ushort val = value & 0xffff; 363 ushort val = value & 0xffff;
326 pci_write_config_word(bdf, addr, val); 364 pci_write_config_word(bdf, addr, val);
327 } 365 }
328 else { 366 else {
329 u_char val = value & 0xff; 367 u_char val = value & 0xff;
330 pci_write_config_byte(bdf, addr, val); 368 pci_write_config_byte(bdf, addr, val);
331 } 369 }
332 return 0; 370 return 0;
333 } 371 }
334 372
335 static int 373 static int
336 pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag) 374 pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag)
337 { 375 {
338 ulong i; 376 ulong i;
339 int nbytes; 377 int nbytes;
340 extern char console_buffer[]; 378 extern char console_buffer[];
341 uint val4; 379 uint val4;
342 ushort val2; 380 ushort val2;
343 u_char val1; 381 u_char val1;
344 382
345 /* Print the address, followed by value. Then accept input for 383 /* Print the address, followed by value. Then accept input for
346 * the next value. A non-converted value exits. 384 * the next value. A non-converted value exits.
347 */ 385 */
348 do { 386 do {
349 printf("%08lx:", addr); 387 printf("%08lx:", addr);
350 if (size == 4) { 388 if (size == 4) {
351 pci_read_config_dword(bdf, addr, &val4); 389 pci_read_config_dword(bdf, addr, &val4);
352 printf(" %08x", val4); 390 printf(" %08x", val4);
353 } 391 }
354 else if (size == 2) { 392 else if (size == 2) {
355 pci_read_config_word(bdf, addr, &val2); 393 pci_read_config_word(bdf, addr, &val2);
356 printf(" %04x", val2); 394 printf(" %04x", val2);
357 } 395 }
358 else { 396 else {
359 pci_read_config_byte(bdf, addr, &val1); 397 pci_read_config_byte(bdf, addr, &val1);
360 printf(" %02x", val1); 398 printf(" %02x", val1);
361 } 399 }
362 400
363 nbytes = readline (" ? "); 401 nbytes = readline (" ? ");
364 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) { 402 if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
365 /* <CR> pressed as only input, don't modify current 403 /* <CR> pressed as only input, don't modify current
366 * location and move to next. "-" pressed will go back. 404 * location and move to next. "-" pressed will go back.
367 */ 405 */
368 if (incrflag) 406 if (incrflag)
369 addr += nbytes ? -size : size; 407 addr += nbytes ? -size : size;
370 nbytes = 1; 408 nbytes = 1;
371 #ifdef CONFIG_BOOT_RETRY_TIME 409 #ifdef CONFIG_BOOT_RETRY_TIME
372 reset_cmd_timeout(); /* good enough to not time out */ 410 reset_cmd_timeout(); /* good enough to not time out */
373 #endif 411 #endif
374 } 412 }
375 #ifdef CONFIG_BOOT_RETRY_TIME 413 #ifdef CONFIG_BOOT_RETRY_TIME
376 else if (nbytes == -2) { 414 else if (nbytes == -2) {
377 break; /* timed out, exit the command */ 415 break; /* timed out, exit the command */
378 } 416 }
379 #endif 417 #endif
380 else { 418 else {
381 char *endp; 419 char *endp;
382 i = simple_strtoul(console_buffer, &endp, 16); 420 i = simple_strtoul(console_buffer, &endp, 16);
383 nbytes = endp - console_buffer; 421 nbytes = endp - console_buffer;
384 if (nbytes) { 422 if (nbytes) {
385 #ifdef CONFIG_BOOT_RETRY_TIME 423 #ifdef CONFIG_BOOT_RETRY_TIME
386 /* good enough to not time out 424 /* good enough to not time out
387 */ 425 */
388 reset_cmd_timeout(); 426 reset_cmd_timeout();
389 #endif 427 #endif
390 pci_cfg_write (bdf, addr, size, i); 428 pci_cfg_write (bdf, addr, size, i);
391 if (incrflag) 429 if (incrflag)
392 addr += size; 430 addr += size;
393 } 431 }
394 } 432 }
395 } while (nbytes); 433 } while (nbytes);
396 434
397 return 0; 435 return 0;
398 } 436 }
399 437
400 /* PCI Configuration Space access commands 438 /* PCI Configuration Space access commands
401 * 439 *
402 * Syntax: 440 * Syntax:
403 * pci display[.b, .w, .l] bus.device.function} [addr] [len] 441 * pci display[.b, .w, .l] bus.device.function} [addr] [len]
404 * pci next[.b, .w, .l] bus.device.function [addr] 442 * pci next[.b, .w, .l] bus.device.function [addr]
405 * pci modify[.b, .w, .l] bus.device.function [addr] 443 * pci modify[.b, .w, .l] bus.device.function [addr]
406 * pci write[.b, .w, .l] bus.device.function addr value 444 * pci write[.b, .w, .l] bus.device.function addr value
407 */ 445 */
408 int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) 446 int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
409 { 447 {
410 ulong addr = 0, value = 0, size = 0; 448 ulong addr = 0, value = 0, size = 0;
411 pci_dev_t bdf = 0; 449 pci_dev_t bdf = 0;
412 char cmd = 's'; 450 char cmd = 's';
413 451
414 if (argc > 1) 452 if (argc > 1)
415 cmd = argv[1][0]; 453 cmd = argv[1][0];
416 454
417 switch (cmd) { 455 switch (cmd) {
418 case 'd': /* display */ 456 case 'd': /* display */
419 case 'n': /* next */ 457 case 'n': /* next */
420 case 'm': /* modify */ 458 case 'm': /* modify */
421 case 'w': /* write */ 459 case 'w': /* write */
422 /* Check for a size specification. */ 460 /* Check for a size specification. */
423 size = cmd_get_data_size(argv[1], 4); 461 size = cmd_get_data_size(argv[1], 4);
424 if (argc > 3) 462 if (argc > 3)
425 addr = simple_strtoul(argv[3], NULL, 16); 463 addr = simple_strtoul(argv[3], NULL, 16);
426 if (argc > 4) 464 if (argc > 4)
427 value = simple_strtoul(argv[4], NULL, 16); 465 value = simple_strtoul(argv[4], NULL, 16);
428 case 'h': /* header */ 466 case 'h': /* header */
429 if (argc < 3) 467 if (argc < 3)
430 goto usage; 468 goto usage;
431 if ((bdf = get_pci_dev(argv[2])) == -1) 469 if ((bdf = get_pci_dev(argv[2])) == -1)
432 return 1; 470 return 1;
433 break; 471 break;
434 default: /* scan bus */ 472 default: /* scan bus */
435 value = 1; /* short listing */ 473 value = 1; /* short listing */
436 bdf = 0; /* bus number */ 474 bdf = 0; /* bus number */
437 if (argc > 1) { 475 if (argc > 1) {
438 if (argv[argc-1][0] == 'l') { 476 if (argv[argc-1][0] == 'l') {
439 value = 0; 477 value = 0;
440 argc--; 478 argc--;
441 } 479 }
442 if (argc > 1) 480 if (argc > 1)
443 bdf = simple_strtoul(argv[1], NULL, 16); 481 bdf = simple_strtoul(argv[1], NULL, 16);
444 } 482 }
445 pciinfo(bdf, value); 483 pciinfo(bdf, value);
446 return 0; 484 return 0;
447 } 485 }
448 486
449 switch (argv[1][0]) { 487 switch (argv[1][0]) {
450 case 'h': /* header */ 488 case 'h': /* header */
451 pci_header_show(bdf); 489 pci_header_show(bdf);
452 return 0; 490 return 0;
453 case 'd': /* display */ 491 case 'd': /* display */
454 return pci_cfg_display(bdf, addr, size, value); 492 return pci_cfg_display(bdf, addr, size, value);
455 case 'n': /* next */ 493 case 'n': /* next */
456 if (argc < 4) 494 if (argc < 4)
457 goto usage; 495 goto usage;
458 return pci_cfg_modify(bdf, addr, size, value, 0); 496 return pci_cfg_modify(bdf, addr, size, value, 0);
459 case 'm': /* modify */ 497 case 'm': /* modify */
460 if (argc < 4) 498 if (argc < 4)
461 goto usage; 499 goto usage;
462 return pci_cfg_modify(bdf, addr, size, value, 1); 500 return pci_cfg_modify(bdf, addr, size, value, 1);
463 case 'w': /* write */ 501 case 'w': /* write */
464 if (argc < 5) 502 if (argc < 5)
465 goto usage; 503 goto usage;
466 return pci_cfg_write(bdf, addr, size, value); 504 return pci_cfg_write(bdf, addr, size, value);
467 } 505 }
468 506
469 return 1; 507 return 1;
470 usage: 508 usage:
471 printf ("Usage:\n%s\n", cmdtp->usage); 509 printf ("Usage:\n%s\n", cmdtp->usage);
472 return 1; 510 return 1;
473 } 511 }
474 512
475 #endif /* (CONFIG_COMMANDS & CFG_CMD_PCI) */ 513 #endif /* (CONFIG_COMMANDS & CFG_CMD_PCI) */
476 514
477 #endif /* CONFIG_PCI */ 515 #endif /* CONFIG_PCI */
1 /* 1 /*
2 * (C) Copyright 2000-2002 2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> 5 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Andreas Heppel <aheppel@sysgo.de> 6 * Andreas Heppel <aheppel@sysgo.de>
7 7
8 * See file CREDITS for list of people who contributed to this 8 * See file CREDITS for list of people who contributed to this
9 * project. 9 * project.
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA 24 * MA 02111-1307 USA
25 */ 25 */
26 26
27 #include <common.h> 27 #include <common.h>
28 #include <command.h> 28 #include <command.h>
29 #include <environment.h> 29 #include <environment.h>
30 #include <cmd_nvedit.h> 30 #include <cmd_nvedit.h>
31 #include <linux/stddef.h> 31 #include <linux/stddef.h>
32 #include <malloc.h> 32 #include <malloc.h>
33 33
34 #ifdef CONFIG_SHOW_BOOT_PROGRESS 34 #ifdef CONFIG_SHOW_BOOT_PROGRESS
35 # include <status_led.h> 35 # include <status_led.h>
36 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) 36 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
37 #else 37 #else
38 # define SHOW_BOOT_PROGRESS(arg) 38 # define SHOW_BOOT_PROGRESS(arg)
39 #endif 39 #endif
40 40
41 #ifdef CONFIG_AMIGAONEG3SE 41 #ifdef CONFIG_AMIGAONEG3SE
42 extern void enable_nvram(void); 42 extern void enable_nvram(void);
43 extern void disable_nvram(void); 43 extern void disable_nvram(void);
44 #endif 44 #endif
45 45
46 #undef DEBUG_ENV 46 #undef DEBUG_ENV
47 #ifdef DEBUG_ENV 47 #ifdef DEBUG_ENV
48 #define DEBUGF(fmt,args...) printf(fmt ,##args) 48 #define DEBUGF(fmt,args...) printf(fmt ,##args)
49 #else 49 #else
50 #define DEBUGF(fmt,args...) 50 #define DEBUGF(fmt,args...)
51 #endif 51 #endif
52 52
53 extern env_t *env_ptr; 53 extern env_t *env_ptr;
54 54
55 extern void env_relocate_spec (void); 55 extern void env_relocate_spec (void);
56 extern uchar env_get_char_spec(int); 56 extern uchar env_get_char_spec(int);
57 57
58 static uchar env_get_char_init (int index); 58 static uchar env_get_char_init (int index);
59 uchar (*env_get_char)(int) = env_get_char_init; 59 uchar (*env_get_char)(int) = env_get_char_init;
60 60
61 /************************************************************************ 61 /************************************************************************
62 * Default settings to be used when no valid environment is found 62 * Default settings to be used when no valid environment is found
63 */ 63 */
64 #define XMK_STR(x) #x 64 #define XMK_STR(x) #x
65 #define MK_STR(x) XMK_STR(x) 65 #define MK_STR(x) XMK_STR(x)
66 66
67 uchar default_environment[] = { 67 uchar default_environment[] = {
68 #ifdef CONFIG_BOOTARGS 68 #ifdef CONFIG_BOOTARGS
69 "bootargs=" CONFIG_BOOTARGS "\0" 69 "bootargs=" CONFIG_BOOTARGS "\0"
70 #endif 70 #endif
71 #ifdef CONFIG_BOOTCOMMAND 71 #ifdef CONFIG_BOOTCOMMAND
72 "bootcmd=" CONFIG_BOOTCOMMAND "\0" 72 "bootcmd=" CONFIG_BOOTCOMMAND "\0"
73 #endif 73 #endif
74 #ifdef CONFIG_RAMBOOTCOMMAND 74 #ifdef CONFIG_RAMBOOTCOMMAND
75 "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" 75 "ramboot=" CONFIG_RAMBOOTCOMMAND "\0"
76 #endif 76 #endif
77 #ifdef CONFIG_NFSBOOTCOMMAND 77 #ifdef CONFIG_NFSBOOTCOMMAND
78 "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" 78 "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0"
79 #endif 79 #endif
80 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) 80 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
81 "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" 81 "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0"
82 #endif 82 #endif
83 #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) 83 #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0)
84 "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0" 84 "baudrate=" MK_STR(CONFIG_BAUDRATE) "\0"
85 #endif 85 #endif
86 #ifdef CONFIG_LOADS_ECHO 86 #ifdef CONFIG_LOADS_ECHO
87 "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0" 87 "loads_echo=" MK_STR(CONFIG_LOADS_ECHO) "\0"
88 #endif 88 #endif
89 #ifdef CONFIG_ETHADDR 89 #ifdef CONFIG_ETHADDR
90 "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0" 90 "ethaddr=" MK_STR(CONFIG_ETHADDR) "\0"
91 #endif 91 #endif
92 #ifdef CONFIG_ETH1ADDR 92 #ifdef CONFIG_ETH1ADDR
93 "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0" 93 "eth1addr=" MK_STR(CONFIG_ETH1ADDR) "\0"
94 #endif 94 #endif
95 #ifdef CONFIG_ETH2ADDR 95 #ifdef CONFIG_ETH2ADDR
96 "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0" 96 "eth2addr=" MK_STR(CONFIG_ETH2ADDR) "\0"
97 #endif 97 #endif
98 #ifdef CONFIG_IPADDR 98 #ifdef CONFIG_IPADDR
99 "ipaddr=" MK_STR(CONFIG_IPADDR) "\0" 99 "ipaddr=" MK_STR(CONFIG_IPADDR) "\0"
100 #endif 100 #endif
101 #ifdef CONFIG_SERVERIP 101 #ifdef CONFIG_SERVERIP
102 "serverip=" MK_STR(CONFIG_SERVERIP) "\0" 102 "serverip=" MK_STR(CONFIG_SERVERIP) "\0"
103 #endif 103 #endif
104 #ifdef CFG_AUTOLOAD 104 #ifdef CFG_AUTOLOAD
105 "autoload=" CFG_AUTOLOAD "\0" 105 "autoload=" CFG_AUTOLOAD "\0"
106 #endif 106 #endif
107 #ifdef CONFIG_PREBOOT 107 #ifdef CONFIG_PREBOOT
108 "preboot=" CONFIG_PREBOOT "\0" 108 "preboot=" CONFIG_PREBOOT "\0"
109 #endif 109 #endif
110 #ifdef CONFIG_ROOTPATH 110 #ifdef CONFIG_ROOTPATH
111 "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0" 111 "rootpath=" MK_STR(CONFIG_ROOTPATH) "\0"
112 #endif 112 #endif
113 #ifdef CONFIG_GATEWAYIP 113 #ifdef CONFIG_GATEWAYIP
114 "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0" 114 "gatewayip=" MK_STR(CONFIG_GATEWAYIP) "\0"
115 #endif 115 #endif
116 #ifdef CONFIG_NETMASK 116 #ifdef CONFIG_NETMASK
117 "netmask=" MK_STR(CONFIG_NETMASK) "\0" 117 "netmask=" MK_STR(CONFIG_NETMASK) "\0"
118 #endif 118 #endif
119 #ifdef CONFIG_HOSTNAME 119 #ifdef CONFIG_HOSTNAME
120 "hostname=" MK_STR(CONFIG_HOSTNAME) "\0" 120 "hostname=" MK_STR(CONFIG_HOSTNAME) "\0"
121 #endif 121 #endif
122 #ifdef CONFIG_BOOTFILE 122 #ifdef CONFIG_BOOTFILE
123 "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0" 123 "bootfile=" MK_STR(CONFIG_BOOTFILE) "\0"
124 #endif 124 #endif
125 #ifdef CONFIG_LOADADDR 125 #ifdef CONFIG_LOADADDR
126 "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0" 126 "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0"
127 #endif 127 #endif
128 #ifdef CONFIG_CLOCKS_IN_MHZ 128 #ifdef CONFIG_CLOCKS_IN_MHZ
129 "clocks_in_mhz=1\0" 129 "clocks_in_mhz=1\0"
130 #endif 130 #endif
131 #ifdef CONFIG_EXTRA_ENV_SETTINGS 131 #ifdef CONFIG_EXTRA_ENV_SETTINGS
132 CONFIG_EXTRA_ENV_SETTINGS 132 CONFIG_EXTRA_ENV_SETTINGS
133 #endif 133 #endif
134 "\0" 134 "\0"
135 }; 135 };
136 136
137 137
138 void env_crc_update (void) 138 void env_crc_update (void)
139 { 139 {
140 env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE); 140 env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
141 } 141 }
142 142
143 static uchar env_get_char_init (int index) 143 static uchar env_get_char_init (int index)
144 { 144 {
145 DECLARE_GLOBAL_DATA_PTR; 145 DECLARE_GLOBAL_DATA_PTR;
146 uchar c; 146 uchar c;
147 147
148 /* if crc was bad, use the default environment */ 148 /* if crc was bad, use the default environment */
149 if (gd->env_valid) 149 if (gd->env_valid)
150 { 150 {
151 c = env_get_char_spec(index); 151 c = env_get_char_spec(index);
152 } else { 152 } else {
153 c = default_environment[index]; 153 c = default_environment[index];
154 } 154 }
155 155
156 return (c); 156 return (c);
157 } 157 }
158 158
159 #ifdef CONFIG_AMIGAONEG3SE
159 uchar env_get_char_memory (int index) 160 uchar env_get_char_memory (int index)
160 { 161 {
161 DECLARE_GLOBAL_DATA_PTR; 162 DECLARE_GLOBAL_DATA_PTR;
163 uchar retval;
164 enable_nvram();
165 if (gd->env_valid) {
166 retval = ( *((uchar *)(gd->env_addr + index)) );
167 } else {
168 retval = ( default_environment[index] );
169 }
170 disable_nvram();
171 return retval;
172 }
173 #else
174 uchar env_get_char_memory (int index)
175 {
176 DECLARE_GLOBAL_DATA_PTR;
162 177
163 if (gd->env_valid) { 178 if (gd->env_valid) {
164 return ( *((uchar *)(gd->env_addr + index)) ); 179 return ( *((uchar *)(gd->env_addr + index)) );
165 } else { 180 } else {
166 return ( default_environment[index] ); 181 return ( default_environment[index] );
167 } 182 }
168 } 183 }
184 #endif
169 185
170 uchar *env_get_addr (int index) 186 uchar *env_get_addr (int index)
171 { 187 {
172 DECLARE_GLOBAL_DATA_PTR; 188 DECLARE_GLOBAL_DATA_PTR;
173 189
174 if (gd->env_valid) { 190 if (gd->env_valid) {
175 return ( ((uchar *)(gd->env_addr + index)) ); 191 return ( ((uchar *)(gd->env_addr + index)) );
176 } else { 192 } else {
177 return (&default_environment[index]); 193 return (&default_environment[index]);
178 } 194 }
179 } 195 }
180 196
181 void env_relocate (void) 197 void env_relocate (void)
182 { 198 {
183 DECLARE_GLOBAL_DATA_PTR; 199 DECLARE_GLOBAL_DATA_PTR;
184 200
185 DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__, 201 DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
186 gd->reloc_off); 202 gd->reloc_off);
187 203
188 #ifdef CONFIG_AMIGAONEG3SE 204 #ifdef CONFIG_AMIGAONEG3SE
189 enable_nvram(); 205 enable_nvram();
190 #endif 206 #endif
191 207
192 #ifdef ENV_IS_EMBEDDED 208 #ifdef ENV_IS_EMBEDDED
193 /* 209 /*
194 * The environment buffer is embedded with the text segment, 210 * The environment buffer is embedded with the text segment,
195 * just relocate the environment pointer 211 * just relocate the environment pointer
196 */ 212 */
197 env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off); 213 env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
198 DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); 214 DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
199 #else 215 #else
200 /* 216 /*
201 * We must allocate a buffer for the environment 217 * We must allocate a buffer for the environment
202 */ 218 */
203 env_ptr = (env_t *)malloc (CFG_ENV_SIZE); 219 env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
204 DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); 220 DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
205 #endif 221 #endif
206 222
207 /* 223 /*
208 * After relocation to RAM, we can always use the "memory" functions 224 * After relocation to RAM, we can always use the "memory" functions
209 */ 225 */
210 env_get_char = env_get_char_memory; 226 env_get_char = env_get_char_memory;
211 227
212 if (gd->env_valid == 0) { 228 if (gd->env_valid == 0) {
213 #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */ 229 #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */
214 puts ("Using default environment\n\n"); 230 puts ("Using default environment\n\n");
215 #else 231 #else
216 puts ("*** Warning - bad CRC, using default environment\n\n"); 232 puts ("*** Warning - bad CRC, using default environment\n\n");
217 SHOW_BOOT_PROGRESS (-1); 233 SHOW_BOOT_PROGRESS (-1);
218 #endif 234 #endif
219 235
220 if (sizeof(default_environment) > ENV_SIZE) 236 if (sizeof(default_environment) > ENV_SIZE)
221 { 237 {
222 puts ("*** Error - default environment is too large\n\n"); 238 puts ("*** Error - default environment is too large\n\n");
223 return; 239 return;
224 } 240 }
225 241
226 memset (env_ptr, 0, sizeof(env_t)); 242 memset (env_ptr, 0, sizeof(env_t));
227 memcpy (env_ptr->data, 243 memcpy (env_ptr->data,
228 default_environment, 244 default_environment,
229 sizeof(default_environment)); 245 sizeof(default_environment));
230 #ifdef CFG_REDUNDAND_ENVIRONMENT 246 #ifdef CFG_REDUNDAND_ENVIRONMENT
231 env_ptr->flags = 0xFF; 247 env_ptr->flags = 0xFF;
232 #endif 248 #endif
233 env_crc_update (); 249 env_crc_update ();
234 gd->env_valid = 1; 250 gd->env_valid = 1;
235 } 251 }
236 else { 252 else {
237 env_relocate_spec (); 253 env_relocate_spec ();
238 } 254 }
239 gd->env_addr = (ulong)&(env_ptr->data); 255 gd->env_addr = (ulong)&(env_ptr->data);
240 256
241 #ifdef CONFIG_AMIGAONEG3SE 257 #ifdef CONFIG_AMIGAONEG3SE
242 disable_nvram(); 258 disable_nvram();
243 #endif 259 #endif
244 } 260 }
245 261
1 /* 1 /*
2 * (C) Copyright 2000-2002 2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> 5 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
6 * Andreas Heppel <aheppel@sysgo.de> 6 * Andreas Heppel <aheppel@sysgo.de>
7 7
8 * See file CREDITS for list of people who contributed to this 8 * See file CREDITS for list of people who contributed to this
9 * project. 9 * project.
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA 24 * MA 02111-1307 USA
25 */ 25 */
26 26
27 /* 27 /*
28 * 09-18-2001 Andreas Heppel, Sysgo RTS GmbH <aheppel@sysgo.de> 28 * 09-18-2001 Andreas Heppel, Sysgo RTS GmbH <aheppel@sysgo.de>
29 * 29 *
30 * It might not be possible in all cases to use 'memcpy()' to copy 30 * It might not be possible in all cases to use 'memcpy()' to copy
31 * the environment to NVRAM, as the NVRAM might not be mapped into 31 * the environment to NVRAM, as the NVRAM might not be mapped into
32 * the memory space. (I.e. this is the case for the BAB750). In those 32 * the memory space. (I.e. this is the case for the BAB750). In those
33 * cases it might be possible to access the NVRAM using a different 33 * cases it might be possible to access the NVRAM using a different
34 * method. For example, the RTC on the BAB750 is accessible in IO 34 * method. For example, the RTC on the BAB750 is accessible in IO
35 * space using its address and data registers. To enable usage of 35 * space using its address and data registers. To enable usage of
36 * NVRAM in those cases I invented the functions 'nvram_read()' and 36 * NVRAM in those cases I invented the functions 'nvram_read()' and
37 * 'nvram_write()', which will be activated upon the configuration 37 * 'nvram_write()', which will be activated upon the configuration
38 * #define CFG_NVRAM_ACCESS_ROUTINE. Note, that those functions are 38 * #define CFG_NVRAM_ACCESS_ROUTINE. Note, that those functions are
39 * strongly dependent on the used HW, and must be redefined for each 39 * strongly dependent on the used HW, and must be redefined for each
40 * board that wants to use them. 40 * board that wants to use them.
41 */ 41 */
42 42
43 #include <common.h> 43 #include <common.h>
44 44
45 #ifdef CFG_ENV_IS_IN_NVRAM /* Environment is in NVRAM */ 45 #ifdef CFG_ENV_IS_IN_NVRAM /* Environment is in NVRAM */
46 46
47 #include <command.h> 47 #include <command.h>
48 #include <environment.h> 48 #include <environment.h>
49 #include <cmd_nvedit.h> 49 #include <cmd_nvedit.h>
50 #include <linux/stddef.h> 50 #include <linux/stddef.h>
51 #include <malloc.h> 51 #include <malloc.h>
52 52
53 #ifdef CFG_NVRAM_ACCESS_ROUTINE 53 #ifdef CFG_NVRAM_ACCESS_ROUTINE
54 extern void *nvram_read(void *dest, const long src, size_t count); 54 extern void *nvram_read(void *dest, const long src, size_t count);
55 extern void nvram_write(long dest, const void *src, size_t count); 55 extern void nvram_write(long dest, const void *src, size_t count);
56 env_t *env_ptr = NULL; 56 env_t *env_ptr = NULL;
57 #else 57 #else
58 env_t *env_ptr = (env_t *)CFG_ENV_ADDR; 58 env_t *env_ptr = (env_t *)CFG_ENV_ADDR;
59 #endif 59 #endif
60 60
61 char * env_name_spec = "NVRAM"; 61 char * env_name_spec = "NVRAM";
62 62
63 extern uchar default_environment[]; 63 extern uchar default_environment[];
64 extern int default_environment_size; 64 extern int default_environment_size;
65 65
66 extern uchar (*env_get_char)(int); 66 extern uchar (*env_get_char)(int);
67 extern uchar env_get_char_memory (int index); 67 extern uchar env_get_char_memory (int index);
68 68
69 #ifdef CONFIG_AMIGAONEG3SE
70 uchar env_get_char_spec (int index)
71 {
72 #ifdef CFG_NVRAM_ACCESS_ROUTINE
73 uchar c;
69 74
75 nvram_read(&c, CFG_ENV_ADDR+index, 1);
76
77 return c;
78 #else
79 DECLARE_GLOBAL_DATA_PTR;
80 uchar retval;
81 enable_nvram();
82 retval = *((uchar *)(gd->env_addr + index));
83 disable_nvram();
84 return retval;
85 #endif
86 }
87 #else
70 uchar env_get_char_spec (int index) 88 uchar env_get_char_spec (int index)
71 { 89 {
72 #ifdef CFG_NVRAM_ACCESS_ROUTINE 90 #ifdef CFG_NVRAM_ACCESS_ROUTINE
73 uchar c; 91 uchar c;
74 92
75 nvram_read(&c, CFG_ENV_ADDR+index, 1); 93 nvram_read(&c, CFG_ENV_ADDR+index, 1);
76 94
77 return c; 95 return c;
78 #else 96 #else
79 DECLARE_GLOBAL_DATA_PTR; 97 DECLARE_GLOBAL_DATA_PTR;
80 98
81 return *((uchar *)(gd->env_addr + index)); 99 return *((uchar *)(gd->env_addr + index));
82 #endif 100 #endif
83 } 101 }
102 #endif
84 103
85 void env_relocate_spec (void) 104 void env_relocate_spec (void)
86 { 105 {
87 #if defined(CFG_NVRAM_ACCESS_ROUTINE) 106 #if defined(CFG_NVRAM_ACCESS_ROUTINE)
88 nvram_read(env_ptr, CFG_ENV_ADDR, CFG_ENV_SIZE); 107 nvram_read(env_ptr, CFG_ENV_ADDR, CFG_ENV_SIZE);
89 #else 108 #else
90 memcpy (env_ptr, (void*)CFG_ENV_ADDR, CFG_ENV_SIZE); 109 memcpy (env_ptr, (void*)CFG_ENV_ADDR, CFG_ENV_SIZE);
91 #endif 110 #endif
92 } 111 }
93 112
94 int saveenv (void) 113 int saveenv (void)
95 { 114 {
96 int rcode = 0; 115 int rcode = 0;
97 116 #ifdef CONFIG_AMIGAONEG3SE
117 enable_nvram();
118 #endif
98 #ifdef CFG_NVRAM_ACCESS_ROUTINE 119 #ifdef CFG_NVRAM_ACCESS_ROUTINE
99 nvram_write(CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE); 120 nvram_write(CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE);
100 #else 121 #else
101 if (memcpy ((char *)CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE) == NULL) 122 if (memcpy ((char *)CFG_ENV_ADDR, env_ptr, CFG_ENV_SIZE) == NULL)
102 rcode = 1 ; 123 rcode = 1 ;
103 #endif 124 #endif
125 #ifdef CONFIG_AMIGAONEG3SE
126 udelay(10000);
127 disable_nvram();
128 #endif
104 return rcode; 129 return rcode;
105 } 130 }
106 131
107 132
108 /************************************************************************ 133 /************************************************************************
109 * Initialize Environment use 134 * Initialize Environment use
110 * 135 *
111 * We are still running from ROM, so data use is limited 136 * We are still running from ROM, so data use is limited
112 */ 137 */
113 int env_init (void) 138 int env_init (void)
114 { 139 {
115 DECLARE_GLOBAL_DATA_PTR; 140 DECLARE_GLOBAL_DATA_PTR;
116 141 #ifdef CONFIG_AMIGAONEG3SE
142 enable_nvram();
143 #endif
117 #if defined(CFG_NVRAM_ACCESS_ROUTINE) 144 #if defined(CFG_NVRAM_ACCESS_ROUTINE)
118 ulong crc; 145 ulong crc;
119 uchar data[ENV_SIZE]; 146 uchar data[ENV_SIZE];
120 nvram_read (&crc, CFG_ENV_ADDR, sizeof(ulong)); 147 nvram_read (&crc, CFG_ENV_ADDR, sizeof(ulong));
121 nvram_read (data, CFG_ENV_ADDR+sizeof(ulong), ENV_SIZE); 148 nvram_read (data, CFG_ENV_ADDR+sizeof(ulong), ENV_SIZE);
122 149
123 if (crc32(0, data, ENV_SIZE) == crc) { 150 if (crc32(0, data, ENV_SIZE) == crc) {
124 gd->env_addr = (ulong)CFG_ENV_ADDR + sizeof(long); 151 gd->env_addr = (ulong)CFG_ENV_ADDR + sizeof(long);
125 #else 152 #else
126 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) { 153 if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
127 gd->env_addr = (ulong)&(env_ptr->data); 154 gd->env_addr = (ulong)&(env_ptr->data);
128 #endif 155 #endif
129 gd->env_valid = 1; 156 gd->env_valid = 1;
130 } else { 157 } else {
131 gd->env_addr = (ulong)&default_environment[0]; 158 gd->env_addr = (ulong)&default_environment[0];
132 gd->env_valid = 0; 159 gd->env_valid = 0;
133 } 160 }
134 161 #ifdef CONFIG_AMIGAONEG3SE
162 disable_nvram();
163 #endif
135 return (0); 164 return (0);
136 } 165 }
137 166
138 #endif /* CFG_ENV_IS_IN_NVRAM */ 167 #endif /* CFG_ENV_IS_IN_NVRAM */
139 168
cpu/74xx_7xx/start.S
1 /* 1 /*
2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> 2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> 3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de> 4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
5 * Copyright (C) 2001 Josh Huber <huber@mclx.com> 5 * Copyright (C) 2001 Josh Huber <huber@mclx.com>
6 * 6 *
7 * See file CREDITS for list of people who contributed to this 7 * See file CREDITS for list of people who contributed to this
8 * project. 8 * project.
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as 11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of 12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version. 13 * the License, or (at your option) any later version.
14 * 14 *
15 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA 23 * MA 02111-1307 USA
24 */ 24 */
25 25
26 /* U-Boot - Startup Code for PowerPC based Embedded Boards 26 /* U-Boot - Startup Code for PowerPC based Embedded Boards
27 * 27 *
28 * 28 *
29 * The processor starts at 0xfff00100 and the code is executed 29 * The processor starts at 0xfff00100 and the code is executed
30 * from flash. The code is organized to be at an other address 30 * from flash. The code is organized to be at an other address
31 * in memory, but as long we don't jump around before relocating. 31 * in memory, but as long we don't jump around before relocating.
32 * board_init lies at a quite high address and when the cpu has 32 * board_init lies at a quite high address and when the cpu has
33 * jumped there, everything is ok. 33 * jumped there, everything is ok.
34 */ 34 */
35 #include <config.h> 35 #include <config.h>
36 #include <74xx_7xx.h> 36 #include <74xx_7xx.h>
37 #include <version.h> 37 #include <version.h>
38 38
39 #include <ppc_asm.tmpl> 39 #include <ppc_asm.tmpl>
40 #include <ppc_defs.h> 40 #include <ppc_defs.h>
41 41
42 #include <asm/cache.h> 42 #include <asm/cache.h>
43 #include <asm/mmu.h> 43 #include <asm/mmu.h>
44 44
45 #include <galileo/gt64260R.h> 45 #include <galileo/gt64260R.h>
46 46
47 #ifndef CONFIG_IDENT_STRING 47 #ifndef CONFIG_IDENT_STRING
48 #define CONFIG_IDENT_STRING "" 48 #define CONFIG_IDENT_STRING ""
49 #endif 49 #endif
50 50
51 /* We don't want the MMU yet. 51 /* We don't want the MMU yet.
52 */ 52 */
53 #undef MSR_KERNEL 53 #undef MSR_KERNEL
54 /* Machine Check and Recoverable Interr. */ 54 /* Machine Check and Recoverable Interr. */
55 #define MSR_KERNEL ( MSR_ME | MSR_RI ) 55 #define MSR_KERNEL ( MSR_ME | MSR_RI )
56 56
57 /* 57 /*
58 * Set up GOT: Global Offset Table 58 * Set up GOT: Global Offset Table
59 * 59 *
60 * Use r14 to access the GOT 60 * Use r14 to access the GOT
61 */ 61 */
62 START_GOT 62 START_GOT
63 GOT_ENTRY(_GOT2_TABLE_) 63 GOT_ENTRY(_GOT2_TABLE_)
64 GOT_ENTRY(_FIXUP_TABLE_) 64 GOT_ENTRY(_FIXUP_TABLE_)
65 65
66 GOT_ENTRY(_start) 66 GOT_ENTRY(_start)
67 GOT_ENTRY(_start_of_vectors) 67 GOT_ENTRY(_start_of_vectors)
68 GOT_ENTRY(_end_of_vectors) 68 GOT_ENTRY(_end_of_vectors)
69 GOT_ENTRY(transfer_to_handler) 69 GOT_ENTRY(transfer_to_handler)
70 70
71 GOT_ENTRY(_end) 71 GOT_ENTRY(_end)
72 GOT_ENTRY(.bss) 72 GOT_ENTRY(.bss)
73 END_GOT 73 END_GOT
74 74
75 /* 75 /*
76 * r3 - 1st arg to board_init(): IMMP pointer 76 * r3 - 1st arg to board_init(): IMMP pointer
77 * r4 - 2nd arg to board_init(): boot flag 77 * r4 - 2nd arg to board_init(): boot flag
78 */ 78 */
79 .text 79 .text
80 .long 0x27051956 /* U-Boot Magic Number */ 80 .long 0x27051956 /* U-Boot Magic Number */
81 .globl version_string 81 .globl version_string
82 version_string: 82 version_string:
83 .ascii U_BOOT_VERSION 83 .ascii U_BOOT_VERSION
84 .ascii " (", __DATE__, " - ", __TIME__, ")" 84 .ascii " (", __DATE__, " - ", __TIME__, ")"
85 .ascii CONFIG_IDENT_STRING, "\0" 85 .ascii CONFIG_IDENT_STRING, "\0"
86 86
87 . = EXC_OFF_SYS_RESET 87 . = EXC_OFF_SYS_RESET
88 .globl _start 88 .globl _start
89 _start: 89 _start:
90 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */ 90 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */
91 b boot_cold 91 b boot_cold
92 sync 92 sync
93 93
94 . = EXC_OFF_SYS_RESET + 0x10 94 . = EXC_OFF_SYS_RESET + 0x10
95 95
96 .globl _start_warm 96 .globl _start_warm
97 _start_warm: 97 _start_warm:
98 li r21, BOOTFLAG_WARM /* Software reboot */ 98 li r21, BOOTFLAG_WARM /* Software reboot */
99 b boot_warm 99 b boot_warm
100 sync 100 sync
101 101
102 /* the boot code is located below the exception table */ 102 /* the boot code is located below the exception table */
103 103
104 .globl _start_of_vectors 104 .globl _start_of_vectors
105 _start_of_vectors: 105 _start_of_vectors:
106 106
107 /* Machine check */ 107 /* Machine check */
108 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException) 108 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
109 109
110 /* Data Storage exception. "Never" generated on the 860. */ 110 /* Data Storage exception. "Never" generated on the 860. */
111 STD_EXCEPTION(0x300, DataStorage, UnknownException) 111 STD_EXCEPTION(0x300, DataStorage, UnknownException)
112 112
113 /* Instruction Storage exception. "Never" generated on the 860. */ 113 /* Instruction Storage exception. "Never" generated on the 860. */
114 STD_EXCEPTION(0x400, InstStorage, UnknownException) 114 STD_EXCEPTION(0x400, InstStorage, UnknownException)
115 115
116 /* External Interrupt exception. */ 116 /* External Interrupt exception. */
117 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt) 117 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
118 118
119 /* Alignment exception. */ 119 /* Alignment exception. */
120 . = 0x600 120 . = 0x600
121 Alignment: 121 Alignment:
122 EXCEPTION_PROLOG 122 EXCEPTION_PROLOG
123 mfspr r4,DAR 123 mfspr r4,DAR
124 stw r4,_DAR(r21) 124 stw r4,_DAR(r21)
125 mfspr r5,DSISR 125 mfspr r5,DSISR
126 stw r5,_DSISR(r21) 126 stw r5,_DSISR(r21)
127 addi r3,r1,STACK_FRAME_OVERHEAD 127 addi r3,r1,STACK_FRAME_OVERHEAD
128 li r20,MSR_KERNEL 128 li r20,MSR_KERNEL
129 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 129 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
130 lwz r6,GOT(transfer_to_handler) 130 lwz r6,GOT(transfer_to_handler)
131 mtlr r6 131 mtlr r6
132 blrl 132 blrl
133 .L_Alignment: 133 .L_Alignment:
134 .long AlignmentException - _start + EXC_OFF_SYS_RESET 134 .long AlignmentException - _start + EXC_OFF_SYS_RESET
135 .long int_return - _start + EXC_OFF_SYS_RESET 135 .long int_return - _start + EXC_OFF_SYS_RESET
136 136
137 /* Program check exception */ 137 /* Program check exception */
138 . = 0x700 138 . = 0x700
139 ProgramCheck: 139 ProgramCheck:
140 EXCEPTION_PROLOG 140 EXCEPTION_PROLOG
141 addi r3,r1,STACK_FRAME_OVERHEAD 141 addi r3,r1,STACK_FRAME_OVERHEAD
142 li r20,MSR_KERNEL 142 li r20,MSR_KERNEL
143 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 143 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
144 lwz r6,GOT(transfer_to_handler) 144 lwz r6,GOT(transfer_to_handler)
145 mtlr r6 145 mtlr r6
146 blrl 146 blrl
147 .L_ProgramCheck: 147 .L_ProgramCheck:
148 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET 148 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
149 .long int_return - _start + EXC_OFF_SYS_RESET 149 .long int_return - _start + EXC_OFF_SYS_RESET
150 150
151 /* No FPU on MPC8xx. This exception is not supposed to happen. 151 /* No FPU on MPC8xx. This exception is not supposed to happen.
152 */ 152 */
153 STD_EXCEPTION(0x800, FPUnavailable, UnknownException) 153 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
154 154
155 /* I guess we could implement decrementer, and may have 155 /* I guess we could implement decrementer, and may have
156 * to someday for timekeeping. 156 * to someday for timekeeping.
157 */ 157 */
158 STD_EXCEPTION(0x900, Decrementer, timer_interrupt) 158 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
159 STD_EXCEPTION(0xa00, Trap_0a, UnknownException) 159 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
160 STD_EXCEPTION(0xb00, Trap_0b, UnknownException) 160 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
161 161
162 . = 0xc00 162 . = 0xc00
163 /* 163 /*
164 * r0 - SYSCALL number 164 * r0 - SYSCALL number
165 * r3-... arguments 165 * r3-... arguments
166 */ 166 */
167 SystemCall: 167 SystemCall:
168 addis r11,r0,0 /* get functions table addr */ 168 addis r11,r0,0 /* get functions table addr */
169 ori r11,r11,0 /* Note: this code is patched in trap_init */ 169 ori r11,r11,0 /* Note: this code is patched in trap_init */
170 addis r12,r0,0 /* get number of functions */ 170 addis r12,r0,0 /* get number of functions */
171 ori r12,r12,0 171 ori r12,r12,0
172 172
173 cmplw 0, r0, r12 173 cmplw 0, r0, r12
174 bge 1f 174 bge 1f
175 175
176 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ 176 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
177 add r11,r11,r0 177 add r11,r11,r0
178 lwz r11,0(r11) 178 lwz r11,0(r11)
179 179
180 li r12,0xd00-4*3 /* save LR & SRRx */ 180 li r20,0xd00-4 /* Get stack pointer */
181 lwz r12,0(r20)
182 subi r12,r12,12 /* Adjust stack pointer */
183 li r0,0xc00+_end_back-SystemCall
184 cmplw 0, r0, r12 /* Check stack overflow */
185 bgt 1f
186 stw r12,0(r20)
187
181 mflr r0 188 mflr r0
182 stw r0,0(r12) 189 stw r0,0(r12)
183 mfspr r0,SRR0 190 mfspr r0,SRR0
184 stw r0,4(r12) 191 stw r0,4(r12)
185 mfspr r0,SRR1 192 mfspr r0,SRR1
186 stw r0,8(r12) 193 stw r0,8(r12)
187 194
188 li r12,0xc00+_back-SystemCall 195 li r12,0xc00+_back-SystemCall
189 mtlr r12 196 mtlr r12
190 mtspr SRR0,r11 197 mtspr SRR0,r11
191 198
192 1: SYNC 199 1: SYNC
193 rfi 200 rfi
194 201
195 _back: 202 _back:
196 203
197 mfmsr r11 /* Disable interrupts */ 204 mfmsr r11 /* Disable interrupts */
198 li r12,0 205 li r12,0
199 ori r12,r12,MSR_EE 206 ori r12,r12,MSR_EE
200 andc r11,r11,r12 207 andc r11,r11,r12
201 SYNC /* Some chip revs need this... */ 208 SYNC /* Some chip revs need this... */
202 mtmsr r11 209 mtmsr r11
203 SYNC 210 SYNC
204 211
205 li r12,0xd00-4*3 /* restore regs */ 212 li r12,0xd00-4 /* restore regs */
213 lwz r12,0(r12)
214
206 lwz r11,0(r12) 215 lwz r11,0(r12)
207 mtlr r11 216 mtlr r11
208 lwz r11,4(r12) 217 lwz r11,4(r12)
209 mtspr SRR0,r11 218 mtspr SRR0,r11
210 lwz r11,8(r12) 219 lwz r11,8(r12)
211 mtspr SRR1,r11 220 mtspr SRR1,r11
212 221
222 addi r12,r12,12 /* Adjust stack pointer */
223 li r20,0xd00-4
224 stw r12,0(r20)
225
213 SYNC 226 SYNC
214 rfi 227 rfi
228 _end_back:
215 229
216 STD_EXCEPTION(0xd00, SingleStep, UnknownException) 230 STD_EXCEPTION(0xd00, SingleStep, UnknownException)
217 231
218 STD_EXCEPTION(0xe00, Trap_0e, UnknownException) 232 STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
219 STD_EXCEPTION(0xf00, Trap_0f, UnknownException) 233 STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
220 234
221 /* 235 /*
222 * On the MPC8xx, this is a software emulation interrupt. It 236 * On the MPC8xx, this is a software emulation interrupt. It
223 * occurs for all unimplemented and illegal instructions. 237 * occurs for all unimplemented and illegal instructions.
224 */ 238 */
225 STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException) 239 STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException)
226 240
227 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException) 241 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
228 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException) 242 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
229 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException) 243 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
230 STD_EXCEPTION(0x1400, DataTLBError, UnknownException) 244 STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
231 245
232 STD_EXCEPTION(0x1500, Reserved5, UnknownException) 246 STD_EXCEPTION(0x1500, Reserved5, UnknownException)
233 STD_EXCEPTION(0x1600, Reserved6, UnknownException) 247 STD_EXCEPTION(0x1600, Reserved6, UnknownException)
234 STD_EXCEPTION(0x1700, Reserved7, UnknownException) 248 STD_EXCEPTION(0x1700, Reserved7, UnknownException)
235 STD_EXCEPTION(0x1800, Reserved8, UnknownException) 249 STD_EXCEPTION(0x1800, Reserved8, UnknownException)
236 STD_EXCEPTION(0x1900, Reserved9, UnknownException) 250 STD_EXCEPTION(0x1900, Reserved9, UnknownException)
237 STD_EXCEPTION(0x1a00, ReservedA, UnknownException) 251 STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
238 STD_EXCEPTION(0x1b00, ReservedB, UnknownException) 252 STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
239 253
240 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException) 254 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
241 STD_EXCEPTION(0x1d00, InstructionBreakpoint, UnknownException) 255 STD_EXCEPTION(0x1d00, InstructionBreakpoint, UnknownException)
242 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException) 256 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
243 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException) 257 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
244 258
245 .globl _end_of_vectors 259 .globl _end_of_vectors
246 _end_of_vectors: 260 _end_of_vectors:
247 261
248 . = 0x2000 262 . = 0x2000
249 263
250 boot_cold: 264 boot_cold:
251 boot_warm: 265 boot_warm:
252 /* disable everything */ 266 /* disable everything */
253 li r0, 0 267 li r0, 0
254 mtspr HID0, r0 268 mtspr HID0, r0
255 sync 269 sync
256 mtmsr 0 270 mtmsr 0
257 bl invalidate_bats 271 bl invalidate_bats
258 sync 272 sync
259 273
260 #ifdef CFG_L2 274 #ifdef CFG_L2
261 /* init the L2 cache */ 275 /* init the L2 cache */
262 addis r3, r0, L2_INIT@h 276 addis r3, r0, L2_INIT@h
263 ori r3, r3, L2_INIT@l 277 ori r3, r3, L2_INIT@l
264 sync 278 sync
265 mtspr l2cr, r3 279 mtspr l2cr, r3
266 #endif 280 #endif
267 #if defined(CONFIG_ALTIVEC) && defined(CONFIG_74xx) 281 #if defined(CONFIG_ALTIVEC) && defined(CONFIG_74xx)
268 .long 0x7e00066c 282 .long 0x7e00066c
269 /* 283 /*
270 * dssall instruction, gas doesn't have it yet 284 * dssall instruction, gas doesn't have it yet
271 * ...for altivec, data stream stop all this probably 285 * ...for altivec, data stream stop all this probably
272 * isn't needed unless we warm (software) reboot U-Boot 286 * isn't needed unless we warm (software) reboot U-Boot
273 */ 287 */
274 #endif 288 #endif
275 289
276 #ifdef CFG_L2 290 #ifdef CFG_L2
277 /* invalidate the L2 cache */ 291 /* invalidate the L2 cache */
278 bl l2cache_invalidate 292 bl l2cache_invalidate
279 sync 293 sync
280 #endif 294 #endif
281 #ifdef CFG_BOARD_ASM_INIT 295 #ifdef CFG_BOARD_ASM_INIT
282 /* do early init */ 296 /* do early init */
283 bl board_asm_init 297 bl board_asm_init
284 #endif 298 #endif
285 299
286 /* 300 /*
287 * Calculate absolute address in FLASH and jump there 301 * Calculate absolute address in FLASH and jump there
288 *------------------------------------------------------*/ 302 *------------------------------------------------------*/
289 lis r3, CFG_MONITOR_BASE@h 303 lis r3, CFG_MONITOR_BASE@h
290 ori r3, r3, CFG_MONITOR_BASE@l 304 ori r3, r3, CFG_MONITOR_BASE@l
291 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET 305 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
292 mtlr r3 306 mtlr r3
293 blr 307 blr
294 308
295 in_flash: 309 in_flash:
296 /* let the C-code set up the rest */ 310 /* let the C-code set up the rest */
297 /* */ 311 /* */
298 /* Be careful to keep code relocatable ! */ 312 /* Be careful to keep code relocatable ! */
299 /*------------------------------------------------------*/ 313 /*------------------------------------------------------*/
300 314
301 /* perform low-level init */ 315 /* perform low-level init */
302 /* sdram init, galileo init, etc */ 316 /* sdram init, galileo init, etc */
303 /* r3: NHR bit from HID0 */ 317 /* r3: NHR bit from HID0 */
304 318
305 /* setup the bats */ 319 /* setup the bats */
306 bl setup_bats 320 bl setup_bats
307 sync 321 sync
308 322
309 /* 323 /*
310 * Cache must be enabled here for stack-in-cache trick. 324 * Cache must be enabled here for stack-in-cache trick.
311 * This means we need to enable the BATS. 325 * This means we need to enable the BATS.
312 * This means: 326 * This means:
313 * 1) for the EVB, original gt regs need to be mapped 327 * 1) for the EVB, original gt regs need to be mapped
314 * 2) need to have an IBAT for the 0xf region, 328 * 2) need to have an IBAT for the 0xf region,
315 * we are running there! 329 * we are running there!
316 * Cache should be turned on after BATs, since by default 330 * Cache should be turned on after BATs, since by default
317 * everything is write-through. 331 * everything is write-through.
318 * The init-mem BAT can be reused after reloc. The old 332 * The init-mem BAT can be reused after reloc. The old
319 * gt-regs BAT can be reused after board_init_f calls 333 * gt-regs BAT can be reused after board_init_f calls
320 * board_pre_init (EVB only). 334 * board_pre_init (EVB only).
321 */ 335 */
322 #if !defined(CONFIG_BAB7xx) && !defined(CONFIG_ELPPC) 336 #if !defined(CONFIG_BAB7xx) && !defined(CONFIG_ELPPC)
323 /* enable address translation */ 337 /* enable address translation */
324 bl enable_addr_trans 338 bl enable_addr_trans
325 sync 339 sync
326 340
327 /* enable and invalidate the data cache */ 341 /* enable and invalidate the data cache */
328 bl l1dcache_enable 342 bl l1dcache_enable
329 sync 343 sync
330 #endif 344 #endif
331 #ifdef CFG_INIT_RAM_LOCK 345 #ifdef CFG_INIT_RAM_LOCK
332 bl lock_ram_in_cache 346 bl lock_ram_in_cache
333 sync 347 sync
334 #endif 348 #endif
335 349
336 /* set up the stack pointer in our newly created 350 /* set up the stack pointer in our newly created
337 * cache-ram (r1) */ 351 * cache-ram (r1) */
338 lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h 352 lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h
339 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l 353 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l
340 354
341 li r0, 0 /* Make room for stack frame header and */ 355 li r0, 0 /* Make room for stack frame header and */
342 stwu r0, -4(r1) /* clear final stack frame so that */ 356 stwu r0, -4(r1) /* clear final stack frame so that */
343 stwu r0, -4(r1) /* stack backtraces terminate cleanly */ 357 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
344 358
345 GET_GOT /* initialize GOT access */ 359 GET_GOT /* initialize GOT access */
346 360
347 /* run low-level CPU init code (from Flash) */ 361 /* run low-level CPU init code (from Flash) */
348 bl cpu_init_f 362 bl cpu_init_f
349 sync 363 sync
350 364
351 mr r3, r21 365 mr r3, r21
352 366
353 /* r3: BOOTFLAG */ 367 /* r3: BOOTFLAG */
354 /* run 1st part of board init code (from Flash) */ 368 /* run 1st part of board init code (from Flash) */
355 bl board_init_f 369 bl board_init_f
356 sync 370 sync
357 371
358 /* NOTREACHED */ 372 /* NOTREACHED */
359 373
360 .globl invalidate_bats 374 .globl invalidate_bats
361 invalidate_bats: 375 invalidate_bats:
362 /* invalidate BATs */ 376 /* invalidate BATs */
363 mtspr IBAT0U, r0 377 mtspr IBAT0U, r0
364 mtspr IBAT1U, r0 378 mtspr IBAT1U, r0
365 mtspr IBAT2U, r0 379 mtspr IBAT2U, r0
366 mtspr IBAT3U, r0 380 mtspr IBAT3U, r0
367 isync 381 isync
368 mtspr DBAT0U, r0 382 mtspr DBAT0U, r0
369 mtspr DBAT1U, r0 383 mtspr DBAT1U, r0
370 mtspr DBAT2U, r0 384 mtspr DBAT2U, r0
371 mtspr DBAT3U, r0 385 mtspr DBAT3U, r0
372 isync 386 isync
373 sync 387 sync
374 blr 388 blr
375 389
376 /* setup_bats - set them up to some initial state */ 390 /* setup_bats - set them up to some initial state */
377 .globl setup_bats 391 .globl setup_bats
378 setup_bats: 392 setup_bats:
379 addis r0, r0, 0x0000 393 addis r0, r0, 0x0000
380 394
381 /* IBAT 0 */ 395 /* IBAT 0 */
382 addis r4, r0, CFG_IBAT0L@h 396 addis r4, r0, CFG_IBAT0L@h
383 ori r4, r4, CFG_IBAT0L@l 397 ori r4, r4, CFG_IBAT0L@l
384 addis r3, r0, CFG_IBAT0U@h 398 addis r3, r0, CFG_IBAT0U@h
385 ori r3, r3, CFG_IBAT0U@l 399 ori r3, r3, CFG_IBAT0U@l
386 mtspr IBAT0L, r4 400 mtspr IBAT0L, r4
387 mtspr IBAT0U, r3 401 mtspr IBAT0U, r3
388 isync 402 isync
389 403
390 /* DBAT 0 */ 404 /* DBAT 0 */
391 addis r4, r0, CFG_DBAT0L@h 405 addis r4, r0, CFG_DBAT0L@h
392 ori r4, r4, CFG_DBAT0L@l 406 ori r4, r4, CFG_DBAT0L@l
393 addis r3, r0, CFG_DBAT0U@h 407 addis r3, r0, CFG_DBAT0U@h
394 ori r3, r3, CFG_DBAT0U@l 408 ori r3, r3, CFG_DBAT0U@l
395 mtspr DBAT0L, r4 409 mtspr DBAT0L, r4
396 mtspr DBAT0U, r3 410 mtspr DBAT0U, r3
397 isync 411 isync
398 412
399 /* IBAT 1 */ 413 /* IBAT 1 */
400 addis r4, r0, CFG_IBAT1L@h 414 addis r4, r0, CFG_IBAT1L@h
401 ori r4, r4, CFG_IBAT1L@l 415 ori r4, r4, CFG_IBAT1L@l
402 addis r3, r0, CFG_IBAT1U@h 416 addis r3, r0, CFG_IBAT1U@h
403 ori r3, r3, CFG_IBAT1U@l 417 ori r3, r3, CFG_IBAT1U@l
404 mtspr IBAT1L, r4 418 mtspr IBAT1L, r4
405 mtspr IBAT1U, r3 419 mtspr IBAT1U, r3
406 isync 420 isync
407 421
408 /* DBAT 1 */ 422 /* DBAT 1 */
409 addis r4, r0, CFG_DBAT1L@h 423 addis r4, r0, CFG_DBAT1L@h
410 ori r4, r4, CFG_DBAT1L@l 424 ori r4, r4, CFG_DBAT1L@l
411 addis r3, r0, CFG_DBAT1U@h 425 addis r3, r0, CFG_DBAT1U@h
412 ori r3, r3, CFG_DBAT1U@l 426 ori r3, r3, CFG_DBAT1U@l
413 mtspr DBAT1L, r4 427 mtspr DBAT1L, r4
414 mtspr DBAT1U, r3 428 mtspr DBAT1U, r3
415 isync 429 isync
416 430
417 /* IBAT 2 */ 431 /* IBAT 2 */
418 addis r4, r0, CFG_IBAT2L@h 432 addis r4, r0, CFG_IBAT2L@h
419 ori r4, r4, CFG_IBAT2L@l 433 ori r4, r4, CFG_IBAT2L@l
420 addis r3, r0, CFG_IBAT2U@h 434 addis r3, r0, CFG_IBAT2U@h
421 ori r3, r3, CFG_IBAT2U@l 435 ori r3, r3, CFG_IBAT2U@l
422 mtspr IBAT2L, r4 436 mtspr IBAT2L, r4
423 mtspr IBAT2U, r3 437 mtspr IBAT2U, r3
424 isync 438 isync
425 439
426 /* DBAT 2 */ 440 /* DBAT 2 */
427 addis r4, r0, CFG_DBAT2L@h 441 addis r4, r0, CFG_DBAT2L@h
428 ori r4, r4, CFG_DBAT2L@l 442 ori r4, r4, CFG_DBAT2L@l
429 addis r3, r0, CFG_DBAT2U@h 443 addis r3, r0, CFG_DBAT2U@h
430 ori r3, r3, CFG_DBAT2U@l 444 ori r3, r3, CFG_DBAT2U@l
431 mtspr DBAT2L, r4 445 mtspr DBAT2L, r4
432 mtspr DBAT2U, r3 446 mtspr DBAT2U, r3
433 isync 447 isync
434 448
435 /* IBAT 3 */ 449 /* IBAT 3 */
436 addis r4, r0, CFG_IBAT3L@h 450 addis r4, r0, CFG_IBAT3L@h
437 ori r4, r4, CFG_IBAT3L@l 451 ori r4, r4, CFG_IBAT3L@l
438 addis r3, r0, CFG_IBAT3U@h 452 addis r3, r0, CFG_IBAT3U@h
439 ori r3, r3, CFG_IBAT3U@l 453 ori r3, r3, CFG_IBAT3U@l
440 mtspr IBAT3L, r4 454 mtspr IBAT3L, r4
441 mtspr IBAT3U, r3 455 mtspr IBAT3U, r3
442 isync 456 isync
443 457
444 /* DBAT 3 */ 458 /* DBAT 3 */
445 addis r4, r0, CFG_DBAT3L@h 459 addis r4, r0, CFG_DBAT3L@h
446 ori r4, r4, CFG_DBAT3L@l 460 ori r4, r4, CFG_DBAT3L@l
447 addis r3, r0, CFG_DBAT3U@h 461 addis r3, r0, CFG_DBAT3U@h
448 ori r3, r3, CFG_DBAT3U@l 462 ori r3, r3, CFG_DBAT3U@l
449 mtspr DBAT3L, r4 463 mtspr DBAT3L, r4
450 mtspr DBAT3U, r3 464 mtspr DBAT3U, r3
451 isync 465 isync
452 466
453 /* bats are done, now invalidate the TLBs */ 467 /* bats are done, now invalidate the TLBs */
454 468
455 addis r3, 0, 0x0000 469 addis r3, 0, 0x0000
456 addis r5, 0, 0x4 /* upper bound of 0x00040000 for 7400/750 */ 470 addis r5, 0, 0x4 /* upper bound of 0x00040000 for 7400/750 */
457 471
458 isync 472 isync
459 473
460 tlblp: 474 tlblp:
461 tlbie r3 475 tlbie r3
462 sync 476 sync
463 addi r3, r3, 0x1000 477 addi r3, r3, 0x1000
464 cmp 0, 0, r3, r5 478 cmp 0, 0, r3, r5
465 blt tlblp 479 blt tlblp
466 480
467 blr 481 blr
468 482
469 .globl enable_addr_trans 483 .globl enable_addr_trans
470 enable_addr_trans: 484 enable_addr_trans:
471 /* enable address translation */ 485 /* enable address translation */
472 mfmsr r5 486 mfmsr r5
473 ori r5, r5, (MSR_IR | MSR_DR) 487 ori r5, r5, (MSR_IR | MSR_DR)
474 mtmsr r5 488 mtmsr r5
475 isync 489 isync
476 blr 490 blr
477 491
478 .globl disable_addr_trans 492 .globl disable_addr_trans
479 disable_addr_trans: 493 disable_addr_trans:
480 /* disable address translation */ 494 /* disable address translation */
481 mflr r4 495 mflr r4
482 mfmsr r3 496 mfmsr r3
483 andi. r0, r3, (MSR_IR | MSR_DR) 497 andi. r0, r3, (MSR_IR | MSR_DR)
484 beqlr 498 beqlr
485 andc r3, r3, r0 499 andc r3, r3, r0
486 mtspr SRR0, r4 500 mtspr SRR0, r4
487 mtspr SRR1, r3 501 mtspr SRR1, r3
488 rfi 502 rfi
489 503
490 /* 504 /*
491 * This code finishes saving the registers to the exception frame 505 * This code finishes saving the registers to the exception frame
492 * and jumps to the appropriate handler for the exception. 506 * and jumps to the appropriate handler for the exception.
493 * Register r21 is pointer into trap frame, r1 has new stack pointer. 507 * Register r21 is pointer into trap frame, r1 has new stack pointer.
494 */ 508 */
495 .globl transfer_to_handler 509 .globl transfer_to_handler
496 transfer_to_handler: 510 transfer_to_handler:
497 stw r22,_NIP(r21) 511 stw r22,_NIP(r21)
498 lis r22,MSR_POW@h 512 lis r22,MSR_POW@h
499 andc r23,r23,r22 513 andc r23,r23,r22
500 stw r23,_MSR(r21) 514 stw r23,_MSR(r21)
501 SAVE_GPR(7, r21) 515 SAVE_GPR(7, r21)
502 SAVE_4GPRS(8, r21) 516 SAVE_4GPRS(8, r21)
503 SAVE_8GPRS(12, r21) 517 SAVE_8GPRS(12, r21)
504 SAVE_8GPRS(24, r21) 518 SAVE_8GPRS(24, r21)
505 mflr r23 519 mflr r23
506 andi. r24,r23,0x3f00 /* get vector offset */ 520 andi. r24,r23,0x3f00 /* get vector offset */
507 stw r24,TRAP(r21) 521 stw r24,TRAP(r21)
508 li r22,0 522 li r22,0
509 stw r22,RESULT(r21) 523 stw r22,RESULT(r21)
510 mtspr SPRG2,r22 /* r1 is now kernel sp */ 524 mtspr SPRG2,r22 /* r1 is now kernel sp */
511 lwz r24,0(r23) /* virtual address of handler */ 525 lwz r24,0(r23) /* virtual address of handler */
512 lwz r23,4(r23) /* where to go when done */ 526 lwz r23,4(r23) /* where to go when done */
513 mtspr SRR0,r24 527 mtspr SRR0,r24
514 mtspr SRR1,r20 528 mtspr SRR1,r20
515 mtlr r23 529 mtlr r23
516 SYNC 530 SYNC
517 rfi /* jump to handler, enable MMU */ 531 rfi /* jump to handler, enable MMU */
518 532
519 int_return: 533 int_return:
520 mfmsr r28 /* Disable interrupts */ 534 mfmsr r28 /* Disable interrupts */
521 li r4,0 535 li r4,0
522 ori r4,r4,MSR_EE 536 ori r4,r4,MSR_EE
523 andc r28,r28,r4 537 andc r28,r28,r4
524 SYNC /* Some chip revs need this... */ 538 SYNC /* Some chip revs need this... */
525 mtmsr r28 539 mtmsr r28
526 SYNC 540 SYNC
527 lwz r2,_CTR(r1) 541 lwz r2,_CTR(r1)
528 lwz r0,_LINK(r1) 542 lwz r0,_LINK(r1)
529 mtctr r2 543 mtctr r2
530 mtlr r0 544 mtlr r0
531 lwz r2,_XER(r1) 545 lwz r2,_XER(r1)
532 lwz r0,_CCR(r1) 546 lwz r0,_CCR(r1)
533 mtspr XER,r2 547 mtspr XER,r2
534 mtcrf 0xFF,r0 548 mtcrf 0xFF,r0
535 REST_10GPRS(3, r1) 549 REST_10GPRS(3, r1)
536 REST_10GPRS(13, r1) 550 REST_10GPRS(13, r1)
537 REST_8GPRS(23, r1) 551 REST_8GPRS(23, r1)
538 REST_GPR(31, r1) 552 REST_GPR(31, r1)
539 lwz r2,_NIP(r1) /* Restore environment */ 553 lwz r2,_NIP(r1) /* Restore environment */
540 lwz r0,_MSR(r1) 554 lwz r0,_MSR(r1)
541 mtspr SRR0,r2 555 mtspr SRR0,r2
542 mtspr SRR1,r0 556 mtspr SRR1,r0
543 lwz r0,GPR0(r1) 557 lwz r0,GPR0(r1)
544 lwz r2,GPR2(r1) 558 lwz r2,GPR2(r1)
545 lwz r1,GPR1(r1) 559 lwz r1,GPR1(r1)
546 SYNC 560 SYNC
547 rfi 561 rfi
548 562
549 .globl dc_read 563 .globl dc_read
550 dc_read: 564 dc_read:
551 blr 565 blr
552 566
553 .globl get_pvr 567 .globl get_pvr
554 get_pvr: 568 get_pvr:
555 mfspr r3, PVR 569 mfspr r3, PVR
556 blr 570 blr
557 571
558 /*-----------------------------------------------------------------------*/ 572 /*-----------------------------------------------------------------------*/
559 /* 573 /*
560 * void relocate_code (addr_sp, gd, addr_moni) 574 * void relocate_code (addr_sp, gd, addr_moni)
561 * 575 *
562 * This "function" does not return, instead it continues in RAM 576 * This "function" does not return, instead it continues in RAM
563 * after relocating the monitor code. 577 * after relocating the monitor code.
564 * 578 *
565 * r3 = dest 579 * r3 = dest
566 * r4 = src 580 * r4 = src
567 * r5 = length in bytes 581 * r5 = length in bytes
568 * r6 = cachelinesize 582 * r6 = cachelinesize
569 */ 583 */
570 .globl relocate_code 584 .globl relocate_code
571 relocate_code: 585 relocate_code:
572 mr r1, r3 /* Set new stack pointer */ 586 mr r1, r3 /* Set new stack pointer */
573 mr r9, r4 /* Save copy of Global Data pointer */ 587 mr r9, r4 /* Save copy of Global Data pointer */
574 mr r10, r5 /* Save copy of Destination Address */ 588 mr r10, r5 /* Save copy of Destination Address */
575 589
576 mr r3, r5 /* Destination Address */ 590 mr r3, r5 /* Destination Address */
577 lis r4, CFG_MONITOR_BASE@h /* Source Address */ 591 lis r4, CFG_MONITOR_BASE@h /* Source Address */
578 ori r4, r4, CFG_MONITOR_BASE@l 592 ori r4, r4, CFG_MONITOR_BASE@l
579 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */ 593 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */
580 ori r5, r5, CFG_MONITOR_LEN@l 594 ori r5, r5, CFG_MONITOR_LEN@l
581 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */ 595 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
582 596
583 /* 597 /*
584 * Fix GOT pointer: 598 * Fix GOT pointer:
585 * 599 *
586 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address 600 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
587 * 601 *
588 * Offset: 602 * Offset:
589 */ 603 */
590 sub r15, r10, r4 604 sub r15, r10, r4
591 605
592 /* First our own GOT */ 606 /* First our own GOT */
593 add r14, r14, r15 607 add r14, r14, r15
594 /* then the one used by the C code */ 608 /* then the one used by the C code */
595 add r30, r30, r15 609 add r30, r30, r15
596 610
597 /* 611 /*
598 * Now relocate code 612 * Now relocate code
599 */ 613 */
600 #ifdef CONFIG_ECC 614 #ifdef CONFIG_ECC
601 bl board_relocate_rom 615 bl board_relocate_rom
602 sync 616 sync
603 mr r3, r10 /* Destination Address */ 617 mr r3, r10 /* Destination Address */
604 lis r4, CFG_MONITOR_BASE@h /* Source Address */ 618 lis r4, CFG_MONITOR_BASE@h /* Source Address */
605 ori r4, r4, CFG_MONITOR_BASE@l 619 ori r4, r4, CFG_MONITOR_BASE@l
606 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */ 620 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */
607 ori r5, r5, CFG_MONITOR_LEN@l 621 ori r5, r5, CFG_MONITOR_LEN@l
608 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */ 622 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
609 #else 623 #else
610 cmplw cr1,r3,r4 624 cmplw cr1,r3,r4
611 addi r0,r5,3 625 addi r0,r5,3
612 srwi. r0,r0,2 626 srwi. r0,r0,2
613 beq cr1,4f /* In place copy is not necessary */ 627 beq cr1,4f /* In place copy is not necessary */
614 beq 7f /* Protect against 0 count */ 628 beq 7f /* Protect against 0 count */
615 mtctr r0 629 mtctr r0
616 bge cr1,2f 630 bge cr1,2f
617 631
618 la r8,-4(r4) 632 la r8,-4(r4)
619 la r7,-4(r3) 633 la r7,-4(r3)
620 1: lwzu r0,4(r8) 634 1: lwzu r0,4(r8)
621 stwu r0,4(r7) 635 stwu r0,4(r7)
622 bdnz 1b 636 bdnz 1b
623 b 4f 637 b 4f
624 638
625 2: slwi r0,r0,2 639 2: slwi r0,r0,2
626 add r8,r4,r0 640 add r8,r4,r0
627 add r7,r3,r0 641 add r7,r3,r0
628 3: lwzu r0,-4(r8) 642 3: lwzu r0,-4(r8)
629 stwu r0,-4(r7) 643 stwu r0,-4(r7)
630 bdnz 3b 644 bdnz 3b
631 #endif 645 #endif
632 /* 646 /*
633 * Now flush the cache: note that we must start from a cache aligned 647 * Now flush the cache: note that we must start from a cache aligned
634 * address. Otherwise we might miss one cache line. 648 * address. Otherwise we might miss one cache line.
635 */ 649 */
636 4: cmpwi r6,0 650 4: cmpwi r6,0
637 add r5,r3,r5 651 add r5,r3,r5
638 beq 7f /* Always flush prefetch queue in any case */ 652 beq 7f /* Always flush prefetch queue in any case */
639 subi r0,r6,1 653 subi r0,r6,1
640 andc r3,r3,r0 654 andc r3,r3,r0
641 mr r4,r3 655 mr r4,r3
642 5: dcbst 0,r4 656 5: dcbst 0,r4
643 add r4,r4,r6 657 add r4,r4,r6
644 cmplw r4,r5 658 cmplw r4,r5
645 blt 5b 659 blt 5b
646 sync /* Wait for all dcbst to complete on bus */ 660 sync /* Wait for all dcbst to complete on bus */
647 mr r4,r3 661 mr r4,r3
648 6: icbi 0,r4 662 6: icbi 0,r4
649 add r4,r4,r6 663 add r4,r4,r6
650 cmplw r4,r5 664 cmplw r4,r5
651 blt 6b 665 blt 6b
652 7: sync /* Wait for all icbi to complete on bus */ 666 7: sync /* Wait for all icbi to complete on bus */
653 isync 667 isync
654 668
655 /* 669 /*
656 * We are done. Do not return, instead branch to second part of board 670 * We are done. Do not return, instead branch to second part of board
657 * initialization, now running from RAM. 671 * initialization, now running from RAM.
658 */ 672 */
659 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET 673 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
660 mtlr r0 674 mtlr r0
661 blr 675 blr
662 676
663 in_ram: 677 in_ram:
664 #ifdef CONFIG_ECC 678 #ifdef CONFIG_ECC
665 bl board_init_ecc 679 bl board_init_ecc
666 #endif 680 #endif
667 /* 681 /*
668 * Relocation Function, r14 point to got2+0x8000 682 * Relocation Function, r14 point to got2+0x8000
669 * 683 *
670 * Adjust got2 pointers, no need to check for 0, this code 684 * Adjust got2 pointers, no need to check for 0, this code
671 * already puts a few entries in the table. 685 * already puts a few entries in the table.
672 */ 686 */
673 li r0,__got2_entries@sectoff@l 687 li r0,__got2_entries@sectoff@l
674 la r3,GOT(_GOT2_TABLE_) 688 la r3,GOT(_GOT2_TABLE_)
675 lwz r11,GOT(_GOT2_TABLE_) 689 lwz r11,GOT(_GOT2_TABLE_)
676 mtctr r0 690 mtctr r0
677 sub r11,r3,r11 691 sub r11,r3,r11
678 addi r3,r3,-4 692 addi r3,r3,-4
679 1: lwzu r0,4(r3) 693 1: lwzu r0,4(r3)
680 add r0,r0,r11 694 add r0,r0,r11
681 stw r0,0(r3) 695 stw r0,0(r3)
682 bdnz 1b 696 bdnz 1b
683 697
684 /* 698 /*
685 * Now adjust the fixups and the pointers to the fixups 699 * Now adjust the fixups and the pointers to the fixups
686 * in case we need to move ourselves again. 700 * in case we need to move ourselves again.
687 */ 701 */
688 2: li r0,__fixup_entries@sectoff@l 702 2: li r0,__fixup_entries@sectoff@l
689 lwz r3,GOT(_FIXUP_TABLE_) 703 lwz r3,GOT(_FIXUP_TABLE_)
690 cmpwi r0,0 704 cmpwi r0,0
691 mtctr r0 705 mtctr r0
692 addi r3,r3,-4 706 addi r3,r3,-4
693 beq 4f 707 beq 4f
694 3: lwzu r4,4(r3) 708 3: lwzu r4,4(r3)
695 lwzux r0,r4,r11 709 lwzux r0,r4,r11
696 add r0,r0,r11 710 add r0,r0,r11
697 stw r10,0(r3) 711 stw r10,0(r3)
698 stw r0,0(r4) 712 stw r0,0(r4)
699 bdnz 3b 713 bdnz 3b
700 4: 714 4:
701 /* clear_bss: */ 715 /* clear_bss: */
702 /* 716 /*
703 * Now clear BSS segment 717 * Now clear BSS segment
704 */ 718 */
705 lwz r3,GOT(.bss) 719 lwz r3,GOT(.bss)
706 lwz r4,GOT(_end) 720 lwz r4,GOT(_end)
707 721
708 cmplw 0, r3, r4 722 cmplw 0, r3, r4
709 beq 6f 723 beq 6f
710 724
711 li r0, 0 725 li r0, 0
712 5: 726 5:
713 stw r0, 0(r3) 727 stw r0, 0(r3)
714 addi r3, r3, 4 728 addi r3, r3, 4
715 cmplw 0, r3, r4 729 cmplw 0, r3, r4
716 bne 5b 730 bne 5b
717 6: 731 6:
718 mr r3, r10 /* Destination Address */ 732 mr r3, r10 /* Destination Address */
733 #ifdef CONFIG_AMIGAONEG3SE
734 mr r4, r9 /* Use RAM copy of the global data */
735 #endif
719 bl after_reloc 736 bl after_reloc
720 737
721 /* not reached - end relocate_code */ 738 /* not reached - end relocate_code */
722 /*-----------------------------------------------------------------------*/ 739 /*-----------------------------------------------------------------------*/
723 740
724 /* Problems accessing "end" in C, so do it here */ 741 /* Problems accessing "end" in C, so do it here */
725 .globl get_endaddr 742 .globl get_endaddr
726 get_endaddr: 743 get_endaddr:
727 lwz r3,GOT(_end) 744 lwz r3,GOT(_end)
728 blr 745 blr
729 746
730 /* 747 /*
731 * Copy exception vector code to low memory 748 * Copy exception vector code to low memory
732 * 749 *
733 * r3: dest_addr 750 * r3: dest_addr
734 * r7: source address, r8: end address, r9: target address 751 * r7: source address, r8: end address, r9: target address
735 */ 752 */
736 .globl trap_init 753 .globl trap_init
737 trap_init: 754 trap_init:
738 lwz r7, GOT(_start) 755 lwz r7, GOT(_start)
739 lwz r8, GOT(_end_of_vectors) 756 lwz r8, GOT(_end_of_vectors)
740 757
741 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */ 758 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
742 759
743 cmplw 0, r7, r8 760 cmplw 0, r7, r8
744 bgelr /* return if r7>=r8 - just in case */ 761 bgelr /* return if r7>=r8 - just in case */
745 762
746 mflr r4 /* save link register */ 763 mflr r4 /* save link register */
747 1: 764 1:
748 lwz r0, 0(r7) 765 lwz r0, 0(r7)
749 stw r0, 0(r9) 766 stw r0, 0(r9)
750 addi r7, r7, 4 767 addi r7, r7, 4
751 addi r9, r9, 4 768 addi r9, r9, 4
752 cmplw 0, r7, r8 769 cmplw 0, r7, r8
753 bne 1b 770 bne 1b
754 771
755 /* 772 /*
756 * relocate `hdlr' and `int_return' entries 773 * relocate `hdlr' and `int_return' entries
757 */ 774 */
758 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET 775 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
759 li r8, Alignment - _start + EXC_OFF_SYS_RESET 776 li r8, Alignment - _start + EXC_OFF_SYS_RESET
760 2: 777 2:
761 bl trap_reloc 778 bl trap_reloc
762 addi r7, r7, 0x100 /* next exception vector */ 779 addi r7, r7, 0x100 /* next exception vector */
763 cmplw 0, r7, r8 780 cmplw 0, r7, r8
764 blt 2b 781 blt 2b
765 782
766 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET 783 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
767 bl trap_reloc 784 bl trap_reloc
768 785
769 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET 786 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
770 bl trap_reloc 787 bl trap_reloc
771 788
772 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET 789 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
773 li r8, SystemCall - _start + EXC_OFF_SYS_RESET 790 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
774 3: 791 3:
775 bl trap_reloc 792 bl trap_reloc
776 addi r7, r7, 0x100 /* next exception vector */ 793 addi r7, r7, 0x100 /* next exception vector */
777 cmplw 0, r7, r8 794 cmplw 0, r7, r8
778 blt 3b 795 blt 3b
779 796
780 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET 797 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
781 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET 798 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
782 4: 799 4:
783 bl trap_reloc 800 bl trap_reloc
784 addi r7, r7, 0x100 /* next exception vector */ 801 addi r7, r7, 0x100 /* next exception vector */
785 cmplw 0, r7, r8 802 cmplw 0, r7, r8
786 blt 4b 803 blt 4b
787 804
788 /* enable execptions from RAM vectors */ 805 /* enable execptions from RAM vectors */
789 mfmsr r7 806 mfmsr r7
790 li r8,MSR_IP 807 li r8,MSR_IP
791 andc r7,r7,r8 808 andc r7,r7,r8
792 mtmsr r7 809 mtmsr r7
793 810
794 mtlr r4 /* restore link register */ 811 mtlr r4 /* restore link register */
795 blr 812 blr
796 813
797 /* 814 /*
798 * Function: relocate entries for one exception vector 815 * Function: relocate entries for one exception vector
799 */ 816 */
800 trap_reloc: 817 trap_reloc:
801 lwz r0, 0(r7) /* hdlr ... */ 818 lwz r0, 0(r7) /* hdlr ... */
802 add r0, r0, r3 /* ... += dest_addr */ 819 add r0, r0, r3 /* ... += dest_addr */
803 stw r0, 0(r7) 820 stw r0, 0(r7)
804 821
805 lwz r0, 4(r7) /* int_return ... */ 822 lwz r0, 4(r7) /* int_return ... */
806 add r0, r0, r3 /* ... += dest_addr */ 823 add r0, r0, r3 /* ... += dest_addr */
807 stw r0, 4(r7) 824 stw r0, 4(r7)
808 825
809 sync 826 sync
810 isync 827 isync
811 828
812 blr 829 blr
813 830
814 #ifdef CFG_INIT_RAM_LOCK 831 #ifdef CFG_INIT_RAM_LOCK
815 lock_ram_in_cache: 832 lock_ram_in_cache:
816 /* Allocate Initial RAM in data cache. 833 /* Allocate Initial RAM in data cache.
817 */ 834 */
818 lis r3, (CFG_INIT_RAM_ADDR & ~31)@h 835 lis r3, (CFG_INIT_RAM_ADDR & ~31)@h
819 ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l 836 ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l
820 li r2, ((CFG_INIT_RAM_END & ~31) + \ 837 li r2, ((CFG_INIT_RAM_END & ~31) + \
821 (CFG_INIT_RAM_ADDR & 31) + 31) / 32 838 (CFG_INIT_RAM_ADDR & 31) + 31) / 32
822 mtctr r2 839 mtctr r2
823 1: 840 1:
824 dcbz r0, r3 841 dcbz r0, r3
825 addi r3, r3, 32 842 addi r3, r3, 32
826 bdnz 1b 843 bdnz 1b
827 844
828 /* Lock the data cache */ 845 /* Lock the data cache */
829 mfspr r0, HID0 846 mfspr r0, HID0
830 ori r0, r0, 0x1000 847 ori r0, r0, 0x1000
831 sync 848 sync
832 mtspr HID0, r0 849 mtspr HID0, r0
833 sync 850 sync
834 blr 851 blr
835 852
836 .globl unlock_ram_in_cache 853 .globl unlock_ram_in_cache
837 unlock_ram_in_cache: 854 unlock_ram_in_cache:
838 /* invalidate the INIT_RAM section */ 855 /* invalidate the INIT_RAM section */
839 lis r3, (CFG_INIT_RAM_ADDR & ~31)@h 856 lis r3, (CFG_INIT_RAM_ADDR & ~31)@h
840 ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l 857 ori r3, r3, (CFG_INIT_RAM_ADDR & ~31)@l
841 li r2, ((CFG_INIT_RAM_END & ~31) + \ 858 li r2, ((CFG_INIT_RAM_END & ~31) + \
842 (CFG_INIT_RAM_ADDR & 31) + 31) / 32 859 (CFG_INIT_RAM_ADDR & 31) + 31) / 32
843 mtctr r2 860 mtctr r2
844 1: icbi r0, r3 861 1: icbi r0, r3
845 addi r3, r3, 32 862 addi r3, r3, 32
846 bdnz 1b 863 bdnz 1b
847 sync /* Wait for all icbi to complete on bus */ 864 sync /* Wait for all icbi to complete on bus */
848 isync 865 isync
849 866
850 /* Unlock the data cache and invalidate it */ 867 /* Unlock the data cache and invalidate it */
851 mfspr r0, HID0 868 mfspr r0, HID0
852 li r3,0x1000 869 li r3,0x1000
853 andc r0,r0,r3 870 andc r0,r0,r3
854 li r3,0x0400 871 li r3,0x0400
855 or r0,r0,r3 872 or r0,r0,r3
856 sync 873 sync
857 mtspr HID0, r0 874 mtspr HID0, r0
858 sync 875 sync
859 blr 876 blr
860 #endif 877 #endif
861 878
cpu/mpc824x/drivers/epic/epic.h
1 /********************************************************************* 1 /*********************************************************************
2 * mpc8240epic.h - EPIC module of the MPC8240 micro-controller 2 * mpc8240epic.h - EPIC module of the MPC8240 micro-controller
3 * 3 *
4 * Copyrigh 1999 Motorola Inc. 4 * Copyrigh 1999 Motorola Inc.
5 * 5 *
6 * Modification History: 6 * Modification History:
7 * ===================== 7 * =====================
8 * 01a,04Feb99,My Created. 8 * 01a,04Feb99,My Created.
9 * 15Nov200, robt -modified to use in U-Boot 9 * 15Nov200, robt -modified to use in U-Boot
10 * 10 *
11 */ 11 */
12 12
13 #ifndef __INCEPICh 13 #ifndef __INCEPICh
14 #define __INCEPICh 14 #define __INCEPICh
15 15
16 #define ULONG unsigned long 16 #define ULONG unsigned long
17 #define MAXVEC 20 17 #define MAXVEC 20
18 #define MAXIRQ 5 /* IRQs */ 18 #define MAXIRQ 5 /* IRQs */
19 #define EPIC_DIRECT_IRQ 0 /* Direct interrupt type */ 19 #define EPIC_DIRECT_IRQ 0 /* Direct interrupt type */
20 20
21 /* EPIC register addresses */ 21 /* EPIC register addresses */
22 22
23 #define EPIC_EUMBBAR 0x40000 /* EUMBBAR of EPIC */ 23 #define EPIC_EUMBBAR 0x40000 /* EUMBBAR of EPIC */
24 #define EPIC_FEATURES_REG (EPIC_EUMBBAR + 0x01000)/* Feature reporting */ 24 #define EPIC_FEATURES_REG (EPIC_EUMBBAR + 0x01000)/* Feature reporting */
25 #define EPIC_GLOBAL_REG (EPIC_EUMBBAR + 0x01020)/* Global config. */ 25 #define EPIC_GLOBAL_REG (EPIC_EUMBBAR + 0x01020)/* Global config. */
26 #define EPIC_INT_CONF_REG (EPIC_EUMBBAR + 0x01030)/* Interrupt config. */ 26 #define EPIC_INT_CONF_REG (EPIC_EUMBBAR + 0x01030)/* Interrupt config. */
27 #define EPIC_VENDOR_ID_REG (EPIC_EUMBBAR + 0x01080)/* Vendor id */ 27 #define EPIC_VENDOR_ID_REG (EPIC_EUMBBAR + 0x01080)/* Vendor id */
28 #define EPIC_PROC_INIT_REG (EPIC_EUMBBAR + 0x01090)/* Processor init. */ 28 #define EPIC_PROC_INIT_REG (EPIC_EUMBBAR + 0x01090)/* Processor init. */
29 #define EPIC_SPUR_VEC_REG (EPIC_EUMBBAR + 0x010e0)/* Spurious vector */ 29 #define EPIC_SPUR_VEC_REG (EPIC_EUMBBAR + 0x010e0)/* Spurious vector */
30 #define EPIC_TM_FREQ_REG (EPIC_EUMBBAR + 0x010f0)/* Timer Frequency */ 30 #define EPIC_TM_FREQ_REG (EPIC_EUMBBAR + 0x010f0)/* Timer Frequency */
31 31
32 #define EPIC_TM0_CUR_COUNT_REG (EPIC_EUMBBAR + 0x01100)/* Gbl TM0 Cur. Count*/ 32 #define EPIC_TM0_CUR_COUNT_REG (EPIC_EUMBBAR + 0x01100)/* Gbl TM0 Cur. Count*/
33 #define EPIC_TM0_BASE_COUNT_REG (EPIC_EUMBBAR + 0x01110)/* Gbl TM0 Base Count*/ 33 #define EPIC_TM0_BASE_COUNT_REG (EPIC_EUMBBAR + 0x01110)/* Gbl TM0 Base Count*/
34 #define EPIC_TM0_VEC_REG (EPIC_EUMBBAR + 0x01120)/* Gbl TM0 Vector Pri*/ 34 #define EPIC_TM0_VEC_REG (EPIC_EUMBBAR + 0x01120)/* Gbl TM0 Vector Pri*/
35 #define EPIC_TM0_DES_REG (EPIC_EUMBBAR + 0x01130)/* Gbl TM0 Dest. */ 35 #define EPIC_TM0_DES_REG (EPIC_EUMBBAR + 0x01130)/* Gbl TM0 Dest. */
36 36
37 #define EPIC_TM1_CUR_COUNT_REG (EPIC_EUMBBAR + 0x01140)/* Gbl TM1 Cur. Count*/ 37 #define EPIC_TM1_CUR_COUNT_REG (EPIC_EUMBBAR + 0x01140)/* Gbl TM1 Cur. Count*/
38 #define EPIC_TM1_BASE_COUNT_REG (EPIC_EUMBBAR + 0x01150)/* Gbl TM1 Base Count*/ 38 #define EPIC_TM1_BASE_COUNT_REG (EPIC_EUMBBAR + 0x01150)/* Gbl TM1 Base Count*/
39 #define EPIC_TM1_VEC_REG (EPIC_EUMBBAR + 0x01160)/* Gbl TM1 Vector Pri*/ 39 #define EPIC_TM1_VEC_REG (EPIC_EUMBBAR + 0x01160)/* Gbl TM1 Vector Pri*/
40 #define EPIC_TM1_DES_REG (EPIC_EUMBBAR + 0x01170)/* Gbl TM1 Dest. */ 40 #define EPIC_TM1_DES_REG (EPIC_EUMBBAR + 0x01170)/* Gbl TM1 Dest. */
41 41
42 #define EPIC_TM2_CUR_COUNT_REG (EPIC_EUMBBAR + 0x01180)/* Gbl TM2 Cur. Count*/ 42 #define EPIC_TM2_CUR_COUNT_REG (EPIC_EUMBBAR + 0x01180)/* Gbl TM2 Cur. Count*/
43 #define EPIC_TM2_BASE_COUNT_REG (EPIC_EUMBBAR + 0x01190)/* Gbl TM2 Base Count*/ 43 #define EPIC_TM2_BASE_COUNT_REG (EPIC_EUMBBAR + 0x01190)/* Gbl TM2 Base Count*/
44 #define EPIC_TM2_VEC_REG (EPIC_EUMBBAR + 0x011a0)/* Gbl TM2 Vector Pri*/ 44 #define EPIC_TM2_VEC_REG (EPIC_EUMBBAR + 0x011a0)/* Gbl TM2 Vector Pri*/
45 #define EPIC_TM2_DES_REG (EPIC_EUMBBAR + 0x011b0)/* Gbl TM2 Dest */ 45 #define EPIC_TM2_DES_REG (EPIC_EUMBBAR + 0x011b0)/* Gbl TM2 Dest */
46 46
47 #define EPIC_TM3_CUR_COUNT_REG (EPIC_EUMBBAR + 0x011c0)/* Gbl TM3 Cur. Count*/ 47 #define EPIC_TM3_CUR_COUNT_REG (EPIC_EUMBBAR + 0x011c0)/* Gbl TM3 Cur. Count*/
48 #define EPIC_TM3_BASE_COUNT_REG (EPIC_EUMBBAR + 0x011d0)/* Gbl TM3 Base Count*/ 48 #define EPIC_TM3_BASE_COUNT_REG (EPIC_EUMBBAR + 0x011d0)/* Gbl TM3 Base Count*/
49 #define EPIC_TM3_VEC_REG (EPIC_EUMBBAR + 0x011e0)/* Gbl TM3 Vector Pri*/ 49 #define EPIC_TM3_VEC_REG (EPIC_EUMBBAR + 0x011e0)/* Gbl TM3 Vector Pri*/
50 #define EPIC_TM3_DES_REG (EPIC_EUMBBAR + 0x011f0)/* Gbl TM3 Dest. */ 50 #define EPIC_TM3_DES_REG (EPIC_EUMBBAR + 0x011f0)/* Gbl TM3 Dest. */
51 51
52 #define EPIC_EX_INT0_VEC_REG (EPIC_EUMBBAR + 0x10200)/* Ext. Int. Sr0 Des */ 52 #define EPIC_EX_INT0_VEC_REG (EPIC_EUMBBAR + 0x10200)/* Ext. Int. Sr0 Des */
53 #define EPIC_EX_INT0_DES_REG (EPIC_EUMBBAR + 0x10210)/* Ext. Int. Sr0 Vect*/ 53 #define EPIC_EX_INT0_DES_REG (EPIC_EUMBBAR + 0x10210)/* Ext. Int. Sr0 Vect*/
54 #define EPIC_EX_INT1_VEC_REG (EPIC_EUMBBAR + 0x10220)/* Ext. Int. Sr1 Des */ 54 #define EPIC_EX_INT1_VEC_REG (EPIC_EUMBBAR + 0x10220)/* Ext. Int. Sr1 Des */
55 #define EPIC_EX_INT1_DES_REG (EPIC_EUMBBAR + 0x10230)/* Ext. Int. Sr1 Vect*/ 55 #define EPIC_EX_INT1_DES_REG (EPIC_EUMBBAR + 0x10230)/* Ext. Int. Sr1 Vect*/
56 #define EPIC_EX_INT2_VEC_REG (EPIC_EUMBBAR + 0x10240)/* Ext. Int. Sr2 Des */ 56 #define EPIC_EX_INT2_VEC_REG (EPIC_EUMBBAR + 0x10240)/* Ext. Int. Sr2 Des */
57 #define EPIC_EX_INT2_DES_REG (EPIC_EUMBBAR + 0x10250)/* Ext. Int. Sr2 Vect*/ 57 #define EPIC_EX_INT2_DES_REG (EPIC_EUMBBAR + 0x10250)/* Ext. Int. Sr2 Vect*/
58 #define EPIC_EX_INT3_VEC_REG (EPIC_EUMBBAR + 0x10260)/* Ext. Int. Sr3 Des */ 58 #define EPIC_EX_INT3_VEC_REG (EPIC_EUMBBAR + 0x10260)/* Ext. Int. Sr3 Des */
59 #define EPIC_EX_INT3_DES_REG (EPIC_EUMBBAR + 0x10270)/* Ext. Int. Sr3 Vect*/ 59 #define EPIC_EX_INT3_DES_REG (EPIC_EUMBBAR + 0x10270)/* Ext. Int. Sr3 Vect*/
60 #define EPIC_EX_INT4_VEC_REG (EPIC_EUMBBAR + 0x10280)/* Ext. Int. Sr4 Des */ 60 #define EPIC_EX_INT4_VEC_REG (EPIC_EUMBBAR + 0x10280)/* Ext. Int. Sr4 Des */
61 #define EPIC_EX_INT4_DES_REG (EPIC_EUMBBAR + 0x10290)/* Ext. Int. Sr4 Vect*/ 61 #define EPIC_EX_INT4_DES_REG (EPIC_EUMBBAR + 0x10290)/* Ext. Int. Sr4 Vect*/
62 62
63 #define EPIC_SR_INT0_VEC_REG (EPIC_EUMBBAR + 0x10200)/* Sr. Int. Sr0 Des */ 63 #define EPIC_SR_INT0_VEC_REG (EPIC_EUMBBAR + 0x10200)/* Sr. Int. Sr0 Des */
64 #define EPIC_SR_INT0_DES_REG (EPIC_EUMBBAR + 0x10210)/* Sr. Int. Sr0 Vect */ 64 #define EPIC_SR_INT0_DES_REG (EPIC_EUMBBAR + 0x10210)/* Sr. Int. Sr0 Vect */
65 #define EPIC_SR_INT1_VEC_REG (EPIC_EUMBBAR + 0x10220)/* Sr. Int. Sr1 Des */ 65 #define EPIC_SR_INT1_VEC_REG (EPIC_EUMBBAR + 0x10220)/* Sr. Int. Sr1 Des */
66 #define EPIC_SR_INT1_DES_REG (EPIC_EUMBBAR + 0x10230)/* Sr. Int. Sr1 Vect.*/ 66 #define EPIC_SR_INT1_DES_REG (EPIC_EUMBBAR + 0x10230)/* Sr. Int. Sr1 Vect.*/
67 #define EPIC_SR_INT2_VEC_REG (EPIC_EUMBBAR + 0x10240)/* Sr. Int. Sr2 Des */ 67 #define EPIC_SR_INT2_VEC_REG (EPIC_EUMBBAR + 0x10240)/* Sr. Int. Sr2 Des */
68 #define EPIC_SR_INT2_DES_REG (EPIC_EUMBBAR + 0x10250)/* Sr. Int. Sr2 Vect.*/ 68 #define EPIC_SR_INT2_DES_REG (EPIC_EUMBBAR + 0x10250)/* Sr. Int. Sr2 Vect.*/
69 #define EPIC_SR_INT3_VEC_REG (EPIC_EUMBBAR + 0x10260)/* Sr. Int. Sr3 Des */ 69 #define EPIC_SR_INT3_VEC_REG (EPIC_EUMBBAR + 0x10260)/* Sr. Int. Sr3 Des */
70 #define EPIC_SR_INT3_DES_REG (EPIC_EUMBBAR + 0x10270)/* Sr. Int. Sr3 Vect.*/ 70 #define EPIC_SR_INT3_DES_REG (EPIC_EUMBBAR + 0x10270)/* Sr. Int. Sr3 Vect.*/
71 #define EPIC_SR_INT4_VEC_REG (EPIC_EUMBBAR + 0x10280)/* Sr. Int. Sr4 Des */ 71 #define EPIC_SR_INT4_VEC_REG (EPIC_EUMBBAR + 0x10280)/* Sr. Int. Sr4 Des */
72 #define EPIC_SR_INT4_DES_REG (EPIC_EUMBBAR + 0x10290)/* Sr. Int. Sr4 Vect.*/ 72 #define EPIC_SR_INT4_DES_REG (EPIC_EUMBBAR + 0x10290)/* Sr. Int. Sr4 Vect.*/
73 73
74 #define EPIC_SR_INT5_VEC_REG (EPIC_EUMBBAR + 0x102a0)/* Sr. Int. Sr5 Des */ 74 #define EPIC_SR_INT5_VEC_REG (EPIC_EUMBBAR + 0x102a0)/* Sr. Int. Sr5 Des */
75 #define EPIC_SR_INT5_DES_REG (EPIC_EUMBBAR + 0x102b0)/* Sr. Int. Sr5 Vect.*/ 75 #define EPIC_SR_INT5_DES_REG (EPIC_EUMBBAR + 0x102b0)/* Sr. Int. Sr5 Vect.*/
76 #define EPIC_SR_INT6_VEC_REG (EPIC_EUMBBAR + 0x102c0)/* Sr. Int. Sr6 Des */ 76 #define EPIC_SR_INT6_VEC_REG (EPIC_EUMBBAR + 0x102c0)/* Sr. Int. Sr6 Des */
77 #define EPIC_SR_INT6_DES_REG (EPIC_EUMBBAR + 0x102d0)/* Sr. Int. Sr6 Vect.*/ 77 #define EPIC_SR_INT6_DES_REG (EPIC_EUMBBAR + 0x102d0)/* Sr. Int. Sr6 Vect.*/
78 #define EPIC_SR_INT7_VEC_REG (EPIC_EUMBBAR + 0x102e0)/* Sr. Int. Sr7 Des */ 78 #define EPIC_SR_INT7_VEC_REG (EPIC_EUMBBAR + 0x102e0)/* Sr. Int. Sr7 Des */
79 #define EPIC_SR_INT7_DES_REG (EPIC_EUMBBAR + 0x102f0)/* Sr. Int. Sr7 Vect.*/ 79 #define EPIC_SR_INT7_DES_REG (EPIC_EUMBBAR + 0x102f0)/* Sr. Int. Sr7 Vect.*/
80 #define EPIC_SR_INT8_VEC_REG (EPIC_EUMBBAR + 0x10300)/* Sr. Int. Sr8 Des */ 80 #define EPIC_SR_INT8_VEC_REG (EPIC_EUMBBAR + 0x10300)/* Sr. Int. Sr8 Des */
81 #define EPIC_SR_INT8_DES_REG (EPIC_EUMBBAR + 0x10310)/* Sr. Int. Sr8 Vect.*/ 81 #define EPIC_SR_INT8_DES_REG (EPIC_EUMBBAR + 0x10310)/* Sr. Int. Sr8 Vect.*/
82 #define EPIC_SR_INT9_VEC_REG (EPIC_EUMBBAR + 0x10320)/* Sr. Int. Sr9 Des */ 82 #define EPIC_SR_INT9_VEC_REG (EPIC_EUMBBAR + 0x10320)/* Sr. Int. Sr9 Des */
83 #define EPIC_SR_INT9_DES_REG (EPIC_EUMBBAR + 0x10330)/* Sr. Int. Sr9 Vect.*/ 83 #define EPIC_SR_INT9_DES_REG (EPIC_EUMBBAR + 0x10330)/* Sr. Int. Sr9 Vect.*/
84 84
85 #define EPIC_SR_INT10_VEC_REG (EPIC_EUMBBAR + 0x10340)/* Sr. Int. Sr10 Des */ 85 #define EPIC_SR_INT10_VEC_REG (EPIC_EUMBBAR + 0x10340)/* Sr. Int. Sr10 Des */
86 #define EPIC_SR_INT10_DES_REG (EPIC_EUMBBAR + 0x10350)/* Sr. Int. Sr10 Vect*/ 86 #define EPIC_SR_INT10_DES_REG (EPIC_EUMBBAR + 0x10350)/* Sr. Int. Sr10 Vect*/
87 #define EPIC_SR_INT11_VEC_REG (EPIC_EUMBBAR + 0x10360)/* Sr. Int. Sr11 Des */ 87 #define EPIC_SR_INT11_VEC_REG (EPIC_EUMBBAR + 0x10360)/* Sr. Int. Sr11 Des */
88 #define EPIC_SR_INT11_DES_REG (EPIC_EUMBBAR + 0x10370)/* Sr. Int. Sr11 Vect*/ 88 #define EPIC_SR_INT11_DES_REG (EPIC_EUMBBAR + 0x10370)/* Sr. Int. Sr11 Vect*/
89 #define EPIC_SR_INT12_VEC_REG (EPIC_EUMBBAR + 0x10380)/* Sr. Int. Sr12 Des */ 89 #define EPIC_SR_INT12_VEC_REG (EPIC_EUMBBAR + 0x10380)/* Sr. Int. Sr12 Des */
90 #define EPIC_SR_INT12_DES_REG (EPIC_EUMBBAR + 0x10390)/* Sr. Int. Sr12 Vect*/ 90 #define EPIC_SR_INT12_DES_REG (EPIC_EUMBBAR + 0x10390)/* Sr. Int. Sr12 Vect*/
91 #define EPIC_SR_INT13_VEC_REG (EPIC_EUMBBAR + 0x103a0)/* Sr. Int. Sr13 Des */ 91 #define EPIC_SR_INT13_VEC_REG (EPIC_EUMBBAR + 0x103a0)/* Sr. Int. Sr13 Des */
92 #define EPIC_SR_INT13_DES_REG (EPIC_EUMBBAR + 0x103b0)/* Sr. Int. Sr13 Vect*/ 92 #define EPIC_SR_INT13_DES_REG (EPIC_EUMBBAR + 0x103b0)/* Sr. Int. Sr13 Vect*/
93 #define EPIC_SR_INT14_VEC_REG (EPIC_EUMBBAR + 0x103c0)/* Sr. Int. Sr14 Des */ 93 #define EPIC_SR_INT14_VEC_REG (EPIC_EUMBBAR + 0x103c0)/* Sr. Int. Sr14 Des */
94 #define EPIC_SR_INT14_DES_REG (EPIC_EUMBBAR + 0x103d0)/* Sr. Int. Sr14 Vect*/ 94 #define EPIC_SR_INT14_DES_REG (EPIC_EUMBBAR + 0x103d0)/* Sr. Int. Sr14 Vect*/
95 #define EPIC_SR_INT15_VEC_REG (EPIC_EUMBBAR + 0x103e0)/* Sr. Int. Sr15 Des */ 95 #define EPIC_SR_INT15_VEC_REG (EPIC_EUMBBAR + 0x103e0)/* Sr. Int. Sr15 Des */
96 #define EPIC_SR_INT15_DES_REG (EPIC_EUMBBAR + 0x103f0)/* Sr. Int. Sr15 Vect*/ 96 #define EPIC_SR_INT15_DES_REG (EPIC_EUMBBAR + 0x103f0)/* Sr. Int. Sr15 Vect*/
97 97
98 #define EPIC_I2C_INT_VEC_REG (EPIC_EUMBBAR + 0x11020)/* I2C Int. Vect Pri.*/ 98 #define EPIC_I2C_INT_VEC_REG (EPIC_EUMBBAR + 0x11020)/* I2C Int. Vect Pri.*/
99 #define EPIC_I2C_INT_DES_REG (EPIC_EUMBBAR + 0x11030)/* I2C Int. Dest */ 99 #define EPIC_I2C_INT_DES_REG (EPIC_EUMBBAR + 0x11030)/* I2C Int. Dest */
100 #define EPIC_DMA0_INT_VEC_REG (EPIC_EUMBBAR + 0x11040)/* DMA0 Int. Vect Pri*/ 100 #define EPIC_DMA0_INT_VEC_REG (EPIC_EUMBBAR + 0x11040)/* DMA0 Int. Vect Pri*/
101 #define EPIC_DMA0_INT_DES_REG (EPIC_EUMBBAR + 0x11050)/* DMA0 Int. Dest */ 101 #define EPIC_DMA0_INT_DES_REG (EPIC_EUMBBAR + 0x11050)/* DMA0 Int. Dest */
102 #define EPIC_DMA1_INT_VEC_REG (EPIC_EUMBBAR + 0x11060)/* DMA1 Int. Vect Pri*/ 102 #define EPIC_DMA1_INT_VEC_REG (EPIC_EUMBBAR + 0x11060)/* DMA1 Int. Vect Pri*/
103 #define EPIC_DMA1_INT_DES_REG (EPIC_EUMBBAR + 0x11070)/* DMA1 Int. Dest */ 103 #define EPIC_DMA1_INT_DES_REG (EPIC_EUMBBAR + 0x11070)/* DMA1 Int. Dest */
104 #define EPIC_MSG_INT_VEC_REG (EPIC_EUMBBAR + 0x110c0)/* Msg Int. Vect Pri*/ 104 #define EPIC_MSG_INT_VEC_REG (EPIC_EUMBBAR + 0x110c0)/* Msg Int. Vect Pri*/
105 #define EPIC_MSG_INT_DES_REG (EPIC_EUMBBAR + 0x110d0)/* Msg Int. Dest */ 105 #define EPIC_MSG_INT_DES_REG (EPIC_EUMBBAR + 0x110d0)/* Msg Int. Dest */
106 106
107 #define EPIC_PROC_CTASK_PRI_REG (EPIC_EUMBBAR + 0x20080)/* Proc. current task*/ 107 #define EPIC_PROC_CTASK_PRI_REG (EPIC_EUMBBAR + 0x20080)/* Proc. current task*/
108 #define EPIC_PROC_INT_ACK_REG (EPIC_EUMBBAR + 0x200a0)/* Int. acknowledge */ 108 #define EPIC_PROC_INT_ACK_REG (EPIC_EUMBBAR + 0x200a0)/* Int. acknowledge */
109 #define EPIC_PROC_EOI_REG (EPIC_EUMBBAR + 0x200b0)/* End of interrupt */ 109 #define EPIC_PROC_EOI_REG (EPIC_EUMBBAR + 0x200b0)/* End of interrupt */
110 110
111 #define EPIC_VEC_PRI_MASK 0x80000000 /* Mask Interrupt bit in IVPR */
112 #define EPIC_VEC_PRI_DFLT_PRI 8 /* Interrupt Priority in IVPR */
113
111 /* Error code */ 114 /* Error code */
112 115
113 #define OK 0 116 #define OK 0
114 #define ERROR -1 117 #define ERROR -1
115 118
116 /* function prototypes */ 119 /* function prototypes */
117 120
118 void epicVendorId( unsigned int *step, 121 void epicVendorId( unsigned int *step,
119 unsigned int *devId, 122 unsigned int *devId,
120 unsigned int *venId 123 unsigned int *venId
121 ); 124 );
122 void epicFeatures( unsigned int *noIRQs, 125 void epicFeatures( unsigned int *noIRQs,
123 unsigned int *noCPUs, 126 unsigned int *noCPUs,
124 unsigned int *VerId ); 127 unsigned int *VerId );
125 extern void epicInit( unsigned int IRQType, unsigned int clkRatio); 128 extern void epicInit( unsigned int IRQType, unsigned int clkRatio);
126 ULONG sysEUMBBARRead ( ULONG regNum ); 129 ULONG sysEUMBBARRead ( ULONG regNum );
127 void sysEUMBBARWrite ( ULONG regNum, ULONG regVal); 130 void sysEUMBBARWrite ( ULONG regNum, ULONG regVal);
128 extern void epicTmFrequencySet( unsigned int frq ); 131 extern void epicTmFrequencySet( unsigned int frq );
129 extern unsigned int epicTmFrequencyGet(void); 132 extern unsigned int epicTmFrequencyGet(void);
130 extern unsigned int epicTmBaseSet( ULONG srcAddr, 133 extern unsigned int epicTmBaseSet( ULONG srcAddr,
131 unsigned int cnt, 134 unsigned int cnt,
132 unsigned int inhibit ); 135 unsigned int inhibit );
133 extern unsigned int epicTmBaseGet ( ULONG srcAddr, unsigned int *val ); 136 extern unsigned int epicTmBaseGet ( ULONG srcAddr, unsigned int *val );
134 extern unsigned int epicTmCountGet( ULONG srcAddr, unsigned int *val ); 137 extern unsigned int epicTmCountGet( ULONG srcAddr, unsigned int *val );
135 extern unsigned int epicTmInhibit( unsigned int timer ); 138 extern unsigned int epicTmInhibit( unsigned int timer );
136 extern unsigned int epicTmEnable( ULONG srcAdr ); 139 extern unsigned int epicTmEnable( ULONG srcAdr );
137 extern void CoreExtIntEnable(void); /* Enable 603e external interrupts */ 140 extern void CoreExtIntEnable(void); /* Enable 603e external interrupts */
138 extern void CoreExtIntDisable(void); /* Disable 603e external interrupts */ 141 extern void CoreExtIntDisable(void); /* Disable 603e external interrupts */
139 extern unsigned char epicIntTaskGet(void); 142 extern unsigned char epicIntTaskGet(void);
140 extern void epicIntTaskSet( unsigned char val ); 143 extern void epicIntTaskSet( unsigned char val );
141 extern unsigned int epicIntAck(void); 144 extern unsigned int epicIntAck(void);
142 extern void epicSprSet( unsigned int eumbbar, unsigned char ); 145 extern void epicSprSet( unsigned int eumbbar, unsigned char );
143 extern void epicConfigGet( unsigned int *clkRatio, 146 extern void epicConfigGet( unsigned int *clkRatio,
144 unsigned int *serEnable ); 147 unsigned int *serEnable );
145 extern void SrcVecTableInit(void); 148 extern void SrcVecTableInit(void);
146 extern unsigned int epicModeGet(void); 149 extern unsigned int epicModeGet(void);
147 extern void epicIntEnable(int Vect); 150 extern void epicIntEnable(int Vect);
148 extern void epicIntDisable(int Vect); 151 extern void epicIntDisable(int Vect);
149 extern int epicIntSourceConfig(int Vect, int Polarity, int Sense, int Prio); 152 extern int epicIntSourceConfig(int Vect, int Polarity, int Sense, int Prio);
150 extern unsigned int epicIntAck(void); 153 extern unsigned int epicIntAck(void);
151 extern void epicEOI(void); 154 extern void epicEOI(void);
152 extern int epicCurTaskPrioSet(int Vect); 155 extern int epicCurTaskPrioSet(int Vect);
153 156
154 struct SrcVecTable 157 struct SrcVecTable
155 { 158 {
156 ULONG srcAddr; 159 ULONG srcAddr;
157 char srcName[40]; 160 char srcName[40];
158 }; 161 };
159 162
160 #endif /* EPIC_H */ 163 #endif /* EPIC_H */
161 164
cpu/mpc824x/drivers/epic/epic1.c
1 /************************************************** 1 /**************************************************
2 * 2 *
3 * copyright @ motorola, 1999 3 * copyright @ motorola, 1999
4 * 4 *
5 *************************************************/ 5 *************************************************/
6 #include <mpc824x.h> 6 #include <mpc824x.h>
7 #include <common.h> 7 #include <common.h>
8 #include "epic.h" 8 #include "epic.h"
9 9
10 10
11 #define PRINT(format, args...) printf(format , ## args) 11 #define PRINT(format, args...) printf(format , ## args)
12 12
13 typedef void (*VOIDFUNCPTR) (void); /* ptr to function returning void */ 13 typedef void (*VOIDFUNCPTR) (void); /* ptr to function returning void */
14 struct SrcVecTable SrcVecTable[MAXVEC] = /* Addr/Vector cross-reference tbl */ 14 struct SrcVecTable SrcVecTable[MAXVEC] = /* Addr/Vector cross-reference tbl */
15 { 15 {
16 { EPIC_EX_INT0_VEC_REG, "External Direct/Serial Source 0"}, 16 { EPIC_EX_INT0_VEC_REG, "External Direct/Serial Source 0"},
17 { EPIC_EX_INT1_VEC_REG, "External Direct/Serial Source 1"}, 17 { EPIC_EX_INT1_VEC_REG, "External Direct/Serial Source 1"},
18 { EPIC_EX_INT2_VEC_REG, "External Direct/Serial Source 2"}, 18 { EPIC_EX_INT2_VEC_REG, "External Direct/Serial Source 2"},
19 { EPIC_EX_INT3_VEC_REG, "External Direct/Serial Source 3"}, 19 { EPIC_EX_INT3_VEC_REG, "External Direct/Serial Source 3"},
20 { EPIC_EX_INT4_VEC_REG, "External Direct/Serial Source 4"}, 20 { EPIC_EX_INT4_VEC_REG, "External Direct/Serial Source 4"},
21 21
22 { EPIC_SR_INT5_VEC_REG, "External Serial Source 5"}, 22 { EPIC_SR_INT5_VEC_REG, "External Serial Source 5"},
23 { EPIC_SR_INT6_VEC_REG, "External Serial Source 6"}, 23 { EPIC_SR_INT6_VEC_REG, "External Serial Source 6"},
24 { EPIC_SR_INT7_VEC_REG, "External Serial Source 7"}, 24 { EPIC_SR_INT7_VEC_REG, "External Serial Source 7"},
25 { EPIC_SR_INT8_VEC_REG, "External Serial Source 8"}, 25 { EPIC_SR_INT8_VEC_REG, "External Serial Source 8"},
26 { EPIC_SR_INT9_VEC_REG, "External Serial Source 9"}, 26 { EPIC_SR_INT9_VEC_REG, "External Serial Source 9"},
27 { EPIC_SR_INT10_VEC_REG, "External Serial Source 10"}, 27 { EPIC_SR_INT10_VEC_REG, "External Serial Source 10"},
28 { EPIC_SR_INT11_VEC_REG, "External Serial Source 11"}, 28 { EPIC_SR_INT11_VEC_REG, "External Serial Source 11"},
29 { EPIC_SR_INT12_VEC_REG, "External Serial Source 12"}, 29 { EPIC_SR_INT12_VEC_REG, "External Serial Source 12"},
30 { EPIC_SR_INT13_VEC_REG, "External Serial Source 13"}, 30 { EPIC_SR_INT13_VEC_REG, "External Serial Source 13"},
31 { EPIC_SR_INT14_VEC_REG, "External Serial Source 14"}, 31 { EPIC_SR_INT14_VEC_REG, "External Serial Source 14"},
32 { EPIC_SR_INT15_VEC_REG, "External Serial Source 15"}, 32 { EPIC_SR_INT15_VEC_REG, "External Serial Source 15"},
33 33
34 { EPIC_I2C_INT_VEC_REG, "Internal I2C Source"}, 34 { EPIC_I2C_INT_VEC_REG, "Internal I2C Source"},
35 { EPIC_DMA0_INT_VEC_REG, "Internal DMA0 Source"}, 35 { EPIC_DMA0_INT_VEC_REG, "Internal DMA0 Source"},
36 { EPIC_DMA1_INT_VEC_REG, "Internal DMA1 Source"}, 36 { EPIC_DMA1_INT_VEC_REG, "Internal DMA1 Source"},
37 { EPIC_MSG_INT_VEC_REG, "Internal Message Source"}, 37 { EPIC_MSG_INT_VEC_REG, "Internal Message Source"},
38 }; 38 };
39 39
40 VOIDFUNCPTR intVecTbl[MAXVEC]; /* Interrupt vector table */ 40 VOIDFUNCPTR intVecTbl[MAXVEC]; /* Interrupt vector table */
41 41
42 42
43 /**************************************************************************** 43 /****************************************************************************
44 * epicInit - Initialize the EPIC registers 44 * epicInit - Initialize the EPIC registers
45 * 45 *
46 * This routine resets the Global Configuration Register, thus it: 46 * This routine resets the Global Configuration Register, thus it:
47 * - Disables all interrupts 47 * - Disables all interrupts
48 * - Sets epic registers to reset values 48 * - Sets epic registers to reset values
49 * - Sets the value of the Processor Current Task Priority to the 49 * - Sets the value of the Processor Current Task Priority to the
50 * highest priority (0xF). 50 * highest priority (0xF).
51 * epicInit then sets the EPIC operation mode to Mixed Mode (vs. Pass 51 * epicInit then sets the EPIC operation mode to Mixed Mode (vs. Pass
52 * Through or 8259 compatible mode). 52 * Through or 8259 compatible mode).
53 * 53 *
54 * If IRQType (input) is Direct IRQs: 54 * If IRQType (input) is Direct IRQs:
55 * - IRQType is written to the SIE bit of the EPIC Interrupt 55 * - IRQType is written to the SIE bit of the EPIC Interrupt
56 * Configuration register (ICR). 56 * Configuration register (ICR).
57 * - clkRatio is ignored. 57 * - clkRatio is ignored.
58 * If IRQType is Serial IRQs: 58 * If IRQType is Serial IRQs:
59 * - both IRQType and clkRatio will be written to the ICR register 59 * - both IRQType and clkRatio will be written to the ICR register
60 */ 60 */
61 61
62 void epicInit 62 void epicInit
63 ( 63 (
64 unsigned int IRQType, /* Direct or Serial */ 64 unsigned int IRQType, /* Direct or Serial */
65 unsigned int clkRatio /* Clk Ratio for Serial IRQs */ 65 unsigned int clkRatio /* Clk Ratio for Serial IRQs */
66 ) 66 )
67 { 67 {
68 ULONG tmp; 68 ULONG tmp;
69 69
70 tmp = sysEUMBBARRead(EPIC_GLOBAL_REG); 70 tmp = sysEUMBBARRead(EPIC_GLOBAL_REG);
71 tmp |= 0xa0000000; /* Set the Global Conf. register */ 71 tmp |= 0xa0000000; /* Set the Global Conf. register */
72 sysEUMBBARWrite(EPIC_GLOBAL_REG, tmp); 72 sysEUMBBARWrite(EPIC_GLOBAL_REG, tmp);
73 /*
74 * Wait for EPIC to reset - CLH
75 */
76 while( (sysEUMBBARRead(EPIC_GLOBAL_REG) & 0x80000000) == 1);
73 sysEUMBBARWrite(EPIC_GLOBAL_REG, 0x20000000); 77 sysEUMBBARWrite(EPIC_GLOBAL_REG, 0x20000000);
74 tmp = sysEUMBBARRead(EPIC_INT_CONF_REG); /* Read interrupt conf. reg */ 78 tmp = sysEUMBBARRead(EPIC_INT_CONF_REG); /* Read interrupt conf. reg */
75 79
76 if (IRQType == EPIC_DIRECT_IRQ) /* direct mode */ 80 if (IRQType == EPIC_DIRECT_IRQ) /* direct mode */
77 sysEUMBBARWrite(EPIC_INT_CONF_REG, tmp & 0xf7ffffff); 81 sysEUMBBARWrite(EPIC_INT_CONF_REG, tmp & 0xf7ffffff);
78 else /* Serial mode */ 82 else /* Serial mode */
79 { 83 {
80 tmp = (clkRatio << 28) | 0x08000000; /* Set clock ratio */ 84 tmp = (clkRatio << 28) | 0x08000000; /* Set clock ratio */
81 sysEUMBBARWrite(EPIC_INT_CONF_REG, tmp); 85 sysEUMBBARWrite(EPIC_INT_CONF_REG, tmp);
82 } 86 }
83 87
84 while (epicIntAck() != 0xff); /* Clear all pending interrupts */ 88 while (epicIntAck() != 0xff) /* Clear all pending interrupts */
89 epicEOI();
85 } 90 }
86 91
87 /**************************************************************************** 92 /****************************************************************************
88 * epicIntEnable - Enable an interrupt source 93 * epicIntEnable - Enable an interrupt source
89 * 94 *
90 * This routine clears the mask bit of an external, an internal or 95 * This routine clears the mask bit of an external, an internal or
91 * a Timer register to enable the interrupt. 96 * a Timer register to enable the interrupt.
92 * 97 *
93 * RETURNS: None 98 * RETURNS: None
94 */ 99 */
95 void epicIntEnable 100 void epicIntEnable(int intVec)
96 ( 101 {
97 int intVec /* Interrupt Vector Number */
98 )
99 {
100 ULONG tmp; 102 ULONG tmp;
101 ULONG srAddr; 103 ULONG srAddr;
102 104
103 srAddr = SrcVecTable[intVec].srcAddr; /* Retrieve src Vec/Prio register */ 105 srAddr = SrcVecTable[intVec].srcAddr; /* Retrieve src Vec/Prio register */
104 tmp = sysEUMBBARRead(srAddr); 106 tmp = sysEUMBBARRead(srAddr);
105 tmp &= 0x7fffffff; /* Clear the mask bit */ 107 tmp &= ~EPIC_VEC_PRI_MASK; /* Clear the mask bit */
108 tmp |= (EPIC_VEC_PRI_DFLT_PRI << 16); /* Set priority to Default - CLH */
109 tmp |= intVec; /* Set Vector number */
106 sysEUMBBARWrite(srAddr, tmp); 110 sysEUMBBARWrite(srAddr, tmp);
111
107 return; 112 return;
108 } 113 }
109 114
110 /**************************************************************************** 115 /****************************************************************************
111 * epicIntDisable - Disable an interrupt source 116 * epicIntDisable - Disable an interrupt source
112 * 117 *
113 * This routine sets the mask bit of an external, an internal or 118 * This routine sets the mask bit of an external, an internal or
114 * a Timer register to disable the interrupt. 119 * a Timer register to disable the interrupt.
115 * 120 *
116 * RETURNS: OK or ERROR 121 * RETURNS: OK or ERROR
117 * 122 *
118 */ 123 */
119 124
120 void epicIntDisable 125 void epicIntDisable
121 ( 126 (
122 int intVec /* Interrupt vector number */ 127 int intVec /* Interrupt vector number */
123 ) 128 )
124 { 129 {
125 130
126 ULONG tmp, srAddr; 131 ULONG tmp, srAddr;
127 132
128 srAddr = SrcVecTable[intVec].srcAddr; 133 srAddr = SrcVecTable[intVec].srcAddr;
129 tmp = sysEUMBBARRead(srAddr); 134 tmp = sysEUMBBARRead(srAddr);
130 tmp |= 0x80000000; /* Set the mask bit */ 135 tmp |= 0x80000000; /* Set the mask bit */
131 sysEUMBBARWrite(srAddr, tmp); 136 sysEUMBBARWrite(srAddr, tmp);
132 return; 137 return;
133 } 138 }
134 139
135 /**************************************************************************** 140 /****************************************************************************
136 * epicIntSourceConfig - Set properties of an interrupt source 141 * epicIntSourceConfig - Set properties of an interrupt source
137 * 142 *
138 * This function sets interrupt properites (Polarity, Sense, Interrupt 143 * This function sets interrupt properites (Polarity, Sense, Interrupt
139 * Prority, and Interrupt Vector) of an Interrupt Source. The properties 144 * Prority, and Interrupt Vector) of an Interrupt Source. The properties
140 * can be set when the current source is not in-request or in-service, 145 * can be set when the current source is not in-request or in-service,
141 * which is determined by the Activity bit. This routine return ERROR 146 * which is determined by the Activity bit. This routine return ERROR
142 * if the the Activity bit is 1 (in-request or in-service). 147 * if the the Activity bit is 1 (in-request or in-service).
143 * 148 *
144 * This function assumes that the Source Vector/Priority register (input) 149 * This function assumes that the Source Vector/Priority register (input)
145 * is a valid address. 150 * is a valid address.
146 * 151 *
147 * RETURNS: OK or ERROR 152 * RETURNS: OK or ERROR
148 */ 153 */
149 154
150 int epicIntSourceConfig 155 int epicIntSourceConfig
151 ( 156 (
152 int Vect, /* interrupt source vector number */ 157 int Vect, /* interrupt source vector number */
153 int Polarity, /* interrupt source polarity */ 158 int Polarity, /* interrupt source polarity */
154 int Sense, /* interrupt source Sense */ 159 int Sense, /* interrupt source Sense */
155 int Prio /* interrupt source priority */ 160 int Prio /* interrupt source priority */
156 ) 161 )
157 162
158 { 163 {
159 ULONG tmp, newVal; 164 ULONG tmp, newVal;
160 ULONG actBit, srAddr; 165 ULONG actBit, srAddr;
161 166
162 srAddr = SrcVecTable[Vect].srcAddr; 167 srAddr = SrcVecTable[Vect].srcAddr;
163 tmp = sysEUMBBARRead(srAddr); 168 tmp = sysEUMBBARRead(srAddr);
164 actBit = (tmp & 40000000) >> 30; /* retrieve activity bit - bit 30 */ 169 actBit = (tmp & 40000000) >> 30; /* retrieve activity bit - bit 30 */
165 if (actBit == 1) 170 if (actBit == 1)
166 return ERROR; 171 return ERROR;
167 172
168 tmp &= 0xff30ff00; /* Erase previously set P,S,Prio,Vector bits */ 173 tmp &= 0xff30ff00; /* Erase previously set P,S,Prio,Vector bits */
169 newVal = (Polarity << 23) | (Sense << 22) | (Prio << 16) | Vect; 174 newVal = (Polarity << 23) | (Sense << 22) | (Prio << 16) | Vect;
170 sysEUMBBARWrite(srAddr, tmp | newVal ); 175 sysEUMBBARWrite(srAddr, tmp | newVal );
171 return (OK); 176 return (OK);
172 } 177 }
173 178
174 /**************************************************************************** 179 /****************************************************************************
175 * epicIntAck - acknowledge an interrupt 180 * epicIntAck - acknowledge an interrupt
176 * 181 *
177 * This function reads the Interrupt acknowldge register and return 182 * This function reads the Interrupt acknowldge register and return
178 * the vector number of the highest pending interrupt. 183 * the vector number of the highest pending interrupt.
179 * 184 *
180 * RETURNS: Interrupt Vector number. 185 * RETURNS: Interrupt Vector number.
181 */ 186 */
182 187
183 unsigned int epicIntAck(void) 188 unsigned int epicIntAck(void)
184 { 189 {
185 return(sysEUMBBARRead( EPIC_PROC_INT_ACK_REG )); 190 return(sysEUMBBARRead( EPIC_PROC_INT_ACK_REG ));
186 } 191 }
187 192
188 /**************************************************************************** 193 /****************************************************************************
189 * epicEOI - signal an end of interrupt 194 * epicEOI - signal an end of interrupt
190 * 195 *
191 * This function writes 0x0 to the EOI register to signal end of interrupt. 196 * This function writes 0x0 to the EOI register to signal end of interrupt.
192 * It is usually called after an interrupt routine is served. 197 * It is usually called after an interrupt routine is served.
193 * 198 *
194 * RETURNS: None 199 * RETURNS: None
195 */ 200 */
196 201
197 void epicEOI(void) 202 void epicEOI(void)
198 { 203 {
199 sysEUMBBARWrite(EPIC_PROC_EOI_REG, 0x0); 204 sysEUMBBARWrite(EPIC_PROC_EOI_REG, 0x0);
200 } 205 }
201 206
202 /**************************************************************************** 207 /****************************************************************************
203 * epicCurTaskPrioSet - sets the priority of the Processor Current Task 208 * epicCurTaskPrioSet - sets the priority of the Processor Current Task
204 * 209 *
205 * This function should be called after epicInit() to lower the priority 210 * This function should be called after epicInit() to lower the priority
206 * of the processor current task. 211 * of the processor current task.
207 * 212 *
208 * RETURNS: OK or ERROR 213 * RETURNS: OK or ERROR
209 */ 214 */
210 215
211 int epicCurTaskPrioSet 216 int epicCurTaskPrioSet
212 ( 217 (
213 int prioNum /* New priority value */ 218 int prioNum /* New priority value */
214 ) 219 )
215 { 220 {
216 221
217 if ( (prioNum < 0) || (prioNum > 0xF)) 222 if ( (prioNum < 0) || (prioNum > 0xF))
218 return ERROR; 223 return ERROR;
219 sysEUMBBARWrite(EPIC_PROC_CTASK_PRI_REG, prioNum); 224 sysEUMBBARWrite(EPIC_PROC_CTASK_PRI_REG, prioNum);
220 return OK; 225 return OK;
221 } 226 }
222 227
223 228
224 /************************************************************************ 229 /************************************************************************
225 * function: epicIntTaskGet 230 * function: epicIntTaskGet
226 * 231 *
227 * description: Get value of processor current interrupt task priority register 232 * description: Get value of processor current interrupt task priority register
228 * 233 *
229 * note: 234 * note:
230 ***********************************************************************/ 235 ***********************************************************************/
231 unsigned char epicIntTaskGet() 236 unsigned char epicIntTaskGet()
232 { 237 {
233 /* get the interrupt task priority register */ 238 /* get the interrupt task priority register */
234 ULONG reg; 239 ULONG reg;
235 unsigned char rec; 240 unsigned char rec;
236 241
237 reg = sysEUMBBARRead( EPIC_PROC_CTASK_PRI_REG ); 242 reg = sysEUMBBARRead( EPIC_PROC_CTASK_PRI_REG );
238 rec = ( reg & 0x0F ); 243 rec = ( reg & 0x0F );
239 return rec; 244 return rec;
240 } 245 }
241 246
242 247
243 /************************************************************** 248 /**************************************************************
244 * function: epicISR 249 * function: epicISR
245 * 250 *
246 * description: EPIC service routine called by the core exception 251 * description: EPIC service routine called by the core exception
247 * at 0x500 252 * at 0x500
248 * 253 *
249 * note: 254 * note:
250 **************************************************************/ 255 **************************************************************/
251 unsigned int epicISR(void) 256 unsigned int epicISR(void)
252 { 257 {
253 return 0; 258 return 0;
254 } 259 }
255 260
256 261
257 /************************************************************ 262 /************************************************************
258 * function: epicModeGet 263 * function: epicModeGet
259 * 264 *
260 * description: query EPIC mode, return 0 if pass through mode 265 * description: query EPIC mode, return 0 if pass through mode
261 * return 1 if mixed mode 266 * return 1 if mixed mode
262 * 267 *
263 * note: 268 * note:
264 *************************************************************/ 269 *************************************************************/
265 unsigned int epicModeGet(void) 270 unsigned int epicModeGet(void)
266 { 271 {
267 ULONG val; 272 ULONG val;
268 273
269 val = sysEUMBBARRead( EPIC_GLOBAL_REG ); 274 val = sysEUMBBARRead( EPIC_GLOBAL_REG );
270 return (( val & 0x20000000 ) >> 29); 275 return (( val & 0x20000000 ) >> 29);
271 } 276 }
272 277
273 278
274 /********************************************* 279 /*********************************************
275 * function: epicConfigGet 280 * function: epicConfigGet
276 * 281 *
277 * description: Get the EPIC interrupt Configuration 282 * description: Get the EPIC interrupt Configuration
278 * return 0 if not error, otherwise return 1 283 * return 0 if not error, otherwise return 1
279 * 284 *
280 * note: 285 * note:
281 ********************************************/ 286 ********************************************/
282 void epicConfigGet( unsigned int *clkRatio, unsigned int *serEnable) 287 void epicConfigGet( unsigned int *clkRatio, unsigned int *serEnable)
283 { 288 {
284 ULONG val; 289 ULONG val;
285 290
286 val = sysEUMBBARRead( EPIC_INT_CONF_REG ); 291 val = sysEUMBBARRead( EPIC_INT_CONF_REG );
287 *clkRatio = ( val & 0x70000000 ) >> 28; 292 *clkRatio = ( val & 0x70000000 ) >> 28;
288 *serEnable = ( val & 0x8000000 ) >> 27; 293 *serEnable = ( val & 0x8000000 ) >> 27;
289 } 294 }
290 295
291 296
292 /******************************************************************* 297 /*******************************************************************
293 * sysEUMBBARRead - Read a 32-bit EUMBBAR register 298 * sysEUMBBARRead - Read a 32-bit EUMBBAR register
294 * 299 *
295 * This routine reads the content of a register in the Embedded 300 * This routine reads the content of a register in the Embedded
296 * Utilities Memory Block, and swaps to big endian before returning 301 * Utilities Memory Block, and swaps to big endian before returning
297 * the value. 302 * the value.
298 * 303 *
299 * RETURNS: The content of the specified EUMBBAR register. 304 * RETURNS: The content of the specified EUMBBAR register.
300 */ 305 */
301 306
302 ULONG sysEUMBBARRead 307 ULONG sysEUMBBARRead
303 ( 308 (
304 ULONG regNum 309 ULONG regNum
305 ) 310 )
306 { 311 {
307 ULONG temp; 312 ULONG temp;
308 313
309 temp = *(ULONG *) (CFG_EUMB_ADDR + regNum); 314 temp = *(ULONG *) (CFG_EUMB_ADDR + regNum);
310 return ( LONGSWAP(temp)); 315 return ( LONGSWAP(temp));
311 } 316 }
312 317
313 /******************************************************************* 318 /*******************************************************************
314 * sysEUMBBARWrite - Write a 32-bit EUMBBAR register 319 * sysEUMBBARWrite - Write a 32-bit EUMBBAR register
315 * 320 *
316 * This routine swaps the value to little endian then writes it to 321 * This routine swaps the value to little endian then writes it to
317 * a register in the Embedded Utilities Memory Block address space. 322 * a register in the Embedded Utilities Memory Block address space.
318 * 323 *
319 * RETURNS: N/A 324 * RETURNS: N/A
320 */ 325 */
321 326
322 void sysEUMBBARWrite 327 void sysEUMBBARWrite
323 ( 328 (
324 ULONG regNum, /* EUMBBAR register address */ 329 ULONG regNum, /* EUMBBAR register address */
325 ULONG regVal /* Value to be written */ 330 ULONG regVal /* Value to be written */
326 ) 331 )
327 { 332 {
328 333
329 *(ULONG *) (CFG_EUMB_ADDR + regNum) = LONGSWAP(regVal); 334 *(ULONG *) (CFG_EUMB_ADDR + regNum) = LONGSWAP(regVal);
330 return ; 335 return ;
331 } 336 }
332 337
333 338
334 /******************************************************** 339 /********************************************************
335 * function: epicVendorId 340 * function: epicVendorId
336 * 341 *
337 * description: return the EPIC Vendor Identification 342 * description: return the EPIC Vendor Identification
338 * register: 343 * register:
339 * 344 *
340 * siliccon version, device id, and vendor id 345 * siliccon version, device id, and vendor id
341 * 346 *
342 * note: 347 * note:
343 ********************************************************/ 348 ********************************************************/
344 void epicVendorId 349 void epicVendorId
345 ( 350 (
346 unsigned int *step, 351 unsigned int *step,
347 unsigned int *devId, 352 unsigned int *devId,
348 unsigned int *venId 353 unsigned int *venId
349 ) 354 )
350 { 355 {
351 ULONG val; 356 ULONG val;
352 val = sysEUMBBARRead( EPIC_VENDOR_ID_REG ); 357 val = sysEUMBBARRead( EPIC_VENDOR_ID_REG );
353 *step = ( val & 0x00FF0000 ) >> 16; 358 *step = ( val & 0x00FF0000 ) >> 16;
354 *devId = ( val & 0x0000FF00 ) >> 8; 359 *devId = ( val & 0x0000FF00 ) >> 8;
355 *venId = ( val & 0x000000FF ); 360 *venId = ( val & 0x000000FF );
356 } 361 }
357 362
358 /************************************************** 363 /**************************************************
359 * function: epicFeatures 364 * function: epicFeatures
360 * 365 *
361 * description: return the number of IRQ supported, 366 * description: return the number of IRQ supported,
362 * number of CPU, and the version of the 367 * number of CPU, and the version of the
363 * OpenEPIC 368 * OpenEPIC
364 * 369 *
365 * note: 370 * note:
366 *************************************************/ 371 *************************************************/
367 void epicFeatures 372 void epicFeatures
368 ( 373 (
369 unsigned int *noIRQs, 374 unsigned int *noIRQs,
370 unsigned int *noCPUs, 375 unsigned int *noCPUs,
371 unsigned int *verId 376 unsigned int *verId
372 ) 377 )
373 { 378 {
374 ULONG val; 379 ULONG val;
375 380
376 val = sysEUMBBARRead( EPIC_FEATURES_REG ); 381 val = sysEUMBBARRead( EPIC_FEATURES_REG );
377 *noIRQs = ( val & 0x07FF0000 ) >> 16; 382 *noIRQs = ( val & 0x07FF0000 ) >> 16;
378 *noCPUs = ( val & 0x00001F00 ) >> 8; 383 *noCPUs = ( val & 0x00001F00 ) >> 8;
379 *verId = ( val & 0x000000FF ); 384 *verId = ( val & 0x000000FF );
380 } 385 }
381 386
382 387
383 /********************************************************* 388 /*********************************************************
384 * function: epciTmFrequncySet 389 * function: epciTmFrequncySet
385 * 390 *
386 * description: Set the timer frequency reporting register 391 * description: Set the timer frequency reporting register
387 ********************************************************/ 392 ********************************************************/
388 void epicTmFrequencySet( unsigned int frq ) 393 void epicTmFrequencySet( unsigned int frq )
389 { 394 {
390 sysEUMBBARWrite(EPIC_TM_FREQ_REG, frq); 395 sysEUMBBARWrite(EPIC_TM_FREQ_REG, frq);
391 } 396 }
392 397
393 /******************************************************* 398 /*******************************************************
394 * function: epicTmFrequncyGet 399 * function: epicTmFrequncyGet
395 * 400 *
396 * description: Get the current value of the Timer Frequency 401 * description: Get the current value of the Timer Frequency
397 * Reporting register 402 * Reporting register
398 * 403 *
399 ******************************************************/ 404 ******************************************************/
400 unsigned int epicTmFrequencyGet(void) 405 unsigned int epicTmFrequencyGet(void)
401 { 406 {
402 return( sysEUMBBARRead(EPIC_TM_FREQ_REG)) ; 407 return( sysEUMBBARRead(EPIC_TM_FREQ_REG)) ;
403 } 408 }
404 409
405 410
406 /**************************************************** 411 /****************************************************
407 * function: epicTmBaseSet 412 * function: epicTmBaseSet
408 * 413 *
409 * description: Set the #n global timer base count register 414 * description: Set the #n global timer base count register
410 * return 0 if no error, otherwise return 1. 415 * return 0 if no error, otherwise return 1.
411 * 416 *
412 * note: 417 * note:
413 ****************************************************/ 418 ****************************************************/
414 unsigned int epicTmBaseSet 419 unsigned int epicTmBaseSet
415 ( 420 (
416 ULONG srcAddr, /* Address of the Timer Base register */ 421 ULONG srcAddr, /* Address of the Timer Base register */
417 unsigned int cnt, /* Base count */ 422 unsigned int cnt, /* Base count */
418 unsigned int inhibit /* 1 - count inhibit */ 423 unsigned int inhibit /* 1 - count inhibit */
419 ) 424 )
420 { 425 {
421 426
422 unsigned int val = 0x80000000; 427 unsigned int val = 0x80000000;
423 /* First inhibit counting the timer */ 428 /* First inhibit counting the timer */
424 sysEUMBBARWrite(srcAddr, val) ; 429 sysEUMBBARWrite(srcAddr, val) ;
425 430
426 /* set the new value */ 431 /* set the new value */
427 val = (cnt & 0x7fffffff) | ((inhibit & 0x1) << 31); 432 val = (cnt & 0x7fffffff) | ((inhibit & 0x1) << 31);
428 sysEUMBBARWrite(srcAddr, val) ; 433 sysEUMBBARWrite(srcAddr, val) ;
429 return 0; 434 return 0;
430 } 435 }
431 436
432 /*********************************************************************** 437 /***********************************************************************
433 * function: epicTmBaseGet 438 * function: epicTmBaseGet
434 * 439 *
435 * description: Get the current value of the global timer base count register 440 * description: Get the current value of the global timer base count register
436 * return 0 if no error, otherwise return 1. 441 * return 0 if no error, otherwise return 1.
437 * 442 *
438 * note: 443 * note:
439 ***********************************************************************/ 444 ***********************************************************************/
440 unsigned int epicTmBaseGet( ULONG srcAddr, unsigned int *val ) 445 unsigned int epicTmBaseGet( ULONG srcAddr, unsigned int *val )
441 { 446 {
442 *val = sysEUMBBARRead( srcAddr ); 447 *val = sysEUMBBARRead( srcAddr );
443 *val = *val & 0x7fffffff; 448 *val = *val & 0x7fffffff;
444 return 0; 449 return 0;
445 } 450 }
446 451
447 /*********************************************************** 452 /***********************************************************
448 * function: epicTmCountGet 453 * function: epicTmCountGet
449 * 454 *
450 * description: Get the value of a given global timer 455 * description: Get the value of a given global timer
451 * current count register 456 * current count register
452 * return 0 if no error, otherwise return 1 457 * return 0 if no error, otherwise return 1
453 * note: 458 * note:
454 **********************************************************/ 459 **********************************************************/
455 unsigned int epicTmCountGet( ULONG srcAddr, unsigned int *val ) 460 unsigned int epicTmCountGet( ULONG srcAddr, unsigned int *val )
456 { 461 {
457 *val = sysEUMBBARRead( srcAddr ); 462 *val = sysEUMBBARRead( srcAddr );
458 *val = *val & 0x7fffffff; 463 *val = *val & 0x7fffffff;
459 return 0; 464 return 0;
460 } 465 }
461 466
462 467
463 468
464 /*********************************************************** 469 /***********************************************************
465 * function: epicTmInhibit 470 * function: epicTmInhibit
466 * 471 *
467 * description: Stop counting of a given global timer 472 * description: Stop counting of a given global timer
468 * return 0 if no error, otherwise return 1 473 * return 0 if no error, otherwise return 1
469 * 474 *
470 * note: 475 * note:
471 ***********************************************************/ 476 ***********************************************************/
472 unsigned int epicTmInhibit( unsigned int srcAddr ) 477 unsigned int epicTmInhibit( unsigned int srcAddr )
473 { 478 {
474 ULONG val; 479 ULONG val;
475 480
476 val = sysEUMBBARRead( srcAddr ); 481 val = sysEUMBBARRead( srcAddr );
477 val |= 0x80000000; 482 val |= 0x80000000;
478 sysEUMBBARWrite( srcAddr, val ); 483 sysEUMBBARWrite( srcAddr, val );
479 return 0; 484 return 0;
480 } 485 }
481 486
482 /****************************************************************** 487 /******************************************************************
483 * function: epicTmEnable 488 * function: epicTmEnable
484 * 489 *
485 * description: Enable counting of a given global timer 490 * description: Enable counting of a given global timer
486 * return 0 if no error, otherwise return 1 491 * return 0 if no error, otherwise return 1
487 * 492 *
488 * note: 493 * note:
489 *****************************************************************/ 494 *****************************************************************/
490 unsigned int epicTmEnable( ULONG srcAddr ) 495 unsigned int epicTmEnable( ULONG srcAddr )
491 { 496 {
492 ULONG val; 497 ULONG val;
493 498
494 val = sysEUMBBARRead( srcAddr ); 499 val = sysEUMBBARRead( srcAddr );
495 val &= 0x7fffffff; 500 val &= 0x7fffffff;
496 sysEUMBBARWrite( srcAddr, val ); 501 sysEUMBBARWrite( srcAddr, val );
497 return 0; 502 return 0;
498 } 503 }
499 504
500 void epicSourcePrint(int Vect) 505 void epicSourcePrint(int Vect)
501 { 506 {
502 ULONG srcVal; 507 ULONG srcVal;
503 508
504 srcVal = sysEUMBBARRead(SrcVecTable[Vect].srcAddr); 509 srcVal = sysEUMBBARRead(SrcVecTable[Vect].srcAddr);
505 PRINT("%s\n", SrcVecTable[Vect].srcName); 510 PRINT("%s\n", SrcVecTable[Vect].srcName);
506 PRINT("Address = 0x%lx\n", SrcVecTable[Vect].srcAddr); 511 PRINT("Address = 0x%lx\n", SrcVecTable[Vect].srcAddr);
507 PRINT("Vector = %ld\n", (srcVal & 0x000000FF) ); 512 PRINT("Vector = %ld\n", (srcVal & 0x000000FF) );
508 PRINT("Mask = %ld\n", srcVal >> 31); 513 PRINT("Mask = %ld\n", srcVal >> 31);
509 PRINT("Activitiy = %ld\n", (srcVal & 40000000) >> 30); 514 PRINT("Activitiy = %ld\n", (srcVal & 40000000) >> 30);
510 PRINT("Polarity = %ld\n", (srcVal & 0x00800000) >> 23); 515 PRINT("Polarity = %ld\n", (srcVal & 0x00800000) >> 23);
511 PRINT("Sense = %ld\n", (srcVal & 0x00400000) >> 22); 516 PRINT("Sense = %ld\n", (srcVal & 0x00400000) >> 22);
cpu/mpc824x/interrupts.c
1 /* 1 /*
2 * (C) Copyright 2000-2002 2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com 4 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com
5 * 5 *
6 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
7 * project. 7 * project.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA 22 * MA 02111-1307 USA
23 */ 23 */
24 24
25 #include <common.h> 25 #include <common.h>
26 #include <mpc824x.h> 26 #include <mpc824x.h>
27 #include <asm/processor.h> 27 #include <asm/processor.h>
28 #include <asm/pci_io.h> 28 #include <asm/pci_io.h>
29 #include <commproc.h> 29 #include <commproc.h>
30 #include "drivers/epic.h" 30 #include "drivers/epic.h"
31 31
32 /****************************************************************************/ 32 /****************************************************************************/
33 33
34 unsigned decrementer_count; /* count val for 1e6/HZ microseconds */ 34 unsigned decrementer_count; /* count val for 1e6/HZ microseconds */
35 35
36 static __inline__ unsigned long get_msr (void) 36 static __inline__ unsigned long get_msr (void)
37 { 37 {
38 unsigned long msr; 38 unsigned long msr;
39 39
40 asm volatile ("mfmsr %0":"=r" (msr):); 40 asm volatile ("mfmsr %0":"=r" (msr):);
41 41
42 return msr; 42 return msr;
43 } 43 }
44 44
45 static __inline__ void set_msr (unsigned long msr) 45 static __inline__ void set_msr (unsigned long msr)
46 { 46 {
47 asm volatile ("mtmsr %0"::"r" (msr)); 47 asm volatile ("mtmsr %0"::"r" (msr));
48 } 48 }
49 49
50 static __inline__ unsigned long get_dec (void) 50 static __inline__ unsigned long get_dec (void)
51 { 51 {
52 unsigned long val; 52 unsigned long val;
53 53
54 asm volatile ("mfdec %0":"=r" (val):); 54 asm volatile ("mfdec %0":"=r" (val):);
55 55
56 return val; 56 return val;
57 } 57 }
58 58
59 59
60 static __inline__ void set_dec (unsigned long val) 60 static __inline__ void set_dec (unsigned long val)
61 { 61 {
62 asm volatile ("mtdec %0"::"r" (val)); 62 asm volatile ("mtdec %0"::"r" (val));
63 } 63 }
64 64
65 65
66 void enable_interrupts (void) 66 void enable_interrupts (void)
67 { 67 {
68 set_msr (get_msr () | MSR_EE); 68 set_msr (get_msr () | MSR_EE);
69 } 69 }
70 70
71 /* returns flag if MSR_EE was set before */ 71 /* returns flag if MSR_EE was set before */
72 int disable_interrupts (void) 72 int disable_interrupts (void)
73 { 73 {
74 ulong msr = get_msr (); 74 ulong msr = get_msr ();
75 75
76 set_msr (msr & ~MSR_EE); 76 set_msr (msr & ~MSR_EE);
77 return ((msr & MSR_EE) != 0); 77 return ((msr & MSR_EE) != 0);
78 } 78 }
79 79
80 /****************************************************************************/ 80 /****************************************************************************/
81 81
82 int interrupt_init (void) 82 int interrupt_init (void)
83 { 83 {
84 decrementer_count = (get_bus_freq (0) / 4) / CFG_HZ; 84 decrementer_count = (get_bus_freq (0) / 4) / CFG_HZ;
85 85
86 /* 86 /*
87 * It's all broken at the moment and I currently don't need 87 * It's all broken at the moment and I currently don't need
88 * interrupts. If you want to fix it, have a look at the epic 88 * interrupts. If you want to fix it, have a look at the epic
89 * drivers in dink32 v12. They do everthing and Motorola said 89 * drivers in dink32 v12. They do everthing and Motorola said
90 * I could use the dink source in this project as long as 90 * I could use the dink source in this project as long as
91 * copyright notices remain intact. 91 * copyright notices remain intact.
92 */ 92 */
93 93
94 epicInit (EPIC_DIRECT_IRQ, 0); 94 epicInit (EPIC_DIRECT_IRQ, 0);
95 /* EPIC won't generate INT unless Current Task Pri < 15 */
96 epicCurTaskPrioSet(0);
95 97
96 set_dec (decrementer_count); 98 set_dec (decrementer_count);
97 99
98 set_msr (get_msr () | MSR_EE); 100 set_msr (get_msr () | MSR_EE);
99 101
100 return (0); 102 return (0);
101 } 103 }
102 104
103 /****************************************************************************/ 105 /****************************************************************************/
104 106
105 /* 107 /*
106 * Handle external interrupts 108 * Handle external interrupts
107 */ 109 */
108 void external_interrupt (struct pt_regs *regs) 110 void external_interrupt (struct pt_regs *regs)
109 { 111 {
110 register unsigned long temp; 112 register unsigned long temp;
111 113
112 pci_readl (CFG_EUMB_ADDR + EPIC_PROC_INT_ACK_REG, temp); 114 pci_readl (CFG_EUMB_ADDR + EPIC_PROC_INT_ACK_REG, temp);
113 sync (); /* i'm not convinced this is needed, but dink source has it */ 115 sync (); /* i'm not convinced this is needed, but dink source has it */
114 temp &= 0xff; /*get vector */ 116 temp &= 0xff; /*get vector */
115 117
116 /*TODO: handle them -... */ 118 /*TODO: handle them -... */
117 epicEOI (); 119 epicEOI ();
118 } 120 }
119 121
120 /****************************************************************************/ 122 /****************************************************************************/
121 123
122 /* 124 /*
123 * blank int handlers. 125 * blank int handlers.
124 */ 126 */
125 127
126 void 128 void
127 irq_install_handler (int vec, interrupt_handler_t * handler, void *arg) 129 irq_install_handler (int vec, interrupt_handler_t * handler, void *arg)
128 { 130 {
129 } 131 }
130 132
131 void irq_free_handler (int vec) 133 void irq_free_handler (int vec)
132 { 134 {
133 135
134 } 136 }
135 137
136 /*TODO: some handlers for winbond and 87308 interrupts 138 /*TODO: some handlers for winbond and 87308 interrupts
137 and what about generic pci inteerupts? 139 and what about generic pci inteerupts?
138 vga? 140 vga?
139 */ 141 */
140 142
141 volatile ulong timestamp = 0; 143 volatile ulong timestamp = 0;
142 144
143 void timer_interrupt (struct pt_regs *regs) 145 void timer_interrupt (struct pt_regs *regs)
144 { 146 {
145 /* Restore Decrementer Count */ 147 /* Restore Decrementer Count */
146 set_dec (decrementer_count); 148 set_dec (decrementer_count);
147 149
148 timestamp++; 150 timestamp++;
149 151
150 #if defined(CONFIG_WATCHDOG) 152 #if defined(CONFIG_WATCHDOG)
151 if ((timestamp % (CFG_HZ / 2)) == 0) { 153 if ((timestamp % (CFG_HZ / 2)) == 0) {
152 #if defined(CONFIG_OXC) 154 #if defined(CONFIG_OXC)
153 { 155 {
154 extern void oxc_wdt_reset (void); 156 extern void oxc_wdt_reset (void);
155 157
156 oxc_wdt_reset (); 158 oxc_wdt_reset ();
157 } 159 }
158 #endif 160 #endif
159 } 161 }
160 #endif /* CONFIG_WATCHDOG */ 162 #endif /* CONFIG_WATCHDOG */
161 #if defined(CONFIG_SHOW_ACTIVITY) && defined(CONFIG_OXC) 163 #if defined(CONFIG_SHOW_ACTIVITY) && defined(CONFIG_OXC)
162 if ((timestamp % (CFG_HZ / 10)) == 0) { 164 if ((timestamp % (CFG_HZ / 10)) == 0) {
163 { 165 {
164 extern void oxc_toggle_activeled (void); 166 extern void oxc_toggle_activeled (void);
165 167
166 oxc_toggle_activeled (); 168 oxc_toggle_activeled ();
167 } 169 }
168 } 170 }
169 #endif 171 #endif
170 } 172 }
171 173
172 void reset_timer (void) 174 void reset_timer (void)
173 { 175 {
174 timestamp = 0; 176 timestamp = 0;
175 } 177 }
176 178
177 ulong get_timer (ulong base) 179 ulong get_timer (ulong base)
178 { 180 {
179 return (timestamp - base); 181 return (timestamp - base);
180 } 182 }
181 183
182 void set_timer (ulong t) 184 void set_timer (ulong t)
183 { 185 {
184 timestamp = t; 186 timestamp = t;
185 } 187 }
186 188
1 /* 1 /*
2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> 2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> 3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de> 4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
5 * 5 *
6 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
7 * project. 7 * project.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA 22 * MA 02111-1307 USA
23 */ 23 */
24 24
25 /* U-Boot - Startup Code for PowerPC based Embedded Boards 25 /* U-Boot - Startup Code for PowerPC based Embedded Boards
26 * 26 *
27 * 27 *
28 * The processor starts at 0x00000100 and the code is executed 28 * The processor starts at 0x00000100 and the code is executed
29 * from flash. The code is organized to be at an other address 29 * from flash. The code is organized to be at an other address
30 * in memory, but as long we don't jump around before relocating. 30 * in memory, but as long we don't jump around before relocating.
31 * board_init lies at a quite high address and when the cpu has 31 * board_init lies at a quite high address and when the cpu has
32 * jumped there, everything is ok. 32 * jumped there, everything is ok.
33 * This works because the cpu gives the FLASH (CS0) the whole 33 * This works because the cpu gives the FLASH (CS0) the whole
34 * address space at startup, and board_init lies as a echo of 34 * address space at startup, and board_init lies as a echo of
35 * the flash somewhere up there in the memorymap. 35 * the flash somewhere up there in the memorymap.
36 * 36 *
37 * board_init will change CS0 to be positioned at the correct 37 * board_init will change CS0 to be positioned at the correct
38 * address and (s)dram will be positioned at address 0 38 * address and (s)dram will be positioned at address 0
39 */ 39 */
40 #include <config.h> 40 #include <config.h>
41 #include <mpc824x.h> 41 #include <mpc824x.h>
42 #include <version.h> 42 #include <version.h>
43 43
44 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ 44 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
45 45
46 #include <ppc_asm.tmpl> 46 #include <ppc_asm.tmpl>
47 #include <ppc_defs.h> 47 #include <ppc_defs.h>
48 48
49 #include <asm/cache.h> 49 #include <asm/cache.h>
50 #include <asm/mmu.h> 50 #include <asm/mmu.h>
51 51
52 #ifndef CONFIG_IDENT_STRING 52 #ifndef CONFIG_IDENT_STRING
53 #define CONFIG_IDENT_STRING "" 53 #define CONFIG_IDENT_STRING ""
54 #endif 54 #endif
55 55
56 /* We don't want the MMU yet. 56 /* We don't want the MMU yet.
57 */ 57 */
58 #undef MSR_KERNEL 58 #undef MSR_KERNEL
59 /* FP, Machine Check and Recoverable Interr. */ 59 /* FP, Machine Check and Recoverable Interr. */
60 #define MSR_KERNEL ( MSR_FP | MSR_ME | MSR_RI ) 60 #define MSR_KERNEL ( MSR_FP | MSR_ME | MSR_RI )
61 61
62 /* 62 /*
63 * Set up GOT: Global Offset Table 63 * Set up GOT: Global Offset Table
64 * 64 *
65 * Use r14 to access the GOT 65 * Use r14 to access the GOT
66 */ 66 */
67 START_GOT 67 START_GOT
68 GOT_ENTRY(_GOT2_TABLE_) 68 GOT_ENTRY(_GOT2_TABLE_)
69 GOT_ENTRY(_FIXUP_TABLE_) 69 GOT_ENTRY(_FIXUP_TABLE_)
70 70
71 GOT_ENTRY(_start) 71 GOT_ENTRY(_start)
72 GOT_ENTRY(_start_of_vectors) 72 GOT_ENTRY(_start_of_vectors)
73 GOT_ENTRY(_end_of_vectors) 73 GOT_ENTRY(_end_of_vectors)
74 GOT_ENTRY(transfer_to_handler) 74 GOT_ENTRY(transfer_to_handler)
75 75
76 GOT_ENTRY(_end) 76 GOT_ENTRY(_end)
77 GOT_ENTRY(.bss) 77 GOT_ENTRY(.bss)
78 #if defined(CONFIG_FADS) 78 #if defined(CONFIG_FADS)
79 GOT_ENTRY(environment) 79 GOT_ENTRY(environment)
80 #endif 80 #endif
81 END_GOT 81 END_GOT
82 82
83 /* 83 /*
84 * r3 - 1st arg to board_init(): IMMP pointer 84 * r3 - 1st arg to board_init(): IMMP pointer
85 * r4 - 2nd arg to board_init(): boot flag 85 * r4 - 2nd arg to board_init(): boot flag
86 */ 86 */
87 .text 87 .text
88 .long 0x27051956 /* U-Boot Magic Number */ 88 .long 0x27051956 /* U-Boot Magic Number */
89 .globl version_string 89 .globl version_string
90 version_string: 90 version_string:
91 .ascii U_BOOT_VERSION 91 .ascii U_BOOT_VERSION
92 .ascii " (", __DATE__, " - ", __TIME__, ")" 92 .ascii " (", __DATE__, " - ", __TIME__, ")"
93 .ascii CONFIG_IDENT_STRING, "\0" 93 .ascii CONFIG_IDENT_STRING, "\0"
94 94
95 . = EXC_OFF_SYS_RESET 95 . = EXC_OFF_SYS_RESET
96 .globl _start 96 .globl _start
97 _start: 97 _start:
98 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */ 98 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */
99 b boot_cold 99 b boot_cold
100 100
101 . = EXC_OFF_SYS_RESET + 0x10 101 . = EXC_OFF_SYS_RESET + 0x10
102 102
103 .globl _start_warm 103 .globl _start_warm
104 _start_warm: 104 _start_warm:
105 li r21, BOOTFLAG_WARM /* Software reboot */ 105 li r21, BOOTFLAG_WARM /* Software reboot */
106 b boot_warm 106 b boot_warm
107 107
108 boot_cold: 108 boot_cold:
109 boot_warm: 109 boot_warm:
110 110
111 /* Initialize machine status; enable machine check interrupt */ 111 /* Initialize machine status; enable machine check interrupt */
112 /*----------------------------------------------------------------------*/ 112 /*----------------------------------------------------------------------*/
113 li r3, MSR_KERNEL /* Set FP, ME, RI flags */ 113 li r3, MSR_KERNEL /* Set FP, ME, RI flags */
114 mtmsr r3 114 mtmsr r3
115 mtspr SRR1, r3 /* Make SRR1 match MSR */ 115 mtspr SRR1, r3 /* Make SRR1 match MSR */
116 116
117 addis r0,0,0x0000 /* lets make sure that r0 is really 0 */ 117 addis r0,0,0x0000 /* lets make sure that r0 is really 0 */
118 mtspr HID0, r0 /* disable I and D caches */ 118 mtspr HID0, r0 /* disable I and D caches */
119 119
120 mfspr r3, ICR /* clear Interrupt Cause Register */ 120 mfspr r3, ICR /* clear Interrupt Cause Register */
121 121
122 mfmsr r3 /* turn off address translation */ 122 mfmsr r3 /* turn off address translation */
123 addis r4,0,0xffff 123 addis r4,0,0xffff
124 ori r4,r4,0xffcf 124 ori r4,r4,0xffcf
125 and r3,r3,r4 125 and r3,r3,r4
126 mtmsr r3 126 mtmsr r3
127 isync 127 isync
128 sync /* the MMU should be off... */ 128 sync /* the MMU should be off... */
129 129
130 130
131 in_flash: 131 in_flash:
132 #if defined(CONFIG_BMW) 132 #if defined(CONFIG_BMW)
133 bl early_init_f /* Must be ASM: no stack yet! */ 133 bl early_init_f /* Must be ASM: no stack yet! */
134 #endif 134 #endif
135 /* 135 /*
136 * Setup BATs - cannot be done in C since we don't have a stack yet 136 * Setup BATs - cannot be done in C since we don't have a stack yet
137 */ 137 */
138 bl setup_bats 138 bl setup_bats
139 139
140 /* Enable MMU. 140 /* Enable MMU.
141 */ 141 */
142 mfmsr r3 142 mfmsr r3
143 ori r3, r3, (MSR_IR | MSR_DR) 143 ori r3, r3, (MSR_IR | MSR_DR)
144 mtmsr r3 144 mtmsr r3
145 #if !defined(CONFIG_BMW) 145 #if !defined(CONFIG_BMW)
146 /* Enable and invalidate data cache. 146 /* Enable and invalidate data cache.
147 */ 147 */
148 mfspr r3, HID0 148 mfspr r3, HID0
149 mr r2, r3 149 mr r2, r3
150 ori r3, r3, HID0_DCE | HID0_DCI 150 ori r3, r3, HID0_DCE | HID0_DCI
151 ori r2, r2, HID0_DCE 151 ori r2, r2, HID0_DCE
152 sync 152 sync
153 mtspr HID0, r3 153 mtspr HID0, r3
154 mtspr HID0, r2 154 mtspr HID0, r2
155 sync 155 sync
156 156
157 /* Allocate Initial RAM in data cache. 157 /* Allocate Initial RAM in data cache.
158 */ 158 */
159 lis r3, CFG_INIT_RAM_ADDR@h 159 lis r3, CFG_INIT_RAM_ADDR@h
160 ori r3, r3, CFG_INIT_RAM_ADDR@l 160 ori r3, r3, CFG_INIT_RAM_ADDR@l
161 li r2, 128 161 li r2, 128
162 mtctr r2 162 mtctr r2
163 1: 163 1:
164 dcbz r0, r3 164 dcbz r0, r3
165 addi r3, r3, 32 165 addi r3, r3, 32
166 bdnz 1b 166 bdnz 1b
167 167
168 /* Lock way0 in data cache. 168 /* Lock way0 in data cache.
169 */ 169 */
170 mfspr r3, 1011 170 mfspr r3, 1011
171 lis r2, 0xffff 171 lis r2, 0xffff
172 ori r2, r2, 0xff1f 172 ori r2, r2, 0xff1f
173 and r3, r3, r2 173 and r3, r3, r2
174 ori r3, r3, 0x0080 174 ori r3, r3, 0x0080
175 sync 175 sync
176 mtspr 1011, r3 176 mtspr 1011, r3
177 #endif /* !CONFIG_BMW */ 177 #endif /* !CONFIG_BMW */
178 /* 178 /*
179 * Thisk the stack pointer *somewhere* sensible. Doesnt 179 * Thisk the stack pointer *somewhere* sensible. Doesnt
180 * matter much where as we'll move it when we relocate 180 * matter much where as we'll move it when we relocate
181 */ 181 */
182 lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h 182 lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h
183 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l 183 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l
184 184
185 li r0, 0 /* Make room for stack frame header and */ 185 li r0, 0 /* Make room for stack frame header and */
186 stwu r0, -4(r1) /* clear final stack frame so that */ 186 stwu r0, -4(r1) /* clear final stack frame so that */
187 stwu r0, -4(r1) /* stack backtraces terminate cleanly */ 187 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
188 188
189 /* let the C-code set up the rest */ 189 /* let the C-code set up the rest */
190 /* */ 190 /* */
191 /* Be careful to keep code relocatable ! */ 191 /* Be careful to keep code relocatable ! */
192 /*----------------------------------------------------------------------*/ 192 /*----------------------------------------------------------------------*/
193 193
194 GET_GOT /* initialize GOT access */ 194 GET_GOT /* initialize GOT access */
195 195
196 /* r3: IMMR */ 196 /* r3: IMMR */
197 bl cpu_init_f /* run low-level CPU init code (from Flash) */ 197 bl cpu_init_f /* run low-level CPU init code (from Flash) */
198 198
199 mr r3, r21 199 mr r3, r21
200 /* r3: BOOTFLAG */ 200 /* r3: BOOTFLAG */
201 bl board_init_f /* run 1st part of board init code (from Flash) */ 201 bl board_init_f /* run 1st part of board init code (from Flash) */
202 202
203 203
204 204
205 .globl _start_of_vectors 205 .globl _start_of_vectors
206 _start_of_vectors: 206 _start_of_vectors:
207 207
208 /* Machine check */ 208 /* Machine check */
209 STD_EXCEPTION(EXC_OFF_MACH_CHCK, MachineCheck, MachineCheckException) 209 STD_EXCEPTION(EXC_OFF_MACH_CHCK, MachineCheck, MachineCheckException)
210 210
211 /* Data Storage exception. "Never" generated on the 860. */ 211 /* Data Storage exception. "Never" generated on the 860. */
212 STD_EXCEPTION(EXC_OFF_DATA_STOR, DataStorage, UnknownException) 212 STD_EXCEPTION(EXC_OFF_DATA_STOR, DataStorage, UnknownException)
213 213
214 /* Instruction Storage exception. "Never" generated on the 860. */ 214 /* Instruction Storage exception. "Never" generated on the 860. */
215 STD_EXCEPTION(EXC_OFF_INS_STOR, InstStorage, UnknownException) 215 STD_EXCEPTION(EXC_OFF_INS_STOR, InstStorage, UnknownException)
216 216
217 /* External Interrupt exception. */ 217 /* External Interrupt exception. */
218 STD_EXCEPTION(EXC_OFF_EXTERNAL, ExtInterrupt, external_interrupt) 218 STD_EXCEPTION(EXC_OFF_EXTERNAL, ExtInterrupt, external_interrupt)
219 219
220 /* Alignment exception. */ 220 /* Alignment exception. */
221 . = EXC_OFF_ALIGN 221 . = EXC_OFF_ALIGN
222 Alignment: 222 Alignment:
223 EXCEPTION_PROLOG 223 EXCEPTION_PROLOG
224 mfspr r4,DAR 224 mfspr r4,DAR
225 stw r4,_DAR(r21) 225 stw r4,_DAR(r21)
226 mfspr r5,DSISR 226 mfspr r5,DSISR
227 stw r5,_DSISR(r21) 227 stw r5,_DSISR(r21)
228 addi r3,r1,STACK_FRAME_OVERHEAD 228 addi r3,r1,STACK_FRAME_OVERHEAD
229 li r20,MSR_KERNEL 229 li r20,MSR_KERNEL
230 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 230 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
231 lwz r6,GOT(transfer_to_handler) 231 lwz r6,GOT(transfer_to_handler)
232 mtlr r6 232 mtlr r6
233 blrl 233 blrl
234 .L_Alignment: 234 .L_Alignment:
235 .long AlignmentException - _start + EXC_OFF_SYS_RESET 235 .long AlignmentException - _start + EXC_OFF_SYS_RESET
236 .long int_return - _start + EXC_OFF_SYS_RESET 236 .long int_return - _start + EXC_OFF_SYS_RESET
237 237
238 /* Program check exception */ 238 /* Program check exception */
239 . = EXC_OFF_PROGRAM 239 . = EXC_OFF_PROGRAM
240 ProgramCheck: 240 ProgramCheck:
241 EXCEPTION_PROLOG 241 EXCEPTION_PROLOG
242 addi r3,r1,STACK_FRAME_OVERHEAD 242 addi r3,r1,STACK_FRAME_OVERHEAD
243 li r20,MSR_KERNEL 243 li r20,MSR_KERNEL
244 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 244 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
245 lwz r6,GOT(transfer_to_handler) 245 lwz r6,GOT(transfer_to_handler)
246 mtlr r6 246 mtlr r6
247 blrl 247 blrl
248 .L_ProgramCheck: 248 .L_ProgramCheck:
249 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET 249 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
250 .long int_return - _start + EXC_OFF_SYS_RESET 250 .long int_return - _start + EXC_OFF_SYS_RESET
251 251
252 /* No FPU on MPC8xx. This exception is not supposed to happen. 252 /* No FPU on MPC8xx. This exception is not supposed to happen.
253 */ 253 */
254 STD_EXCEPTION(EXC_OFF_FPUNAVAIL, FPUnavailable, UnknownException) 254 STD_EXCEPTION(EXC_OFF_FPUNAVAIL, FPUnavailable, UnknownException)
255 255
256 /* I guess we could implement decrementer, and may have 256 /* I guess we could implement decrementer, and may have
257 * to someday for timekeeping. 257 * to someday for timekeeping.
258 */ 258 */
259 STD_EXCEPTION(EXC_OFF_DECR, Decrementer, timer_interrupt) 259 STD_EXCEPTION(EXC_OFF_DECR, Decrementer, timer_interrupt)
260 STD_EXCEPTION(0xa00, Trap_0a, UnknownException) 260 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
261 STD_EXCEPTION(0xb00, Trap_0b, UnknownException) 261 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
262 262
263 . = 0xc00 263 . = 0xc00
264 /* 264 /*
265 * r0 - SYSCALL number 265 * r0 - SYSCALL number
266 * r3-... arguments 266 * r3-... arguments
267 */ 267 */
268 SystemCall: 268 SystemCall:
269 addis r11,r0,0 /* get functions table addr */ 269 addis r11,r0,0 /* get functions table addr */
270 ori r11,r11,0 /* Note: this code is patched in trap_init */ 270 ori r11,r11,0 /* Note: this code is patched in trap_init */
271 addis r12,r0,0 /* get number of functions */ 271 addis r12,r0,0 /* get number of functions */
272 ori r12,r12,0 272 ori r12,r12,0
273 273
274 cmplw 0, r0, r12 274 cmplw 0, r0, r12
275 bge 1f 275 bge 1f
276 276
277 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ 277 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
278 add r11,r11,r0 278 add r11,r11,r0
279 lwz r11,0(r11) 279 lwz r11,0(r11)
280 280
281 li r12,0xd00-4*3 /* save LR & SRRx */ 281 li r20,0xd00-4 /* Get stack pointer */
282 lwz r12,0(r20)
283 subi r12,r12,12 /* Adjust stack pointer */
284 li r0,0xc00+_end_back-SystemCall
285 cmplw 0, r0, r12 /* Check stack overflow */
286 bgt 1f
287 stw r12,0(r20)
288
282 mflr r0 289 mflr r0
283 stw r0,0(r12) 290 stw r0,0(r12)
284 mfspr r0,SRR0 291 mfspr r0,SRR0
285 stw r0,4(r12) 292 stw r0,4(r12)
286 mfspr r0,SRR1 293 mfspr r0,SRR1
287 stw r0,8(r12) 294 stw r0,8(r12)
288 295
289 li r12,0xc00+_back-SystemCall 296 li r12,0xc00+_back-SystemCall
290 mtlr r12 297 mtlr r12
291 mtspr SRR0,r11 298 mtspr SRR0,r11
292 299
293 1: SYNC 300 1: SYNC
294 rfi 301 rfi
295 302
296 _back: 303 _back:
297 304
298 mfmsr r11 /* Disable interrupts */ 305 mfmsr r11 /* Disable interrupts */
299 li r12,0 306 li r12,0
300 ori r12,r12,MSR_EE 307 ori r12,r12,MSR_EE
301 andc r11,r11,r12 308 andc r11,r11,r12
302 SYNC /* Some chip revs need this... */ 309 SYNC /* Some chip revs need this... */
303 mtmsr r11 310 mtmsr r11
304 SYNC 311 SYNC
305 312
306 li r12,0xd00-4*3 /* restore regs */ 313 li r12,0xd00-4 /* restore regs */
314 lwz r12,0(r12)
315
307 lwz r11,0(r12) 316 lwz r11,0(r12)
308 mtlr r11 317 mtlr r11
309 lwz r11,4(r12) 318 lwz r11,4(r12)
310 mtspr SRR0,r11 319 mtspr SRR0,r11
311 lwz r11,8(r12) 320 lwz r11,8(r12)
312 mtspr SRR1,r11 321 mtspr SRR1,r11
313 322
323 addi r12,r12,12 /* Adjust stack pointer */
324 li r20,0xd00-4
325 stw r12,0(r20)
326
314 SYNC 327 SYNC
315 rfi 328 rfi
329 _end_back:
316 330
317 STD_EXCEPTION(EXC_OFF_TRACE, SingleStep, UnknownException) 331 STD_EXCEPTION(EXC_OFF_TRACE, SingleStep, UnknownException)
318 332
319 STD_EXCEPTION(EXC_OFF_FPUNASSIST, Trap_0e, UnknownException) 333 STD_EXCEPTION(EXC_OFF_FPUNASSIST, Trap_0e, UnknownException)
320 STD_EXCEPTION(EXC_OFF_PMI, Trap_0f, UnknownException) 334 STD_EXCEPTION(EXC_OFF_PMI, Trap_0f, UnknownException)
321 335
322 STD_EXCEPTION(EXC_OFF_ITME, InstructionTransMiss, UnknownException) 336 STD_EXCEPTION(EXC_OFF_ITME, InstructionTransMiss, UnknownException)
323 STD_EXCEPTION(EXC_OFF_DLTME, DataLoadTransMiss, UnknownException) 337 STD_EXCEPTION(EXC_OFF_DLTME, DataLoadTransMiss, UnknownException)
324 STD_EXCEPTION(EXC_OFF_DSTME, DataStoreTransMiss, UnknownException) 338 STD_EXCEPTION(EXC_OFF_DSTME, DataStoreTransMiss, UnknownException)
325 STD_EXCEPTION(EXC_OFF_IABE, InstructionBreakpoint, UnknownException) 339 STD_EXCEPTION(EXC_OFF_IABE, InstructionBreakpoint, UnknownException)
326 STD_EXCEPTION(EXC_OFF_SMIE, SysManageInt, UnknownException) 340 STD_EXCEPTION(EXC_OFF_SMIE, SysManageInt, UnknownException)
327 STD_EXCEPTION(0x1500, Reserved5, UnknownException) 341 STD_EXCEPTION(0x1500, Reserved5, UnknownException)
328 STD_EXCEPTION(0x1600, Reserved6, UnknownException) 342 STD_EXCEPTION(0x1600, Reserved6, UnknownException)
329 STD_EXCEPTION(0x1700, Reserved7, UnknownException) 343 STD_EXCEPTION(0x1700, Reserved7, UnknownException)
330 STD_EXCEPTION(0x1800, Reserved8, UnknownException) 344 STD_EXCEPTION(0x1800, Reserved8, UnknownException)
331 STD_EXCEPTION(0x1900, Reserved9, UnknownException) 345 STD_EXCEPTION(0x1900, Reserved9, UnknownException)
332 STD_EXCEPTION(0x1a00, ReservedA, UnknownException) 346 STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
333 STD_EXCEPTION(0x1b00, ReservedB, UnknownException) 347 STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
334 STD_EXCEPTION(0x1c00, ReservedC, UnknownException) 348 STD_EXCEPTION(0x1c00, ReservedC, UnknownException)
335 STD_EXCEPTION(0x1d00, ReservedD, UnknownException) 349 STD_EXCEPTION(0x1d00, ReservedD, UnknownException)
336 STD_EXCEPTION(0x1e00, ReservedE, UnknownException) 350 STD_EXCEPTION(0x1e00, ReservedE, UnknownException)
337 STD_EXCEPTION(0x1f00, ReservedF, UnknownException) 351 STD_EXCEPTION(0x1f00, ReservedF, UnknownException)
338 352
339 STD_EXCEPTION(EXC_OFF_RMTE, RunModeTrace, UnknownException) 353 STD_EXCEPTION(EXC_OFF_RMTE, RunModeTrace, UnknownException)
340 354
341 .globl _end_of_vectors 355 .globl _end_of_vectors
342 _end_of_vectors: 356 _end_of_vectors:
343 357
344 358
345 . = 0x3000 359 . = 0x3000
346 360
347 /* 361 /*
348 * This code finishes saving the registers to the exception frame 362 * This code finishes saving the registers to the exception frame
349 * and jumps to the appropriate handler for the exception. 363 * and jumps to the appropriate handler for the exception.
350 * Register r21 is pointer into trap frame, r1 has new stack pointer. 364 * Register r21 is pointer into trap frame, r1 has new stack pointer.
351 */ 365 */
352 .globl transfer_to_handler 366 .globl transfer_to_handler
353 transfer_to_handler: 367 transfer_to_handler:
354 stw r22,_NIP(r21) 368 stw r22,_NIP(r21)
355 lis r22,MSR_POW@h 369 lis r22,MSR_POW@h
356 andc r23,r23,r22 370 andc r23,r23,r22
357 stw r23,_MSR(r21) 371 stw r23,_MSR(r21)
358 SAVE_GPR(7, r21) 372 SAVE_GPR(7, r21)
359 SAVE_4GPRS(8, r21) 373 SAVE_4GPRS(8, r21)
360 SAVE_8GPRS(12, r21) 374 SAVE_8GPRS(12, r21)
361 SAVE_8GPRS(24, r21) 375 SAVE_8GPRS(24, r21)
362 #if 0 376 #if 0
363 andi. r23,r23,MSR_PR 377 andi. r23,r23,MSR_PR
364 mfspr r23,SPRG3 /* if from user, fix up tss.regs */ 378 mfspr r23,SPRG3 /* if from user, fix up tss.regs */
365 beq 2f 379 beq 2f
366 addi r24,r1,STACK_FRAME_OVERHEAD 380 addi r24,r1,STACK_FRAME_OVERHEAD
367 stw r24,PT_REGS(r23) 381 stw r24,PT_REGS(r23)
368 2: addi r2,r23,-TSS /* set r2 to current */ 382 2: addi r2,r23,-TSS /* set r2 to current */
369 tovirt(r2,r2,r23) 383 tovirt(r2,r2,r23)
370 #endif 384 #endif
371 mflr r23 385 mflr r23
372 andi. r24,r23,0x3f00 /* get vector offset */ 386 andi. r24,r23,0x3f00 /* get vector offset */
373 stw r24,TRAP(r21) 387 stw r24,TRAP(r21)
374 li r22,0 388 li r22,0
375 stw r22,RESULT(r21) 389 stw r22,RESULT(r21)
376 mtspr SPRG2,r22 /* r1 is now kernel sp */ 390 mtspr SPRG2,r22 /* r1 is now kernel sp */
377 #if 0 391 #if 0
378 addi r24,r2,TASK_STRUCT_SIZE /* check for kernel stack overflow */ 392 addi r24,r2,TASK_STRUCT_SIZE /* check for kernel stack overflow */
379 cmplw 0,r1,r2 393 cmplw 0,r1,r2
380 cmplw 1,r1,r24 394 cmplw 1,r1,r24
381 crand 1,1,4 395 crand 1,1,4
382 bgt stack_ovf /* if r2 < r1 < r2+TASK_STRUCT_SIZE */ 396 bgt stack_ovf /* if r2 < r1 < r2+TASK_STRUCT_SIZE */
383 #endif 397 #endif
384 lwz r24,0(r23) /* virtual address of handler */ 398 lwz r24,0(r23) /* virtual address of handler */
385 lwz r23,4(r23) /* where to go when done */ 399 lwz r23,4(r23) /* where to go when done */
386 mtspr SRR0,r24 400 mtspr SRR0,r24
387 ori r20,r20,0x30 /* enable IR, DR */ 401 ori r20,r20,0x30 /* enable IR, DR */
388 mtspr SRR1,r20 402 mtspr SRR1,r20
389 mtlr r23 403 mtlr r23
390 SYNC 404 SYNC
391 rfi /* jump to handler, enable MMU */ 405 rfi /* jump to handler, enable MMU */
392 406
393 int_return: 407 int_return:
394 mfmsr r28 /* Disable interrupts */ 408 mfmsr r28 /* Disable interrupts */
395 li r4,0 409 li r4,0
396 ori r4,r4,MSR_EE 410 ori r4,r4,MSR_EE
397 andc r28,r28,r4 411 andc r28,r28,r4
398 SYNC /* Some chip revs need this... */ 412 SYNC /* Some chip revs need this... */
399 mtmsr r28 413 mtmsr r28
400 SYNC 414 SYNC
401 lwz r2,_CTR(r1) 415 lwz r2,_CTR(r1)
402 lwz r0,_LINK(r1) 416 lwz r0,_LINK(r1)
403 mtctr r2 417 mtctr r2
404 mtlr r0 418 mtlr r0
405 lwz r2,_XER(r1) 419 lwz r2,_XER(r1)
406 lwz r0,_CCR(r1) 420 lwz r0,_CCR(r1)
407 mtspr XER,r2 421 mtspr XER,r2
408 mtcrf 0xFF,r0 422 mtcrf 0xFF,r0
409 REST_10GPRS(3, r1) 423 REST_10GPRS(3, r1)
410 REST_10GPRS(13, r1) 424 REST_10GPRS(13, r1)
411 REST_8GPRS(23, r1) 425 REST_8GPRS(23, r1)
412 REST_GPR(31, r1) 426 REST_GPR(31, r1)
413 lwz r2,_NIP(r1) /* Restore environment */ 427 lwz r2,_NIP(r1) /* Restore environment */
414 lwz r0,_MSR(r1) 428 lwz r0,_MSR(r1)
415 mtspr SRR0,r2 429 mtspr SRR0,r2
416 mtspr SRR1,r0 430 mtspr SRR1,r0
417 lwz r0,GPR0(r1) 431 lwz r0,GPR0(r1)
418 lwz r2,GPR2(r1) 432 lwz r2,GPR2(r1)
419 lwz r1,GPR1(r1) 433 lwz r1,GPR1(r1)
420 SYNC 434 SYNC
421 rfi 435 rfi
422 436
423 /* Cache functions. 437 /* Cache functions.
424 */ 438 */
425 .globl icache_enable 439 .globl icache_enable
426 icache_enable: 440 icache_enable:
427 mfspr r5,HID0 /* turn on the I cache. */ 441 mfspr r5,HID0 /* turn on the I cache. */
428 ori r5,r5,0x8800 /* Instruction cache only! */ 442 ori r5,r5,0x8800 /* Instruction cache only! */
429 addis r6,0,0xFFFF 443 addis r6,0,0xFFFF
430 ori r6,r6,0xF7FF 444 ori r6,r6,0xF7FF
431 and r6,r5,r6 /* clear the invalidate bit */ 445 and r6,r5,r6 /* clear the invalidate bit */
432 sync 446 sync
433 mtspr HID0,r5 447 mtspr HID0,r5
434 mtspr HID0,r6 448 mtspr HID0,r6
435 isync 449 isync
436 sync 450 sync
437 blr 451 blr
438 452
439 .globl icache_disable 453 .globl icache_disable
440 icache_disable: 454 icache_disable:
441 mfspr r5,HID0 455 mfspr r5,HID0
442 addis r6,0,0xFFFF 456 addis r6,0,0xFFFF
443 ori r6,r6,0x7FFF 457 ori r6,r6,0x7FFF
444 and r5,r5,r6 458 and r5,r5,r6
445 sync 459 sync
446 mtspr HID0,r5 460 mtspr HID0,r5
447 isync 461 isync
448 sync 462 sync
449 blr 463 blr
450 464
451 .globl icache_status 465 .globl icache_status
452 icache_status: 466 icache_status:
453 mfspr r3, HID0 467 mfspr r3, HID0
454 srwi r3, r3, 15 /* >>15 & 1=> select bit 16 */ 468 srwi r3, r3, 15 /* >>15 & 1=> select bit 16 */
455 andi. r3, r3, 1 469 andi. r3, r3, 1
456 blr 470 blr
457 471
458 .globl dcache_enable 472 .globl dcache_enable
459 dcache_enable: 473 dcache_enable:
460 mfspr r5,HID0 /* turn on the D cache. */ 474 mfspr r5,HID0 /* turn on the D cache. */
461 ori r5,r5,0x4400 /* Data cache only! */ 475 ori r5,r5,0x4400 /* Data cache only! */
462 mfspr r4, PVR /* read PVR */ 476 mfspr r4, PVR /* read PVR */
463 srawi r3, r4, 16 /* shift off the least 16 bits */ 477 srawi r3, r4, 16 /* shift off the least 16 bits */
464 cmpi 0, 0, r3, 0xC /* Check for Max pvr */ 478 cmpi 0, 0, r3, 0xC /* Check for Max pvr */
465 bne NotMax 479 bne NotMax
466 ori r5,r5,0x0040 /* setting the DCFA bit, for Max rev 1 errata */ 480 ori r5,r5,0x0040 /* setting the DCFA bit, for Max rev 1 errata */
467 NotMax: 481 NotMax:
468 addis r6,0,0xFFFF 482 addis r6,0,0xFFFF
469 ori r6,r6,0xFBFF 483 ori r6,r6,0xFBFF
470 and r6,r5,r6 /* clear the invalidate bit */ 484 and r6,r5,r6 /* clear the invalidate bit */
471 sync 485 sync
472 mtspr HID0,r5 486 mtspr HID0,r5
473 mtspr HID0,r6 487 mtspr HID0,r6
474 isync 488 isync
475 sync 489 sync
476 blr 490 blr
477 491
478 .globl dcache_disable 492 .globl dcache_disable
479 dcache_disable: 493 dcache_disable:
480 mfspr r5,HID0 494 mfspr r5,HID0
481 addis r6,0,0xFFFF 495 addis r6,0,0xFFFF
482 ori r6,r6,0xBFFF 496 ori r6,r6,0xBFFF
483 and r5,r5,r6 497 and r5,r5,r6
484 sync 498 sync
485 mtspr HID0,r5 499 mtspr HID0,r5
486 isync 500 isync
487 sync 501 sync
488 blr 502 blr
489 503
490 .globl dcache_status 504 .globl dcache_status
491 dcache_status: 505 dcache_status:
492 mfspr r3, HID0 506 mfspr r3, HID0
493 srwi r3, r3, 14 /* >>14 & 1=> select bit 17 */ 507 srwi r3, r3, 14 /* >>14 & 1=> select bit 17 */
494 andi. r3, r3, 1 508 andi. r3, r3, 1
495 blr 509 blr
496 510
497 .globl dc_read 511 .globl dc_read
498 dc_read: 512 dc_read:
499 /*TODO : who uses this, what should it do? 513 /*TODO : who uses this, what should it do?
500 */ 514 */
501 blr 515 blr
502 516
503 517
504 .globl get_pvr 518 .globl get_pvr
505 get_pvr: 519 get_pvr:
506 mfspr r3, PVR 520 mfspr r3, PVR
507 blr 521 blr
508 522
509 523
510 /*------------------------------------------------------------------------------*/ 524 /*------------------------------------------------------------------------------*/
511 525
512 /* 526 /*
513 * void relocate_code (addr_sp, gd, addr_moni) 527 * void relocate_code (addr_sp, gd, addr_moni)
514 * 528 *
515 * This "function" does not return, instead it continues in RAM 529 * This "function" does not return, instead it continues in RAM
516 * after relocating the monitor code. 530 * after relocating the monitor code.
517 * 531 *
518 * r3 = dest 532 * r3 = dest
519 * r4 = src 533 * r4 = src
520 * r5 = length in bytes 534 * r5 = length in bytes
521 * r6 = cachelinesize 535 * r6 = cachelinesize
522 */ 536 */
523 .globl relocate_code 537 .globl relocate_code
524 relocate_code: 538 relocate_code:
525 539
526 mr r1, r3 /* Set new stack pointer */ 540 mr r1, r3 /* Set new stack pointer */
527 mr r9, r4 /* Save copy of Global Data pointer */ 541 mr r9, r4 /* Save copy of Global Data pointer */
528 mr r10, r5 /* Save copy of Destination Address */ 542 mr r10, r5 /* Save copy of Destination Address */
529 543
530 mr r3, r5 /* Destination Address */ 544 mr r3, r5 /* Destination Address */
531 #ifdef DEBUG 545 #ifdef DEBUG
532 lis r4, CFG_SDRAM_BASE@h /* Source Address */ 546 lis r4, CFG_SDRAM_BASE@h /* Source Address */
533 ori r4, r4, CFG_SDRAM_BASE@l 547 ori r4, r4, CFG_SDRAM_BASE@l
534 #else 548 #else
535 lis r4, CFG_MONITOR_BASE@h /* Source Address */ 549 lis r4, CFG_MONITOR_BASE@h /* Source Address */
536 ori r4, r4, CFG_MONITOR_BASE@l 550 ori r4, r4, CFG_MONITOR_BASE@l
537 #endif 551 #endif
538 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */ 552 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */
539 ori r5, r5, CFG_MONITOR_LEN@l 553 ori r5, r5, CFG_MONITOR_LEN@l
540 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */ 554 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
541 555
542 /* 556 /*
543 * Fix GOT pointer: 557 * Fix GOT pointer:
544 * 558 *
545 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address 559 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
546 * 560 *
547 * Offset: 561 * Offset:
548 */ 562 */
549 sub r15, r10, r4 563 sub r15, r10, r4
550 564
551 /* First our own GOT */ 565 /* First our own GOT */
552 add r14, r14, r15 566 add r14, r14, r15
553 /* the the one used by the C code */ 567 /* the the one used by the C code */
554 add r30, r30, r15 568 add r30, r30, r15
555 569
556 /* 570 /*
557 * Now relocate code 571 * Now relocate code
558 */ 572 */
559 573
560 cmplw cr1,r3,r4 574 cmplw cr1,r3,r4
561 addi r0,r5,3 575 addi r0,r5,3
562 srwi. r0,r0,2 576 srwi. r0,r0,2
563 beq cr1,4f /* In place copy is not necessary */ 577 beq cr1,4f /* In place copy is not necessary */
564 beq 7f /* Protect against 0 count */ 578 beq 7f /* Protect against 0 count */
565 mtctr r0 579 mtctr r0
566 bge cr1,2f 580 bge cr1,2f
567 581
568 la r8,-4(r4) 582 la r8,-4(r4)
569 la r7,-4(r3) 583 la r7,-4(r3)
570 1: lwzu r0,4(r8) 584 1: lwzu r0,4(r8)
571 stwu r0,4(r7) 585 stwu r0,4(r7)
572 bdnz 1b 586 bdnz 1b
573 b 4f 587 b 4f
574 588
575 2: slwi r0,r0,2 589 2: slwi r0,r0,2
576 add r8,r4,r0 590 add r8,r4,r0
577 add r7,r3,r0 591 add r7,r3,r0
578 3: lwzu r0,-4(r8) 592 3: lwzu r0,-4(r8)
579 stwu r0,-4(r7) 593 stwu r0,-4(r7)
580 bdnz 3b 594 bdnz 3b
581 595
582 /* 596 /*
583 * Now flush the cache: note that we must start from a cache aligned 597 * Now flush the cache: note that we must start from a cache aligned
584 * address. Otherwise we might miss one cache line. 598 * address. Otherwise we might miss one cache line.
585 */ 599 */
586 4: cmpwi r6,0 600 4: cmpwi r6,0
587 add r5,r3,r5 601 add r5,r3,r5
588 beq 7f /* Always flush prefetch queue in any case */ 602 beq 7f /* Always flush prefetch queue in any case */
589 subi r0,r6,1 603 subi r0,r6,1
590 andc r3,r3,r0 604 andc r3,r3,r0
591 mr r4,r3 605 mr r4,r3
592 5: dcbst 0,r4 606 5: dcbst 0,r4
593 add r4,r4,r6 607 add r4,r4,r6
594 cmplw r4,r5 608 cmplw r4,r5
595 blt 5b 609 blt 5b
596 sync /* Wait for all dcbst to complete on bus */ 610 sync /* Wait for all dcbst to complete on bus */
597 mr r4,r3 611 mr r4,r3
598 6: icbi 0,r4 612 6: icbi 0,r4
599 add r4,r4,r6 613 add r4,r4,r6
600 cmplw r4,r5 614 cmplw r4,r5
601 blt 6b 615 blt 6b
602 7: sync /* Wait for all icbi to complete on bus */ 616 7: sync /* Wait for all icbi to complete on bus */
603 isync 617 isync
604 618
605 /* 619 /*
606 * We are done. Do not return, instead branch to second part of board 620 * We are done. Do not return, instead branch to second part of board
607 * initialization, now running from RAM. 621 * initialization, now running from RAM.
608 */ 622 */
609 623
610 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET 624 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
611 mtlr r0 625 mtlr r0
612 blr 626 blr
613 627
614 in_ram: 628 in_ram:
615 629
616 /* 630 /*
617 * Relocation Function, r14 point to got2+0x8000 631 * Relocation Function, r14 point to got2+0x8000
618 * 632 *
619 * Adjust got2 pointers, no need to check for 0, this code 633 * Adjust got2 pointers, no need to check for 0, this code
620 * already puts a few entries in the table. 634 * already puts a few entries in the table.
621 */ 635 */
622 li r0,__got2_entries@sectoff@l 636 li r0,__got2_entries@sectoff@l
623 la r3,GOT(_GOT2_TABLE_) 637 la r3,GOT(_GOT2_TABLE_)
624 lwz r11,GOT(_GOT2_TABLE_) 638 lwz r11,GOT(_GOT2_TABLE_)
625 mtctr r0 639 mtctr r0
626 sub r11,r3,r11 640 sub r11,r3,r11
627 addi r3,r3,-4 641 addi r3,r3,-4
628 1: lwzu r0,4(r3) 642 1: lwzu r0,4(r3)
629 add r0,r0,r11 643 add r0,r0,r11
630 stw r0,0(r3) 644 stw r0,0(r3)
631 bdnz 1b 645 bdnz 1b
632 646
633 /* 647 /*
634 * Now adjust the fixups and the pointers to the fixups 648 * Now adjust the fixups and the pointers to the fixups
635 * in case we need to move ourselves again. 649 * in case we need to move ourselves again.
636 */ 650 */
637 2: li r0,__fixup_entries@sectoff@l 651 2: li r0,__fixup_entries@sectoff@l
638 lwz r3,GOT(_FIXUP_TABLE_) 652 lwz r3,GOT(_FIXUP_TABLE_)
639 cmpwi r0,0 653 cmpwi r0,0
640 mtctr r0 654 mtctr r0
641 addi r3,r3,-4 655 addi r3,r3,-4
642 beq 4f 656 beq 4f
643 3: lwzu r4,4(r3) 657 3: lwzu r4,4(r3)
644 lwzux r0,r4,r11 658 lwzux r0,r4,r11
645 add r0,r0,r11 659 add r0,r0,r11
646 stw r10,0(r3) 660 stw r10,0(r3)
647 stw r0,0(r4) 661 stw r0,0(r4)
648 bdnz 3b 662 bdnz 3b
649 4: 663 4:
650 clear_bss: 664 clear_bss:
651 /* 665 /*
652 * Now clear BSS segment 666 * Now clear BSS segment
653 */ 667 */
654 lwz r3,GOT(.bss) 668 lwz r3,GOT(.bss)
655 lwz r4,GOT(_end) 669 lwz r4,GOT(_end)
656 670
657 cmplw 0, r3, r4 671 cmplw 0, r3, r4
658 beq 6f 672 beq 6f
659 673
660 li r0, 0 674 li r0, 0
661 5: 675 5:
662 stw r0, 0(r3) 676 stw r0, 0(r3)
663 addi r3, r3, 4 677 addi r3, r3, 4
664 cmplw 0, r3, r4 678 cmplw 0, r3, r4
665 blt 5b 679 blt 5b
666 6: 680 6:
667 681
668 mr r3, r9 /* Global Data pointer */ 682 mr r3, r9 /* Global Data pointer */
669 mr r4, r10 /* Destination Address */ 683 mr r4, r10 /* Destination Address */
670 bl board_init_r 684 bl board_init_r
671 685
672 /* Problems accessing "end" in C, so do it here */ 686 /* Problems accessing "end" in C, so do it here */
673 .globl get_endaddr 687 .globl get_endaddr
674 get_endaddr: 688 get_endaddr:
675 lwz r3,GOT(_end) 689 lwz r3,GOT(_end)
676 blr 690 blr
677 691
678 /* 692 /*
679 * Copy exception vector code to low memory 693 * Copy exception vector code to low memory
680 * 694 *
681 * r3: dest_addr 695 * r3: dest_addr
682 * r7: source address, r8: end address, r9: target address 696 * r7: source address, r8: end address, r9: target address
683 */ 697 */
684 .globl trap_init 698 .globl trap_init
685 trap_init: 699 trap_init:
686 lwz r7, GOT(_start) 700 lwz r7, GOT(_start)
687 lwz r8, GOT(_end_of_vectors) 701 lwz r8, GOT(_end_of_vectors)
688 702
689 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */ 703 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
690 704
691 cmplw 0, r7, r8 705 cmplw 0, r7, r8
692 bgelr /* return if r7>=r8 - just in case */ 706 bgelr /* return if r7>=r8 - just in case */
693 707
694 mflr r4 /* save link register */ 708 mflr r4 /* save link register */
695 1: 709 1:
696 lwz r0, 0(r7) 710 lwz r0, 0(r7)
697 stw r0, 0(r9) 711 stw r0, 0(r9)
698 addi r7, r7, 4 712 addi r7, r7, 4
699 addi r9, r9, 4 713 addi r9, r9, 4
700 cmplw 0, r7, r8 714 cmplw 0, r7, r8
701 bne 1b 715 bne 1b
702 716
703 /* 717 /*
704 * relocate `hdlr' and `int_return' entries 718 * relocate `hdlr' and `int_return' entries
705 */ 719 */
706 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET 720 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
707 li r8, Alignment - _start + EXC_OFF_SYS_RESET 721 li r8, Alignment - _start + EXC_OFF_SYS_RESET
708 2: 722 2:
709 bl trap_reloc 723 bl trap_reloc
710 addi r7, r7, 0x100 /* next exception vector */ 724 addi r7, r7, 0x100 /* next exception vector */
711 cmplw 0, r7, r8 725 cmplw 0, r7, r8
712 blt 2b 726 blt 2b
713 727
714 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET 728 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
715 bl trap_reloc 729 bl trap_reloc
716 730
717 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET 731 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
718 bl trap_reloc 732 bl trap_reloc
719 733
720 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET 734 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
721 li r8, SystemCall - _start + EXC_OFF_SYS_RESET 735 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
722 3: 736 3:
723 bl trap_reloc 737 bl trap_reloc
724 addi r7, r7, 0x100 /* next exception vector */ 738 addi r7, r7, 0x100 /* next exception vector */
725 cmplw 0, r7, r8 739 cmplw 0, r7, r8
726 blt 3b 740 blt 3b
727 741
728 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET 742 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
729 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET 743 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
730 4: 744 4:
731 bl trap_reloc 745 bl trap_reloc
732 addi r7, r7, 0x100 /* next exception vector */ 746 addi r7, r7, 0x100 /* next exception vector */
733 cmplw 0, r7, r8 747 cmplw 0, r7, r8
734 blt 4b 748 blt 4b
735 749
736 mtlr r4 /* restore link register */ 750 mtlr r4 /* restore link register */
737 blr 751 blr
738 752
739 /* 753 /*
740 * Function: relocate entries for one exception vector 754 * Function: relocate entries for one exception vector
741 */ 755 */
742 trap_reloc: 756 trap_reloc:
743 lwz r0, 0(r7) /* hdlr ... */ 757 lwz r0, 0(r7) /* hdlr ... */
744 add r0, r0, r3 /* ... += dest_addr */ 758 add r0, r0, r3 /* ... += dest_addr */
745 stw r0, 0(r7) 759 stw r0, 0(r7)
746 760
747 lwz r0, 4(r7) /* int_return ... */ 761 lwz r0, 4(r7) /* int_return ... */
748 add r0, r0, r3 /* ... += dest_addr */ 762 add r0, r0, r3 /* ... += dest_addr */
749 stw r0, 4(r7) 763 stw r0, 4(r7)
750 764
751 blr 765 blr
752 766
753 /* Setup the BAT registers. 767 /* Setup the BAT registers.
754 */ 768 */
755 setup_bats: 769 setup_bats:
756 lis r4, CFG_IBAT0L@h 770 lis r4, CFG_IBAT0L@h
757 ori r4, r4, CFG_IBAT0L@l 771 ori r4, r4, CFG_IBAT0L@l
758 lis r3, CFG_IBAT0U@h 772 lis r3, CFG_IBAT0U@h
759 ori r3, r3, CFG_IBAT0U@l 773 ori r3, r3, CFG_IBAT0U@l
760 mtspr IBAT0L, r4 774 mtspr IBAT0L, r4
761 mtspr IBAT0U, r3 775 mtspr IBAT0U, r3
762 isync 776 isync
763 777
764 lis r4, CFG_DBAT0L@h 778 lis r4, CFG_DBAT0L@h
765 ori r4, r4, CFG_DBAT0L@l 779 ori r4, r4, CFG_DBAT0L@l
766 lis r3, CFG_DBAT0U@h 780 lis r3, CFG_DBAT0U@h
767 ori r3, r3, CFG_DBAT0U@l 781 ori r3, r3, CFG_DBAT0U@l
768 mtspr DBAT0L, r4 782 mtspr DBAT0L, r4
769 mtspr DBAT0U, r3 783 mtspr DBAT0U, r3
770 isync 784 isync
771 785
772 lis r4, CFG_IBAT1L@h 786 lis r4, CFG_IBAT1L@h
773 ori r4, r4, CFG_IBAT1L@l 787 ori r4, r4, CFG_IBAT1L@l
774 lis r3, CFG_IBAT1U@h 788 lis r3, CFG_IBAT1U@h
775 ori r3, r3, CFG_IBAT1U@l 789 ori r3, r3, CFG_IBAT1U@l
776 mtspr IBAT1L, r4 790 mtspr IBAT1L, r4
777 mtspr IBAT1U, r3 791 mtspr IBAT1U, r3
778 isync 792 isync
779 793
780 lis r4, CFG_DBAT1L@h 794 lis r4, CFG_DBAT1L@h
781 ori r4, r4, CFG_DBAT1L@l 795 ori r4, r4, CFG_DBAT1L@l
782 lis r3, CFG_DBAT1U@h 796 lis r3, CFG_DBAT1U@h
783 ori r3, r3, CFG_DBAT1U@l 797 ori r3, r3, CFG_DBAT1U@l
784 mtspr DBAT1L, r4 798 mtspr DBAT1L, r4
785 mtspr DBAT1U, r3 799 mtspr DBAT1U, r3
786 isync 800 isync
787 801
788 lis r4, CFG_IBAT2L@h 802 lis r4, CFG_IBAT2L@h
789 ori r4, r4, CFG_IBAT2L@l 803 ori r4, r4, CFG_IBAT2L@l
790 lis r3, CFG_IBAT2U@h 804 lis r3, CFG_IBAT2U@h
791 ori r3, r3, CFG_IBAT2U@l 805 ori r3, r3, CFG_IBAT2U@l
792 mtspr IBAT2L, r4 806 mtspr IBAT2L, r4
793 mtspr IBAT2U, r3 807 mtspr IBAT2U, r3
794 isync 808 isync
795 809
796 lis r4, CFG_DBAT2L@h 810 lis r4, CFG_DBAT2L@h
797 ori r4, r4, CFG_DBAT2L@l 811 ori r4, r4, CFG_DBAT2L@l
798 lis r3, CFG_DBAT2U@h 812 lis r3, CFG_DBAT2U@h
799 ori r3, r3, CFG_DBAT2U@l 813 ori r3, r3, CFG_DBAT2U@l
800 mtspr DBAT2L, r4 814 mtspr DBAT2L, r4
801 mtspr DBAT2U, r3 815 mtspr DBAT2U, r3
802 isync 816 isync
803 817
804 lis r4, CFG_IBAT3L@h 818 lis r4, CFG_IBAT3L@h
805 ori r4, r4, CFG_IBAT3L@l 819 ori r4, r4, CFG_IBAT3L@l
806 lis r3, CFG_IBAT3U@h 820 lis r3, CFG_IBAT3U@h
807 ori r3, r3, CFG_IBAT3U@l 821 ori r3, r3, CFG_IBAT3U@l
808 mtspr IBAT3L, r4 822 mtspr IBAT3L, r4
809 mtspr IBAT3U, r3 823 mtspr IBAT3U, r3
810 isync 824 isync
811 825
812 lis r4, CFG_DBAT3L@h 826 lis r4, CFG_DBAT3L@h
813 ori r4, r4, CFG_DBAT3L@l 827 ori r4, r4, CFG_DBAT3L@l
814 lis r3, CFG_DBAT3U@h 828 lis r3, CFG_DBAT3U@h
815 ori r3, r3, CFG_DBAT3U@l 829 ori r3, r3, CFG_DBAT3U@l
816 mtspr DBAT3L, r4 830 mtspr DBAT3L, r4
817 mtspr DBAT3U, r3 831 mtspr DBAT3U, r3
818 isync 832 isync
819 833
820 /* Invalidate TLBs. 834 /* Invalidate TLBs.
821 * -> for (val = 0; val < 0x20000; val+=0x1000) 835 * -> for (val = 0; val < 0x20000; val+=0x1000)
822 * -> tlbie(val); 836 * -> tlbie(val);
823 */ 837 */
824 lis r3, 0 838 lis r3, 0
825 lis r5, 2 839 lis r5, 2
826 840
827 1: 841 1:
828 tlbie r3 842 tlbie r3
829 addi r3, r3, 0x1000 843 addi r3, r3, 0x1000
830 cmp 0, 0, r3, r5 844 cmp 0, 0, r3, r5
831 blt 1b 845 blt 1b
832 846
833 blr 847 blr
834 848
835 849
836 850
1 /* 1 /*
2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> 2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> 3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
4 * Copyright (C) 2000, 2001,2002 Wolfgang Denk <wd@denx.de> 4 * Copyright (C) 2000, 2001,2002 Wolfgang Denk <wd@denx.de>
5 * 5 *
6 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
7 * project. 7 * project.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA 22 * MA 02111-1307 USA
23 */ 23 */
24 24
25 /* 25 /*
26 * U-Boot - Startup Code for MPC8260 PowerPC based Embedded Boards 26 * U-Boot - Startup Code for MPC8260 PowerPC based Embedded Boards
27 */ 27 */
28 #include <config.h> 28 #include <config.h>
29 #include <mpc8260.h> 29 #include <mpc8260.h>
30 #include <version.h> 30 #include <version.h>
31 31
32 #define CONFIG_8260 1 /* needed for Linux kernel header files */ 32 #define CONFIG_8260 1 /* needed for Linux kernel header files */
33 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ 33 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
34 34
35 #include <ppc_asm.tmpl> 35 #include <ppc_asm.tmpl>
36 #include <ppc_defs.h> 36 #include <ppc_defs.h>
37 37
38 #include <asm/cache.h> 38 #include <asm/cache.h>
39 #include <asm/mmu.h> 39 #include <asm/mmu.h>
40 40
41 #ifndef CONFIG_IDENT_STRING 41 #ifndef CONFIG_IDENT_STRING
42 #define CONFIG_IDENT_STRING "" 42 #define CONFIG_IDENT_STRING ""
43 #endif 43 #endif
44 44
45 /* We don't want the MMU yet. 45 /* We don't want the MMU yet.
46 */ 46 */
47 #undef MSR_KERNEL 47 #undef MSR_KERNEL
48 /* Floating Point enable, Machine Check and Recoverable Interr. */ 48 /* Floating Point enable, Machine Check and Recoverable Interr. */
49 #ifdef DEBUG 49 #ifdef DEBUG
50 #define MSR_KERNEL (MSR_FP|MSR_RI) 50 #define MSR_KERNEL (MSR_FP|MSR_RI)
51 #else 51 #else
52 #define MSR_KERNEL (MSR_FP|MSR_ME|MSR_RI) 52 #define MSR_KERNEL (MSR_FP|MSR_ME|MSR_RI)
53 #endif 53 #endif
54 54
55 /* 55 /*
56 * Set up GOT: Global Offset Table 56 * Set up GOT: Global Offset Table
57 * 57 *
58 * Use r14 to access the GOT 58 * Use r14 to access the GOT
59 */ 59 */
60 START_GOT 60 START_GOT
61 GOT_ENTRY(_GOT2_TABLE_) 61 GOT_ENTRY(_GOT2_TABLE_)
62 GOT_ENTRY(_FIXUP_TABLE_) 62 GOT_ENTRY(_FIXUP_TABLE_)
63 63
64 GOT_ENTRY(_start) 64 GOT_ENTRY(_start)
65 GOT_ENTRY(_start_of_vectors) 65 GOT_ENTRY(_start_of_vectors)
66 GOT_ENTRY(_end_of_vectors) 66 GOT_ENTRY(_end_of_vectors)
67 GOT_ENTRY(transfer_to_handler) 67 GOT_ENTRY(transfer_to_handler)
68 68
69 GOT_ENTRY(_end) 69 GOT_ENTRY(_end)
70 GOT_ENTRY(.bss) 70 GOT_ENTRY(.bss)
71 #if defined(CONFIG_HYMOD) 71 #if defined(CONFIG_HYMOD)
72 GOT_ENTRY(environment) 72 GOT_ENTRY(environment)
73 #endif 73 #endif
74 END_GOT 74 END_GOT
75 75
76 /* 76 /*
77 * Version string - must be in data segment because MPC8260 uses the first 77 * Version string - must be in data segment because MPC8260 uses the first
78 * 256 bytes for the Hard Reset Configuration Word table (see below). 78 * 256 bytes for the Hard Reset Configuration Word table (see below).
79 * Similarly, can't have the U-Boot Magic Number as the first thing in 79 * Similarly, can't have the U-Boot Magic Number as the first thing in
80 * the image - don't know how this will affect the image tools, but I guess 80 * the image - don't know how this will affect the image tools, but I guess
81 * I'll find out soon 81 * I'll find out soon
82 */ 82 */
83 .data 83 .data
84 .globl version_string 84 .globl version_string
85 version_string: 85 version_string:
86 .ascii U_BOOT_VERSION 86 .ascii U_BOOT_VERSION
87 .ascii " (", __DATE__, " - ", __TIME__, ")" 87 .ascii " (", __DATE__, " - ", __TIME__, ")"
88 .ascii CONFIG_IDENT_STRING, "\0" 88 .ascii CONFIG_IDENT_STRING, "\0"
89 89
90 /* 90 /*
91 * Hard Reset Configuration Word (HRCW) table 91 * Hard Reset Configuration Word (HRCW) table
92 * 92 *
93 * The Hard Reset Configuration Word (HRCW) sets a number of useful things 93 * The Hard Reset Configuration Word (HRCW) sets a number of useful things
94 * such as whether there is an external memory controller, whether the 94 * such as whether there is an external memory controller, whether the
95 * PowerPC core is disabled (i.e. only the communications processor is 95 * PowerPC core is disabled (i.e. only the communications processor is
96 * active, accessed by another CPU on the bus), whether using external 96 * active, accessed by another CPU on the bus), whether using external
97 * arbitration, external bus mode, boot port size, core initial prefix, 97 * arbitration, external bus mode, boot port size, core initial prefix,
98 * internal space base, boot memory space, etc. 98 * internal space base, boot memory space, etc.
99 * 99 *
100 * These things dictate where the processor begins execution, where the 100 * These things dictate where the processor begins execution, where the
101 * boot ROM appears in memory, the memory controller setup when access 101 * boot ROM appears in memory, the memory controller setup when access
102 * boot ROM, etc. The HRCW is *extremely* important. 102 * boot ROM, etc. The HRCW is *extremely* important.
103 * 103 *
104 * The HRCW is read from the bus during reset. One CPU on the bus will 104 * The HRCW is read from the bus during reset. One CPU on the bus will
105 * be a hard reset configuration master, any others will be hard reset 105 * be a hard reset configuration master, any others will be hard reset
106 * configuration slaves. The master reads eight HRCWs from flash during 106 * configuration slaves. The master reads eight HRCWs from flash during
107 * reset - the first it uses for itself, the other 7 it communicates to 107 * reset - the first it uses for itself, the other 7 it communicates to
108 * up to 7 configuration slaves by some complicated mechanism, which is 108 * up to 7 configuration slaves by some complicated mechanism, which is
109 * not really important here. 109 * not really important here.
110 * 110 *
111 * The configuration master performs 32 successive reads starting at address 111 * The configuration master performs 32 successive reads starting at address
112 * 0 and incrementing by 8 each read (i.e. on 64 bit boundaries) but only 8 112 * 0 and incrementing by 8 each read (i.e. on 64 bit boundaries) but only 8
113 * bits is read, and always from byte lane D[0-7] (so that port size of the 113 * bits is read, and always from byte lane D[0-7] (so that port size of the
114 * boot device does not matter). The first four reads form the 32 bit HRCW 114 * boot device does not matter). The first four reads form the 32 bit HRCW
115 * for the master itself. The second four reads form the HRCW for the first 115 * for the master itself. The second four reads form the HRCW for the first
116 * slave, and so on, up to seven slaves. The 32 bit HRCW is formed by 116 * slave, and so on, up to seven slaves. The 32 bit HRCW is formed by
117 * concatenating the four bytes, with the first read placed in byte 0 (the 117 * concatenating the four bytes, with the first read placed in byte 0 (the
118 * most significant byte), and so on with the fourth read placed in byte 3 118 * most significant byte), and so on with the fourth read placed in byte 3
119 * (the least significant byte). 119 * (the least significant byte).
120 */ 120 */
121 #define _HRCW_TABLE_ENTRY(w) \ 121 #define _HRCW_TABLE_ENTRY(w) \
122 .fill 8,1,(((w)>>24)&0xff); \ 122 .fill 8,1,(((w)>>24)&0xff); \
123 .fill 8,1,(((w)>>16)&0xff); \ 123 .fill 8,1,(((w)>>16)&0xff); \
124 .fill 8,1,(((w)>> 8)&0xff); \ 124 .fill 8,1,(((w)>> 8)&0xff); \
125 .fill 8,1,(((w) )&0xff) 125 .fill 8,1,(((w) )&0xff)
126 .text 126 .text
127 .globl _hrcw_table 127 .globl _hrcw_table
128 _hrcw_table: 128 _hrcw_table:
129 _HRCW_TABLE_ENTRY(CFG_HRCW_MASTER) 129 _HRCW_TABLE_ENTRY(CFG_HRCW_MASTER)
130 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE1) 130 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE1)
131 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE2) 131 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE2)
132 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE3) 132 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE3)
133 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE4) 133 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE4)
134 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE5) 134 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE5)
135 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE6) 135 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE6)
136 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE7) 136 _HRCW_TABLE_ENTRY(CFG_HRCW_SLAVE7)
137 /* 137 /*
138 * After configuration, a system reset exception is executed using the 138 * After configuration, a system reset exception is executed using the
139 * vector at offset 0x100 relative to the base set by MSR[IP]. If MSR[IP] 139 * vector at offset 0x100 relative to the base set by MSR[IP]. If MSR[IP]
140 * is 0, the base address is 0x00000000. If MSR[IP] is 1, the base address 140 * is 0, the base address is 0x00000000. If MSR[IP] is 1, the base address
141 * is 0xfff00000. In the case of a Power On Reset or Hard Reset, the value 141 * is 0xfff00000. In the case of a Power On Reset or Hard Reset, the value
142 * of MSR[IP] is determined by the CIP field in the HRCW. 142 * of MSR[IP] is determined by the CIP field in the HRCW.
143 * 143 *
144 * Other bits in the HRCW set up the Base Address and Port Size in BR0. 144 * Other bits in the HRCW set up the Base Address and Port Size in BR0.
145 * This determines the location of the boot ROM (flash or EPROM) in the 145 * This determines the location of the boot ROM (flash or EPROM) in the
146 * processor's address space at boot time. As long as the HRCW is set up 146 * processor's address space at boot time. As long as the HRCW is set up
147 * so that we eventually end up executing the code below when the processor 147 * so that we eventually end up executing the code below when the processor
148 * executes the reset exception, the actual values used should not matter. 148 * executes the reset exception, the actual values used should not matter.
149 * 149 *
150 * Once we have got here, the address mask in OR0 is cleared so that the 150 * Once we have got here, the address mask in OR0 is cleared so that the
151 * bottom 32K of the boot ROM is effectively repeated all throughout the 151 * bottom 32K of the boot ROM is effectively repeated all throughout the
152 * processor's address space, after which we can jump to the absolute 152 * processor's address space, after which we can jump to the absolute
153 * address at which the boot ROM was linked at compile time, and proceed 153 * address at which the boot ROM was linked at compile time, and proceed
154 * to initialise the memory controller without worrying if the rug will be 154 * to initialise the memory controller without worrying if the rug will be
155 * pulled out from under us, so to speak (it will be fine as long as we 155 * pulled out from under us, so to speak (it will be fine as long as we
156 * configure BR0 with the same boot ROM link address). 156 * configure BR0 with the same boot ROM link address).
157 */ 157 */
158 . = EXC_OFF_SYS_RESET 158 . = EXC_OFF_SYS_RESET
159 159
160 .globl _start 160 .globl _start
161 _start: 161 _start:
162 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH*/ 162 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH*/
163 b boot_cold 163 b boot_cold
164 164
165 . = EXC_OFF_SYS_RESET + 0x10 165 . = EXC_OFF_SYS_RESET + 0x10
166 166
167 .globl _start_warm 167 .globl _start_warm
168 _start_warm: 168 _start_warm:
169 li r21, BOOTFLAG_WARM /* Software reboot */ 169 li r21, BOOTFLAG_WARM /* Software reboot */
170 b boot_warm 170 b boot_warm
171 171
172 boot_cold: 172 boot_cold:
173 boot_warm: 173 boot_warm:
174 mfmsr r5 /* save msr contents */ 174 mfmsr r5 /* save msr contents */
175 175
176 #if defined(CONFIG_COGENT) 176 #if defined(CONFIG_COGENT)
177 /* this is what the cogent EPROM does */ 177 /* this is what the cogent EPROM does */
178 li r0, 0 178 li r0, 0
179 mtmsr r0 179 mtmsr r0
180 isync 180 isync
181 bl cogent_init_8260 181 bl cogent_init_8260
182 #endif /* CONFIG_COGENT */ 182 #endif /* CONFIG_COGENT */
183 183
184 #if defined(CFG_DEFAULT_IMMR) 184 #if defined(CFG_DEFAULT_IMMR)
185 lis r3, CFG_IMMR@h 185 lis r3, CFG_IMMR@h
186 ori r3, r3, CFG_IMMR@l 186 ori r3, r3, CFG_IMMR@l
187 lis r4, CFG_DEFAULT_IMMR@h 187 lis r4, CFG_DEFAULT_IMMR@h
188 stw r3, 0x1A8(r4) 188 stw r3, 0x1A8(r4)
189 #endif /* CFG_DEFAULT_IMMR */ 189 #endif /* CFG_DEFAULT_IMMR */
190 190
191 /* Initialise the MPC8260 processor core */ 191 /* Initialise the MPC8260 processor core */
192 /*--------------------------------------------------------------*/ 192 /*--------------------------------------------------------------*/
193 193
194 bl init_8260_core 194 bl init_8260_core
195 195
196 #ifndef CFG_RAMBOOT 196 #ifndef CFG_RAMBOOT
197 /* When booting from ROM (Flash or EPROM), clear the */ 197 /* When booting from ROM (Flash or EPROM), clear the */
198 /* Address Mask in OR0 so ROM appears everywhere */ 198 /* Address Mask in OR0 so ROM appears everywhere */
199 /*--------------------------------------------------------------*/ 199 /*--------------------------------------------------------------*/
200 200
201 lis r3, (CFG_IMMR+IM_REGBASE)@h 201 lis r3, (CFG_IMMR+IM_REGBASE)@h
202 lwz r4, IM_OR0@l(r3) 202 lwz r4, IM_OR0@l(r3)
203 li r5, 0x7fff 203 li r5, 0x7fff
204 and r4, r4, r5 204 and r4, r4, r5
205 stw r4, IM_OR0@l(r3) 205 stw r4, IM_OR0@l(r3)
206 206
207 /* Calculate absolute address in FLASH and jump there */ 207 /* Calculate absolute address in FLASH and jump there */
208 /*--------------------------------------------------------------*/ 208 /*--------------------------------------------------------------*/
209 209
210 lis r3, CFG_MONITOR_BASE@h 210 lis r3, CFG_MONITOR_BASE@h
211 ori r3, r3, CFG_MONITOR_BASE@l 211 ori r3, r3, CFG_MONITOR_BASE@l
212 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET 212 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
213 mtlr r3 213 mtlr r3
214 blr 214 blr
215 215
216 in_flash: 216 in_flash:
217 #endif /* CFG_RAMBOOT */ 217 #endif /* CFG_RAMBOOT */
218 218
219 /* initialize some things that are hard to access from C */ 219 /* initialize some things that are hard to access from C */
220 /*--------------------------------------------------------------*/ 220 /*--------------------------------------------------------------*/
221 221
222 lis r3, CFG_IMMR@h /* set up stack in internal DPRAM */ 222 lis r3, CFG_IMMR@h /* set up stack in internal DPRAM */
223 ori r1, r3, CFG_INIT_SP_OFFSET 223 ori r1, r3, CFG_INIT_SP_OFFSET
224 li r0, 0 /* Make room for stack frame header and */ 224 li r0, 0 /* Make room for stack frame header and */
225 stwu r0, -4(r1) /* clear final stack frame so that */ 225 stwu r0, -4(r1) /* clear final stack frame so that */
226 stwu r0, -4(r1) /* stack backtraces terminate cleanly */ 226 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
227 227
228 /* let the C-code set up the rest */ 228 /* let the C-code set up the rest */
229 /* */ 229 /* */
230 /* Be careful to keep code relocatable ! */ 230 /* Be careful to keep code relocatable ! */
231 /*--------------------------------------------------------------*/ 231 /*--------------------------------------------------------------*/
232 232
233 GET_GOT /* initialize GOT access */ 233 GET_GOT /* initialize GOT access */
234 234
235 /* r3: IMMR */ 235 /* r3: IMMR */
236 bl cpu_init_f /* run low-level CPU init code (in Flash)*/ 236 bl cpu_init_f /* run low-level CPU init code (in Flash)*/
237 237
238 #ifdef DEBUG 238 #ifdef DEBUG
239 bl init_debug /* set up debugging stuff */ 239 bl init_debug /* set up debugging stuff */
240 #endif 240 #endif
241 241
242 mr r3, r21 242 mr r3, r21
243 /* r3: BOOTFLAG */ 243 /* r3: BOOTFLAG */
244 bl board_init_f /* run 1st part of board init code (in Flash)*/ 244 bl board_init_f /* run 1st part of board init code (in Flash)*/
245 245
246 /* 246 /*
247 * Vector Table 247 * Vector Table
248 */ 248 */
249 249
250 .globl _start_of_vectors 250 .globl _start_of_vectors
251 _start_of_vectors: 251 _start_of_vectors:
252 252
253 /* Machine check */ 253 /* Machine check */
254 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException) 254 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
255 255
256 /* Data Storage exception. */ 256 /* Data Storage exception. */
257 STD_EXCEPTION(0x300, DataStorage, UnknownException) 257 STD_EXCEPTION(0x300, DataStorage, UnknownException)
258 258
259 /* Instruction Storage exception. */ 259 /* Instruction Storage exception. */
260 STD_EXCEPTION(0x400, InstStorage, UnknownException) 260 STD_EXCEPTION(0x400, InstStorage, UnknownException)
261 261
262 /* External Interrupt exception. */ 262 /* External Interrupt exception. */
263 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt) 263 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
264 264
265 /* Alignment exception. */ 265 /* Alignment exception. */
266 . = 0x600 266 . = 0x600
267 Alignment: 267 Alignment:
268 EXCEPTION_PROLOG 268 EXCEPTION_PROLOG
269 mfspr r4,DAR 269 mfspr r4,DAR
270 stw r4,_DAR(r21) 270 stw r4,_DAR(r21)
271 mfspr r5,DSISR 271 mfspr r5,DSISR
272 stw r5,_DSISR(r21) 272 stw r5,_DSISR(r21)
273 addi r3,r1,STACK_FRAME_OVERHEAD 273 addi r3,r1,STACK_FRAME_OVERHEAD
274 li r20,MSR_KERNEL 274 li r20,MSR_KERNEL
275 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 275 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
276 rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */ 276 rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
277 lwz r6,GOT(transfer_to_handler) 277 lwz r6,GOT(transfer_to_handler)
278 mtlr r6 278 mtlr r6
279 blrl 279 blrl
280 .L_Alignment: 280 .L_Alignment:
281 .long AlignmentException - _start + EXC_OFF_SYS_RESET 281 .long AlignmentException - _start + EXC_OFF_SYS_RESET
282 .long int_return - _start + EXC_OFF_SYS_RESET 282 .long int_return - _start + EXC_OFF_SYS_RESET
283 283
284 /* Program check exception */ 284 /* Program check exception */
285 . = 0x700 285 . = 0x700
286 ProgramCheck: 286 ProgramCheck:
287 EXCEPTION_PROLOG 287 EXCEPTION_PROLOG
288 addi r3,r1,STACK_FRAME_OVERHEAD 288 addi r3,r1,STACK_FRAME_OVERHEAD
289 li r20,MSR_KERNEL 289 li r20,MSR_KERNEL
290 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 290 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
291 rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */ 291 rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
292 lwz r6,GOT(transfer_to_handler) 292 lwz r6,GOT(transfer_to_handler)
293 mtlr r6 293 mtlr r6
294 blrl 294 blrl
295 .L_ProgramCheck: 295 .L_ProgramCheck:
296 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET 296 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
297 .long int_return - _start + EXC_OFF_SYS_RESET 297 .long int_return - _start + EXC_OFF_SYS_RESET
298 298
299 STD_EXCEPTION(0x800, FPUnavailable, UnknownException) 299 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
300 300
301 /* I guess we could implement decrementer, and may have 301 /* I guess we could implement decrementer, and may have
302 * to someday for timekeeping. 302 * to someday for timekeeping.
303 */ 303 */
304 STD_EXCEPTION(0x900, Decrementer, timer_interrupt) 304 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
305 305
306 STD_EXCEPTION(0xa00, Trap_0a, UnknownException) 306 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
307 STD_EXCEPTION(0xb00, Trap_0b, UnknownException) 307 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
308 308
309 . = 0xc00 309 . = 0xc00
310 /* 310 /*
311 * r0 - SYSCALL number 311 * r0 - SYSCALL number
312 * r3-... arguments 312 * r3-... arguments
313 */ 313 */
314 SystemCall: 314 SystemCall:
315 addis r11,r0,0 /* get functions table addr */ 315 addis r11,r0,0 /* get functions table addr */
316 ori r11,r11,0 /* Note: this code is patched in trap_init */ 316 ori r11,r11,0 /* Note: this code is patched in trap_init */
317 addis r12,r0,0 /* get number of functions */ 317 addis r12,r0,0 /* get number of functions */
318 ori r12,r12,0 318 ori r12,r12,0
319 319
320 cmplw 0, r0, r12 320 cmplw 0, r0, r12
321 bge 1f 321 bge 1f
322 322
323 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ 323 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
324 add r11,r11,r0 324 add r11,r11,r0
325 lwz r11,0(r11) 325 lwz r11,0(r11)
326 326
327 li r12,0xd00-4*3 /* save LR & SRRx */ 327 li r20,0xd00-4 /* Get stack pointer */
328 lwz r12,0(r20)
329 subi r12,r12,12 /* Adjust stack pointer */
330 li r0,0xc00+_end_back-SystemCall
331 cmplw 0, r0, r12 /* Check stack overflow */
332 bgt 1f
333 stw r12,0(r20)
334
328 mflr r0 335 mflr r0
329 stw r0,0(r12) 336 stw r0,0(r12)
330 mfspr r0,SRR0 337 mfspr r0,SRR0
331 stw r0,4(r12) 338 stw r0,4(r12)
332 mfspr r0,SRR1 339 mfspr r0,SRR1
333 stw r0,8(r12) 340 stw r0,8(r12)
334 341
335 li r12,0xc00+_back-SystemCall 342 li r12,0xc00+_back-SystemCall
336 mtlr r12 343 mtlr r12
337 mtspr SRR0,r11 344 mtspr SRR0,r11
338 345
339 1: SYNC 346 1: SYNC
340 rfi 347 rfi
341 348
342 _back: 349 _back:
343 350
344 mfmsr r11 /* Disable interrupts */ 351 mfmsr r11 /* Disable interrupts */
345 li r12,0 352 li r12,0
346 ori r12,r12,MSR_EE 353 ori r12,r12,MSR_EE
347 andc r11,r11,r12 354 andc r11,r11,r12
348 SYNC /* Some chip revs need this... */ 355 SYNC /* Some chip revs need this... */
349 mtmsr r11 356 mtmsr r11
350 SYNC 357 SYNC
351 358
352 li r12,0xd00-4*3 /* restore regs */ 359 li r12,0xd00-4 /* restore regs */
360 lwz r12,0(r12)
361
353 lwz r11,0(r12) 362 lwz r11,0(r12)
354 mtlr r11 363 mtlr r11
355 lwz r11,4(r12) 364 lwz r11,4(r12)
356 mtspr SRR0,r11 365 mtspr SRR0,r11
357 lwz r11,8(r12) 366 lwz r11,8(r12)
358 mtspr SRR1,r11 367 mtspr SRR1,r11
359 368
369 addi r12,r12,12 /* Adjust stack pointer */
370 li r20,0xd00-4
371 stw r12,0(r20)
372
360 SYNC 373 SYNC
361 rfi 374 rfi
375 _end_back:
362 376
363 STD_EXCEPTION(0xd00, SingleStep, UnknownException) 377 STD_EXCEPTION(0xd00, SingleStep, UnknownException)
364 378
365 STD_EXCEPTION(0xe00, Trap_0e, UnknownException) 379 STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
366 STD_EXCEPTION(0xf00, Trap_0f, UnknownException) 380 STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
367 381
368 STD_EXCEPTION(0x1000, InstructionTLBMiss, UnknownException) 382 STD_EXCEPTION(0x1000, InstructionTLBMiss, UnknownException)
369 STD_EXCEPTION(0x1100, DataLoadTLBMiss, UnknownException) 383 STD_EXCEPTION(0x1100, DataLoadTLBMiss, UnknownException)
370 STD_EXCEPTION(0x1200, DataStoreTLBMiss, UnknownException) 384 STD_EXCEPTION(0x1200, DataStoreTLBMiss, UnknownException)
371 #ifdef DEBUG 385 #ifdef DEBUG
372 . = 0x1300 386 . = 0x1300
373 /* 387 /*
374 * This exception occurs when the program counter matches the 388 * This exception occurs when the program counter matches the
375 * Instruction Address Breakpoint Register (IABR). 389 * Instruction Address Breakpoint Register (IABR).
376 * 390 *
377 * I want the cpu to halt if this occurs so I can hunt around 391 * I want the cpu to halt if this occurs so I can hunt around
378 * with the debugger and look at things. 392 * with the debugger and look at things.
379 * 393 *
380 * When DEBUG is defined, both machine check enable (in the MSR) 394 * When DEBUG is defined, both machine check enable (in the MSR)
381 * and checkstop reset enable (in the reset mode register) are 395 * and checkstop reset enable (in the reset mode register) are
382 * turned off and so a checkstop condition will result in the cpu 396 * turned off and so a checkstop condition will result in the cpu
383 * halting. 397 * halting.
384 * 398 *
385 * I force the cpu into a checkstop condition by putting an illegal 399 * I force the cpu into a checkstop condition by putting an illegal
386 * instruction here (at least this is the theory). 400 * instruction here (at least this is the theory).
387 * 401 *
388 * well - that didnt work, so just do an infinite loop! 402 * well - that didnt work, so just do an infinite loop!
389 */ 403 */
390 1: b 1b 404 1: b 1b
391 #else 405 #else
392 STD_EXCEPTION(0x1300, InstructionBreakpoint, DebugException) 406 STD_EXCEPTION(0x1300, InstructionBreakpoint, DebugException)
393 #endif 407 #endif
394 STD_EXCEPTION(0x1400, SMI, UnknownException) 408 STD_EXCEPTION(0x1400, SMI, UnknownException)
395 409
396 STD_EXCEPTION(0x1500, Trap_15, UnknownException) 410 STD_EXCEPTION(0x1500, Trap_15, UnknownException)
397 STD_EXCEPTION(0x1600, Trap_16, UnknownException) 411 STD_EXCEPTION(0x1600, Trap_16, UnknownException)
398 STD_EXCEPTION(0x1700, Trap_17, UnknownException) 412 STD_EXCEPTION(0x1700, Trap_17, UnknownException)
399 STD_EXCEPTION(0x1800, Trap_18, UnknownException) 413 STD_EXCEPTION(0x1800, Trap_18, UnknownException)
400 STD_EXCEPTION(0x1900, Trap_19, UnknownException) 414 STD_EXCEPTION(0x1900, Trap_19, UnknownException)
401 STD_EXCEPTION(0x1a00, Trap_1a, UnknownException) 415 STD_EXCEPTION(0x1a00, Trap_1a, UnknownException)
402 STD_EXCEPTION(0x1b00, Trap_1b, UnknownException) 416 STD_EXCEPTION(0x1b00, Trap_1b, UnknownException)
403 STD_EXCEPTION(0x1c00, Trap_1c, UnknownException) 417 STD_EXCEPTION(0x1c00, Trap_1c, UnknownException)
404 STD_EXCEPTION(0x1d00, Trap_1d, UnknownException) 418 STD_EXCEPTION(0x1d00, Trap_1d, UnknownException)
405 STD_EXCEPTION(0x1e00, Trap_1e, UnknownException) 419 STD_EXCEPTION(0x1e00, Trap_1e, UnknownException)
406 STD_EXCEPTION(0x1f00, Trap_1f, UnknownException) 420 STD_EXCEPTION(0x1f00, Trap_1f, UnknownException)
407 STD_EXCEPTION(0x2000, Trap_20, UnknownException) 421 STD_EXCEPTION(0x2000, Trap_20, UnknownException)
408 STD_EXCEPTION(0x2100, Trap_21, UnknownException) 422 STD_EXCEPTION(0x2100, Trap_21, UnknownException)
409 STD_EXCEPTION(0x2200, Trap_22, UnknownException) 423 STD_EXCEPTION(0x2200, Trap_22, UnknownException)
410 STD_EXCEPTION(0x2300, Trap_23, UnknownException) 424 STD_EXCEPTION(0x2300, Trap_23, UnknownException)
411 STD_EXCEPTION(0x2400, Trap_24, UnknownException) 425 STD_EXCEPTION(0x2400, Trap_24, UnknownException)
412 STD_EXCEPTION(0x2500, Trap_25, UnknownException) 426 STD_EXCEPTION(0x2500, Trap_25, UnknownException)
413 STD_EXCEPTION(0x2600, Trap_26, UnknownException) 427 STD_EXCEPTION(0x2600, Trap_26, UnknownException)
414 STD_EXCEPTION(0x2700, Trap_27, UnknownException) 428 STD_EXCEPTION(0x2700, Trap_27, UnknownException)
415 STD_EXCEPTION(0x2800, Trap_28, UnknownException) 429 STD_EXCEPTION(0x2800, Trap_28, UnknownException)
416 STD_EXCEPTION(0x2900, Trap_29, UnknownException) 430 STD_EXCEPTION(0x2900, Trap_29, UnknownException)
417 STD_EXCEPTION(0x2a00, Trap_2a, UnknownException) 431 STD_EXCEPTION(0x2a00, Trap_2a, UnknownException)
418 STD_EXCEPTION(0x2b00, Trap_2b, UnknownException) 432 STD_EXCEPTION(0x2b00, Trap_2b, UnknownException)
419 STD_EXCEPTION(0x2c00, Trap_2c, UnknownException) 433 STD_EXCEPTION(0x2c00, Trap_2c, UnknownException)
420 STD_EXCEPTION(0x2d00, Trap_2d, UnknownException) 434 STD_EXCEPTION(0x2d00, Trap_2d, UnknownException)
421 STD_EXCEPTION(0x2e00, Trap_2e, UnknownException) 435 STD_EXCEPTION(0x2e00, Trap_2e, UnknownException)
422 STD_EXCEPTION(0x2f00, Trap_2f, UnknownException) 436 STD_EXCEPTION(0x2f00, Trap_2f, UnknownException)
423 437
424 438
425 .globl _end_of_vectors 439 .globl _end_of_vectors
426 _end_of_vectors: 440 _end_of_vectors:
427 441
428 . = 0x3000 442 . = 0x3000
429 443
430 /* 444 /*
431 * This code finishes saving the registers to the exception frame 445 * This code finishes saving the registers to the exception frame
432 * and jumps to the appropriate handler for the exception. 446 * and jumps to the appropriate handler for the exception.
433 * Register r21 is pointer into trap frame, r1 has new stack pointer. 447 * Register r21 is pointer into trap frame, r1 has new stack pointer.
434 */ 448 */
435 .globl transfer_to_handler 449 .globl transfer_to_handler
436 transfer_to_handler: 450 transfer_to_handler:
437 stw r22,_NIP(r21) 451 stw r22,_NIP(r21)
438 lis r22,MSR_POW@h 452 lis r22,MSR_POW@h
439 andc r23,r23,r22 453 andc r23,r23,r22
440 stw r23,_MSR(r21) 454 stw r23,_MSR(r21)
441 SAVE_GPR(7, r21) 455 SAVE_GPR(7, r21)
442 SAVE_4GPRS(8, r21) 456 SAVE_4GPRS(8, r21)
443 SAVE_8GPRS(12, r21) 457 SAVE_8GPRS(12, r21)
444 SAVE_8GPRS(24, r21) 458 SAVE_8GPRS(24, r21)
445 mflr r23 459 mflr r23
446 andi. r24,r23,0x3f00 /* get vector offset */ 460 andi. r24,r23,0x3f00 /* get vector offset */
447 stw r24,TRAP(r21) 461 stw r24,TRAP(r21)
448 li r22,0 462 li r22,0
449 stw r22,RESULT(r21) 463 stw r22,RESULT(r21)
450 lwz r24,0(r23) /* virtual address of handler */ 464 lwz r24,0(r23) /* virtual address of handler */
451 lwz r23,4(r23) /* where to go when done */ 465 lwz r23,4(r23) /* where to go when done */
452 mtspr SRR0,r24 466 mtspr SRR0,r24
453 mtspr SRR1,r20 467 mtspr SRR1,r20
454 mtlr r23 468 mtlr r23
455 SYNC 469 SYNC
456 rfi /* jump to handler, enable MMU */ 470 rfi /* jump to handler, enable MMU */
457 471
458 int_return: 472 int_return:
459 mfmsr r28 /* Disable interrupts */ 473 mfmsr r28 /* Disable interrupts */
460 li r4,0 474 li r4,0
461 ori r4,r4,MSR_EE 475 ori r4,r4,MSR_EE
462 andc r28,r28,r4 476 andc r28,r28,r4
463 SYNC /* Some chip revs need this... */ 477 SYNC /* Some chip revs need this... */
464 mtmsr r28 478 mtmsr r28
465 SYNC 479 SYNC
466 lwz r2,_CTR(r1) 480 lwz r2,_CTR(r1)
467 lwz r0,_LINK(r1) 481 lwz r0,_LINK(r1)
468 mtctr r2 482 mtctr r2
469 mtlr r0 483 mtlr r0
470 lwz r2,_XER(r1) 484 lwz r2,_XER(r1)
471 lwz r0,_CCR(r1) 485 lwz r0,_CCR(r1)
472 mtspr XER,r2 486 mtspr XER,r2
473 mtcrf 0xFF,r0 487 mtcrf 0xFF,r0
474 REST_10GPRS(3, r1) 488 REST_10GPRS(3, r1)
475 REST_10GPRS(13, r1) 489 REST_10GPRS(13, r1)
476 REST_8GPRS(23, r1) 490 REST_8GPRS(23, r1)
477 REST_GPR(31, r1) 491 REST_GPR(31, r1)
478 lwz r2,_NIP(r1) /* Restore environment */ 492 lwz r2,_NIP(r1) /* Restore environment */
479 lwz r0,_MSR(r1) 493 lwz r0,_MSR(r1)
480 mtspr SRR0,r2 494 mtspr SRR0,r2
481 mtspr SRR1,r0 495 mtspr SRR1,r0
482 lwz r0,GPR0(r1) 496 lwz r0,GPR0(r1)
483 lwz r2,GPR2(r1) 497 lwz r2,GPR2(r1)
484 lwz r1,GPR1(r1) 498 lwz r1,GPR1(r1)
485 SYNC 499 SYNC
486 rfi 500 rfi
487 501
488 #if defined(CONFIG_COGENT) 502 #if defined(CONFIG_COGENT)
489 503
490 /* 504 /*
491 * This code initialises the MPC8260 processor core 505 * This code initialises the MPC8260 processor core
492 * (conforms to PowerPC 603e spec) 506 * (conforms to PowerPC 603e spec)
493 */ 507 */
494 508
495 .globl cogent_init_8260 509 .globl cogent_init_8260
496 cogent_init_8260: 510 cogent_init_8260:
497 511
498 /* Taken from page 14 of CMA282 manual */ 512 /* Taken from page 14 of CMA282 manual */
499 /*--------------------------------------------------------------*/ 513 /*--------------------------------------------------------------*/
500 514
501 lis r4, (CFG_IMMR+IM_REGBASE)@h 515 lis r4, (CFG_IMMR+IM_REGBASE)@h
502 lis r3, CFG_IMMR@h 516 lis r3, CFG_IMMR@h
503 stw r3, IM_IMMR@l(r4) 517 stw r3, IM_IMMR@l(r4)
504 lwz r3, IM_IMMR@l(r4) 518 lwz r3, IM_IMMR@l(r4)
505 stw r3, 0(r0) 519 stw r3, 0(r0)
506 lis r3, CFG_SYPCR@h 520 lis r3, CFG_SYPCR@h
507 ori r3, r3, CFG_SYPCR@l 521 ori r3, r3, CFG_SYPCR@l
508 stw r3, IM_SYPCR@l(r4) 522 stw r3, IM_SYPCR@l(r4)
509 lwz r3, IM_SYPCR@l(r4) 523 lwz r3, IM_SYPCR@l(r4)
510 stw r3, 4(r0) 524 stw r3, 4(r0)
511 lis r3, CFG_SCCR@h 525 lis r3, CFG_SCCR@h
512 ori r3, r3, CFG_SCCR@l 526 ori r3, r3, CFG_SCCR@l
513 stw r3, IM_SCCR@l(r4) 527 stw r3, IM_SCCR@l(r4)
514 lwz r3, IM_SCCR@l(r4) 528 lwz r3, IM_SCCR@l(r4)
515 stw r3, 8(r0) 529 stw r3, 8(r0)
516 530
517 /* the rest of this was disassembled from the */ 531 /* the rest of this was disassembled from the */
518 /* EPROM code that came with my CMA282 CPU module */ 532 /* EPROM code that came with my CMA282 CPU module */
519 /*--------------------------------------------------------------*/ 533 /*--------------------------------------------------------------*/
520 534
521 lis r1, 0x1234 535 lis r1, 0x1234
522 ori r1, r1, 0x5678 536 ori r1, r1, 0x5678
523 stw r1, 0x20(r0) 537 stw r1, 0x20(r0)
524 lwz r1, 0x20(r0) 538 lwz r1, 0x20(r0)
525 stw r1, 0x24(r0) 539 stw r1, 0x24(r0)
526 lwz r1, 0x24(r0) 540 lwz r1, 0x24(r0)
527 lis r3, 0x0e80 541 lis r3, 0x0e80
528 ori r3, r3, 0 542 ori r3, r3, 0
529 stw r1, 4(r3) 543 stw r1, 4(r3)
530 lwz r1, 4(r3) 544 lwz r1, 4(r3)
531 545
532 /* Done! */ 546 /* Done! */
533 /*--------------------------------------------------------------*/ 547 /*--------------------------------------------------------------*/
534 548
535 blr 549 blr
536 550
537 #endif /* CONFIG_COGENT */ 551 #endif /* CONFIG_COGENT */
538 552
539 /* 553 /*
540 * This code initialises the MPC8260 processor core 554 * This code initialises the MPC8260 processor core
541 * (conforms to PowerPC 603e spec) 555 * (conforms to PowerPC 603e spec)
542 * Note: expects original MSR contents to be in r5. 556 * Note: expects original MSR contents to be in r5.
543 */ 557 */
544 558
545 .globl init_8260_core 559 .globl init_8260_core
546 init_8260_core: 560 init_8260_core:
547 561
548 /* Initialize machine status; enable machine check interrupt */ 562 /* Initialize machine status; enable machine check interrupt */
549 /*--------------------------------------------------------------*/ 563 /*--------------------------------------------------------------*/
550 564
551 li r3, MSR_KERNEL /* Set ME and RI flags */ 565 li r3, MSR_KERNEL /* Set ME and RI flags */
552 rlwimi r3, r5, 0, 25, 25 /* preserve IP bit set by HRCW */ 566 rlwimi r3, r5, 0, 25, 25 /* preserve IP bit set by HRCW */
553 #ifdef DEBUG 567 #ifdef DEBUG
554 rlwimi r3, r5, 0, 21, 22 /* debugger might set SE & BE bits */ 568 rlwimi r3, r5, 0, 21, 22 /* debugger might set SE & BE bits */
555 #endif 569 #endif
556 SYNC /* Some chip revs need this... */ 570 SYNC /* Some chip revs need this... */
557 mtmsr r3 571 mtmsr r3
558 SYNC 572 SYNC
559 mtspr SRR1, r3 /* Make SRR1 match MSR */ 573 mtspr SRR1, r3 /* Make SRR1 match MSR */
560 574
561 /* Initialise the SYPCR early, and reset the watchdog (if req) */ 575 /* Initialise the SYPCR early, and reset the watchdog (if req) */
562 /*--------------------------------------------------------------*/ 576 /*--------------------------------------------------------------*/
563 577
564 lis r3, (CFG_IMMR+IM_REGBASE)@h 578 lis r3, (CFG_IMMR+IM_REGBASE)@h
565 #if !defined(CONFIG_COGENT) 579 #if !defined(CONFIG_COGENT)
566 lis r4, CFG_SYPCR@h 580 lis r4, CFG_SYPCR@h
567 ori r4, r4, CFG_SYPCR@l 581 ori r4, r4, CFG_SYPCR@l
568 stw r4, IM_SYPCR@l(r3) 582 stw r4, IM_SYPCR@l(r3)
569 #endif /* !CONFIG_COGENT */ 583 #endif /* !CONFIG_COGENT */
570 #if defined(CONFIG_WATCHDOG) 584 #if defined(CONFIG_WATCHDOG)
571 li r4, 21868 /* = 0x556c */ 585 li r4, 21868 /* = 0x556c */
572 sth r4, IM_SWSR@l(r3) 586 sth r4, IM_SWSR@l(r3)
573 li r4, -21959 /* = 0xaa39 */ 587 li r4, -21959 /* = 0xaa39 */
574 sth r4, IM_SWSR@l(r3) 588 sth r4, IM_SWSR@l(r3)
575 #endif /* CONFIG_WATCHDOG */ 589 #endif /* CONFIG_WATCHDOG */
576 590
577 /* Initialize the Hardware Implementation-dependent Registers */ 591 /* Initialize the Hardware Implementation-dependent Registers */
578 /* HID0 also contains cache control */ 592 /* HID0 also contains cache control */
579 /*--------------------------------------------------------------*/ 593 /*--------------------------------------------------------------*/
580 594
581 lis r3, CFG_HID0_INIT@h 595 lis r3, CFG_HID0_INIT@h
582 ori r3, r3, CFG_HID0_INIT@l 596 ori r3, r3, CFG_HID0_INIT@l
583 SYNC 597 SYNC
584 mtspr HID0, r3 598 mtspr HID0, r3
585 599
586 lis r3, CFG_HID0_FINAL@h 600 lis r3, CFG_HID0_FINAL@h
587 ori r3, r3, CFG_HID0_FINAL@l 601 ori r3, r3, CFG_HID0_FINAL@l
588 SYNC 602 SYNC
589 mtspr HID0, r3 603 mtspr HID0, r3
590 604
591 lis r3, CFG_HID2@h 605 lis r3, CFG_HID2@h
592 ori r3, r3, CFG_HID2@l 606 ori r3, r3, CFG_HID2@l
593 mtspr HID2, r3 607 mtspr HID2, r3
594 608
595 /* clear all BAT's */ 609 /* clear all BAT's */
596 /*--------------------------------------------------------------*/ 610 /*--------------------------------------------------------------*/
597 611
598 li r0, 0 612 li r0, 0
599 mtspr DBAT0U, r0 613 mtspr DBAT0U, r0
600 mtspr DBAT0L, r0 614 mtspr DBAT0L, r0
601 mtspr DBAT1U, r0 615 mtspr DBAT1U, r0
602 mtspr DBAT1L, r0 616 mtspr DBAT1L, r0
603 mtspr DBAT2U, r0 617 mtspr DBAT2U, r0
604 mtspr DBAT2L, r0 618 mtspr DBAT2L, r0
605 mtspr DBAT3U, r0 619 mtspr DBAT3U, r0
606 mtspr DBAT3L, r0 620 mtspr DBAT3L, r0
607 mtspr IBAT0U, r0 621 mtspr IBAT0U, r0
608 mtspr IBAT0L, r0 622 mtspr IBAT0L, r0
609 mtspr IBAT1U, r0 623 mtspr IBAT1U, r0
610 mtspr IBAT1L, r0 624 mtspr IBAT1L, r0
611 mtspr IBAT2U, r0 625 mtspr IBAT2U, r0
612 mtspr IBAT2L, r0 626 mtspr IBAT2L, r0
613 mtspr IBAT3U, r0 627 mtspr IBAT3U, r0
614 mtspr IBAT3L, r0 628 mtspr IBAT3L, r0
615 SYNC 629 SYNC
616 630
617 /* invalidate all tlb's */ 631 /* invalidate all tlb's */
618 /* */ 632 /* */
619 /* From the 603e User Manual: "The 603e provides the ability to */ 633 /* From the 603e User Manual: "The 603e provides the ability to */
620 /* invalidate a TLB entry. The TLB Invalidate Entry (tlbie) */ 634 /* invalidate a TLB entry. The TLB Invalidate Entry (tlbie) */
621 /* instruction invalidates the TLB entry indexed by the EA, and */ 635 /* instruction invalidates the TLB entry indexed by the EA, and */
622 /* operates on both the instruction and data TLBs simultaneously*/ 636 /* operates on both the instruction and data TLBs simultaneously*/
623 /* invalidating four TLB entries (both sets in each TLB). The */ 637 /* invalidating four TLB entries (both sets in each TLB). The */
624 /* index corresponds to bits 15-19 of the EA. To invalidate all */ 638 /* index corresponds to bits 15-19 of the EA. To invalidate all */
625 /* entries within both TLBs, 32 tlbie instructions should be */ 639 /* entries within both TLBs, 32 tlbie instructions should be */
626 /* issued, incrementing this field by one each time." */ 640 /* issued, incrementing this field by one each time." */
627 /* */ 641 /* */
628 /* "Note that the tlbia instruction is not implemented on the */ 642 /* "Note that the tlbia instruction is not implemented on the */
629 /* 603e." */ 643 /* 603e." */
630 /* */ 644 /* */
631 /* bits 15-19 correspond to addresses 0x00000000 to 0x0001F000 */ 645 /* bits 15-19 correspond to addresses 0x00000000 to 0x0001F000 */
632 /* incrementing by 0x1000 each time. The code below is sort of */ 646 /* incrementing by 0x1000 each time. The code below is sort of */
633 /* based on code in "flush_tlbs" from arch/ppc/kernel/head.S */ 647 /* based on code in "flush_tlbs" from arch/ppc/kernel/head.S */
634 /* */ 648 /* */
635 /*--------------------------------------------------------------*/ 649 /*--------------------------------------------------------------*/
636 650
637 li r3, 32 651 li r3, 32
638 mtctr r3 652 mtctr r3
639 li r3, 0 653 li r3, 0
640 1: tlbie r3 654 1: tlbie r3
641 addi r3, r3, 0x1000 655 addi r3, r3, 0x1000
642 bdnz 1b 656 bdnz 1b
643 SYNC 657 SYNC
644 658
645 /* Done! */ 659 /* Done! */
646 /*--------------------------------------------------------------*/ 660 /*--------------------------------------------------------------*/
647 661
648 blr 662 blr
649 663
650 #ifdef DEBUG 664 #ifdef DEBUG
651 665
652 /* 666 /*
653 * initialise things related to debugging. 667 * initialise things related to debugging.
654 * 668 *
655 * must be called after the global offset table (GOT) is initialised 669 * must be called after the global offset table (GOT) is initialised
656 * (GET_GOT) and after cpu_init_f() has executed. 670 * (GET_GOT) and after cpu_init_f() has executed.
657 */ 671 */
658 672
659 .globl init_debug 673 .globl init_debug
660 init_debug: 674 init_debug:
661 675
662 lis r3, (CFG_IMMR+IM_REGBASE)@h 676 lis r3, (CFG_IMMR+IM_REGBASE)@h
663 677
664 /* Quick and dirty hack to enable the RAM and copy the */ 678 /* Quick and dirty hack to enable the RAM and copy the */
665 /* vectors so that we can take exceptions. */ 679 /* vectors so that we can take exceptions. */
666 /*--------------------------------------------------------------*/ 680 /*--------------------------------------------------------------*/
667 /* write Memory Refresh Prescaler */ 681 /* write Memory Refresh Prescaler */
668 li r4, CFG_MPTPR 682 li r4, CFG_MPTPR
669 sth r4, IM_MPTPR@l(r3) 683 sth r4, IM_MPTPR@l(r3)
670 /* write 60x Refresh Timer */ 684 /* write 60x Refresh Timer */
671 li r4, CFG_PSRT 685 li r4, CFG_PSRT
672 stb r4, IM_PSRT@l(r3) 686 stb r4, IM_PSRT@l(r3)
673 /* init the 60x SDRAM Mode Register */ 687 /* init the 60x SDRAM Mode Register */
674 lis r4, (CFG_PSDMR|PSDMR_OP_NORM)@h 688 lis r4, (CFG_PSDMR|PSDMR_OP_NORM)@h
675 ori r4, r4, (CFG_PSDMR|PSDMR_OP_NORM)@l 689 ori r4, r4, (CFG_PSDMR|PSDMR_OP_NORM)@l
676 stw r4, IM_PSDMR@l(r3) 690 stw r4, IM_PSDMR@l(r3)
677 /* write Precharge All Banks command */ 691 /* write Precharge All Banks command */
678 lis r4, (CFG_PSDMR|PSDMR_OP_PREA)@h 692 lis r4, (CFG_PSDMR|PSDMR_OP_PREA)@h
679 ori r4, r4, (CFG_PSDMR|PSDMR_OP_PREA)@l 693 ori r4, r4, (CFG_PSDMR|PSDMR_OP_PREA)@l
680 stw r4, IM_PSDMR@l(r3) 694 stw r4, IM_PSDMR@l(r3)
681 stb r0, 0(0) 695 stb r0, 0(0)
682 /* write eight CBR Refresh commands */ 696 /* write eight CBR Refresh commands */
683 lis r4, (CFG_PSDMR|PSDMR_OP_CBRR)@h 697 lis r4, (CFG_PSDMR|PSDMR_OP_CBRR)@h
684 ori r4, r4, (CFG_PSDMR|PSDMR_OP_CBRR)@l 698 ori r4, r4, (CFG_PSDMR|PSDMR_OP_CBRR)@l
685 stw r4, IM_PSDMR@l(r3) 699 stw r4, IM_PSDMR@l(r3)
686 stb r0, 0(0) 700 stb r0, 0(0)
687 stb r0, 0(0) 701 stb r0, 0(0)
688 stb r0, 0(0) 702 stb r0, 0(0)
689 stb r0, 0(0) 703 stb r0, 0(0)
690 stb r0, 0(0) 704 stb r0, 0(0)
691 stb r0, 0(0) 705 stb r0, 0(0)
692 stb r0, 0(0) 706 stb r0, 0(0)
693 stb r0, 0(0) 707 stb r0, 0(0)
694 /* write Mode Register Write command */ 708 /* write Mode Register Write command */
695 lis r4, (CFG_PSDMR|PSDMR_OP_MRW)@h 709 lis r4, (CFG_PSDMR|PSDMR_OP_MRW)@h
696 ori r4, r4, (CFG_PSDMR|PSDMR_OP_MRW)@l 710 ori r4, r4, (CFG_PSDMR|PSDMR_OP_MRW)@l
697 stw r4, IM_PSDMR@l(r3) 711 stw r4, IM_PSDMR@l(r3)
698 stb r0, 0(0) 712 stb r0, 0(0)
699 /* write Normal Operation command and enable Refresh */ 713 /* write Normal Operation command and enable Refresh */
700 lis r4, (CFG_PSDMR|PSDMR_OP_NORM|PSDMR_RFEN)@h 714 lis r4, (CFG_PSDMR|PSDMR_OP_NORM|PSDMR_RFEN)@h
701 ori r4, r4, (CFG_PSDMR|PSDMR_OP_NORM|PSDMR_RFEN)@l 715 ori r4, r4, (CFG_PSDMR|PSDMR_OP_NORM|PSDMR_RFEN)@l
702 stw r4, IM_PSDMR@l(r3) 716 stw r4, IM_PSDMR@l(r3)
703 stb r0, 0(0) 717 stb r0, 0(0)
704 /* RAM should now be operational */ 718 /* RAM should now be operational */
705 719
706 #define VEC_WRD_CNT ((_end_of_vectors - _start + EXC_OFF_SYS_RESET) / 4) 720 #define VEC_WRD_CNT ((_end_of_vectors - _start + EXC_OFF_SYS_RESET) / 4)
707 721
708 lwz r3, GOT(_end_of_vectors) 722 lwz r3, GOT(_end_of_vectors)
709 rlwinm r4, r3, 0, 18, 31 /* _end_of_vectors & 0x3FFF */ 723 rlwinm r4, r3, 0, 18, 31 /* _end_of_vectors & 0x3FFF */
710 lis r5, VEC_WRD_CNT@h 724 lis r5, VEC_WRD_CNT@h
711 ori r5, r5, VEC_WRD_CNT@l 725 ori r5, r5, VEC_WRD_CNT@l
712 mtctr r5 726 mtctr r5
713 1: 727 1:
714 lwzu r5, -4(r3) 728 lwzu r5, -4(r3)
715 stwu r5, -4(r4) 729 stwu r5, -4(r4)
716 bdnz 1b 730 bdnz 1b
717 731
718 /* Load the Instruction Address Breakpoint Register (IABR). */ 732 /* Load the Instruction Address Breakpoint Register (IABR). */
719 /* */ 733 /* */
720 /* The address to load is stored in the first word of dual port */ 734 /* The address to load is stored in the first word of dual port */
721 /* ram and should be preserved while the power is on, so you */ 735 /* ram and should be preserved while the power is on, so you */
722 /* can plug addresses into that location then reset the cpu and */ 736 /* can plug addresses into that location then reset the cpu and */
723 /* this code will load that address into the IABR after the */ 737 /* this code will load that address into the IABR after the */
724 /* reset. */ 738 /* reset. */
725 /* */ 739 /* */
726 /* When the program counter matches the contents of the IABR, */ 740 /* When the program counter matches the contents of the IABR, */
727 /* an exception is generated (before the instruction at that */ 741 /* an exception is generated (before the instruction at that */
728 /* location completes). The vector for this exception is 0x1300 */ 742 /* location completes). The vector for this exception is 0x1300 */
729 /*--------------------------------------------------------------*/ 743 /*--------------------------------------------------------------*/
730 lis r3, CFG_IMMR@h 744 lis r3, CFG_IMMR@h
731 lwz r3, 0(r3) 745 lwz r3, 0(r3)
732 mtspr IABR, r3 746 mtspr IABR, r3
733 747
734 /* Set the entire dual port RAM (where the initial stack */ 748 /* Set the entire dual port RAM (where the initial stack */
735 /* resides) to a known value - makes it easier to see where */ 749 /* resides) to a known value - makes it easier to see where */
736 /* the stack has been written */ 750 /* the stack has been written */
737 /*--------------------------------------------------------------*/ 751 /*--------------------------------------------------------------*/
738 lis r3, (CFG_IMMR + CFG_INIT_SP_OFFSET)@h 752 lis r3, (CFG_IMMR + CFG_INIT_SP_OFFSET)@h
739 ori r3, r3, (CFG_IMMR + CFG_INIT_SP_OFFSET)@l 753 ori r3, r3, (CFG_IMMR + CFG_INIT_SP_OFFSET)@l
740 li r4, ((CFG_INIT_SP_OFFSET - 4) / 4) 754 li r4, ((CFG_INIT_SP_OFFSET - 4) / 4)
741 mtctr r4 755 mtctr r4
742 lis r4, 0xdeadbeaf@h 756 lis r4, 0xdeadbeaf@h
743 ori r4, r4, 0xdeadbeaf@l 757 ori r4, r4, 0xdeadbeaf@l
744 1: 758 1:
745 stwu r4, -4(r3) 759 stwu r4, -4(r3)
746 bdnz 1b 760 bdnz 1b
747 761
748 /* Done! */ 762 /* Done! */
749 /*--------------------------------------------------------------*/ 763 /*--------------------------------------------------------------*/
750 764
751 blr 765 blr
752 #endif 766 #endif
753 767
754 /* Cache functions. 768 /* Cache functions.
755 * 769 *
756 * Note: requires that all cache bits in 770 * Note: requires that all cache bits in
757 * HID0 are in the low half word. 771 * HID0 are in the low half word.
758 */ 772 */
759 .globl icache_enable 773 .globl icache_enable
760 icache_enable: 774 icache_enable:
761 mfspr r3, HID0 775 mfspr r3, HID0
762 ori r3, r3, HID0_ICE 776 ori r3, r3, HID0_ICE
763 lis r4, 0 777 lis r4, 0
764 ori r4, r4, HID0_ILOCK 778 ori r4, r4, HID0_ILOCK
765 andc r3, r3, r4 779 andc r3, r3, r4
766 ori r4, r3, HID0_ICFI 780 ori r4, r3, HID0_ICFI
767 isync 781 isync
768 mtspr HID0, r4 /* sets enable and invalidate, clears lock */ 782 mtspr HID0, r4 /* sets enable and invalidate, clears lock */
769 isync 783 isync
770 mtspr HID0, r3 /* clears invalidate */ 784 mtspr HID0, r3 /* clears invalidate */
771 blr 785 blr
772 786
773 .globl icache_disable 787 .globl icache_disable
774 icache_disable: 788 icache_disable:
775 mfspr r3, HID0 789 mfspr r3, HID0
776 lis r4, 0 790 lis r4, 0
777 ori r4, r4, HID0_ICE|HID0_ILOCK 791 ori r4, r4, HID0_ICE|HID0_ILOCK
778 andc r3, r3, r4 792 andc r3, r3, r4
779 ori r4, r3, HID0_ICFI 793 ori r4, r3, HID0_ICFI
780 isync 794 isync
781 mtspr HID0, r4 /* sets invalidate, clears enable and lock */ 795 mtspr HID0, r4 /* sets invalidate, clears enable and lock */
782 isync 796 isync
783 mtspr HID0, r3 /* clears invalidate */ 797 mtspr HID0, r3 /* clears invalidate */
784 blr 798 blr
785 799
786 .globl icache_status 800 .globl icache_status
787 icache_status: 801 icache_status:
788 mfspr r3, HID0 802 mfspr r3, HID0
789 rlwinm r3, r3, HID0_ICE_BITPOS + 1, 31, 31 803 rlwinm r3, r3, HID0_ICE_BITPOS + 1, 31, 31
790 blr 804 blr
791 805
792 .globl dcache_enable 806 .globl dcache_enable
793 dcache_enable: 807 dcache_enable:
794 mfspr r3, HID0 808 mfspr r3, HID0
795 ori r3, r3, HID0_DCE 809 ori r3, r3, HID0_DCE
796 lis r4, 0 810 lis r4, 0
797 ori r4, r4, HID0_DLOCK 811 ori r4, r4, HID0_DLOCK
798 andc r3, r3, r4 812 andc r3, r3, r4
799 ori r4, r3, HID0_DCI 813 ori r4, r3, HID0_DCI
800 sync 814 sync
801 mtspr HID0, r4 /* sets enable and invalidate, clears lock */ 815 mtspr HID0, r4 /* sets enable and invalidate, clears lock */
802 sync 816 sync
803 mtspr HID0, r3 /* clears invalidate */ 817 mtspr HID0, r3 /* clears invalidate */
804 blr 818 blr
805 819
806 .globl dcache_disable 820 .globl dcache_disable
807 dcache_disable: 821 dcache_disable:
808 mfspr r3, HID0 822 mfspr r3, HID0
809 lis r4, 0 823 lis r4, 0
810 ori r4, r4, HID0_DCE|HID0_DLOCK 824 ori r4, r4, HID0_DCE|HID0_DLOCK
811 andc r3, r3, r4 825 andc r3, r3, r4
812 ori r4, r3, HID0_DCI 826 ori r4, r3, HID0_DCI
813 sync 827 sync
814 mtspr HID0, r4 /* sets invalidate, clears enable and lock */ 828 mtspr HID0, r4 /* sets invalidate, clears enable and lock */
815 sync 829 sync
816 mtspr HID0, r3 /* clears invalidate */ 830 mtspr HID0, r3 /* clears invalidate */
817 blr 831 blr
818 832
819 .globl dcache_status 833 .globl dcache_status
820 dcache_status: 834 dcache_status:
821 mfspr r3, HID0 835 mfspr r3, HID0
822 rlwinm r3, r3, HID0_DCE_BITPOS + 1, 31, 31 836 rlwinm r3, r3, HID0_DCE_BITPOS + 1, 31, 31
823 blr 837 blr
824 838
825 .globl get_pvr 839 .globl get_pvr
826 get_pvr: 840 get_pvr:
827 mfspr r3, PVR 841 mfspr r3, PVR
828 blr 842 blr
829 843
830 /*------------------------------------------------------------------------------*/ 844 /*------------------------------------------------------------------------------*/
831 845
832 /* 846 /*
833 * void relocate_code (addr_sp, gd, addr_moni) 847 * void relocate_code (addr_sp, gd, addr_moni)
834 * 848 *
835 * This "function" does not return, instead it continues in RAM 849 * This "function" does not return, instead it continues in RAM
836 * after relocating the monitor code. 850 * after relocating the monitor code.
837 * 851 *
838 * r3 = dest 852 * r3 = dest
839 * r4 = src 853 * r4 = src
840 * r5 = length in bytes 854 * r5 = length in bytes
841 * r6 = cachelinesize 855 * r6 = cachelinesize
842 */ 856 */
843 .globl relocate_code 857 .globl relocate_code
844 relocate_code: 858 relocate_code:
845 mr r1, r3 /* Set new stack pointer */ 859 mr r1, r3 /* Set new stack pointer */
846 mr r9, r4 /* Save copy of Global Data pointer */ 860 mr r9, r4 /* Save copy of Global Data pointer */
847 mr r10, r5 /* Save copy of Destination Address */ 861 mr r10, r5 /* Save copy of Destination Address */
848 862
849 mr r3, r5 /* Destination Address */ 863 mr r3, r5 /* Destination Address */
850 lis r4, CFG_MONITOR_BASE@h /* Source Address */ 864 lis r4, CFG_MONITOR_BASE@h /* Source Address */
851 ori r4, r4, CFG_MONITOR_BASE@l 865 ori r4, r4, CFG_MONITOR_BASE@l
852 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */ 866 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */
853 ori r5, r5, CFG_MONITOR_LEN@l 867 ori r5, r5, CFG_MONITOR_LEN@l
854 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */ 868 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
855 869
856 /* 870 /*
857 * Fix GOT pointer: 871 * Fix GOT pointer:
858 * 872 *
859 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address 873 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
860 * 874 *
861 * Offset: 875 * Offset:
862 */ 876 */
863 sub r15, r10, r4 877 sub r15, r10, r4
864 878
865 /* First our own GOT */ 879 /* First our own GOT */
866 add r14, r14, r15 880 add r14, r14, r15
867 /* then the one used by the C code */ 881 /* then the one used by the C code */
868 add r30, r30, r15 882 add r30, r30, r15
869 883
870 /* 884 /*
871 * Now relocate code 885 * Now relocate code
872 */ 886 */
873 887
874 cmplw cr1,r3,r4 888 cmplw cr1,r3,r4
875 addi r0,r5,3 889 addi r0,r5,3
876 srwi. r0,r0,2 890 srwi. r0,r0,2
877 beq cr1,4f /* In place copy is not necessary */ 891 beq cr1,4f /* In place copy is not necessary */
878 beq 7f /* Protect against 0 count */ 892 beq 7f /* Protect against 0 count */
879 mtctr r0 893 mtctr r0
880 bge cr1,2f 894 bge cr1,2f
881 895
882 la r8,-4(r4) 896 la r8,-4(r4)
883 la r7,-4(r3) 897 la r7,-4(r3)
884 1: lwzu r0,4(r8) 898 1: lwzu r0,4(r8)
885 stwu r0,4(r7) 899 stwu r0,4(r7)
886 bdnz 1b 900 bdnz 1b
887 b 4f 901 b 4f
888 902
889 2: slwi r0,r0,2 903 2: slwi r0,r0,2
890 add r8,r4,r0 904 add r8,r4,r0
891 add r7,r3,r0 905 add r7,r3,r0
892 3: lwzu r0,-4(r8) 906 3: lwzu r0,-4(r8)
893 stwu r0,-4(r7) 907 stwu r0,-4(r7)
894 bdnz 3b 908 bdnz 3b
895 909
896 /* 910 /*
897 * Now flush the cache: note that we must start from a cache aligned 911 * Now flush the cache: note that we must start from a cache aligned
898 * address. Otherwise we might miss one cache line. 912 * address. Otherwise we might miss one cache line.
899 */ 913 */
900 4: cmpwi r6,0 914 4: cmpwi r6,0
901 add r5,r3,r5 915 add r5,r3,r5
902 beq 7f /* Always flush prefetch queue in any case */ 916 beq 7f /* Always flush prefetch queue in any case */
903 subi r0,r6,1 917 subi r0,r6,1
904 andc r3,r3,r0 918 andc r3,r3,r0
905 mfspr r7,HID0 /* don't do dcbst if dcache is disabled */ 919 mfspr r7,HID0 /* don't do dcbst if dcache is disabled */
906 rlwinm r7,r7,HID0_DCE_BITPOS+1,31,31 920 rlwinm r7,r7,HID0_DCE_BITPOS+1,31,31
907 cmpwi r7,0 921 cmpwi r7,0
908 beq 9f 922 beq 9f
909 mr r4,r3 923 mr r4,r3
910 5: dcbst 0,r4 924 5: dcbst 0,r4
911 add r4,r4,r6 925 add r4,r4,r6
912 cmplw r4,r5 926 cmplw r4,r5
913 blt 5b 927 blt 5b
914 sync /* Wait for all dcbst to complete on bus */ 928 sync /* Wait for all dcbst to complete on bus */
915 9: mfspr r7,HID0 /* don't do icbi if icache is disabled */ 929 9: mfspr r7,HID0 /* don't do icbi if icache is disabled */
916 rlwinm r7,r7,HID0_ICE_BITPOS+1,31,31 930 rlwinm r7,r7,HID0_ICE_BITPOS+1,31,31
917 cmpwi r7,0 931 cmpwi r7,0
918 beq 7f 932 beq 7f
919 mr r4,r3 933 mr r4,r3
920 6: icbi 0,r4 934 6: icbi 0,r4
921 add r4,r4,r6 935 add r4,r4,r6
922 cmplw r4,r5 936 cmplw r4,r5
923 blt 6b 937 blt 6b
924 7: sync /* Wait for all icbi to complete on bus */ 938 7: sync /* Wait for all icbi to complete on bus */
925 isync 939 isync
926 940
927 /* 941 /*
928 * We are done. Do not return, instead branch to second part of board 942 * We are done. Do not return, instead branch to second part of board
929 * initialization, now running from RAM. 943 * initialization, now running from RAM.
930 */ 944 */
931 945
932 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET 946 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
933 mtlr r0 947 mtlr r0
934 blr 948 blr
935 949
936 in_ram: 950 in_ram:
937 951
938 /* 952 /*
939 * Relocation Function, r14 point to got2+0x8000 953 * Relocation Function, r14 point to got2+0x8000
940 * 954 *
941 * Adjust got2 pointers, no need to check for 0, this code 955 * Adjust got2 pointers, no need to check for 0, this code
942 * already puts a few entries in the table. 956 * already puts a few entries in the table.
943 */ 957 */
944 li r0,__got2_entries@sectoff@l 958 li r0,__got2_entries@sectoff@l
945 la r3,GOT(_GOT2_TABLE_) 959 la r3,GOT(_GOT2_TABLE_)
946 lwz r11,GOT(_GOT2_TABLE_) 960 lwz r11,GOT(_GOT2_TABLE_)
947 mtctr r0 961 mtctr r0
948 sub r11,r3,r11 962 sub r11,r3,r11
949 addi r3,r3,-4 963 addi r3,r3,-4
950 1: lwzu r0,4(r3) 964 1: lwzu r0,4(r3)
951 add r0,r0,r11 965 add r0,r0,r11
952 stw r0,0(r3) 966 stw r0,0(r3)
953 bdnz 1b 967 bdnz 1b
954 968
955 /* 969 /*
956 * Now adjust the fixups and the pointers to the fixups 970 * Now adjust the fixups and the pointers to the fixups
957 * in case we need to move ourselves again. 971 * in case we need to move ourselves again.
958 */ 972 */
959 2: li r0,__fixup_entries@sectoff@l 973 2: li r0,__fixup_entries@sectoff@l
960 lwz r3,GOT(_FIXUP_TABLE_) 974 lwz r3,GOT(_FIXUP_TABLE_)
961 cmpwi r0,0 975 cmpwi r0,0
962 mtctr r0 976 mtctr r0
963 addi r3,r3,-4 977 addi r3,r3,-4
964 beq 4f 978 beq 4f
965 3: lwzu r4,4(r3) 979 3: lwzu r4,4(r3)
966 lwzux r0,r4,r11 980 lwzux r0,r4,r11
967 add r0,r0,r11 981 add r0,r0,r11
968 stw r10,0(r3) 982 stw r10,0(r3)
969 stw r0,0(r4) 983 stw r0,0(r4)
970 bdnz 3b 984 bdnz 3b
971 4: 985 4:
972 clear_bss: 986 clear_bss:
973 /* 987 /*
974 * Now clear BSS segment 988 * Now clear BSS segment
975 */ 989 */
976 lwz r3,GOT(.bss) 990 lwz r3,GOT(.bss)
977 #if defined(CONFIG_HYMOD) 991 #if defined(CONFIG_HYMOD)
978 /* 992 /*
979 * For HYMOD - the environment is the very last item in flash. 993 * For HYMOD - the environment is the very last item in flash.
980 * The real .bss stops just before environment starts, so only 994 * The real .bss stops just before environment starts, so only
981 * clear up to that point. 995 * clear up to that point.
982 * 996 *
983 * taken from mods for FADS board 997 * taken from mods for FADS board
984 */ 998 */
985 lwz r4,GOT(environment) 999 lwz r4,GOT(environment)
986 #else 1000 #else
987 lwz r4,GOT(_end) 1001 lwz r4,GOT(_end)
988 #endif 1002 #endif
989 1003
990 cmplw 0, r3, r4 1004 cmplw 0, r3, r4
991 beq 6f 1005 beq 6f
992 1006
993 li r0, 0 1007 li r0, 0
994 5: 1008 5:
995 stw r0, 0(r3) 1009 stw r0, 0(r3)
996 addi r3, r3, 4 1010 addi r3, r3, 4
997 cmplw 0, r3, r4 1011 cmplw 0, r3, r4
998 bne 5b 1012 bne 5b
999 6: 1013 6:
1000 1014
1001 mr r3, r9 /* Global Data pointer */ 1015 mr r3, r9 /* Global Data pointer */
1002 mr r4, r10 /* Destination Address */ 1016 mr r4, r10 /* Destination Address */
1003 bl board_init_r 1017 bl board_init_r
1004 1018
1005 /* Problems accessing "end" in C, so do it here */ 1019 /* Problems accessing "end" in C, so do it here */
1006 .globl get_endaddr 1020 .globl get_endaddr
1007 get_endaddr: 1021 get_endaddr:
1008 lwz r3,GOT(_end) 1022 lwz r3,GOT(_end)
1009 blr 1023 blr
1010 1024
1011 /* 1025 /*
1012 * Copy exception vector code to low memory 1026 * Copy exception vector code to low memory
1013 * 1027 *
1014 * r3: dest_addr 1028 * r3: dest_addr
1015 * r7: source address, r8: end address, r9: target address 1029 * r7: source address, r8: end address, r9: target address
1016 */ 1030 */
1017 .globl trap_init 1031 .globl trap_init
1018 trap_init: 1032 trap_init:
1019 lwz r7, GOT(_start) 1033 lwz r7, GOT(_start)
1020 lwz r8, GOT(_end_of_vectors) 1034 lwz r8, GOT(_end_of_vectors)
1021 1035
1022 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */ 1036 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
1023 1037
1024 cmplw 0, r7, r8 1038 cmplw 0, r7, r8
1025 bgelr /* return if r7>=r8 - just in case */ 1039 bgelr /* return if r7>=r8 - just in case */
1026 1040
1027 mflr r4 /* save link register */ 1041 mflr r4 /* save link register */
1028 1: 1042 1:
1029 lwz r0, 0(r7) 1043 lwz r0, 0(r7)
1030 stw r0, 0(r9) 1044 stw r0, 0(r9)
1031 addi r7, r7, 4 1045 addi r7, r7, 4
1032 addi r9, r9, 4 1046 addi r9, r9, 4
1033 cmplw 0, r7, r8 1047 cmplw 0, r7, r8
1034 bne 1b 1048 bne 1b
1035 1049
1036 /* 1050 /*
1037 * relocate `hdlr' and `int_return' entries 1051 * relocate `hdlr' and `int_return' entries
1038 */ 1052 */
1039 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET 1053 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
1040 li r8, Alignment - _start + EXC_OFF_SYS_RESET 1054 li r8, Alignment - _start + EXC_OFF_SYS_RESET
1041 2: 1055 2:
1042 bl trap_reloc 1056 bl trap_reloc
1043 addi r7, r7, 0x100 /* next exception vector */ 1057 addi r7, r7, 0x100 /* next exception vector */
1044 cmplw 0, r7, r8 1058 cmplw 0, r7, r8
1045 blt 2b 1059 blt 2b
1046 1060
1047 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET 1061 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
1048 bl trap_reloc 1062 bl trap_reloc
1049 1063
1050 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET 1064 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
1051 bl trap_reloc 1065 bl trap_reloc
1052 1066
1053 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET 1067 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
1054 li r8, SystemCall - _start + EXC_OFF_SYS_RESET 1068 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
1055 3: 1069 3:
1056 bl trap_reloc 1070 bl trap_reloc
1057 addi r7, r7, 0x100 /* next exception vector */ 1071 addi r7, r7, 0x100 /* next exception vector */
1058 cmplw 0, r7, r8 1072 cmplw 0, r7, r8
1059 blt 3b 1073 blt 3b
1060 1074
1061 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET 1075 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
1062 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET 1076 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
1063 4: 1077 4:
1064 bl trap_reloc 1078 bl trap_reloc
1065 addi r7, r7, 0x100 /* next exception vector */ 1079 addi r7, r7, 0x100 /* next exception vector */
1066 cmplw 0, r7, r8 1080 cmplw 0, r7, r8
1067 blt 4b 1081 blt 4b
1068 1082
1069 mfmsr r3 /* now that the vectors have */ 1083 mfmsr r3 /* now that the vectors have */
1070 lis r7, MSR_IP@h /* relocated into low memory */ 1084 lis r7, MSR_IP@h /* relocated into low memory */
1071 ori r7, r7, MSR_IP@l /* MSR[IP] can be turned off */ 1085 ori r7, r7, MSR_IP@l /* MSR[IP] can be turned off */
1072 andc r3, r3, r7 /* (if it was on) */ 1086 andc r3, r3, r7 /* (if it was on) */
1073 SYNC /* Some chip revs need this... */ 1087 SYNC /* Some chip revs need this... */
1074 mtmsr r3 1088 mtmsr r3
1075 SYNC 1089 SYNC
1076 1090
1077 mtlr r4 /* restore link register */ 1091 mtlr r4 /* restore link register */
1078 blr 1092 blr
1079 1093
1080 /* 1094 /*
1081 * Function: relocate entries for one exception vector 1095 * Function: relocate entries for one exception vector
1082 */ 1096 */
1083 trap_reloc: 1097 trap_reloc:
1084 lwz r0, 0(r7) /* hdlr ... */ 1098 lwz r0, 0(r7) /* hdlr ... */
1085 add r0, r0, r3 /* ... += dest_addr */ 1099 add r0, r0, r3 /* ... += dest_addr */
1086 stw r0, 0(r7) 1100 stw r0, 0(r7)
1087 1101
1088 lwz r0, 4(r7) /* int_return ... */ 1102 lwz r0, 4(r7) /* int_return ... */
1089 add r0, r0, r3 /* ... += dest_addr */ 1103 add r0, r0, r3 /* ... += dest_addr */
1090 stw r0, 4(r7) 1104 stw r0, 4(r7)
1091 1105
1092 blr 1106 blr
1093 1107
cpu/mpc8xx/interrupts.c
1 /* 1 /*
2 * (C) Copyright 2000-2002 2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 #include <common.h> 24 #include <common.h>
25 #include <watchdog.h> 25 #include <watchdog.h>
26 #include <mpc8xx.h> 26 #include <mpc8xx.h>
27 #include <mpc8xx_irq.h> 27 #include <mpc8xx_irq.h>
28 #include <asm/processor.h> 28 #include <asm/processor.h>
29 #include <commproc.h> 29 #include <commproc.h>
30 30
31 /****************************************************************************/ 31 /************************************************************************/
32 32
33 unsigned decrementer_count; /* count value for 1e6/HZ microseconds */ 33 unsigned decrementer_count; /* count value for 1e6/HZ microseconds */
34 34
35 /****************************************************************************/ 35 /************************************************************************/
36 36
37 /* 37 /*
38 * CPM interrupt vector functions. 38 * CPM interrupt vector functions.
39 */ 39 */
40 struct cpm_action { 40 struct interrupt_action {
41 interrupt_handler_t *handler; 41 interrupt_handler_t *handler;
42 void *arg; 42 void *arg;
43 }; 43 };
44 44
45 static struct cpm_action cpm_vecs[CPMVEC_NR]; 45 static struct interrupt_action cpm_vecs[CPMVEC_NR];
46 static struct interrupt_action irq_vecs[NR_IRQS];
46 47
47 static void cpm_interrupt_init (void); 48 static void cpm_interrupt_init (void);
48 static void cpm_interrupt(int irq, struct pt_regs * regs); 49 static void cpm_interrupt (void *regs);
49 50
50 /****************************************************************************/ 51 /************************************************************************/
51 52
52 static __inline__ unsigned long get_msr(void) 53 static __inline__ unsigned long get_msr (void)
53 { 54 {
54 unsigned long msr; 55 unsigned long msr;
55 56
56 asm volatile("mfmsr %0" : "=r" (msr) :); 57 asm volatile ("mfmsr %0":"=r" (msr):);
57 return msr; 58
59 return msr;
58 } 60 }
59 61
60 static __inline__ void set_msr(unsigned long msr) 62 static __inline__ void set_msr (unsigned long msr)
61 { 63 {
62 asm volatile("mtmsr %0" : : "r" (msr)); 64 asm volatile ("mtmsr %0"::"r" (msr));
63 } 65 }
64 66
65 static __inline__ unsigned long get_dec(void) 67 static __inline__ unsigned long get_dec (void)
66 { 68 {
67 unsigned long val; 69 unsigned long val;
68 70
69 asm volatile("mfdec %0" : "=r" (val) :); 71 asm volatile ("mfdec %0":"=r" (val):);
70 return val; 72
73 return val;
71 } 74 }
72 75
73 76
74 static __inline__ void set_dec(unsigned long val) 77 static __inline__ void set_dec (unsigned long val)
75 { 78 {
76 asm volatile("mtdec %0" : : "r" (val)); 79 asm volatile ("mtdec %0"::"r" (val));
77 } 80 }
78 81
79 82
80 void enable_interrupts (void) 83 void enable_interrupts (void)
81 { 84 {
82 set_msr (get_msr() | MSR_EE); 85 set_msr (get_msr () | MSR_EE);
83 } 86 }
84 87
85 /* returns flag if MSR_EE was set before */ 88 /* returns flag if MSR_EE was set before */
86 int disable_interrupts (void) 89 int disable_interrupts (void)
87 { 90 {
88 ulong msr = get_msr(); 91 ulong msr = get_msr ();
92
89 set_msr (msr & ~MSR_EE); 93 set_msr (msr & ~MSR_EE);
90 return ((msr & MSR_EE) != 0); 94 return ((msr & MSR_EE) != 0);
91 } 95 }
92 96
93 /****************************************************************************/ 97 /************************************************************************/
94 98
95 int interrupt_init(void) 99 int interrupt_init (void)
96 { 100 {
97 volatile immap_t *immr = (immap_t *)CFG_IMMR; 101 volatile immap_t *immr = (immap_t *) CFG_IMMR;
98 102
99 decrementer_count = get_tbclk() / CFG_HZ; 103 decrementer_count = get_tbclk () / CFG_HZ;
100 104
101 cpm_interrupt_init(); 105 /* disable all interrupts */
106 immr->im_siu_conf.sc_simask = 0;
102 107
103 /* disable all interrupts except for the CPM interrupt */ 108 /* Configure CPM interrupts */
104 immr->im_siu_conf.sc_simask = 1 << (31-CPM_INTERRUPT); 109 cpm_interrupt_init ();
105 110
106 set_dec (decrementer_count); 111 set_dec (decrementer_count);
107 112
108 set_msr (get_msr() | MSR_EE); 113 set_msr (get_msr () | MSR_EE);
109 114
110 return (0); 115 return (0);
111 } 116 }
112 117
113 /****************************************************************************/ 118 /************************************************************************/
114 119
115 /* 120 /*
116 * Handle external interrupts 121 * Handle external interrupts
117 */ 122 */
118 void external_interrupt(struct pt_regs *regs) 123 void external_interrupt (struct pt_regs *regs)
119 { 124 {
120 volatile immap_t *immr = (immap_t *)CFG_IMMR; 125 volatile immap_t *immr = (immap_t *) CFG_IMMR;
121 int irq; 126 int irq;
122 ulong simask, newmask; 127 ulong simask, newmask;
123 ulong vec, v_bit; 128 ulong vec, v_bit;
124 129
125 /* 130 /*
126 * read the SIVEC register and shift the bits down 131 * read the SIVEC register and shift the bits down
127 * to get the irq number 132 * to get the irq number
128 */ 133 */
129 vec = immr->im_siu_conf.sc_sivec; 134 vec = immr->im_siu_conf.sc_sivec;
130 irq = vec >> 26; 135 irq = vec >> 26;
131 v_bit = 0x80000000UL >> irq; 136 v_bit = 0x80000000UL >> irq;
132 137
133 /* 138 /*
134 * Read Interrupt Mask Register and Mask Interrupts 139 * Read Interrupt Mask Register and Mask Interrupts
135 */ 140 */
136 simask = immr->im_siu_conf.sc_simask; 141 simask = immr->im_siu_conf.sc_simask;
137 newmask = simask & (~(0xFFFF0000 >> irq)); 142 newmask = simask & (~(0xFFFF0000 >> irq));
138 immr->im_siu_conf.sc_simask = newmask; 143 immr->im_siu_conf.sc_simask = newmask;
139 144
140 if (!(irq & 0x1)) { /* External Interrupt ? */ 145 if (!(irq & 0x1)) { /* External Interrupt ? */
141 ulong siel; 146 ulong siel;
147
142 /* 148 /*
143 * Read Interrupt Edge/Level Register 149 * Read Interrupt Edge/Level Register
144 */ 150 */
145 siel = immr->im_siu_conf.sc_siel; 151 siel = immr->im_siu_conf.sc_siel;
146 152
147 if (siel & v_bit) { /* edge triggered interrupt ? */ 153 if (siel & v_bit) { /* edge triggered interrupt ? */
148 /* 154 /*
149 * Rewrite SIPEND Register to clear interrupt 155 * Rewrite SIPEND Register to clear interrupt
150 */ 156 */
151 immr->im_siu_conf.sc_sipend = v_bit; 157 immr->im_siu_conf.sc_sipend = v_bit;
152 } 158 }
153 } 159 }
154 160
155 switch (irq) { 161 if (irq_vecs[irq].handler != NULL) {
156 case CPM_INTERRUPT: 162 irq_vecs[irq].handler (irq_vecs[irq].arg);
157 cpm_interrupt (irq, regs); 163 } else {
158 break;
159 default:
160 printf ("\nBogus External Interrupt IRQ %d Vector %ld\n", 164 printf ("\nBogus External Interrupt IRQ %d Vector %ld\n",
161 irq, vec); 165 irq, vec);
162 /* turn off the bogus interrupt to avoid it from now */ 166 /* turn off the bogus interrupt to avoid it from now */
163 simask &= ~v_bit; 167 simask &= ~v_bit;
164 break;
165 } 168 }
166
167 /* 169 /*
168 * Re-Enable old Interrupt Mask 170 * Re-Enable old Interrupt Mask
169 */ 171 */
170 immr->im_siu_conf.sc_simask = simask; 172 immr->im_siu_conf.sc_simask = simask;
171 } 173 }
172 174
173 /****************************************************************************/ 175 /************************************************************************/
174 176
175 /* 177 /*
176 * CPM interrupt handler 178 * CPM interrupt handler
177 */ 179 */
178 static void 180 static void cpm_interrupt (void *regs)
179 cpm_interrupt(int irq, struct pt_regs * regs)
180 { 181 {
181 volatile immap_t *immr = (immap_t *)CFG_IMMR; 182 volatile immap_t *immr = (immap_t *) CFG_IMMR;
182 uint vec; 183 uint vec;
183 184
184 /* 185 /*
185 * Get the vector by setting the ACK bit 186 * Get the vector by setting the ACK bit
186 * and then reading the register. 187 * and then reading the register.
187 */ 188 */
188 immr->im_cpic.cpic_civr = 1; 189 immr->im_cpic.cpic_civr = 1;
189 vec = immr->im_cpic.cpic_civr; 190 vec = immr->im_cpic.cpic_civr;
190 vec >>= 11; 191 vec >>= 11;
191 192
192 if (cpm_vecs[vec].handler != NULL) { 193 if (cpm_vecs[vec].handler != NULL) {
193 (*cpm_vecs[vec].handler)(cpm_vecs[vec].arg); 194 (*cpm_vecs[vec].handler) (cpm_vecs[vec].arg);
194 } else { 195 } else {
195 immr->im_cpic.cpic_cimr &= ~(1 << vec); 196 immr->im_cpic.cpic_cimr &= ~(1 << vec);
196 printf ("Masking bogus CPM interrupt vector 0x%x\n", vec); 197 printf ("Masking bogus CPM interrupt vector 0x%x\n", vec);
197 } 198 }
198 /* 199 /*
199 * After servicing the interrupt, we have to remove the status indicator. 200 * After servicing the interrupt,
201 * we have to remove the status indicator.
200 */ 202 */
201 immr->im_cpic.cpic_cisr |= (1 << vec); 203 immr->im_cpic.cpic_cisr |= (1 << vec);
202 } 204 }
203 205
204 /* 206 /*
205 * The CPM can generate the error interrupt when there is a race 207 * The CPM can generate the error interrupt when there is a race
206 * condition between generating and masking interrupts. All we have 208 * condition between generating and masking interrupts. All we have
207 * to do is ACK it and return. This is a no-op function so we don't 209 * to do is ACK it and return. This is a no-op function so we don't
208 * need any special tests in the interrupt handler. 210 * need any special tests in the interrupt handler.
209 */ 211 */
210 static void 212 static void cpm_error_interrupt (void *dummy)
211 cpm_error_interrupt (void *dummy)
212 { 213 {
213 } 214 }
214 215
215 /****************************************************************************/ 216 /************************************************************************/
216
217 /* 217 /*
218 * Install and free a CPM interrupt handler. 218 * Install and free an interrupt handler
219 */ 219 */
220 220 void irq_install_handler (int vec, interrupt_handler_t * handler,
221 void 221 void *arg)
222 irq_install_handler(int vec, interrupt_handler_t *handler, void *arg)
223 { 222 {
224 volatile immap_t *immr = (immap_t *)CFG_IMMR; 223 volatile immap_t *immr = (immap_t *) CFG_IMMR;
225 224
226 if (cpm_vecs[vec].handler != NULL) { 225 if ((vec & CPMVEC_OFFSET) != 0) {
227 printf ("CPM interrupt 0x%x replacing 0x%x\n", 226 /* CPM interrupt */
228 (uint)handler, (uint)cpm_vecs[vec].handler); 227 vec &= 0xffff;
229 } 228 if (cpm_vecs[vec].handler != NULL) {
230 cpm_vecs[vec].handler = handler; 229 printf ("CPM interrupt 0x%x replacing 0x%x\n",
231 cpm_vecs[vec].arg = arg; 230 (uint) handler,
232 immr->im_cpic.cpic_cimr |= (1 << vec); 231 (uint) cpm_vecs[vec].handler);
232 }
233 cpm_vecs[vec].handler = handler;
234 cpm_vecs[vec].arg = arg;
235 immr->im_cpic.cpic_cimr |= (1 << vec);
233 #if 0 236 #if 0
234 printf ("Install CPM interrupt for vector %d ==> %p\n", vec, handler); 237 printf ("Install CPM interrupt for vector %d ==> %p\n",
238 vec, handler);
235 #endif 239 #endif
240 } else {
241 /* SIU interrupt */
242 if (irq_vecs[vec].handler != NULL) {
243 printf ("SIU interrupt %d 0x%x replacing 0x%x\n",
244 vec,
245 (uint) handler,
246 (uint) cpm_vecs[vec].handler);
247 }
248 irq_vecs[vec].handler = handler;
249 irq_vecs[vec].arg = arg;
250 immr->im_siu_conf.sc_simask |= 1 << (31 - vec);
251 #if 0
252 printf ("Install SIU interrupt for vector %d ==> %p\n",
253 vec, handler);
254 #endif
255 }
236 } 256 }
237 257
238 void 258 void irq_free_handler (int vec)
239 irq_free_handler(int vec)
240 { 259 {
241 volatile immap_t *immr = (immap_t *)CFG_IMMR; 260 volatile immap_t *immr = (immap_t *) CFG_IMMR;
261
262 if ((vec & CPMVEC_OFFSET) != 0) {
263 /* CPM interrupt */
264 vec &= 0xffff;
242 #if 0 265 #if 0
243 printf ("Free CPM interrupt for vector %d ==> %p\n", 266 printf ("Free CPM interrupt for vector %d ==> %p\n",
244 vec, cpm_vecs[vec].handler); 267 vec, cpm_vecs[vec].handler);
245 #endif 268 #endif
246 immr->im_cpic.cpic_cimr &= ~(1 << vec); 269 immr->im_cpic.cpic_cimr &= ~(1 << vec);
247 cpm_vecs[vec].handler = NULL; 270 cpm_vecs[vec].handler = NULL;
248 cpm_vecs[vec].arg = NULL; 271 cpm_vecs[vec].arg = NULL;
272 } else {
273 /* SIU interrupt */
274 #if 0
275 printf ("Free CPM interrupt for vector %d ==> %p\n",
276 vec, cpm_vecs[vec].handler);
277 #endif
278 immr->im_siu_conf.sc_simask &= ~(1 << (31 - vec));
279 irq_vecs[vec].handler = NULL;
280 irq_vecs[vec].arg = NULL;
281 }
249 } 282 }
250 283
251 /****************************************************************************/ 284 /************************************************************************/
252 285
253 static void 286 static void cpm_interrupt_init (void)
254 cpm_interrupt_init (void)
255 { 287 {
256 volatile immap_t *immr = (immap_t *)CFG_IMMR; 288 volatile immap_t *immr = (immap_t *) CFG_IMMR;
257 289
258 /* 290 /*
259 * Initialize the CPM interrupt controller. 291 * Initialize the CPM interrupt controller.
260 */ 292 */
261 293
262 immr->im_cpic.cpic_cicr = 294 immr->im_cpic.cpic_cicr =
263 ( CICR_SCD_SCC4 | 295 (CICR_SCD_SCC4 |
264 CICR_SCC_SCC3 | 296 CICR_SCC_SCC3 |
265 CICR_SCB_SCC2 | 297 CICR_SCB_SCC2 |
266 CICR_SCA_SCC1 ) | ((CPM_INTERRUPT/2) << 13) | CICR_HP_MASK; 298 CICR_SCA_SCC1) | ((CPM_INTERRUPT / 2) << 13) | CICR_HP_MASK;
267 299
268 immr->im_cpic.cpic_cimr = 0; 300 immr->im_cpic.cpic_cimr = 0;
269 301
270 /* 302 /*
271 * Install the error handler. 303 * Install the error handler.
272 */ 304 */
273 irq_install_handler(CPMVEC_ERROR, cpm_error_interrupt, NULL); 305 irq_install_handler (CPMVEC_ERROR, cpm_error_interrupt, NULL);
274 306
275 immr->im_cpic.cpic_cicr |= CICR_IEN; 307 immr->im_cpic.cpic_cicr |= CICR_IEN;
308
309 /*
310 * Install the cpm interrupt handler
311 */
312 irq_install_handler (CPM_INTERRUPT, cpm_interrupt, NULL);
276 } 313 }
277 314
278 /****************************************************************************/ 315 /************************************************************************/
279 316
280 volatile ulong timestamp = 0; 317 volatile ulong timestamp = 0;
281 318
282 /* 319 /*
283 * timer_interrupt - gets called when the decrementer overflows, 320 * timer_interrupt - gets called when the decrementer overflows,
284 * with interrupts disabled. 321 * with interrupts disabled.
285 * Trivial implementation - no need to be really accurate. 322 * Trivial implementation - no need to be really accurate.
286 */ 323 */
287 void timer_interrupt(struct pt_regs *regs) 324 void timer_interrupt (struct pt_regs *regs)
288 { 325 {
289 volatile immap_t *immr = (immap_t *)CFG_IMMR; 326 volatile immap_t *immr = (immap_t *) CFG_IMMR;
327
290 #ifdef CONFIG_STATUS_LED 328 #ifdef CONFIG_STATUS_LED
291 extern void status_led_tick (ulong); 329 extern void status_led_tick (ulong);
292 #endif 330 #endif
293 #if 0 331 #if 0
294 printf ("*** Timer Interrupt *** "); 332 printf ("*** Timer Interrupt *** ");
295 #endif 333 #endif
296 /* Reset Timer Expired and Timers Interrupt Status */ 334 /* Reset Timer Expired and Timers Interrupt Status */
297 immr->im_clkrstk.cark_plprcrk = KAPWR_KEY; 335 immr->im_clkrstk.cark_plprcrk = KAPWR_KEY;
298 __asm__("nop"); 336 __asm__ ("nop");
299 immr->im_clkrst.car_plprcr |= PLPRCR_TEXPS | PLPRCR_TMIST; 337 immr->im_clkrst.car_plprcr |= PLPRCR_TEXPS | PLPRCR_TMIST;
300 /* Restore Decrementer Count */ 338 /* Restore Decrementer Count */
301 set_dec (decrementer_count); 339 set_dec (decrementer_count);
302 340
303 timestamp++; 341 timestamp++;
304 342
305 #ifdef CONFIG_STATUS_LED 343 #ifdef CONFIG_STATUS_LED
306 status_led_tick (timestamp); 344 status_led_tick (timestamp);
307 #endif /* CONFIG_STATUS_LED */ 345 #endif /* CONFIG_STATUS_LED */
308 346
309 #if defined(CONFIG_WATCHDOG) || defined(CFG_CMA_LCD_HEARTBEAT) 347 #if defined(CONFIG_WATCHDOG) || defined(CFG_CMA_LCD_HEARTBEAT)
310 348
311
312 /* 349 /*
313 * The shortest watchdog period of all boards (except LWMON) 350 * The shortest watchdog period of all boards (except LWMON)
314 * is approx. 1 sec, thus re-trigger watchdog at least 351 * is approx. 1 sec, thus re-trigger watchdog at least
315 * every 500 ms = CFG_HZ / 2 352 * every 500 ms = CFG_HZ / 2
316 */ 353 */
317 #ifndef CONFIG_LWMON 354 #ifndef CONFIG_LWMON
318 if ((timestamp % (CFG_HZ / 2)) == 0) { 355 if ((timestamp % (CFG_HZ / 2)) == 0) {
319 #else 356 #else
320 if ((timestamp % (CFG_HZ / 20)) == 0) { 357 if ((timestamp % (CFG_HZ / 20)) == 0) {
321 #endif 358 #endif
322 359
323 #if defined(CFG_CMA_LCD_HEARTBEAT) 360 #if defined(CFG_CMA_LCD_HEARTBEAT)
324 extern void lcd_heartbeat(void); 361 extern void lcd_heartbeat (void);
325 lcd_heartbeat(); 362
363 lcd_heartbeat ();
326 #endif /* CFG_CMA_LCD_HEARTBEAT */ 364 #endif /* CFG_CMA_LCD_HEARTBEAT */
327 365
328 #if defined(CONFIG_WATCHDOG) 366 #if defined(CONFIG_WATCHDOG)
329 reset_8xx_watchdog(immr); 367 reset_8xx_watchdog (immr);
330 #endif /* CONFIG_WATCHDOG */ 368 #endif /* CONFIG_WATCHDOG */
331 369
332 } 370 }
333
334 #endif /* CONFIG_WATCHDOG || CFG_CMA_LCD_HEARTBEAT */ 371 #endif /* CONFIG_WATCHDOG || CFG_CMA_LCD_HEARTBEAT */
335 } 372 }
336 373
337 /****************************************************************************/ 374 /************************************************************************/
338 375
339 void reset_timer (void) 376 void reset_timer (void)
340 { 377 {
341 timestamp = 0; 378 timestamp = 0;
342 } 379 }
343 380
1 /* 1 /*
2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> 2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> 3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de> 4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
5 * 5 *
6 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
7 * project. 7 * project.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA 22 * MA 02111-1307 USA
23 */ 23 */
24 24
25 /* U-Boot - Startup Code for PowerPC based Embedded Boards 25 /* U-Boot - Startup Code for PowerPC based Embedded Boards
26 * 26 *
27 * 27 *
28 * The processor starts at 0x00000100 and the code is executed 28 * The processor starts at 0x00000100 and the code is executed
29 * from flash. The code is organized to be at an other address 29 * from flash. The code is organized to be at an other address
30 * in memory, but as long we don't jump around before relocating. 30 * in memory, but as long we don't jump around before relocating.
31 * board_init lies at a quite high address and when the cpu has 31 * board_init lies at a quite high address and when the cpu has
32 * jumped there, everything is ok. 32 * jumped there, everything is ok.
33 * This works because the cpu gives the FLASH (CS0) the whole 33 * This works because the cpu gives the FLASH (CS0) the whole
34 * address space at startup, and board_init lies as a echo of 34 * address space at startup, and board_init lies as a echo of
35 * the flash somewhere up there in the memorymap. 35 * the flash somewhere up there in the memorymap.
36 * 36 *
37 * board_init will change CS0 to be positioned at the correct 37 * board_init will change CS0 to be positioned at the correct
38 * address and (s)dram will be positioned at address 0 38 * address and (s)dram will be positioned at address 0
39 */ 39 */
40 #include <config.h> 40 #include <config.h>
41 #include <mpc8xx.h> 41 #include <mpc8xx.h>
42 #include <version.h> 42 #include <version.h>
43 43
44 #define CONFIG_8xx 1 /* needed for Linux kernel header files */ 44 #define CONFIG_8xx 1 /* needed for Linux kernel header files */
45 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ 45 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
46 46
47 #include <ppc_asm.tmpl> 47 #include <ppc_asm.tmpl>
48 #include <ppc_defs.h> 48 #include <ppc_defs.h>
49 49
50 #include <asm/cache.h> 50 #include <asm/cache.h>
51 #include <asm/mmu.h> 51 #include <asm/mmu.h>
52 52
53 #ifndef CONFIG_IDENT_STRING 53 #ifndef CONFIG_IDENT_STRING
54 #define CONFIG_IDENT_STRING "" 54 #define CONFIG_IDENT_STRING ""
55 #endif 55 #endif
56 56
57 /* We don't want the MMU yet. 57 /* We don't want the MMU yet.
58 */ 58 */
59 #undef MSR_KERNEL 59 #undef MSR_KERNEL
60 #define MSR_KERNEL ( MSR_ME | MSR_RI ) /* Machine Check and Recoverable Interr. */ 60 #define MSR_KERNEL ( MSR_ME | MSR_RI ) /* Machine Check and Recoverable Interr. */
61 61
62 /* 62 /*
63 * Set up GOT: Global Offset Table 63 * Set up GOT: Global Offset Table
64 * 64 *
65 * Use r14 to access the GOT 65 * Use r14 to access the GOT
66 */ 66 */
67 START_GOT 67 START_GOT
68 GOT_ENTRY(_GOT2_TABLE_) 68 GOT_ENTRY(_GOT2_TABLE_)
69 GOT_ENTRY(_FIXUP_TABLE_) 69 GOT_ENTRY(_FIXUP_TABLE_)
70 70
71 GOT_ENTRY(_start) 71 GOT_ENTRY(_start)
72 GOT_ENTRY(_start_of_vectors) 72 GOT_ENTRY(_start_of_vectors)
73 GOT_ENTRY(_end_of_vectors) 73 GOT_ENTRY(_end_of_vectors)
74 GOT_ENTRY(transfer_to_handler) 74 GOT_ENTRY(transfer_to_handler)
75 75
76 GOT_ENTRY(_end) 76 GOT_ENTRY(_end)
77 GOT_ENTRY(.bss) 77 GOT_ENTRY(.bss)
78 #if defined(CONFIG_FADS) || defined(CONFIG_ICU862) 78 #if defined(CONFIG_FADS) || defined(CONFIG_ICU862)
79 GOT_ENTRY(environment) 79 GOT_ENTRY(environment)
80 #endif 80 #endif
81 END_GOT 81 END_GOT
82 82
83 /* 83 /*
84 * r3 - 1st arg to board_init(): IMMP pointer 84 * r3 - 1st arg to board_init(): IMMP pointer
85 * r4 - 2nd arg to board_init(): boot flag 85 * r4 - 2nd arg to board_init(): boot flag
86 */ 86 */
87 .text 87 .text
88 .long 0x27051956 /* U-Boot Magic Number */ 88 .long 0x27051956 /* U-Boot Magic Number */
89 .globl version_string 89 .globl version_string
90 version_string: 90 version_string:
91 .ascii U_BOOT_VERSION 91 .ascii U_BOOT_VERSION
92 .ascii " (", __DATE__, " - ", __TIME__, ")" 92 .ascii " (", __DATE__, " - ", __TIME__, ")"
93 .ascii CONFIG_IDENT_STRING, "\0" 93 .ascii CONFIG_IDENT_STRING, "\0"
94 94
95 . = EXC_OFF_SYS_RESET 95 . = EXC_OFF_SYS_RESET
96 .globl _start 96 .globl _start
97 _start: 97 _start:
98 lis r3, CFG_IMMR@h /* position IMMR */ 98 lis r3, CFG_IMMR@h /* position IMMR */
99 mtspr 638, r3 99 mtspr 638, r3
100 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */ 100 li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH */
101 b boot_cold 101 b boot_cold
102 102
103 . = EXC_OFF_SYS_RESET + 0x10 103 . = EXC_OFF_SYS_RESET + 0x10
104 104
105 .globl _start_warm 105 .globl _start_warm
106 _start_warm: 106 _start_warm:
107 li r21, BOOTFLAG_WARM /* Software reboot */ 107 li r21, BOOTFLAG_WARM /* Software reboot */
108 b boot_warm 108 b boot_warm
109 109
110 boot_cold: 110 boot_cold:
111 boot_warm: 111 boot_warm:
112 112
113 /* Initialize machine status; enable machine check interrupt */ 113 /* Initialize machine status; enable machine check interrupt */
114 /*----------------------------------------------------------------------*/ 114 /*----------------------------------------------------------------------*/
115 li r3, MSR_KERNEL /* Set ME, RI flags */ 115 li r3, MSR_KERNEL /* Set ME, RI flags */
116 mtmsr r3 116 mtmsr r3
117 mtspr SRR1, r3 /* Make SRR1 match MSR */ 117 mtspr SRR1, r3 /* Make SRR1 match MSR */
118 118
119 mfspr r3, ICR /* clear Interrupt Cause Register */ 119 mfspr r3, ICR /* clear Interrupt Cause Register */
120 120
121 /* Initialize debug port registers */ 121 /* Initialize debug port registers */
122 /*----------------------------------------------------------------------*/ 122 /*----------------------------------------------------------------------*/
123 xor r0, r0, r0 /* Clear R0 */ 123 xor r0, r0, r0 /* Clear R0 */
124 mtspr LCTRL1, r0 /* Initialize debug port regs */ 124 mtspr LCTRL1, r0 /* Initialize debug port regs */
125 mtspr LCTRL2, r0 125 mtspr LCTRL2, r0
126 mtspr COUNTA, r0 126 mtspr COUNTA, r0
127 mtspr COUNTB, r0 127 mtspr COUNTB, r0
128 128
129 /* Reset the caches */ 129 /* Reset the caches */
130 /*----------------------------------------------------------------------*/ 130 /*----------------------------------------------------------------------*/
131 131
132 mfspr r3, IC_CST /* Clear error bits */ 132 mfspr r3, IC_CST /* Clear error bits */
133 mfspr r3, DC_CST 133 mfspr r3, DC_CST
134 134
135 lis r3, IDC_UNALL@h /* Unlock all */ 135 lis r3, IDC_UNALL@h /* Unlock all */
136 mtspr IC_CST, r3 136 mtspr IC_CST, r3
137 mtspr DC_CST, r3 137 mtspr DC_CST, r3
138 138
139 lis r3, IDC_INVALL@h /* Invalidate all */ 139 lis r3, IDC_INVALL@h /* Invalidate all */
140 mtspr IC_CST, r3 140 mtspr IC_CST, r3
141 mtspr DC_CST, r3 141 mtspr DC_CST, r3
142 142
143 lis r3, IDC_DISABLE@h /* Disable data cache */ 143 lis r3, IDC_DISABLE@h /* Disable data cache */
144 mtspr DC_CST, r3 144 mtspr DC_CST, r3
145 145
146 #if !(defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || defined (CONFIG_FLAGADM)) 146 #if !(defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || defined (CONFIG_FLAGADM))
147 /* On IP860 and PCU E, 147 /* On IP860 and PCU E,
148 * we cannot enable IC yet 148 * we cannot enable IC yet
149 */ 149 */
150 lis r3, IDC_ENABLE@h /* Enable instruction cache */ 150 lis r3, IDC_ENABLE@h /* Enable instruction cache */
151 #endif 151 #endif
152 mtspr IC_CST, r3 152 mtspr IC_CST, r3
153 153
154 /* invalidate all tlb's */ 154 /* invalidate all tlb's */
155 /*----------------------------------------------------------------------*/ 155 /*----------------------------------------------------------------------*/
156 156
157 tlbia 157 tlbia
158 isync 158 isync
159 159
160 /* 160 /*
161 * Calculate absolute address in FLASH and jump there 161 * Calculate absolute address in FLASH and jump there
162 *----------------------------------------------------------------------*/ 162 *----------------------------------------------------------------------*/
163 163
164 lis r3, CFG_MONITOR_BASE@h 164 lis r3, CFG_MONITOR_BASE@h
165 ori r3, r3, CFG_MONITOR_BASE@l 165 ori r3, r3, CFG_MONITOR_BASE@l
166 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET 166 addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
167 mtlr r3 167 mtlr r3
168 blr 168 blr
169 169
170 in_flash: 170 in_flash:
171 171
172 /* initialize some SPRs that are hard to access from C */ 172 /* initialize some SPRs that are hard to access from C */
173 /*----------------------------------------------------------------------*/ 173 /*----------------------------------------------------------------------*/
174 174
175 lis r3, CFG_IMMR@h /* pass IMMR as arg1 to C routine */ 175 lis r3, CFG_IMMR@h /* pass IMMR as arg1 to C routine */
176 ori r1, r3, CFG_INIT_SP_OFFSET /* set up the stack in internal DPRAM */ 176 ori r1, r3, CFG_INIT_SP_OFFSET /* set up the stack in internal DPRAM */
177 /* Note: R0 is still 0 here */ 177 /* Note: R0 is still 0 here */
178 stwu r0, -4(r1) /* clear final stack frame so that */ 178 stwu r0, -4(r1) /* clear final stack frame so that */
179 stwu r0, -4(r1) /* stack backtraces terminate cleanly */ 179 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
180 180
181 /* 181 /*
182 * Disable serialized ifetch and show cycles 182 * Disable serialized ifetch and show cycles
183 * (i.e. set processor to normal mode). 183 * (i.e. set processor to normal mode).
184 * This is also a silicon bug workaround, see errata 184 * This is also a silicon bug workaround, see errata
185 */ 185 */
186 186
187 li r2, 0x0007 187 li r2, 0x0007
188 mtspr ICTRL, r2 188 mtspr ICTRL, r2
189 189
190 /* Set up debug mode entry */ 190 /* Set up debug mode entry */
191 191
192 lis r2, CFG_DER@h 192 lis r2, CFG_DER@h
193 ori r2, r2, CFG_DER@l 193 ori r2, r2, CFG_DER@l
194 mtspr DER, r2 194 mtspr DER, r2
195 195
196 /* let the C-code set up the rest */ 196 /* let the C-code set up the rest */
197 /* */ 197 /* */
198 /* Be careful to keep code relocatable ! */ 198 /* Be careful to keep code relocatable ! */
199 /*----------------------------------------------------------------------*/ 199 /*----------------------------------------------------------------------*/
200 200
201 GET_GOT /* initialize GOT access */ 201 GET_GOT /* initialize GOT access */
202 202
203 /* r3: IMMR */ 203 /* r3: IMMR */
204 bl cpu_init_f /* run low-level CPU init code (from Flash) */ 204 bl cpu_init_f /* run low-level CPU init code (from Flash) */
205 205
206 mr r3, r21 206 mr r3, r21
207 /* r3: BOOTFLAG */ 207 /* r3: BOOTFLAG */
208 bl board_init_f /* run 1st part of board init code (from Flash) */ 208 bl board_init_f /* run 1st part of board init code (from Flash) */
209 209
210 210
211 211
212 .globl _start_of_vectors 212 .globl _start_of_vectors
213 _start_of_vectors: 213 _start_of_vectors:
214 214
215 /* Machine check */ 215 /* Machine check */
216 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException) 216 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
217 217
218 /* Data Storage exception. "Never" generated on the 860. */ 218 /* Data Storage exception. "Never" generated on the 860. */
219 STD_EXCEPTION(0x300, DataStorage, UnknownException) 219 STD_EXCEPTION(0x300, DataStorage, UnknownException)
220 220
221 /* Instruction Storage exception. "Never" generated on the 860. */ 221 /* Instruction Storage exception. "Never" generated on the 860. */
222 STD_EXCEPTION(0x400, InstStorage, UnknownException) 222 STD_EXCEPTION(0x400, InstStorage, UnknownException)
223 223
224 /* External Interrupt exception. */ 224 /* External Interrupt exception. */
225 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt) 225 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
226 226
227 /* Alignment exception. */ 227 /* Alignment exception. */
228 . = 0x600 228 . = 0x600
229 Alignment: 229 Alignment:
230 EXCEPTION_PROLOG 230 EXCEPTION_PROLOG
231 mfspr r4,DAR 231 mfspr r4,DAR
232 stw r4,_DAR(r21) 232 stw r4,_DAR(r21)
233 mfspr r5,DSISR 233 mfspr r5,DSISR
234 stw r5,_DSISR(r21) 234 stw r5,_DSISR(r21)
235 addi r3,r1,STACK_FRAME_OVERHEAD 235 addi r3,r1,STACK_FRAME_OVERHEAD
236 li r20,MSR_KERNEL 236 li r20,MSR_KERNEL
237 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 237 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
238 lwz r6,GOT(transfer_to_handler) 238 lwz r6,GOT(transfer_to_handler)
239 mtlr r6 239 mtlr r6
240 blrl 240 blrl
241 .L_Alignment: 241 .L_Alignment:
242 .long AlignmentException - _start + EXC_OFF_SYS_RESET 242 .long AlignmentException - _start + EXC_OFF_SYS_RESET
243 .long int_return - _start + EXC_OFF_SYS_RESET 243 .long int_return - _start + EXC_OFF_SYS_RESET
244 244
245 /* Program check exception */ 245 /* Program check exception */
246 . = 0x700 246 . = 0x700
247 ProgramCheck: 247 ProgramCheck:
248 EXCEPTION_PROLOG 248 EXCEPTION_PROLOG
249 addi r3,r1,STACK_FRAME_OVERHEAD 249 addi r3,r1,STACK_FRAME_OVERHEAD
250 li r20,MSR_KERNEL 250 li r20,MSR_KERNEL
251 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 251 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
252 lwz r6,GOT(transfer_to_handler) 252 lwz r6,GOT(transfer_to_handler)
253 mtlr r6 253 mtlr r6
254 blrl 254 blrl
255 .L_ProgramCheck: 255 .L_ProgramCheck:
256 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET 256 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
257 .long int_return - _start + EXC_OFF_SYS_RESET 257 .long int_return - _start + EXC_OFF_SYS_RESET
258 258
259 /* No FPU on MPC8xx. This exception is not supposed to happen. 259 /* No FPU on MPC8xx. This exception is not supposed to happen.
260 */ 260 */
261 STD_EXCEPTION(0x800, FPUnavailable, UnknownException) 261 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
262 262
263 /* I guess we could implement decrementer, and may have 263 /* I guess we could implement decrementer, and may have
264 * to someday for timekeeping. 264 * to someday for timekeeping.
265 */ 265 */
266 STD_EXCEPTION(0x900, Decrementer, timer_interrupt) 266 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
267 STD_EXCEPTION(0xa00, Trap_0a, UnknownException) 267 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
268 STD_EXCEPTION(0xb00, Trap_0b, UnknownException) 268 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
269 269
270 . = 0xc00 270 . = 0xc00
271 /* 271 /*
272 * r0 - SYSCALL number 272 * r0 - SYSCALL number
273 * r3-... arguments 273 * r3-... arguments
274 */ 274 */
275 SystemCall: 275 SystemCall:
276 addis r11,r0,0 /* get functions table addr */ 276 addis r11,r0,0 /* get functions table addr */
277 ori r11,r11,0 /* Note: this code is patched in trap_init */ 277 ori r11,r11,0 /* Note: this code is patched in trap_init */
278 addis r12,r0,0 /* get number of functions */ 278 addis r12,r0,0 /* get number of functions */
279 ori r12,r12,0 279 ori r12,r12,0
280 280
281 cmplw 0, r0, r12 281 cmplw 0, r0, r12
282 bge 1f 282 bge 1f
283 283
284 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ 284 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
285 add r11,r11,r0 285 add r11,r11,r0
286 lwz r11,0(r11) 286 lwz r11,0(r11)
287 287
288 li r12,0xd00-4*3 /* save LR & SRRx */ 288 li r20,0xd00-4 /* Get stack pointer */
289 lwz r12,0(r20)
290 subi r12,r12,12 /* Adjust stack pointer */
291 li r0,0xc00+_end_back-SystemCall
292 cmplw 0, r0, r12 /* Check stack overflow */
293 bgt 1f
294 stw r12,0(r20)
295
289 mflr r0 296 mflr r0
290 stw r0,0(r12) 297 stw r0,0(r12)
291 mfspr r0,SRR0 298 mfspr r0,SRR0
292 stw r0,4(r12) 299 stw r0,4(r12)
293 mfspr r0,SRR1 300 mfspr r0,SRR1
294 stw r0,8(r12) 301 stw r0,8(r12)
295 302
296 li r12,0xc00+_back-SystemCall 303 li r12,0xc00+_back-SystemCall
297 mtlr r12 304 mtlr r12
298 mtspr SRR0,r11 305 mtspr SRR0,r11
299 306
300 1: SYNC 307 1: SYNC
301 rfi 308 rfi
302 309
303 _back: 310 _back:
304 311
305 mfmsr r11 /* Disable interrupts */ 312 mfmsr r11 /* Disable interrupts */
306 li r12,0 313 li r12,0
307 ori r12,r12,MSR_EE 314 ori r12,r12,MSR_EE
308 andc r11,r11,r12 315 andc r11,r11,r12
309 SYNC /* Some chip revs need this... */ 316 SYNC /* Some chip revs need this... */
310 mtmsr r11 317 mtmsr r11
311 SYNC 318 SYNC
312 319
313 li r12,0xd00-4*3 /* restore regs */ 320 li r12,0xd00-4 /* restore regs */
321 lwz r12,0(r12)
322
314 lwz r11,0(r12) 323 lwz r11,0(r12)
315 mtlr r11 324 mtlr r11
316 lwz r11,4(r12) 325 lwz r11,4(r12)
317 mtspr SRR0,r11 326 mtspr SRR0,r11
318 lwz r11,8(r12) 327 lwz r11,8(r12)
319 mtspr SRR1,r11 328 mtspr SRR1,r11
320 329
330 addi r12,r12,12 /* Adjust stack pointer */
331 li r20,0xd00-4
332 stw r12,0(r20)
333
321 SYNC 334 SYNC
322 rfi 335 rfi
336 _end_back:
323 337
324 STD_EXCEPTION(0xd00, SingleStep, UnknownException) 338 STD_EXCEPTION(0xd00, SingleStep, UnknownException)
325 339
326 STD_EXCEPTION(0xe00, Trap_0e, UnknownException) 340 STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
327 STD_EXCEPTION(0xf00, Trap_0f, UnknownException) 341 STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
328 342
329 /* On the MPC8xx, this is a software emulation interrupt. It occurs 343 /* On the MPC8xx, this is a software emulation interrupt. It occurs
330 * for all unimplemented and illegal instructions. 344 * for all unimplemented and illegal instructions.
331 */ 345 */
332 STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException) 346 STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException)
333 347
334 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException) 348 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
335 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException) 349 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
336 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException) 350 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
337 STD_EXCEPTION(0x1400, DataTLBError, UnknownException) 351 STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
338 352
339 STD_EXCEPTION(0x1500, Reserved5, UnknownException) 353 STD_EXCEPTION(0x1500, Reserved5, UnknownException)
340 STD_EXCEPTION(0x1600, Reserved6, UnknownException) 354 STD_EXCEPTION(0x1600, Reserved6, UnknownException)
341 STD_EXCEPTION(0x1700, Reserved7, UnknownException) 355 STD_EXCEPTION(0x1700, Reserved7, UnknownException)
342 STD_EXCEPTION(0x1800, Reserved8, UnknownException) 356 STD_EXCEPTION(0x1800, Reserved8, UnknownException)
343 STD_EXCEPTION(0x1900, Reserved9, UnknownException) 357 STD_EXCEPTION(0x1900, Reserved9, UnknownException)
344 STD_EXCEPTION(0x1a00, ReservedA, UnknownException) 358 STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
345 STD_EXCEPTION(0x1b00, ReservedB, UnknownException) 359 STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
346 360
347 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException) 361 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
348 STD_EXCEPTION(0x1d00, InstructionBreakpoint, DebugException) 362 STD_EXCEPTION(0x1d00, InstructionBreakpoint, DebugException)
349 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException) 363 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
350 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException) 364 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
351 365
352 366
353 .globl _end_of_vectors 367 .globl _end_of_vectors
354 _end_of_vectors: 368 _end_of_vectors:
355 369
356 370
357 . = 0x2000 371 . = 0x2000
358 372
359 /* 373 /*
360 * This code finishes saving the registers to the exception frame 374 * This code finishes saving the registers to the exception frame
361 * and jumps to the appropriate handler for the exception. 375 * and jumps to the appropriate handler for the exception.
362 * Register r21 is pointer into trap frame, r1 has new stack pointer. 376 * Register r21 is pointer into trap frame, r1 has new stack pointer.
363 */ 377 */
364 .globl transfer_to_handler 378 .globl transfer_to_handler
365 transfer_to_handler: 379 transfer_to_handler:
366 stw r22,_NIP(r21) 380 stw r22,_NIP(r21)
367 lis r22,MSR_POW@h 381 lis r22,MSR_POW@h
368 andc r23,r23,r22 382 andc r23,r23,r22
369 stw r23,_MSR(r21) 383 stw r23,_MSR(r21)
370 SAVE_GPR(7, r21) 384 SAVE_GPR(7, r21)
371 SAVE_4GPRS(8, r21) 385 SAVE_4GPRS(8, r21)
372 SAVE_8GPRS(12, r21) 386 SAVE_8GPRS(12, r21)
373 SAVE_8GPRS(24, r21) 387 SAVE_8GPRS(24, r21)
374 mflr r23 388 mflr r23
375 andi. r24,r23,0x3f00 /* get vector offset */ 389 andi. r24,r23,0x3f00 /* get vector offset */
376 stw r24,TRAP(r21) 390 stw r24,TRAP(r21)
377 li r22,0 391 li r22,0
378 stw r22,RESULT(r21) 392 stw r22,RESULT(r21)
379 mtspr SPRG2,r22 /* r1 is now kernel sp */ 393 mtspr SPRG2,r22 /* r1 is now kernel sp */
380 lwz r24,0(r23) /* virtual address of handler */ 394 lwz r24,0(r23) /* virtual address of handler */
381 lwz r23,4(r23) /* where to go when done */ 395 lwz r23,4(r23) /* where to go when done */
382 mtspr SRR0,r24 396 mtspr SRR0,r24
383 mtspr SRR1,r20 397 mtspr SRR1,r20
384 mtlr r23 398 mtlr r23
385 SYNC 399 SYNC
386 rfi /* jump to handler, enable MMU */ 400 rfi /* jump to handler, enable MMU */
387 401
388 int_return: 402 int_return:
389 mfmsr r28 /* Disable interrupts */ 403 mfmsr r28 /* Disable interrupts */
390 li r4,0 404 li r4,0
391 ori r4,r4,MSR_EE 405 ori r4,r4,MSR_EE
392 andc r28,r28,r4 406 andc r28,r28,r4
393 SYNC /* Some chip revs need this... */ 407 SYNC /* Some chip revs need this... */
394 mtmsr r28 408 mtmsr r28
395 SYNC 409 SYNC
396 lwz r2,_CTR(r1) 410 lwz r2,_CTR(r1)
397 lwz r0,_LINK(r1) 411 lwz r0,_LINK(r1)
398 mtctr r2 412 mtctr r2
399 mtlr r0 413 mtlr r0
400 lwz r2,_XER(r1) 414 lwz r2,_XER(r1)
401 lwz r0,_CCR(r1) 415 lwz r0,_CCR(r1)
402 mtspr XER,r2 416 mtspr XER,r2
403 mtcrf 0xFF,r0 417 mtcrf 0xFF,r0
404 REST_10GPRS(3, r1) 418 REST_10GPRS(3, r1)
405 REST_10GPRS(13, r1) 419 REST_10GPRS(13, r1)
406 REST_8GPRS(23, r1) 420 REST_8GPRS(23, r1)
407 REST_GPR(31, r1) 421 REST_GPR(31, r1)
408 lwz r2,_NIP(r1) /* Restore environment */ 422 lwz r2,_NIP(r1) /* Restore environment */
409 lwz r0,_MSR(r1) 423 lwz r0,_MSR(r1)
410 mtspr SRR0,r2 424 mtspr SRR0,r2
411 mtspr SRR1,r0 425 mtspr SRR1,r0
412 lwz r0,GPR0(r1) 426 lwz r0,GPR0(r1)
413 lwz r2,GPR2(r1) 427 lwz r2,GPR2(r1)
414 lwz r1,GPR1(r1) 428 lwz r1,GPR1(r1)
415 SYNC 429 SYNC
416 rfi 430 rfi
417 431
418 /* Cache functions. 432 /* Cache functions.
419 */ 433 */
420 .globl icache_enable 434 .globl icache_enable
421 icache_enable: 435 icache_enable:
422 SYNC 436 SYNC
423 lis r3, IDC_INVALL@h 437 lis r3, IDC_INVALL@h
424 mtspr IC_CST, r3 438 mtspr IC_CST, r3
425 lis r3, IDC_ENABLE@h 439 lis r3, IDC_ENABLE@h
426 mtspr IC_CST, r3 440 mtspr IC_CST, r3
427 blr 441 blr
428 442
429 .globl icache_disable 443 .globl icache_disable
430 icache_disable: 444 icache_disable:
431 SYNC 445 SYNC
432 lis r3, IDC_DISABLE@h 446 lis r3, IDC_DISABLE@h
433 mtspr IC_CST, r3 447 mtspr IC_CST, r3
434 blr 448 blr
435 449
436 .globl icache_status 450 .globl icache_status
437 icache_status: 451 icache_status:
438 mfspr r3, IC_CST 452 mfspr r3, IC_CST
439 srwi r3, r3, 31 /* >>31 => select bit 0 */ 453 srwi r3, r3, 31 /* >>31 => select bit 0 */
440 blr 454 blr
441 455
442 .globl dcache_enable 456 .globl dcache_enable
443 dcache_enable: 457 dcache_enable:
444 #if 0 458 #if 0
445 SYNC 459 SYNC
446 #endif 460 #endif
447 #if 1 461 #if 1
448 lis r3, 0x0400 /* Set cache mode with MMU off */ 462 lis r3, 0x0400 /* Set cache mode with MMU off */
449 mtspr MD_CTR, r3 463 mtspr MD_CTR, r3
450 #endif 464 #endif
451 465
452 lis r3, IDC_INVALL@h 466 lis r3, IDC_INVALL@h
453 mtspr DC_CST, r3 467 mtspr DC_CST, r3
454 #if 0 468 #if 0
455 lis r3, DC_SFWT@h 469 lis r3, DC_SFWT@h
456 mtspr DC_CST, r3 470 mtspr DC_CST, r3
457 #endif 471 #endif
458 lis r3, IDC_ENABLE@h 472 lis r3, IDC_ENABLE@h
459 mtspr DC_CST, r3 473 mtspr DC_CST, r3
460 blr 474 blr
461 475
462 .globl dcache_disable 476 .globl dcache_disable
463 dcache_disable: 477 dcache_disable:
464 SYNC 478 SYNC
465 lis r3, IDC_DISABLE@h 479 lis r3, IDC_DISABLE@h
466 mtspr DC_CST, r3 480 mtspr DC_CST, r3
467 lis r3, IDC_INVALL@h 481 lis r3, IDC_INVALL@h
468 mtspr DC_CST, r3 482 mtspr DC_CST, r3
469 blr 483 blr
470 484
471 .globl dcache_status 485 .globl dcache_status
472 dcache_status: 486 dcache_status:
473 mfspr r3, DC_CST 487 mfspr r3, DC_CST
474 srwi r3, r3, 31 /* >>31 => select bit 0 */ 488 srwi r3, r3, 31 /* >>31 => select bit 0 */
475 blr 489 blr
476 490
477 .globl dc_read 491 .globl dc_read
478 dc_read: 492 dc_read:
479 mtspr DC_ADR, r3 493 mtspr DC_ADR, r3
480 mfspr r3, DC_DAT 494 mfspr r3, DC_DAT
481 blr 495 blr
482 496
483 /* 497 /*
484 * unsigned int get_immr (unsigned int mask) 498 * unsigned int get_immr (unsigned int mask)
485 * 499 *
486 * return (mask ? (IMMR & mask) : IMMR); 500 * return (mask ? (IMMR & mask) : IMMR);
487 */ 501 */
488 .globl get_immr 502 .globl get_immr
489 get_immr: 503 get_immr:
490 mr r4,r3 /* save mask */ 504 mr r4,r3 /* save mask */
491 mfspr r3, IMMR /* IMMR */ 505 mfspr r3, IMMR /* IMMR */
492 cmpwi 0,r4,0 /* mask != 0 ? */ 506 cmpwi 0,r4,0 /* mask != 0 ? */
493 beq 4f 507 beq 4f
494 and r3,r3,r4 /* IMMR & mask */ 508 and r3,r3,r4 /* IMMR & mask */
495 4: 509 4:
496 blr 510 blr
497 511
498 .globl get_pvr 512 .globl get_pvr
499 get_pvr: 513 get_pvr:
500 mfspr r3, PVR 514 mfspr r3, PVR
501 blr 515 blr
502 516
503 517
504 .globl wr_ic_cst 518 .globl wr_ic_cst
505 wr_ic_cst: 519 wr_ic_cst:
506 mtspr IC_CST, r3 520 mtspr IC_CST, r3
507 blr 521 blr
508 522
509 .globl rd_ic_cst 523 .globl rd_ic_cst
510 rd_ic_cst: 524 rd_ic_cst:
511 mfspr r3, IC_CST 525 mfspr r3, IC_CST
512 blr 526 blr
513 527
514 .globl wr_ic_adr 528 .globl wr_ic_adr
515 wr_ic_adr: 529 wr_ic_adr:
516 mtspr IC_ADR, r3 530 mtspr IC_ADR, r3
517 blr 531 blr
518 532
519 533
520 .globl wr_dc_cst 534 .globl wr_dc_cst
521 wr_dc_cst: 535 wr_dc_cst:
522 mtspr DC_CST, r3 536 mtspr DC_CST, r3
523 blr 537 blr
524 538
525 .globl rd_dc_cst 539 .globl rd_dc_cst
526 rd_dc_cst: 540 rd_dc_cst:
527 mfspr r3, DC_CST 541 mfspr r3, DC_CST
528 blr 542 blr
529 543
530 .globl wr_dc_adr 544 .globl wr_dc_adr
531 wr_dc_adr: 545 wr_dc_adr:
532 mtspr DC_ADR, r3 546 mtspr DC_ADR, r3
533 blr 547 blr
534 548
535 /*------------------------------------------------------------------------------*/ 549 /*------------------------------------------------------------------------------*/
536 550
537 /* 551 /*
538 * void relocate_code (addr_sp, gd, addr_moni) 552 * void relocate_code (addr_sp, gd, addr_moni)
539 * 553 *
540 * This "function" does not return, instead it continues in RAM 554 * This "function" does not return, instead it continues in RAM
541 * after relocating the monitor code. 555 * after relocating the monitor code.
542 * 556 *
543 * r3 = dest 557 * r3 = dest
544 * r4 = src 558 * r4 = src
545 * r5 = length in bytes 559 * r5 = length in bytes
546 * r6 = cachelinesize 560 * r6 = cachelinesize
547 */ 561 */
548 .globl relocate_code 562 .globl relocate_code
549 relocate_code: 563 relocate_code:
550 mr r1, r3 /* Set new stack pointer */ 564 mr r1, r3 /* Set new stack pointer */
551 mr r9, r4 /* Save copy of Global Data pointer */ 565 mr r9, r4 /* Save copy of Global Data pointer */
552 mr r10, r5 /* Save copy of Destination Address */ 566 mr r10, r5 /* Save copy of Destination Address */
553 567
554 mr r3, r5 /* Destination Address */ 568 mr r3, r5 /* Destination Address */
555 lis r4, CFG_MONITOR_BASE@h /* Source Address */ 569 lis r4, CFG_MONITOR_BASE@h /* Source Address */
556 ori r4, r4, CFG_MONITOR_BASE@l 570 ori r4, r4, CFG_MONITOR_BASE@l
557 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */ 571 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */
558 ori r5, r5, CFG_MONITOR_LEN@l 572 ori r5, r5, CFG_MONITOR_LEN@l
559 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */ 573 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
560 574
561 /* 575 /*
562 * Fix GOT pointer: 576 * Fix GOT pointer:
563 * 577 *
564 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address 578 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
565 * 579 *
566 * Offset: 580 * Offset:
567 */ 581 */
568 sub r15, r10, r4 582 sub r15, r10, r4
569 583
570 /* First our own GOT */ 584 /* First our own GOT */
571 add r14, r14, r15 585 add r14, r14, r15
572 /* the the one used by the C code */ 586 /* the the one used by the C code */
573 add r30, r30, r15 587 add r30, r30, r15
574 588
575 /* 589 /*
576 * Now relocate code 590 * Now relocate code
577 */ 591 */
578 592
579 cmplw cr1,r3,r4 593 cmplw cr1,r3,r4
580 addi r0,r5,3 594 addi r0,r5,3
581 srwi. r0,r0,2 595 srwi. r0,r0,2
582 beq cr1,4f /* In place copy is not necessary */ 596 beq cr1,4f /* In place copy is not necessary */
583 beq 7f /* Protect against 0 count */ 597 beq 7f /* Protect against 0 count */
584 mtctr r0 598 mtctr r0
585 bge cr1,2f 599 bge cr1,2f
586 600
587 la r8,-4(r4) 601 la r8,-4(r4)
588 la r7,-4(r3) 602 la r7,-4(r3)
589 1: lwzu r0,4(r8) 603 1: lwzu r0,4(r8)
590 stwu r0,4(r7) 604 stwu r0,4(r7)
591 bdnz 1b 605 bdnz 1b
592 b 4f 606 b 4f
593 607
594 2: slwi r0,r0,2 608 2: slwi r0,r0,2
595 add r8,r4,r0 609 add r8,r4,r0
596 add r7,r3,r0 610 add r7,r3,r0
597 3: lwzu r0,-4(r8) 611 3: lwzu r0,-4(r8)
598 stwu r0,-4(r7) 612 stwu r0,-4(r7)
599 bdnz 3b 613 bdnz 3b
600 614
601 /* 615 /*
602 * Now flush the cache: note that we must start from a cache aligned 616 * Now flush the cache: note that we must start from a cache aligned
603 * address. Otherwise we might miss one cache line. 617 * address. Otherwise we might miss one cache line.
604 */ 618 */
605 4: cmpwi r6,0 619 4: cmpwi r6,0
606 add r5,r3,r5 620 add r5,r3,r5
607 beq 7f /* Always flush prefetch queue in any case */ 621 beq 7f /* Always flush prefetch queue in any case */
608 subi r0,r6,1 622 subi r0,r6,1
609 andc r3,r3,r0 623 andc r3,r3,r0
610 mr r4,r3 624 mr r4,r3
611 5: dcbst 0,r4 625 5: dcbst 0,r4
612 add r4,r4,r6 626 add r4,r4,r6
613 cmplw r4,r5 627 cmplw r4,r5
614 blt 5b 628 blt 5b
615 sync /* Wait for all dcbst to complete on bus */ 629 sync /* Wait for all dcbst to complete on bus */
616 mr r4,r3 630 mr r4,r3
617 6: icbi 0,r4 631 6: icbi 0,r4
618 add r4,r4,r6 632 add r4,r4,r6
619 cmplw r4,r5 633 cmplw r4,r5
620 blt 6b 634 blt 6b
621 7: sync /* Wait for all icbi to complete on bus */ 635 7: sync /* Wait for all icbi to complete on bus */
622 isync 636 isync
623 637
624 /* 638 /*
625 * We are done. Do not return, instead branch to second part of board 639 * We are done. Do not return, instead branch to second part of board
626 * initialization, now running from RAM. 640 * initialization, now running from RAM.
627 */ 641 */
628 642
629 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET 643 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
630 mtlr r0 644 mtlr r0
631 blr 645 blr
632 646
633 in_ram: 647 in_ram:
634 648
635 /* 649 /*
636 * Relocation Function, r14 point to got2+0x8000 650 * Relocation Function, r14 point to got2+0x8000
637 * 651 *
638 * Adjust got2 pointers, no need to check for 0, this code 652 * Adjust got2 pointers, no need to check for 0, this code
639 * already puts a few entries in the table. 653 * already puts a few entries in the table.
640 */ 654 */
641 li r0,__got2_entries@sectoff@l 655 li r0,__got2_entries@sectoff@l
642 la r3,GOT(_GOT2_TABLE_) 656 la r3,GOT(_GOT2_TABLE_)
643 lwz r11,GOT(_GOT2_TABLE_) 657 lwz r11,GOT(_GOT2_TABLE_)
644 mtctr r0 658 mtctr r0
645 sub r11,r3,r11 659 sub r11,r3,r11
646 addi r3,r3,-4 660 addi r3,r3,-4
647 1: lwzu r0,4(r3) 661 1: lwzu r0,4(r3)
648 add r0,r0,r11 662 add r0,r0,r11
649 stw r0,0(r3) 663 stw r0,0(r3)
650 bdnz 1b 664 bdnz 1b
651 665
652 /* 666 /*
653 * Now adjust the fixups and the pointers to the fixups 667 * Now adjust the fixups and the pointers to the fixups
654 * in case we need to move ourselves again. 668 * in case we need to move ourselves again.
655 */ 669 */
656 2: li r0,__fixup_entries@sectoff@l 670 2: li r0,__fixup_entries@sectoff@l
657 lwz r3,GOT(_FIXUP_TABLE_) 671 lwz r3,GOT(_FIXUP_TABLE_)
658 cmpwi r0,0 672 cmpwi r0,0
659 mtctr r0 673 mtctr r0
660 addi r3,r3,-4 674 addi r3,r3,-4
661 beq 4f 675 beq 4f
662 3: lwzu r4,4(r3) 676 3: lwzu r4,4(r3)
663 lwzux r0,r4,r11 677 lwzux r0,r4,r11
664 add r0,r0,r11 678 add r0,r0,r11
665 stw r10,0(r3) 679 stw r10,0(r3)
666 stw r0,0(r4) 680 stw r0,0(r4)
667 bdnz 3b 681 bdnz 3b
668 4: 682 4:
669 clear_bss: 683 clear_bss:
670 /* 684 /*
671 * Now clear BSS segment 685 * Now clear BSS segment
672 */ 686 */
673 lwz r3,GOT(.bss) 687 lwz r3,GOT(.bss)
674 #if defined(CONFIG_FADS) || defined(CONFIG_ICU862) 688 #if defined(CONFIG_FADS) || defined(CONFIG_ICU862)
675 /* 689 /*
676 * For the FADS - the environment is the very last item in flash. 690 * For the FADS - the environment is the very last item in flash.
677 * The real .bss stops just before environment starts, so only 691 * The real .bss stops just before environment starts, so only
678 * clear up to that point. 692 * clear up to that point.
679 */ 693 */
680 lwz r4,GOT(environment) 694 lwz r4,GOT(environment)
681 #else 695 #else
682 lwz r4,GOT(_end) 696 lwz r4,GOT(_end)
683 #endif 697 #endif
684 698
685 cmplw 0, r3, r4 699 cmplw 0, r3, r4
686 beq 6f 700 beq 6f
687 701
688 li r0, 0 702 li r0, 0
689 5: 703 5:
690 stw r0, 0(r3) 704 stw r0, 0(r3)
691 addi r3, r3, 4 705 addi r3, r3, 4
692 cmplw 0, r3, r4 706 cmplw 0, r3, r4
693 bne 5b 707 bne 5b
694 6: 708 6:
695 709
696 mr r3, r9 /* Global Data pointer */ 710 mr r3, r9 /* Global Data pointer */
697 mr r4, r10 /* Destination Address */ 711 mr r4, r10 /* Destination Address */
698 bl board_init_r 712 bl board_init_r
699 713
700 /* Problems accessing "end" in C, so do it here */ 714 /* Problems accessing "end" in C, so do it here */
701 .globl get_endaddr 715 .globl get_endaddr
702 get_endaddr: 716 get_endaddr:
703 lwz r3,GOT(_end) 717 lwz r3,GOT(_end)
704 blr 718 blr
705 719
706 /* 720 /*
707 * Copy exception vector code to low memory 721 * Copy exception vector code to low memory
708 * 722 *
709 * r3: dest_addr 723 * r3: dest_addr
710 * r7: source address, r8: end address, r9: target address 724 * r7: source address, r8: end address, r9: target address
711 */ 725 */
712 .globl trap_init 726 .globl trap_init
713 trap_init: 727 trap_init:
714 lwz r7, GOT(_start) 728 lwz r7, GOT(_start)
715 lwz r8, GOT(_end_of_vectors) 729 lwz r8, GOT(_end_of_vectors)
716 730
717 rlwinm r9, r7, 0, 22, 31 /* _start & 0x3FF */ 731 rlwinm r9, r7, 0, 22, 31 /* _start & 0x3FF */
718 732
719 cmplw 0, r7, r8 733 cmplw 0, r7, r8
720 bgelr /* return if r7>=r8 - just in case */ 734 bgelr /* return if r7>=r8 - just in case */
721 735
722 mflr r4 /* save link register */ 736 mflr r4 /* save link register */
723 1: 737 1:
724 lwz r0, 0(r7) 738 lwz r0, 0(r7)
725 stw r0, 0(r9) 739 stw r0, 0(r9)
726 addi r7, r7, 4 740 addi r7, r7, 4
727 addi r9, r9, 4 741 addi r9, r9, 4
728 cmplw 0, r7, r8 742 cmplw 0, r7, r8
729 bne 1b 743 bne 1b
730 744
731 /* 745 /*
732 * relocate `hdlr' and `int_return' entries 746 * relocate `hdlr' and `int_return' entries
733 */ 747 */
734 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET 748 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
735 li r8, Alignment - _start + EXC_OFF_SYS_RESET 749 li r8, Alignment - _start + EXC_OFF_SYS_RESET
736 2: 750 2:
737 bl trap_reloc 751 bl trap_reloc
738 addi r7, r7, 0x100 /* next exception vector */ 752 addi r7, r7, 0x100 /* next exception vector */
739 cmplw 0, r7, r8 753 cmplw 0, r7, r8
740 blt 2b 754 blt 2b
741 755
742 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET 756 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
743 bl trap_reloc 757 bl trap_reloc
744 758
745 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET 759 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
746 bl trap_reloc 760 bl trap_reloc
747 761
748 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET 762 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
749 li r8, SystemCall - _start + EXC_OFF_SYS_RESET 763 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
750 3: 764 3:
751 bl trap_reloc 765 bl trap_reloc
752 addi r7, r7, 0x100 /* next exception vector */ 766 addi r7, r7, 0x100 /* next exception vector */
753 cmplw 0, r7, r8 767 cmplw 0, r7, r8
754 blt 3b 768 blt 3b
755 769
756 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET 770 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
757 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET 771 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
758 4: 772 4:
759 bl trap_reloc 773 bl trap_reloc
760 addi r7, r7, 0x100 /* next exception vector */ 774 addi r7, r7, 0x100 /* next exception vector */
761 cmplw 0, r7, r8 775 cmplw 0, r7, r8
762 blt 4b 776 blt 4b
763 777
764 mtlr r4 /* restore link register */ 778 mtlr r4 /* restore link register */
765 blr 779 blr
766 780
767 /* 781 /*
768 * Function: relocate entries for one exception vector 782 * Function: relocate entries for one exception vector
769 */ 783 */
770 trap_reloc: 784 trap_reloc:
771 lwz r0, 0(r7) /* hdlr ... */ 785 lwz r0, 0(r7) /* hdlr ... */
772 add r0, r0, r3 /* ... += dest_addr */ 786 add r0, r0, r3 /* ... += dest_addr */
773 stw r0, 0(r7) 787 stw r0, 0(r7)
774 788
775 lwz r0, 4(r7) /* int_return ... */ 789 lwz r0, 4(r7) /* int_return ... */
776 add r0, r0, r3 /* ... += dest_addr */ 790 add r0, r0, r3 /* ... += dest_addr */
777 stw r0, 4(r7) 791 stw r0, 4(r7)
778 792
779 sync 793 sync
780 isync 794 isync
781 795
782 blr 796 blr
783 797
1 /* 1 /*
2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> 2 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> 3 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de> 4 * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
5 * 5 *
6 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
7 * project. 7 * project.
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details. 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA 22 * MA 02111-1307 USA
23 */ 23 */
24 /*------------------------------------------------------------------------------+ */ 24 /*------------------------------------------------------------------------------+ */
25 /* */ 25 /* */
26 /* This source code has been made available to you by IBM on an AS-IS */ 26 /* This source code has been made available to you by IBM on an AS-IS */
27 /* basis. Anyone receiving this source is licensed under IBM */ 27 /* basis. Anyone receiving this source is licensed under IBM */
28 /* copyrights to use it in any way he or she deems fit, including */ 28 /* copyrights to use it in any way he or she deems fit, including */
29 /* copying it, modifying it, compiling it, and redistributing it either */ 29 /* copying it, modifying it, compiling it, and redistributing it either */
30 /* with or without modifications. No license under IBM patents or */ 30 /* with or without modifications. No license under IBM patents or */
31 /* patent applications is to be implied by the copyright license. */ 31 /* patent applications is to be implied by the copyright license. */
32 /* */ 32 /* */
33 /* Any user of this software should understand that IBM cannot provide */ 33 /* Any user of this software should understand that IBM cannot provide */
34 /* technical support for this software and will not be responsible for */ 34 /* technical support for this software and will not be responsible for */
35 /* any consequences resulting from the use of this software. */ 35 /* any consequences resulting from the use of this software. */
36 /* */ 36 /* */
37 /* Any person who transfers this source code or any derivative work */ 37 /* Any person who transfers this source code or any derivative work */
38 /* must include the IBM copyright notice, this paragraph, and the */ 38 /* must include the IBM copyright notice, this paragraph, and the */
39 /* preceding two paragraphs in the transferred software. */ 39 /* preceding two paragraphs in the transferred software. */
40 /* */ 40 /* */
41 /* COPYRIGHT I B M CORPORATION 1995 */ 41 /* COPYRIGHT I B M CORPORATION 1995 */
42 /* LICENSED MATERIAL - PROGRAM PROPERTY OF I B M */ 42 /* LICENSED MATERIAL - PROGRAM PROPERTY OF I B M */
43 /*------------------------------------------------------------------------------- */ 43 /*------------------------------------------------------------------------------- */
44 44
45 /* U-Boot - Startup Code for IBM 4xx PowerPC based Embedded Boards 45 /* U-Boot - Startup Code for IBM 4xx PowerPC based Embedded Boards
46 * 46 *
47 * 47 *
48 * The processor starts at 0xfffffffc and the code is executed 48 * The processor starts at 0xfffffffc and the code is executed
49 * from flash/rom. 49 * from flash/rom.
50 * in memory, but as long we don't jump around before relocating. 50 * in memory, but as long we don't jump around before relocating.
51 * board_init lies at a quite high address and when the cpu has 51 * board_init lies at a quite high address and when the cpu has
52 * jumped there, everything is ok. 52 * jumped there, everything is ok.
53 * This works because the cpu gives the FLASH (CS0) the whole 53 * This works because the cpu gives the FLASH (CS0) the whole
54 * address space at startup, and board_init lies as a echo of 54 * address space at startup, and board_init lies as a echo of
55 * the flash somewhere up there in the memorymap. 55 * the flash somewhere up there in the memorymap.
56 * 56 *
57 * board_init will change CS0 to be positioned at the correct 57 * board_init will change CS0 to be positioned at the correct
58 * address and (s)dram will be positioned at address 0 58 * address and (s)dram will be positioned at address 0
59 */ 59 */
60 #include <config.h> 60 #include <config.h>
61 #include <mpc8xx.h> 61 #include <mpc8xx.h>
62 #include <ppc4xx.h> 62 #include <ppc4xx.h>
63 #include <version.h> 63 #include <version.h>
64 64
65 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ 65 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
66 66
67 #include <ppc_asm.tmpl> 67 #include <ppc_asm.tmpl>
68 #include <ppc_defs.h> 68 #include <ppc_defs.h>
69 69
70 #include <asm/cache.h> 70 #include <asm/cache.h>
71 #include <asm/mmu.h> 71 #include <asm/mmu.h>
72 72
73 #ifndef CONFIG_IDENT_STRING 73 #ifndef CONFIG_IDENT_STRING
74 #define CONFIG_IDENT_STRING "" 74 #define CONFIG_IDENT_STRING ""
75 #endif 75 #endif
76 76
77 #ifdef CFG_INIT_DCACHE_CS 77 #ifdef CFG_INIT_DCACHE_CS
78 # if (CFG_INIT_DCACHE_CS == 0) 78 # if (CFG_INIT_DCACHE_CS == 0)
79 # define PBxAP pb0ap 79 # define PBxAP pb0ap
80 # define PBxCR pb0cr 80 # define PBxCR pb0cr
81 # endif 81 # endif
82 # if (CFG_INIT_DCACHE_CS == 1) 82 # if (CFG_INIT_DCACHE_CS == 1)
83 # define PBxAP pb1ap 83 # define PBxAP pb1ap
84 # define PBxCR pb1cr 84 # define PBxCR pb1cr
85 # endif 85 # endif
86 # if (CFG_INIT_DCACHE_CS == 2) 86 # if (CFG_INIT_DCACHE_CS == 2)
87 # define PBxAP pb2ap 87 # define PBxAP pb2ap
88 # define PBxCR pb2cr 88 # define PBxCR pb2cr
89 # endif 89 # endif
90 # if (CFG_INIT_DCACHE_CS == 3) 90 # if (CFG_INIT_DCACHE_CS == 3)
91 # define PBxAP pb3ap 91 # define PBxAP pb3ap
92 # define PBxCR pb3cr 92 # define PBxCR pb3cr
93 # endif 93 # endif
94 # if (CFG_INIT_DCACHE_CS == 4) 94 # if (CFG_INIT_DCACHE_CS == 4)
95 # define PBxAP pb4ap 95 # define PBxAP pb4ap
96 # define PBxCR pb4cr 96 # define PBxCR pb4cr
97 # endif 97 # endif
98 # if (CFG_INIT_DCACHE_CS == 5) 98 # if (CFG_INIT_DCACHE_CS == 5)
99 # define PBxAP pb5ap 99 # define PBxAP pb5ap
100 # define PBxCR pb5cr 100 # define PBxCR pb5cr
101 # endif 101 # endif
102 # if (CFG_INIT_DCACHE_CS == 6) 102 # if (CFG_INIT_DCACHE_CS == 6)
103 # define PBxAP pb6ap 103 # define PBxAP pb6ap
104 # define PBxCR pb6cr 104 # define PBxCR pb6cr
105 # endif 105 # endif
106 # if (CFG_INIT_DCACHE_CS == 7) 106 # if (CFG_INIT_DCACHE_CS == 7)
107 # define PBxAP pb7ap 107 # define PBxAP pb7ap
108 # define PBxCR pb7cr 108 # define PBxCR pb7cr
109 # endif 109 # endif
110 #endif /* CFG_INIT_DCACHE_CS */ 110 #endif /* CFG_INIT_DCACHE_CS */
111 111
112 /* We don't want the MMU yet. 112 /* We don't want the MMU yet.
113 */ 113 */
114 #undef MSR_KERNEL 114 #undef MSR_KERNEL
115 #define MSR_KERNEL ( MSR_ME ) /* Machine Check */ 115 #define MSR_KERNEL ( MSR_ME ) /* Machine Check */
116 116
117 117
118 .extern ext_bus_cntlr_init 118 .extern ext_bus_cntlr_init
119 .extern sdram_init 119 .extern sdram_init
120 120
121 /* 121 /*
122 * Set up GOT: Global Offset Table 122 * Set up GOT: Global Offset Table
123 * 123 *
124 * Use r14 to access the GOT 124 * Use r14 to access the GOT
125 */ 125 */
126 START_GOT 126 START_GOT
127 GOT_ENTRY(_GOT2_TABLE_) 127 GOT_ENTRY(_GOT2_TABLE_)
128 GOT_ENTRY(_FIXUP_TABLE_) 128 GOT_ENTRY(_FIXUP_TABLE_)
129 129
130 GOT_ENTRY(_start) 130 GOT_ENTRY(_start)
131 GOT_ENTRY(_start_of_vectors) 131 GOT_ENTRY(_start_of_vectors)
132 GOT_ENTRY(_end_of_vectors) 132 GOT_ENTRY(_end_of_vectors)
133 GOT_ENTRY(transfer_to_handler) 133 GOT_ENTRY(transfer_to_handler)
134 134
135 GOT_ENTRY(_end) 135 GOT_ENTRY(_end)
136 GOT_ENTRY(.bss) 136 GOT_ENTRY(.bss)
137 END_GOT 137 END_GOT
138 138
139 /* 139 /*
140 * 440 Startup -- on reset only the top 4k of the effective 140 * 440 Startup -- on reset only the top 4k of the effective
141 * address space is mapped in by an entry in the instruction 141 * address space is mapped in by an entry in the instruction
142 * and data shadow TLB. The .bootpg section is located in the 142 * and data shadow TLB. The .bootpg section is located in the
143 * top 4k & does only what's necessary to map in the the rest 143 * top 4k & does only what's necessary to map in the the rest
144 * of the boot rom. Once the boot rom is mapped in we can 144 * of the boot rom. Once the boot rom is mapped in we can
145 * proceed with normal startup. 145 * proceed with normal startup.
146 * 146 *
147 * NOTE: CS0 only covers the top 2MB of the effective address 147 * NOTE: CS0 only covers the top 2MB of the effective address
148 * space after reset. 148 * space after reset.
149 */ 149 */
150 150
151 #if defined(CONFIG_440) 151 #if defined(CONFIG_440)
152 .section .bootpg,"ax" 152 .section .bootpg,"ax"
153 .globl _start_440 153 .globl _start_440
154 154
155 /**************************************************************************/ 155 /**************************************************************************/
156 _start_440: 156 _start_440:
157 /*----------------------------------------------------------------*/ 157 /*----------------------------------------------------------------*/
158 /* Clear and set up some registers. */ 158 /* Clear and set up some registers. */
159 /*----------------------------------------------------------------*/ 159 /*----------------------------------------------------------------*/
160 iccci r0,r0 /* NOTE: operands not used for 440 */ 160 iccci r0,r0 /* NOTE: operands not used for 440 */
161 dccci r0,r0 /* NOTE: operands not used for 440 */ 161 dccci r0,r0 /* NOTE: operands not used for 440 */
162 sync 162 sync
163 li r0,0 163 li r0,0
164 mtspr srr0,r0 164 mtspr srr0,r0
165 mtspr srr1,r0 165 mtspr srr1,r0
166 mtspr csrr0,r0 166 mtspr csrr0,r0
167 mtspr csrr1,r0 167 mtspr csrr1,r0
168 168
169 /*----------------------------------------------------------------*/ 169 /*----------------------------------------------------------------*/
170 /* Initialize debug */ 170 /* Initialize debug */
171 /*----------------------------------------------------------------*/ 171 /*----------------------------------------------------------------*/
172 mtspr dbcr0,r0 172 mtspr dbcr0,r0
173 mtspr dbcr1,r0 173 mtspr dbcr1,r0
174 mtspr dbcr2,r0 174 mtspr dbcr2,r0
175 mtspr iac1,r0 175 mtspr iac1,r0
176 mtspr iac2,r0 176 mtspr iac2,r0
177 mtspr iac3,r0 177 mtspr iac3,r0
178 mtspr dac1,r0 178 mtspr dac1,r0
179 mtspr dac2,r0 179 mtspr dac2,r0
180 mtspr dvc1,r0 180 mtspr dvc1,r0
181 mtspr dvc2,r0 181 mtspr dvc2,r0
182 182
183 mfspr r1,dbsr 183 mfspr r1,dbsr
184 mtspr dbsr,r1 /* Clear all valid bits */ 184 mtspr dbsr,r1 /* Clear all valid bits */
185 185
186 /*----------------------------------------------------------------*/ 186 /*----------------------------------------------------------------*/
187 /* CCR0 init */ 187 /* CCR0 init */
188 /*----------------------------------------------------------------*/ 188 /*----------------------------------------------------------------*/
189 /* Disable store gathering & broadcast, guarantee inst/data 189 /* Disable store gathering & broadcast, guarantee inst/data
190 * cache block touch, force load/store alignment 190 * cache block touch, force load/store alignment
191 * (see errata 1.12: 440_33) 191 * (see errata 1.12: 440_33)
192 */ 192 */
193 lis r1,0x0030 /* store gathering & broadcast disable */ 193 lis r1,0x0030 /* store gathering & broadcast disable */
194 ori r1,r1,0x6000 /* cache touch */ 194 ori r1,r1,0x6000 /* cache touch */
195 mtspr ccr0,r1 195 mtspr ccr0,r1
196 196
197 /*----------------------------------------------------------------*/ 197 /*----------------------------------------------------------------*/
198 /* Setup interrupt vectors */ 198 /* Setup interrupt vectors */
199 /*----------------------------------------------------------------*/ 199 /*----------------------------------------------------------------*/
200 mtspr ivpr,r0 /* Vectors start at 0x0000_0000 */ 200 mtspr ivpr,r0 /* Vectors start at 0x0000_0000 */
201 li r1,0x0100 201 li r1,0x0100
202 mtspr ivor0,r1 /* Critical input */ 202 mtspr ivor0,r1 /* Critical input */
203 li r1,0x0200 203 li r1,0x0200
204 mtspr ivor1,r1 /* Machine check */ 204 mtspr ivor1,r1 /* Machine check */
205 li r1,0x0300 205 li r1,0x0300
206 mtspr ivor2,r1 /* Data storage */ 206 mtspr ivor2,r1 /* Data storage */
207 li r1,0x0400 207 li r1,0x0400
208 mtspr ivor3,r1 /* Instruction storage */ 208 mtspr ivor3,r1 /* Instruction storage */
209 li r1,0x0500 209 li r1,0x0500
210 mtspr ivor4,r1 /* External interrupt */ 210 mtspr ivor4,r1 /* External interrupt */
211 li r1,0x0600 211 li r1,0x0600
212 mtspr ivor5,r1 /* Alignment */ 212 mtspr ivor5,r1 /* Alignment */
213 li r1,0x0700 213 li r1,0x0700
214 mtspr ivor6,r1 /* Program check */ 214 mtspr ivor6,r1 /* Program check */
215 li r1,0x0800 215 li r1,0x0800
216 mtspr ivor7,r1 /* Floating point unavailable */ 216 mtspr ivor7,r1 /* Floating point unavailable */
217 li r1,0x0c00 217 li r1,0x0c00
218 mtspr ivor8,r1 /* System call */ 218 mtspr ivor8,r1 /* System call */
219 li r1,0x1000 219 li r1,0x1000
220 mtspr ivor10,r1 /* Decrementer (PIT for 440) */ 220 mtspr ivor10,r1 /* Decrementer (PIT for 440) */
221 li r1,0x1400 221 li r1,0x1400
222 mtspr ivor13,r1 /* Data TLB error */ 222 mtspr ivor13,r1 /* Data TLB error */
223 li r1,0x1300 223 li r1,0x1300
224 mtspr ivor14,r1 /* Instr TLB error */ 224 mtspr ivor14,r1 /* Instr TLB error */
225 li r1,0x2000 225 li r1,0x2000
226 mtspr ivor15,r1 /* Debug */ 226 mtspr ivor15,r1 /* Debug */
227 227
228 /*----------------------------------------------------------------*/ 228 /*----------------------------------------------------------------*/
229 /* Configure cache regions */ 229 /* Configure cache regions */
230 /*----------------------------------------------------------------*/ 230 /*----------------------------------------------------------------*/
231 mtspr inv0,r0 231 mtspr inv0,r0
232 mtspr inv1,r0 232 mtspr inv1,r0
233 mtspr inv2,r0 233 mtspr inv2,r0
234 mtspr inv3,r0 234 mtspr inv3,r0
235 mtspr dnv0,r0 235 mtspr dnv0,r0
236 mtspr dnv1,r0 236 mtspr dnv1,r0
237 mtspr dnv2,r0 237 mtspr dnv2,r0
238 mtspr dnv3,r0 238 mtspr dnv3,r0
239 mtspr itv0,r0 239 mtspr itv0,r0
240 mtspr itv1,r0 240 mtspr itv1,r0
241 mtspr itv2,r0 241 mtspr itv2,r0
242 mtspr itv3,r0 242 mtspr itv3,r0
243 mtspr dtv0,r0 243 mtspr dtv0,r0
244 mtspr dtv1,r0 244 mtspr dtv1,r0
245 mtspr dtv2,r0 245 mtspr dtv2,r0
246 mtspr dtv3,r0 246 mtspr dtv3,r0
247 247
248 /*----------------------------------------------------------------*/ 248 /*----------------------------------------------------------------*/
249 /* Cache victim limits */ 249 /* Cache victim limits */
250 /*----------------------------------------------------------------*/ 250 /*----------------------------------------------------------------*/
251 /* floors 0, ceiling max to use the entire cache -- nothing locked 251 /* floors 0, ceiling max to use the entire cache -- nothing locked
252 */ 252 */
253 lis r1,0x0001 253 lis r1,0x0001
254 ori r1,r1,0xf800 254 ori r1,r1,0xf800
255 mtspr ivlim,r1 255 mtspr ivlim,r1
256 mtspr dvlim,r1 256 mtspr dvlim,r1
257 257
258 /*----------------------------------------------------------------*/ 258 /*----------------------------------------------------------------*/
259 /* Clear all TLB entries -- TID = 0, TS = 0 */ 259 /* Clear all TLB entries -- TID = 0, TS = 0 */
260 /*----------------------------------------------------------------*/ 260 /*----------------------------------------------------------------*/
261 mtspr mmucr,r0 261 mtspr mmucr,r0
262 li r1,0x003f /* 64 TLB entries */ 262 li r1,0x003f /* 64 TLB entries */
263 mtctr r1 263 mtctr r1
264 0: tlbwe r0,r1,0x0000 /* Invalidate all entries (V=0)*/ 264 0: tlbwe r0,r1,0x0000 /* Invalidate all entries (V=0)*/
265 subi r1,r1,0x0001 265 subi r1,r1,0x0001
266 bdnz 0b 266 bdnz 0b
267 267
268 /*----------------------------------------------------------------*/ 268 /*----------------------------------------------------------------*/
269 /* TLB entry setup -- step thru tlbtab */ 269 /* TLB entry setup -- step thru tlbtab */
270 /*----------------------------------------------------------------*/ 270 /*----------------------------------------------------------------*/
271 bl tlbtab /* Get tlbtab pointer */ 271 bl tlbtab /* Get tlbtab pointer */
272 mr r5,r0 272 mr r5,r0
273 li r1,0x003f /* 64 TLB entries max */ 273 li r1,0x003f /* 64 TLB entries max */
274 mtctr r1 274 mtctr r1
275 li r4,0 /* TLB # */ 275 li r4,0 /* TLB # */
276 276
277 addi r5,r5,-4 277 addi r5,r5,-4
278 1: lwzu r0,4(r5) 278 1: lwzu r0,4(r5)
279 cmpwi r0,0 279 cmpwi r0,0
280 beq 2f /* 0 marks end */ 280 beq 2f /* 0 marks end */
281 lwzu r1,4(r5) 281 lwzu r1,4(r5)
282 lwzu r2,4(r5) 282 lwzu r2,4(r5)
283 tlbwe r0,r4,0 /* TLB Word 0 */ 283 tlbwe r0,r4,0 /* TLB Word 0 */
284 tlbwe r1,r4,1 /* TLB Word 1 */ 284 tlbwe r1,r4,1 /* TLB Word 1 */
285 tlbwe r2,r4,2 /* TLB Word 2 */ 285 tlbwe r2,r4,2 /* TLB Word 2 */
286 addi r4,r4,1 /* Next TLB */ 286 addi r4,r4,1 /* Next TLB */
287 bdnz 1b 287 bdnz 1b
288 288
289 /*----------------------------------------------------------------*/ 289 /*----------------------------------------------------------------*/
290 /* Continue from 'normal' start */ 290 /* Continue from 'normal' start */
291 /*----------------------------------------------------------------*/ 291 /*----------------------------------------------------------------*/
292 2: bl 3f 292 2: bl 3f
293 b _start 293 b _start
294 294
295 3: li r0,0 295 3: li r0,0
296 mtspr srr1,r0 /* Keep things disabled for now */ 296 mtspr srr1,r0 /* Keep things disabled for now */
297 mflr r1 297 mflr r1
298 mtspr srr0,r1 298 mtspr srr0,r1
299 rfi 299 rfi
300 #endif 300 #endif
301 301
302 /* 302 /*
303 * r3 - 1st arg to board_init(): IMMP pointer 303 * r3 - 1st arg to board_init(): IMMP pointer
304 * r4 - 2nd arg to board_init(): boot flag 304 * r4 - 2nd arg to board_init(): boot flag
305 */ 305 */
306 .text 306 .text
307 .long 0x27051956 /* U-Boot Magic Number */ 307 .long 0x27051956 /* U-Boot Magic Number */
308 .globl version_string 308 .globl version_string
309 version_string: 309 version_string:
310 .ascii U_BOOT_VERSION 310 .ascii U_BOOT_VERSION
311 .ascii " (", __DATE__, " - ", __TIME__, ")" 311 .ascii " (", __DATE__, " - ", __TIME__, ")"
312 .ascii CONFIG_IDENT_STRING, "\0" 312 .ascii CONFIG_IDENT_STRING, "\0"
313 313
314 /* 314 /*
315 * Maybe this should be moved somewhere else because the current 315 * Maybe this should be moved somewhere else because the current
316 * location (0x100) is where the CriticalInput Execption should be. 316 * location (0x100) is where the CriticalInput Execption should be.
317 */ 317 */
318 . = EXC_OFF_SYS_RESET 318 . = EXC_OFF_SYS_RESET
319 .globl _start 319 .globl _start
320 _start: 320 _start:
321 321
322 /*****************************************************************************/ 322 /*****************************************************************************/
323 #if defined(CONFIG_440) 323 #if defined(CONFIG_440)
324 324
325 /*----------------------------------------------------------------*/ 325 /*----------------------------------------------------------------*/
326 /* Clear and set up some registers. */ 326 /* Clear and set up some registers. */
327 /*----------------------------------------------------------------*/ 327 /*----------------------------------------------------------------*/
328 li r0,0x0000 328 li r0,0x0000
329 lis r1,0xffff 329 lis r1,0xffff
330 mtspr dec,r0 /* prevent dec exceptions */ 330 mtspr dec,r0 /* prevent dec exceptions */
331 mtspr tbl,r0 /* prevent fit & wdt exceptions */ 331 mtspr tbl,r0 /* prevent fit & wdt exceptions */
332 mtspr tbu,r0 332 mtspr tbu,r0
333 mtspr tsr,r1 /* clear all timer exception status */ 333 mtspr tsr,r1 /* clear all timer exception status */
334 mtspr tcr,r0 /* disable all */ 334 mtspr tcr,r0 /* disable all */
335 mtspr esr,r0 /* clear exception syndrome register */ 335 mtspr esr,r0 /* clear exception syndrome register */
336 mtxer r0 /* clear integer exception register */ 336 mtxer r0 /* clear integer exception register */
337 lis r1,0x0002 /* set CE bit (Critical Exceptions) */ 337 lis r1,0x0002 /* set CE bit (Critical Exceptions) */
338 ori r1,r1,0x1000 /* set ME bit (Machine Exceptions) */ 338 ori r1,r1,0x1000 /* set ME bit (Machine Exceptions) */
339 mtmsr r1 /* change MSR */ 339 mtmsr r1 /* change MSR */
340 340
341 /*----------------------------------------------------------------*/ 341 /*----------------------------------------------------------------*/
342 /* Debug setup -- some (not very good) ice's need an event*/ 342 /* Debug setup -- some (not very good) ice's need an event*/
343 /* to establish control :-( Define CFG_INIT_DBCR to the dbsr */ 343 /* to establish control :-( Define CFG_INIT_DBCR to the dbsr */
344 /* value you need in this case 0x8cff 0000 should do the trick */ 344 /* value you need in this case 0x8cff 0000 should do the trick */
345 /*----------------------------------------------------------------*/ 345 /*----------------------------------------------------------------*/
346 #if defined(CFG_INIT_DBCR) 346 #if defined(CFG_INIT_DBCR)
347 lis r1,0xffff 347 lis r1,0xffff
348 ori r1,r1,0xffff 348 ori r1,r1,0xffff
349 mtspr dbsr,r1 /* Clear all status bits */ 349 mtspr dbsr,r1 /* Clear all status bits */
350 lis r0,CFG_INIT_DBCR@h 350 lis r0,CFG_INIT_DBCR@h
351 ori r0,r0,CFG_INIT_DBCR@l 351 ori r0,r0,CFG_INIT_DBCR@l
352 mtspr dbcr0,r0 352 mtspr dbcr0,r0
353 isync 353 isync
354 #endif 354 #endif
355 355
356 /*----------------------------------------------------------------*/ 356 /*----------------------------------------------------------------*/
357 /* Setup the internal SRAM */ 357 /* Setup the internal SRAM */
358 /*----------------------------------------------------------------*/ 358 /*----------------------------------------------------------------*/
359 li r0,0 359 li r0,0
360 mtdcr isram0_sb1cr,r0 /* Disable bank 1 */ 360 mtdcr isram0_sb1cr,r0 /* Disable bank 1 */
361 361
362 li r2,0x7fff 362 li r2,0x7fff
363 ori r2,r2,0xffff 363 ori r2,r2,0xffff
364 mfdcr r1,isram0_dpc 364 mfdcr r1,isram0_dpc
365 and r1,r1,r2 /* Disable parity check */ 365 and r1,r1,r2 /* Disable parity check */
366 mtdcr isram0_dpc,r1 366 mtdcr isram0_dpc,r1
367 mfdcr r1,isram0_pmeg 367 mfdcr r1,isram0_pmeg
368 andis. r1,r1,r2 /* Disable pwr mgmt */ 368 andis. r1,r1,r2 /* Disable pwr mgmt */
369 mtdcr isram0_pmeg,r1 369 mtdcr isram0_pmeg,r1
370 370
371 lis r1,0x8000 /* BAS = 8000_0000 */ 371 lis r1,0x8000 /* BAS = 8000_0000 */
372 ori r1,r1,0x0380 /* 8k rw */ 372 ori r1,r1,0x0380 /* 8k rw */
373 mtdcr isram0_sb0cr,r1 373 mtdcr isram0_sb0cr,r1
374 374
375 /*----------------------------------------------------------------*/ 375 /*----------------------------------------------------------------*/
376 /* Setup the stack in internal SRAM */ 376 /* Setup the stack in internal SRAM */
377 /*----------------------------------------------------------------*/ 377 /*----------------------------------------------------------------*/
378 lis r1,CFG_INIT_RAM_ADDR@h 378 lis r1,CFG_INIT_RAM_ADDR@h
379 ori r1,r1,CFG_INIT_SP_OFFSET@l 379 ori r1,r1,CFG_INIT_SP_OFFSET@l
380 380
381 li r0,0 381 li r0,0
382 stwu r0,-4(r1) 382 stwu r0,-4(r1)
383 stwu r0,-4(r1) /* Terminate call chain */ 383 stwu r0,-4(r1) /* Terminate call chain */
384 384
385 stwu r1,-8(r1) /* Save back chain and move SP */ 385 stwu r1,-8(r1) /* Save back chain and move SP */
386 lis r0,RESET_VECTOR@h /* Address of reset vector */ 386 lis r0,RESET_VECTOR@h /* Address of reset vector */
387 ori r0,r0, RESET_VECTOR@l 387 ori r0,r0, RESET_VECTOR@l
388 stwu r1,-8(r1) /* Save back chain and move SP */ 388 stwu r1,-8(r1) /* Save back chain and move SP */
389 stw r0,+12(r1) /* Save return addr (underflow vect) */ 389 stw r0,+12(r1) /* Save return addr (underflow vect) */
390 390
391 GET_GOT 391 GET_GOT
392 bl board_init_f 392 bl board_init_f
393 393
394 #endif /* CONFIG_440 */ 394 #endif /* CONFIG_440 */
395 395
396 /*****************************************************************************/ 396 /*****************************************************************************/
397 #ifdef CONFIG_IOP480 397 #ifdef CONFIG_IOP480
398 /*----------------------------------------------------------------------- */ 398 /*----------------------------------------------------------------------- */
399 /* Set up some machine state registers. */ 399 /* Set up some machine state registers. */
400 /*----------------------------------------------------------------------- */ 400 /*----------------------------------------------------------------------- */
401 addi r0,r0,0x0000 /* initialize r0 to zero */ 401 addi r0,r0,0x0000 /* initialize r0 to zero */
402 mtspr esr,r0 /* clear Exception Syndrome Reg */ 402 mtspr esr,r0 /* clear Exception Syndrome Reg */
403 mttcr r0 /* timer control register */ 403 mttcr r0 /* timer control register */
404 mtexier r0 /* disable all interrupts */ 404 mtexier r0 /* disable all interrupts */
405 addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */ 405 addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */
406 oris r4,r4,0x2 /* set CE bit (Critical Exceptions) */ 406 oris r4,r4,0x2 /* set CE bit (Critical Exceptions) */
407 mtmsr r4 /* change MSR */ 407 mtmsr r4 /* change MSR */
408 addis r4,r0,0xFFFF /* set r4 to 0xFFFFFFFF (status in the */ 408 addis r4,r0,0xFFFF /* set r4 to 0xFFFFFFFF (status in the */
409 ori r4,r4,0xFFFF /* dbsr is cleared by setting bits to 1) */ 409 ori r4,r4,0xFFFF /* dbsr is cleared by setting bits to 1) */
410 mtdbsr r4 /* clear/reset the dbsr */ 410 mtdbsr r4 /* clear/reset the dbsr */
411 mtexisr r4 /* clear all pending interrupts */ 411 mtexisr r4 /* clear all pending interrupts */
412 addis r4,r0,0x8000 412 addis r4,r0,0x8000
413 mtexier r4 /* enable critical exceptions */ 413 mtexier r4 /* enable critical exceptions */
414 addis r4,r0,0x0000 /* assume 403GCX - enable core clk */ 414 addis r4,r0,0x0000 /* assume 403GCX - enable core clk */
415 ori r4,r4,0x4020 /* dbling (no harm done on GA and GC */ 415 ori r4,r4,0x4020 /* dbling (no harm done on GA and GC */
416 mtiocr r4 /* since bit not used) & DRC to latch */ 416 mtiocr r4 /* since bit not used) & DRC to latch */
417 /* data bus on rising edge of CAS */ 417 /* data bus on rising edge of CAS */
418 /*----------------------------------------------------------------------- */ 418 /*----------------------------------------------------------------------- */
419 /* Clear XER. */ 419 /* Clear XER. */
420 /*----------------------------------------------------------------------- */ 420 /*----------------------------------------------------------------------- */
421 mtxer r0 421 mtxer r0
422 /*----------------------------------------------------------------------- */ 422 /*----------------------------------------------------------------------- */
423 /* Invalidate i-cache and d-cache TAG arrays. */ 423 /* Invalidate i-cache and d-cache TAG arrays. */
424 /*----------------------------------------------------------------------- */ 424 /*----------------------------------------------------------------------- */
425 addi r3,0,1024 /* 1/4 of I-cache size, half of D-cache */ 425 addi r3,0,1024 /* 1/4 of I-cache size, half of D-cache */
426 addi r4,0,1024 /* 1/4 of I-cache */ 426 addi r4,0,1024 /* 1/4 of I-cache */
427 ..cloop: 427 ..cloop:
428 iccci 0,r3 428 iccci 0,r3
429 iccci r4,r3 429 iccci r4,r3
430 dccci 0,r3 430 dccci 0,r3
431 addic. r3,r3,-16 /* move back one cache line */ 431 addic. r3,r3,-16 /* move back one cache line */
432 bne ..cloop /* loop back to do rest until r3 = 0 */ 432 bne ..cloop /* loop back to do rest until r3 = 0 */
433 433
434 /* */ 434 /* */
435 /* initialize IOP480 so it can read 1 MB code area for SRAM spaces */ 435 /* initialize IOP480 so it can read 1 MB code area for SRAM spaces */
436 /* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */ 436 /* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */
437 /* */ 437 /* */
438 438
439 /* first copy IOP480 register base address into r3 */ 439 /* first copy IOP480 register base address into r3 */
440 addis r3,0,0x5000 /* IOP480 register base address hi */ 440 addis r3,0,0x5000 /* IOP480 register base address hi */
441 /* ori r3,r3,0x0000 / IOP480 register base address lo */ 441 /* ori r3,r3,0x0000 / IOP480 register base address lo */
442 442
443 #ifdef CONFIG_ADCIOP 443 #ifdef CONFIG_ADCIOP
444 /* use r4 as the working variable */ 444 /* use r4 as the working variable */
445 /* turn on CS3 (LOCCTL.7) */ 445 /* turn on CS3 (LOCCTL.7) */
446 lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */ 446 lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
447 andi. r4,r4,0xff7f /* make bit 7 = 0 -- CS3 mode */ 447 andi. r4,r4,0xff7f /* make bit 7 = 0 -- CS3 mode */
448 stw r4,0x84(r3) /* LOCTL is at offset 0x84 */ 448 stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
449 #endif 449 #endif
450 450
451 #ifdef CONFIG_DASA_SIM 451 #ifdef CONFIG_DASA_SIM
452 /* use r4 as the working variable */ 452 /* use r4 as the working variable */
453 /* turn on MA17 (LOCCTL.7) */ 453 /* turn on MA17 (LOCCTL.7) */
454 lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */ 454 lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
455 ori r4,r4,0x80 /* make bit 7 = 1 -- MA17 mode */ 455 ori r4,r4,0x80 /* make bit 7 = 1 -- MA17 mode */
456 stw r4,0x84(r3) /* LOCTL is at offset 0x84 */ 456 stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
457 #endif 457 #endif
458 458
459 /* turn on MA16..13 (LCS0BRD.12 = 0) */ 459 /* turn on MA16..13 (LCS0BRD.12 = 0) */
460 lwz r4,0x100(r3) /* LCS0BRD is at offset 0x100 */ 460 lwz r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
461 andi. r4,r4,0xefff /* make bit 12 = 0 */ 461 andi. r4,r4,0xefff /* make bit 12 = 0 */
462 stw r4,0x100(r3) /* LCS0BRD is at offset 0x100 */ 462 stw r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
463 463
464 /* make sure above stores all comlete before going on */ 464 /* make sure above stores all comlete before going on */
465 sync 465 sync
466 466
467 /* last thing, set local init status done bit (DEVINIT.31) */ 467 /* last thing, set local init status done bit (DEVINIT.31) */
468 lwz r4,0x80(r3) /* DEVINIT is at offset 0x80 */ 468 lwz r4,0x80(r3) /* DEVINIT is at offset 0x80 */
469 oris r4,r4,0x8000 /* make bit 31 = 1 */ 469 oris r4,r4,0x8000 /* make bit 31 = 1 */
470 stw r4,0x80(r3) /* DEVINIT is at offset 0x80 */ 470 stw r4,0x80(r3) /* DEVINIT is at offset 0x80 */
471 471
472 /* clear all pending interrupts and disable all interrupts */ 472 /* clear all pending interrupts and disable all interrupts */
473 li r4,-1 /* set p1 to 0xffffffff */ 473 li r4,-1 /* set p1 to 0xffffffff */
474 stw r4,0x1b0(r3) /* clear all pending interrupts */ 474 stw r4,0x1b0(r3) /* clear all pending interrupts */
475 stw r4,0x1b8(r3) /* clear all pending interrupts */ 475 stw r4,0x1b8(r3) /* clear all pending interrupts */
476 li r4,0 /* set r4 to 0 */ 476 li r4,0 /* set r4 to 0 */
477 stw r4,0x1b4(r3) /* disable all interrupts */ 477 stw r4,0x1b4(r3) /* disable all interrupts */
478 stw r4,0x1bc(r3) /* disable all interrupts */ 478 stw r4,0x1bc(r3) /* disable all interrupts */
479 479
480 /* make sure above stores all comlete before going on */ 480 /* make sure above stores all comlete before going on */
481 sync 481 sync
482 482
483 /*----------------------------------------------------------------------- */ 483 /*----------------------------------------------------------------------- */
484 /* Enable two 128MB cachable regions. */ 484 /* Enable two 128MB cachable regions. */
485 /*----------------------------------------------------------------------- */ 485 /*----------------------------------------------------------------------- */
486 addis r1,r0,0x8000 486 addis r1,r0,0x8000
487 addi r1,r1,0x0001 487 addi r1,r1,0x0001
488 mticcr r1 /* instruction cache */ 488 mticcr r1 /* instruction cache */
489 489
490 addis r1,r0,0x0000 490 addis r1,r0,0x0000
491 addi r1,r1,0x0000 491 addi r1,r1,0x0000
492 mtdccr r1 /* data cache */ 492 mtdccr r1 /* data cache */
493 493
494 addis r1,r0,CFG_INIT_RAM_ADDR@h 494 addis r1,r0,CFG_INIT_RAM_ADDR@h
495 ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack to SDRAM */ 495 ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack to SDRAM */
496 li r0, 0 /* Make room for stack frame header and */ 496 li r0, 0 /* Make room for stack frame header and */
497 stwu r0, -4(r1) /* clear final stack frame so that */ 497 stwu r0, -4(r1) /* clear final stack frame so that */
498 stwu r0, -4(r1) /* stack backtraces terminate cleanly */ 498 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
499 499
500 GET_GOT /* initialize GOT access */ 500 GET_GOT /* initialize GOT access */
501 501
502 bl board_init_f /* run first part of init code (from Flash) */ 502 bl board_init_f /* run first part of init code (from Flash) */
503 503
504 #endif /* CONFIG_IOP480 */ 504 #endif /* CONFIG_IOP480 */
505 505
506 /*****************************************************************************/ 506 /*****************************************************************************/
507 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405) 507 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405)
508 /*----------------------------------------------------------------------- */ 508 /*----------------------------------------------------------------------- */
509 /* Clear and set up some registers. */ 509 /* Clear and set up some registers. */
510 /*----------------------------------------------------------------------- */ 510 /*----------------------------------------------------------------------- */
511 addi r4,r0,0x0000 511 addi r4,r0,0x0000
512 mtspr sgr,r4 512 mtspr sgr,r4
513 mtspr dcwr,r4 513 mtspr dcwr,r4
514 mtesr r4 /* clear Exception Syndrome Reg */ 514 mtesr r4 /* clear Exception Syndrome Reg */
515 mttcr r4 /* clear Timer Control Reg */ 515 mttcr r4 /* clear Timer Control Reg */
516 mtxer r4 /* clear Fixed-Point Exception Reg */ 516 mtxer r4 /* clear Fixed-Point Exception Reg */
517 mtevpr r4 /* clear Exception Vector Prefix Reg */ 517 mtevpr r4 /* clear Exception Vector Prefix Reg */
518 addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */ 518 addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */
519 oris r4,r4,0x0002 /* set CE bit (Critical Exceptions) */ 519 oris r4,r4,0x0002 /* set CE bit (Critical Exceptions) */
520 mtmsr r4 /* change MSR */ 520 mtmsr r4 /* change MSR */
521 addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */ 521 addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
522 /* dbsr is cleared by setting bits to 1) */ 522 /* dbsr is cleared by setting bits to 1) */
523 mtdbsr r4 /* clear/reset the dbsr */ 523 mtdbsr r4 /* clear/reset the dbsr */
524 524
525 /*----------------------------------------------------------------------- */ 525 /*----------------------------------------------------------------------- */
526 /* Invalidate I and D caches. Enable I cache for defined memory regions */ 526 /* Invalidate I and D caches. Enable I cache for defined memory regions */
527 /* to speed things up. Leave the D cache disabled for now. It will be */ 527 /* to speed things up. Leave the D cache disabled for now. It will be */
528 /* enabled/left disabled later based on user selected menu options. */ 528 /* enabled/left disabled later based on user selected menu options. */
529 /* Be aware that the I cache may be disabled later based on the menu */ 529 /* Be aware that the I cache may be disabled later based on the menu */
530 /* options as well. See miscLib/main.c. */ 530 /* options as well. See miscLib/main.c. */
531 /*----------------------------------------------------------------------- */ 531 /*----------------------------------------------------------------------- */
532 bl invalidate_icache 532 bl invalidate_icache
533 bl invalidate_dcache 533 bl invalidate_dcache
534 534
535 /*----------------------------------------------------------------------- */ 535 /*----------------------------------------------------------------------- */
536 /* Enable two 128MB cachable regions. */ 536 /* Enable two 128MB cachable regions. */
537 /*----------------------------------------------------------------------- */ 537 /*----------------------------------------------------------------------- */
538 addis r4,r0,0x8000 538 addis r4,r0,0x8000
539 addi r4,r4,0x0001 539 addi r4,r4,0x0001
540 mticcr r4 /* instruction cache */ 540 mticcr r4 /* instruction cache */
541 isync 541 isync
542 542
543 addis r4,r0,0x0000 543 addis r4,r0,0x0000
544 addi r4,r4,0x0000 544 addi r4,r4,0x0000
545 mtdccr r4 /* data cache */ 545 mtdccr r4 /* data cache */
546 546
547 #if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR)) 547 #if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
548 /*----------------------------------------------------------------------- */ 548 /*----------------------------------------------------------------------- */
549 /* Tune the speed and size for flash CS0 */ 549 /* Tune the speed and size for flash CS0 */
550 /*----------------------------------------------------------------------- */ 550 /*----------------------------------------------------------------------- */
551 bl ext_bus_cntlr_init 551 bl ext_bus_cntlr_init
552 #endif 552 #endif
553 553
554 #if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE) 554 #if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)
555 /******************************************************************** 555 /********************************************************************
556 * Setup OCM - On Chip Memory 556 * Setup OCM - On Chip Memory
557 *******************************************************************/ 557 *******************************************************************/
558 /* Setup OCM */ 558 /* Setup OCM */
559 lis r0, 0x7FFF 559 lis r0, 0x7FFF
560 ori r0, r0, 0xFFFF 560 ori r0, r0, 0xFFFF
561 mfdcr r3, ocmiscntl /* get instr-side IRAM config */ 561 mfdcr r3, ocmiscntl /* get instr-side IRAM config */
562 mfdcr r4, ocmdscntl /* get data-side IRAM config */ 562 mfdcr r4, ocmdscntl /* get data-side IRAM config */
563 and r3, r3, r0 /* disable data-side IRAM */ 563 and r3, r3, r0 /* disable data-side IRAM */
564 and r4, r4, r0 /* disable data-side IRAM */ 564 and r4, r4, r0 /* disable data-side IRAM */
565 mtdcr ocmiscntl, r3 /* set instr-side IRAM config */ 565 mtdcr ocmiscntl, r3 /* set instr-side IRAM config */
566 mtdcr ocmdscntl, r4 /* set data-side IRAM config */ 566 mtdcr ocmdscntl, r4 /* set data-side IRAM config */
567 isync 567 isync
568 568
569 addis r3, 0, CFG_OCM_DATA_ADDR@h /* OCM location */ 569 addis r3, 0, CFG_OCM_DATA_ADDR@h /* OCM location */
570 mtdcr ocmdsarc, r3 570 mtdcr ocmdsarc, r3
571 addis r4, 0, 0xC000 /* OCM data area enabled */ 571 addis r4, 0, 0xC000 /* OCM data area enabled */
572 mtdcr ocmdscntl, r4 572 mtdcr ocmdscntl, r4
573 isync 573 isync
574 #endif 574 #endif
575 575
576 /*----------------------------------------------------------------------- */ 576 /*----------------------------------------------------------------------- */
577 /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */ 577 /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
578 /*----------------------------------------------------------------------- */ 578 /*----------------------------------------------------------------------- */
579 #ifdef CFG_INIT_DCACHE_CS 579 #ifdef CFG_INIT_DCACHE_CS
580 /*----------------------------------------------------------------------- */ 580 /*----------------------------------------------------------------------- */
581 /* Memory Bank x (nothingness) initialization 1GB+64MEG */ 581 /* Memory Bank x (nothingness) initialization 1GB+64MEG */
582 /* used as temporary stack pointer for stage0 */ 582 /* used as temporary stack pointer for stage0 */
583 /*----------------------------------------------------------------------- */ 583 /*----------------------------------------------------------------------- */
584 li r4,PBxAP 584 li r4,PBxAP
585 mtdcr ebccfga,r4 585 mtdcr ebccfga,r4
586 lis r4,0x0380 586 lis r4,0x0380
587 ori r4,r4,0x0480 587 ori r4,r4,0x0480
588 mtdcr ebccfgd,r4 588 mtdcr ebccfgd,r4
589 589
590 addi r4,0,PBxCR 590 addi r4,0,PBxCR
591 mtdcr ebccfga,r4 591 mtdcr ebccfga,r4
592 lis r4,0x400D 592 lis r4,0x400D
593 ori r4,r4,0xa000 593 ori r4,r4,0xa000
594 mtdcr ebccfgd,r4 594 mtdcr ebccfgd,r4
595 595
596 /* turn on data chache for this region */ 596 /* turn on data chache for this region */
597 lis r4,0x0080 597 lis r4,0x0080
598 mtdccr r4 598 mtdccr r4
599 599
600 /* set stack pointer and clear stack to known value */ 600 /* set stack pointer and clear stack to known value */
601 601
602 lis r1,CFG_INIT_RAM_ADDR@h 602 lis r1,CFG_INIT_RAM_ADDR@h
603 ori r1,r1,CFG_INIT_SP_OFFSET@l 603 ori r1,r1,CFG_INIT_SP_OFFSET@l
604 604
605 li r4,2048 /* we store 2048 words to stack */ 605 li r4,2048 /* we store 2048 words to stack */
606 mtctr r4 606 mtctr r4
607 607
608 lis r2,CFG_INIT_RAM_ADDR@h /* we also clear data area */ 608 lis r2,CFG_INIT_RAM_ADDR@h /* we also clear data area */
609 ori r2,r2,CFG_INIT_RAM_END@l /* so cant copy value from r1 */ 609 ori r2,r2,CFG_INIT_RAM_END@l /* so cant copy value from r1 */
610 610
611 lis r4,0xdead /* we store 0xdeaddead in the stack */ 611 lis r4,0xdead /* we store 0xdeaddead in the stack */
612 ori r4,r4,0xdead 612 ori r4,r4,0xdead
613 613
614 ..stackloop: 614 ..stackloop:
615 stwu r4,-4(r2) 615 stwu r4,-4(r2)
616 bdnz ..stackloop 616 bdnz ..stackloop
617 617
618 li r0, 0 /* Make room for stack frame header and */ 618 li r0, 0 /* Make room for stack frame header and */
619 stwu r0, -4(r1) /* clear final stack frame so that */ 619 stwu r0, -4(r1) /* clear final stack frame so that */
620 stwu r0, -4(r1) /* stack backtraces terminate cleanly */ 620 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
621 /* 621 /*
622 * Set up a dummy frame to store reset vector as return address. 622 * Set up a dummy frame to store reset vector as return address.
623 * this causes stack underflow to reset board. 623 * this causes stack underflow to reset board.
624 */ 624 */
625 stwu r1, -8(r1) /* Save back chain and move SP */ 625 stwu r1, -8(r1) /* Save back chain and move SP */
626 addis r0, 0, RESET_VECTOR@h /* Address of reset vector */ 626 addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
627 ori r0, r0, RESET_VECTOR@l 627 ori r0, r0, RESET_VECTOR@l
628 stwu r1, -8(r1) /* Save back chain and move SP */ 628 stwu r1, -8(r1) /* Save back chain and move SP */
629 stw r0, +12(r1) /* Save return addr (underflow vect) */ 629 stw r0, +12(r1) /* Save return addr (underflow vect) */
630 630
631 #elif defined(CFG_TEMP_STACK_OCM) && \ 631 #elif defined(CFG_TEMP_STACK_OCM) && \
632 (defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)) 632 (defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE))
633 /* 633 /*
634 * Stack in OCM. 634 * Stack in OCM.
635 */ 635 */
636 636
637 /* Set up Stack at top of OCM */ 637 /* Set up Stack at top of OCM */
638 lis r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@h 638 lis r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@h
639 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@l 639 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@l
640 640
641 /* Set up a zeroized stack frame so that backtrace works right */ 641 /* Set up a zeroized stack frame so that backtrace works right */
642 li r0, 0 642 li r0, 0
643 stwu r0, -4(r1) 643 stwu r0, -4(r1)
644 stwu r0, -4(r1) 644 stwu r0, -4(r1)
645 645
646 /* 646 /*
647 * Set up a dummy frame to store reset vector as return address. 647 * Set up a dummy frame to store reset vector as return address.
648 * this causes stack underflow to reset board. 648 * this causes stack underflow to reset board.
649 */ 649 */
650 stwu r1, -8(r1) /* Save back chain and move SP */ 650 stwu r1, -8(r1) /* Save back chain and move SP */
651 lis r0, RESET_VECTOR@h /* Address of reset vector */ 651 lis r0, RESET_VECTOR@h /* Address of reset vector */
652 ori r0, r0, RESET_VECTOR@l 652 ori r0, r0, RESET_VECTOR@l
653 stwu r1, -8(r1) /* Save back chain and move SP */ 653 stwu r1, -8(r1) /* Save back chain and move SP */
654 stw r0, +12(r1) /* Save return addr (underflow vect) */ 654 stw r0, +12(r1) /* Save return addr (underflow vect) */
655 #endif /* CFG_INIT_DCACHE_CS */ 655 #endif /* CFG_INIT_DCACHE_CS */
656 656
657 /*----------------------------------------------------------------------- */ 657 /*----------------------------------------------------------------------- */
658 /* Initialize SDRAM Controller */ 658 /* Initialize SDRAM Controller */
659 /*----------------------------------------------------------------------- */ 659 /*----------------------------------------------------------------------- */
660 bl sdram_init 660 bl sdram_init
661 661
662 /* 662 /*
663 * Setup temporary stack pointer only for boards 663 * Setup temporary stack pointer only for boards
664 * that do not use SDRAM SPD I2C stuff since it 664 * that do not use SDRAM SPD I2C stuff since it
665 * is already initialized to use DCACHE or OCM 665 * is already initialized to use DCACHE or OCM
666 * stacks. 666 * stacks.
667 */ 667 */
668 #if !(defined(CFG_INIT_DCACHE_CS) || defined(CFG_TEMP_STACK_OCM)) 668 #if !(defined(CFG_INIT_DCACHE_CS) || defined(CFG_TEMP_STACK_OCM))
669 lis r1, CFG_INIT_RAM_ADDR@h 669 lis r1, CFG_INIT_RAM_ADDR@h
670 ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack in SDRAM */ 670 ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack in SDRAM */
671 671
672 li r0, 0 /* Make room for stack frame header and */ 672 li r0, 0 /* Make room for stack frame header and */
673 stwu r0, -4(r1) /* clear final stack frame so that */ 673 stwu r0, -4(r1) /* clear final stack frame so that */
674 stwu r0, -4(r1) /* stack backtraces terminate cleanly */ 674 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
675 /* 675 /*
676 * Set up a dummy frame to store reset vector as return address. 676 * Set up a dummy frame to store reset vector as return address.
677 * this causes stack underflow to reset board. 677 * this causes stack underflow to reset board.
678 */ 678 */
679 stwu r1, -8(r1) /* Save back chain and move SP */ 679 stwu r1, -8(r1) /* Save back chain and move SP */
680 lis r0, RESET_VECTOR@h /* Address of reset vector */ 680 lis r0, RESET_VECTOR@h /* Address of reset vector */
681 ori r0, r0, RESET_VECTOR@l 681 ori r0, r0, RESET_VECTOR@l
682 stwu r1, -8(r1) /* Save back chain and move SP */ 682 stwu r1, -8(r1) /* Save back chain and move SP */
683 stw r0, +12(r1) /* Save return addr (underflow vect) */ 683 stw r0, +12(r1) /* Save return addr (underflow vect) */
684 #endif /* !(CFG_INIT_DCACHE_CS || !CFG_TEM_STACK_OCM) */ 684 #endif /* !(CFG_INIT_DCACHE_CS || !CFG_TEM_STACK_OCM) */
685 685
686 GET_GOT /* initialize GOT access */ 686 GET_GOT /* initialize GOT access */
687 687
688 bl cpu_init_f /* run low-level CPU init code (from Flash) */ 688 bl cpu_init_f /* run low-level CPU init code (from Flash) */
689 689
690 /* NEVER RETURNS! */ 690 /* NEVER RETURNS! */
691 bl board_init_f /* run first part of init code (from Flash) */ 691 bl board_init_f /* run first part of init code (from Flash) */
692 692
693 #endif /* CONFIG_405GP || CONFIG_405CR */ 693 #endif /* CONFIG_405GP || CONFIG_405CR */
694 694
695 695
696 .globl _start_of_vectors 696 .globl _start_of_vectors
697 _start_of_vectors: 697 _start_of_vectors:
698 698
699 #if 0 699 #if 0
700 /*TODO Fixup _start above so we can do this*/ 700 /*TODO Fixup _start above so we can do this*/
701 /* Critical input. */ 701 /* Critical input. */
702 CRIT_EXCEPTION(0x100, CritcalInput, CritcalInputException) 702 CRIT_EXCEPTION(0x100, CritcalInput, CritcalInputException)
703 #endif 703 #endif
704 704
705 /* Machine check */ 705 /* Machine check */
706 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException) 706 STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
707 707
708 /* Data Storage exception. */ 708 /* Data Storage exception. */
709 STD_EXCEPTION(0x300, DataStorage, UnknownException) 709 STD_EXCEPTION(0x300, DataStorage, UnknownException)
710 710
711 /* Instruction Storage exception. */ 711 /* Instruction Storage exception. */
712 STD_EXCEPTION(0x400, InstStorage, UnknownException) 712 STD_EXCEPTION(0x400, InstStorage, UnknownException)
713 713
714 /* External Interrupt exception. */ 714 /* External Interrupt exception. */
715 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt) 715 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
716 716
717 /* Alignment exception. */ 717 /* Alignment exception. */
718 . = 0x600 718 . = 0x600
719 Alignment: 719 Alignment:
720 EXCEPTION_PROLOG 720 EXCEPTION_PROLOG
721 mfspr r4,DAR 721 mfspr r4,DAR
722 stw r4,_DAR(r21) 722 stw r4,_DAR(r21)
723 mfspr r5,DSISR 723 mfspr r5,DSISR
724 stw r5,_DSISR(r21) 724 stw r5,_DSISR(r21)
725 addi r3,r1,STACK_FRAME_OVERHEAD 725 addi r3,r1,STACK_FRAME_OVERHEAD
726 li r20,MSR_KERNEL 726 li r20,MSR_KERNEL
727 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 727 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
728 lwz r6,GOT(transfer_to_handler) 728 lwz r6,GOT(transfer_to_handler)
729 mtlr r6 729 mtlr r6
730 blrl 730 blrl
731 .L_Alignment: 731 .L_Alignment:
732 .long AlignmentException - _start + EXC_OFF_SYS_RESET 732 .long AlignmentException - _start + EXC_OFF_SYS_RESET
733 .long int_return - _start + EXC_OFF_SYS_RESET 733 .long int_return - _start + EXC_OFF_SYS_RESET
734 734
735 /* Program check exception */ 735 /* Program check exception */
736 . = 0x700 736 . = 0x700
737 ProgramCheck: 737 ProgramCheck:
738 EXCEPTION_PROLOG 738 EXCEPTION_PROLOG
739 addi r3,r1,STACK_FRAME_OVERHEAD 739 addi r3,r1,STACK_FRAME_OVERHEAD
740 li r20,MSR_KERNEL 740 li r20,MSR_KERNEL
741 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ 741 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
742 lwz r6,GOT(transfer_to_handler) 742 lwz r6,GOT(transfer_to_handler)
743 mtlr r6 743 mtlr r6
744 blrl 744 blrl
745 .L_ProgramCheck: 745 .L_ProgramCheck:
746 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET 746 .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
747 .long int_return - _start + EXC_OFF_SYS_RESET 747 .long int_return - _start + EXC_OFF_SYS_RESET
748 748
749 /* No FPU on MPC8xx. This exception is not supposed to happen. 749 /* No FPU on MPC8xx. This exception is not supposed to happen.
750 */ 750 */
751 STD_EXCEPTION(0x800, FPUnavailable, UnknownException) 751 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
752 752
753 /* I guess we could implement decrementer, and may have 753 /* I guess we could implement decrementer, and may have
754 * to someday for timekeeping. 754 * to someday for timekeeping.
755 */ 755 */
756 STD_EXCEPTION(0x900, Decrementer, timer_interrupt) 756 STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
757 STD_EXCEPTION(0xa00, Trap_0a, UnknownException) 757 STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
758 STD_EXCEPTION(0xb00, Trap_0b, UnknownException) 758 STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
759 759
760 . = 0xc00 760 . = 0xc00
761 /* 761 /*
762 * r0 - SYSCALL number 762 * r0 - SYSCALL number
763 * r3-... arguments 763 * r3-... arguments
764 */ 764 */
765 SystemCall: 765 SystemCall:
766 addis r11,r0,0 /* get functions table addr */ 766 addis r11,r0,0 /* get functions table addr */
767 ori r11,r11,0 /* Note: this code is patched in trap_init */ 767 ori r11,r11,0 /* Note: this code is patched in trap_init */
768 addis r12,r0,0 /* get number of functions */ 768 addis r12,r0,0 /* get number of functions */
769 ori r12,r12,0 769 ori r12,r12,0
770 770
771 cmplw 0, r0, r12 771 cmplw 0, r0, r12
772 bge 1f 772 bge 1f
773 773
774 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ 774 rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */
775 add r11,r11,r0 775 add r11,r11,r0
776 lwz r11,0(r11) 776 lwz r11,0(r11)
777 777
778 li r12,0xd00-4*3 /* save LR & SRRx */ 778 li r20,0xd00-4 /* Get stack pointer */
779 lwz r12,0(r20)
780 subi r12,r12,12 /* Adjust stack pointer */
781 li r0,0xc00+_end_back-SystemCall
782 cmplw 0, r0, r12 /* Check stack overflow */
783 bgt 1f
784 stw r12,0(r20)
785
779 mflr r0 786 mflr r0
780 stw r0,0(r12) 787 stw r0,0(r12)
781 mfspr r0,SRR0 788 mfspr r0,SRR0
782 stw r0,4(r12) 789 stw r0,4(r12)
783 mfspr r0,SRR1 790 mfspr r0,SRR1
784 stw r0,8(r12) 791 stw r0,8(r12)
785 792
786 li r12,0xc00+_back-SystemCall 793 li r12,0xc00+_back-SystemCall
787 mtlr r12 794 mtlr r12
788 mtspr SRR0,r11 795 mtspr SRR0,r11
789 796
790 1: SYNC 797 1: SYNC
791 rfi 798 rfi
792 799
793 _back: 800 _back:
794 801
795 mfmsr r11 /* Disable interrupts */ 802 mfmsr r11 /* Disable interrupts */
796 li r12,0 803 li r12,0
797 ori r12,r12,MSR_EE 804 ori r12,r12,MSR_EE
798 andc r11,r11,r12 805 andc r11,r11,r12
799 SYNC /* Some chip revs need this... */ 806 SYNC /* Some chip revs need this... */
800 mtmsr r11 807 mtmsr r11
801 SYNC 808 SYNC
802 809
803 li r12,0xd00-4*3 /* restore regs */ 810 li r12,0xd00-4 /* restore regs */
811 lwz r12,0(r12)
812
804 lwz r11,0(r12) 813 lwz r11,0(r12)
805 mtlr r11 814 mtlr r11
806 lwz r11,4(r12) 815 lwz r11,4(r12)
807 mtspr SRR0,r11 816 mtspr SRR0,r11
808 lwz r11,8(r12) 817 lwz r11,8(r12)
809 mtspr SRR1,r11 818 mtspr SRR1,r11
810 819
820 addi r12,r12,12 /* Adjust stack pointer */
821 li r20,0xd00-4
822 stw r12,0(r20)
823
811 SYNC 824 SYNC
812 rfi 825 rfi
826 _end_back:
813 827
814 STD_EXCEPTION(0xd00, SingleStep, UnknownException) 828 STD_EXCEPTION(0xd00, SingleStep, UnknownException)
815 829
816 STD_EXCEPTION(0xe00, Trap_0e, UnknownException) 830 STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
817 STD_EXCEPTION(0xf00, Trap_0f, UnknownException) 831 STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
818 832
819 /* On the MPC8xx, this is a software emulation interrupt. It occurs 833 /* On the MPC8xx, this is a software emulation interrupt. It occurs
820 * for all unimplemented and illegal instructions. 834 * for all unimplemented and illegal instructions.
821 */ 835 */
822 STD_EXCEPTION(0x1000, PIT, PITException) 836 STD_EXCEPTION(0x1000, PIT, PITException)
823 837
824 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException) 838 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
825 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException) 839 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
826 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException) 840 STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
827 STD_EXCEPTION(0x1400, DataTLBError, UnknownException) 841 STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
828 842
829 STD_EXCEPTION(0x1500, Reserved5, UnknownException) 843 STD_EXCEPTION(0x1500, Reserved5, UnknownException)
830 STD_EXCEPTION(0x1600, Reserved6, UnknownException) 844 STD_EXCEPTION(0x1600, Reserved6, UnknownException)
831 STD_EXCEPTION(0x1700, Reserved7, UnknownException) 845 STD_EXCEPTION(0x1700, Reserved7, UnknownException)
832 STD_EXCEPTION(0x1800, Reserved8, UnknownException) 846 STD_EXCEPTION(0x1800, Reserved8, UnknownException)
833 STD_EXCEPTION(0x1900, Reserved9, UnknownException) 847 STD_EXCEPTION(0x1900, Reserved9, UnknownException)
834 STD_EXCEPTION(0x1a00, ReservedA, UnknownException) 848 STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
835 STD_EXCEPTION(0x1b00, ReservedB, UnknownException) 849 STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
836 850
837 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException) 851 STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
838 STD_EXCEPTION(0x1d00, InstructionBreakpoint, UnknownException) 852 STD_EXCEPTION(0x1d00, InstructionBreakpoint, UnknownException)
839 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException) 853 STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
840 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException) 854 STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
841 855
842 CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException ) 856 CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
843 857
844 .globl _end_of_vectors 858 .globl _end_of_vectors
845 _end_of_vectors: 859 _end_of_vectors:
846 860
847 861
848 . = 0x2100 862 . = 0x2100
849 863
850 /* 864 /*
851 * This code finishes saving the registers to the exception frame 865 * This code finishes saving the registers to the exception frame
852 * and jumps to the appropriate handler for the exception. 866 * and jumps to the appropriate handler for the exception.
853 * Register r21 is pointer into trap frame, r1 has new stack pointer. 867 * Register r21 is pointer into trap frame, r1 has new stack pointer.
854 */ 868 */
855 .globl transfer_to_handler 869 .globl transfer_to_handler
856 transfer_to_handler: 870 transfer_to_handler:
857 stw r22,_NIP(r21) 871 stw r22,_NIP(r21)
858 lis r22,MSR_POW@h 872 lis r22,MSR_POW@h
859 andc r23,r23,r22 873 andc r23,r23,r22
860 stw r23,_MSR(r21) 874 stw r23,_MSR(r21)
861 SAVE_GPR(7, r21) 875 SAVE_GPR(7, r21)
862 SAVE_4GPRS(8, r21) 876 SAVE_4GPRS(8, r21)
863 SAVE_8GPRS(12, r21) 877 SAVE_8GPRS(12, r21)
864 SAVE_8GPRS(24, r21) 878 SAVE_8GPRS(24, r21)
865 #if 0 879 #if 0
866 andi. r23,r23,MSR_PR 880 andi. r23,r23,MSR_PR
867 mfspr r23,SPRG3 /* if from user, fix up tss.regs */ 881 mfspr r23,SPRG3 /* if from user, fix up tss.regs */
868 beq 2f 882 beq 2f
869 addi r24,r1,STACK_FRAME_OVERHEAD 883 addi r24,r1,STACK_FRAME_OVERHEAD
870 stw r24,PT_REGS(r23) 884 stw r24,PT_REGS(r23)
871 2: addi r2,r23,-TSS /* set r2 to current */ 885 2: addi r2,r23,-TSS /* set r2 to current */
872 tovirt(r2,r2,r23) 886 tovirt(r2,r2,r23)
873 #endif 887 #endif
874 mflr r23 888 mflr r23
875 andi. r24,r23,0x3f00 /* get vector offset */ 889 andi. r24,r23,0x3f00 /* get vector offset */
876 stw r24,TRAP(r21) 890 stw r24,TRAP(r21)
877 li r22,0 891 li r22,0
878 stw r22,RESULT(r21) 892 stw r22,RESULT(r21)
879 mtspr SPRG2,r22 /* r1 is now kernel sp */ 893 mtspr SPRG2,r22 /* r1 is now kernel sp */
880 #if 0 894 #if 0
881 addi r24,r2,TASK_STRUCT_SIZE /* check for kernel stack overflow */ 895 addi r24,r2,TASK_STRUCT_SIZE /* check for kernel stack overflow */
882 cmplw 0,r1,r2 896 cmplw 0,r1,r2
883 cmplw 1,r1,r24 897 cmplw 1,r1,r24
884 crand 1,1,4 898 crand 1,1,4
885 bgt stack_ovf /* if r2 < r1 < r2+TASK_STRUCT_SIZE */ 899 bgt stack_ovf /* if r2 < r1 < r2+TASK_STRUCT_SIZE */
886 #endif 900 #endif
887 lwz r24,0(r23) /* virtual address of handler */ 901 lwz r24,0(r23) /* virtual address of handler */
888 lwz r23,4(r23) /* where to go when done */ 902 lwz r23,4(r23) /* where to go when done */
889 mtspr SRR0,r24 903 mtspr SRR0,r24
890 mtspr SRR1,r20 904 mtspr SRR1,r20
891 mtlr r23 905 mtlr r23
892 SYNC 906 SYNC
893 rfi /* jump to handler, enable MMU */ 907 rfi /* jump to handler, enable MMU */
894 908
895 int_return: 909 int_return:
896 mfmsr r28 /* Disable interrupts */ 910 mfmsr r28 /* Disable interrupts */
897 li r4,0 911 li r4,0
898 ori r4,r4,MSR_EE 912 ori r4,r4,MSR_EE
899 andc r28,r28,r4 913 andc r28,r28,r4
900 SYNC /* Some chip revs need this... */ 914 SYNC /* Some chip revs need this... */
901 mtmsr r28 915 mtmsr r28
902 SYNC 916 SYNC
903 lwz r2,_CTR(r1) 917 lwz r2,_CTR(r1)
904 lwz r0,_LINK(r1) 918 lwz r0,_LINK(r1)
905 mtctr r2 919 mtctr r2
906 mtlr r0 920 mtlr r0
907 lwz r2,_XER(r1) 921 lwz r2,_XER(r1)
908 lwz r0,_CCR(r1) 922 lwz r0,_CCR(r1)
909 mtspr XER,r2 923 mtspr XER,r2
910 mtcrf 0xFF,r0 924 mtcrf 0xFF,r0
911 REST_10GPRS(3, r1) 925 REST_10GPRS(3, r1)
912 REST_10GPRS(13, r1) 926 REST_10GPRS(13, r1)
913 REST_8GPRS(23, r1) 927 REST_8GPRS(23, r1)
914 REST_GPR(31, r1) 928 REST_GPR(31, r1)
915 lwz r2,_NIP(r1) /* Restore environment */ 929 lwz r2,_NIP(r1) /* Restore environment */
916 lwz r0,_MSR(r1) 930 lwz r0,_MSR(r1)
917 mtspr SRR0,r2 931 mtspr SRR0,r2
918 mtspr SRR1,r0 932 mtspr SRR1,r0
919 lwz r0,GPR0(r1) 933 lwz r0,GPR0(r1)
920 lwz r2,GPR2(r1) 934 lwz r2,GPR2(r1)
921 lwz r1,GPR1(r1) 935 lwz r1,GPR1(r1)
922 SYNC 936 SYNC
923 rfi 937 rfi
924 938
925 crit_return: 939 crit_return:
926 mfmsr r28 /* Disable interrupts */ 940 mfmsr r28 /* Disable interrupts */
927 li r4,0 941 li r4,0
928 ori r4,r4,MSR_EE 942 ori r4,r4,MSR_EE
929 andc r28,r28,r4 943 andc r28,r28,r4
930 SYNC /* Some chip revs need this... */ 944 SYNC /* Some chip revs need this... */
931 mtmsr r28 945 mtmsr r28
932 SYNC 946 SYNC
933 lwz r2,_CTR(r1) 947 lwz r2,_CTR(r1)
934 lwz r0,_LINK(r1) 948 lwz r0,_LINK(r1)
935 mtctr r2 949 mtctr r2
936 mtlr r0 950 mtlr r0
937 lwz r2,_XER(r1) 951 lwz r2,_XER(r1)
938 lwz r0,_CCR(r1) 952 lwz r0,_CCR(r1)
939 mtspr XER,r2 953 mtspr XER,r2
940 mtcrf 0xFF,r0 954 mtcrf 0xFF,r0
941 REST_10GPRS(3, r1) 955 REST_10GPRS(3, r1)
942 REST_10GPRS(13, r1) 956 REST_10GPRS(13, r1)
943 REST_8GPRS(23, r1) 957 REST_8GPRS(23, r1)
944 REST_GPR(31, r1) 958 REST_GPR(31, r1)
945 lwz r2,_NIP(r1) /* Restore environment */ 959 lwz r2,_NIP(r1) /* Restore environment */
946 lwz r0,_MSR(r1) 960 lwz r0,_MSR(r1)
947 mtspr 990,r2 /* SRR2 */ 961 mtspr 990,r2 /* SRR2 */
948 mtspr 991,r0 /* SRR3 */ 962 mtspr 991,r0 /* SRR3 */
949 lwz r0,GPR0(r1) 963 lwz r0,GPR0(r1)
950 lwz r2,GPR2(r1) 964 lwz r2,GPR2(r1)
951 lwz r1,GPR1(r1) 965 lwz r1,GPR1(r1)
952 SYNC 966 SYNC
953 rfci 967 rfci
954 968
955 /* Cache functions. 969 /* Cache functions.
956 */ 970 */
957 invalidate_icache: 971 invalidate_icache:
958 iccci r0,r0 /* for 405, iccci invalidates the */ 972 iccci r0,r0 /* for 405, iccci invalidates the */
959 blr /* entire I cache */ 973 blr /* entire I cache */
960 974
961 invalidate_dcache: 975 invalidate_dcache:
962 addi r6,0,0x0000 /* clear GPR 6 */ 976 addi r6,0,0x0000 /* clear GPR 6 */
963 /* Do loop for # of dcache congruence classes. */ 977 /* Do loop for # of dcache congruence classes. */
964 addi r7,r0, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2) 978 addi r7,r0, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
965 /* NOTE: dccci invalidates both */ 979 /* NOTE: dccci invalidates both */
966 mtctr r7 /* ways in the D cache */ 980 mtctr r7 /* ways in the D cache */
967 ..dcloop: 981 ..dcloop:
968 dccci 0,r6 /* invalidate line */ 982 dccci 0,r6 /* invalidate line */
969 addi r6,r6, CFG_CACHELINE_SIZE /* bump to next line */ 983 addi r6,r6, CFG_CACHELINE_SIZE /* bump to next line */
970 bdnz ..dcloop 984 bdnz ..dcloop
971 blr 985 blr
972 986
973 flush_dcache: 987 flush_dcache:
974 addis r9,r0,0x0002 /* set mask for EE and CE msr bits */ 988 addis r9,r0,0x0002 /* set mask for EE and CE msr bits */
975 ori r9,r9,0x8000 989 ori r9,r9,0x8000
976 mfmsr r12 /* save msr */ 990 mfmsr r12 /* save msr */
977 andc r9,r12,r9 991 andc r9,r12,r9
978 mtmsr r9 /* disable EE and CE */ 992 mtmsr r9 /* disable EE and CE */
979 addi r10,r0,0x0001 /* enable data cache for unused memory */ 993 addi r10,r0,0x0001 /* enable data cache for unused memory */
980 mfdccr r9 /* region 0xF8000000-0xFFFFFFFF via */ 994 mfdccr r9 /* region 0xF8000000-0xFFFFFFFF via */
981 or r10,r10,r9 /* bit 31 in dccr */ 995 or r10,r10,r9 /* bit 31 in dccr */
982 mtdccr r10 996 mtdccr r10
983 997
984 /* do loop for # of congruence classes. */ 998 /* do loop for # of congruence classes. */
985 addi r10,r0,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2) 999 addi r10,r0,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
986 addi r11,r0,(CFG_DCACHE_SIZE / 2) /* D cache set size - 2 way sets */ 1000 addi r11,r0,(CFG_DCACHE_SIZE / 2) /* D cache set size - 2 way sets */
987 mtctr r10 1001 mtctr r10
988 addi r10,r0,(0xE000-0x10000) /* start at 0xFFFFE000 */ 1002 addi r10,r0,(0xE000-0x10000) /* start at 0xFFFFE000 */
989 add r11,r10,r11 /* add to get to other side of cache line */ 1003 add r11,r10,r11 /* add to get to other side of cache line */
990 ..flush_dcache_loop: 1004 ..flush_dcache_loop:
991 lwz r3,0(r10) /* least recently used side */ 1005 lwz r3,0(r10) /* least recently used side */
992 lwz r3,0(r11) /* the other side */ 1006 lwz r3,0(r11) /* the other side */
993 dccci r0,r11 /* invalidate both sides */ 1007 dccci r0,r11 /* invalidate both sides */
994 addi r10,r10,CFG_CACHELINE_SIZE /* bump to next line */ 1008 addi r10,r10,CFG_CACHELINE_SIZE /* bump to next line */
995 addi r11,r11,CFG_CACHELINE_SIZE /* bump to next line */ 1009 addi r11,r11,CFG_CACHELINE_SIZE /* bump to next line */
996 bdnz ..flush_dcache_loop 1010 bdnz ..flush_dcache_loop
997 sync /* allow memory access to complete */ 1011 sync /* allow memory access to complete */
998 mtdccr r9 /* restore dccr */ 1012 mtdccr r9 /* restore dccr */
999 mtmsr r12 /* restore msr */ 1013 mtmsr r12 /* restore msr */
1000 blr 1014 blr
1001 1015
1002 .globl icache_enable 1016 .globl icache_enable
1003 icache_enable: 1017 icache_enable:
1004 mflr r8 1018 mflr r8
1005 bl invalidate_icache 1019 bl invalidate_icache
1006 mtlr r8 1020 mtlr r8
1007 isync 1021 isync
1008 addis r3,r0, 0x8000 /* set bit 0 */ 1022 addis r3,r0, 0x8000 /* set bit 0 */
1009 mticcr r3 1023 mticcr r3
1010 blr 1024 blr
1011 1025
1012 .globl icache_disable 1026 .globl icache_disable
1013 icache_disable: 1027 icache_disable:
1014 addis r3,r0, 0x0000 /* clear bit 0 */ 1028 addis r3,r0, 0x0000 /* clear bit 0 */
1015 mticcr r3 1029 mticcr r3
1016 isync 1030 isync
1017 blr 1031 blr
1018 1032
1019 .globl icache_status 1033 .globl icache_status
1020 icache_status: 1034 icache_status:
1021 mficcr r3 1035 mficcr r3
1022 srwi r3, r3, 31 /* >>31 => select bit 0 */ 1036 srwi r3, r3, 31 /* >>31 => select bit 0 */
1023 blr 1037 blr
1024 1038
1025 .globl dcache_enable 1039 .globl dcache_enable
1026 dcache_enable: 1040 dcache_enable:
1027 mflr r8 1041 mflr r8
1028 bl invalidate_dcache 1042 bl invalidate_dcache
1029 mtlr r8 1043 mtlr r8
1030 isync 1044 isync
1031 addis r3,r0, 0x8000 /* set bit 0 */ 1045 addis r3,r0, 0x8000 /* set bit 0 */
1032 mtdccr r3 1046 mtdccr r3
1033 blr 1047 blr
1034 1048
1035 .globl dcache_disable 1049 .globl dcache_disable
1036 dcache_disable: 1050 dcache_disable:
1037 mflr r8 1051 mflr r8
1038 bl flush_dcache 1052 bl flush_dcache
1039 mtlr r8 1053 mtlr r8
1040 addis r3,r0, 0x0000 /* clear bit 0 */ 1054 addis r3,r0, 0x0000 /* clear bit 0 */
1041 mtdccr r3 1055 mtdccr r3
1042 blr 1056 blr
1043 1057
1044 .globl dcache_status 1058 .globl dcache_status
1045 dcache_status: 1059 dcache_status:
1046 mfdccr r3 1060 mfdccr r3
1047 srwi r3, r3, 31 /* >>31 => select bit 0 */ 1061 srwi r3, r3, 31 /* >>31 => select bit 0 */
1048 blr 1062 blr
1049 1063
1050 .globl get_pvr 1064 .globl get_pvr
1051 get_pvr: 1065 get_pvr:
1052 mfspr r3, PVR 1066 mfspr r3, PVR
1053 blr 1067 blr
1054 1068
1055 #if !defined(CONFIG_440) 1069 #if !defined(CONFIG_440)
1056 .globl wr_pit 1070 .globl wr_pit
1057 wr_pit: 1071 wr_pit:
1058 mtspr pit, r3 1072 mtspr pit, r3
1059 blr 1073 blr
1060 #endif 1074 #endif
1061 1075
1062 .globl wr_tcr 1076 .globl wr_tcr
1063 wr_tcr: 1077 wr_tcr:
1064 mtspr tcr, r3 1078 mtspr tcr, r3
1065 blr 1079 blr
1066 1080
1067 /*------------------------------------------------------------------------------- */ 1081 /*------------------------------------------------------------------------------- */
1068 /* Function: in8 */ 1082 /* Function: in8 */
1069 /* Description: Input 8 bits */ 1083 /* Description: Input 8 bits */
1070 /*------------------------------------------------------------------------------- */ 1084 /*------------------------------------------------------------------------------- */
1071 .globl in8 1085 .globl in8
1072 in8: 1086 in8:
1073 lbz r3,0x0000(r3) 1087 lbz r3,0x0000(r3)
1074 blr 1088 blr
1075 1089
1076 /*------------------------------------------------------------------------------- */ 1090 /*------------------------------------------------------------------------------- */
1077 /* Function: out8 */ 1091 /* Function: out8 */
1078 /* Description: Output 8 bits */ 1092 /* Description: Output 8 bits */
1079 /*------------------------------------------------------------------------------- */ 1093 /*------------------------------------------------------------------------------- */
1080 .globl out8 1094 .globl out8
1081 out8: 1095 out8:
1082 stb r4,0x0000(r3) 1096 stb r4,0x0000(r3)
1083 blr 1097 blr
1084 1098
1085 /*------------------------------------------------------------------------------- */ 1099 /*------------------------------------------------------------------------------- */
1086 /* Function: out16 */ 1100 /* Function: out16 */
1087 /* Description: Output 16 bits */ 1101 /* Description: Output 16 bits */
1088 /*------------------------------------------------------------------------------- */ 1102 /*------------------------------------------------------------------------------- */
1089 .globl out16 1103 .globl out16
1090 out16: 1104 out16:
1091 sth r4,0x0000(r3) 1105 sth r4,0x0000(r3)
1092 blr 1106 blr
1093 1107
1094 /*------------------------------------------------------------------------------- */ 1108 /*------------------------------------------------------------------------------- */
1095 /* Function: out16r */ 1109 /* Function: out16r */
1096 /* Description: Byte reverse and output 16 bits */ 1110 /* Description: Byte reverse and output 16 bits */
1097 /*------------------------------------------------------------------------------- */ 1111 /*------------------------------------------------------------------------------- */
1098 .globl out16r 1112 .globl out16r
1099 out16r: 1113 out16r:
1100 sthbrx r4,r0,r3 1114 sthbrx r4,r0,r3
1101 blr 1115 blr
1102 1116
1103 /*------------------------------------------------------------------------------- */ 1117 /*------------------------------------------------------------------------------- */
1104 /* Function: out32 */ 1118 /* Function: out32 */
1105 /* Description: Output 32 bits */ 1119 /* Description: Output 32 bits */
1106 /*------------------------------------------------------------------------------- */ 1120 /*------------------------------------------------------------------------------- */
1107 .globl out32 1121 .globl out32
1108 out32: 1122 out32:
1109 stw r4,0x0000(r3) 1123 stw r4,0x0000(r3)
1110 blr 1124 blr
1111 1125
1112 /*------------------------------------------------------------------------------- */ 1126 /*------------------------------------------------------------------------------- */
1113 /* Function: out32r */ 1127 /* Function: out32r */
1114 /* Description: Byte reverse and output 32 bits */ 1128 /* Description: Byte reverse and output 32 bits */
1115 /*------------------------------------------------------------------------------- */ 1129 /*------------------------------------------------------------------------------- */
1116 .globl out32r 1130 .globl out32r
1117 out32r: 1131 out32r:
1118 stwbrx r4,r0,r3 1132 stwbrx r4,r0,r3
1119 blr 1133 blr
1120 1134
1121 /*------------------------------------------------------------------------------- */ 1135 /*------------------------------------------------------------------------------- */
1122 /* Function: in16 */ 1136 /* Function: in16 */
1123 /* Description: Input 16 bits */ 1137 /* Description: Input 16 bits */
1124 /*------------------------------------------------------------------------------- */ 1138 /*------------------------------------------------------------------------------- */
1125 .globl in16 1139 .globl in16
1126 in16: 1140 in16:
1127 lhz r3,0x0000(r3) 1141 lhz r3,0x0000(r3)
1128 blr 1142 blr
1129 1143
1130 /*------------------------------------------------------------------------------- */ 1144 /*------------------------------------------------------------------------------- */
1131 /* Function: in16r */ 1145 /* Function: in16r */
1132 /* Description: Input 16 bits and byte reverse */ 1146 /* Description: Input 16 bits and byte reverse */
1133 /*------------------------------------------------------------------------------- */ 1147 /*------------------------------------------------------------------------------- */
1134 .globl in16r 1148 .globl in16r
1135 in16r: 1149 in16r:
1136 lhbrx r3,r0,r3 1150 lhbrx r3,r0,r3
1137 blr 1151 blr
1138 1152
1139 /*------------------------------------------------------------------------------- */ 1153 /*------------------------------------------------------------------------------- */
1140 /* Function: in32 */ 1154 /* Function: in32 */
1141 /* Description: Input 32 bits */ 1155 /* Description: Input 32 bits */
1142 /*------------------------------------------------------------------------------- */ 1156 /*------------------------------------------------------------------------------- */
1143 .globl in32 1157 .globl in32
1144 in32: 1158 in32:
1145 lwz 3,0x0000(3) 1159 lwz 3,0x0000(3)
1146 blr 1160 blr
1147 1161
1148 /*------------------------------------------------------------------------------- */ 1162 /*------------------------------------------------------------------------------- */
1149 /* Function: in32r */ 1163 /* Function: in32r */
1150 /* Description: Input 32 bits and byte reverse */ 1164 /* Description: Input 32 bits and byte reverse */
1151 /*------------------------------------------------------------------------------- */ 1165 /*------------------------------------------------------------------------------- */
1152 .globl in32r 1166 .globl in32r
1153 in32r: 1167 in32r:
1154 lwbrx r3,r0,r3 1168 lwbrx r3,r0,r3
1155 blr 1169 blr
1156 1170
1157 /*------------------------------------------------------------------------------- */ 1171 /*------------------------------------------------------------------------------- */
1158 /* Function: ppcDcbf */ 1172 /* Function: ppcDcbf */
1159 /* Description: Data Cache block flush */ 1173 /* Description: Data Cache block flush */
1160 /* Input: r3 = effective address */ 1174 /* Input: r3 = effective address */
1161 /* Output: none. */ 1175 /* Output: none. */
1162 /*------------------------------------------------------------------------------- */ 1176 /*------------------------------------------------------------------------------- */
1163 .globl ppcDcbf 1177 .globl ppcDcbf
1164 ppcDcbf: 1178 ppcDcbf:
1165 dcbf r0,r3 1179 dcbf r0,r3
1166 blr 1180 blr
1167 1181
1168 /*------------------------------------------------------------------------------- */ 1182 /*------------------------------------------------------------------------------- */
1169 /* Function: ppcDcbi */ 1183 /* Function: ppcDcbi */
1170 /* Description: Data Cache block Invalidate */ 1184 /* Description: Data Cache block Invalidate */
1171 /* Input: r3 = effective address */ 1185 /* Input: r3 = effective address */
1172 /* Output: none. */ 1186 /* Output: none. */
1173 /*------------------------------------------------------------------------------- */ 1187 /*------------------------------------------------------------------------------- */
1174 .globl ppcDcbi 1188 .globl ppcDcbi
1175 ppcDcbi: 1189 ppcDcbi:
1176 dcbi r0,r3 1190 dcbi r0,r3
1177 blr 1191 blr
1178 1192
1179 /*------------------------------------------------------------------------------- */ 1193 /*------------------------------------------------------------------------------- */
1180 /* Function: ppcSync */ 1194 /* Function: ppcSync */
1181 /* Description: Processor Synchronize */ 1195 /* Description: Processor Synchronize */
1182 /* Input: none. */ 1196 /* Input: none. */
1183 /* Output: none. */ 1197 /* Output: none. */
1184 /*------------------------------------------------------------------------------- */ 1198 /*------------------------------------------------------------------------------- */
1185 .globl ppcSync 1199 .globl ppcSync
1186 ppcSync: 1200 ppcSync:
1187 sync 1201 sync
1188 blr 1202 blr
1189 1203
1190 /*------------------------------------------------------------------------------*/ 1204 /*------------------------------------------------------------------------------*/
1191 1205
1192 /* 1206 /*
1193 * void relocate_code (addr_sp, gd, addr_moni) 1207 * void relocate_code (addr_sp, gd, addr_moni)
1194 * 1208 *
1195 * This "function" does not return, instead it continues in RAM 1209 * This "function" does not return, instead it continues in RAM
1196 * after relocating the monitor code. 1210 * after relocating the monitor code.
1197 * 1211 *
1198 * r3 = dest 1212 * r3 = dest
1199 * r4 = src 1213 * r4 = src
1200 * r5 = length in bytes 1214 * r5 = length in bytes
1201 * r6 = cachelinesize 1215 * r6 = cachelinesize
1202 */ 1216 */
1203 .globl relocate_code 1217 .globl relocate_code
1204 relocate_code: 1218 relocate_code:
1205 mr r1, r3 /* Set new stack pointer */ 1219 mr r1, r3 /* Set new stack pointer */
1206 mr r9, r4 /* Save copy of Init Data pointer */ 1220 mr r9, r4 /* Save copy of Init Data pointer */
1207 mr r10, r5 /* Save copy of Destination Address */ 1221 mr r10, r5 /* Save copy of Destination Address */
1208 1222
1209 mr r3, r5 /* Destination Address */ 1223 mr r3, r5 /* Destination Address */
1210 lis r4, CFG_MONITOR_BASE@h /* Source Address */ 1224 lis r4, CFG_MONITOR_BASE@h /* Source Address */
1211 ori r4, r4, CFG_MONITOR_BASE@l 1225 ori r4, r4, CFG_MONITOR_BASE@l
1212 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */ 1226 lis r5, CFG_MONITOR_LEN@h /* Length in Bytes */
1213 ori r5, r5, CFG_MONITOR_LEN@l 1227 ori r5, r5, CFG_MONITOR_LEN@l
1214 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */ 1228 li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
1215 1229
1216 /* 1230 /*
1217 * Fix GOT pointer: 1231 * Fix GOT pointer:
1218 * 1232 *
1219 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address 1233 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
1220 * 1234 *
1221 * Offset: 1235 * Offset:
1222 */ 1236 */
1223 sub r15, r10, r4 1237 sub r15, r10, r4
1224 1238
1225 /* First our own GOT */ 1239 /* First our own GOT */
1226 add r14, r14, r15 1240 add r14, r14, r15
1227 /* the the one used by the C code */ 1241 /* the the one used by the C code */
1228 add r30, r30, r15 1242 add r30, r30, r15
1229 1243
1230 /* 1244 /*
1231 * Now relocate code 1245 * Now relocate code
1232 */ 1246 */
1233 1247
1234 cmplw cr1,r3,r4 1248 cmplw cr1,r3,r4
1235 addi r0,r5,3 1249 addi r0,r5,3
1236 srwi. r0,r0,2 1250 srwi. r0,r0,2
1237 beq cr1,4f /* In place copy is not necessary */ 1251 beq cr1,4f /* In place copy is not necessary */
1238 beq 7f /* Protect against 0 count */ 1252 beq 7f /* Protect against 0 count */
1239 mtctr r0 1253 mtctr r0
1240 bge cr1,2f 1254 bge cr1,2f
1241 1255
1242 la r8,-4(r4) 1256 la r8,-4(r4)
1243 la r7,-4(r3) 1257 la r7,-4(r3)
1244 1: lwzu r0,4(r8) 1258 1: lwzu r0,4(r8)
1245 stwu r0,4(r7) 1259 stwu r0,4(r7)
1246 bdnz 1b 1260 bdnz 1b
1247 b 4f 1261 b 4f
1248 1262
1249 2: slwi r0,r0,2 1263 2: slwi r0,r0,2
1250 add r8,r4,r0 1264 add r8,r4,r0
1251 add r7,r3,r0 1265 add r7,r3,r0
1252 3: lwzu r0,-4(r8) 1266 3: lwzu r0,-4(r8)
1253 stwu r0,-4(r7) 1267 stwu r0,-4(r7)
1254 bdnz 3b 1268 bdnz 3b
1255 1269
1256 /* 1270 /*
1257 * Now flush the cache: note that we must start from a cache aligned 1271 * Now flush the cache: note that we must start from a cache aligned
1258 * address. Otherwise we might miss one cache line. 1272 * address. Otherwise we might miss one cache line.
1259 */ 1273 */
1260 4: cmpwi r6,0 1274 4: cmpwi r6,0
1261 add r5,r3,r5 1275 add r5,r3,r5
1262 beq 7f /* Always flush prefetch queue in any case */ 1276 beq 7f /* Always flush prefetch queue in any case */
1263 subi r0,r6,1 1277 subi r0,r6,1
1264 andc r3,r3,r0 1278 andc r3,r3,r0
1265 mr r4,r3 1279 mr r4,r3
1266 5: dcbst 0,r4 1280 5: dcbst 0,r4
1267 add r4,r4,r6 1281 add r4,r4,r6
1268 cmplw r4,r5 1282 cmplw r4,r5
1269 blt 5b 1283 blt 5b
1270 sync /* Wait for all dcbst to complete on bus */ 1284 sync /* Wait for all dcbst to complete on bus */
1271 mr r4,r3 1285 mr r4,r3
1272 6: icbi 0,r4 1286 6: icbi 0,r4
1273 add r4,r4,r6 1287 add r4,r4,r6
1274 cmplw r4,r5 1288 cmplw r4,r5
1275 blt 6b 1289 blt 6b
1276 7: sync /* Wait for all icbi to complete on bus */ 1290 7: sync /* Wait for all icbi to complete on bus */
1277 isync 1291 isync
1278 1292
1279 /* 1293 /*
1280 * We are done. Do not return, instead branch to second part of board 1294 * We are done. Do not return, instead branch to second part of board
1281 * initialization, now running from RAM. 1295 * initialization, now running from RAM.
1282 */ 1296 */
1283 1297
1284 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET 1298 addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
1285 mtlr r0 1299 mtlr r0
1286 blr /* NEVER RETURNS! */ 1300 blr /* NEVER RETURNS! */
1287 1301
1288 in_ram: 1302 in_ram:
1289 1303
1290 /* 1304 /*
1291 * Relocation Function, r14 point to got2+0x8000 1305 * Relocation Function, r14 point to got2+0x8000
1292 * 1306 *
1293 * Adjust got2 pointers, no need to check for 0, this code 1307 * Adjust got2 pointers, no need to check for 0, this code
1294 * already puts a few entries in the table. 1308 * already puts a few entries in the table.
1295 */ 1309 */
1296 li r0,__got2_entries@sectoff@l 1310 li r0,__got2_entries@sectoff@l
1297 la r3,GOT(_GOT2_TABLE_) 1311 la r3,GOT(_GOT2_TABLE_)
1298 lwz r11,GOT(_GOT2_TABLE_) 1312 lwz r11,GOT(_GOT2_TABLE_)
1299 mtctr r0 1313 mtctr r0
1300 sub r11,r3,r11 1314 sub r11,r3,r11
1301 addi r3,r3,-4 1315 addi r3,r3,-4
1302 1: lwzu r0,4(r3) 1316 1: lwzu r0,4(r3)
1303 add r0,r0,r11 1317 add r0,r0,r11
1304 stw r0,0(r3) 1318 stw r0,0(r3)
1305 bdnz 1b 1319 bdnz 1b
1306 1320
1307 /* 1321 /*
1308 * Now adjust the fixups and the pointers to the fixups 1322 * Now adjust the fixups and the pointers to the fixups
1309 * in case we need to move ourselves again. 1323 * in case we need to move ourselves again.
1310 */ 1324 */
1311 2: li r0,__fixup_entries@sectoff@l 1325 2: li r0,__fixup_entries@sectoff@l
1312 lwz r3,GOT(_FIXUP_TABLE_) 1326 lwz r3,GOT(_FIXUP_TABLE_)
1313 cmpwi r0,0 1327 cmpwi r0,0
1314 mtctr r0 1328 mtctr r0
1315 addi r3,r3,-4 1329 addi r3,r3,-4
1316 beq 4f 1330 beq 4f
1317 3: lwzu r4,4(r3) 1331 3: lwzu r4,4(r3)
1318 lwzux r0,r4,r11 1332 lwzux r0,r4,r11
1319 add r0,r0,r11 1333 add r0,r0,r11
1320 stw r10,0(r3) 1334 stw r10,0(r3)
1321 stw r0,0(r4) 1335 stw r0,0(r4)
1322 bdnz 3b 1336 bdnz 3b
1323 4: 1337 4:
1324 clear_bss: 1338 clear_bss:
1325 /* 1339 /*
1326 * Now clear BSS segment 1340 * Now clear BSS segment
1327 */ 1341 */
1328 lwz r3,GOT(.bss) 1342 lwz r3,GOT(.bss)
1329 lwz r4,GOT(_end) 1343 lwz r4,GOT(_end)
1330 1344
1331 cmplw 0, r3, r4 1345 cmplw 0, r3, r4
1332 beq 6f 1346 beq 6f
1333 1347
1334 li r0, 0 1348 li r0, 0
1335 5: 1349 5:
1336 stw r0, 0(r3) 1350 stw r0, 0(r3)
1337 addi r3, r3, 4 1351 addi r3, r3, 4
1338 cmplw 0, r3, r4 1352 cmplw 0, r3, r4
1339 bne 5b 1353 bne 5b
1340 6: 1354 6:
1341 1355
1342 mr r3, r9 /* Init Data pointer */ 1356 mr r3, r9 /* Init Data pointer */
1343 mr r4, r10 /* Destination Address */ 1357 mr r4, r10 /* Destination Address */
1344 bl board_init_r 1358 bl board_init_r
1345 1359
1346 /* Problems accessing "end" in C, so do it here */ 1360 /* Problems accessing "end" in C, so do it here */
1347 .globl get_endaddr 1361 .globl get_endaddr
1348 get_endaddr: 1362 get_endaddr:
1349 lwz r3,GOT(_end) 1363 lwz r3,GOT(_end)
1350 blr 1364 blr
1351 1365
1352 /* 1366 /*
1353 * Copy exception vector code to low memory 1367 * Copy exception vector code to low memory
1354 * 1368 *
1355 * r3: dest_addr 1369 * r3: dest_addr
1356 * r7: source address, r8: end address, r9: target address 1370 * r7: source address, r8: end address, r9: target address
1357 */ 1371 */
1358 .globl trap_init 1372 .globl trap_init
1359 trap_init: 1373 trap_init:
1360 lwz r7, GOT(_start) 1374 lwz r7, GOT(_start)
1361 lwz r8, GOT(_end_of_vectors) 1375 lwz r8, GOT(_end_of_vectors)
1362 1376
1363 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */ 1377 rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
1364 1378
1365 cmplw 0, r7, r8 1379 cmplw 0, r7, r8
1366 bgelr /* return if r7>=r8 - just in case */ 1380 bgelr /* return if r7>=r8 - just in case */
1367 1381
1368 mflr r4 /* save link register */ 1382 mflr r4 /* save link register */
1369 1: 1383 1:
1370 lwz r0, 0(r7) 1384 lwz r0, 0(r7)
1371 stw r0, 0(r9) 1385 stw r0, 0(r9)
1372 addi r7, r7, 4 1386 addi r7, r7, 4
1373 addi r9, r9, 4 1387 addi r9, r9, 4
1374 cmplw 0, r7, r8 1388 cmplw 0, r7, r8
1375 bne 1b 1389 bne 1b
1376 1390
1377 /* 1391 /*
1378 * relocate `hdlr' and `int_return' entries 1392 * relocate `hdlr' and `int_return' entries
1379 */ 1393 */
1380 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET 1394 li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
1381 li r8, Alignment - _start + EXC_OFF_SYS_RESET 1395 li r8, Alignment - _start + EXC_OFF_SYS_RESET
1382 2: 1396 2:
1383 bl trap_reloc 1397 bl trap_reloc
1384 addi r7, r7, 0x100 /* next exception vector */ 1398 addi r7, r7, 0x100 /* next exception vector */
1385 cmplw 0, r7, r8 1399 cmplw 0, r7, r8
1386 blt 2b 1400 blt 2b
1387 1401
1388 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET 1402 li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
1389 bl trap_reloc 1403 bl trap_reloc
1390 1404
1391 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET 1405 li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
1392 bl trap_reloc 1406 bl trap_reloc
1393 1407
1394 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET 1408 li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
1395 li r8, SystemCall - _start + EXC_OFF_SYS_RESET 1409 li r8, SystemCall - _start + EXC_OFF_SYS_RESET
1396 3: 1410 3:
1397 bl trap_reloc 1411 bl trap_reloc
1398 addi r7, r7, 0x100 /* next exception vector */ 1412 addi r7, r7, 0x100 /* next exception vector */
1399 cmplw 0, r7, r8 1413 cmplw 0, r7, r8
1400 blt 3b 1414 blt 3b
1401 1415
1402 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET 1416 li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
1403 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET 1417 li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
1404 4: 1418 4:
1405 bl trap_reloc 1419 bl trap_reloc
1406 addi r7, r7, 0x100 /* next exception vector */ 1420 addi r7, r7, 0x100 /* next exception vector */
1407 cmplw 0, r7, r8 1421 cmplw 0, r7, r8
1408 blt 4b 1422 blt 4b
1409 1423
1410 mtlr r4 /* restore link register */ 1424 mtlr r4 /* restore link register */
1411 blr 1425 blr
1412 1426
1413 /* 1427 /*
1414 * Function: relocate entries for one exception vector 1428 * Function: relocate entries for one exception vector
1415 */ 1429 */
1416 trap_reloc: 1430 trap_reloc:
1417 lwz r0, 0(r7) /* hdlr ... */ 1431 lwz r0, 0(r7) /* hdlr ... */
1418 add r0, r0, r3 /* ... += dest_addr */ 1432 add r0, r0, r3 /* ... += dest_addr */
1419 stw r0, 0(r7) 1433 stw r0, 0(r7)
1420 1434
1421 lwz r0, 4(r7) /* int_return ... */ 1435 lwz r0, 4(r7) /* int_return ... */
1422 add r0, r0, r3 /* ... += dest_addr */ 1436 add r0, r0, r3 /* ... += dest_addr */
1423 stw r0, 4(r7) 1437 stw r0, 4(r7)
1424 1438
1425 blr 1439 blr
1426 1440
1 /* 1 /*
2 * (C) Copyright 2000 2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 #include <common.h> 24 #include <common.h>
25 #include <commproc.h> 25 #include <commproc.h>
26 #include <mpc8xx_irq.h> 26 #include <mpc8xx_irq.h>
27 #include <syscall.h> 27 #include <syscall.h>
28 28
29 #undef DEBUG 29 #undef DEBUG
30 30
31 #define TIMER_PERIOD 1000000 /* 1 second clock */ 31 #define TIMER_PERIOD 1000000 /* 1 second clock */
32 32
33 static void timer_handler (void *arg); 33 static void timer_handler (void *arg);
34 34
35 35
36 /* Access functions for the Machine State Register */ 36 /* Access functions for the Machine State Register */
37 static __inline__ unsigned long get_msr(void) 37 static __inline__ unsigned long get_msr(void)
38 { 38 {
39 unsigned long msr; 39 unsigned long msr;
40 40
41 asm volatile("mfmsr %0" : "=r" (msr) :); 41 asm volatile("mfmsr %0" : "=r" (msr) :);
42 return msr; 42 return msr;
43 } 43 }
44 44
45 static __inline__ void set_msr(unsigned long msr) 45 static __inline__ void set_msr(unsigned long msr)
46 { 46 {
47 asm volatile("mtmsr %0" : : "r" (msr)); 47 asm volatile("mtmsr %0" : : "r" (msr));
48 } 48 }
49 49
50 /* 50 /*
51 * Definitions to access the CPM Timer registers 51 * Definitions to access the CPM Timer registers
52 * See 8xx_immap.h for Internal Memory Map layout, 52 * See 8xx_immap.h for Internal Memory Map layout,
53 * and commproc.h for CPM Interrupt vectors (aka "IRQ"s) 53 * and commproc.h for CPM Interrupt vectors (aka "IRQ"s)
54 */ 54 */
55 55
56 typedef struct tid_8xx_cpmtimer_s { 56 typedef struct tid_8xx_cpmtimer_s {
57 int cpm_vec; /* CPM Interrupt Vector for this timer */ 57 int cpm_vec; /* CPM Interrupt Vector for this timer */
58 ushort *tgcrp; /* Pointer to Timer Global Config Reg. */ 58 ushort *tgcrp; /* Pointer to Timer Global Config Reg. */
59 ushort *tmrp; /* Pointer to Timer Mode Register */ 59 ushort *tmrp; /* Pointer to Timer Mode Register */
60 ushort *trrp; /* Pointer to Timer Reference Register */ 60 ushort *trrp; /* Pointer to Timer Reference Register */
61 ushort *tcrp; /* Pointer to Timer Capture Register */ 61 ushort *tcrp; /* Pointer to Timer Capture Register */
62 ushort *tcnp; /* Pointer to Timer Counter Register */ 62 ushort *tcnp; /* Pointer to Timer Counter Register */
63 ushort *terp; /* Pointer to Timer Event Register */ 63 ushort *terp; /* Pointer to Timer Event Register */
64 } tid_8xx_cpmtimer_t; 64 } tid_8xx_cpmtimer_t;
65 65
66 #ifndef CLOCKRATE 66 #ifndef CLOCKRATE
67 # define CLOCKRATE 64 67 # define CLOCKRATE 64
68 #endif 68 #endif
69 69
70 #define CPMT_CLOCK_DIV 16 70 #define CPMT_CLOCK_DIV 16
71 #define CPMT_MAX_PRESCALER 256 71 #define CPMT_MAX_PRESCALER 256
72 #define CPMT_MAX_REFERENCE 65535 /* max. unsigned short */ 72 #define CPMT_MAX_REFERENCE 65535 /* max. unsigned short */
73 73
74 #define CPMT_MAX_TICKS (CPMT_MAX_REFERENCE * CPMT_MAX_PRESCALER) 74 #define CPMT_MAX_TICKS (CPMT_MAX_REFERENCE * CPMT_MAX_PRESCALER)
75 #define CPMT_MAX_TICKS_WITH_DIV (CPMT_MAX_REFERENCE * CPMT_MAX_PRESCALER * CPMT_CLOCK_DIV) 75 #define CPMT_MAX_TICKS_WITH_DIV (CPMT_MAX_REFERENCE * CPMT_MAX_PRESCALER * CPMT_CLOCK_DIV)
76 #define CPMT_MAX_INTERVAL (CPMT_MAX_TICKS_WITH_DIV / CLOCKRATE) 76 #define CPMT_MAX_INTERVAL (CPMT_MAX_TICKS_WITH_DIV / CLOCKRATE)
77 77
78 /* For now: always use max. prescaler value */ 78 /* For now: always use max. prescaler value */
79 #define CPMT_PRESCALER (CPMT_MAX_PRESCALER) 79 #define CPMT_PRESCALER (CPMT_MAX_PRESCALER)
80 80
81 /* CPM Timer Event Register Bits */ 81 /* CPM Timer Event Register Bits */
82 #define CPMT_EVENT_CAP 0x0001 /* Capture Event */ 82 #define CPMT_EVENT_CAP 0x0001 /* Capture Event */
83 #define CPMT_EVENT_REF 0x0002 /* Reference Counter Event */ 83 #define CPMT_EVENT_REF 0x0002 /* Reference Counter Event */
84 84
85 /* CPM Timer Global Config Register */ 85 /* CPM Timer Global Config Register */
86 #define CPMT_GCR_RST 0x0001 /* Reset Timer */ 86 #define CPMT_GCR_RST 0x0001 /* Reset Timer */
87 #define CPMT_GCR_STP 0x0002 /* Stop Timer */ 87 #define CPMT_GCR_STP 0x0002 /* Stop Timer */
88 #define CPMT_GCR_FRZ 0x0004 /* Freeze Timer */ 88 #define CPMT_GCR_FRZ 0x0004 /* Freeze Timer */
89 #define CPMT_GCR_GM_CAS 0x0008 /* Gate Mode / Cascade Timers */ 89 #define CPMT_GCR_GM_CAS 0x0008 /* Gate Mode / Cascade Timers */
90 #define CPMT_GCR_MASK (CPMT_GCR_RST|CPMT_GCR_STP|CPMT_GCR_FRZ|CPMT_GCR_GM_CAS) 90 #define CPMT_GCR_MASK (CPMT_GCR_RST|CPMT_GCR_STP|CPMT_GCR_FRZ|CPMT_GCR_GM_CAS)
91 91
92 /* CPM Timer Mode register */ 92 /* CPM Timer Mode register */
93 #define CPMT_MR_GE 0x0001 /* Gate Enable */ 93 #define CPMT_MR_GE 0x0001 /* Gate Enable */
94 #define CPMT_MR_ICLK_CASC 0x0000 /* Clock internally cascaded */ 94 #define CPMT_MR_ICLK_CASC 0x0000 /* Clock internally cascaded */
95 #define CPMT_MR_ICLK_CLK 0x0002 /* Clock = system clock */ 95 #define CPMT_MR_ICLK_CLK 0x0002 /* Clock = system clock */
96 #define CPMT_MR_ICLK_CLKDIV 0x0004 /* Clock = system clock / 16 */ 96 #define CPMT_MR_ICLK_CLKDIV 0x0004 /* Clock = system clock / 16 */
97 #define CPMT_MR_ICLK_TIN 0x0006 /* Clock = TINx signal */ 97 #define CPMT_MR_ICLK_TIN 0x0006 /* Clock = TINx signal */
98 #define CPMT_MR_FRR 0x0008 /* Free Run / Restart */ 98 #define CPMT_MR_FRR 0x0008 /* Free Run / Restart */
99 #define CPMT_MR_ORI 0x0010 /* Out. Reference Interrupt En. */ 99 #define CPMT_MR_ORI 0x0010 /* Out. Reference Interrupt En. */
100 #define CPMT_MR_OM 0x0020 /* Output Mode */ 100 #define CPMT_MR_OM 0x0020 /* Output Mode */
101 #define CPMT_MR_CE_DIS 0x0000 /* Capture/Interrupt disabled */ 101 #define CPMT_MR_CE_DIS 0x0000 /* Capture/Interrupt disabled */
102 #define CPMT_MR_CE_RISE 0x0040 /* Capt./Interr. on rising TIN */ 102 #define CPMT_MR_CE_RISE 0x0040 /* Capt./Interr. on rising TIN */
103 #define CPMT_MR_CE_FALL 0x0080 /* Capt./Interr. on falling TIN */ 103 #define CPMT_MR_CE_FALL 0x0080 /* Capt./Interr. on falling TIN */
104 #define CPMT_MR_CE_ANY 0x00C0 /* Capt./Interr. on any TIN edge*/ 104 #define CPMT_MR_CE_ANY 0x00C0 /* Capt./Interr. on any TIN edge*/
105 105
106 106
107 107
108 /* 108 /*
109 * which CPM timer to use - index starts at 0 (= timer 1) 109 * which CPM timer to use - index starts at 0 (= timer 1)
110 */ 110 */
111 #define TID_TIMER_ID 0 /* use CPM timer 1 */ 111 #define TID_TIMER_ID 0 /* use CPM timer 1 */
112 112
113 void setPeriod (tid_8xx_cpmtimer_t *hwp, ulong interval); 113 void setPeriod (tid_8xx_cpmtimer_t *hwp, ulong interval);
114 114
115 static char *usage = "\n[q, b, e, ?] "; 115 static char *usage = "\n[q, b, e, ?] ";
116 116
117 int timer (int argc, char *argv[]) 117 int timer (int argc, char *argv[])
118 { 118 {
119 DECLARE_GLOBAL_DATA_PTR; 119 DECLARE_GLOBAL_DATA_PTR;
120 120
121 cpmtimer8xx_t *cpmtimerp; /* Pointer to the CPM Timer structure */ 121 cpmtimer8xx_t *cpmtimerp; /* Pointer to the CPM Timer structure */
122 tid_8xx_cpmtimer_t hw; 122 tid_8xx_cpmtimer_t hw;
123 tid_8xx_cpmtimer_t *hwp = &hw; 123 tid_8xx_cpmtimer_t *hwp = &hw;
124 int c; 124 int c;
125 int running;
125 126
126 /* Pointer to CPM Timer structure */ 127 /* Pointer to CPM Timer structure */
127 cpmtimerp = &((immap_t *) gd->bd->bi_immr_base)->im_cpmtimer; 128 cpmtimerp = &((immap_t *) gd->bd->bi_immr_base)->im_cpmtimer;
128 129
129 mon_printf ("TIMERS=0x%x\n", (unsigned) cpmtimerp); 130 mon_printf ("TIMERS=0x%x\n", (unsigned) cpmtimerp);
130 131
131 /* Initialize pointers depending on which timer we use */ 132 /* Initialize pointers depending on which timer we use */
132 switch (TID_TIMER_ID) { 133 switch (TID_TIMER_ID) {
133 case 0: 134 case 0:
134 hwp->tmrp = &(cpmtimerp->cpmt_tmr1); 135 hwp->tmrp = &(cpmtimerp->cpmt_tmr1);
135 hwp->trrp = &(cpmtimerp->cpmt_trr1); 136 hwp->trrp = &(cpmtimerp->cpmt_trr1);
136 hwp->tcrp = &(cpmtimerp->cpmt_tcr1); 137 hwp->tcrp = &(cpmtimerp->cpmt_tcr1);
137 hwp->tcnp = &(cpmtimerp->cpmt_tcn1); 138 hwp->tcnp = &(cpmtimerp->cpmt_tcn1);
138 hwp->terp = &(cpmtimerp->cpmt_ter1); 139 hwp->terp = &(cpmtimerp->cpmt_ter1);
139 hwp->cpm_vec = CPMVEC_TIMER1; 140 hwp->cpm_vec = CPMVEC_TIMER1;
140 break; 141 break;
141 case 1: 142 case 1:
142 hwp->tmrp = &(cpmtimerp->cpmt_tmr2); 143 hwp->tmrp = &(cpmtimerp->cpmt_tmr2);
143 hwp->trrp = &(cpmtimerp->cpmt_trr2); 144 hwp->trrp = &(cpmtimerp->cpmt_trr2);
144 hwp->tcrp = &(cpmtimerp->cpmt_tcr2); 145 hwp->tcrp = &(cpmtimerp->cpmt_tcr2);
145 hwp->tcnp = &(cpmtimerp->cpmt_tcn2); 146 hwp->tcnp = &(cpmtimerp->cpmt_tcn2);
146 hwp->terp = &(cpmtimerp->cpmt_ter2); 147 hwp->terp = &(cpmtimerp->cpmt_ter2);
147 hwp->cpm_vec = CPMVEC_TIMER2; 148 hwp->cpm_vec = CPMVEC_TIMER2;
148 break; 149 break;
149 case 2: 150 case 2:
150 hwp->tmrp = &(cpmtimerp->cpmt_tmr3); 151 hwp->tmrp = &(cpmtimerp->cpmt_tmr3);
151 hwp->trrp = &(cpmtimerp->cpmt_trr3); 152 hwp->trrp = &(cpmtimerp->cpmt_trr3);
152 hwp->tcrp = &(cpmtimerp->cpmt_tcr3); 153 hwp->tcrp = &(cpmtimerp->cpmt_tcr3);
153 hwp->tcnp = &(cpmtimerp->cpmt_tcn3); 154 hwp->tcnp = &(cpmtimerp->cpmt_tcn3);
154 hwp->terp = &(cpmtimerp->cpmt_ter3); 155 hwp->terp = &(cpmtimerp->cpmt_ter3);
155 hwp->cpm_vec = CPMVEC_TIMER3; 156 hwp->cpm_vec = CPMVEC_TIMER3;
156 break; 157 break;
157 case 3: 158 case 3:
158 hwp->tmrp = &(cpmtimerp->cpmt_tmr4); 159 hwp->tmrp = &(cpmtimerp->cpmt_tmr4);
159 hwp->trrp = &(cpmtimerp->cpmt_trr4); 160 hwp->trrp = &(cpmtimerp->cpmt_trr4);
160 hwp->tcrp = &(cpmtimerp->cpmt_tcr4); 161 hwp->tcrp = &(cpmtimerp->cpmt_tcr4);
161 hwp->tcnp = &(cpmtimerp->cpmt_tcn4); 162 hwp->tcnp = &(cpmtimerp->cpmt_tcn4);
162 hwp->terp = &(cpmtimerp->cpmt_ter4); 163 hwp->terp = &(cpmtimerp->cpmt_ter4);
163 hwp->cpm_vec = CPMVEC_TIMER4; 164 hwp->cpm_vec = CPMVEC_TIMER4;
164 break; 165 break;
165 } 166 }
166 167
167 hwp->tgcrp = &cpmtimerp->cpmt_tgcr; 168 hwp->tgcrp = &cpmtimerp->cpmt_tgcr;
168 169
169 mon_printf ("Using timer %d\n" 170 mon_printf ("Using timer %d\n"
170 "tgcr @ 0x%x, tmr @ 0x%x, trr @ 0x%x," 171 "tgcr @ 0x%x, tmr @ 0x%x, trr @ 0x%x,"
171 " tcr @ 0x%x, tcn @ 0x%x, ter @ 0x%x\n", 172 " tcr @ 0x%x, tcn @ 0x%x, ter @ 0x%x\n",
172 TID_TIMER_ID + 1, 173 TID_TIMER_ID + 1,
173 (unsigned) hwp->tgcrp, 174 (unsigned) hwp->tgcrp,
174 (unsigned) hwp->tmrp, 175 (unsigned) hwp->tmrp,
175 (unsigned) hwp->trrp, 176 (unsigned) hwp->trrp,
176 (unsigned) hwp->tcrp, 177 (unsigned) hwp->tcrp,
177 (unsigned) hwp->tcnp, 178 (unsigned) hwp->tcnp,
178 (unsigned) hwp->terp 179 (unsigned) hwp->terp
179 ); 180 );
180 181
181 /* reset timer */ 182 /* reset timer */
182 *hwp->tgcrp &= ~(CPMT_GCR_MASK << TID_TIMER_ID); 183 *hwp->tgcrp &= ~(CPMT_GCR_MASK << TID_TIMER_ID);
183 184
184 /* clear all events */ 185 /* clear all events */
185 *hwp->terp = (CPMT_EVENT_CAP | CPMT_EVENT_REF); 186 *hwp->terp = (CPMT_EVENT_CAP | CPMT_EVENT_REF);
186 187
187 mon_printf (usage); 188 mon_printf (usage);
189 running = 0;
188 while ((c = mon_getc()) != 'q') { 190 while ((c = mon_getc()) != 'q') {
189 if (c == 'b') { 191 if (c == 'b') {
190 192
191 setPeriod (hwp, TIMER_PERIOD); /* Set period and start ticking */ 193 setPeriod (hwp, TIMER_PERIOD); /* Set period and start ticking */
192 194
193 /* Install interrupt handler (enable timer in CIMR) */ 195 /* Install interrupt handler (enable timer in CIMR) */
194 mon_install_hdlr (hwp->cpm_vec, timer_handler, hwp); 196 mon_install_hdlr (hwp->cpm_vec, timer_handler, hwp);
195 197
196 mon_printf ("Enabling timer\n"); 198 mon_printf ("Enabling timer\n");
197 199
198 /* enable timer */ 200 /* enable timer */
199 *hwp->tgcrp |= (CPMT_GCR_RST << TID_TIMER_ID); 201 *hwp->tgcrp |= (CPMT_GCR_RST << TID_TIMER_ID);
202 running = 1;
200 203
201 #ifdef DEBUG 204 #ifdef DEBUG
202 mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x," 205 mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x,"
203 " tcr=0x%x, tcn=0x%x, ter=0x%x\n", 206 " tcr=0x%x, tcn=0x%x, ter=0x%x\n",
204 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp, 207 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp,
205 *hwp->tcrp, *hwp->tcnp, *hwp->terp 208 *hwp->tcrp, *hwp->tcnp, *hwp->terp
206 ); 209 );
207 #endif 210 #endif
208 } else if (c == 'e') { 211 } else if (c == 'e') {
209 212
210 mon_printf ("Stopping timer\n"); 213 mon_printf ("Stopping timer\n");
211 214
212 *hwp->tgcrp &= ~(CPMT_GCR_MASK << TID_TIMER_ID); 215 *hwp->tgcrp &= ~(CPMT_GCR_MASK << TID_TIMER_ID);
216 running = 0;
213 217
214 #ifdef DEBUG 218 #ifdef DEBUG
215 mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x," 219 mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x,"
216 " tcr=0x%x, tcn=0x%x, ter=0x%x\n", 220 " tcr=0x%x, tcn=0x%x, ter=0x%x\n",
217 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp, 221 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp,
218 *hwp->tcrp, *hwp->tcnp, *hwp->terp 222 *hwp->tcrp, *hwp->tcnp, *hwp->terp
219 ); 223 );
220 #endif 224 #endif
221 /* Uninstall interrupt handler */ 225 /* Uninstall interrupt handler */
222 mon_free_hdlr (hwp->cpm_vec); 226 mon_free_hdlr (hwp->cpm_vec);
223 227
224 } else if (c == '?') { 228 } else if (c == '?') {
225 #ifdef DEBUG 229 #ifdef DEBUG
226 cpic8xx_t *cpm_icp = &((immap_t *) gd->bd->bi_immr_base)->im_cpic; 230 cpic8xx_t *cpm_icp = &((immap_t *) gd->bd->bi_immr_base)->im_cpic;
227 sysconf8xx_t *siup = &((immap_t *) gd->bd->bi_immr_base)->im_siu_conf; 231 sysconf8xx_t *siup = &((immap_t *) gd->bd->bi_immr_base)->im_siu_conf;
228 #endif 232 #endif
229 233
230 mon_printf ("\ntgcr=0x%x, tmr=0x%x, trr=0x%x," 234 mon_printf ("\ntgcr=0x%x, tmr=0x%x, trr=0x%x,"
231 " tcr=0x%x, tcn=0x%x, ter=0x%x\n", 235 " tcr=0x%x, tcn=0x%x, ter=0x%x\n",
232 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp, 236 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp,
233 *hwp->tcrp, *hwp->tcnp, *hwp->terp 237 *hwp->tcrp, *hwp->tcnp, *hwp->terp
234 ); 238 );
235 #ifdef DEBUG 239 #ifdef DEBUG
236 mon_printf ("SIUMCR=0x%08lx, SYPCR=0x%08lx," 240 mon_printf ("SIUMCR=0x%08lx, SYPCR=0x%08lx,"
237 " SIMASK=0x%08lx, SIPEND=0x%08lx\n", 241 " SIMASK=0x%08lx, SIPEND=0x%08lx\n",
238 siup->sc_siumcr, 242 siup->sc_siumcr,
239 siup->sc_sypcr, 243 siup->sc_sypcr,
240 siup->sc_simask, 244 siup->sc_simask,
241 siup->sc_sipend 245 siup->sc_sipend
242 ); 246 );
243 247
244 mon_printf ("CIMR=0x%08lx, CICR=0x%08lx, CIPR=0x%08lx\n", 248 mon_printf ("CIMR=0x%08lx, CICR=0x%08lx, CIPR=0x%08lx\n",
245 cpm_icp->cpic_cimr, 249 cpm_icp->cpic_cimr,
246 cpm_icp->cpic_cicr, 250 cpm_icp->cpic_cicr,
247 cpm_icp->cpic_cipr 251 cpm_icp->cpic_cipr
248 ); 252 );
249 #endif 253 #endif
250 } else { 254 } else {
251 mon_printf ("\nEnter: q - quit, b - start timer, e - stop timer, ? - get status\n"); 255 mon_printf ("\nEnter: q - quit, b - start timer, e - stop timer, ? - get status\n");
252 } 256 }
253 mon_printf (usage); 257 mon_printf (usage);
254 } 258 }
259 if (running) {
260 mon_printf ("Stopping timer\n");
261 *hwp->tgcrp &= ~(CPMT_GCR_MASK << TID_TIMER_ID);
262 mon_free_hdlr (hwp->cpm_vec);
263 }
264
255 return (0); 265 return (0);
256 } 266 }
257 267
258 268
259 /* Set period in microseconds and start. 269 /* Set period in microseconds and start.
260 * Truncate to maximum period if more than this is requested - but warn about it. 270 * Truncate to maximum period if more than this is requested - but warn about it.
261 */ 271 */
262 272
263 void setPeriod (tid_8xx_cpmtimer_t *hwp, ulong interval) 273 void setPeriod (tid_8xx_cpmtimer_t *hwp, ulong interval)
264 { 274 {
265 unsigned short prescaler; 275 unsigned short prescaler;
266 unsigned long ticks; 276 unsigned long ticks;
267 277
268 mon_printf ("Set interval %ld us\n", interval); 278 mon_printf ("Set interval %ld us\n", interval);
269 279
270 /* Warn if requesting longer period than possible */ 280 /* Warn if requesting longer period than possible */
271 if (interval > CPMT_MAX_INTERVAL) { 281 if (interval > CPMT_MAX_INTERVAL) {
272 mon_printf ("Truncate interval %ld to maximum (%d)\n", 282 mon_printf ("Truncate interval %ld to maximum (%d)\n",
273 interval, CPMT_MAX_INTERVAL); 283 interval, CPMT_MAX_INTERVAL);
274 interval = CPMT_MAX_INTERVAL; 284 interval = CPMT_MAX_INTERVAL;
275 } 285 }
276 /* 286 /*
277 * Check if we want to use clock divider: 287 * Check if we want to use clock divider:
278 * Since the reference counter can be incremented only in integer steps, 288 * Since the reference counter can be incremented only in integer steps,
279 * we try to keep it as big as possible to allow the resulting period to be 289 * we try to keep it as big as possible to allow the resulting period to be
280 * as precise as possible. 290 * as precise as possible.
281 */ 291 */
282 /* prescaler, enable interrupt, restart after ref count is reached */ 292 /* prescaler, enable interrupt, restart after ref count is reached */
283 prescaler = (ushort) ((CPMT_PRESCALER - 1) << 8) | 293 prescaler = (ushort) ((CPMT_PRESCALER - 1) << 8) |
284 CPMT_MR_ORI | 294 CPMT_MR_ORI |
285 CPMT_MR_FRR; 295 CPMT_MR_FRR;
286 296
287 ticks = ((ulong) CLOCKRATE * interval); 297 ticks = ((ulong) CLOCKRATE * interval);
288 298
289 if (ticks > CPMT_MAX_TICKS) { 299 if (ticks > CPMT_MAX_TICKS) {
290 ticks /= CPMT_CLOCK_DIV; 300 ticks /= CPMT_CLOCK_DIV;
291 prescaler |= CPMT_MR_ICLK_CLKDIV; /* use system clock divided by 16 */ 301 prescaler |= CPMT_MR_ICLK_CLKDIV; /* use system clock divided by 16 */
292 } else { 302 } else {
293 prescaler |= CPMT_MR_ICLK_CLK; /* use system clock without divider */ 303 prescaler |= CPMT_MR_ICLK_CLK; /* use system clock without divider */
294 } 304 }
295 305
296 #ifdef DEBUG 306 #ifdef DEBUG
297 mon_printf ("clock/%d, prescale factor %d, reference %ld, ticks %ld\n", 307 mon_printf ("clock/%d, prescale factor %d, reference %ld, ticks %ld\n",
298 (ticks > CPMT_MAX_TICKS) ? CPMT_CLOCK_DIV : 1, 308 (ticks > CPMT_MAX_TICKS) ? CPMT_CLOCK_DIV : 1,
299 CPMT_PRESCALER, 309 CPMT_PRESCALER,
300 (ticks / CPMT_PRESCALER), 310 (ticks / CPMT_PRESCALER),
301 ticks 311 ticks
302 ); 312 );
303 #endif 313 #endif
304 314
305 /* set prescaler register */ 315 /* set prescaler register */
306 *hwp->tmrp = prescaler; 316 *hwp->tmrp = prescaler;
307 317
308 /* clear timer counter */ 318 /* clear timer counter */
309 *hwp->tcnp = 0; 319 *hwp->tcnp = 0;
310 320
311 /* set reference register */ 321 /* set reference register */
312 *hwp->trrp = (unsigned short) (ticks / CPMT_PRESCALER); 322 *hwp->trrp = (unsigned short) (ticks / CPMT_PRESCALER);
313 323
314 #ifdef DEBUG 324 #ifdef DEBUG
315 mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x," 325 mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x,"
316 " tcr=0x%x, tcn=0x%x, ter=0x%x\n", 326 " tcr=0x%x, tcn=0x%x, ter=0x%x\n",
317 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp, 327 *hwp->tgcrp, *hwp->tmrp, *hwp->trrp,
318 *hwp->tcrp, *hwp->tcnp, *hwp->terp 328 *hwp->tcrp, *hwp->tcnp, *hwp->terp
319 ); 329 );
320 #endif 330 #endif
321 } 331 }
322 332
323 /* 333 /*
324 * Handler for CPMVEC_TIMER1 interrupt 334 * Handler for CPMVEC_TIMER1 interrupt
325 */ 335 */
326 static 336 static
327 void timer_handler (void *arg) 337 void timer_handler (void *arg)
328 { 338 {
329 tid_8xx_cpmtimer_t *hwp = (tid_8xx_cpmtimer_t *)arg; 339 tid_8xx_cpmtimer_t *hwp = (tid_8xx_cpmtimer_t *)arg;
330 340
331 /* printf ("** TER1=%04x ** ", *hwp->terp); */ 341 /* printf ("** TER1=%04x ** ", *hwp->terp); */
332 342
333 /* just for demonstration */ 343 /* just for demonstration */
334 mon_printf ("."); 344 mon_printf (".");
335 345
336 /* clear all possible events: Ref. and Cap. */ 346 /* clear all possible events: Ref. and Cap. */
337 *hwp->terp = (CPMT_EVENT_CAP | CPMT_EVENT_REF); 347 *hwp->terp = (CPMT_EVENT_CAP | CPMT_EVENT_REF);
338 } 348 }
339 349
1 /* 1 /*
2 * MPC8xx Communication Processor Module. 2 * MPC8xx Communication Processor Module.
3 * Copyright (c) 1997 Dan Malek (dmalek@jlc.net) 3 * Copyright (c) 1997 Dan Malek (dmalek@jlc.net)
4 * 4 *
5 * This file contains structures and information for the communication 5 * This file contains structures and information for the communication
6 * processor channels. Some CPM control and status is available 6 * processor channels. Some CPM control and status is available
7 * throught the MPC8xx internal memory map. See immap.h for details. 7 * throught the MPC8xx internal memory map. See immap.h for details.
8 * This file only contains what I need for the moment, not the total 8 * This file only contains what I need for the moment, not the total
9 * CPM capabilities. I (or someone else) will add definitions as they 9 * CPM capabilities. I (or someone else) will add definitions as they
10 * are needed. -- Dan 10 * are needed. -- Dan
11 * 11 *
12 * On the MBX board, EPPC-Bug loads CPM microcode into the first 512 12 * On the MBX board, EPPC-Bug loads CPM microcode into the first 512
13 * bytes of the DP RAM and relocates the I2C parameter area to the 13 * bytes of the DP RAM and relocates the I2C parameter area to the
14 * IDMA1 space. The remaining DP RAM is available for buffer descriptors 14 * IDMA1 space. The remaining DP RAM is available for buffer descriptors
15 * or other use. 15 * or other use.
16 */ 16 */
17 #ifndef __CPM_8XX__ 17 #ifndef __CPM_8XX__
18 #define __CPM_8XX__ 18 #define __CPM_8XX__
19 19
20 #include <linux/config.h> 20 #include <linux/config.h>
21 #include <asm/8xx_immap.h> 21 #include <asm/8xx_immap.h>
22 22
23 /* CPM Command register. 23 /* CPM Command register.
24 */ 24 */
25 #define CPM_CR_RST ((ushort)0x8000) 25 #define CPM_CR_RST ((ushort)0x8000)
26 #define CPM_CR_OPCODE ((ushort)0x0f00) 26 #define CPM_CR_OPCODE ((ushort)0x0f00)
27 #define CPM_CR_CHAN ((ushort)0x00f0) 27 #define CPM_CR_CHAN ((ushort)0x00f0)
28 #define CPM_CR_FLG ((ushort)0x0001) 28 #define CPM_CR_FLG ((ushort)0x0001)
29 29
30 /* Some commands (there are more...later) 30 /* Some commands (there are more...later)
31 */ 31 */
32 #define CPM_CR_INIT_TRX ((ushort)0x0000) 32 #define CPM_CR_INIT_TRX ((ushort)0x0000)
33 #define CPM_CR_INIT_RX ((ushort)0x0001) 33 #define CPM_CR_INIT_RX ((ushort)0x0001)
34 #define CPM_CR_INIT_TX ((ushort)0x0002) 34 #define CPM_CR_INIT_TX ((ushort)0x0002)
35 #define CPM_CR_HUNT_MODE ((ushort)0x0003) 35 #define CPM_CR_HUNT_MODE ((ushort)0x0003)
36 #define CPM_CR_STOP_TX ((ushort)0x0004) 36 #define CPM_CR_STOP_TX ((ushort)0x0004)
37 #define CPM_CR_RESTART_TX ((ushort)0x0006) 37 #define CPM_CR_RESTART_TX ((ushort)0x0006)
38 #define CPM_CR_SET_GADDR ((ushort)0x0008) 38 #define CPM_CR_SET_GADDR ((ushort)0x0008)
39 39
40 /* Channel numbers. 40 /* Channel numbers.
41 */ 41 */
42 #define CPM_CR_CH_SCC1 ((ushort)0x0000) 42 #define CPM_CR_CH_SCC1 ((ushort)0x0000)
43 #define CPM_CR_CH_I2C ((ushort)0x0001) /* I2C and IDMA1 */ 43 #define CPM_CR_CH_I2C ((ushort)0x0001) /* I2C and IDMA1 */
44 #define CPM_CR_CH_SCC2 ((ushort)0x0004) 44 #define CPM_CR_CH_SCC2 ((ushort)0x0004)
45 #define CPM_CR_CH_SPI ((ushort)0x0005) /* SPI / IDMA2 / Timers */ 45 #define CPM_CR_CH_SPI ((ushort)0x0005) /* SPI/IDMA2/Timers */
46 #define CPM_CR_CH_SCC3 ((ushort)0x0008) 46 #define CPM_CR_CH_SCC3 ((ushort)0x0008)
47 #define CPM_CR_CH_SMC1 ((ushort)0x0009) /* SMC1 / DSP1 */ 47 #define CPM_CR_CH_SMC1 ((ushort)0x0009) /* SMC1 / DSP1 */
48 #define CPM_CR_CH_SCC4 ((ushort)0x000c) 48 #define CPM_CR_CH_SCC4 ((ushort)0x000c)
49 #define CPM_CR_CH_SMC2 ((ushort)0x000d) /* SMC2 / DSP2 */ 49 #define CPM_CR_CH_SMC2 ((ushort)0x000d) /* SMC2 / DSP2 */
50 50
51 #define mk_cr_cmd(CH, CMD) ((CMD << 8) | (CH << 4)) 51 #define mk_cr_cmd(CH, CMD) ((CMD << 8) | (CH << 4))
52 52
53 /* 53 /*
54 * DPRAM defines and allocation functions 54 * DPRAM defines and allocation functions
55 */ 55 */
56 56
57 /* The dual ported RAM is multi-functional. Some areas can be (and are 57 /* The dual ported RAM is multi-functional. Some areas can be (and are
58 * being) used for microcode. There is an area that can only be used 58 * being) used for microcode. There is an area that can only be used
59 * as data ram for buffer descriptors, which is all we use right now. 59 * as data ram for buffer descriptors, which is all we use right now.
60 * Currently the first 512 and last 256 bytes are used for microcode. 60 * Currently the first 512 and last 256 bytes are used for microcode.
61 */ 61 */
62 #ifdef CFG_ALLOC_DPRAM 62 #ifdef CFG_ALLOC_DPRAM
63 63
64 #define CPM_DATAONLY_BASE ((uint)0x0800) 64 #define CPM_DATAONLY_BASE ((uint)0x0800)
65 #define CPM_DATAONLY_SIZE ((uint)0x0700) 65 #define CPM_DATAONLY_SIZE ((uint)0x0700)
66 #define CPM_DP_NOSPACE ((uint)0x7fffffff) 66 #define CPM_DP_NOSPACE ((uint)0x7fffffff)
67 67
68 #else 68 #else
69 69
70 #define CPM_SERIAL_BASE 0x0800 70 #define CPM_SERIAL_BASE 0x0800
71 #define CPM_I2C_BASE 0x0820 71 #define CPM_I2C_BASE 0x0820
72 #define CPM_SPI_BASE 0x0840 72 #define CPM_SPI_BASE 0x0840
73 #define CPM_FEC_BASE 0x0860 73 #define CPM_FEC_BASE 0x0860
74 #define CPM_WLKBD_BASE 0x0880 74 #define CPM_WLKBD_BASE 0x0880
75 #define CPM_SCC_BASE 0x0900 75 #define CPM_SCC_BASE 0x0900
76 #define CPM_POST_BASE 0x0980 76 #define CPM_POST_BASE 0x0980
77 77
78 #endif 78 #endif
79 79
80 #ifndef CFG_CPM_POST_WORD_ADDR 80 #ifndef CFG_CPM_POST_WORD_ADDR
81 #define CPM_POST_WORD_ADDR 0x07FC 81 #define CPM_POST_WORD_ADDR 0x07FC
82 #else 82 #else
83 #define CPM_POST_WORD_ADDR CFG_CPM_POST_WORD_ADDR 83 #define CPM_POST_WORD_ADDR CFG_CPM_POST_WORD_ADDR
84 #endif 84 #endif
85 85
86 #define BD_IIC_START ((uint) 0x0400) /* <- please use CPM_I2C_BASE !! */ 86 #define BD_IIC_START ((uint) 0x0400) /* <- please use CPM_I2C_BASE !! */
87 87
88 /* Export the base address of the communication processor registers 88 /* Export the base address of the communication processor registers
89 * and dual port ram. 89 * and dual port ram.
90 */ 90 */
91 extern cpm8xx_t *cpmp; /* Pointer to comm processor */ 91 extern cpm8xx_t *cpmp; /* Pointer to comm processor */
92 92
93 /* Buffer descriptors used by many of the CPM protocols. 93 /* Buffer descriptors used by many of the CPM protocols.
94 */ 94 */
95 typedef struct cpm_buf_desc { 95 typedef struct cpm_buf_desc {
96 ushort cbd_sc; /* Status and Control */ 96 ushort cbd_sc; /* Status and Control */
97 ushort cbd_datlen; /* Data length in buffer */ 97 ushort cbd_datlen; /* Data length in buffer */
98 uint cbd_bufaddr; /* Buffer address in host memory */ 98 uint cbd_bufaddr; /* Buffer address in host memory */
99 } cbd_t; 99 } cbd_t;
100 100
101 #define BD_SC_EMPTY ((ushort)0x8000) /* Recieve is empty */ 101 #define BD_SC_EMPTY ((ushort)0x8000) /* Recieve is empty */
102 #define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */ 102 #define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */
103 #define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */ 103 #define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */
104 #define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */ 104 #define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */
105 #define BD_SC_LAST ((ushort)0x0800) /* Last buffer in frame */ 105 #define BD_SC_LAST ((ushort)0x0800) /* Last buffer in frame */
106 #define BD_SC_TC ((ushort)0x0400) /* Transmit CRC */ 106 #define BD_SC_TC ((ushort)0x0400) /* Transmit CRC */
107 #define BD_SC_CM ((ushort)0x0200) /* Continous mode */ 107 #define BD_SC_CM ((ushort)0x0200) /* Continous mode */
108 #define BD_SC_ID ((ushort)0x0100) /* Rec'd too many idles */ 108 #define BD_SC_ID ((ushort)0x0100) /* Rec'd too many idles */
109 #define BD_SC_P ((ushort)0x0100) /* xmt preamble */ 109 #define BD_SC_P ((ushort)0x0100) /* xmt preamble */
110 #define BD_SC_BR ((ushort)0x0020) /* Break received */ 110 #define BD_SC_BR ((ushort)0x0020) /* Break received */
111 #define BD_SC_FR ((ushort)0x0010) /* Framing error */ 111 #define BD_SC_FR ((ushort)0x0010) /* Framing error */
112 #define BD_SC_PR ((ushort)0x0008) /* Parity error */ 112 #define BD_SC_PR ((ushort)0x0008) /* Parity error */
113 #define BD_SC_OV ((ushort)0x0002) /* Overrun */ 113 #define BD_SC_OV ((ushort)0x0002) /* Overrun */
114 #define BD_SC_CD ((ushort)0x0001) /* Carrier Detect lost */ 114 #define BD_SC_CD ((ushort)0x0001) /* Carrier Detect lost */
115 115
116 /* Parameter RAM offsets. 116 /* Parameter RAM offsets.
117 */ 117 */
118 #define PROFF_SCC1 ((uint)0x0000) 118 #define PROFF_SCC1 ((uint)0x0000)
119 #define PROFF_IIC ((uint)0x0080) 119 #define PROFF_IIC ((uint)0x0080)
120 #define PROFF_SCC2 ((uint)0x0100) 120 #define PROFF_SCC2 ((uint)0x0100)
121 #define PROFF_SPI ((uint)0x0180) 121 #define PROFF_SPI ((uint)0x0180)
122 #define PROFF_SCC3 ((uint)0x0200) 122 #define PROFF_SCC3 ((uint)0x0200)
123 #define PROFF_SMC1 ((uint)0x0280) 123 #define PROFF_SMC1 ((uint)0x0280)
124 #define PROFF_SCC4 ((uint)0x0300) 124 #define PROFF_SCC4 ((uint)0x0300)
125 #define PROFF_SMC2 ((uint)0x0380) 125 #define PROFF_SMC2 ((uint)0x0380)
126 126
127 /* Define enough so I can at least use the serial port as a UART. 127 /* Define enough so I can at least use the serial port as a UART.
128 * The MBX uses SMC1 as the host serial port. 128 * The MBX uses SMC1 as the host serial port.
129 */ 129 */
130 typedef struct smc_uart { 130 typedef struct smc_uart {
131 ushort smc_rbase; /* Rx Buffer descriptor base address */ 131 ushort smc_rbase; /* Rx Buffer descriptor base address */
132 ushort smc_tbase; /* Tx Buffer descriptor base address */ 132 ushort smc_tbase; /* Tx Buffer descriptor base address */
133 u_char smc_rfcr; /* Rx function code */ 133 u_char smc_rfcr; /* Rx function code */
134 u_char smc_tfcr; /* Tx function code */ 134 u_char smc_tfcr; /* Tx function code */
135 ushort smc_mrblr; /* Max receive buffer length */ 135 ushort smc_mrblr; /* Max receive buffer length */
136 uint smc_rstate; /* Internal */ 136 uint smc_rstate; /* Internal */
137 uint smc_idp; /* Internal */ 137 uint smc_idp; /* Internal */
138 ushort smc_rbptr; /* Internal */ 138 ushort smc_rbptr; /* Internal */
139 ushort smc_ibc; /* Internal */ 139 ushort smc_ibc; /* Internal */
140 uint smc_rxtmp; /* Internal */ 140 uint smc_rxtmp; /* Internal */
141 uint smc_tstate; /* Internal */ 141 uint smc_tstate; /* Internal */
142 uint smc_tdp; /* Internal */ 142 uint smc_tdp; /* Internal */
143 ushort smc_tbptr; /* Internal */ 143 ushort smc_tbptr; /* Internal */
144 ushort smc_tbc; /* Internal */ 144 ushort smc_tbc; /* Internal */
145 uint smc_txtmp; /* Internal */ 145 uint smc_txtmp; /* Internal */
146 ushort smc_maxidl; /* Maximum idle characters */ 146 ushort smc_maxidl; /* Maximum idle characters */
147 ushort smc_tmpidl; /* Temporary idle counter */ 147 ushort smc_tmpidl; /* Temporary idle counter */
148 ushort smc_brklen; /* Last received break length */ 148 ushort smc_brklen; /* Last received break length */
149 ushort smc_brkec; /* rcv'd break condition counter */ 149 ushort smc_brkec; /* rcv'd break condition counter */
150 ushort smc_brkcr; /* xmt break count register */ 150 ushort smc_brkcr; /* xmt break count register */
151 ushort smc_rmask; /* Temporary bit mask */ 151 ushort smc_rmask; /* Temporary bit mask */
152 } smc_uart_t; 152 } smc_uart_t;
153 153
154 /* Function code bits. 154 /* Function code bits.
155 */ 155 */
156 #define SMC_EB ((u_char)0x10) /* Set big endian byte order */ 156 #define SMC_EB ((u_char)0x10) /* Set big endian byte order */
157 157
158 /* SMC uart mode register. 158 /* SMC uart mode register.
159 */ 159 */
160 #define SMCMR_REN ((ushort)0x0001) 160 #define SMCMR_REN ((ushort)0x0001)
161 #define SMCMR_TEN ((ushort)0x0002) 161 #define SMCMR_TEN ((ushort)0x0002)
162 #define SMCMR_DM ((ushort)0x000c) 162 #define SMCMR_DM ((ushort)0x000c)
163 #define SMCMR_SM_GCI ((ushort)0x0000) 163 #define SMCMR_SM_GCI ((ushort)0x0000)
164 #define SMCMR_SM_UART ((ushort)0x0020) 164 #define SMCMR_SM_UART ((ushort)0x0020)
165 #define SMCMR_SM_TRANS ((ushort)0x0030) 165 #define SMCMR_SM_TRANS ((ushort)0x0030)
166 #define SMCMR_SM_MASK ((ushort)0x0030) 166 #define SMCMR_SM_MASK ((ushort)0x0030)
167 #define SMCMR_PM_EVEN ((ushort)0x0100) /* Even parity, else odd */ 167 #define SMCMR_PM_EVEN ((ushort)0x0100) /* Even parity, else odd */
168 #define SMCMR_REVD SMCMR_PM_EVEN 168 #define SMCMR_REVD SMCMR_PM_EVEN
169 #define SMCMR_PEN ((ushort)0x0200) /* Parity enable */ 169 #define SMCMR_PEN ((ushort)0x0200) /* Parity enable */
170 #define SMCMR_BS SMCMR_PEN 170 #define SMCMR_BS SMCMR_PEN
171 #define SMCMR_SL ((ushort)0x0400) /* Two stops, else one */ 171 #define SMCMR_SL ((ushort)0x0400) /* Two stops, else one */
172 #define SMCR_CLEN_MASK ((ushort)0x7800) /* Character length */ 172 #define SMCR_CLEN_MASK ((ushort)0x7800) /* Character length */
173 #define smcr_mk_clen(C) (((C) << 11) & SMCR_CLEN_MASK) 173 #define smcr_mk_clen(C) (((C) << 11) & SMCR_CLEN_MASK)
174 174
175 /* SMC2 as Centronics parallel printer. It is half duplex, in that 175 /* SMC2 as Centronics parallel printer. It is half duplex, in that
176 * it can only receive or transmit. The parameter ram values for 176 * it can only receive or transmit. The parameter ram values for
177 * each direction are either unique or properly overlap, so we can 177 * each direction are either unique or properly overlap, so we can
178 * include them in one structure. 178 * include them in one structure.
179 */ 179 */
180 typedef struct smc_centronics { 180 typedef struct smc_centronics {
181 ushort scent_rbase; 181 ushort scent_rbase;
182 ushort scent_tbase; 182 ushort scent_tbase;
183 u_char scent_cfcr; 183 u_char scent_cfcr;
184 u_char scent_smask; 184 u_char scent_smask;
185 ushort scent_mrblr; 185 ushort scent_mrblr;
186 uint scent_rstate; 186 uint scent_rstate;
187 uint scent_r_ptr; 187 uint scent_r_ptr;
188 ushort scent_rbptr; 188 ushort scent_rbptr;
189 ushort scent_r_cnt; 189 ushort scent_r_cnt;
190 uint scent_rtemp; 190 uint scent_rtemp;
191 uint scent_tstate; 191 uint scent_tstate;
192 uint scent_t_ptr; 192 uint scent_t_ptr;
193 ushort scent_tbptr; 193 ushort scent_tbptr;
194 ushort scent_t_cnt; 194 ushort scent_t_cnt;
195 uint scent_ttemp; 195 uint scent_ttemp;
196 ushort scent_max_sl; 196 ushort scent_max_sl;
197 ushort scent_sl_cnt; 197 ushort scent_sl_cnt;
198 ushort scent_character1; 198 ushort scent_character1;
199 ushort scent_character2; 199 ushort scent_character2;
200 ushort scent_character3; 200 ushort scent_character3;
201 ushort scent_character4; 201 ushort scent_character4;
202 ushort scent_character5; 202 ushort scent_character5;
203 ushort scent_character6; 203 ushort scent_character6;
204 ushort scent_character7; 204 ushort scent_character7;
205 ushort scent_character8; 205 ushort scent_character8;
206 ushort scent_rccm; 206 ushort scent_rccm;
207 ushort scent_rccr; 207 ushort scent_rccr;
208 } smc_cent_t; 208 } smc_cent_t;
209 209
210 /* Centronics Status Mask Register. 210 /* Centronics Status Mask Register.
211 */ 211 */
212 #define SMC_CENT_F ((u_char)0x08) 212 #define SMC_CENT_F ((u_char)0x08)
213 #define SMC_CENT_PE ((u_char)0x04) 213 #define SMC_CENT_PE ((u_char)0x04)
214 #define SMC_CENT_S ((u_char)0x02) 214 #define SMC_CENT_S ((u_char)0x02)
215 215
216 /* SMC Event and Mask register. 216 /* SMC Event and Mask register.
217 */ 217 */
218 #define SMCM_BRKE ((unsigned char)0x40) /* When in UART Mode */ 218 #define SMCM_BRKE ((unsigned char)0x40) /* When in UART Mode */
219 #define SMCM_BRK ((unsigned char)0x10) /* When in UART Mode */ 219 #define SMCM_BRK ((unsigned char)0x10) /* When in UART Mode */
220 #define SMCM_TXE ((unsigned char)0x10) /* When in Transparent Mode */ 220 #define SMCM_TXE ((unsigned char)0x10) /* When in Transparent Mode */
221 #define SMCM_BSY ((unsigned char)0x04) 221 #define SMCM_BSY ((unsigned char)0x04)
222 #define SMCM_TX ((unsigned char)0x02) 222 #define SMCM_TX ((unsigned char)0x02)
223 #define SMCM_RX ((unsigned char)0x01) 223 #define SMCM_RX ((unsigned char)0x01)
224 224
225 /* Baud rate generators. 225 /* Baud rate generators.
226 */ 226 */
227 #define CPM_BRG_RST ((uint)0x00020000) 227 #define CPM_BRG_RST ((uint)0x00020000)
228 #define CPM_BRG_EN ((uint)0x00010000) 228 #define CPM_BRG_EN ((uint)0x00010000)
229 #define CPM_BRG_EXTC_INT ((uint)0x00000000) 229 #define CPM_BRG_EXTC_INT ((uint)0x00000000)
230 #define CPM_BRG_EXTC_CLK2 ((uint)0x00004000) 230 #define CPM_BRG_EXTC_CLK2 ((uint)0x00004000)
231 #define CPM_BRG_EXTC_CLK6 ((uint)0x00008000) 231 #define CPM_BRG_EXTC_CLK6 ((uint)0x00008000)
232 #define CPM_BRG_ATB ((uint)0x00002000) 232 #define CPM_BRG_ATB ((uint)0x00002000)
233 #define CPM_BRG_CD_MASK ((uint)0x00001ffe) 233 #define CPM_BRG_CD_MASK ((uint)0x00001ffe)
234 #define CPM_BRG_DIV16 ((uint)0x00000001) 234 #define CPM_BRG_DIV16 ((uint)0x00000001)
235 235
236 /* SI Clock Route Register 236 /* SI Clock Route Register
237 */ 237 */
238 #define SICR_RCLK_SCC1_BRG1 ((uint)0x00000000) 238 #define SICR_RCLK_SCC1_BRG1 ((uint)0x00000000)
239 #define SICR_TCLK_SCC1_BRG1 ((uint)0x00000000) 239 #define SICR_TCLK_SCC1_BRG1 ((uint)0x00000000)
240 #define SICR_RCLK_SCC2_BRG2 ((uint)0x00000800) 240 #define SICR_RCLK_SCC2_BRG2 ((uint)0x00000800)
241 #define SICR_TCLK_SCC2_BRG2 ((uint)0x00000100) 241 #define SICR_TCLK_SCC2_BRG2 ((uint)0x00000100)
242 #define SICR_RCLK_SCC3_BRG3 ((uint)0x00100000) 242 #define SICR_RCLK_SCC3_BRG3 ((uint)0x00100000)
243 #define SICR_TCLK_SCC3_BRG3 ((uint)0x00020000) 243 #define SICR_TCLK_SCC3_BRG3 ((uint)0x00020000)
244 #define SICR_RCLK_SCC4_BRG4 ((uint)0x18000000) 244 #define SICR_RCLK_SCC4_BRG4 ((uint)0x18000000)
245 #define SICR_TCLK_SCC4_BRG4 ((uint)0x03000000) 245 #define SICR_TCLK_SCC4_BRG4 ((uint)0x03000000)
246 246
247 /* SCCs. 247 /* SCCs.
248 */ 248 */
249 #define SCC_GSMRH_IRP ((uint)0x00040000) 249 #define SCC_GSMRH_IRP ((uint)0x00040000)
250 #define SCC_GSMRH_GDE ((uint)0x00010000) 250 #define SCC_GSMRH_GDE ((uint)0x00010000)
251 #define SCC_GSMRH_TCRC_CCITT ((uint)0x00008000) 251 #define SCC_GSMRH_TCRC_CCITT ((uint)0x00008000)
252 #define SCC_GSMRH_TCRC_BISYNC ((uint)0x00004000) 252 #define SCC_GSMRH_TCRC_BISYNC ((uint)0x00004000)
253 #define SCC_GSMRH_TCRC_HDLC ((uint)0x00000000) 253 #define SCC_GSMRH_TCRC_HDLC ((uint)0x00000000)
254 #define SCC_GSMRH_REVD ((uint)0x00002000) 254 #define SCC_GSMRH_REVD ((uint)0x00002000)
255 #define SCC_GSMRH_TRX ((uint)0x00001000) 255 #define SCC_GSMRH_TRX ((uint)0x00001000)
256 #define SCC_GSMRH_TTX ((uint)0x00000800) 256 #define SCC_GSMRH_TTX ((uint)0x00000800)
257 #define SCC_GSMRH_CDP ((uint)0x00000400) 257 #define SCC_GSMRH_CDP ((uint)0x00000400)
258 #define SCC_GSMRH_CTSP ((uint)0x00000200) 258 #define SCC_GSMRH_CTSP ((uint)0x00000200)
259 #define SCC_GSMRH_CDS ((uint)0x00000100) 259 #define SCC_GSMRH_CDS ((uint)0x00000100)
260 #define SCC_GSMRH_CTSS ((uint)0x00000080) 260 #define SCC_GSMRH_CTSS ((uint)0x00000080)
261 #define SCC_GSMRH_TFL ((uint)0x00000040) 261 #define SCC_GSMRH_TFL ((uint)0x00000040)
262 #define SCC_GSMRH_RFW ((uint)0x00000020) 262 #define SCC_GSMRH_RFW ((uint)0x00000020)
263 #define SCC_GSMRH_TXSY ((uint)0x00000010) 263 #define SCC_GSMRH_TXSY ((uint)0x00000010)
264 #define SCC_GSMRH_SYNL16 ((uint)0x0000000c) 264 #define SCC_GSMRH_SYNL16 ((uint)0x0000000c)
265 #define SCC_GSMRH_SYNL8 ((uint)0x00000008) 265 #define SCC_GSMRH_SYNL8 ((uint)0x00000008)
266 #define SCC_GSMRH_SYNL4 ((uint)0x00000004) 266 #define SCC_GSMRH_SYNL4 ((uint)0x00000004)
267 #define SCC_GSMRH_RTSM ((uint)0x00000002) 267 #define SCC_GSMRH_RTSM ((uint)0x00000002)
268 #define SCC_GSMRH_RSYN ((uint)0x00000001) 268 #define SCC_GSMRH_RSYN ((uint)0x00000001)
269 269
270 #define SCC_GSMRL_SIR ((uint)0x80000000) /* SCC2 only */ 270 #define SCC_GSMRL_SIR ((uint)0x80000000) /* SCC2 only */
271 #define SCC_GSMRL_EDGE_NONE ((uint)0x60000000) 271 #define SCC_GSMRL_EDGE_NONE ((uint)0x60000000)
272 #define SCC_GSMRL_EDGE_NEG ((uint)0x40000000) 272 #define SCC_GSMRL_EDGE_NEG ((uint)0x40000000)
273 #define SCC_GSMRL_EDGE_POS ((uint)0x20000000) 273 #define SCC_GSMRL_EDGE_POS ((uint)0x20000000)
274 #define SCC_GSMRL_EDGE_BOTH ((uint)0x00000000) 274 #define SCC_GSMRL_EDGE_BOTH ((uint)0x00000000)
275 #define SCC_GSMRL_TCI ((uint)0x10000000) 275 #define SCC_GSMRL_TCI ((uint)0x10000000)
276 #define SCC_GSMRL_TSNC_3 ((uint)0x0c000000) 276 #define SCC_GSMRL_TSNC_3 ((uint)0x0c000000)
277 #define SCC_GSMRL_TSNC_4 ((uint)0x08000000) 277 #define SCC_GSMRL_TSNC_4 ((uint)0x08000000)
278 #define SCC_GSMRL_TSNC_14 ((uint)0x04000000) 278 #define SCC_GSMRL_TSNC_14 ((uint)0x04000000)
279 #define SCC_GSMRL_TSNC_INF ((uint)0x00000000) 279 #define SCC_GSMRL_TSNC_INF ((uint)0x00000000)
280 #define SCC_GSMRL_RINV ((uint)0x02000000) 280 #define SCC_GSMRL_RINV ((uint)0x02000000)
281 #define SCC_GSMRL_TINV ((uint)0x01000000) 281 #define SCC_GSMRL_TINV ((uint)0x01000000)
282 #define SCC_GSMRL_TPL_128 ((uint)0x00c00000) 282 #define SCC_GSMRL_TPL_128 ((uint)0x00c00000)
283 #define SCC_GSMRL_TPL_64 ((uint)0x00a00000) 283 #define SCC_GSMRL_TPL_64 ((uint)0x00a00000)
284 #define SCC_GSMRL_TPL_48 ((uint)0x00800000) 284 #define SCC_GSMRL_TPL_48 ((uint)0x00800000)
285 #define SCC_GSMRL_TPL_32 ((uint)0x00600000) 285 #define SCC_GSMRL_TPL_32 ((uint)0x00600000)
286 #define SCC_GSMRL_TPL_16 ((uint)0x00400000) 286 #define SCC_GSMRL_TPL_16 ((uint)0x00400000)
287 #define SCC_GSMRL_TPL_8 ((uint)0x00200000) 287 #define SCC_GSMRL_TPL_8 ((uint)0x00200000)
288 #define SCC_GSMRL_TPL_NONE ((uint)0x00000000) 288 #define SCC_GSMRL_TPL_NONE ((uint)0x00000000)
289 #define SCC_GSMRL_TPP_ALL1 ((uint)0x00180000) 289 #define SCC_GSMRL_TPP_ALL1 ((uint)0x00180000)
290 #define SCC_GSMRL_TPP_01 ((uint)0x00100000) 290 #define SCC_GSMRL_TPP_01 ((uint)0x00100000)
291 #define SCC_GSMRL_TPP_10 ((uint)0x00080000) 291 #define SCC_GSMRL_TPP_10 ((uint)0x00080000)
292 #define SCC_GSMRL_TPP_ZEROS ((uint)0x00000000) 292 #define SCC_GSMRL_TPP_ZEROS ((uint)0x00000000)
293 #define SCC_GSMRL_TEND ((uint)0x00040000) 293 #define SCC_GSMRL_TEND ((uint)0x00040000)
294 #define SCC_GSMRL_TDCR_32 ((uint)0x00030000) 294 #define SCC_GSMRL_TDCR_32 ((uint)0x00030000)
295 #define SCC_GSMRL_TDCR_16 ((uint)0x00020000) 295 #define SCC_GSMRL_TDCR_16 ((uint)0x00020000)
296 #define SCC_GSMRL_TDCR_8 ((uint)0x00010000) 296 #define SCC_GSMRL_TDCR_8 ((uint)0x00010000)
297 #define SCC_GSMRL_TDCR_1 ((uint)0x00000000) 297 #define SCC_GSMRL_TDCR_1 ((uint)0x00000000)
298 #define SCC_GSMRL_RDCR_32 ((uint)0x0000c000) 298 #define SCC_GSMRL_RDCR_32 ((uint)0x0000c000)
299 #define SCC_GSMRL_RDCR_16 ((uint)0x00008000) 299 #define SCC_GSMRL_RDCR_16 ((uint)0x00008000)
300 #define SCC_GSMRL_RDCR_8 ((uint)0x00004000) 300 #define SCC_GSMRL_RDCR_8 ((uint)0x00004000)
301 #define SCC_GSMRL_RDCR_1 ((uint)0x00000000) 301 #define SCC_GSMRL_RDCR_1 ((uint)0x00000000)
302 #define SCC_GSMRL_RENC_DFMAN ((uint)0x00003000) 302 #define SCC_GSMRL_RENC_DFMAN ((uint)0x00003000)
303 #define SCC_GSMRL_RENC_MANCH ((uint)0x00002000) 303 #define SCC_GSMRL_RENC_MANCH ((uint)0x00002000)
304 #define SCC_GSMRL_RENC_FM0 ((uint)0x00001000) 304 #define SCC_GSMRL_RENC_FM0 ((uint)0x00001000)
305 #define SCC_GSMRL_RENC_NRZI ((uint)0x00000800) 305 #define SCC_GSMRL_RENC_NRZI ((uint)0x00000800)
306 #define SCC_GSMRL_RENC_NRZ ((uint)0x00000000) 306 #define SCC_GSMRL_RENC_NRZ ((uint)0x00000000)
307 #define SCC_GSMRL_TENC_DFMAN ((uint)0x00000600) 307 #define SCC_GSMRL_TENC_DFMAN ((uint)0x00000600)
308 #define SCC_GSMRL_TENC_MANCH ((uint)0x00000400) 308 #define SCC_GSMRL_TENC_MANCH ((uint)0x00000400)
309 #define SCC_GSMRL_TENC_FM0 ((uint)0x00000200) 309 #define SCC_GSMRL_TENC_FM0 ((uint)0x00000200)
310 #define SCC_GSMRL_TENC_NRZI ((uint)0x00000100) 310 #define SCC_GSMRL_TENC_NRZI ((uint)0x00000100)
311 #define SCC_GSMRL_TENC_NRZ ((uint)0x00000000) 311 #define SCC_GSMRL_TENC_NRZ ((uint)0x00000000)
312 #define SCC_GSMRL_DIAG_LE ((uint)0x000000c0) /* Loop and echo */ 312 #define SCC_GSMRL_DIAG_LE ((uint)0x000000c0) /* Loop and echo */
313 #define SCC_GSMRL_DIAG_ECHO ((uint)0x00000080) 313 #define SCC_GSMRL_DIAG_ECHO ((uint)0x00000080)
314 #define SCC_GSMRL_DIAG_LOOP ((uint)0x00000040) 314 #define SCC_GSMRL_DIAG_LOOP ((uint)0x00000040)
315 #define SCC_GSMRL_DIAG_NORM ((uint)0x00000000) 315 #define SCC_GSMRL_DIAG_NORM ((uint)0x00000000)
316 #define SCC_GSMRL_ENR ((uint)0x00000020) 316 #define SCC_GSMRL_ENR ((uint)0x00000020)
317 #define SCC_GSMRL_ENT ((uint)0x00000010) 317 #define SCC_GSMRL_ENT ((uint)0x00000010)
318 #define SCC_GSMRL_MODE_ENET ((uint)0x0000000c) 318 #define SCC_GSMRL_MODE_ENET ((uint)0x0000000c)
319 #define SCC_GSMRL_MODE_DDCMP ((uint)0x00000009) 319 #define SCC_GSMRL_MODE_DDCMP ((uint)0x00000009)
320 #define SCC_GSMRL_MODE_BISYNC ((uint)0x00000008) 320 #define SCC_GSMRL_MODE_BISYNC ((uint)0x00000008)
321 #define SCC_GSMRL_MODE_V14 ((uint)0x00000007) 321 #define SCC_GSMRL_MODE_V14 ((uint)0x00000007)
322 #define SCC_GSMRL_MODE_AHDLC ((uint)0x00000006) 322 #define SCC_GSMRL_MODE_AHDLC ((uint)0x00000006)
323 #define SCC_GSMRL_MODE_PROFIBUS ((uint)0x00000005) 323 #define SCC_GSMRL_MODE_PROFIBUS ((uint)0x00000005)
324 #define SCC_GSMRL_MODE_UART ((uint)0x00000004) 324 #define SCC_GSMRL_MODE_UART ((uint)0x00000004)
325 #define SCC_GSMRL_MODE_SS7 ((uint)0x00000003) 325 #define SCC_GSMRL_MODE_SS7 ((uint)0x00000003)
326 #define SCC_GSMRL_MODE_ATALK ((uint)0x00000002) 326 #define SCC_GSMRL_MODE_ATALK ((uint)0x00000002)
327 #define SCC_GSMRL_MODE_HDLC ((uint)0x00000000) 327 #define SCC_GSMRL_MODE_HDLC ((uint)0x00000000)
328 328
329 #define SCC_TODR_TOD ((ushort)0x8000) 329 #define SCC_TODR_TOD ((ushort)0x8000)
330 330
331 /* SCC Event and Mask register. 331 /* SCC Event and Mask register.
332 */ 332 */
333 #define SCCM_TXE ((unsigned char)0x10) 333 #define SCCM_TXE ((unsigned char)0x10)
334 #define SCCM_BSY ((unsigned char)0x04) 334 #define SCCM_BSY ((unsigned char)0x04)
335 #define SCCM_TX ((unsigned char)0x02) 335 #define SCCM_TX ((unsigned char)0x02)
336 #define SCCM_RX ((unsigned char)0x01) 336 #define SCCM_RX ((unsigned char)0x01)
337 337
338 typedef struct scc_param { 338 typedef struct scc_param {
339 ushort scc_rbase; /* Rx Buffer descriptor base address */ 339 ushort scc_rbase; /* Rx Buffer descriptor base address */
340 ushort scc_tbase; /* Tx Buffer descriptor base address */ 340 ushort scc_tbase; /* Tx Buffer descriptor base address */
341 u_char scc_rfcr; /* Rx function code */ 341 u_char scc_rfcr; /* Rx function code */
342 u_char scc_tfcr; /* Tx function code */ 342 u_char scc_tfcr; /* Tx function code */
343 ushort scc_mrblr; /* Max receive buffer length */ 343 ushort scc_mrblr; /* Max receive buffer length */
344 uint scc_rstate; /* Internal */ 344 uint scc_rstate; /* Internal */
345 uint scc_idp; /* Internal */ 345 uint scc_idp; /* Internal */
346 ushort scc_rbptr; /* Internal */ 346 ushort scc_rbptr; /* Internal */
347 ushort scc_ibc; /* Internal */ 347 ushort scc_ibc; /* Internal */
348 uint scc_rxtmp; /* Internal */ 348 uint scc_rxtmp; /* Internal */
349 uint scc_tstate; /* Internal */ 349 uint scc_tstate; /* Internal */
350 uint scc_tdp; /* Internal */ 350 uint scc_tdp; /* Internal */
351 ushort scc_tbptr; /* Internal */ 351 ushort scc_tbptr; /* Internal */
352 ushort scc_tbc; /* Internal */ 352 ushort scc_tbc; /* Internal */
353 uint scc_txtmp; /* Internal */ 353 uint scc_txtmp; /* Internal */
354 uint scc_rcrc; /* Internal */ 354 uint scc_rcrc; /* Internal */
355 uint scc_tcrc; /* Internal */ 355 uint scc_tcrc; /* Internal */
356 } sccp_t; 356 } sccp_t;
357 357
358 /* Function code bits. 358 /* Function code bits.
359 */ 359 */
360 #define SCC_EB ((u_char)0x10) /* Set big endian byte order */ 360 #define SCC_EB ((u_char)0x10) /* Set big endian byte order */
361 361
362 /* CPM Ethernet through SCCx. 362 /* CPM Ethernet through SCCx.
363 */ 363 */
364 typedef struct scc_enet { 364 typedef struct scc_enet {
365 sccp_t sen_genscc; 365 sccp_t sen_genscc;
366 uint sen_cpres; /* Preset CRC */ 366 uint sen_cpres; /* Preset CRC */
367 uint sen_cmask; /* Constant mask for CRC */ 367 uint sen_cmask; /* Constant mask for CRC */
368 uint sen_crcec; /* CRC Error counter */ 368 uint sen_crcec; /* CRC Error counter */
369 uint sen_alec; /* alignment error counter */ 369 uint sen_alec; /* alignment error counter */
370 uint sen_disfc; /* discard frame counter */ 370 uint sen_disfc; /* discard frame counter */
371 ushort sen_pads; /* Tx short frame pad character */ 371 ushort sen_pads; /* Tx short frame pad character */
372 ushort sen_retlim; /* Retry limit threshold */ 372 ushort sen_retlim; /* Retry limit threshold */
373 ushort sen_retcnt; /* Retry limit counter */ 373 ushort sen_retcnt; /* Retry limit counter */
374 ushort sen_maxflr; /* maximum frame length register */ 374 ushort sen_maxflr; /* maximum frame length register */
375 ushort sen_minflr; /* minimum frame length register */ 375 ushort sen_minflr; /* minimum frame length register */
376 ushort sen_maxd1; /* maximum DMA1 length */ 376 ushort sen_maxd1; /* maximum DMA1 length */
377 ushort sen_maxd2; /* maximum DMA2 length */ 377 ushort sen_maxd2; /* maximum DMA2 length */
378 ushort sen_maxd; /* Rx max DMA */ 378 ushort sen_maxd; /* Rx max DMA */
379 ushort sen_dmacnt; /* Rx DMA counter */ 379 ushort sen_dmacnt; /* Rx DMA counter */
380 ushort sen_maxb; /* Max BD byte count */ 380 ushort sen_maxb; /* Max BD byte count */
381 ushort sen_gaddr1; /* Group address filter */ 381 ushort sen_gaddr1; /* Group address filter */
382 ushort sen_gaddr2; 382 ushort sen_gaddr2;
383 ushort sen_gaddr3; 383 ushort sen_gaddr3;
384 ushort sen_gaddr4; 384 ushort sen_gaddr4;
385 uint sen_tbuf0data0; /* Save area 0 - current frame */ 385 uint sen_tbuf0data0; /* Save area 0 - current frame */
386 uint sen_tbuf0data1; /* Save area 1 - current frame */ 386 uint sen_tbuf0data1; /* Save area 1 - current frame */
387 uint sen_tbuf0rba; /* Internal */ 387 uint sen_tbuf0rba; /* Internal */
388 uint sen_tbuf0crc; /* Internal */ 388 uint sen_tbuf0crc; /* Internal */
389 ushort sen_tbuf0bcnt; /* Internal */ 389 ushort sen_tbuf0bcnt; /* Internal */
390 ushort sen_paddrh; /* physical address (MSB) */ 390 ushort sen_paddrh; /* physical address (MSB) */
391 ushort sen_paddrm; 391 ushort sen_paddrm;
392 ushort sen_paddrl; /* physical address (LSB) */ 392 ushort sen_paddrl; /* physical address (LSB) */
393 ushort sen_pper; /* persistence */ 393 ushort sen_pper; /* persistence */
394 ushort sen_rfbdptr; /* Rx first BD pointer */ 394 ushort sen_rfbdptr; /* Rx first BD pointer */
395 ushort sen_tfbdptr; /* Tx first BD pointer */ 395 ushort sen_tfbdptr; /* Tx first BD pointer */
396 ushort sen_tlbdptr; /* Tx last BD pointer */ 396 ushort sen_tlbdptr; /* Tx last BD pointer */
397 uint sen_tbuf1data0; /* Save area 0 - current frame */ 397 uint sen_tbuf1data0; /* Save area 0 - current frame */
398 uint sen_tbuf1data1; /* Save area 1 - current frame */ 398 uint sen_tbuf1data1; /* Save area 1 - current frame */
399 uint sen_tbuf1rba; /* Internal */ 399 uint sen_tbuf1rba; /* Internal */
400 uint sen_tbuf1crc; /* Internal */ 400 uint sen_tbuf1crc; /* Internal */
401 ushort sen_tbuf1bcnt; /* Internal */ 401 ushort sen_tbuf1bcnt; /* Internal */
402 ushort sen_txlen; /* Tx Frame length counter */ 402 ushort sen_txlen; /* Tx Frame length counter */
403 ushort sen_iaddr1; /* Individual address filter */ 403 ushort sen_iaddr1; /* Individual address filter */
404 ushort sen_iaddr2; 404 ushort sen_iaddr2;
405 ushort sen_iaddr3; 405 ushort sen_iaddr3;
406 ushort sen_iaddr4; 406 ushort sen_iaddr4;
407 ushort sen_boffcnt; /* Backoff counter */ 407 ushort sen_boffcnt; /* Backoff counter */
408 408
409 /* NOTE: Some versions of the manual have the following items 409 /* NOTE: Some versions of the manual have the following items
410 * incorrectly documented. Below is the proper order. 410 * incorrectly documented. Below is the proper order.
411 */ 411 */
412 ushort sen_taddrh; /* temp address (MSB) */ 412 ushort sen_taddrh; /* temp address (MSB) */
413 ushort sen_taddrm; 413 ushort sen_taddrm;
414 ushort sen_taddrl; /* temp address (LSB) */ 414 ushort sen_taddrl; /* temp address (LSB) */
415 } scc_enet_t; 415 } scc_enet_t;
416 416
417 /********************************************************************** 417 /**********************************************************************
418 * 418 *
419 * Board specific configuration settings. 419 * Board specific configuration settings.
420 * 420 *
421 * Please note that we use the presence of a #define SCC_ENET and/or 421 * Please note that we use the presence of a #define SCC_ENET and/or
422 * #define FEC_ENET to enable the SCC resp. FEC ethernet drivers. 422 * #define FEC_ENET to enable the SCC resp. FEC ethernet drivers.
423 **********************************************************************/ 423 **********************************************************************/
424 424
425 425
426 /*** ADS *************************************************************/ 426 /*** ADS *************************************************************/
427 427
428 #if defined(CONFIG_MPC860) && defined(CONFIG_ADS) 428 #if defined(CONFIG_MPC860) && defined(CONFIG_ADS)
429 /* This ENET stuff is for the MPC860ADS with ethernet on SCC1. 429 /* This ENET stuff is for the MPC860ADS with ethernet on SCC1.
430 */ 430 */
431 431
432 #define PROFF_ENET PROFF_SCC1 432 #define PROFF_ENET PROFF_SCC1
433 #define CPM_CR_ENET CPM_CR_CH_SCC1 433 #define CPM_CR_ENET CPM_CR_CH_SCC1
434 #define SCC_ENET 0 434 #define SCC_ENET 0
435 435
436 #define PA_ENET_RXD ((ushort)0x0001) 436 #define PA_ENET_RXD ((ushort)0x0001)
437 #define PA_ENET_TXD ((ushort)0x0002) 437 #define PA_ENET_TXD ((ushort)0x0002)
438 #define PA_ENET_TCLK ((ushort)0x0100) 438 #define PA_ENET_TCLK ((ushort)0x0100)
439 #define PA_ENET_RCLK ((ushort)0x0200) 439 #define PA_ENET_RCLK ((ushort)0x0200)
440 440
441 #define PB_ENET_TENA ((uint)0x00001000) 441 #define PB_ENET_TENA ((uint)0x00001000)
442 442
443 #define PC_ENET_CLSN ((ushort)0x0010) 443 #define PC_ENET_CLSN ((ushort)0x0010)
444 #define PC_ENET_RENA ((ushort)0x0020) 444 #define PC_ENET_RENA ((ushort)0x0020)
445 445
446 #define SICR_ENET_MASK ((uint)0x000000ff) 446 #define SICR_ENET_MASK ((uint)0x000000ff)
447 #define SICR_ENET_CLKRT ((uint)0x0000002c) 447 #define SICR_ENET_CLKRT ((uint)0x0000002c)
448 448
449 /* 68160 PHY control */ 449 /* 68160 PHY control */
450 450
451 #define PC_ENET_ETHLOOP ((ushort)0x0800) 451 #define PC_ENET_ETHLOOP ((ushort)0x0800)
452 #define PC_ENET_TPFLDL ((ushort)0x0400) 452 #define PC_ENET_TPFLDL ((ushort)0x0400)
453 #define PC_ENET_TPSQEL ((ushort)0x0200) 453 #define PC_ENET_TPSQEL ((ushort)0x0200)
454 454
455 #endif /* MPC860ADS */ 455 #endif /* MPC860ADS */
456 456
457 /*** AMX860 **********************************************/ 457 /*** AMX860 **********************************************/
458 458
459 #if defined(CONFIG_AMX860) 459 #if defined(CONFIG_AMX860)
460 460
461 /* This ENET stuff is for the AMX860 with ethernet on SCC1. 461 /* This ENET stuff is for the AMX860 with ethernet on SCC1.
462 */ 462 */
463 463
464 #define PROFF_ENET PROFF_SCC1 464 #define PROFF_ENET PROFF_SCC1
465 #define CPM_CR_ENET CPM_CR_CH_SCC1 465 #define CPM_CR_ENET CPM_CR_CH_SCC1
466 #define SCC_ENET 0 466 #define SCC_ENET 0
467 467
468 #define PA_ENET_RXD ((ushort)0x0001) 468 #define PA_ENET_RXD ((ushort)0x0001)
469 #define PA_ENET_TXD ((ushort)0x0002) 469 #define PA_ENET_TXD ((ushort)0x0002)
470 #define PA_ENET_TCLK ((ushort)0x0400) 470 #define PA_ENET_TCLK ((ushort)0x0400)
471 #define PA_ENET_RCLK ((ushort)0x0800) 471 #define PA_ENET_RCLK ((ushort)0x0800)
472 472
473 #define PB_ENET_TENA ((uint)0x00001000) 473 #define PB_ENET_TENA ((uint)0x00001000)
474 474
475 #define PC_ENET_CLSN ((ushort)0x0010) 475 #define PC_ENET_CLSN ((ushort)0x0010)
476 #define PC_ENET_RENA ((ushort)0x0020) 476 #define PC_ENET_RENA ((ushort)0x0020)
477 477
478 #define SICR_ENET_MASK ((uint)0x000000ff) 478 #define SICR_ENET_MASK ((uint)0x000000ff)
479 #define SICR_ENET_CLKRT ((uint)0x0000003e) 479 #define SICR_ENET_CLKRT ((uint)0x0000003e)
480 480
481 /* 68160 PHY control */ 481 /* 68160 PHY control */
482 482
483 #define PB_ENET_ETHLOOP ((uint)0x00020000) 483 #define PB_ENET_ETHLOOP ((uint)0x00020000)
484 #define PB_ENET_TPFLDL ((uint)0x00010000) 484 #define PB_ENET_TPFLDL ((uint)0x00010000)
485 #define PB_ENET_TPSQEL ((uint)0x00008000) 485 #define PB_ENET_TPSQEL ((uint)0x00008000)
486 #define PD_ENET_ETH_EN ((ushort)0x0004) 486 #define PD_ENET_ETH_EN ((ushort)0x0004)
487 487
488 #endif /* CONFIG_AMX860 */ 488 #endif /* CONFIG_AMX860 */
489 489
490 /*** BSEIP **********************************************************/ 490 /*** BSEIP **********************************************************/
491 491
492 #ifdef CONFIG_BSEIP 492 #ifdef CONFIG_BSEIP
493 /* This ENET stuff is for the MPC823 with ethernet on SCC2. 493 /* This ENET stuff is for the MPC823 with ethernet on SCC2.
494 * This is unique to the BSE ip-Engine board. 494 * This is unique to the BSE ip-Engine board.
495 */ 495 */
496 #define PROFF_ENET PROFF_SCC2 496 #define PROFF_ENET PROFF_SCC2
497 #define CPM_CR_ENET CPM_CR_CH_SCC2 497 #define CPM_CR_ENET CPM_CR_CH_SCC2
498 #define SCC_ENET 1 498 #define SCC_ENET 1
499 #define PA_ENET_RXD ((ushort)0x0004) 499 #define PA_ENET_RXD ((ushort)0x0004)
500 #define PA_ENET_TXD ((ushort)0x0008) 500 #define PA_ENET_TXD ((ushort)0x0008)
501 #define PA_ENET_TCLK ((ushort)0x0100) 501 #define PA_ENET_TCLK ((ushort)0x0100)
502 #define PA_ENET_RCLK ((ushort)0x0200) 502 #define PA_ENET_RCLK ((ushort)0x0200)
503 #define PB_ENET_TENA ((uint)0x00002000) 503 #define PB_ENET_TENA ((uint)0x00002000)
504 #define PC_ENET_CLSN ((ushort)0x0040) 504 #define PC_ENET_CLSN ((ushort)0x0040)
505 #define PC_ENET_RENA ((ushort)0x0080) 505 #define PC_ENET_RENA ((ushort)0x0080)
506 506
507 /* BSE uses port B and C bits for PHY control also. 507 /* BSE uses port B and C bits for PHY control also.
508 */ 508 */
509 #define PB_BSE_POWERUP ((uint)0x00000004) 509 #define PB_BSE_POWERUP ((uint)0x00000004)
510 #define PB_BSE_FDXDIS ((uint)0x00008000) 510 #define PB_BSE_FDXDIS ((uint)0x00008000)
511 #define PC_BSE_LOOPBACK ((ushort)0x0800) 511 #define PC_BSE_LOOPBACK ((ushort)0x0800)
512 512
513 #define SICR_ENET_MASK ((uint)0x0000ff00) 513 #define SICR_ENET_MASK ((uint)0x0000ff00)
514 #define SICR_ENET_CLKRT ((uint)0x00002c00) 514 #define SICR_ENET_CLKRT ((uint)0x00002c00)
515 #endif /* CONFIG_BSEIP */ 515 #endif /* CONFIG_BSEIP */
516 516
517 /*** BSEIP **********************************************************/ 517 /*** BSEIP **********************************************************/
518 518
519 #ifdef CONFIG_FLAGADM 519 #ifdef CONFIG_FLAGADM
520 /* Enet configuration for the FLAGADM */ 520 /* Enet configuration for the FLAGADM */
521 /* Enet on SCC2 */ 521 /* Enet on SCC2 */
522 522
523 #define PROFF_ENET PROFF_SCC2 523 #define PROFF_ENET PROFF_SCC2
524 #define CPM_CR_ENET CPM_CR_CH_SCC2 524 #define CPM_CR_ENET CPM_CR_CH_SCC2
525 #define SCC_ENET 1 525 #define SCC_ENET 1
526 #define PA_ENET_RXD ((ushort)0x0004) 526 #define PA_ENET_RXD ((ushort)0x0004)
527 #define PA_ENET_TXD ((ushort)0x0008) 527 #define PA_ENET_TXD ((ushort)0x0008)
528 #define PA_ENET_TCLK ((ushort)0x0100) 528 #define PA_ENET_TCLK ((ushort)0x0100)
529 #define PA_ENET_RCLK ((ushort)0x0400) 529 #define PA_ENET_RCLK ((ushort)0x0400)
530 #define PB_ENET_TENA ((uint)0x00002000) 530 #define PB_ENET_TENA ((uint)0x00002000)
531 #define PC_ENET_CLSN ((ushort)0x0040) 531 #define PC_ENET_CLSN ((ushort)0x0040)
532 #define PC_ENET_RENA ((ushort)0x0080) 532 #define PC_ENET_RENA ((ushort)0x0080)
533 533
534 #define SICR_ENET_MASK ((uint)0x0000ff00) 534 #define SICR_ENET_MASK ((uint)0x0000ff00)
535 #define SICR_ENET_CLKRT ((uint)0x00003400) 535 #define SICR_ENET_CLKRT ((uint)0x00003400)
536 #endif /* CONFIG_FLAGADM */ 536 #endif /* CONFIG_FLAGADM */
537 537
538 /*** C2MON **********************************************************/ 538 /*** C2MON **********************************************************/
539 539
540 #ifdef CONFIG_C2MON 540 #ifdef CONFIG_C2MON
541 541
542 # ifndef CONFIG_FEC_ENET /* use SCC for 10Mbps Ethernet */ 542 # ifndef CONFIG_FEC_ENET /* use SCC for 10Mbps Ethernet */
543 # error "Ethernet on SCC not supported on C2MON Board!" 543 # error "Ethernet on SCC not supported on C2MON Board!"
544 # else /* Use FEC for Fast Ethernet */ 544 # else /* Use FEC for Fast Ethernet */
545 545
546 #undef SCC_ENET 546 #undef SCC_ENET
547 #define FEC_ENET 547 #define FEC_ENET
548 548
549 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */ 549 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */
550 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */ 550 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */
551 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */ 551 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */
552 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */ 552 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */
553 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */ 553 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */
554 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */ 554 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */
555 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */ 555 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */
556 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */ 556 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */
557 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */ 557 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */
558 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */ 558 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */
559 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */ 559 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */
560 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */ 560 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */
561 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */ 561 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */
562 562
563 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */ 563 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */
564 564
565 # endif /* CONFIG_FEC_ENET */ 565 # endif /* CONFIG_FEC_ENET */
566 #endif /* CONFIG_C2MON */ 566 #endif /* CONFIG_C2MON */
567 567
568 /*********************************************************************/ 568 /*********************************************************************/
569 569
570 570
571 /*** CCM and PCU E ***********************************************/ 571 /*** CCM and PCU E ***********************************************/
572 572
573 /* The PCU E and CCM use the FEC on a MPC860T for Ethernet */ 573 /* The PCU E and CCM use the FEC on a MPC860T for Ethernet */
574 574
575 #if defined (CONFIG_PCU_E) || defined(CONFIG_CCM) 575 #if defined (CONFIG_PCU_E) || defined(CONFIG_CCM)
576 576
577 #define FEC_ENET /* use FEC for EThernet */ 577 #define FEC_ENET /* use FEC for EThernet */
578 #undef SCC_ENET 578 #undef SCC_ENET
579 579
580 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */ 580 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */
581 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */ 581 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */
582 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */ 582 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */
583 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */ 583 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */
584 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */ 584 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */
585 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */ 585 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */
586 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */ 586 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */
587 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */ 587 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */
588 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */ 588 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */
589 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */ 589 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */
590 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */ 590 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */
591 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */ 591 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */
592 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */ 592 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */
593 593
594 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */ 594 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */
595 595
596 #endif /* CONFIG_PCU_E, CONFIG_CCM */ 596 #endif /* CONFIG_PCU_E, CONFIG_CCM */
597 597
598 /*** ESTEEM 192E **************************************************/ 598 /*** ESTEEM 192E **************************************************/
599 #ifdef CONFIG_ESTEEM192E 599 #ifdef CONFIG_ESTEEM192E
600 /* ESTEEM192E 600 /* ESTEEM192E
601 * This ENET stuff is for the MPC850 with ethernet on SCC2. This 601 * This ENET stuff is for the MPC850 with ethernet on SCC2. This
602 * is very similar to the RPX-Lite configuration. 602 * is very similar to the RPX-Lite configuration.
603 * Note TENA , LOOPBACK , FDPLEX_DIS on Port B. 603 * Note TENA , LOOPBACK , FDPLEX_DIS on Port B.
604 */ 604 */
605 605
606 #define PROFF_ENET PROFF_SCC2 606 #define PROFF_ENET PROFF_SCC2
607 #define CPM_CR_ENET CPM_CR_CH_SCC2 607 #define CPM_CR_ENET CPM_CR_CH_SCC2
608 #define SCC_ENET 1 608 #define SCC_ENET 1
609 609
610 #define PA_ENET_RXD ((ushort)0x0004) 610 #define PA_ENET_RXD ((ushort)0x0004)
611 #define PA_ENET_TXD ((ushort)0x0008) 611 #define PA_ENET_TXD ((ushort)0x0008)
612 #define PA_ENET_TCLK ((ushort)0x0200) 612 #define PA_ENET_TCLK ((ushort)0x0200)
613 #define PA_ENET_RCLK ((ushort)0x0800) 613 #define PA_ENET_RCLK ((ushort)0x0800)
614 #define PB_ENET_TENA ((uint)0x00002000) 614 #define PB_ENET_TENA ((uint)0x00002000)
615 #define PC_ENET_CLSN ((ushort)0x0040) 615 #define PC_ENET_CLSN ((ushort)0x0040)
616 #define PC_ENET_RENA ((ushort)0x0080) 616 #define PC_ENET_RENA ((ushort)0x0080)
617 617
618 #define SICR_ENET_MASK ((uint)0x0000ff00) 618 #define SICR_ENET_MASK ((uint)0x0000ff00)
619 #define SICR_ENET_CLKRT ((uint)0x00003d00) 619 #define SICR_ENET_CLKRT ((uint)0x00003d00)
620 620
621 #define PB_ENET_LOOPBACK ((uint)0x00004000) 621 #define PB_ENET_LOOPBACK ((uint)0x00004000)
622 #define PB_ENET_FDPLEX_DIS ((uint)0x00008000) 622 #define PB_ENET_FDPLEX_DIS ((uint)0x00008000)
623 623
624 #endif 624 #endif
625 625
626 /*** FADS823 ********************************************************/ 626 /*** FADS823 ********************************************************/
627 627
628 #if defined(CONFIG_MPC823FADS) && defined(CONFIG_FADS) 628 #if defined(CONFIG_MPC823FADS) && defined(CONFIG_FADS)
629 /* This ENET stuff is for the MPC823FADS with ethernet on SCC2. 629 /* This ENET stuff is for the MPC823FADS with ethernet on SCC2.
630 */ 630 */
631 #ifdef CONFIG_SCC2_ENET 631 #ifdef CONFIG_SCC2_ENET
632 #define PROFF_ENET PROFF_SCC2 632 #define PROFF_ENET PROFF_SCC2
633 #define CPM_CR_ENET CPM_CR_CH_SCC2 633 #define CPM_CR_ENET CPM_CR_CH_SCC2
634 #define SCC_ENET 1 634 #define SCC_ENET 1
635 #define CPMVEC_ENET CPMVEC_SCC2 635 #define CPMVEC_ENET CPMVEC_SCC2
636 #endif 636 #endif
637 637
638 #ifdef CONFIG_SCC1_ENET 638 #ifdef CONFIG_SCC1_ENET
639 #define PROFF_ENET PROFF_SCC1 639 #define PROFF_ENET PROFF_SCC1
640 #define CPM_CR_ENET CPM_CR_CH_SCC1 640 #define CPM_CR_ENET CPM_CR_CH_SCC1
641 #define SCC_ENET 0 641 #define SCC_ENET 0
642 #define CPMVEC_ENET CPMVEC_SCC1 642 #define CPMVEC_ENET CPMVEC_SCC1
643 #endif 643 #endif
644 644
645 #define PA_ENET_RXD ((ushort)0x0004) 645 #define PA_ENET_RXD ((ushort)0x0004)
646 #define PA_ENET_TXD ((ushort)0x0008) 646 #define PA_ENET_TXD ((ushort)0x0008)
647 #define PA_ENET_TCLK ((ushort)0x0400) 647 #define PA_ENET_TCLK ((ushort)0x0400)
648 #define PA_ENET_RCLK ((ushort)0x0200) 648 #define PA_ENET_RCLK ((ushort)0x0200)
649 649
650 #define PB_ENET_TENA ((uint)0x00002000) 650 #define PB_ENET_TENA ((uint)0x00002000)
651 651
652 #define PC_ENET_CLSN ((ushort)0x0040) 652 #define PC_ENET_CLSN ((ushort)0x0040)
653 #define PC_ENET_RENA ((ushort)0x0080) 653 #define PC_ENET_RENA ((ushort)0x0080)
654 654
655 #define SICR_ENET_MASK ((uint)0x0000ff00) 655 #define SICR_ENET_MASK ((uint)0x0000ff00)
656 #define SICR_ENET_CLKRT ((uint)0x00002e00) 656 #define SICR_ENET_CLKRT ((uint)0x00002e00)
657 657
658 #endif /* CONFIG_FADS823FADS */ 658 #endif /* CONFIG_FADS823FADS */
659 659
660 /*** FADS850SAR ********************************************************/ 660 /*** FADS850SAR ********************************************************/
661 661
662 #if defined(CONFIG_MPC850SAR) && defined(CONFIG_FADS) 662 #if defined(CONFIG_MPC850SAR) && defined(CONFIG_FADS)
663 /* This ENET stuff is for the MPC850SAR with ethernet on SCC2. Some of 663 /* This ENET stuff is for the MPC850SAR with ethernet on SCC2. Some of
664 * this may be unique to the FADS850SAR configuration. 664 * this may be unique to the FADS850SAR configuration.
665 * Note TENA is on Port B. 665 * Note TENA is on Port B.
666 */ 666 */
667 #define PROFF_ENET PROFF_SCC2 667 #define PROFF_ENET PROFF_SCC2
668 #define CPM_CR_ENET CPM_CR_CH_SCC2 668 #define CPM_CR_ENET CPM_CR_CH_SCC2
669 #define SCC_ENET 1 669 #define SCC_ENET 1
670 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 670 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
671 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 671 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
672 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 672 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
673 #define PA_ENET_TCLK ((ushort)0x0800) /* PA 4 */ 673 #define PA_ENET_TCLK ((ushort)0x0800) /* PA 4 */
674 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 674 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
675 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 675 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
676 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 676 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
677 677
678 #define SICR_ENET_MASK ((uint)0x0000ff00) 678 #define SICR_ENET_MASK ((uint)0x0000ff00)
679 #define SICR_ENET_CLKRT ((uint)0x00002f00) /* RCLK-CLK2, TCLK-CLK4 */ 679 #define SICR_ENET_CLKRT ((uint)0x00002f00) /* RCLK-CLK2, TCLK-CLK4 */
680 #endif /* CONFIG_FADS850SAR */ 680 #endif /* CONFIG_FADS850SAR */
681 681
682 /*** FADS860T********************************************************/ 682 /*** FADS860T********************************************************/
683 683
684 #if defined(CONFIG_MPC860T) && defined(CONFIG_FADS) 684 #if defined(CONFIG_MPC860T) && defined(CONFIG_FADS)
685 /* This ENET stuff is for the MPC860TFADS with ethernet on SCC1. 685 /* This ENET stuff is for the MPC860TFADS with ethernet on SCC1.
686 */ 686 */
687 687
688 #ifdef CONFIG_SCC1_ENET 688 #ifdef CONFIG_SCC1_ENET
689 #define SCC_ENET 0 689 #define SCC_ENET 0
690 #endif /* CONFIG_SCC1_ETHERNET */ 690 #endif /* CONFIG_SCC1_ETHERNET */
691 #define PROFF_ENET PROFF_SCC1 691 #define PROFF_ENET PROFF_SCC1
692 #define CPM_CR_ENET CPM_CR_CH_SCC1 692 #define CPM_CR_ENET CPM_CR_CH_SCC1
693 693
694 #define PA_ENET_RXD ((ushort)0x0001) 694 #define PA_ENET_RXD ((ushort)0x0001)
695 #define PA_ENET_TXD ((ushort)0x0002) 695 #define PA_ENET_TXD ((ushort)0x0002)
696 #define PA_ENET_TCLK ((ushort)0x0100) 696 #define PA_ENET_TCLK ((ushort)0x0100)
697 #define PA_ENET_RCLK ((ushort)0x0200) 697 #define PA_ENET_RCLK ((ushort)0x0200)
698 698
699 #define PB_ENET_TENA ((uint)0x00001000) 699 #define PB_ENET_TENA ((uint)0x00001000)
700 700
701 #define PC_ENET_CLSN ((ushort)0x0010) 701 #define PC_ENET_CLSN ((ushort)0x0010)
702 #define PC_ENET_RENA ((ushort)0x0020) 702 #define PC_ENET_RENA ((ushort)0x0020)
703 703
704 #define SICR_ENET_MASK ((uint)0x000000ff) 704 #define SICR_ENET_MASK ((uint)0x000000ff)
705 #define SICR_ENET_CLKRT ((uint)0x0000002c) 705 #define SICR_ENET_CLKRT ((uint)0x0000002c)
706 706
707 /* This ENET stuff is for the MPC860TFADS with ethernet on FEC. 707 /* This ENET stuff is for the MPC860TFADS with ethernet on FEC.
708 */ 708 */
709 709
710 #ifdef CONFIG_FEC_ENET 710 #ifdef CONFIG_FEC_ENET
711 #define FEC_ENET /* use FEC for EThernet */ 711 #define FEC_ENET /* use FEC for EThernet */
712 #endif /* CONFIG_FEC_ETHERNET */ 712 #endif /* CONFIG_FEC_ETHERNET */
713 713
714 #endif /* CONFIG_FADS860T */ 714 #endif /* CONFIG_FADS860T */
715 715
716 /*** FPS850L, FPS860L ************************************************/ 716 /*** FPS850L, FPS860L ************************************************/
717 717
718 #if defined(CONFIG_FPS850L) || defined(CONFIG_FPS860L) 718 #if defined(CONFIG_FPS850L) || defined(CONFIG_FPS860L)
719 /* Bits in parallel I/O port registers that have to be set/cleared 719 /* Bits in parallel I/O port registers that have to be set/cleared
720 * to configure the pins for SCC2 use. 720 * to configure the pins for SCC2 use.
721 */ 721 */
722 #define PROFF_ENET PROFF_SCC2 722 #define PROFF_ENET PROFF_SCC2
723 #define CPM_CR_ENET CPM_CR_CH_SCC2 723 #define CPM_CR_ENET CPM_CR_CH_SCC2
724 #define SCC_ENET 1 724 #define SCC_ENET 1
725 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 725 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
726 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 726 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
727 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */ 727 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
728 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 728 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
729 729
730 #define PC_ENET_TENA ((ushort)0x0002) /* PC 14 */ 730 #define PC_ENET_TENA ((ushort)0x0002) /* PC 14 */
731 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 731 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
732 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 732 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
733 733
734 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to 734 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to
735 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero. 735 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
736 */ 736 */
737 #define SICR_ENET_MASK ((uint)0x0000ff00) 737 #define SICR_ENET_MASK ((uint)0x0000ff00)
738 #define SICR_ENET_CLKRT ((uint)0x00002600) 738 #define SICR_ENET_CLKRT ((uint)0x00002600)
739 #endif /* CONFIG_FPS850L, CONFIG_FPS860L */ 739 #endif /* CONFIG_FPS850L, CONFIG_FPS860L */
740 740
741 /*** GEN860T **********************************************************/ 741 /*** GEN860T **********************************************************/
742 #if defined(CONFIG_GEN860T) 742 #if defined(CONFIG_GEN860T)
743 #undef SCC_ENET 743 #undef SCC_ENET
744 #define FEC_ENET 744 #define FEC_ENET
745 745
746 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */ 746 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */
747 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */ 747 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */
748 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */ 748 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */
749 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */ 749 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */
750 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */ 750 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */
751 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */ 751 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */
752 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */ 752 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */
753 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */ 753 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */
754 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */ 754 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */
755 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */ 755 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */
756 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */ 756 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */
757 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */ 757 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */
758 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */ 758 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */
759 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3-15 */ 759 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3-15 */
760 #endif /* CONFIG_GEN860T */ 760 #endif /* CONFIG_GEN860T */
761 761
762 /*** GENIETV ********************************************************/ 762 /*** GENIETV ********************************************************/
763 763
764 #if defined(CONFIG_GENIETV) 764 #if defined(CONFIG_GENIETV)
765 /* Ethernet is only on SCC2 */ 765 /* Ethernet is only on SCC2 */
766 766
767 #define CONFIG_SCC2_ENET 767 #define CONFIG_SCC2_ENET
768 #define PROFF_ENET PROFF_SCC2 768 #define PROFF_ENET PROFF_SCC2
769 #define CPM_CR_ENET CPM_CR_CH_SCC2 769 #define CPM_CR_ENET CPM_CR_CH_SCC2
770 #define SCC_ENET 1 770 #define SCC_ENET 1
771 #define CPMVEC_ENET CPMVEC_SCC2 771 #define CPMVEC_ENET CPMVEC_SCC2
772 772
773 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 773 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
774 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 774 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
775 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 775 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
776 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 776 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
777 777
778 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 778 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
779 779
780 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 780 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
781 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 781 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
782 782
783 #define SICR_ENET_MASK ((uint)0x0000ff00) 783 #define SICR_ENET_MASK ((uint)0x0000ff00)
784 #define SICR_ENET_CLKRT ((uint)0x00002e00) 784 #define SICR_ENET_CLKRT ((uint)0x00002e00)
785 785
786 #endif /* CONFIG_GENIETV */ 786 #endif /* CONFIG_GENIETV */
787 787
788 /*** GTH ******************************************************/ 788 /*** GTH ******************************************************/
789 789
790 #ifdef CONFIG_GTH 790 #ifdef CONFIG_GTH
791 #ifdef CONFIG_FEC_ENET 791 #ifdef CONFIG_FEC_ENET
792 #define FEC_ENET /* use FEC for EThernet */ 792 #define FEC_ENET /* use FEC for EThernet */
793 #endif /* CONFIG_FEC_ETHERNET */ 793 #endif /* CONFIG_FEC_ETHERNET */
794 794
795 /* This ENET stuff is for GTH 10 Mbit ( SCC ) */ 795 /* This ENET stuff is for GTH 10 Mbit ( SCC ) */
796 #define PROFF_ENET PROFF_SCC1 796 #define PROFF_ENET PROFF_SCC1
797 #define CPM_CR_ENET CPM_CR_CH_SCC1 797 #define CPM_CR_ENET CPM_CR_CH_SCC1
798 #define SCC_ENET 0 798 #define SCC_ENET 0
799 799
800 #define PA_ENET_RXD ((ushort)0x0001) /* PA15 */ 800 #define PA_ENET_RXD ((ushort)0x0001) /* PA15 */
801 #define PA_ENET_TXD ((ushort)0x0002) /* PA14 */ 801 #define PA_ENET_TXD ((ushort)0x0002) /* PA14 */
802 #define PA_ENET_TCLK ((ushort)0x0800) /* PA4 */ 802 #define PA_ENET_TCLK ((ushort)0x0800) /* PA4 */
803 #define PA_ENET_RCLK ((ushort)0x0400) /* PA5 */ 803 #define PA_ENET_RCLK ((ushort)0x0400) /* PA5 */
804 804
805 #define PB_ENET_TENA ((uint)0x00001000) /* PB19 */ 805 #define PB_ENET_TENA ((uint)0x00001000) /* PB19 */
806 806
807 #define PC_ENET_CLSN ((ushort)0x0010) /* PC11 */ 807 #define PC_ENET_CLSN ((ushort)0x0010) /* PC11 */
808 #define PC_ENET_RENA ((ushort)0x0020) /* PC10 */ 808 #define PC_ENET_RENA ((ushort)0x0020) /* PC10 */
809 809
810 /* NOTE. This is reset for 10Mbit port only */ 810 /* NOTE. This is reset for 10Mbit port only */
811 #define PC_ENET_RESET ((ushort)0x0100) /* PC 7 */ 811 #define PC_ENET_RESET ((ushort)0x0100) /* PC 7 */
812 812
813 #define SICR_ENET_MASK ((uint)0x000000ff) 813 #define SICR_ENET_MASK ((uint)0x000000ff)
814 814
815 /* TCLK PA4 -->CLK4, RCLK PA5 -->CLK3 */ 815 /* TCLK PA4 -->CLK4, RCLK PA5 -->CLK3 */
816 #define SICR_ENET_CLKRT ((uint)0x00000037) 816 #define SICR_ENET_CLKRT ((uint)0x00000037)
817 817
818 #endif /* CONFIG_GTH */ 818 #endif /* CONFIG_GTH */
819 819
820 /*** HERMES-PRO ******************************************************/ 820 /*** HERMES-PRO ******************************************************/
821 821
822 /* The HERMES-PRO uses the FEC on a MPC860T for Ethernet */ 822 /* The HERMES-PRO uses the FEC on a MPC860T for Ethernet */
823 823
824 #ifdef CONFIG_HERMES 824 #ifdef CONFIG_HERMES
825 825
826 #define FEC_ENET /* use FEC for EThernet */ 826 #define FEC_ENET /* use FEC for EThernet */
827 #undef SCC_ENET 827 #undef SCC_ENET
828 828
829 829
830 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */ 830 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */
831 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */ 831 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */
832 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */ 832 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */
833 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */ 833 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */
834 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */ 834 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */
835 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */ 835 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */
836 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */ 836 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */
837 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */ 837 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */
838 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */ 838 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */
839 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */ 839 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */
840 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */ 840 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */
841 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */ 841 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */
842 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */ 842 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */
843 843
844 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */ 844 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */
845 845
846 #endif /* CONFIG_HERMES */ 846 #endif /* CONFIG_HERMES */
847 847
848 /*** IAD210 **********************************************************/ 848 /*** IAD210 **********************************************************/
849 849
850 /* The IAD210 uses the FEC on a MPC860P for Ethernet */ 850 /* The IAD210 uses the FEC on a MPC860P for Ethernet */
851 851
852 #if defined(CONFIG_IAD210) 852 #if defined(CONFIG_IAD210)
853 853
854 # define FEC_ENET /* use FEC for Ethernet */ 854 # define FEC_ENET /* use FEC for Ethernet */
855 # undef SCC_ENET 855 # undef SCC_ENET
856 856
857 # define PD_MII_TXD1 ((ushort) 0x1000 ) /* PD 3 */ 857 # define PD_MII_TXD1 ((ushort) 0x1000 ) /* PD 3 */
858 # define PD_MII_TXD2 ((ushort) 0x0800 ) /* PD 4 */ 858 # define PD_MII_TXD2 ((ushort) 0x0800 ) /* PD 4 */
859 # define PD_MII_TXD3 ((ushort) 0x0400 ) /* PD 5 */ 859 # define PD_MII_TXD3 ((ushort) 0x0400 ) /* PD 5 */
860 # define PD_MII_RX_DV ((ushort) 0x0200 ) /* PD 6 */ 860 # define PD_MII_RX_DV ((ushort) 0x0200 ) /* PD 6 */
861 # define PD_MII_RX_ERR ((ushort) 0x0100 ) /* PD 7 */ 861 # define PD_MII_RX_ERR ((ushort) 0x0100 ) /* PD 7 */
862 # define PD_MII_RX_CLK ((ushort) 0x0080 ) /* PD 8 */ 862 # define PD_MII_RX_CLK ((ushort) 0x0080 ) /* PD 8 */
863 # define PD_MII_TXD0 ((ushort) 0x0040 ) /* PD 9 */ 863 # define PD_MII_TXD0 ((ushort) 0x0040 ) /* PD 9 */
864 # define PD_MII_RXD0 ((ushort) 0x0020 ) /* PD 10 */ 864 # define PD_MII_RXD0 ((ushort) 0x0020 ) /* PD 10 */
865 # define PD_MII_TX_ERR ((ushort) 0x0010 ) /* PD 11 */ 865 # define PD_MII_TX_ERR ((ushort) 0x0010 ) /* PD 11 */
866 # define PD_MII_MDC ((ushort) 0x0008 ) /* PD 12 */ 866 # define PD_MII_MDC ((ushort) 0x0008 ) /* PD 12 */
867 # define PD_MII_RXD1 ((ushort) 0x0004 ) /* PD 13 */ 867 # define PD_MII_RXD1 ((ushort) 0x0004 ) /* PD 13 */
868 # define PD_MII_RXD2 ((ushort) 0x0002 ) /* PD 14 */ 868 # define PD_MII_RXD2 ((ushort) 0x0002 ) /* PD 14 */
869 # define PD_MII_RXD3 ((ushort) 0x0001 ) /* PD 15 */ 869 # define PD_MII_RXD3 ((ushort) 0x0001 ) /* PD 15 */
870 870
871 # define PD_MII_MASK ((ushort) 0x1FFF ) /* PD 3...15 */ 871 # define PD_MII_MASK ((ushort) 0x1FFF ) /* PD 3...15 */
872 872
873 #endif /* CONFIG_IAD210 */ 873 #endif /* CONFIG_IAD210 */
874 874
875 /*** ICU862 **********************************************************/ 875 /*** ICU862 **********************************************************/
876 876
877 #if defined(CONFIG_ICU862) 877 #if defined(CONFIG_ICU862)
878 878
879 #ifdef CONFIG_FEC_ENET 879 #ifdef CONFIG_FEC_ENET
880 #define FEC_ENET /* use FEC for EThernet */ 880 #define FEC_ENET /* use FEC for EThernet */
881 #endif /* CONFIG_FEC_ETHERNET */ 881 #endif /* CONFIG_FEC_ETHERNET */
882 882
883 #endif /* CONFIG_ICU862 */ 883 #endif /* CONFIG_ICU862 */
884 884
885 /*** IP860 **********************************************************/ 885 /*** IP860 **********************************************************/
886 886
887 #if defined(CONFIG_IP860) 887 #if defined(CONFIG_IP860)
888 /* Bits in parallel I/O port registers that have to be set/cleared 888 /* Bits in parallel I/O port registers that have to be set/cleared
889 * to configure the pins for SCC1 use. 889 * to configure the pins for SCC1 use.
890 */ 890 */
891 #define PROFF_ENET PROFF_SCC1 891 #define PROFF_ENET PROFF_SCC1
892 #define CPM_CR_ENET CPM_CR_CH_SCC1 892 #define CPM_CR_ENET CPM_CR_CH_SCC1
893 #define SCC_ENET 0 893 #define SCC_ENET 0
894 #define PA_ENET_RXD ((ushort)0x0001) /* PA 15 */ 894 #define PA_ENET_RXD ((ushort)0x0001) /* PA 15 */
895 #define PA_ENET_TXD ((ushort)0x0002) /* PA 14 */ 895 #define PA_ENET_TXD ((ushort)0x0002) /* PA 14 */
896 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 896 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
897 #define PA_ENET_TCLK ((ushort)0x0100) /* PA 7 */ 897 #define PA_ENET_TCLK ((ushort)0x0100) /* PA 7 */
898 898
899 #define PC_ENET_TENA ((ushort)0x0001) /* PC 15 */ 899 #define PC_ENET_TENA ((ushort)0x0001) /* PC 15 */
900 #define PC_ENET_CLSN ((ushort)0x0010) /* PC 11 */ 900 #define PC_ENET_CLSN ((ushort)0x0010) /* PC 11 */
901 #define PC_ENET_RENA ((ushort)0x0020) /* PC 10 */ 901 #define PC_ENET_RENA ((ushort)0x0020) /* PC 10 */
902 902
903 #define PB_ENET_RESET (uint)0x00000008 /* PB 28 */ 903 #define PB_ENET_RESET (uint)0x00000008 /* PB 28 */
904 #define PB_ENET_JABD (uint)0x00000004 /* PB 29 */ 904 #define PB_ENET_JABD (uint)0x00000004 /* PB 29 */
905 905
906 /* Control bits in the SICR to route TCLK (CLK1) and RCLK (CLK2) to 906 /* Control bits in the SICR to route TCLK (CLK1) and RCLK (CLK2) to
907 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero. 907 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero.
908 */ 908 */
909 #define SICR_ENET_MASK ((uint)0x000000ff) 909 #define SICR_ENET_MASK ((uint)0x000000ff)
910 #define SICR_ENET_CLKRT ((uint)0x0000002C) 910 #define SICR_ENET_CLKRT ((uint)0x0000002C)
911 #endif /* CONFIG_IP860 */ 911 #endif /* CONFIG_IP860 */
912 912
913 /*** IVMS8 **********************************************************/ 913 /*** IVMS8 **********************************************************/
914 914
915 /* The IVMS8 uses the FEC on a MPC860T for Ethernet */ 915 /* The IVMS8 uses the FEC on a MPC860T for Ethernet */
916 916
917 #if defined(CONFIG_IVMS8) || defined(CONFIG_IVML24) 917 #if defined(CONFIG_IVMS8) || defined(CONFIG_IVML24)
918 918
919 #define FEC_ENET /* use FEC for EThernet */ 919 #define FEC_ENET /* use FEC for EThernet */
920 #undef SCC_ENET 920 #undef SCC_ENET
921 921
922 #define PB_ENET_POWER ((uint)0x00010000) /* PB 15 */ 922 #define PB_ENET_POWER ((uint)0x00010000) /* PB 15 */
923 923
924 #define PC_ENET_RESET ((ushort)0x0010) /* PC 11 */ 924 #define PC_ENET_RESET ((ushort)0x0010) /* PC 11 */
925 925
926 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */ 926 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */
927 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */ 927 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */
928 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */ 928 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */
929 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */ 929 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */
930 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */ 930 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */
931 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */ 931 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */
932 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */ 932 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */
933 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */ 933 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */
934 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */ 934 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */
935 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */ 935 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */
936 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */ 936 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */
937 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */ 937 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */
938 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */ 938 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */
939 939
940 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */ 940 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */
941 941
942 #endif /* CONFIG_IVMS8, CONFIG_IVML24 */ 942 #endif /* CONFIG_IVMS8, CONFIG_IVML24 */
943 943
944 /*** KUP4K *********************************************************/ 944 /*** KUP4K *********************************************************/
945 /* The KUP4K uses the FEC on a MPC855T for Ethernet */ 945 /* The KUP4K uses the FEC on a MPC855T for Ethernet */
946 946
947 #if defined(CONFIG_KUP4K) 947 #if defined(CONFIG_KUP4K)
948 948
949 #define FEC_ENET /* use FEC for EThernet */ 949 #define FEC_ENET /* use FEC for EThernet */
950 #undef SCC_ENET 950 #undef SCC_ENET
951 951
952 #define PB_ENET_POWER ((uint)0x00010000) /* PB 15 */ 952 #define PB_ENET_POWER ((uint)0x00010000) /* PB 15 */
953 953
954 #define PC_ENET_RESET ((ushort)0x0010) /* PC 11 */ 954 #define PC_ENET_RESET ((ushort)0x0010) /* PC 11 */
955 955
956 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */ 956 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */
957 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */ 957 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */
958 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */ 958 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */
959 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */ 959 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */
960 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */ 960 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */
961 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */ 961 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */
962 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */ 962 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */
963 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */ 963 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */
964 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */ 964 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */
965 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */ 965 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */
966 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */ 966 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */
967 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */ 967 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */
968 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */ 968 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */
969 969
970 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */ 970 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */
971 971
972 #endif /* CONFIG_KUP4K */ 972 #endif /* CONFIG_KUP4K */
973 973
974 974
975 /*** LANTEC *********************************************************/ 975 /*** LANTEC *********************************************************/
976 976
977 #if defined(CONFIG_LANTEC) && CONFIG_LANTEC >= 2 977 #if defined(CONFIG_LANTEC) && CONFIG_LANTEC >= 2
978 /* Bits in parallel I/O port registers that have to be set/cleared 978 /* Bits in parallel I/O port registers that have to be set/cleared
979 * to configure the pins for SCC2 use. 979 * to configure the pins for SCC2 use.
980 */ 980 */
981 #define PROFF_ENET PROFF_SCC2 981 #define PROFF_ENET PROFF_SCC2
982 #define CPM_CR_ENET CPM_CR_CH_SCC2 982 #define CPM_CR_ENET CPM_CR_CH_SCC2
983 #define SCC_ENET 1 983 #define SCC_ENET 1
984 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 984 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
985 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 985 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
986 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 986 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
987 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 987 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
988 988
989 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 989 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
990 990
991 #define PC_ENET_LBK ((ushort)0x0010) /* PC 11 */ 991 #define PC_ENET_LBK ((ushort)0x0010) /* PC 11 */
992 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 992 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
993 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 993 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
994 994
995 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK2) to 995 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK2) to
996 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero. 996 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
997 */ 997 */
998 #define SICR_ENET_MASK ((uint)0x0000FF00) 998 #define SICR_ENET_MASK ((uint)0x0000FF00)
999 #define SICR_ENET_CLKRT ((uint)0x00002E00) 999 #define SICR_ENET_CLKRT ((uint)0x00002E00)
1000 #endif /* CONFIG_LANTEC v2 */ 1000 #endif /* CONFIG_LANTEC v2 */
1001 1001
1002 /*** LWMON **********************************************************/ 1002 /*** LWMON **********************************************************/
1003 1003
1004 #if defined(CONFIG_LWMON) && !defined(CONFIG_8xx_CONS_SCC2) 1004 #if defined(CONFIG_LWMON) && !defined(CONFIG_8xx_CONS_SCC2)
1005 /* Bits in parallel I/O port registers that have to be set/cleared 1005 /* Bits in parallel I/O port registers that have to be set/cleared
1006 * to configure the pins for SCC2 use. 1006 * to configure the pins for SCC2 use.
1007 */ 1007 */
1008 #define PROFF_ENET PROFF_SCC2 1008 #define PROFF_ENET PROFF_SCC2
1009 #define CPM_CR_ENET CPM_CR_CH_SCC2 1009 #define CPM_CR_ENET CPM_CR_CH_SCC2
1010 #define SCC_ENET 1 1010 #define SCC_ENET 1
1011 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 1011 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
1012 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 1012 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
1013 #define PA_ENET_RCLK ((ushort)0x0800) /* PA 4 */ 1013 #define PA_ENET_RCLK ((ushort)0x0800) /* PA 4 */
1014 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 1014 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
1015 1015
1016 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 1016 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
1017 1017
1018 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 1018 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
1019 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 1019 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
1020 1020
1021 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK4) to 1021 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK4) to
1022 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero. 1022 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
1023 */ 1023 */
1024 #define SICR_ENET_MASK ((uint)0x0000ff00) 1024 #define SICR_ENET_MASK ((uint)0x0000ff00)
1025 #define SICR_ENET_CLKRT ((uint)0x00003E00) 1025 #define SICR_ENET_CLKRT ((uint)0x00003E00)
1026 #endif /* CONFIG_LWMON */ 1026 #endif /* CONFIG_LWMON */
1027 1027
1028 /*** NX823 ***********************************************/ 1028 /*** NX823 ***********************************************/
1029 1029
1030 #if defined(CONFIG_NX823) 1030 #if defined(CONFIG_NX823)
1031 /* Bits in parallel I/O port registers that have to be set/cleared 1031 /* Bits in parallel I/O port registers that have to be set/cleared
1032 * to configure the pins for SCC1 use. 1032 * to configure the pins for SCC1 use.
1033 */ 1033 */
1034 #define PROFF_ENET PROFF_SCC2 1034 #define PROFF_ENET PROFF_SCC2
1035 #define CPM_CR_ENET CPM_CR_CH_SCC2 1035 #define CPM_CR_ENET CPM_CR_CH_SCC2
1036 #define SCC_ENET 1 1036 #define SCC_ENET 1
1037 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 1037 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
1038 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 1038 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
1039 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 1039 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
1040 #define PA_ENET_TCLK ((ushort)0x0800) /* PA 4 */ 1040 #define PA_ENET_TCLK ((ushort)0x0800) /* PA 4 */
1041 1041
1042 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 1042 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
1043 1043
1044 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 1044 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
1045 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 1045 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
1046 1046
1047 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to 1047 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
1048 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero. 1048 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
1049 */ 1049 */
1050 #define SICR_ENET_MASK ((uint)0x0000ff00) 1050 #define SICR_ENET_MASK ((uint)0x0000ff00)
1051 #define SICR_ENET_CLKRT ((uint)0x00002f00) 1051 #define SICR_ENET_CLKRT ((uint)0x00002f00)
1052 1052
1053 #endif /* CONFIG_NX823 */ 1053 #endif /* CONFIG_NX823 */
1054 1054
1055 /*** MBX ************************************************************/ 1055 /*** MBX ************************************************************/
1056 1056
1057 #ifdef CONFIG_MBX 1057 #ifdef CONFIG_MBX
1058 /* Bits in parallel I/O port registers that have to be set/cleared 1058 /* Bits in parallel I/O port registers that have to be set/cleared
1059 * to configure the pins for SCC1 use. The TCLK and RCLK seem unique 1059 * to configure the pins for SCC1 use. The TCLK and RCLK seem unique
1060 * to the MBX860 board. Any two of the four available clocks could be 1060 * to the MBX860 board. Any two of the four available clocks could be
1061 * used, and the MPC860 cookbook manual has an example using different 1061 * used, and the MPC860 cookbook manual has an example using different
1062 * clock pins. 1062 * clock pins.
1063 */ 1063 */
1064 #define PROFF_ENET PROFF_SCC1 1064 #define PROFF_ENET PROFF_SCC1
1065 #define CPM_CR_ENET CPM_CR_CH_SCC1 1065 #define CPM_CR_ENET CPM_CR_CH_SCC1
1066 #define SCC_ENET 0 1066 #define SCC_ENET 0
1067 #define PA_ENET_RXD ((ushort)0x0001) 1067 #define PA_ENET_RXD ((ushort)0x0001)
1068 #define PA_ENET_TXD ((ushort)0x0002) 1068 #define PA_ENET_TXD ((ushort)0x0002)
1069 #define PA_ENET_TCLK ((ushort)0x0200) 1069 #define PA_ENET_TCLK ((ushort)0x0200)
1070 #define PA_ENET_RCLK ((ushort)0x0800) 1070 #define PA_ENET_RCLK ((ushort)0x0800)
1071 #define PC_ENET_TENA ((ushort)0x0001) 1071 #define PC_ENET_TENA ((ushort)0x0001)
1072 #define PC_ENET_CLSN ((ushort)0x0010) 1072 #define PC_ENET_CLSN ((ushort)0x0010)
1073 #define PC_ENET_RENA ((ushort)0x0020) 1073 #define PC_ENET_RENA ((ushort)0x0020)
1074 1074
1075 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to 1075 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to
1076 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero. 1076 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero.
1077 */ 1077 */
1078 #define SICR_ENET_MASK ((uint)0x000000ff) 1078 #define SICR_ENET_MASK ((uint)0x000000ff)
1079 #define SICR_ENET_CLKRT ((uint)0x0000003d) 1079 #define SICR_ENET_CLKRT ((uint)0x0000003d)
1080 #endif /* CONFIG_MBX */ 1080 #endif /* CONFIG_MBX */
1081 1081
1082 /*** MHPC ********************************************************/ 1082 /*** MHPC ********************************************************/
1083 1083
1084 #if defined(CONFIG_MHPC) 1084 #if defined(CONFIG_MHPC)
1085 /* This ENET stuff is for the MHPC with ethernet on SCC2. 1085 /* This ENET stuff is for the MHPC with ethernet on SCC2.
1086 * Note TENA is on Port B. 1086 * Note TENA is on Port B.
1087 */ 1087 */
1088 #define PROFF_ENET PROFF_SCC2 1088 #define PROFF_ENET PROFF_SCC2
1089 #define CPM_CR_ENET CPM_CR_CH_SCC2 1089 #define CPM_CR_ENET CPM_CR_CH_SCC2
1090 #define SCC_ENET 1 1090 #define SCC_ENET 1
1091 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 1091 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
1092 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 1092 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
1093 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 1093 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
1094 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 1094 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
1095 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 1095 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
1096 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 1096 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
1097 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 1097 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
1098 1098
1099 #define SICR_ENET_MASK ((uint)0x0000ff00) 1099 #define SICR_ENET_MASK ((uint)0x0000ff00)
1100 #define SICR_ENET_CLKRT ((uint)0x00002e00) /* RCLK-CLK2, TCLK-CLK3 */ 1100 #define SICR_ENET_CLKRT ((uint)0x00002e00) /* RCLK-CLK2, TCLK-CLK3 */
1101 #endif /* CONFIG_MHPC */ 1101 #endif /* CONFIG_MHPC */
1102 1102
1103 /*** RPXCLASSIC *****************************************************/ 1103 /*** RPXCLASSIC *****************************************************/
1104 1104
1105 #ifdef CONFIG_RPXCLASSIC 1105 #ifdef CONFIG_RPXCLASSIC
1106 1106
1107 #ifdef CONFIG_FEC_ENET 1107 #ifdef CONFIG_FEC_ENET
1108 1108
1109 # define FEC_ENET /* use FEC for EThernet */ 1109 # define FEC_ENET /* use FEC for EThernet */
1110 # undef SCC_ENET 1110 # undef SCC_ENET
1111 1111
1112 #else /* ! CONFIG_FEC_ENET */ 1112 #else /* ! CONFIG_FEC_ENET */
1113 1113
1114 /* Bits in parallel I/O port registers that have to be set/cleared 1114 /* Bits in parallel I/O port registers that have to be set/cleared
1115 * to configure the pins for SCC1 use. 1115 * to configure the pins for SCC1 use.
1116 */ 1116 */
1117 #define PROFF_ENET PROFF_SCC1 1117 #define PROFF_ENET PROFF_SCC1
1118 #define CPM_CR_ENET CPM_CR_CH_SCC1 1118 #define CPM_CR_ENET CPM_CR_CH_SCC1
1119 #define SCC_ENET 0 1119 #define SCC_ENET 0
1120 #define PA_ENET_RXD ((ushort)0x0001) 1120 #define PA_ENET_RXD ((ushort)0x0001)
1121 #define PA_ENET_TXD ((ushort)0x0002) 1121 #define PA_ENET_TXD ((ushort)0x0002)
1122 #define PA_ENET_TCLK ((ushort)0x0200) 1122 #define PA_ENET_TCLK ((ushort)0x0200)
1123 #define PA_ENET_RCLK ((ushort)0x0800) 1123 #define PA_ENET_RCLK ((ushort)0x0800)
1124 #define PB_ENET_TENA ((uint)0x00001000) 1124 #define PB_ENET_TENA ((uint)0x00001000)
1125 #define PC_ENET_CLSN ((ushort)0x0010) 1125 #define PC_ENET_CLSN ((ushort)0x0010)
1126 #define PC_ENET_RENA ((ushort)0x0020) 1126 #define PC_ENET_RENA ((ushort)0x0020)
1127 1127
1128 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to 1128 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to
1129 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero. 1129 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero.
1130 */ 1130 */
1131 #define SICR_ENET_MASK ((uint)0x000000ff) 1131 #define SICR_ENET_MASK ((uint)0x000000ff)
1132 #define SICR_ENET_CLKRT ((uint)0x0000003d) 1132 #define SICR_ENET_CLKRT ((uint)0x0000003d)
1133 1133
1134 #endif /* CONFIG_FEC_ENET */ 1134 #endif /* CONFIG_FEC_ENET */
1135 1135
1136 #endif /* CONFIG_RPXCLASSIC */ 1136 #endif /* CONFIG_RPXCLASSIC */
1137 1137
1138 /*** RPXLITE ********************************************************/ 1138 /*** RPXLITE ********************************************************/
1139 1139
1140 #ifdef CONFIG_RPXLITE 1140 #ifdef CONFIG_RPXLITE
1141 /* This ENET stuff is for the MPC850 with ethernet on SCC2. Some of 1141 /* This ENET stuff is for the MPC850 with ethernet on SCC2. Some of
1142 * this may be unique to the RPX-Lite configuration. 1142 * this may be unique to the RPX-Lite configuration.
1143 * Note TENA is on Port B. 1143 * Note TENA is on Port B.
1144 */ 1144 */
1145 #define PROFF_ENET PROFF_SCC2 1145 #define PROFF_ENET PROFF_SCC2
1146 #define CPM_CR_ENET CPM_CR_CH_SCC2 1146 #define CPM_CR_ENET CPM_CR_CH_SCC2
1147 #define SCC_ENET 1 1147 #define SCC_ENET 1
1148 #define PA_ENET_RXD ((ushort)0x0004) 1148 #define PA_ENET_RXD ((ushort)0x0004)
1149 #define PA_ENET_TXD ((ushort)0x0008) 1149 #define PA_ENET_TXD ((ushort)0x0008)
1150 #define PA_ENET_TCLK ((ushort)0x0200) 1150 #define PA_ENET_TCLK ((ushort)0x0200)
1151 #define PA_ENET_RCLK ((ushort)0x0800) 1151 #define PA_ENET_RCLK ((ushort)0x0800)
1152 #define PB_ENET_TENA ((uint)0x00002000) 1152 #define PB_ENET_TENA ((uint)0x00002000)
1153 #define PC_ENET_CLSN ((ushort)0x0040) 1153 #define PC_ENET_CLSN ((ushort)0x0040)
1154 #define PC_ENET_RENA ((ushort)0x0080) 1154 #define PC_ENET_RENA ((ushort)0x0080)
1155 1155
1156 #define SICR_ENET_MASK ((uint)0x0000ff00) 1156 #define SICR_ENET_MASK ((uint)0x0000ff00)
1157 #define SICR_ENET_CLKRT ((uint)0x00003d00) 1157 #define SICR_ENET_CLKRT ((uint)0x00003d00)
1158 #endif /* CONFIG_RPXLITE */ 1158 #endif /* CONFIG_RPXLITE */
1159 1159
1160 /*** SM850 *********************************************************/ 1160 /*** SM850 *********************************************************/
1161 1161
1162 /* The SM850 Service Module uses SCC2 for IrDA and SCC3 for Ethernet */ 1162 /* The SM850 Service Module uses SCC2 for IrDA and SCC3 for Ethernet */
1163 1163
1164 #ifdef CONFIG_SM850 1164 #ifdef CONFIG_SM850
1165 #define PROFF_ENET PROFF_SCC3 /* Ethernet on SCC3 */ 1165 #define PROFF_ENET PROFF_SCC3 /* Ethernet on SCC3 */
1166 #define CPM_CR_ENET CPM_CR_CH_SCC3 1166 #define CPM_CR_ENET CPM_CR_CH_SCC3
1167 #define SCC_ENET 2 1167 #define SCC_ENET 2
1168 #define PB_ENET_RXD ((uint)0x00000004) /* PB 29 */ 1168 #define PB_ENET_RXD ((uint)0x00000004) /* PB 29 */
1169 #define PB_ENET_TXD ((uint)0x00000002) /* PB 30 */ 1169 #define PB_ENET_TXD ((uint)0x00000002) /* PB 30 */
1170 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */ 1170 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
1171 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 1171 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
1172 1172
1173 #define PC_ENET_LBK ((ushort)0x0008) /* PC 12 */ 1173 #define PC_ENET_LBK ((ushort)0x0008) /* PC 12 */
1174 #define PC_ENET_TENA ((ushort)0x0004) /* PC 13 */ 1174 #define PC_ENET_TENA ((ushort)0x0004) /* PC 13 */
1175 1175
1176 #define PC_ENET_RENA ((ushort)0x0800) /* PC 4 */ 1176 #define PC_ENET_RENA ((ushort)0x0800) /* PC 4 */
1177 #define PC_ENET_CLSN ((ushort)0x0400) /* PC 5 */ 1177 #define PC_ENET_CLSN ((ushort)0x0400) /* PC 5 */
1178 1178
1179 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to 1179 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
1180 * SCC3. Also, make sure GR3 (bit 8) and SC3 (bit 9) are zero. 1180 * SCC3. Also, make sure GR3 (bit 8) and SC3 (bit 9) are zero.
1181 */ 1181 */
1182 #define SICR_ENET_MASK ((uint)0x00FF0000) 1182 #define SICR_ENET_MASK ((uint)0x00FF0000)
1183 #define SICR_ENET_CLKRT ((uint)0x00260000) 1183 #define SICR_ENET_CLKRT ((uint)0x00260000)
1184 #endif /* CONFIG_SM850 */ 1184 #endif /* CONFIG_SM850 */
1185 1185
1186 /*** SPD823TS ******************************************************/ 1186 /*** SPD823TS ******************************************************/
1187 1187
1188 #ifdef CONFIG_SPD823TS 1188 #ifdef CONFIG_SPD823TS
1189 /* Bits in parallel I/O port registers that have to be set/cleared 1189 /* Bits in parallel I/O port registers that have to be set/cleared
1190 * to configure the pins for SCC2 use. 1190 * to configure the pins for SCC2 use.
1191 */ 1191 */
1192 #define PROFF_ENET PROFF_SCC2 /* Ethernet on SCC2 */ 1192 #define PROFF_ENET PROFF_SCC2 /* Ethernet on SCC2 */
1193 #define CPM_CR_ENET CPM_CR_CH_SCC2 1193 #define CPM_CR_ENET CPM_CR_CH_SCC2
1194 #define SCC_ENET 1 1194 #define SCC_ENET 1
1195 #define PA_ENET_MDC ((ushort)0x0001) /* PA 15 !!! */ 1195 #define PA_ENET_MDC ((ushort)0x0001) /* PA 15 !!! */
1196 #define PA_ENET_MDIO ((ushort)0x0002) /* PA 14 !!! */ 1196 #define PA_ENET_MDIO ((ushort)0x0002) /* PA 14 !!! */
1197 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 1197 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
1198 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 1198 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
1199 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 1199 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
1200 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 1200 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
1201 1201
1202 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 1202 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
1203 1203
1204 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 1204 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
1205 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 1205 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
1206 #define PC_ENET_RESET ((ushort)0x0100) /* PC 7 !!! */ 1206 #define PC_ENET_RESET ((ushort)0x0100) /* PC 7 !!! */
1207 1207
1208 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK2) to 1208 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK2) to
1209 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero. 1209 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
1210 */ 1210 */
1211 #define SICR_ENET_MASK ((uint)0x0000ff00) 1211 #define SICR_ENET_MASK ((uint)0x0000ff00)
1212 #define SICR_ENET_CLKRT ((uint)0x00002E00) 1212 #define SICR_ENET_CLKRT ((uint)0x00002E00)
1213 #endif /* CONFIG_SPD823TS */ 1213 #endif /* CONFIG_SPD823TS */
1214 1214
1215 /*** SXNI855T ******************************************************/ 1215 /*** SXNI855T ******************************************************/
1216 1216
1217 #if defined(CONFIG_SXNI855T) 1217 #if defined(CONFIG_SXNI855T)
1218 1218
1219 #ifdef CONFIG_FEC_ENET 1219 #ifdef CONFIG_FEC_ENET
1220 #define FEC_ENET /* use FEC for Ethernet */ 1220 #define FEC_ENET /* use FEC for Ethernet */
1221 #endif /* CONFIG_FEC_ETHERNET */ 1221 #endif /* CONFIG_FEC_ETHERNET */
1222 1222
1223 #endif /* CONFIG_SXNI855T */ 1223 #endif /* CONFIG_SXNI855T */
1224 1224
1225 /*** MVS1, TQM823L, TQM850L, ETX094, R360MPI ***********************/ 1225 /*** MVS1, TQM823L, TQM850L, ETX094, R360MPI ***********************/
1226 1226
1227 #if (defined(CONFIG_MVS) && CONFIG_MVS < 2) || \ 1227 #if (defined(CONFIG_MVS) && CONFIG_MVS < 2) || \
1228 defined(CONFIG_R360MPI) || \ 1228 defined(CONFIG_R360MPI) || \
1229 defined(CONFIG_TQM823L) || \ 1229 defined(CONFIG_TQM823L) || \
1230 defined(CONFIG_TQM850L) || \ 1230 defined(CONFIG_TQM850L) || \
1231 defined(CONFIG_ETX094) || \ 1231 defined(CONFIG_ETX094) || \
1232 defined(CONFIG_RRVISION)|| \ 1232 defined(CONFIG_RRVISION)|| \
1233 (defined(CONFIG_LANTEC) && CONFIG_LANTEC < 2) 1233 (defined(CONFIG_LANTEC) && CONFIG_LANTEC < 2)
1234 /* Bits in parallel I/O port registers that have to be set/cleared 1234 /* Bits in parallel I/O port registers that have to be set/cleared
1235 * to configure the pins for SCC2 use. 1235 * to configure the pins for SCC2 use.
1236 */ 1236 */
1237 #define PROFF_ENET PROFF_SCC2 1237 #define PROFF_ENET PROFF_SCC2
1238 #define CPM_CR_ENET CPM_CR_CH_SCC2 1238 #define CPM_CR_ENET CPM_CR_CH_SCC2
1239 #define SCC_ENET 1 1239 #define SCC_ENET 1
1240 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 1240 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
1241 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 1241 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
1242 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */ 1242 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
1243 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 1243 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
1244 1244
1245 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */ 1245 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
1246 1246
1247 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 1247 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
1248 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 1248 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
1249 #if defined(CONFIG_R360MPI) 1249 #if defined(CONFIG_R360MPI)
1250 #define PC_ENET_LBK ((ushort)0x0008) /* PC 12 */ 1250 #define PC_ENET_LBK ((ushort)0x0008) /* PC 12 */
1251 #endif /* CONFIG_R360MPI */ 1251 #endif /* CONFIG_R360MPI */
1252 1252
1253 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to 1253 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
1254 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero. 1254 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
1255 */ 1255 */
1256 #define SICR_ENET_MASK ((uint)0x0000ff00) 1256 #define SICR_ENET_MASK ((uint)0x0000ff00)
1257 #define SICR_ENET_CLKRT ((uint)0x00002600) 1257 #define SICR_ENET_CLKRT ((uint)0x00002600)
1258 #endif /* CONFIG_MVS v1, CONFIG_TQM823L, CONFIG_TQM850L, etc. */ 1258 #endif /* CONFIG_MVS v1, CONFIG_TQM823L, CONFIG_TQM850L, etc. */
1259 1259
1260 /*** TQM860L, TQM855L ************************************************/ 1260 /*** TQM860L, TQM855L ************************************************/
1261 1261
1262 #if (defined(CONFIG_TQM860L) || defined(CONFIG_TQM855L)) 1262 #if (defined(CONFIG_TQM860L) || defined(CONFIG_TQM855L))
1263 1263
1264 # ifdef CONFIG_SCC1_ENET /* use SCC for 10Mbps Ethernet */ 1264 # ifdef CONFIG_SCC1_ENET /* use SCC for 10Mbps Ethernet */
1265 1265
1266 /* Bits in parallel I/O port registers that have to be set/cleared 1266 /* Bits in parallel I/O port registers that have to be set/cleared
1267 * to configure the pins for SCC1 use. 1267 * to configure the pins for SCC1 use.
1268 */ 1268 */
1269 #define PROFF_ENET PROFF_SCC1 1269 #define PROFF_ENET PROFF_SCC1
1270 #define CPM_CR_ENET CPM_CR_CH_SCC1 1270 #define CPM_CR_ENET CPM_CR_CH_SCC1
1271 #define SCC_ENET 0 1271 #define SCC_ENET 0
1272 #define PA_ENET_RXD ((ushort)0x0001) /* PA 15 */ 1272 #define PA_ENET_RXD ((ushort)0x0001) /* PA 15 */
1273 #define PA_ENET_TXD ((ushort)0x0002) /* PA 14 */ 1273 #define PA_ENET_TXD ((ushort)0x0002) /* PA 14 */
1274 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */ 1274 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
1275 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */ 1275 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
1276 1276
1277 #define PC_ENET_TENA ((ushort)0x0001) /* PC 15 */ 1277 #define PC_ENET_TENA ((ushort)0x0001) /* PC 15 */
1278 #define PC_ENET_CLSN ((ushort)0x0010) /* PC 11 */ 1278 #define PC_ENET_CLSN ((ushort)0x0010) /* PC 11 */
1279 #define PC_ENET_RENA ((ushort)0x0020) /* PC 10 */ 1279 #define PC_ENET_RENA ((ushort)0x0020) /* PC 10 */
1280 1280
1281 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to 1281 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
1282 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero. 1282 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero.
1283 */ 1283 */
1284 #define SICR_ENET_MASK ((uint)0x000000ff) 1284 #define SICR_ENET_MASK ((uint)0x000000ff)
1285 #define SICR_ENET_CLKRT ((uint)0x00000026) 1285 #define SICR_ENET_CLKRT ((uint)0x00000026)
1286 1286
1287 # endif /* CONFIG_SCC1_ENET */ 1287 # endif /* CONFIG_SCC1_ENET */
1288 1288
1289 # ifdef CONFIG_FEC_ENET /* Use FEC for Fast Ethernet */ 1289 # ifdef CONFIG_FEC_ENET /* Use FEC for Fast Ethernet */
1290 1290
1291 #define FEC_ENET 1291 #define FEC_ENET
1292 1292
1293 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */ 1293 #define PD_MII_TXD1 ((ushort)0x1000) /* PD 3 */
1294 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */ 1294 #define PD_MII_TXD2 ((ushort)0x0800) /* PD 4 */
1295 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */ 1295 #define PD_MII_TXD3 ((ushort)0x0400) /* PD 5 */
1296 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */ 1296 #define PD_MII_RX_DV ((ushort)0x0200) /* PD 6 */
1297 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */ 1297 #define PD_MII_RX_ERR ((ushort)0x0100) /* PD 7 */
1298 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */ 1298 #define PD_MII_RX_CLK ((ushort)0x0080) /* PD 8 */
1299 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */ 1299 #define PD_MII_TXD0 ((ushort)0x0040) /* PD 9 */
1300 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */ 1300 #define PD_MII_RXD0 ((ushort)0x0020) /* PD 10 */
1301 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */ 1301 #define PD_MII_TX_ERR ((ushort)0x0010) /* PD 11 */
1302 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */ 1302 #define PD_MII_MDC ((ushort)0x0008) /* PD 12 */
1303 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */ 1303 #define PD_MII_RXD1 ((ushort)0x0004) /* PD 13 */
1304 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */ 1304 #define PD_MII_RXD2 ((ushort)0x0002) /* PD 14 */
1305 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */ 1305 #define PD_MII_RXD3 ((ushort)0x0001) /* PD 15 */
1306 1306
1307 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */ 1307 #define PD_MII_MASK ((ushort)0x1FFF) /* PD 3...15 */
1308 1308
1309 # endif /* CONFIG_FEC_ENET */ 1309 # endif /* CONFIG_FEC_ENET */
1310 #endif /* CONFIG_TQM860L, CONFIG_TQM855L */ 1310 #endif /* CONFIG_TQM860L, CONFIG_TQM855L */
1311 1311
1312 #if defined(CONFIG_NETVIA) 1312 #if defined(CONFIG_NETVIA)
1313 /* Bits in parallel I/O port registers that have to be set/cleared 1313 /* Bits in parallel I/O port registers that have to be set/cleared
1314 * to configure the pins for SCC2 use. 1314 * to configure the pins for SCC2 use.
1315 */ 1315 */
1316 #define PROFF_ENET PROFF_SCC2 1316 #define PROFF_ENET PROFF_SCC2
1317 #define CPM_CR_ENET CPM_CR_CH_SCC2 1317 #define CPM_CR_ENET CPM_CR_CH_SCC2
1318 #define SCC_ENET 1 1318 #define SCC_ENET 1
1319 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */ 1319 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
1320 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */ 1320 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
1321 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */ 1321 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
1322 #define PA_ENET_TCLK ((ushort)0x0800) /* PA 4 */ 1322 #define PA_ENET_TCLK ((ushort)0x0800) /* PA 4 */
1323 1323
1324 #define PB_ENET_PDN ((ushort)0x4000) /* PB 17 */ 1324 #define PB_ENET_PDN ((ushort)0x4000) /* PB 17 */
1325 #define PB_ENET_TENA ((ushort)0x2000) /* PB 18 */ 1325 #define PB_ENET_TENA ((ushort)0x2000) /* PB 18 */
1326 1326
1327 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */ 1327 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
1328 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */ 1328 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
1329 1329
1330 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to 1330 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
1331 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero. 1331 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
1332 */ 1332 */
1333 #define SICR_ENET_MASK ((uint)0x0000ff00) 1333 #define SICR_ENET_MASK ((uint)0x0000ff00)
1334 #define SICR_ENET_CLKRT ((uint)0x00002f00) 1334 #define SICR_ENET_CLKRT ((uint)0x00002f00)
1335 1335
1336 #endif /* CONFIG_NETVIA */ 1336 #endif /* CONFIG_NETVIA */
1337 1337
1338 /*********************************************************************/ 1338 /*********************************************************************/
1339 1339
1340 /* SCC Event register as used by Ethernet. 1340 /* SCC Event register as used by Ethernet.
1341 */ 1341 */
1342 #define SCCE_ENET_GRA ((ushort)0x0080) /* Graceful stop complete */ 1342 #define SCCE_ENET_GRA ((ushort)0x0080) /* Graceful stop complete */
1343 #define SCCE_ENET_TXE ((ushort)0x0010) /* Transmit Error */ 1343 #define SCCE_ENET_TXE ((ushort)0x0010) /* Transmit Error */
1344 #define SCCE_ENET_RXF ((ushort)0x0008) /* Full frame received */ 1344 #define SCCE_ENET_RXF ((ushort)0x0008) /* Full frame received */
1345 #define SCCE_ENET_BSY ((ushort)0x0004) /* All incoming buffers full */ 1345 #define SCCE_ENET_BSY ((ushort)0x0004) /* All incoming buffers full */
1346 #define SCCE_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */ 1346 #define SCCE_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */
1347 #define SCCE_ENET_RXB ((ushort)0x0001) /* A buffer was received */ 1347 #define SCCE_ENET_RXB ((ushort)0x0001) /* A buffer was received */
1348 1348
1349 /* SCC Mode Register (PSMR) as used by Ethernet. 1349 /* SCC Mode Register (PSMR) as used by Ethernet.
1350 */ 1350 */
1351 #define SCC_PSMR_HBC ((ushort)0x8000) /* Enable heartbeat */ 1351 #define SCC_PSMR_HBC ((ushort)0x8000) /* Enable heartbeat */
1352 #define SCC_PSMR_FC ((ushort)0x4000) /* Force collision */ 1352 #define SCC_PSMR_FC ((ushort)0x4000) /* Force collision */
1353 #define SCC_PSMR_RSH ((ushort)0x2000) /* Receive short frames */ 1353 #define SCC_PSMR_RSH ((ushort)0x2000) /* Receive short frames */
1354 #define SCC_PSMR_IAM ((ushort)0x1000) /* Check individual hash */ 1354 #define SCC_PSMR_IAM ((ushort)0x1000) /* Check individual hash */
1355 #define SCC_PSMR_ENCRC ((ushort)0x0800) /* Ethernet CRC mode */ 1355 #define SCC_PSMR_ENCRC ((ushort)0x0800) /* Ethernet CRC mode */
1356 #define SCC_PSMR_PRO ((ushort)0x0200) /* Promiscuous mode */ 1356 #define SCC_PSMR_PRO ((ushort)0x0200) /* Promiscuous mode */
1357 #define SCC_PSMR_BRO ((ushort)0x0100) /* Catch broadcast pkts */ 1357 #define SCC_PSMR_BRO ((ushort)0x0100) /* Catch broadcast pkts */
1358 #define SCC_PSMR_SBT ((ushort)0x0080) /* Special backoff timer */ 1358 #define SCC_PSMR_SBT ((ushort)0x0080) /* Special backoff timer */
1359 #define SCC_PSMR_LPB ((ushort)0x0040) /* Set Loopback mode */ 1359 #define SCC_PSMR_LPB ((ushort)0x0040) /* Set Loopback mode */
1360 #define SCC_PSMR_SIP ((ushort)0x0020) /* Sample Input Pins */ 1360 #define SCC_PSMR_SIP ((ushort)0x0020) /* Sample Input Pins */
1361 #define SCC_PSMR_LCW ((ushort)0x0010) /* Late collision window */ 1361 #define SCC_PSMR_LCW ((ushort)0x0010) /* Late collision window */
1362 #define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */ 1362 #define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */
1363 #define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */ 1363 #define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */
1364 1364
1365 /* Buffer descriptor control/status used by Ethernet receive. 1365 /* Buffer descriptor control/status used by Ethernet receive.
1366 */ 1366 */
1367 #define BD_ENET_RX_EMPTY ((ushort)0x8000) 1367 #define BD_ENET_RX_EMPTY ((ushort)0x8000)
1368 #define BD_ENET_RX_WRAP ((ushort)0x2000) 1368 #define BD_ENET_RX_WRAP ((ushort)0x2000)
1369 #define BD_ENET_RX_INTR ((ushort)0x1000) 1369 #define BD_ENET_RX_INTR ((ushort)0x1000)
1370 #define BD_ENET_RX_LAST ((ushort)0x0800) 1370 #define BD_ENET_RX_LAST ((ushort)0x0800)
1371 #define BD_ENET_RX_FIRST ((ushort)0x0400) 1371 #define BD_ENET_RX_FIRST ((ushort)0x0400)
1372 #define BD_ENET_RX_MISS ((ushort)0x0100) 1372 #define BD_ENET_RX_MISS ((ushort)0x0100)
1373 #define BD_ENET_RX_LG ((ushort)0x0020) 1373 #define BD_ENET_RX_LG ((ushort)0x0020)
1374 #define BD_ENET_RX_NO ((ushort)0x0010) 1374 #define BD_ENET_RX_NO ((ushort)0x0010)
1375 #define BD_ENET_RX_SH ((ushort)0x0008) 1375 #define BD_ENET_RX_SH ((ushort)0x0008)
1376 #define BD_ENET_RX_CR ((ushort)0x0004) 1376 #define BD_ENET_RX_CR ((ushort)0x0004)
1377 #define BD_ENET_RX_OV ((ushort)0x0002) 1377 #define BD_ENET_RX_OV ((ushort)0x0002)
1378 #define BD_ENET_RX_CL ((ushort)0x0001) 1378 #define BD_ENET_RX_CL ((ushort)0x0001)
1379 #define BD_ENET_RX_STATS ((ushort)0x013f) /* All status bits */ 1379 #define BD_ENET_RX_STATS ((ushort)0x013f) /* All status bits */
1380 1380
1381 /* Buffer descriptor control/status used by Ethernet transmit. 1381 /* Buffer descriptor control/status used by Ethernet transmit.
1382 */ 1382 */
1383 #define BD_ENET_TX_READY ((ushort)0x8000) 1383 #define BD_ENET_TX_READY ((ushort)0x8000)
1384 #define BD_ENET_TX_PAD ((ushort)0x4000) 1384 #define BD_ENET_TX_PAD ((ushort)0x4000)
1385 #define BD_ENET_TX_WRAP ((ushort)0x2000) 1385 #define BD_ENET_TX_WRAP ((ushort)0x2000)
1386 #define BD_ENET_TX_INTR ((ushort)0x1000) 1386 #define BD_ENET_TX_INTR ((ushort)0x1000)
1387 #define BD_ENET_TX_LAST ((ushort)0x0800) 1387 #define BD_ENET_TX_LAST ((ushort)0x0800)
1388 #define BD_ENET_TX_TC ((ushort)0x0400) 1388 #define BD_ENET_TX_TC ((ushort)0x0400)
1389 #define BD_ENET_TX_DEF ((ushort)0x0200) 1389 #define BD_ENET_TX_DEF ((ushort)0x0200)
1390 #define BD_ENET_TX_HB ((ushort)0x0100) 1390 #define BD_ENET_TX_HB ((ushort)0x0100)
1391 #define BD_ENET_TX_LC ((ushort)0x0080) 1391 #define BD_ENET_TX_LC ((ushort)0x0080)
1392 #define BD_ENET_TX_RL ((ushort)0x0040) 1392 #define BD_ENET_TX_RL ((ushort)0x0040)
1393 #define BD_ENET_TX_RCMASK ((ushort)0x003c) 1393 #define BD_ENET_TX_RCMASK ((ushort)0x003c)
1394 #define BD_ENET_TX_UN ((ushort)0x0002) 1394 #define BD_ENET_TX_UN ((ushort)0x0002)
1395 #define BD_ENET_TX_CSL ((ushort)0x0001) 1395 #define BD_ENET_TX_CSL ((ushort)0x0001)
1396 #define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */ 1396 #define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */
1397 1397
1398 /* SCC as UART 1398 /* SCC as UART
1399 */ 1399 */
1400 typedef struct scc_uart { 1400 typedef struct scc_uart {
1401 sccp_t scc_genscc; 1401 sccp_t scc_genscc;
1402 uint scc_res1; /* Reserved */ 1402 uint scc_res1; /* Reserved */
1403 uint scc_res2; /* Reserved */ 1403 uint scc_res2; /* Reserved */
1404 ushort scc_maxidl; /* Maximum idle chars */ 1404 ushort scc_maxidl; /* Maximum idle chars */
1405 ushort scc_idlc; /* temp idle counter */ 1405 ushort scc_idlc; /* temp idle counter */
1406 ushort scc_brkcr; /* Break count register */ 1406 ushort scc_brkcr; /* Break count register */
1407 ushort scc_parec; /* receive parity error counter */ 1407 ushort scc_parec; /* receive parity error counter */
1408 ushort scc_frmec; /* receive framing error counter */ 1408 ushort scc_frmec; /* receive framing error counter */
1409 ushort scc_nosec; /* receive noise counter */ 1409 ushort scc_nosec; /* receive noise counter */
1410 ushort scc_brkec; /* receive break condition counter */ 1410 ushort scc_brkec; /* receive break condition counter */
1411 ushort scc_brkln; /* last received break length */ 1411 ushort scc_brkln; /* last received break length */
1412 ushort scc_uaddr1; /* UART address character 1 */ 1412 ushort scc_uaddr1; /* UART address character 1 */
1413 ushort scc_uaddr2; /* UART address character 2 */ 1413 ushort scc_uaddr2; /* UART address character 2 */
1414 ushort scc_rtemp; /* Temp storage */ 1414 ushort scc_rtemp; /* Temp storage */
1415 ushort scc_toseq; /* Transmit out of sequence char */ 1415 ushort scc_toseq; /* Transmit out of sequence char */
1416 ushort scc_char1; /* control character 1 */ 1416 ushort scc_char1; /* control character 1 */
1417 ushort scc_char2; /* control character 2 */ 1417 ushort scc_char2; /* control character 2 */
1418 ushort scc_char3; /* control character 3 */ 1418 ushort scc_char3; /* control character 3 */
1419 ushort scc_char4; /* control character 4 */ 1419 ushort scc_char4; /* control character 4 */
1420 ushort scc_char5; /* control character 5 */ 1420 ushort scc_char5; /* control character 5 */
1421 ushort scc_char6; /* control character 6 */ 1421 ushort scc_char6; /* control character 6 */
1422 ushort scc_char7; /* control character 7 */ 1422 ushort scc_char7; /* control character 7 */
1423 ushort scc_char8; /* control character 8 */ 1423 ushort scc_char8; /* control character 8 */
1424 ushort scc_rccm; /* receive control character mask */ 1424 ushort scc_rccm; /* receive control character mask */
1425 ushort scc_rccr; /* receive control character register */ 1425 ushort scc_rccr; /* receive control character register */
1426 ushort scc_rlbc; /* receive last break character */ 1426 ushort scc_rlbc; /* receive last break character */
1427 } scc_uart_t; 1427 } scc_uart_t;
1428 1428
1429 /* SCC Event and Mask registers when it is used as a UART. 1429 /* SCC Event and Mask registers when it is used as a UART.
1430 */ 1430 */
1431 #define UART_SCCM_GLR ((ushort)0x1000) 1431 #define UART_SCCM_GLR ((ushort)0x1000)
1432 #define UART_SCCM_GLT ((ushort)0x0800) 1432 #define UART_SCCM_GLT ((ushort)0x0800)
1433 #define UART_SCCM_AB ((ushort)0x0200) 1433 #define UART_SCCM_AB ((ushort)0x0200)
1434 #define UART_SCCM_IDL ((ushort)0x0100) 1434 #define UART_SCCM_IDL ((ushort)0x0100)
1435 #define UART_SCCM_GRA ((ushort)0x0080) 1435 #define UART_SCCM_GRA ((ushort)0x0080)
1436 #define UART_SCCM_BRKE ((ushort)0x0040) 1436 #define UART_SCCM_BRKE ((ushort)0x0040)
1437 #define UART_SCCM_BRKS ((ushort)0x0020) 1437 #define UART_SCCM_BRKS ((ushort)0x0020)
1438 #define UART_SCCM_CCR ((ushort)0x0008) 1438 #define UART_SCCM_CCR ((ushort)0x0008)
1439 #define UART_SCCM_BSY ((ushort)0x0004) 1439 #define UART_SCCM_BSY ((ushort)0x0004)
1440 #define UART_SCCM_TX ((ushort)0x0002) 1440 #define UART_SCCM_TX ((ushort)0x0002)
1441 #define UART_SCCM_RX ((ushort)0x0001) 1441 #define UART_SCCM_RX ((ushort)0x0001)
1442 1442
1443 /* The SCC PSMR when used as a UART. 1443 /* The SCC PSMR when used as a UART.
1444 */ 1444 */
1445 #define SCU_PSMR_FLC ((ushort)0x8000) 1445 #define SCU_PSMR_FLC ((ushort)0x8000)
1446 #define SCU_PSMR_SL ((ushort)0x4000) 1446 #define SCU_PSMR_SL ((ushort)0x4000)
1447 #define SCU_PSMR_CL ((ushort)0x3000) 1447 #define SCU_PSMR_CL ((ushort)0x3000)
1448 #define SCU_PSMR_UM ((ushort)0x0c00) 1448 #define SCU_PSMR_UM ((ushort)0x0c00)
1449 #define SCU_PSMR_FRZ ((ushort)0x0200) 1449 #define SCU_PSMR_FRZ ((ushort)0x0200)
1450 #define SCU_PSMR_RZS ((ushort)0x0100) 1450 #define SCU_PSMR_RZS ((ushort)0x0100)
1451 #define SCU_PSMR_SYN ((ushort)0x0080) 1451 #define SCU_PSMR_SYN ((ushort)0x0080)
1452 #define SCU_PSMR_DRT ((ushort)0x0040) 1452 #define SCU_PSMR_DRT ((ushort)0x0040)
1453 #define SCU_PSMR_PEN ((ushort)0x0010) 1453 #define SCU_PSMR_PEN ((ushort)0x0010)
1454 #define SCU_PSMR_RPM ((ushort)0x000c) 1454 #define SCU_PSMR_RPM ((ushort)0x000c)
1455 #define SCU_PSMR_REVP ((ushort)0x0008) 1455 #define SCU_PSMR_REVP ((ushort)0x0008)
1456 #define SCU_PSMR_TPM ((ushort)0x0003) 1456 #define SCU_PSMR_TPM ((ushort)0x0003)
1457 #define SCU_PSMR_TEVP ((ushort)0x0003) 1457 #define SCU_PSMR_TEVP ((ushort)0x0003)
1458 1458
1459 /* CPM Transparent mode SCC. 1459 /* CPM Transparent mode SCC.
1460 */ 1460 */
1461 typedef struct scc_trans { 1461 typedef struct scc_trans {
1462 sccp_t st_genscc; 1462 sccp_t st_genscc;
1463 uint st_cpres; /* Preset CRC */ 1463 uint st_cpres; /* Preset CRC */
1464 uint st_cmask; /* Constant mask for CRC */ 1464 uint st_cmask; /* Constant mask for CRC */
1465 } scc_trans_t; 1465 } scc_trans_t;
1466 1466
1467 #define BD_SCC_TX_LAST ((ushort)0x0800) 1467 #define BD_SCC_TX_LAST ((ushort)0x0800)
1468 1468
1469 /* IIC parameter RAM. 1469 /* IIC parameter RAM.
1470 */ 1470 */
1471 typedef struct iic { 1471 typedef struct iic {
1472 ushort iic_rbase; /* Rx Buffer descriptor base address */ 1472 ushort iic_rbase; /* Rx Buffer descriptor base address */
1473 ushort iic_tbase; /* Tx Buffer descriptor base address */ 1473 ushort iic_tbase; /* Tx Buffer descriptor base address */
1474 u_char iic_rfcr; /* Rx function code */ 1474 u_char iic_rfcr; /* Rx function code */
1475 u_char iic_tfcr; /* Tx function code */ 1475 u_char iic_tfcr; /* Tx function code */
1476 ushort iic_mrblr; /* Max receive buffer length */ 1476 ushort iic_mrblr; /* Max receive buffer length */
1477 uint iic_rstate; /* Internal */ 1477 uint iic_rstate; /* Internal */
1478 uint iic_rdp; /* Internal */ 1478 uint iic_rdp; /* Internal */
1479 ushort iic_rbptr; /* Internal */ 1479 ushort iic_rbptr; /* Internal */
1480 ushort iic_rbc; /* Internal */ 1480 ushort iic_rbc; /* Internal */
1481 uint iic_rxtmp; /* Internal */ 1481 uint iic_rxtmp; /* Internal */
1482 uint iic_tstate; /* Internal */ 1482 uint iic_tstate; /* Internal */
1483 uint iic_tdp; /* Internal */ 1483 uint iic_tdp; /* Internal */
1484 ushort iic_tbptr; /* Internal */ 1484 ushort iic_tbptr; /* Internal */
1485 ushort iic_tbc; /* Internal */ 1485 ushort iic_tbc; /* Internal */
1486 uint iic_txtmp; /* Internal */ 1486 uint iic_txtmp; /* Internal */
1487 uint iic_res; /* reserved */ 1487 uint iic_res; /* reserved */
1488 ushort iic_rpbase; /* Relocation pointer */ 1488 ushort iic_rpbase; /* Relocation pointer */
1489 ushort iic_res2; /* reserved */ 1489 ushort iic_res2; /* reserved */
1490 } iic_t; 1490 } iic_t;
1491 1491
1492 /* SPI parameter RAM. 1492 /* SPI parameter RAM.
1493 */ 1493 */
1494 typedef struct spi { 1494 typedef struct spi {
1495 ushort spi_rbase; /* Rx Buffer descriptor base address */ 1495 ushort spi_rbase; /* Rx Buffer descriptor base address */
1496 ushort spi_tbase; /* Tx Buffer descriptor base address */ 1496 ushort spi_tbase; /* Tx Buffer descriptor base address */
1497 u_char spi_rfcr; /* Rx function code */ 1497 u_char spi_rfcr; /* Rx function code */
1498 u_char spi_tfcr; /* Tx function code */ 1498 u_char spi_tfcr; /* Tx function code */
1499 ushort spi_mrblr; /* Max receive buffer length */ 1499 ushort spi_mrblr; /* Max receive buffer length */
1500 uint spi_rstate; /* Internal */ 1500 uint spi_rstate; /* Internal */
1501 uint spi_rdp; /* Internal */ 1501 uint spi_rdp; /* Internal */
1502 ushort spi_rbptr; /* Internal */ 1502 ushort spi_rbptr; /* Internal */
1503 ushort spi_rbc; /* Internal */ 1503 ushort spi_rbc; /* Internal */
1504 uint spi_rxtmp; /* Internal */ 1504 uint spi_rxtmp; /* Internal */
1505 uint spi_tstate; /* Internal */ 1505 uint spi_tstate; /* Internal */
1506 uint spi_tdp; /* Internal */ 1506 uint spi_tdp; /* Internal */
1507 ushort spi_tbptr; /* Internal */ 1507 ushort spi_tbptr; /* Internal */
1508 ushort spi_tbc; /* Internal */ 1508 ushort spi_tbc; /* Internal */
1509 uint spi_txtmp; /* Internal */ 1509 uint spi_txtmp; /* Internal */
1510 uint spi_res; 1510 uint spi_res;
1511 ushort spi_rpbase; /* Relocation pointer */ 1511 ushort spi_rpbase; /* Relocation pointer */
1512 ushort spi_res2; 1512 ushort spi_res2;
1513 } spi_t; 1513 } spi_t;
1514 1514
1515 /* SPI Mode register. 1515 /* SPI Mode register.
1516 */ 1516 */
1517 #define SPMODE_LOOP ((ushort)0x4000) /* Loopback */ 1517 #define SPMODE_LOOP ((ushort)0x4000) /* Loopback */
1518 #define SPMODE_CI ((ushort)0x2000) /* Clock Invert */ 1518 #define SPMODE_CI ((ushort)0x2000) /* Clock Invert */
1519 #define SPMODE_CP ((ushort)0x1000) /* Clock Phase */ 1519 #define SPMODE_CP ((ushort)0x1000) /* Clock Phase */
1520 #define SPMODE_DIV16 ((ushort)0x0800) /* BRG/16 mode */ 1520 #define SPMODE_DIV16 ((ushort)0x0800) /* BRG/16 mode */
1521 #define SPMODE_REV ((ushort)0x0400) /* Reversed Data */ 1521 #define SPMODE_REV ((ushort)0x0400) /* Reversed Data */
1522 #define SPMODE_MSTR ((ushort)0x0200) /* SPI Master */ 1522 #define SPMODE_MSTR ((ushort)0x0200) /* SPI Master */
1523 #define SPMODE_EN ((ushort)0x0100) /* Enable */ 1523 #define SPMODE_EN ((ushort)0x0100) /* Enable */
1524 #define SPMODE_LENMSK ((ushort)0x00f0) /* character length */ 1524 #define SPMODE_LENMSK ((ushort)0x00f0) /* character length */
1525 #define SPMODE_PMMSK ((ushort)0x000f) /* prescale modulus */ 1525 #define SPMODE_PMMSK ((ushort)0x000f) /* prescale modulus */
1526 1526
1527 #define SPMODE_LEN(x) ((((x)-1)&0xF)<<4) 1527 #define SPMODE_LEN(x) ((((x)-1)&0xF)<<4)
1528 #define SPMODE_PM(x) ((x) &0xF) 1528 #define SPMODE_PM(x) ((x) &0xF)
1529 1529
1530 /* HDLC parameter RAM. 1530 /* HDLC parameter RAM.
1531 */ 1531 */
1532 1532
1533 typedef struct hdlc_pram_s { 1533 typedef struct hdlc_pram_s {
1534 /* 1534 /*
1535 * SCC parameter RAM 1535 * SCC parameter RAM
1536 */ 1536 */
1537 ushort rbase; /* Rx Buffer descriptor base address */ 1537 ushort rbase; /* Rx Buffer descriptor base address */
1538 ushort tbase; /* Tx Buffer descriptor base address */ 1538 ushort tbase; /* Tx Buffer descriptor base address */
1539 uchar rfcr; /* Rx function code */ 1539 uchar rfcr; /* Rx function code */
1540 uchar tfcr; /* Tx function code */ 1540 uchar tfcr; /* Tx function code */
1541 ushort mrblr; /* Rx buffer length */ 1541 ushort mrblr; /* Rx buffer length */
1542 ulong rstate; /* Rx internal state */ 1542 ulong rstate; /* Rx internal state */
1543 ulong rptr; /* Rx internal data pointer */ 1543 ulong rptr; /* Rx internal data pointer */
1544 ushort rbptr; /* rb BD Pointer */ 1544 ushort rbptr; /* rb BD Pointer */
1545 ushort rcount; /* Rx internal byte count */ 1545 ushort rcount; /* Rx internal byte count */
1546 ulong rtemp; /* Rx temp */ 1546 ulong rtemp; /* Rx temp */
1547 ulong tstate; /* Tx internal state */ 1547 ulong tstate; /* Tx internal state */
1548 ulong tptr; /* Tx internal data pointer */ 1548 ulong tptr; /* Tx internal data pointer */
1549 ushort tbptr; /* Tx BD pointer */ 1549 ushort tbptr; /* Tx BD pointer */
1550 ushort tcount; /* Tx byte count */ 1550 ushort tcount; /* Tx byte count */
1551 ulong ttemp; /* Tx temp */ 1551 ulong ttemp; /* Tx temp */
1552 ulong rcrc; /* temp receive CRC */ 1552 ulong rcrc; /* temp receive CRC */
1553 ulong tcrc; /* temp transmit CRC */ 1553 ulong tcrc; /* temp transmit CRC */
1554 /* 1554 /*
1555 * HDLC specific parameter RAM 1555 * HDLC specific parameter RAM
1556 */ 1556 */
1557 uchar res[4]; /* reserved */ 1557 uchar res[4]; /* reserved */
1558 ulong c_mask; /* CRC constant */ 1558 ulong c_mask; /* CRC constant */
1559 ulong c_pres; /* CRC preset */ 1559 ulong c_pres; /* CRC preset */
1560 ushort disfc; /* discarded frame counter */ 1560 ushort disfc; /* discarded frame counter */
1561 ushort crcec; /* CRC error counter */ 1561 ushort crcec; /* CRC error counter */
1562 ushort abtsc; /* abort sequence counter */ 1562 ushort abtsc; /* abort sequence counter */
1563 ushort nmarc; /* nonmatching address rx cnt */ 1563 ushort nmarc; /* nonmatching address rx cnt */
1564 ushort retrc; /* frame retransmission cnt */ 1564 ushort retrc; /* frame retransmission cnt */
1565 ushort mflr; /* maximum frame length reg */ 1565 ushort mflr; /* maximum frame length reg */
1566 ushort max_cnt; /* maximum length counter */ 1566 ushort max_cnt; /* maximum length counter */
1567 ushort rfthr; /* received frames threshold */ 1567 ushort rfthr; /* received frames threshold */
1568 ushort rfcnt; /* received frames count */ 1568 ushort rfcnt; /* received frames count */
1569 ushort hmask; /* user defined frm addr mask */ 1569 ushort hmask; /* user defined frm addr mask */
1570 ushort haddr1; /* user defined frm address 1 */ 1570 ushort haddr1; /* user defined frm address 1 */
1571 ushort haddr2; /* user defined frm address 2 */ 1571 ushort haddr2; /* user defined frm address 2 */
1572 ushort haddr3; /* user defined frm address 3 */ 1572 ushort haddr3; /* user defined frm address 3 */
1573 ushort haddr4; /* user defined frm address 4 */ 1573 ushort haddr4; /* user defined frm address 4 */
1574 ushort tmp; /* temp */ 1574 ushort tmp; /* temp */
1575 ushort tmp_mb; /* temp */ 1575 ushort tmp_mb; /* temp */
1576 } hdlc_pram_t; 1576 } hdlc_pram_t;
1577 1577
1578 /* CPM interrupts. There are nearly 32 interrupts generated by CPM 1578 /* CPM interrupts. There are nearly 32 interrupts generated by CPM
1579 * channels or devices. All of these are presented to the PPC core 1579 * channels or devices. All of these are presented to the PPC core
1580 * as a single interrupt. The CPM interrupt handler dispatches its 1580 * as a single interrupt. The CPM interrupt handler dispatches its
1581 * own handlers, in a similar fashion to the PPC core handler. We 1581 * own handlers, in a similar fashion to the PPC core handler. We
1582 * use the table as defined in the manuals (i.e. no special high 1582 * use the table as defined in the manuals (i.e. no special high
1583 * priority and SCC1 == SCCa, etc...). 1583 * priority and SCC1 == SCCa, etc...).
1584 */ 1584 */
1585 #define CPMVEC_NR 32 1585 #define CPMVEC_NR 32
1586 #define CPMVEC_PIO_PC15 ((ushort)0x1f) 1586 #define CPMVEC_OFFSET 0x00010000
1587 #define CPMVEC_SCC1 ((ushort)0x1e) 1587 #define CPMVEC_PIO_PC15 ((ushort)0x1f | CPMVEC_OFFSET)
1588 #define CPMVEC_SCC2 ((ushort)0x1d) 1588 #define CPMVEC_SCC1 ((ushort)0x1e | CPMVEC_OFFSET)
1589 #define CPMVEC_SCC3 ((ushort)0x1c) 1589 #define CPMVEC_SCC2 ((ushort)0x1d | CPMVEC_OFFSET)
1590 #define CPMVEC_SCC4 ((ushort)0x1b) 1590 #define CPMVEC_SCC3 ((ushort)0x1c | CPMVEC_OFFSET)
1591 #define CPMVEC_PIO_PC14 ((ushort)0x1a) 1591 #define CPMVEC_SCC4 ((ushort)0x1b | CPMVEC_OFFSET)
1592 #define CPMVEC_TIMER1 ((ushort)0x19) 1592 #define CPMVEC_PIO_PC14 ((ushort)0x1a | CPMVEC_OFFSET)
1593 #define CPMVEC_PIO_PC13 ((ushort)0x18) 1593 #define CPMVEC_TIMER1 ((ushort)0x19 | CPMVEC_OFFSET)
1594 #define CPMVEC_PIO_PC12 ((ushort)0x17) 1594 #define CPMVEC_PIO_PC13 ((ushort)0x18 | CPMVEC_OFFSET)
1595 #define CPMVEC_SDMA_CB_ERR ((ushort)0x16) 1595 #define CPMVEC_PIO_PC12 ((ushort)0x17 | CPMVEC_OFFSET)
1596 #define CPMVEC_IDMA1 ((ushort)0x15) 1596 #define CPMVEC_SDMA_CB_ERR ((ushort)0x16 | CPMVEC_OFFSET)
1597 #define CPMVEC_IDMA2 ((ushort)0x14) 1597 #define CPMVEC_IDMA1 ((ushort)0x15 | CPMVEC_OFFSET)
1598 #define CPMVEC_TIMER2 ((ushort)0x12) 1598 #define CPMVEC_IDMA2 ((ushort)0x14 | CPMVEC_OFFSET)
1599 #define CPMVEC_RISCTIMER ((ushort)0x11) 1599 #define CPMVEC_TIMER2 ((ushort)0x12 | CPMVEC_OFFSET)
1600 #define CPMVEC_I2C ((ushort)0x10) 1600 #define CPMVEC_RISCTIMER ((ushort)0x11 | CPMVEC_OFFSET)
1601 #define CPMVEC_PIO_PC11 ((ushort)0x0f) 1601 #define CPMVEC_I2C ((ushort)0x10 | CPMVEC_OFFSET)
1602 #define CPMVEC_PIO_PC10 ((ushort)0x0e) 1602 #define CPMVEC_PIO_PC11 ((ushort)0x0f | CPMVEC_OFFSET)
1603 #define CPMVEC_TIMER3 ((ushort)0x0c) 1603 #define CPMVEC_PIO_PC10 ((ushort)0x0e | CPMVEC_OFFSET)
1604 #define CPMVEC_PIO_PC9 ((ushort)0x0b) 1604 #define CPMVEC_TIMER3 ((ushort)0x0c | CPMVEC_OFFSET)
1605 #define CPMVEC_PIO_PC8 ((ushort)0x0a) 1605 #define CPMVEC_PIO_PC9 ((ushort)0x0b | CPMVEC_OFFSET)
1606 #define CPMVEC_PIO_PC7 ((ushort)0x09) 1606 #define CPMVEC_PIO_PC8 ((ushort)0x0a | CPMVEC_OFFSET)
1607 #define CPMVEC_TIMER4 ((ushort)0x07) 1607 #define CPMVEC_PIO_PC7 ((ushort)0x09 | CPMVEC_OFFSET)
1608 #define CPMVEC_PIO_PC6 ((ushort)0x06) 1608 #define CPMVEC_TIMER4 ((ushort)0x07 | CPMVEC_OFFSET)
1609 #define CPMVEC_SPI ((ushort)0x05) 1609 #define CPMVEC_PIO_PC6 ((ushort)0x06 | CPMVEC_OFFSET)
1610 #define CPMVEC_SMC1 ((ushort)0x04) 1610 #define CPMVEC_SPI ((ushort)0x05 | CPMVEC_OFFSET)
1611 #define CPMVEC_SMC2 ((ushort)0x03) 1611 #define CPMVEC_SMC1 ((ushort)0x04 | CPMVEC_OFFSET)
1612 #define CPMVEC_PIO_PC5 ((ushort)0x02) 1612 #define CPMVEC_SMC2 ((ushort)0x03 | CPMVEC_OFFSET)
1613 #define CPMVEC_PIO_PC4 ((ushort)0x01) 1613 #define CPMVEC_PIO_PC5 ((ushort)0x02 | CPMVEC_OFFSET)
1614 #define CPMVEC_ERROR ((ushort)0x00) 1614 #define CPMVEC_PIO_PC4 ((ushort)0x01 | CPMVEC_OFFSET)
1615 #define CPMVEC_ERROR ((ushort)0x00 | CPMVEC_OFFSET)
1615 1616
1616 extern void irq_install_handler(int vec, void (*handler)(void *), void *dev_id); 1617 extern void irq_install_handler(int vec, void (*handler)(void *), void *dev_id);
1617 1618
1618 /* CPM interrupt configuration vector. 1619 /* CPM interrupt configuration vector.
1619 */ 1620 */
1620 #define CICR_SCD_SCC4 ((uint)0x00c00000) /* SCC4 @ SCCd */ 1621 #define CICR_SCD_SCC4 ((uint)0x00c00000) /* SCC4 @ SCCd */
1621 #define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */ 1622 #define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */
1622 #define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */ 1623 #define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */
1623 #define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */ 1624 #define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */
1624 #define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrrupt */ 1625 #define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrrupt */
1625 #define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */ 1626 #define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */
1626 #define CICR_IEN ((uint)0x00000080) /* Int. enable */ 1627 #define CICR_IEN ((uint)0x00000080) /* Int. enable */
1627 #define CICR_SPS ((uint)0x00000001) /* SCC Spread */ 1628 #define CICR_SPS ((uint)0x00000001) /* SCC Spread */
1628 #endif /* __CPM_8XX__ */ 1629 #endif /* __CPM_8XX__ */
1629 1630
include/configs/AmigaOneG3SE.h
1 /* 1 /*
2 * (C) Copyright 2002 2 * (C) Copyright 2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 /* 24 /*
25 * 25 *
26 * Configuration settings for the AmigaOneG3SE board. 26 * Configuration settings for the AmigaOneG3SE board.
27 * 27 *
28 */ 28 */
29 29
30 /* ------------------------------------------------------------------------- */ 30 /* ------------------------------------------------------------------------- */
31 31
32 /* 32 /*
33 * board/config.h - configuration options, board specific 33 * board/config.h - configuration options, board specific
34 */ 34 */
35 35
36 #ifndef __CONFIG_H 36 #ifndef __CONFIG_H
37 #define __CONFIG_H 37 #define __CONFIG_H
38 38
39 /* 39 /*
40 * High Level Configuration Options 40 * High Level Configuration Options
41 * (easy to change) 41 * (easy to change)
42 */ 42 */
43 43
44 #define CONFIG_AMIGAONEG3SE 1 44 #define CONFIG_AMIGAONEG3SE 1
45 45
46 #define CONFIG_BOARD_PRE_INIT 1 46 #define CONFIG_BOARD_PRE_INIT 1
47 #define CONFIG_MISC_INIT_R 1 47 #define CONFIG_MISC_INIT_R 1
48 48
49 #define CONFIG_VERY_BIG_RAM 1 49 #define CONFIG_VERY_BIG_RAM 1
50 50
51 #define CONFIG_CONS_INDEX 1 51 #define CONFIG_CONS_INDEX 1
52 #define CONFIG_BAUDRATE 9600 52 #define CONFIG_BAUDRATE 9600
53 #define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } 53 #define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
54 54
55 #undef CONFIG_CLOCKS_IN_MHZ /* clocks passed to Linux in Hz */ 55 #undef CONFIG_CLOCKS_IN_MHZ /* clocks passed to Linux in Hz */
56 56
57 #define CONFIG_BOOTARGS "root=/dev/ram rw ramdisk=4096" 57 #define CONFIG_BOOTARGS "root=/dev/ram rw ramdisk=4096"
58 58
59 #define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAULT | \ 59 #define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAULT | \
60 CONFIG_BOOTP_BOOTFILESIZE) 60 CONFIG_BOOTP_BOOTFILESIZE)
61 61
62 #define CONFIG_MAC_PARTITION 62 #define CONFIG_MAC_PARTITION
63 #define CONFIG_DOS_PARTITION 63 #define CONFIG_DOS_PARTITION
64 #define CONFIG_AMIGA_PARTITION 64 #define CONFIG_AMIGA_PARTITION
65 65
66 #define CONFIG_COMMANDS (CONFIG_CMD_DFL | \ 66 #define CONFIG_COMMANDS (CONFIG_CMD_DFL | \
67 CFG_CMD_ASKENV | \ 67 CFG_CMD_ASKENV | \
68 CFG_CMD_BSP | \ 68 CFG_CMD_BSP | \
69 CFG_CMD_DATE | \ 69 CFG_CMD_DATE | \
70 CFG_CMD_DHCP | \ 70 CFG_CMD_DHCP | \
71 CFG_CMD_ELF | \ 71 CFG_CMD_ELF | \
72 CFG_CMD_NET | \ 72 CFG_CMD_NET | \
73 CFG_CMD_IDE | \ 73 CFG_CMD_IDE | \
74 CFG_CMD_FDC | \ 74 CFG_CMD_FDC | \
75 CFG_CMD_CACHE | \ 75 CFG_CMD_CACHE | \
76 CFG_CMD_CONSOLE| \ 76 CFG_CMD_CONSOLE| \
77 CFG_CMD_USB | \ 77 CFG_CMD_USB | \
78 CFG_CMD_BSP | \ 78 CFG_CMD_BSP | \
79 CFG_CMD_PCI ) 79 CFG_CMD_PCI )
80 80
81 /* CFG_CMD_MII | \ */ 81 /* CFG_CMD_MII | \ */
82 82
83 #define CONFIG_PCI 1 83 #define CONFIG_PCI 1
84 /* #define CONFIG_PCI_SCAN_SHOW 1 */ 84 /* #define CONFIG_PCI_SCAN_SHOW 1 */
85 #define CONFIG_PCI_PNP 1 /* PCI plug-and-play */ 85 #define CONFIG_PCI_PNP 1 /* PCI plug-and-play */
86 86
87 /* This must be included AFTER the definition of CONFIG_COMMANDS (if any) 87 /* This must be included AFTER the definition of CONFIG_COMMANDS (if any)
88 */ 88 */
89 #include <cmd_confdefs.h> 89 #include <cmd_confdefs.h>
90 90
91 91
92 /* 92 /*
93 * Miscellaneous configurable options 93 * Miscellaneous configurable options
94 */ 94 */
95 #define CFG_LONGHELP /* undef to save memory */ 95 #define CFG_LONGHELP /* undef to save memory */
96 #define CFG_PROMPT "=> " /* Monitor Command Prompt */ 96 #define CFG_PROMPT "] " /* Monitor Command Prompt */
97 97
98 #define CFG_HUSH_PARSER 1 /* use "hush" command parser */ 98 #define CFG_HUSH_PARSER 1 /* use "hush" command parser */
99 /* #undef CFG_HUSH_PARSER */ 99 /* #undef CFG_HUSH_PARSER */
100 #ifdef CFG_HUSH_PARSER 100 #ifdef CFG_HUSH_PARSER
101 #define CFG_PROMPT_HUSH_PS2 "> " 101 #define CFG_PROMPT_HUSH_PS2 "> "
102 #endif 102 #endif
103 #define CFG_CBSIZE 1024 /* Console I/O Buffer Size */ 103 #define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
104 104
105 /* Print Buffer Size 105 /* Print Buffer Size
106 */ 106 */
107 #define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16) 107 #define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)
108 108
109 #define CFG_MAXARGS 64 /* max number of command args */ 109 #define CFG_MAXARGS 64 /* max number of command args */
110 #define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */ 110 #define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
111 #define CFG_LOAD_ADDR 0x00500000 /* Default load address */ 111 #define CFG_LOAD_ADDR 0x00500000 /* Default load address */
112 112
113 /*----------------------------------------------------------------------- 113 /*-----------------------------------------------------------------------
114 * Start addresses for the final memory configuration 114 * Start addresses for the final memory configuration
115 * (Set up by the startup code) 115 * (Set up by the startup code)
116 * Please note that CFG_SDRAM_BASE _must_ start at 0 116 * Please note that CFG_SDRAM_BASE _must_ start at 0
117 */ 117 */
118 #define CFG_SDRAM_BASE 0x00000000 118 #define CFG_SDRAM_BASE 0x00000000
119 #define CFG_FLASH_BASE 0xFFF00000 119 #define CFG_FLASH_BASE 0xFFF00000
120 #define CFG_FLASH_MAX_SIZE 0x00080000 120 #define CFG_FLASH_MAX_SIZE 0x00080000
121 /* Maximum amount of RAM. 121 /* Maximum amount of RAM.
122 */ 122 */
123 #define CFG_MAX_RAM_SIZE 0x80000000 /* 2G */ 123 #define CFG_MAX_RAM_SIZE 0x80000000 /* 2G */
124 124
125 #define CFG_RESET_ADDRESS 0xFFF00100 125 #define CFG_RESET_ADDRESS 0xFFF00100
126 126
127 #define CFG_MONITOR_BASE TEXT_BASE 127 #define CFG_MONITOR_BASE TEXT_BASE
128 128
129 #define CFG_MONITOR_LEN (768 << 10) /* Reserve 512 kB for Monitor */ 129 #define CFG_MONITOR_LEN (768 << 10) /* Reserve 512 kB for Monitor */
130 #define CFG_MALLOC_LEN (2500 << 10) /* Reserve 128 kB for malloc() */ 130 #define CFG_MALLOC_LEN (2500 << 10) /* Reserve 128 kB for malloc() */
131 131
132 #if CFG_MONITOR_BASE >= CFG_SDRAM_BASE && \ 132 #if CFG_MONITOR_BASE >= CFG_SDRAM_BASE && \
133 CFG_MONITOR_BASE < CFG_SDRAM_BASE + CFG_MAX_RAM_SIZE 133 CFG_MONITOR_BASE < CFG_SDRAM_BASE + CFG_MAX_RAM_SIZE
134 #define CFG_RAMBOOT 134 #define CFG_RAMBOOT
135 #else 135 #else
136 #undef CFG_RAMBOOT 136 #undef CFG_RAMBOOT
137 #endif 137 #endif
138 138
139 #define CFG_MEMTEST_START 0x00004000 /* memtest works on */ 139 #define CFG_MEMTEST_START 0x00004000 /* memtest works on */
140 #define CFG_MEMTEST_END 0x02000000 /* 0 ... 32 MB in DRAM */ 140 #define CFG_MEMTEST_END 0x02000000 /* 0 ... 32 MB in DRAM */
141 141
142 /*----------------------------------------------------------------------- 142 /*-----------------------------------------------------------------------
143 * Definitions for initial stack pointer and data area 143 * Definitions for initial stack pointer and data area
144 */ 144 */
145 145
146 /* Size in bytes reserved for initial data 146 /* Size in bytes reserved for initial data
147 */ 147 */
148 #define CFG_INIT_RAM_ADDR 0x400000 148 /* HJF: used to be 0x400000 */
149 #define CFG_INIT_RAM_ADDR 0x40000000
149 #define CFG_INIT_RAM_END 0x8000 150 #define CFG_INIT_RAM_END 0x8000
150 #define CFG_GBL_DATA_SIZE 128 151 #define CFG_GBL_DATA_SIZE 128
151 #define CFG_GBL_DATA_OFFSET (CFG_INIT_RAM_END - CFG_GBL_DATA_SIZE) 152 #define CFG_GBL_DATA_OFFSET (CFG_INIT_RAM_END - CFG_GBL_DATA_SIZE)
152 #define CFG_INIT_SP_OFFSET CFG_GBL_DATA_OFFSET 153 #define CFG_INIT_SP_OFFSET CFG_GBL_DATA_OFFSET
153 154
154 #define CFG_INIT_RAM_LOCK 155 #define CFG_INIT_RAM_LOCK
155 156
156 /* 157 /*
157 * Temporary buffer for serial data until the real serial driver 158 * Temporary buffer for serial data until the real serial driver
158 * is initialised (memtest will destroy this buffer) 159 * is initialised (memtest will destroy this buffer)
159 */ 160 */
160 #define CFG_SCONSOLE_ADDR CFG_INIT_RAM_ADDR 161 #define CFG_SCONSOLE_ADDR CFG_INIT_RAM_ADDR
161 #define CFG_SCONSOLE_SIZE 0x0002000 162 #define CFG_SCONSOLE_SIZE 0x0002000
162 163
163 /* SDRAM 0 - 256MB 164 /* SDRAM 0 - 256MB
164 */ 165 */
165 166
166 #define CFG_IBAT0L (CFG_SDRAM_BASE | BATL_PP_RW | BATL_CACHEINHIBIT) 167 /*HJF: #define CFG_IBAT0L (CFG_SDRAM_BASE | BATL_PP_RW | BATL_CACHEINHIBIT)
167 #define CFG_IBAT0U (CFG_SDRAM_BASE | BATU_BL_4M | BATU_VS | BATU_VP) 168 #define CFG_IBAT0U (CFG_SDRAM_BASE | BATU_BL_4M | BATU_VS | BATU_VP)
168 #define CFG_DBAT0L (CFG_SDRAM_BASE | BATL_PP_RW | BATL_CACHEINHIBIT) 169 #define CFG_DBAT0L (CFG_SDRAM_BASE | BATL_PP_RW | BATL_CACHEINHIBIT)
169 #define CFG_DBAT0U CFG_IBAT0U 170 #define CFG_DBAT0U CFG_IBAT0U*/
170 171
171 /* SDRAM 1 - 256MB 172 #define CFG_DBAT0L (CFG_SDRAM_BASE | BATL_PP_10 | BATL_MEMCOHERENCE)
173 #define CFG_DBAT0U (CFG_SDRAM_BASE | BATU_BL_256M | BATU_VS | BATU_VP)
174 #define CFG_IBAT0L (CFG_SDRAM_BASE | BATL_PP_10 | BATL_MEMCOHERENCE)
175 #define CFG_IBAT0U (CFG_SDRAM_BASE | BATU_BL_256M | BATU_VS | BATU_VP)
176 /* PCI Range
172 */ 177 */
173 #define CFG_IBAT1L ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR) | BATL_PP_RW) /* | BATL_CACHEINHIBIT) */ 178 #define CFG_DBAT1L (0x80000000 | BATL_PP_RW | BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE)
179 #define CFG_DBAT1U (0x80000000 | BATU_BL_256M | BATU_VS | BATU_VP)
180 #define CFG_IBAT1L (0x80000000 | BATL_PP_RW | BATL_CACHEINHIBIT)
181 #define CFG_IBAT1U (0x80000000 | BATU_BL_256M | BATU_VS | BATU_VP)
182 /* HJF:
183 #define CFG_IBAT1L ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR) | BATL_PP_RW)
174 #define CFG_IBAT1U ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR) | BATU_BL_256M | BATU_VS | BATU_VP) 184 #define CFG_IBAT1U ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR) | BATU_BL_256M | BATU_VS | BATU_VP)
175 #define CFG_DBAT1L ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR + 0x20000) | BATL_PP_RW ) /* | BATL_CACHEINHIBIT) */ 185 #define CFG_DBAT1L ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR + 0x20000) | BATL_PP_RW )
176 #define CFG_DBAT1U ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR + 0x20000) | BATU_BL_256M | BATU_VS | BATU_VP) 186 #define CFG_DBAT1U ((CFG_SDRAM_BASE+CFG_INIT_RAM_ADDR + 0x20000) | BATU_BL_256M | BATU_VS | BATU_VP)
187 */
177 188
178 /* Init RAM in the CPU DCache (no backing memory) 189 /* Init RAM in the CPU DCache (no backing memory)
179 */ 190 */
180 #define CFG_DBAT2L (CFG_INIT_RAM_ADDR | BATL_PP_RW | BATL_MEMCOHERENCE) 191 #define CFG_DBAT2L (CFG_INIT_RAM_ADDR | BATL_PP_RW | BATL_MEMCOHERENCE)
181 #define CFG_DBAT2U (CFG_INIT_RAM_ADDR | BATU_BL_128K | BATU_VS | BATU_VP) 192 #define CFG_DBAT2U (CFG_INIT_RAM_ADDR | BATU_BL_128K | BATU_VS | BATU_VP)
182 #define CFG_IBAT2L 0 /* CFG_DBAT2L */ 193 /* This used to be commented out */
183 #define CFG_IBAT2U 0 /* CFG_DBAT2U */ 194 #define CFG_IBAT2L CFG_DBAT2L
195 /* This here too */
196 #define CFG_IBAT2U CFG_DBAT2U
184 197
198
185 /* I/O and PCI memory at 0xf0000000 199 /* I/O and PCI memory at 0xf0000000
186 */ 200 */
187 #define CFG_DBAT3L (0xf0000000 | BATL_PP_RW | BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE) 201 #define CFG_DBAT3L (0xf0000000 | BATL_PP_RW | BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE)
188 #define CFG_DBAT3U (0xf0000000 | BATU_BL_256M | BATU_VS | BATU_VP) 202 #define CFG_DBAT3U (0xf0000000 | BATU_BL_256M | BATU_VS | BATU_VP)
189 203
190 #define CFG_IBAT3L (0xf0000000 | BATL_PP_RW | BATL_CACHEINHIBIT) 204 #define CFG_IBAT3L (0xf0000000 | BATL_PP_RW | BATL_CACHEINHIBIT)
191 #define CFG_IBAT3U (0xf0000000 | BATU_BL_256M | BATU_VS | BATU_VP) 205 #define CFG_IBAT3U (0xf0000000 | BATU_BL_256M | BATU_VS | BATU_VP)
192 206
193 /* 207 /*
194 * Low Level Configuration Settings 208 * Low Level Configuration Settings
195 * (address mappings, register initial values, etc.) 209 * (address mappings, register initial values, etc.)
196 */ 210 */
197 #define CFG_HZ 1000 211 #define CFG_HZ 1000
198 #define CFG_BUS_HZ 133000000 /* bus speed - 100 mhz */ 212 #define CFG_BUS_HZ 133000000 /* bus speed - 100 mhz */
199 #define CFG_CPU_CLK 133000000 213 #define CFG_CPU_CLK 133000000
200 #define CFG_BUS_CLK 133000000 214 #define CFG_BUS_CLK 133000000
201 215
202 /* 216 /*
203 * For booting Linux, the board info and command line data 217 * For booting Linux, the board info and command line data
204 * have to be in the first 8 MB of memory, since this is 218 * have to be in the first 8 MB of memory, since this is
205 * the maximum mapped by the Linux kernel during initialization. 219 * the maximum mapped by the Linux kernel during initialization.
206 */ 220 */
207 #define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */ 221 #define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */
208 222
209 /*----------------------------------------------------------------------- 223 /*-----------------------------------------------------------------------
210 * FLASH organization 224 * FLASH organization
211 */ 225 */
212 #define CFG_MAX_FLASH_BANKS 1 /* Max number of flash banks */ 226 #define CFG_MAX_FLASH_BANKS 1 /* Max number of flash banks */
213 #define CFG_MAX_FLASH_SECT 8 /* Max number of sectors in one bank */ 227 #define CFG_MAX_FLASH_SECT 8 /* Max number of sectors in one bank */
214 228
215 #define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */ 229 #define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */
216 #define CFG_FLASH_WRITE_TOUT 1000 /* Timeout for Flash Write (in ms) */ 230 #define CFG_FLASH_WRITE_TOUT 1000 /* Timeout for Flash Write (in ms) */
217 231
218 /* 232 /*
219 * Environment is stored in NVRAM. 233 * Environment is stored in NVRAM.
220 */ 234 */
221 #define CFG_ENV_IS_IN_NVRAM 1 235 #define CFG_ENV_IS_IN_NVRAM 1
222 #define CFG_ENV_ADDR 0xFD0E0000 /* This should be 0xFD0E0000, but we skip bytes to 236 #define CFG_ENV_ADDR 0xFD0E0000 /* This should be 0xFD0E0000, but we skip bytes to
223 * protect softex's settings for now. 237 * protect softex's settings for now.
224 * Original 768 bytes where not enough. 238 * Original 768 bytes where not enough.
225 */ 239 */
226 #define CFG_ENV_SIZE 0x8000 /* Size of the Environment. See comment above */ 240 #define CFG_ENV_SIZE 0x8000 /* Size of the Environment. See comment above */
227 241
228 #define CFG_CONSOLE_IS_IN_ENV 1 /* stdin/stdout/stderr are in environment */ 242 #define CFG_CONSOLE_IS_IN_ENV 1 /* stdin/stdout/stderr are in environment */
229 #define CFG_CONSOLE_OVERWRITE_ROUTINE 1 243 #define CFG_CONSOLE_OVERWRITE_ROUTINE 1
230 #define CONFIG_ENV_OVERWRITE 1 244 #define CONFIG_ENV_OVERWRITE 1
231 245
232 /*----------------------------------------------------------------------- 246 /*-----------------------------------------------------------------------
233 * Cache Configuration 247 * Cache Configuration
234 */ 248 */
235 #define CFG_CACHELINE_SIZE 32 249 #define CFG_CACHELINE_SIZE 32
236 #if (CONFIG_COMMANDS & CFG_CMD_KGDB) 250 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
237 # define CFG_CACHELINE_SHIFT 5 /* log base 2 of the above value */ 251 # define CFG_CACHELINE_SHIFT 5 /* log base 2 of the above value */
238 #endif 252 #endif
239 253
240 /* 254 /*
241 * L2 cache 255 * L2 cache
242 */ 256 */
243 #define CFG_L2 257 #define CFG_L2
244 #define L2_INIT (L2CR_L2SIZ_2M | L2CR_L2CLK_3 | L2CR_L2RAM_BURST | \ 258 #define L2_INIT (L2CR_L2SIZ_2M | L2CR_L2CLK_3 | L2CR_L2RAM_BURST | \
245 L2CR_L2OH_5 | L2CR_L2CTL | L2CR_L2WT) 259 L2CR_L2OH_5 | L2CR_L2CTL | L2CR_L2WT)
246 #define L2_ENABLE (L2_INIT | L2CR_L2E) 260 #define L2_ENABLE (L2_INIT | L2CR_L2E)
247 261
248 /* 262 /*
249 * Internal Definitions 263 * Internal Definitions
250 * 264 *
251 * Boot Flags 265 * Boot Flags
252 */ 266 */
253 #define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */ 267 #define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */
254 #define BOOTFLAG_WARM 0x02 /* Software reboot */ 268 #define BOOTFLAG_WARM 0x02 /* Software reboot */
255 269
256 270
257 /*----------------------------------------------------------------------- 271 /*-----------------------------------------------------------------------
258 * IDE ATAPI Configuration 272 * IDE ATAPI Configuration
259 */ 273 */
260 274
261 #define CONFIG_ATAPI 1 275 #define CONFIG_ATAPI 1
262 #define CFG_IDE_MAXBUS 2 276 #define CFG_IDE_MAXBUS 2
263 #define CFG_IDE_MAXDEVICE 4 277 #define CFG_IDE_MAXDEVICE 4
264 #define CONFIG_ISO_PARTITION 1 278 #define CONFIG_ISO_PARTITION 1
265 279
266 #define CFG_ATA_BASE_ADDR 0xFE000000 /* was: via_get_base_addr() */ 280 #define CFG_ATA_BASE_ADDR 0xFE000000 /* was: via_get_base_addr() */
267 #define CFG_ATA_IDE0_OFFSET 0x1F0 281 #define CFG_ATA_IDE0_OFFSET 0x1F0
268 #define CFG_ATA_IDE1_OFFSET 0x170 282 #define CFG_ATA_IDE1_OFFSET 0x170
269 283
270 #define CFG_ATA_REG_OFFSET 0 284 #define CFG_ATA_REG_OFFSET 0
271 #define CFG_ATA_DATA_OFFSET 0 285 #define CFG_ATA_DATA_OFFSET 0
272 #define CFG_ATA_ALT_OFFSET 0x0200 286 #define CFG_ATA_ALT_OFFSET 0x0200
273 287
274 /*----------------------------------------------------------------------- 288 /*-----------------------------------------------------------------------
275 * Disk-On-Chip configuration 289 * Disk-On-Chip configuration
276 */ 290 */
277 291
278 #define CFG_MAX_DOC_DEVICE 1 /* Max number of DOC devices */ 292 #define CFG_MAX_DOC_DEVICE 1 /* Max number of DOC devices */
279 293
280 #define CFG_DOC_SUPPORT_2000 294 #define CFG_DOC_SUPPORT_2000
281 #undef CFG_DOC_SUPPORT_MILLENNIUM 295 #undef CFG_DOC_SUPPORT_MILLENNIUM
282 296
283 /*----------------------------------------------------------------------- 297 /*-----------------------------------------------------------------------
284 RTC 298 RTC
285 */ 299 */
286 #define CONFIG_RTC_MC146818 300 #define CONFIG_RTC_MC146818
287 301
288 /*----------------------------------------------------------------------- 302 /*-----------------------------------------------------------------------
289 * NS16550 Configuration 303 * NS16550 Configuration
290 */ 304 */
291 305
292 #define CFG_NS16550 306 #define CFG_NS16550
293 307
294 #define CFG_NS16550_COM1 0xFE0003F8 308 #define CFG_NS16550_COM1 0xFE0003F8
295 #define CFG_NS16550_COM2 0xFE0002F8 309 #define CFG_NS16550_COM2 0xFE0002F8
296 310
297 #define CFG_NS16550_REG_SIZE 1 311 #define CFG_NS16550_REG_SIZE 1
298 312
299 /* base address for ISA I/O 313 /* base address for ISA I/O
300 */ 314 */
301 #define CFG_ISA_IO_BASE_ADDRESS 0xFE000000 315 #define CFG_ISA_IO_BASE_ADDRESS 0xFE000000
302 316
303 /* ISA Interrupt stuff (taken from JWL) */ 317 /* ISA Interrupt stuff (taken from JWL) */
304 318
305 #define ISA_INT1_OCW1 0x21 319 #define ISA_INT1_OCW1 0x21
306 #define ISA_INT2_OCW1 0xA1 320 #define ISA_INT2_OCW1 0xA1
307 #define ISA_INT1_OCW2 0x20 321 #define ISA_INT1_OCW2 0x20
308 #define ISA_INT2_OCW2 0xA0 322 #define ISA_INT2_OCW2 0xA0
309 #define ISA_INT1_OCW3 0x20 323 #define ISA_INT1_OCW3 0x20
310 #define ISA_INT2_OCW3 0xA0 324 #define ISA_INT2_OCW3 0xA0
311 325
312 #define ISA_INT1_ICW1 0x20 326 #define ISA_INT1_ICW1 0x20
313 #define ISA_INT2_ICW1 0xA0 327 #define ISA_INT2_ICW1 0xA0
314 #define ISA_INT1_ICW2 0x21 328 #define ISA_INT1_ICW2 0x21
315 #define ISA_INT2_ICW2 0xA1 329 #define ISA_INT2_ICW2 0xA1
316 #define ISA_INT1_ICW3 0x21 330 #define ISA_INT1_ICW3 0x21
317 #define ISA_INT2_ICW3 0xA1 331 #define ISA_INT2_ICW3 0xA1
318 #define ISA_INT1_ICW4 0x21 332 #define ISA_INT1_ICW4 0x21
319 #define ISA_INT2_ICW4 0xA1 333 #define ISA_INT2_ICW4 0xA1
320 334
321 335
322 /* 336 /*
323 * misc 337 * misc
324 */ 338 */
325 339
326 #define CONFIG_NET_MULTI 340 #define CONFIG_NET_MULTI
327 #define CFG_BOARD_ASM_INIT 341 #define CFG_BOARD_ASM_INIT
328 #define CONFIG_LAST_STAGE_INIT 342 #define CONFIG_LAST_STAGE_INIT
329 343
330 /* #define CONFIG_ETHADDR 00:09:D2:10:00:76 */ 344 /* #define CONFIG_ETHADDR 00:09:D2:10:00:76 */
331 /* #define CONFIG_IPADDR 192.168.0.2 */ 345 /* #define CONFIG_IPADDR 192.168.0.2 */
332 /* #define CONFIG_NETMASK 255.255.255.240 */ 346 /* #define CONFIG_NETMASK 255.255.255.240 */
333 /* #define CONFIG_GATEWAYIP 192.168.0.3 */ 347 /* #define CONFIG_GATEWAYIP 192.168.0.3 */
334 348
335 #define CONFIG_3COM 349 #define CONFIG_3COM
336 /* #define CONFIG_BOOTP_RANDOM_DELAY */ 350 /* #define CONFIG_BOOTP_RANDOM_DELAY */
337 #define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAULT | \ 351 #define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAULT | \
338 CONFIG_BOOTP_BOOTFILESIZE) 352 CONFIG_BOOTP_BOOTFILESIZE)
339 353
340 /* 354 /*
341 * USB configuration 355 * USB configuration
342 */ 356 */
343 #define CONFIG_USB_UHCI 1 357 #define CONFIG_USB_UHCI 1
344 #define CONFIG_USB_STORAGE 1 358 #define CONFIG_USB_STORAGE 1
345 #define CONFIG_USB_KEYBOARD 1 359 #define CONFIG_USB_KEYBOARD 1
346 #define CFG_DEVICE_DEREGISTER 1 /* needed by CONFIG_USB_KEYBOARD */ 360 #define CFG_DEVICE_DEREGISTER 1 /* needed by CONFIG_USB_KEYBOARD */
347 361
348 /* 362 /*
349 * Autoboot stuff 363 * Autoboot stuff
350 */ 364 */
351 #define CONFIG_BOOTDELAY 5 /* Boot automatically after five seconds */ 365 #define CONFIG_BOOTDELAY 5 /* Boot automatically after five seconds */
352 #define CONFIG_PREBOOT "" 366 #define CONFIG_PREBOOT ""
353 #define CONFIG_BOOTCOMMAND "fdcboot; diskboot" 367 #define CONFIG_BOOTCOMMAND "fdcboot; diskboot"
354 #define CONFIG_MENUPROMPT "Press any key to interrupt autoboot: %2d " 368 #define CONFIG_MENUPROMPT "Press any key to interrupt autoboot: %2d "
355 #define CONFIG_MENUKEY ' ' 369 #define CONFIG_MENUKEY ' '
356 #define CONFIG_MENUCOMMAND "menu" 370 #define CONFIG_MENUCOMMAND "menu"
357 /* #define CONFIG_AUTOBOOT_KEYED */ 371 /* #define CONFIG_AUTOBOOT_KEYED */
358 372
359 /* 373 /*
360 * Extra ENV stuff 374 * Extra ENV stuff
361 */ 375 */
362 #define CONFIG_EXTRA_ENV_SETTINGS \ 376 #define CONFIG_EXTRA_ENV_SETTINGS \
363 "stdout=vga\0" \ 377 "stdout=vga\0" \
364 "stdin=ps2kbd\0" \ 378 "stdin=ps2kbd\0" \
365 "ide_doreset=on\0" \ 379 "ide_doreset=on\0" \
366 "ide_maxbus=2\0" \ 380 "ide_maxbus=2\0" \
367 "ide_cd_timeout=30\0" \ 381 "ide_cd_timeout=30\0" \
368 "menucmd=menu\0" \ 382 "menucmd=menu\0" \
369 "pci_irqa=9\0" \ 383 "pci_irqa=9\0" \
370 "pci_irqa_select=edge\0" \ 384 "pci_irqa_select=edge\0" \
371 "pci_irqb=10\0" \ 385 "pci_irqb=10\0" \
372 "pci_irqb_select=edge\0" \ 386 "pci_irqb_select=edge\0" \
373 "pci_irqc=11\0" \ 387 "pci_irqc=11\0" \
374 "pci_irqc_select=edge\0" \ 388 "pci_irqc_select=edge\0" \
375 "pci_irqd=12\0" \ 389 "pci_irqd=7\0" \
376 "pci_irqd_select=edge\0" 390 "pci_irqd_select=edge\0"
377 391
378 392
379 /* #define CONFIG_MII 1 */ 393 /* #define CONFIG_MII 1 */
380 /* #define CONFIG_BITBANGMII 1 */ 394 /* #define CONFIG_BITBANGMII 1 */
381 395
382 396
383 #endif /* __CONFIG_H */ 397 #endif /* __CONFIG_H */
384 398
1 /* 1 /*
2 * (C) Copyright 2000-2002 2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 #include <common.h> 24 #include <common.h>
25 #include <watchdog.h> 25 #include <watchdog.h>
26 #include <command.h> 26 #include <command.h>
27 #include <malloc.h> 27 #include <malloc.h>
28 #include <devices.h> 28 #include <devices.h>
29 #include <syscall.h> 29 #include <syscall.h>
30 #ifdef CONFIG_8xx 30 #ifdef CONFIG_8xx
31 #include <mpc8xx.h> 31 #include <mpc8xx.h>
32 #endif 32 #endif
33 #if (CONFIG_COMMANDS & CFG_CMD_IDE) 33 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
34 #include <ide.h> 34 #include <ide.h>
35 #endif 35 #endif
36 #if (CONFIG_COMMANDS & CFG_CMD_SCSI) 36 #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
37 #include <scsi.h> 37 #include <scsi.h>
38 #endif 38 #endif
39 #if (CONFIG_COMMANDS & CFG_CMD_KGDB) 39 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
40 #include <kgdb.h> 40 #include <kgdb.h>
41 #endif 41 #endif
42 #ifdef CONFIG_STATUS_LED 42 #ifdef CONFIG_STATUS_LED
43 #include <status_led.h> 43 #include <status_led.h>
44 #endif 44 #endif
45 #include <net.h> 45 #include <net.h>
46 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) 46 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
47 #include <cmd_bedbug.h> 47 #include <cmd_bedbug.h>
48 #endif 48 #endif
49 #ifdef CFG_ALLOC_DPRAM 49 #ifdef CFG_ALLOC_DPRAM
50 #include <commproc.h> 50 #include <commproc.h>
51 #endif 51 #endif
52 #include <version.h> 52 #include <version.h>
53 #if defined(CONFIG_BAB7xx) 53 #if defined(CONFIG_BAB7xx)
54 #include <w83c553f.h> 54 #include <w83c553f.h>
55 #endif 55 #endif
56 #include <dtt.h> 56 #include <dtt.h>
57 #if defined(CONFIG_POST) 57 #if defined(CONFIG_POST)
58 #include <post.h> 58 #include <post.h>
59 #endif 59 #endif
60 #if defined(CONFIG_LOGBUFFER) 60 #if defined(CONFIG_LOGBUFFER)
61 #include <logbuff.h> 61 #include <logbuff.h>
62 #endif 62 #endif
63 63
64 #if (CONFIG_COMMANDS & CFG_CMD_DOC) 64 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
65 void doc_init (void); 65 void doc_init (void);
66 #endif 66 #endif
67 #if defined(CONFIG_HARD_I2C) || \ 67 #if defined(CONFIG_HARD_I2C) || \
68 defined(CONFIG_SOFT_I2C) 68 defined(CONFIG_SOFT_I2C)
69 #include <i2c.h> 69 #include <i2c.h>
70 #endif 70 #endif
71 71
72 static char *failed = "*** failed ***\n"; 72 static char *failed = "*** failed ***\n";
73 73
74 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) 74 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
75 extern flash_info_t flash_info[]; 75 extern flash_info_t flash_info[];
76 #endif 76 #endif
77 77
78 #include <environment.h> 78 #include <environment.h>
79 79
80 #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \ 80 #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
81 (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \ 81 (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
82 defined(CFG_ENV_IS_IN_NVRAM) 82 defined(CFG_ENV_IS_IN_NVRAM)
83 #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE) 83 #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
84 #else 84 #else
85 #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN 85 #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
86 #endif 86 #endif
87 87
88 /* 88 /*
89 * Begin and End of memory area for malloc(), and current "brk" 89 * Begin and End of memory area for malloc(), and current "brk"
90 */ 90 */
91 static ulong mem_malloc_start = 0; 91 static ulong mem_malloc_start = 0;
92 static ulong mem_malloc_end = 0; 92 static ulong mem_malloc_end = 0;
93 static ulong mem_malloc_brk = 0; 93 static ulong mem_malloc_brk = 0;
94 94
95 /************************************************************************ 95 /************************************************************************
96 * Utilities * 96 * Utilities *
97 ************************************************************************ 97 ************************************************************************
98 */ 98 */
99 99
100 /* 100 /*
101 * The Malloc area is immediately below the monitor copy in DRAM 101 * The Malloc area is immediately below the monitor copy in DRAM
102 */ 102 */
103 static void mem_malloc_init (void) 103 static void mem_malloc_init (void)
104 { 104 {
105 DECLARE_GLOBAL_DATA_PTR; 105 DECLARE_GLOBAL_DATA_PTR;
106 106
107 ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off; 107 ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
108 108
109 mem_malloc_end = dest_addr; 109 mem_malloc_end = dest_addr;
110 mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN; 110 mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
111 mem_malloc_brk = mem_malloc_start; 111 mem_malloc_brk = mem_malloc_start;
112 112
113 memset ((void *) mem_malloc_start, 113 memset ((void *) mem_malloc_start,
114 0, 114 0,
115 mem_malloc_end - mem_malloc_start); 115 mem_malloc_end - mem_malloc_start);
116 } 116 }
117 117
118 void *sbrk (ptrdiff_t increment) 118 void *sbrk (ptrdiff_t increment)
119 { 119 {
120 ulong old = mem_malloc_brk; 120 ulong old = mem_malloc_brk;
121 ulong new = old + increment; 121 ulong new = old + increment;
122 122
123 if ((new < mem_malloc_start) || (new > mem_malloc_end)) { 123 if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
124 return (NULL); 124 return (NULL);
125 } 125 }
126 mem_malloc_brk = new; 126 mem_malloc_brk = new;
127 return ((void *) old); 127 return ((void *) old);
128 } 128 }
129 129
130 char *strmhz (char *buf, long hz) 130 char *strmhz (char *buf, long hz)
131 { 131 {
132 long l, n; 132 long l, n;
133 long m; 133 long m;
134 134
135 n = hz / 1000000L; 135 n = hz / 1000000L;
136 l = sprintf (buf, "%ld", n); 136 l = sprintf (buf, "%ld", n);
137 m = (hz % 1000000L) / 1000L; 137 m = (hz % 1000000L) / 1000L;
138 if (m != 0) 138 if (m != 0)
139 sprintf (buf + l, ".%03ld", m); 139 sprintf (buf + l, ".%03ld", m);
140 return (buf); 140 return (buf);
141 } 141 }
142 142
143 static void syscalls_init (void) 143 static void syscalls_init (void)
144 { 144 {
145 ulong *addr; 145 ulong *addr;
146 146
147 syscall_tbl[SYSCALL_MALLOC] = (void *) malloc; 147 syscall_tbl[SYSCALL_MALLOC] = (void *) malloc;
148 syscall_tbl[SYSCALL_FREE] = (void *) free; 148 syscall_tbl[SYSCALL_FREE] = (void *) free;
149 149
150 syscall_tbl[SYSCALL_INSTALL_HDLR] = (void *) irq_install_handler; 150 syscall_tbl[SYSCALL_INSTALL_HDLR] = (void *) irq_install_handler;
151 syscall_tbl[SYSCALL_FREE_HDLR] = (void *) irq_free_handler; 151 syscall_tbl[SYSCALL_FREE_HDLR] = (void *) irq_free_handler;
152 syscall_tbl[SYSCALL_GET_TIMER] = (void *)get_timer; 152 syscall_tbl[SYSCALL_GET_TIMER] = (void *)get_timer;
153 syscall_tbl[SYSCALL_UDELAY] = (void *)udelay; 153 syscall_tbl[SYSCALL_UDELAY] = (void *)udelay;
154 154
155 addr = (ulong *) 0xc00; /* syscall ISR addr */ 155 addr = (ulong *) 0xc00; /* syscall ISR addr */
156 156
157 /* patch ISR code */ 157 /* patch ISR code */
158 *addr++ |= (ulong) syscall_tbl >> 16; 158 *addr++ |= (ulong) syscall_tbl >> 16;
159 *addr++ |= (ulong) syscall_tbl & 0xFFFF; 159 *addr++ |= (ulong) syscall_tbl & 0xFFFF;
160 *addr++ |= NR_SYSCALLS >> 16; 160 *addr++ |= NR_SYSCALLS >> 16;
161 *addr++ |= NR_SYSCALLS & 0xFFFF; 161 *addr++ |= NR_SYSCALLS & 0xFFFF;
162 162
163 flush_cache (0x0C00, 0x10); 163 flush_cache (0x0C00, 0x10);
164
165 /* Initialize syscalls stack pointer */
166 addr = (ulong *) 0xCFC;
167 *addr = (ulong)addr;
168 flush_cache ((ulong)addr, 0x10);
164 } 169 }
165 170
166 /* 171 /*
167 * All attempts to come up with a "common" initialization sequence 172 * All attempts to come up with a "common" initialization sequence
168 * that works for all boards and architectures failed: some of the 173 * that works for all boards and architectures failed: some of the
169 * requirements are just _too_ different. To get rid of the resulting 174 * requirements are just _too_ different. To get rid of the resulting
170 * mess of board dependend #ifdef'ed code we now make the whole 175 * mess of board dependend #ifdef'ed code we now make the whole
171 * initialization sequence configurable to the user. 176 * initialization sequence configurable to the user.
172 * 177 *
173 * The requirements for any new initalization function is simple: it 178 * The requirements for any new initalization function is simple: it
174 * receives a pointer to the "global data" structure as it's only 179 * receives a pointer to the "global data" structure as it's only
175 * argument, and returns an integer return code, where 0 means 180 * argument, and returns an integer return code, where 0 means
176 * "continue" and != 0 means "fatal error, hang the system". 181 * "continue" and != 0 means "fatal error, hang the system".
177 */ 182 */
178 typedef int (init_fnc_t) (void); 183 typedef int (init_fnc_t) (void);
179 184
180 /************************************************************************ 185 /************************************************************************
181 * Init Utilities * 186 * Init Utilities *
182 ************************************************************************ 187 ************************************************************************
183 * Some of this code should be moved into the core functions, 188 * Some of this code should be moved into the core functions,
184 * but let's get it working (again) first... 189 * but let's get it working (again) first...
185 */ 190 */
186 191
187 static int init_baudrate (void) 192 static int init_baudrate (void)
188 { 193 {
189 DECLARE_GLOBAL_DATA_PTR; 194 DECLARE_GLOBAL_DATA_PTR;
190 195
191 uchar tmp[64]; /* long enough for environment variables */ 196 uchar tmp[64]; /* long enough for environment variables */
192 int i = getenv_r ("baudrate", tmp, sizeof (tmp)); 197 int i = getenv_r ("baudrate", tmp, sizeof (tmp));
193 198
194 gd->baudrate = (i > 0) 199 gd->baudrate = (i > 0)
195 ? (int) simple_strtoul (tmp, NULL, 10) 200 ? (int) simple_strtoul (tmp, NULL, 10)
196 : CONFIG_BAUDRATE; 201 : CONFIG_BAUDRATE;
197 202
198 return (0); 203 return (0);
199 } 204 }
200 205
201 /***********************************************************************/ 206 /***********************************************************************/
202 207
203 static int init_func_ram (void) 208 static int init_func_ram (void)
204 { 209 {
205 DECLARE_GLOBAL_DATA_PTR; 210 DECLARE_GLOBAL_DATA_PTR;
206 211
207 #ifdef CONFIG_BOARD_TYPES 212 #ifdef CONFIG_BOARD_TYPES
208 int board_type = gd->board_type; 213 int board_type = gd->board_type;
209 #else 214 #else
210 int board_type = 0; /* use dummy arg */ 215 int board_type = 0; /* use dummy arg */
211 #endif 216 #endif
212 puts ("DRAM: "); 217 puts ("DRAM: ");
213 218
214 if ((gd->ram_size = initdram (board_type)) > 0) { 219 if ((gd->ram_size = initdram (board_type)) > 0) {
215 print_size (gd->ram_size, "\n"); 220 print_size (gd->ram_size, "\n");
216 return (0); 221 return (0);
217 } 222 }
218 puts (failed); 223 puts (failed);
219 return (1); 224 return (1);
220 } 225 }
221 226
222 /***********************************************************************/ 227 /***********************************************************************/
223 228
224 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) 229 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
225 static int init_func_i2c (void) 230 static int init_func_i2c (void)
226 { 231 {
227 puts ("I2C: "); 232 puts ("I2C: ");
228 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); 233 i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
229 puts ("ready\n"); 234 puts ("ready\n");
230 return (0); 235 return (0);
231 } 236 }
232 #endif 237 #endif
233 238
234 /***********************************************************************/ 239 /***********************************************************************/
235 240
236 #if defined(CONFIG_WATCHDOG) 241 #if defined(CONFIG_WATCHDOG)
237 static int init_func_watchdog_init (void) 242 static int init_func_watchdog_init (void)
238 { 243 {
239 puts (" Watchdog enabled\n"); 244 puts (" Watchdog enabled\n");
240 WATCHDOG_RESET (); 245 WATCHDOG_RESET ();
241 return (0); 246 return (0);
242 } 247 }
243 # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init, 248 # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init,
244 249
245 static int init_func_watchdog_reset (void) 250 static int init_func_watchdog_reset (void)
246 { 251 {
247 WATCHDOG_RESET (); 252 WATCHDOG_RESET ();
248 return (0); 253 return (0);
249 } 254 }
250 # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset, 255 # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset,
251 #else 256 #else
252 # define INIT_FUNC_WATCHDOG_INIT /* undef */ 257 # define INIT_FUNC_WATCHDOG_INIT /* undef */
253 # define INIT_FUNC_WATCHDOG_RESET /* undef */ 258 # define INIT_FUNC_WATCHDOG_RESET /* undef */
254 #endif /* CONFIG_WATCHDOG */ 259 #endif /* CONFIG_WATCHDOG */
255 260
256 /************************************************************************ 261 /************************************************************************
257 * Initialization sequence * 262 * Initialization sequence *
258 ************************************************************************ 263 ************************************************************************
259 */ 264 */
260 265
261 init_fnc_t *init_sequence[] = { 266 init_fnc_t *init_sequence[] = {
262 267
263 #if defined(CONFIG_BOARD_PRE_INIT) 268 #if defined(CONFIG_BOARD_PRE_INIT)
264 board_pre_init, /* very early board init code (fpga boot, etc.) */ 269 board_pre_init, /* very early board init code (fpga boot, etc.) */
265 #endif 270 #endif
266 271
267 get_clocks, /* get CPU and bus clocks (etc.) */ 272 get_clocks, /* get CPU and bus clocks (etc.) */
268 init_timebase, 273 init_timebase,
269 #ifdef CFG_ALLOC_DPRAM 274 #ifdef CFG_ALLOC_DPRAM
270 dpram_init, 275 dpram_init,
271 #endif 276 #endif
272 #if defined(CONFIG_BOARD_POSTCLK_INIT) 277 #if defined(CONFIG_BOARD_POSTCLK_INIT)
273 board_postclk_init, 278 board_postclk_init,
274 #endif 279 #endif
275 env_init, 280 env_init,
276 init_baudrate, 281 init_baudrate,
277 serial_init, 282 serial_init,
278 console_init_f, 283 console_init_f,
279 display_options, 284 display_options,
280 #if defined(CONFIG_8260) 285 #if defined(CONFIG_8260)
281 prt_8260_rsr, 286 prt_8260_rsr,
282 prt_8260_clks, 287 prt_8260_clks,
283 #endif /* CONFIG_8260 */ 288 #endif /* CONFIG_8260 */
284 checkcpu, 289 checkcpu,
285 checkboard, 290 checkboard,
286 INIT_FUNC_WATCHDOG_INIT 291 INIT_FUNC_WATCHDOG_INIT
287 #if defined(CONFIG_BMW) || \ 292 #if defined(CONFIG_BMW) || \
288 defined(CONFIG_COGENT) || \ 293 defined(CONFIG_COGENT) || \
289 defined(CONFIG_HYMOD) || \ 294 defined(CONFIG_HYMOD) || \
290 defined(CONFIG_RSD_PROTO) || \ 295 defined(CONFIG_RSD_PROTO) || \
291 defined(CONFIG_W7O) 296 defined(CONFIG_W7O)
292 misc_init_f, 297 misc_init_f,
293 #endif 298 #endif
294 INIT_FUNC_WATCHDOG_RESET 299 INIT_FUNC_WATCHDOG_RESET
295 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) 300 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
296 init_func_i2c, 301 init_func_i2c,
297 #endif 302 #endif
298 #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */ 303 #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */
299 dtt_init, 304 dtt_init,
300 #endif 305 #endif
301 INIT_FUNC_WATCHDOG_RESET 306 INIT_FUNC_WATCHDOG_RESET
302 init_func_ram, 307 init_func_ram,
303 #if defined(CFG_DRAM_TEST) 308 #if defined(CFG_DRAM_TEST)
304 testdram, 309 testdram,
305 #endif /* CFG_DRAM_TEST */ 310 #endif /* CFG_DRAM_TEST */
306 INIT_FUNC_WATCHDOG_RESET 311 INIT_FUNC_WATCHDOG_RESET
307 312
308 NULL, /* Terminate this list */ 313 NULL, /* Terminate this list */
309 }; 314 };
310 315
311 /************************************************************************ 316 /************************************************************************
312 * 317 *
313 * This is the first part of the initialization sequence that is 318 * This is the first part of the initialization sequence that is
314 * implemented in C, but still running from ROM. 319 * implemented in C, but still running from ROM.
315 * 320 *
316 * The main purpose is to provide a (serial) console interface as 321 * The main purpose is to provide a (serial) console interface as
317 * soon as possible (so we can see any error messages), and to 322 * soon as possible (so we can see any error messages), and to
318 * initialize the RAM so that we can relocate the monitor code to 323 * initialize the RAM so that we can relocate the monitor code to
319 * RAM. 324 * RAM.
320 * 325 *
321 * Be aware of the restrictions: global data is read-only, BSS is not 326 * Be aware of the restrictions: global data is read-only, BSS is not
322 * initialized, and stack space is limited to a few kB. 327 * initialized, and stack space is limited to a few kB.
323 * 328 *
324 ************************************************************************ 329 ************************************************************************
325 */ 330 */
326 331
327 void board_init_f (ulong bootflag) 332 void board_init_f (ulong bootflag)
328 { 333 {
329 DECLARE_GLOBAL_DATA_PTR; 334 DECLARE_GLOBAL_DATA_PTR;
330 335
331 bd_t *bd; 336 bd_t *bd;
332 ulong len, addr, addr_sp; 337 ulong len, addr, addr_sp;
333 gd_t *id; 338 gd_t *id;
334 init_fnc_t **init_fnc_ptr; 339 init_fnc_t **init_fnc_ptr;
335 #ifdef CONFIG_PRAM 340 #ifdef CONFIG_PRAM
336 int i; 341 int i;
337 ulong reg; 342 ulong reg;
338 uchar tmp[64]; /* long enough for environment variables */ 343 uchar tmp[64]; /* long enough for environment variables */
339 #endif 344 #endif
340 345
341 /* Pointer is writable since we allocated a register for it */ 346 /* Pointer is writable since we allocated a register for it */
342 gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); 347 gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
343 348
344 #ifndef CONFIG_8260 349 #ifndef CONFIG_8260
345 /* Clear initial global data */ 350 /* Clear initial global data */
346 memset ((void *) gd, 0, sizeof (gd_t)); 351 memset ((void *) gd, 0, sizeof (gd_t));
347 #endif 352 #endif
348 353
349 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { 354 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
350 if ((*init_fnc_ptr) () != 0) { 355 if ((*init_fnc_ptr) () != 0) {
351 hang (); 356 hang ();
352 } 357 }
353 } 358 }
354 359
355 /* 360 /*
356 * Now that we have DRAM mapped and working, we can 361 * Now that we have DRAM mapped and working, we can
357 * relocate the code and continue running from DRAM. 362 * relocate the code and continue running from DRAM.
358 * 363 *
359 * Reserve memory at end of RAM for (top down in that order): 364 * Reserve memory at end of RAM for (top down in that order):
360 * - protected RAM 365 * - protected RAM
361 * - LCD framebuffer 366 * - LCD framebuffer
362 * - monitor code 367 * - monitor code
363 * - board info struct 368 * - board info struct
364 */ 369 */
365 len = get_endaddr () - CFG_MONITOR_BASE; 370 len = get_endaddr () - CFG_MONITOR_BASE;
366 371
367 if (len > CFG_MONITOR_LEN) { 372 if (len > CFG_MONITOR_LEN) {
368 printf ("*** U-Boot size %ld > reserved memory (%d)\n", 373 printf ("*** U-Boot size %ld > reserved memory (%d)\n",
369 len, CFG_MONITOR_LEN); 374 len, CFG_MONITOR_LEN);
370 hang (); 375 hang ();
371 } 376 }
372 377
373 if (CFG_MONITOR_LEN > len) 378 if (CFG_MONITOR_LEN > len)
374 len = CFG_MONITOR_LEN; 379 len = CFG_MONITOR_LEN;
375 380
376 #ifndef CONFIG_VERY_BIG_RAM 381 #ifndef CONFIG_VERY_BIG_RAM
377 addr = CFG_SDRAM_BASE + gd->ram_size; 382 addr = CFG_SDRAM_BASE + gd->ram_size;
378 #else 383 #else
379 /* only allow stack below 256M */ 384 /* only allow stack below 256M */
380 addr = CFG_SDRAM_BASE + 385 addr = CFG_SDRAM_BASE +
381 (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size; 386 (gd->ram_size > 256 << 20) ? 256 << 20 : gd->ram_size;
382 #endif 387 #endif
383 388
384 #ifdef CONFIG_PRAM 389 #ifdef CONFIG_PRAM
385 /* 390 /*
386 * reserve protected RAM 391 * reserve protected RAM
387 */ 392 */
388 i = getenv_r ("pram", tmp, sizeof (tmp)); 393 i = getenv_r ("pram", tmp, sizeof (tmp));
389 reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM; 394 reg = (i > 0) ? simple_strtoul (tmp, NULL, 10) : CONFIG_PRAM;
390 addr -= (reg << 10); /* size is in kB */ 395 addr -= (reg << 10); /* size is in kB */
391 # ifdef DEBUG 396 # ifdef DEBUG
392 printf ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); 397 printf ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
393 # endif 398 # endif
394 #endif /* CONFIG_PRAM */ 399 #endif /* CONFIG_PRAM */
395 400
396 /* round down to next 4 kB limit */ 401 /* round down to next 4 kB limit */
397 addr &= ~(4096 - 1); 402 addr &= ~(4096 - 1);
398 #ifdef DEBUG 403 #ifdef DEBUG
399 printf ("Top of RAM usable for U-Boot at: %08lx\n", addr); 404 printf ("Top of RAM usable for U-Boot at: %08lx\n", addr);
400 #endif 405 #endif
401 406
402 #ifdef CONFIG_LCD 407 #ifdef CONFIG_LCD
403 /* reserve memory for LCD display (always full pages) */ 408 /* reserve memory for LCD display (always full pages) */
404 addr = lcd_setmem (addr); 409 addr = lcd_setmem (addr);
405 gd->fb_base = addr; 410 gd->fb_base = addr;
406 #endif /* CONFIG_LCD */ 411 #endif /* CONFIG_LCD */
407 412
408 #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx) 413 #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx)
409 /* reserve memory for video display (always full pages) */ 414 /* reserve memory for video display (always full pages) */
410 addr = video_setmem (addr); 415 addr = video_setmem (addr);
411 gd->fb_base = addr; 416 gd->fb_base = addr;
412 #endif /* CONFIG_VIDEO */ 417 #endif /* CONFIG_VIDEO */
413 418
414 /* 419 /*
415 * reserve memory for U-Boot code, data & bss 420 * reserve memory for U-Boot code, data & bss
416 * round down to next 4 kB limit 421 * round down to next 4 kB limit
417 */ 422 */
418 addr -= len; 423 addr -= len;
419 addr &= ~(4096 - 1); 424 addr &= ~(4096 - 1);
420 425
421 #ifdef DEBUG 426 #ifdef DEBUG
422 printf ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); 427 printf ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
423 #endif 428 #endif
424 429
425 #ifdef CONFIG_AMIGAONEG3SE 430 #ifdef CONFIG_AMIGAONEG3SE
426 gd->relocaddr = addr; 431 gd->relocaddr = addr;
427 #endif 432 #endif
428 433
429 /* 434 /*
430 * reserve memory for malloc() arena 435 * reserve memory for malloc() arena
431 */ 436 */
432 addr_sp = addr - TOTAL_MALLOC_LEN; 437 addr_sp = addr - TOTAL_MALLOC_LEN;
433 #ifdef DEBUG 438 #ifdef DEBUG
434 printf ("Reserving %dk for malloc() at: %08lx\n", 439 printf ("Reserving %dk for malloc() at: %08lx\n",
435 TOTAL_MALLOC_LEN >> 10, addr_sp); 440 TOTAL_MALLOC_LEN >> 10, addr_sp);
436 #endif 441 #endif
437 442
438 /* 443 /*
439 * (permanently) allocate a Board Info struct 444 * (permanently) allocate a Board Info struct
440 * and a permanent copy of the "global" data 445 * and a permanent copy of the "global" data
441 */ 446 */
442 addr_sp -= sizeof (bd_t); 447 addr_sp -= sizeof (bd_t);
443 bd = (bd_t *) addr_sp; 448 bd = (bd_t *) addr_sp;
444 gd->bd = bd; 449 gd->bd = bd;
445 #ifdef DEBUG 450 #ifdef DEBUG
446 printf ("Reserving %d Bytes for Board Info at: %08lx\n", 451 printf ("Reserving %d Bytes for Board Info at: %08lx\n",
447 sizeof (bd_t), addr_sp); 452 sizeof (bd_t), addr_sp);
448 #endif 453 #endif
449 addr_sp -= sizeof (gd_t); 454 addr_sp -= sizeof (gd_t);
450 id = (gd_t *) addr_sp; 455 id = (gd_t *) addr_sp;
451 #ifdef DEBUG 456 #ifdef DEBUG
452 printf ("Reserving %d Bytes for Global Data at: %08lx\n", 457 printf ("Reserving %d Bytes for Global Data at: %08lx\n",
453 sizeof (gd_t), addr_sp); 458 sizeof (gd_t), addr_sp);
454 #endif 459 #endif
455 460
456 /* 461 /*
457 * Finally, we set up a new (bigger) stack. 462 * Finally, we set up a new (bigger) stack.
458 * 463 *
459 * Leave some safety gap for SP, force alignment on 16 byte boundary 464 * Leave some safety gap for SP, force alignment on 16 byte boundary
460 * Clear initial stack frame 465 * Clear initial stack frame
461 */ 466 */
462 addr_sp -= 16; 467 addr_sp -= 16;
463 addr_sp &= ~0xF; 468 addr_sp &= ~0xF;
464 *((ulong *) addr_sp)-- = 0; 469 *((ulong *) addr_sp)-- = 0;
465 *((ulong *) addr_sp)-- = 0; 470 *((ulong *) addr_sp)-- = 0;
466 #ifdef DEBUG 471 #ifdef DEBUG
467 printf ("Stack Pointer at: %08lx\n", addr_sp); 472 printf ("Stack Pointer at: %08lx\n", addr_sp);
468 #endif 473 #endif
469 474
470 /* 475 /*
471 * Save local variables to board info struct 476 * Save local variables to board info struct
472 */ 477 */
473 478
474 bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */ 479 bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */
475 bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ 480 bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
476 481
477 #ifdef CONFIG_IP860 482 #ifdef CONFIG_IP860
478 bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */ 483 bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */
479 bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */ 484 bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */
480 #else 485 #else
481 bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */ 486 bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */
482 bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */ 487 bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */
483 #endif 488 #endif
484 489
485 #if defined(CONFIG_8xx) || defined(CONFIG_8260) 490 #if defined(CONFIG_8xx) || defined(CONFIG_8260)
486 bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */ 491 bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */
487 #endif 492 #endif
488 493
489 bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ 494 bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
490 495
491 WATCHDOG_RESET (); 496 WATCHDOG_RESET ();
492 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ 497 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
493 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ 498 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
494 #if defined(CONFIG_8260) 499 #if defined(CONFIG_8260)
495 bd->bi_cpmfreq = gd->cpm_clk; 500 bd->bi_cpmfreq = gd->cpm_clk;
496 bd->bi_brgfreq = gd->brg_clk; 501 bd->bi_brgfreq = gd->brg_clk;
497 bd->bi_sccfreq = gd->scc_clk; 502 bd->bi_sccfreq = gd->scc_clk;
498 bd->bi_vco = gd->vco_out; 503 bd->bi_vco = gd->vco_out;
499 #endif /* CONFIG_8260 */ 504 #endif /* CONFIG_8260 */
500 505
501 bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ 506 bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
502 507
503 #ifdef CFG_EXTBDINFO 508 #ifdef CFG_EXTBDINFO
504 strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); 509 strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
505 strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); 510 strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
506 511
507 bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */ 512 bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */
508 bd->bi_plb_busfreq = gd->bus_clk; 513 bd->bi_plb_busfreq = gd->bus_clk;
509 #ifdef CONFIG_405GP 514 #ifdef CONFIG_405GP
510 bd->bi_pci_busfreq = get_PCI_freq (); 515 bd->bi_pci_busfreq = get_PCI_freq ();
511 #endif 516 #endif
512 #endif 517 #endif
513 518
514 #ifdef DEBUG 519 #ifdef DEBUG
515 printf ("New Stack Pointer is: %08lx\n", addr_sp); 520 printf ("New Stack Pointer is: %08lx\n", addr_sp);
516 #endif 521 #endif
517 522
518 WATCHDOG_RESET (); 523 WATCHDOG_RESET ();
519 524
520 #ifdef CONFIG_POST 525 #ifdef CONFIG_POST
521 post_bootmode_init(); 526 post_bootmode_init();
522 post_run (NULL, POST_ROM | post_bootmode_get(0)); 527 post_run (NULL, POST_ROM | post_bootmode_get(0));
523 #endif 528 #endif
524 529
525 WATCHDOG_RESET(); 530 WATCHDOG_RESET();
526 531
527 memcpy (id, gd, sizeof (gd_t)); 532 memcpy (id, gd, sizeof (gd_t));
528 533
529 relocate_code (addr_sp, id, addr); 534 relocate_code (addr_sp, id, addr);
530 535
531 /* NOTREACHED - relocate_code() does not return */ 536 /* NOTREACHED - relocate_code() does not return */
532 } 537 }
533 538
534 539
535 /************************************************************************ 540 /************************************************************************
536 * 541 *
537 * This is the next part if the initialization sequence: we are now 542 * This is the next part if the initialization sequence: we are now
538 * running from RAM and have a "normal" C environment, i. e. global 543 * running from RAM and have a "normal" C environment, i. e. global
539 * data can be written, BSS has been cleared, the stack size in not 544 * data can be written, BSS has been cleared, the stack size in not
540 * that critical any more, etc. 545 * that critical any more, etc.
541 * 546 *
542 ************************************************************************ 547 ************************************************************************
543 */ 548 */
544 549
545 void board_init_r (gd_t *id, ulong dest_addr) 550 void board_init_r (gd_t *id, ulong dest_addr)
546 { 551 {
547 DECLARE_GLOBAL_DATA_PTR; 552 DECLARE_GLOBAL_DATA_PTR;
548 553
549 cmd_tbl_t *cmdtp; 554 cmd_tbl_t *cmdtp;
550 char *s, *e; 555 char *s, *e;
551 bd_t *bd; 556 bd_t *bd;
552 int i; 557 int i;
553 extern void malloc_bin_reloc (void); 558 extern void malloc_bin_reloc (void);
554 #ifndef CFG_ENV_IS_NOWHERE 559 #ifndef CFG_ENV_IS_NOWHERE
555 extern char * env_name_spec; 560 extern char * env_name_spec;
556 #endif 561 #endif
557 562
558 #ifndef CFG_NO_FLASH 563 #ifndef CFG_NO_FLASH
559 ulong flash_size; 564 ulong flash_size;
560 #endif 565 #endif
561 566
562 gd = id; /* initialize RAM version of global data */ 567 gd = id; /* initialize RAM version of global data */
563 bd = gd->bd; 568 bd = gd->bd;
564 569
565 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ 570 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
566 571
567 #ifdef DEBUG 572 #ifdef DEBUG
568 printf ("Now running in RAM - U-Boot at: %08lx\n", dest_addr); 573 printf ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
569 #endif 574 #endif
570 575
571 WATCHDOG_RESET (); 576 WATCHDOG_RESET ();
572 577
573 gd->reloc_off = dest_addr - CFG_MONITOR_BASE; 578 gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
574 579
575 /* 580 /*
576 * We have to relocate the command table manually 581 * We have to relocate the command table manually
577 */ 582 */
578 for (cmdtp = &cmd_tbl[0]; cmdtp->name; cmdtp++) { 583 for (cmdtp = &cmd_tbl[0]; cmdtp->name; cmdtp++) {
579 ulong addr; 584 ulong addr;
580 585
581 addr = (ulong) (cmdtp->cmd) + gd->reloc_off; 586 addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
582 #if 0 587 #if 0
583 printf ("Command \"%s\": 0x%08lx => 0x%08lx\n", 588 printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
584 cmdtp->name, (ulong) (cmdtp->cmd), addr); 589 cmdtp->name, (ulong) (cmdtp->cmd), addr);
585 #endif 590 #endif
586 cmdtp->cmd = 591 cmdtp->cmd =
587 (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr; 592 (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
588 593
589 addr = (ulong)(cmdtp->name) + gd->reloc_off; 594 addr = (ulong)(cmdtp->name) + gd->reloc_off;
590 cmdtp->name = (char *)addr; 595 cmdtp->name = (char *)addr;
591 596
592 if (cmdtp->usage) { 597 if (cmdtp->usage) {
593 addr = (ulong)(cmdtp->usage) + gd->reloc_off; 598 addr = (ulong)(cmdtp->usage) + gd->reloc_off;
594 cmdtp->usage = (char *)addr; 599 cmdtp->usage = (char *)addr;
595 } 600 }
596 #ifdef CFG_LONGHELP 601 #ifdef CFG_LONGHELP
597 if (cmdtp->help) { 602 if (cmdtp->help) {
598 addr = (ulong)(cmdtp->help) + gd->reloc_off; 603 addr = (ulong)(cmdtp->help) + gd->reloc_off;
599 cmdtp->help = (char *)addr; 604 cmdtp->help = (char *)addr;
600 } 605 }
601 #endif 606 #endif
602 } 607 }
603 /* there are some other pointer constants we must deal with */ 608 /* there are some other pointer constants we must deal with */
604 #ifndef CFG_ENV_IS_NOWHERE 609 #ifndef CFG_ENV_IS_NOWHERE
605 env_name_spec += gd->reloc_off; 610 env_name_spec += gd->reloc_off;
606 #endif 611 #endif
607 612
608 WATCHDOG_RESET (); 613 WATCHDOG_RESET ();
609 614
610 #ifdef CONFIG_LOGBUFFER 615 #ifdef CONFIG_LOGBUFFER
611 logbuff_reset (); 616 logbuff_reset ();
612 #endif 617 #endif
613 #ifdef CONFIG_POST 618 #ifdef CONFIG_POST
614 post_reloc (); 619 post_reloc ();
615 #endif 620 #endif
616 621
617 WATCHDOG_RESET(); 622 WATCHDOG_RESET();
618 623
619 #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || defined (CONFIG_FLAGADM) 624 #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || defined (CONFIG_FLAGADM)
620 icache_enable (); /* it's time to enable the instruction cache */ 625 icache_enable (); /* it's time to enable the instruction cache */
621 #endif 626 #endif
622 627
623 #if defined(CONFIG_BAB7xx) 628 #if defined(CONFIG_BAB7xx)
624 /* 629 /*
625 * Do pci configuration on BAB 7xx _before_ the flash 630 * Do pci configuration on BAB 7xx _before_ the flash
626 * is initialised, because we need the ISA bridge there. 631 * is initialised, because we need the ISA bridge there.
627 */ 632 */
628 pci_init (); 633 pci_init ();
629 /* 634 /*
630 * Initialise the ISA bridge 635 * Initialise the ISA bridge
631 */ 636 */
632 initialise_w83c553f (); 637 initialise_w83c553f ();
633 #endif 638 #endif
634 639
635 asm ("sync ; isync"); 640 asm ("sync ; isync");
636 641
637 /* 642 /*
638 * Setup trap handlers 643 * Setup trap handlers
639 */ 644 */
640 trap_init (dest_addr); 645 trap_init (dest_addr);
641 646
642 #if !defined(CFG_NO_FLASH) 647 #if !defined(CFG_NO_FLASH)
643 puts ("FLASH: "); 648 puts ("FLASH: ");
644 649
645 if ((flash_size = flash_init ()) > 0) { 650 if ((flash_size = flash_init ()) > 0) {
646 #ifdef CFG_FLASH_CHECKSUM 651 #ifdef CFG_FLASH_CHECKSUM
647 print_size (flash_size, ""); 652 print_size (flash_size, "");
648 /* 653 /*
649 * Compute and print flash CRC if flashchecksum is set to 'y' 654 * Compute and print flash CRC if flashchecksum is set to 'y'
650 * 655 *
651 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX 656 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
652 */ 657 */
653 s = getenv ("flashchecksum"); 658 s = getenv ("flashchecksum");
654 if (s && (*s == 'y')) { 659 if (s && (*s == 'y')) {
655 printf (" CRC: %08lX", 660 printf (" CRC: %08lX",
656 crc32 (0, 661 crc32 (0,
657 (const unsigned char *) CFG_FLASH_BASE, 662 (const unsigned char *) CFG_FLASH_BASE,
658 flash_size) 663 flash_size)
659 ); 664 );
660 } 665 }
661 putc ('\n'); 666 putc ('\n');
662 #else 667 #else
663 print_size (flash_size, "\n"); 668 print_size (flash_size, "\n");
664 #endif /* CFG_FLASH_CHECKSUM */ 669 #endif /* CFG_FLASH_CHECKSUM */
665 } else { 670 } else {
666 puts (failed); 671 puts (failed);
667 hang (); 672 hang ();
668 } 673 }
669 674
670 bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */ 675 bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */
671 bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ 676 bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
672 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) 677 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
673 bd->bi_flashoffset = 0; 678 bd->bi_flashoffset = 0;
674 #elif CFG_MONITOR_BASE == CFG_FLASH_BASE 679 #elif CFG_MONITOR_BASE == CFG_FLASH_BASE
675 bd->bi_flashoffset = CFG_MONITOR_LEN; /* reserved area for startup monitor */ 680 bd->bi_flashoffset = CFG_MONITOR_LEN; /* reserved area for startup monitor */
676 #else 681 #else
677 bd->bi_flashoffset = 0; 682 bd->bi_flashoffset = 0;
678 #endif 683 #endif
679 #else 684 #else
680 685
681 bd->bi_flashsize = 0; 686 bd->bi_flashsize = 0;
682 bd->bi_flashstart = 0; 687 bd->bi_flashstart = 0;
683 bd->bi_flashoffset = 0; 688 bd->bi_flashoffset = 0;
684 #endif /* !CFG_NO_FLASH */ 689 #endif /* !CFG_NO_FLASH */
685 690
686 WATCHDOG_RESET (); 691 WATCHDOG_RESET ();
687 692
688 /* initialize higher level parts of CPU like time base and timers */ 693 /* initialize higher level parts of CPU like time base and timers */
689 cpu_init_r (); 694 cpu_init_r ();
690 695
691 WATCHDOG_RESET (); 696 WATCHDOG_RESET ();
692 697
693 /* initialize malloc() area */ 698 /* initialize malloc() area */
694 mem_malloc_init (); 699 mem_malloc_init ();
695 malloc_bin_reloc (); 700 malloc_bin_reloc ();
696 701
697 #ifdef CONFIG_SPI 702 #ifdef CONFIG_SPI
698 # if !defined(CFG_ENV_IS_IN_EEPROM) 703 # if !defined(CFG_ENV_IS_IN_EEPROM)
699 spi_init_f (); 704 spi_init_f ();
700 # endif 705 # endif
701 spi_init_r (); 706 spi_init_r ();
702 #endif 707 #endif
703 708
704 /* relocate environment function pointers etc. */ 709 /* relocate environment function pointers etc. */
705 env_relocate (); 710 env_relocate ();
706 711
707 /* 712 /*
708 * Fill in missing fields of bd_info. 713 * Fill in missing fields of bd_info.
709 * We do this here, where we have "normal" access to the 714 * We do this here, where we have "normal" access to the
710 * environment; we used to do this still running from ROM, 715 * environment; we used to do this still running from ROM,
711 * where had to use getenv_r(), which can be pretty slow when 716 * where had to use getenv_r(), which can be pretty slow when
712 * the environment is in EEPROM. 717 * the environment is in EEPROM.
713 */ 718 */
714 s = getenv ("ethaddr"); 719 s = getenv ("ethaddr");
715 #if defined (CONFIG_MBX) || defined (CONFIG_RPXCLASSIC) || defined(CONFIG_IAD210) 720 #if defined (CONFIG_MBX) || defined (CONFIG_RPXCLASSIC) || defined(CONFIG_IAD210)
716 if (s == NULL) 721 if (s == NULL)
717 board_get_enetaddr (bd->bi_enetaddr); 722 board_get_enetaddr (bd->bi_enetaddr);
718 else 723 else
719 #endif 724 #endif
720 for (i = 0; i < 6; ++i) { 725 for (i = 0; i < 6; ++i) {
721 bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0; 726 bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
722 if (s) 727 if (s)
723 s = (*e) ? e + 1 : e; 728 s = (*e) ? e + 1 : e;
724 } 729 }
725 #ifdef CONFIG_HERMES 730 #ifdef CONFIG_HERMES
726 if ((gd->board_type >> 16) == 2) 731 if ((gd->board_type >> 16) == 2)
727 bd->bi_ethspeed = gd->board_type & 0xFFFF; 732 bd->bi_ethspeed = gd->board_type & 0xFFFF;
728 else 733 else
729 bd->bi_ethspeed = 0xFFFF; 734 bd->bi_ethspeed = 0xFFFF;
730 #endif 735 #endif
731 736
732 #ifdef CONFIG_NX823 737 #ifdef CONFIG_NX823
733 load_sernum_ethaddr (); 738 load_sernum_ethaddr ();
734 #endif 739 #endif
735 740
736 #if defined(CFG_GT_6426x) || defined(CONFIG_PN62) 741 #if defined(CFG_GT_6426x) || defined(CONFIG_PN62)
737 /* handle the 2nd ethernet address */ 742 /* handle the 2nd ethernet address */
738 743
739 s = getenv ("eth1addr"); 744 s = getenv ("eth1addr");
740 745
741 for (i = 0; i < 6; ++i) { 746 for (i = 0; i < 6; ++i) {
742 bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0; 747 bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
743 if (s) 748 if (s)
744 s = (*e) ? e + 1 : e; 749 s = (*e) ? e + 1 : e;
745 } 750 }
746 #endif 751 #endif
747 #if defined(CFG_GT_6426x) 752 #if defined(CFG_GT_6426x)
748 /* handle the 3rd ethernet address */ 753 /* handle the 3rd ethernet address */
749 754
750 s = getenv ("eth2addr"); 755 s = getenv ("eth2addr");
751 756
752 for (i = 0; i < 6; ++i) { 757 for (i = 0; i < 6; ++i) {
753 bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0; 758 bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
754 if (s) 759 if (s)
755 s = (*e) ? e + 1 : e; 760 s = (*e) ? e + 1 : e;
756 } 761 }
757 #endif 762 #endif
758 763
759 764
760 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \ 765 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
761 defined(CONFIG_CCM) 766 defined(CONFIG_CCM)
762 load_sernum_ethaddr (); 767 load_sernum_ethaddr ();
763 #endif 768 #endif
764 /* IP Address */ 769 /* IP Address */
765 bd->bi_ip_addr = getenv_IPaddr ("ipaddr"); 770 bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
766 771
767 WATCHDOG_RESET (); 772 WATCHDOG_RESET ();
768 773
769 #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) 774 #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx)
770 /* 775 /*
771 * Do pci configuration 776 * Do pci configuration
772 */ 777 */
773 pci_init (); 778 pci_init ();
774 #endif 779 #endif
775 780
776 /** leave this here (after malloc(), environment and PCI are working) **/ 781 /** leave this here (after malloc(), environment and PCI are working) **/
777 /* Initialize devices */ 782 /* Initialize devices */
778 devices_init (); 783 devices_init ();
779 784
780 /* allocate syscalls table (console_init_r will fill it in */ 785 /* allocate syscalls table (console_init_r will fill it in */
781 syscall_tbl = (void **) malloc (NR_SYSCALLS * sizeof (void *)); 786 syscall_tbl = (void **) malloc (NR_SYSCALLS * sizeof (void *));
782 787
783 /* Initialize the console (after the relocation and devices init) */ 788 /* Initialize the console (after the relocation and devices init) */
784 console_init_r (); 789 console_init_r ();
785 /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ 790 /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/
786 syscalls_init (); 791 syscalls_init ();
787 792
788 #if defined(CONFIG_CCM) || \ 793 #if defined(CONFIG_CCM) || \
789 defined(CONFIG_COGENT) || \ 794 defined(CONFIG_COGENT) || \
790 defined(CONFIG_CPCI405) || \ 795 defined(CONFIG_CPCI405) || \
791 defined(CONFIG_EVB64260) || \ 796 defined(CONFIG_EVB64260) || \
792 defined(CONFIG_HYMOD) || \ 797 defined(CONFIG_HYMOD) || \
793 defined(CONFIG_KUP4K) || \ 798 defined(CONFIG_KUP4K) || \
794 defined(CONFIG_LWMON) || \ 799 defined(CONFIG_LWMON) || \
795 defined(CONFIG_PCU_E) || \ 800 defined(CONFIG_PCU_E) || \
796 defined(CONFIG_W7O) || \ 801 defined(CONFIG_W7O) || \
797 defined(CONFIG_MISC_INIT_R) 802 defined(CONFIG_MISC_INIT_R)
798 /* miscellaneous platform dependent initialisations */ 803 /* miscellaneous platform dependent initialisations */
799 misc_init_r (); 804 misc_init_r ();
800 #endif 805 #endif
801 806
802 #ifdef CONFIG_HERMES 807 #ifdef CONFIG_HERMES
803 if (bd->bi_ethspeed != 0xFFFF) 808 if (bd->bi_ethspeed != 0xFFFF)
804 hermes_start_lxt980 ((int) bd->bi_ethspeed); 809 hermes_start_lxt980 ((int) bd->bi_ethspeed);
805 #endif 810 #endif
806 811
807 #if (CONFIG_COMMANDS & CFG_CMD_NET) && ( \ 812 #if (CONFIG_COMMANDS & CFG_CMD_NET) && ( \
808 defined(CONFIG_CCM) || \ 813 defined(CONFIG_CCM) || \
809 defined(CONFIG_EP8260) || \ 814 defined(CONFIG_EP8260) || \
810 defined(CONFIG_IP860) || \ 815 defined(CONFIG_IP860) || \
811 defined(CONFIG_IVML24) || \ 816 defined(CONFIG_IVML24) || \
812 defined(CONFIG_IVMS8) || \ 817 defined(CONFIG_IVMS8) || \
813 defined(CONFIG_LWMON) || \ 818 defined(CONFIG_LWMON) || \
814 defined(CONFIG_MPC8260ADS) || \ 819 defined(CONFIG_MPC8260ADS) || \
815 defined(CONFIG_PCU_E) || \ 820 defined(CONFIG_PCU_E) || \
816 defined(CONFIG_RPXSUPER) || \ 821 defined(CONFIG_RPXSUPER) || \
817 defined(CONFIG_SPD823TS) ) 822 defined(CONFIG_SPD823TS) )
818 823
819 WATCHDOG_RESET (); 824 WATCHDOG_RESET ();
820 # ifdef DEBUG 825 # ifdef DEBUG
821 puts ("Reset Ethernet PHY\n"); 826 puts ("Reset Ethernet PHY\n");
822 # endif 827 # endif
823 reset_phy (); 828 reset_phy ();
824 #endif 829 #endif
825 830
826 #if (CONFIG_COMMANDS & CFG_CMD_KGDB) 831 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
827 WATCHDOG_RESET (); 832 WATCHDOG_RESET ();
828 puts ("KGDB: "); 833 puts ("KGDB: ");
829 kgdb_init (); 834 kgdb_init ();
830 #endif 835 #endif
831 836
832 #ifdef DEBUG 837 #ifdef DEBUG
833 printf ("U-Boot relocated to %08lx\n", dest_addr); 838 printf ("U-Boot relocated to %08lx\n", dest_addr);
834 #endif 839 #endif
835 840
836 /* 841 /*
837 * Enable Interrupts 842 * Enable Interrupts
838 */ 843 */
839 interrupt_init (); 844 interrupt_init ();
840 845
841 /* Must happen after interrupts are initialized since 846 /* Must happen after interrupts are initialized since
842 * an irq handler gets installed 847 * an irq handler gets installed
843 */ 848 */
844 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO 849 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
845 serial_buffered_init(); 850 serial_buffered_init();
846 #endif 851 #endif
847 852
848 #ifdef CONFIG_STATUS_LED 853 #ifdef CONFIG_STATUS_LED
849 status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); 854 status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
850 #endif 855 #endif
851 856
852 udelay (20); 857 udelay (20);
853 858
854 set_timer (0); 859 set_timer (0);
855 860
856 /* Insert function pointers now that we have relocated the code */ 861 /* Insert function pointers now that we have relocated the code */
857 862
858 /* Initialize from environment */ 863 /* Initialize from environment */
859 if ((s = getenv ("loadaddr")) != NULL) { 864 if ((s = getenv ("loadaddr")) != NULL) {
860 load_addr = simple_strtoul (s, NULL, 16); 865 load_addr = simple_strtoul (s, NULL, 16);
861 } 866 }
862 #if (CONFIG_COMMANDS & CFG_CMD_NET) 867 #if (CONFIG_COMMANDS & CFG_CMD_NET)
863 if ((s = getenv ("bootfile")) != NULL) { 868 if ((s = getenv ("bootfile")) != NULL) {
864 copy_filename (BootFile, s, sizeof (BootFile)); 869 copy_filename (BootFile, s, sizeof (BootFile));
865 } 870 }
866 #endif /* CFG_CMD_NET */ 871 #endif /* CFG_CMD_NET */
867 872
868 WATCHDOG_RESET (); 873 WATCHDOG_RESET ();
869 874
870 #if (CONFIG_COMMANDS & CFG_CMD_SCSI) 875 #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
871 WATCHDOG_RESET (); 876 WATCHDOG_RESET ();
872 puts ("SCSI: "); 877 puts ("SCSI: ");
873 scsi_init (); 878 scsi_init ();
874 #endif 879 #endif
875 880
876 #if (CONFIG_COMMANDS & CFG_CMD_DOC) 881 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
877 WATCHDOG_RESET (); 882 WATCHDOG_RESET ();
878 puts ("DOC: "); 883 puts ("DOC: ");
879 doc_init (); 884 doc_init ();
880 #endif 885 #endif
881 886
882 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI) 887 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
883 WATCHDOG_RESET (); 888 WATCHDOG_RESET ();
884 puts ("Net: "); 889 puts ("Net: ");
885 eth_initialize (bd); 890 eth_initialize (bd);
886 #endif 891 #endif
887 892
888 #ifdef CONFIG_POST 893 #ifdef CONFIG_POST
889 post_run (NULL, POST_RAM | post_bootmode_get(0)); 894 post_run (NULL, POST_RAM | post_bootmode_get(0));
890 if (post_bootmode_get(0) & POST_POWERFAIL) { 895 if (post_bootmode_get(0) & POST_POWERFAIL) {
891 post_bootmode_clear(); 896 post_bootmode_clear();
892 board_poweroff(); 897 board_poweroff();
893 } 898 }
894 #endif 899 #endif
895 900
896 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE) 901 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE)
897 WATCHDOG_RESET (); 902 WATCHDOG_RESET ();
898 puts ("PCMCIA:"); 903 puts ("PCMCIA:");
899 pcmcia_init (); 904 pcmcia_init ();
900 #endif 905 #endif
901 906
902 #if (CONFIG_COMMANDS & CFG_CMD_IDE) 907 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
903 WATCHDOG_RESET (); 908 WATCHDOG_RESET ();
904 # ifdef CONFIG_IDE_8xx_PCCARD 909 # ifdef CONFIG_IDE_8xx_PCCARD
905 puts ("PCMCIA:"); 910 puts ("PCMCIA:");
906 # else 911 # else
907 puts ("IDE: "); 912 puts ("IDE: ");
908 #endif 913 #endif
909 ide_init (); 914 ide_init ();
910 #endif /* CFG_CMD_IDE */ 915 #endif /* CFG_CMD_IDE */
911 916
912 #ifdef CONFIG_LAST_STAGE_INIT 917 #ifdef CONFIG_LAST_STAGE_INIT
913 WATCHDOG_RESET (); 918 WATCHDOG_RESET ();
914 /* 919 /*
915 * Some parts can be only initialized if all others (like 920 * Some parts can be only initialized if all others (like
916 * Interrupts) are up and running (i.e. the PC-style ISA 921 * Interrupts) are up and running (i.e. the PC-style ISA
917 * keyboard). 922 * keyboard).
918 */ 923 */
919 last_stage_init (); 924 last_stage_init ();
920 #endif 925 #endif
921 926
922 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG) 927 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
923 WATCHDOG_RESET (); 928 WATCHDOG_RESET ();
924 bedbug_init (); 929 bedbug_init ();
925 #endif 930 #endif
926 931
927 #ifdef CONFIG_PRAM 932 #ifdef CONFIG_PRAM
928 /* 933 /*
929 * Export available size of memory for Linux, 934 * Export available size of memory for Linux,
930 * taking into account the protected RAM at top of memory 935 * taking into account the protected RAM at top of memory
931 */ 936 */
932 { 937 {
933 ulong pram; 938 ulong pram;
934 char *s; 939 char *s;
935 uchar memsz[32]; 940 uchar memsz[32];
936 941
937 if ((s = getenv ("pram")) != NULL) { 942 if ((s = getenv ("pram")) != NULL) {
938 pram = simple_strtoul (s, NULL, 10); 943 pram = simple_strtoul (s, NULL, 10);
939 } else { 944 } else {
940 pram = CONFIG_PRAM; 945 pram = CONFIG_PRAM;
941 } 946 }
942 sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram); 947 sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
943 setenv ("mem", memsz); 948 setenv ("mem", memsz);
944 } 949 }
945 #endif 950 #endif
946 951
947 /* Initialization complete - start the monitor */ 952 /* Initialization complete - start the monitor */
948 953
949 /* main_loop() can return to retry autoboot, if so just run it again. */ 954 /* main_loop() can return to retry autoboot, if so just run it again. */
950 for (;;) { 955 for (;;) {
951 WATCHDOG_RESET (); 956 WATCHDOG_RESET ();
952 main_loop (); 957 main_loop ();
953 } 958 }
954 959
955 /* NOTREACHED - no way out of command loop except booting */ 960 /* NOTREACHED - no way out of command loop except booting */
956 } 961 }
957 962
958 void hang (void) 963 void hang (void)
959 { 964 {
960 puts ("### ERROR ### Please RESET the board ###\n"); 965 puts ("### ERROR ### Please RESET the board ###\n");
961 for (;;); 966 for (;;);
962 } 967 }
963 968
964 #if 0 /* We could use plain global data, but the resulting code is bigger */ 969 #if 0 /* We could use plain global data, but the resulting code is bigger */
965 /* 970 /*
966 * Pointer to initial global data area 971 * Pointer to initial global data area
967 * 972 *
968 * Here we initialize it. 973 * Here we initialize it.
969 */ 974 */
970 #undef XTRN_DECLARE_GLOBAL_DATA_PTR 975 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
971 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */ 976 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
972 DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); 977 DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
973 #endif /* 0 */ 978 #endif /* 0 */
974 979
975 /************************************************************************/ 980 /************************************************************************/
976 981