source: rtems/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c @ e2d79559

4.104.114.84.95
Last change on this file since e2d79559 was e2d79559, checked in by Joel Sherrill <joel.sherrill@…>, on 04/09/97 at 14:05:50

Added ka9q tcpip stack and network driver for the gen68360. This effort
was done based on the 3.6.0 release and had to be autoconf'ed locally.
It is turned on is the bsp enables it and it is not explicitly disabled
via the configure option --disable-tcpip. As many warnings as possible
were removed locally after the code was merged. Only the gen68360
and mvme136 bsps were compiled this way.

The ka9q port and network driver were submitted by Eric Norum
(eric@…).

The network demo programs are not included in the tree at this point.

  • Property mode set to 100644
File size: 7.0 KB
Line 
1/*
2 * MC68360 support routines
3 *
4 * W. Eric Norum
5 * Saskatchewan Accelerator Laboratory
6 * University of Saskatchewan
7 * Saskatoon, Saskatchewan, CANADA
8 * eric@skatter.usask.ca
9 *
10 *  $Id$
11 */
12
13#include <rtems.h>
14#include <bsp.h>
15#include <m68360.h>
16
17/*
18 * Send a command to the CPM RISC processer
19 */
20
21void M360ExecuteRISC(rtems_unsigned16 command)
22{
23        rtems_unsigned16 sr;
24
25        m68k_disable_interrupts (sr);
26        while (m360.cr & M360_CR_FLG)
27                continue;
28        m360.cr = command | M360_CR_FLG;
29        m68k_enable_interrupts (sr);
30}
31
32/*
33 * Initialize MC68360
34 */
35
36void _Init68360 (void)
37{
38        int i;
39        unsigned long l;
40        m68k_isr_entry *vbr;
41        extern void _CopyDataClearBSSAndStart (void);
42
43        /*
44         * Step 6: Is this a power-up reset?
45         * For now we just ignore this and do *all* the steps
46         * Someday we might want to:
47         *      if (Hard, Loss of Clock, Power-up)
48         *              Do all steps
49         *      else if (Double bus fault, watchdog or soft reset)
50         *              Skip to step 12
51         *      else (must be a CPU32+ reset command)
52         *              Skip to step 14
53         */
54
55        /*
56         * Step 7: Deal with clock synthesizer
57         * HARDWARE:
58         *      Change if you're not using an external 25 MHz oscillator.
59         */
60        m360.clkocr = 0x8F;     /* No more writes, no clock outputs */
61        m360.pllcr = 0xD000;    /* PLL, no writes, no prescale,
62                                   no LPSTOP slowdown, PLL X1 */
63        m360.cdvcr = 0x8000;    /* No more writes, no clock division */
64
65        /*
66         * Step 8: Initialize system protection
67         *      Disable watchdog FIXME: Should use watchdog!!!!
68         *      Watchdog causes system reset
69         *      Slowest watchdog timeout
70         *      Enable double bus fault monitor
71         *      Enable bus monitor external
72         *      128 clocks for external timeout
73         */
74        m360.sypcr = 0x7F;
75
76        /*
77         * Step 9: Clear parameter RAM and reset communication processor module
78         */
79        for (i = 0 ; i < 192  ; i += sizeof (long)) {
80                *((long *)((char *)&m360 + 0xC00 + i)) = 0;
81                *((long *)((char *)&m360 + 0xD00 + i)) = 0;
82                *((long *)((char *)&m360 + 0xE00 + i)) = 0;
83                *((long *)((char *)&m360 + 0xF00 + i)) = 0;
84        }
85        M360ExecuteRISC (M360_CR_RST);
86
87        /*
88         * Step 10: Write PEPAR
89         *      SINTOUT not used (CPU32+ mode)
90         *      CF1MODE=00 (CONFIG1 input)
91         *      RAS1* double drive
92         *      WE0* - WE3*
93         *      OE* output
94         *      CAS2* - CAS3*
95         *      CAS0* - CAS1*
96         *      CS7*
97         *      AVEC*
98         * HARDWARE:
99         *      Change if you are using a different memory configuration
100         *      (static RAM, external address multiplexing, etc).
101         */
102        m360.pepar = 0x0180;
103
104        /*
105         * Step 11: Remap Chip Select 0 (CS0*), set up GMR
106         */
107        if (&_MC68360HardwareType == &_MC68360HardwareTypeAtlasHSB) {
108                m360.gmr = M360_GMR_RCNT(12) | M360_GMR_RFEN |
109                                M360_GMR_RCYC(0) | M360_GMR_PGS(1) |
110                                M360_GMR_DPS_32BIT | M360_GMR_DWQ |
111                                M360_GMR_GAMX;
112                m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
113                                                                M360_MEMC_BR_V;
114                m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB |
115                                                        M360_MEMC_OR_8BIT;
116        }
117        else {
118                /*
119                 * 1024/2048/4096 addresses per DRAM page (1M/4M/16M DRAM chips)
120                 * 60 nsec DRAM
121                 * 180 nsec ROM (3 wait states)
122                 */
123                switch ((unsigned long)&_RamSize) {
124                default:
125                case 4*1024*1024:
126                        m360.gmr = M360_GMR_RCNT(24) | M360_GMR_RFEN |
127                                        M360_GMR_RCYC(0) | M360_GMR_PGS(3) |
128                                        M360_GMR_DPS_32BIT | M360_GMR_NCS |
129                                        M360_GMR_GAMX;
130                        break;
131
132                case 16*1024*1024:
133                        m360.gmr = M360_GMR_RCNT(24) | M360_GMR_RFEN |
134                                        M360_GMR_RCYC(0) | M360_GMR_PGS(5) |
135                                        M360_GMR_DPS_32BIT | M360_GMR_NCS |
136                                        M360_GMR_GAMX;
137                        break;
138
139                case 64*1024*1024:
140                        m360.gmr = M360_GMR_RCNT(24) | M360_GMR_RFEN |
141                                        M360_GMR_RCYC(0) | M360_GMR_PGS(7) |
142                                        M360_GMR_DPS_32BIT | M360_GMR_NCS |
143                                        M360_GMR_GAMX;
144                        break;
145                }
146                m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
147                                                                M360_MEMC_BR_V;
148                m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB |
149                                                        M360_MEMC_OR_8BIT;
150        }
151
152        /*
153         * Step 12: Initialize the system RAM
154         */
155        if (&_MC68360HardwareType == &_MC68360HardwareTypeAtlasHSB) {
156                /* first bank 1MByte DRAM */
157                m360.memc[1].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB |
158                                        M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM;
159                m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V;
160
161                /* second bank 1MByte DRAM */
162                m360.memc[2].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB |
163                                        M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM;
164                m360.memc[2].br = ((unsigned long)&_RamBase + 0x100000) |
165                                        M360_MEMC_BR_V;
166
167                /* flash rom socket U6 on CS5 */
168                m360.memc[5].br = (unsigned long)ATLASHSB_ROM_U6 | M360_MEMC_BR_WP |
169                                                                M360_MEMC_BR_V;
170                m360.memc[5].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB |
171                                                                M360_MEMC_OR_8BIT;
172
173                /* CSRs on CS7 */
174                m360.memc[7].or = M360_MEMC_OR_TCYC(4) | M360_MEMC_OR_64KB |
175                                        M360_MEMC_OR_8BIT;
176                m360.memc[7].br = ATLASHSB_ESR | 0x01;
177                for (i = 0; i < 50000; i++)
178                        continue;
179                for (i = 0; i < 8; ++i)
180                        *((volatile unsigned long *)(unsigned long)&_RamBase);
181        }
182        else {
183                /*
184                 *      Set up option/base registers
185                 *              4M/16M/64M DRAM
186                 *              60 nsec DRAM
187                 *      Wait for chips to power up
188                 *      Perform 8 read cycles
189                 *      Set all parity bits to correct state
190                 *      Enable parity checking
191                 */
192                switch ((unsigned long)&_RamSize) {
193                default:
194                case 4*1024*1024:
195                        m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
196                                                M360_MEMC_OR_4MB |
197                                                M360_MEMC_OR_DRAM;
198                        break;
199
200                case 16*1024*1024:
201                        m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
202                                                M360_MEMC_OR_16MB |
203                                                M360_MEMC_OR_DRAM;
204                        break;
205
206                case 64*1024*1024:
207                        m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
208                                                M360_MEMC_OR_64MB |
209                                                M360_MEMC_OR_DRAM;
210                        break;
211                }
212                m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V;
213                for (i = 0; i < 50000; i++)
214                        continue;
215                for (i = 0; i < 8; ++i)
216                        *((volatile unsigned long *)(unsigned long)&_RamBase);
217                for (l = 0 ; l < (unsigned long)&_RamSize ; l += sizeof (unsigned long)) {
218                        volatile unsigned long *lp;
219                        lp = (unsigned long *)((unsigned char *)&_RamBase + i);
220                        *lp = *lp;
221                }
222                m360.memc[1].br = (unsigned long)&_RamBase |
223                                        M360_MEMC_BR_PAREN | M360_MEMC_BR_V;
224        }
225
226        /*
227         * Step 13: Copy  the exception vector table to system RAM
228         */
229        m68k_get_vbr (vbr);
230        for (i = 0; i < 256; ++i)
231                M68Kvec[i] = vbr[i];
232        m68k_set_vbr (M68Kvec);
233       
234        /*
235         * Step 14: More system initialization
236         * SDCR (Serial DMA configuration register)
237         *      Disable SDMA during FREEZE
238         *      Give SDMA priority over all interrupt handlers
239         *      Set DMA arbiration level to 4
240         * CICR (CPM interrupt configuration register):
241         *      SCC1 requests at SCCa position
242         *      SCC2 requests at SCCb position
243         *      SCC3 requests at SCCc position
244         *      SCC4 requests at SCCd position
245         *      Interrupt request level 4
246         *      Maintain original priority order
247         *      Vector base 128
248         *      SCCs priority grouped at top of table
249         */
250        m360.sdcr = M360_SDMA_FREEZE | M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
251        m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) |
252                                                (4 << 13) | (0x1F << 8) | (128);
253
254        /*
255         * Step 15: Set module configuration register
256         *      Disable timers during FREEZE
257         *      Enable bus monitor during FREEZE
258         *      BCLRO* arbitration level 3
259         *      No show cycles
260         *      User/supervisor access
261         *      Bus clear interrupt service level 7
262         *      SIM60 interrupt sources higher priority than CPM
263         */
264        m360.mcr = 0x4C7F;
265
266        /*
267         * Copy data, clear BSS, switch stacks and call main()
268         */
269        _CopyDataClearBSSAndStart ();
270}
Note: See TracBrowser for help on using the repository browser.