source: rtems/bsps/m68k/gen68360/start/init68360.c @ 753873e5

Last change on this file since 753873e5 was 753873e5, checked in by Joel Sherrill <joel@…>, on 03/22/22 at 20:03:30

Update Eric Norum contact info and start to normalize file headers

  • Property mode set to 100644
File size: 24.6 KB
Line 
1/*
2 * MC68360 support routines
3 */
4
5/*
6 * Copyright (c) 1996 Eric Norum <eric@norum.ca>
7 */
8
9#include <bsp.h>
10#include <rtems/m68k/m68360.h>
11
12extern void _CopyDataClearBSSAndStart (unsigned long ramSize);
13extern void *RamBase;
14extern void *_RomBase;  /* From linkcmds */
15
16/*
17 * Declare the m360 structure here for the benefit of the debugger
18 */
19
20volatile m360_t m360;
21
22/*
23 * Send a command to the CPM RISC processer
24 */
25
26void M360ExecuteRISC(uint16_t         command)
27{
28  uint16_t         sr;
29
30  m68k_disable_interrupts (sr);
31  while (m360.cr & M360_CR_FLG)
32    continue;
33  m360.cr = command | M360_CR_FLG;
34  m68k_enable_interrupts (sr);
35}
36
37/*
38 * Initialize MC68360
39 */
40void _Init68360 (void)
41{
42  int i;
43  rtems_isr_entry *vbr;
44  unsigned long ramSize;
45
46#if (defined (__mc68040__))
47  volatile unsigned long *RamBase_p;
48
49  RamBase_p = (volatile unsigned long *)&RamBase;
50
51  /*
52   *******************************************
53   * Motorola 68040 and companion-mode 68360 *
54   *******************************************
55   */
56
57  /*
58   * Step 6: Is this a power-up reset?
59   * For now we just ignore this and do *all* the steps
60   * Someday we might want to:
61   *  if (Hard, Loss of Clock, Power-up)
62   *    Do all steps
63   *  else if (Double bus fault, watchdog or soft reset)
64   *    Skip to step 12
65   *  else (must be a reset command)
66   *    Skip to step 14
67   */
68
69  /*
70   * Step 7: Deal with clock synthesizer
71   * HARDWARE:
72   *  Change if you're not using an external 25 MHz oscillator.
73   */
74  m360.clkocr = 0x83;  /* No more writes, full-power CLKO2 */
75  m360.pllcr = 0xD000;  /* PLL, no writes, no prescale,
76           no LPSTOP slowdown, PLL X1 */
77  m360.cdvcr = 0x8000;  /* No more writes, no clock division */
78
79  /*
80   * Step 8: Initialize system protection
81   *  Enable watchdog
82   *  Watchdog causes system reset
83   *  Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator)
84   *  Enable double bus fault monitor
85   *  Enable bus monitor for external cycles
86   *  1024 clocks for external timeout
87   */
88  m360.sypcr = 0xEC;
89
90  /*
91   * Step 9: Clear parameter RAM and reset communication processor module
92   */
93  for (i = 0 ; i < 192  ; i += sizeof (long)) {
94    *((long *)((char *)&m360 + 0xC00 + i)) = 0;
95    *((long *)((char *)&m360 + 0xD00 + i)) = 0;
96    *((long *)((char *)&m360 + 0xE00 + i)) = 0;
97    *((long *)((char *)&m360 + 0xF00 + i)) = 0;
98  }
99  M360ExecuteRISC (M360_CR_RST);
100
101  /*
102   * Step 10: Write PEPAR
103   *  SINTOUT standard M68000 family interrupt level encoding
104   *  CF1MODE=10 (BCLRO* output)
105   *  No RAS1* double drive
106   *  A31 - A28
107   *  AMUX output
108   *  CAS2* - CAS3*
109   *  CAS0* - CAS1*
110   *  CS7*
111   *  AVEC*
112   */
113  m360.pepar = 0x3440;
114
115  /*
116   * Step 11: Remap Chip Select 0 (CS0*), set up GMR
117   */
118  /*
119   * 512 addresses per DRAM page (256K DRAM chips)
120   * 70 nsec DRAM
121   * 180 nsec ROM (3 wait states)
122   */
123  m360.gmr = M360_GMR_RCNT(23) | M360_GMR_RFEN |
124        M360_GMR_RCYC(0) | M360_GMR_PGS(1) |
125        M360_GMR_DPS_32BIT | M360_GMR_NCS |
126        M360_GMR_TSS40;
127  m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
128              M360_MEMC_BR_V;
129  m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB |
130            M360_MEMC_OR_32BIT;
131
132  /*
133   * Step 12: Initialize the system RAM
134   */
135  /*
136   *  Set up option/base registers
137   *    1M DRAM
138   *    70 nsec DRAM
139   *  Enable burst mode
140   *  No parity checking
141   *  Wait for chips to power up
142   *  Perform 8 read cycles
143   */
144  ramSize = 1 * 1024 * 1024;
145  m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
146          M360_MEMC_OR_1MB |
147          M360_MEMC_OR_DRAM;
148  m360.memc[1].br = (unsigned long)&RamBase |
149          M360_MEMC_BR_BACK40 |
150          M360_MEMC_BR_V;
151  for (i = 0; i < 50000; i++)
152    continue;
153  for (i = 0; i < 8; ++i) {
154    unsigned long rambase_value;
155    rambase_value = *RamBase_p;
156    (void) rambase_value; /* avoid set but not used warning */
157  }
158
159  /*
160   * Step 13: Copy  the exception vector table to system RAM
161   */
162  m68k_get_vbr (vbr);
163  for (i = 0; i < 256; ++i)
164    M68Kvec[i] = vbr[i];
165  m68k_set_vbr (M68Kvec);
166
167  /*
168   * Step 14: More system initialization
169   * SDCR (Serial DMA configuration register)
170   *  Enable SDMA during FREEZE
171   *  Give SDMA priority over all interrupt handlers
172   *  Set DMA arbiration level to 4
173   * CICR (CPM interrupt configuration register):
174   *  SCC1 requests at SCCa position
175   *  SCC2 requests at SCCb position
176   *  SCC3 requests at SCCc position
177   *  SCC4 requests at SCCd position
178   *  Interrupt request level 4
179   *  Maintain original priority order
180   *  Vector base 128
181   *  SCCs priority grouped at top of table
182   */
183  m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
184  m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) |
185            (4 << 13) | (0x1F << 8) | (128);
186
187  /*
188   * Step 15: Set module configuration register
189   *  Bus request MC68040 Arbitration ID 3
190   *  Bus asynchronous timing mode (work around bug in Rev. B)
191   *  Arbitration asynchronous timing mode
192   *  Disable timers during FREEZE
193   *  Disable bus monitor during FREEZE
194   *  BCLRO* arbitration level 3
195   *  No show cycles
196   *  User/supervisor access
197   *  Bus clear in arbitration ID level  3
198   *  SIM60 interrupt sources higher priority than CPM
199   */
200  m360.mcr = 0x6000EC3F;
201
202#elif (defined (M68360_ATLAS_HSB))
203  /*
204   ******************************************
205   * Standalone Motorola 68360 -- ATLAS HSB *
206   ******************************************
207   */
208
209  /*
210   * Step 6: Is this a power-up reset?
211   * For now we just ignore this and do *all* the steps
212   * Someday we might want to:
213   *  if (Hard, Loss of Clock, Power-up)
214   *    Do all steps
215   *  else if (Double bus fault, watchdog or soft reset)
216   *    Skip to step 12
217   *  else (must be a CPU32+ reset command)
218   *    Skip to step 14
219   */
220
221  /*
222   * Step 7: Deal with clock synthesizer
223   * HARDWARE:
224   *  Change if you're not using an external 25 MHz oscillator.
225   */
226  m360.clkocr = 0x8F;  /* No more writes, no clock outputs */
227  m360.pllcr = 0xD000;  /* PLL, no writes, no prescale,
228           no LPSTOP slowdown, PLL X1 */
229  m360.cdvcr = 0x8000;  /* No more writes, no clock division */
230
231  /*
232   * Step 8: Initialize system protection
233   *  Enable watchdog
234   *  Watchdog causes system reset
235   *  Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator)
236   *  Enable double bus fault monitor
237   *  Enable bus monitor for external cycles
238   *  1024 clocks for external timeout
239   */
240  m360.sypcr = 0xEC;
241
242  /*
243   * Step 9: Clear parameter RAM and reset communication processor module
244   */
245  for (i = 0 ; i < 192  ; i += sizeof (long)) {
246    *((long *)((char *)&m360 + 0xC00 + i)) = 0;
247    *((long *)((char *)&m360 + 0xD00 + i)) = 0;
248    *((long *)((char *)&m360 + 0xE00 + i)) = 0;
249    *((long *)((char *)&m360 + 0xF00 + i)) = 0;
250  }
251  M360ExecuteRISC (M360_CR_RST);
252
253  /*
254   * Step 10: Write PEPAR
255   *  SINTOUT not used (CPU32+ mode)
256   *  CF1MODE=00 (CONFIG1 input)
257   *  RAS1* double drive
258   *  WE0* - WE3*
259   *  OE* output
260   *  CAS2* - CAS3*
261   *  CAS0* - CAS1*
262   *  CS7*
263   *  AVEC*
264   * HARDWARE:
265   *  Change if you are using a different memory configuration
266   *  (static RAM, external address multiplexing, etc).
267   */
268  m360.pepar = 0x0180;
269
270  /*
271   * Step 11: Remap Chip Select 0 (CS0*), set up GMR
272   */
273  m360.gmr = M360_GMR_RCNT(12) | M360_GMR_RFEN |
274        M360_GMR_RCYC(0) | M360_GMR_PGS(1) |
275        M360_GMR_DPS_32BIT | M360_GMR_DWQ |
276        M360_GMR_GAMX;
277  m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
278                M360_MEMC_BR_V;
279  m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB |
280              M360_MEMC_OR_8BIT;
281
282  /*
283   * Step 12: Initialize the system RAM
284   */
285  ramSize = 2 * 1024 * 1024;
286  /* first bank 1MByte DRAM */
287  m360.memc[1].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB |
288          M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM;
289  m360.memc[1].br = (unsigned long)&RamBase | M360_MEMC_BR_V;
290
291  /* second bank 1MByte DRAM */
292  m360.memc[2].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB |
293          M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM;
294  m360.memc[2].br = ((unsigned long)&RamBase + 0x100000) |
295          M360_MEMC_BR_V;
296
297  /* flash rom socket U6 on CS5 */
298  m360.memc[5].br = (unsigned long)ATLASHSB_ROM_U6 | M360_MEMC_BR_WP |
299                M360_MEMC_BR_V;
300  m360.memc[5].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB |
301                M360_MEMC_OR_8BIT;
302
303  /* CSRs on CS7 */
304  m360.memc[7].or = M360_MEMC_OR_TCYC(4) | M360_MEMC_OR_64KB |
305          M360_MEMC_OR_8BIT;
306  m360.memc[7].br = ATLASHSB_ESR | 0x01;
307  for (i = 0; i < 50000; i++)
308    continue;
309  for (i = 0; i < 8; ++i)
310    *((volatile unsigned long *)(unsigned long)&RamBase);
311
312  /*
313   * Step 13: Copy  the exception vector table to system RAM
314   */
315  m68k_get_vbr (vbr);
316  for (i = 0; i < 256; ++i)
317    M68Kvec[i] = vbr[i];
318  m68k_set_vbr (M68Kvec);
319
320  /*
321   * Step 14: More system initialization
322   * SDCR (Serial DMA configuration register)
323   *  Enable SDMA during FREEZE
324   *  Give SDMA priority over all interrupt handlers
325   *  Set DMA arbiration level to 4
326   * CICR (CPM interrupt configuration register):
327   *  SCC1 requests at SCCa position
328   *  SCC2 requests at SCCb position
329   *  SCC3 requests at SCCc position
330   *  SCC4 requests at SCCd position
331   *  Interrupt request level 4
332   *  Maintain original priority order
333   *  Vector base 128
334   *  SCCs priority grouped at top of table
335   */
336  m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
337  m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) |
338            (4 << 13) | (0x1F << 8) | (128);
339
340  /*
341   * Step 15: Set module configuration register
342   *  Disable timers during FREEZE
343   *  Enable bus monitor during FREEZE
344   *  BCLRO* arbitration level 3
345   */
346
347#elif defined(PGH360)
348  /*
349   * Step 6: Is this a power-up reset?
350   * For now we just ignore this and do *all* the steps
351   * Someday we might want to:
352   *  if (Hard, Loss of Clock, Power-up)
353   *    Do all steps
354   *  else if (Double bus fault, watchdog or soft reset)
355   *    Skip to step 12
356   *  else (must be a CPU32+ reset command)
357   *    Skip to step 14
358   */
359
360  /*
361   * Step 7: Deal with clock synthesizer
362   * HARDWARE:
363   *  Change if you're not using an external 25 MHz oscillator.
364   */
365  m360.clkocr = 0x8e;  /* No more writes, CLKO1=1/3, CLKO2=off */
366  /*
367   * adjust crystal to average between 4.19 MHz and 4.00 MHz
368   * reprogram pll
369   */
370  m360.pllcr = 0xA000+(24576000/((4000000+4194304)/2/128))-1;
371          /* LPSTOP slowdown, PLL /128*??? */
372  m360.cdvcr = 0x8000;  /* No more writes, no clock division */
373
374  /*
375   * Step 8: Initialize system protection
376   *  Enable watchdog
377   *  Watchdog causes system reset
378   *  128 sec. watchdog timeout
379   *  Enable double bus fault monitor
380   *  Enable bus monitor external
381   *  128 clocks for external timeout
382   */
383  m360.sypcr = 0xEF;
384  /*
385   * also initialize the SWP bit in PITR to 1
386   */
387  m360.pitr |= 0x0200;
388  /*
389   * and trigger SWSR twice to ensure, that interval starts right now
390   */
391  m360.swsr = 0x55;
392  m360.swsr = 0xAA;
393  m360.swsr = 0x55;
394  m360.swsr = 0xAA;
395  /*
396   * Step 9: Clear parameter RAM and reset communication processor module
397   */
398  for (i = 0 ; i < 192  ; i += sizeof (long)) {
399    *((long *)((char *)&m360 + 0xC00 + i)) = 0;
400    *((long *)((char *)&m360 + 0xD00 + i)) = 0;
401    *((long *)((char *)&m360 + 0xE00 + i)) = 0;
402    *((long *)((char *)&m360 + 0xF00 + i)) = 0;
403  }
404  M360ExecuteRISC (M360_CR_RST);
405
406  /*
407   * Step 10: Write PEPAR
408   *  SINTOUT not used (CPU32+ mode)
409   *  CF1MODE=00 (CONFIG1 input)
410   *  IPIPE1
411   *  WE0-3
412   *  OE* output
413   *  CAS2* / CAS3*
414   *  CAS0* / CAS1*
415   *  CS7*
416   *  AVEC*
417   * HARDWARE:
418   *  Change if you are using a different memory configuration
419   *  (static RAM, external address multiplexing, etc).
420   */
421  m360.pepar = 0x0080;
422  /*
423   * Step 11: Remap Chip Select 0 (CS0*), set up GMR
424   *  no DRAM support
425   * HARDWARE:
426   *  Change if you are using a different memory configuration
427   */
428  m360.gmr = M360_GMR_RCNT(23) | M360_GMR_RFEN      | M360_GMR_RCYC(0) |
429       M360_GMR_PGS(6)   | M360_GMR_DPS_32BIT | M360_GMR_DWQ     |
430             M360_GMR_GAMX;
431
432  m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
433              M360_MEMC_BR_V;
434  m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_512KB |
435              M360_MEMC_OR_8BIT;
436
437  /*
438   * Step 12: Initialize the system RAM
439   *  Set up option/base registers
440   *    16 MB DRAM
441   *    1 wait state
442   * HARDWARE:
443   *  Change if you are using a different memory configuration
444   *      NOTE: no Page mode possible for EDO RAMs (?)
445   */
446  ramSize = 16 * 1024 * 1024;
447  m360.memc[7].or = M360_MEMC_OR_TCYC(1)  | M360_MEMC_OR_16MB |
448        M360_MEMC_OR_FCMC(0)  | /* M360_MEMC_OR_PGME | */
449                          M360_MEMC_OR_32BIT    | M360_MEMC_OR_DRAM;
450  m360.memc[7].br = (unsigned long)&RamBase | M360_MEMC_BR_V;
451
452  /*
453   * FIXME: here we should wait for 8 refresh cycles...
454   */
455  /*
456   * Step 12a: test the ram, if wanted
457   * FIXME: when do we call this?
458   * -> only during firmware execution
459   * -> perform intesive test only on request
460   * -> ensure, that results are stored properly
461   */
462#if 0 /* FIXME: activate RAM tests again */
463  {
464    void *ram_base, *ram_end, *code_loc;
465    extern char ramtest_start,ramtest_end;
466    ram_base = &ramtest_start;
467    ram_end  = &ramtest_end;
468    code_loc = (void *)ramtest_exec;
469    if ((ram_base < ram_end) &&
470      !((ram_base <= code_loc) && (code_loc < ram_end))) {
471      ramtest_exec(ram_base,ram_end);
472    }
473  }
474#endif
475  /*
476   * Step 13: Copy  the exception vector table to system RAM
477   */
478  m68k_get_vbr (vbr);
479  for (i = 0; i < 256; ++i)
480    M68Kvec[i] = vbr[i];
481  m68k_set_vbr (M68Kvec);
482
483  /*
484   * Step 14: More system initialization
485   * SDCR (Serial DMA configuration register)
486   *  Disable SDMA during FREEZE
487   *  Give SDMA priority over all interrupt handlers
488   *  Set DMA arbiration level to 4
489   * CICR (CPM interrupt configuration register):
490   *  SCC1 requests at SCCa position
491   *  SCC2 requests at SCCb position
492   *  SCC3 requests at SCCc position
493   *  SCC4 requests at SCCd position
494   *  Interrupt request level 4
495   *  Maintain original priority order
496   *  Vector base 128
497   *  SCCs priority grouped at top of table
498   */
499  m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
500  m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) |
501            (4 << 13) | (0x1F << 8) | (128);
502
503  /*
504   * Step 15: Set module configuration register
505   *  Disable timers during FREEZE
506   *  Enable bus monitor during FREEZE
507   *  BCLRO* arbitration level 3
508   *  No show cycles
509   *  User/supervisor access
510   *  Bus clear interupt service level 7
511   *  SIM60 interrupt sources higher priority than CPM
512   */
513  m360.mcr = 0x4C7F;
514
515#elif (defined (GEN68360_WITH_SRAM))
516   /*
517    ***************************************************
518    * Generic Standalone Motorola 68360               *
519    *           As described in MC68360 User's Manual *
520    * But uses SRAM instead of DRAM                   *
521    *  CS0* - 512kx8 flash memory                     *
522    *  CS1* - 512kx32 static RAM                      *
523    *  CS2* - 512kx32 static RAM                      *
524    ***************************************************
525    */
526
527   /*
528    * Step 7: Deal with clock synthesizer
529    * HARDWARE:
530    * Change if you're not using an external oscillator which
531    * oscillates at the system clock rate.
532    */
533   m360.clkocr = 0x8F;     /* No more writes, no clock outputs */
534   m360.pllcr = 0xD000;    /* PLL, no writes, no prescale,
535                              no LPSTOP slowdown, PLL X1 */
536   m360.cdvcr = 0x8000;    /* No more writes, no clock division */
537
538   /*
539    * Step 8: Initialize system protection
540    * Enable watchdog
541    * Watchdog causes system reset
542    * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator)
543    * Enable double bus fault monitor
544    * Enable bus monitor for external cycles
545    * 1024 clocks for external timeout
546    */
547    m360.sypcr = 0xEC;
548
549   /*
550    * Step 9: Clear parameter RAM and reset communication processor module
551    */
552   for (i = 0 ; i < 192  ; i += sizeof (long)) {
553      *((long *)((char *)&m360 + 0xC00 + i)) = 0;
554      *((long *)((char *)&m360 + 0xD00 + i)) = 0;
555      *((long *)((char *)&m360 + 0xE00 + i)) = 0;
556      *((long *)((char *)&m360 + 0xF00 + i)) = 0;
557   }
558   M360ExecuteRISC (M360_CR_RST);
559
560   /*
561    * Step 10: Write PEPAR
562    * SINTOUT not used (CPU32+ mode)
563    * CF1MODE=00 (CONFIG1 input)
564    * IPIPE1*
565    * WE0* - WE3*
566    * OE* output
567    * CAS2* - CAS3*
568    * CAS0* - CAS1*
569    * CS7*
570    * AVEC*
571    * HARDWARE:
572    * Change if you are using a different memory configuration
573    * (static RAM, external address multiplexing, etc).
574    */
575   m360.pepar = 0x0080;
576
577   /*
578    * Step 11: Set up GMR
579    *
580    */
581   m360.gmr = 0x0;
582
583   /*
584    * Step 11a: Remap 512Kx8 flash memory on CS0*
585    * 2 wait states
586    * Make it read-only for now
587    */
588   m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
589                                                   M360_MEMC_BR_V;
590   m360.memc[0].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB |
591                                                   M360_MEMC_OR_8BIT;
592   /*
593    * Step 12: Set up main memory
594    * 512Kx32 SRAM on CS1*
595    * 512Kx32 SRAM on CS2*
596    * 0 wait states
597    */
598   ramSize = 4 * 1024 * 1024;
599   m360.memc[1].br = (unsigned long)&RamBase | M360_MEMC_BR_V;
600   m360.memc[1].or = M360_MEMC_OR_WAITS(0) | M360_MEMC_OR_2MB |
601                                                   M360_MEMC_OR_32BIT;
602   m360.memc[2].br = ((unsigned long)&RamBase + 0x200000) | M360_MEMC_BR_V;
603   m360.memc[2].or = M360_MEMC_OR_WAITS(0) | M360_MEMC_OR_2MB |
604                                                   M360_MEMC_OR_32BIT;
605   /*
606    * Step 13: Copy  the exception vector table to system RAM
607    */
608   m68k_get_vbr (vbr);
609   for (i = 0; i < 256; ++i)
610           M68Kvec[i] = vbr[i];
611   m68k_set_vbr (M68Kvec);
612
613   /*
614    * Step 14: More system initialization
615    * SDCR (Serial DMA configuration register)
616    * Enable SDMA during FREEZE
617    * Give SDMA priority over all interrupt handlers
618    * Set DMA arbiration level to 4
619    * CICR (CPM interrupt configuration register):
620    * SCC1 requests at SCCa position
621    * SCC2 requests at SCCb position
622    * SCC3 requests at SCCc position
623    * SCC4 requests at SCCd position
624    * Interrupt request level 4
625    * Maintain original priority order
626    * Vector base 128
627    * SCCs priority grouped at top of table
628    */
629   m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
630   m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) |
631                  (4 << 13) | (0x1F << 8) | (128);
632
633   /*
634    * Step 15: Set module configuration register
635    * Disable timers during FREEZE
636    * Enable bus monitor during FREEZE
637    * BCLRO* arbitration level 3
638    * No show cycles
639    * User/supervisor access
640    * Bus clear interrupt service level 7
641    * SIM60 interrupt sources higher priority than CPM
642    */
643   m360.mcr = 0x4C7F;
644
645#else
646  volatile unsigned long *RamBase_p;
647
648  RamBase_p = (volatile unsigned long *)&RamBase;
649  /*
650   ***************************************************
651   * Generic Standalone Motorola 68360               *
652   *           As described in MC68360 User's Manual *
653   *           Atlas ACE360                          *
654   ***************************************************
655   */
656
657  /*
658   * Step 6: Is this a power-up reset?
659   * For now we just ignore this and do *all* the steps
660   * Someday we might want to:
661   *  if (Hard, Loss of Clock, Power-up)
662   *    Do all steps
663   *  else if (Double bus fault, watchdog or soft reset)
664   *    Skip to step 12
665   *  else (must be a CPU32+ reset command)
666   *    Skip to step 14
667   */
668
669  /*
670   * Step 7: Deal with clock synthesizer
671   * HARDWARE:
672   *  Change if you're not using an external 25 MHz oscillator.
673   */
674  m360.clkocr = 0x8F;  /* No more writes, no clock outputs */
675  m360.pllcr = 0xD000;  /* PLL, no writes, no prescale,
676           no LPSTOP slowdown, PLL X1 */
677  m360.cdvcr = 0x8000;  /* No more writes, no clock division */
678
679  /*
680   * Step 8: Initialize system protection
681   *  Enable watchdog
682   *  Watchdog causes system reset
683   *  Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator)
684   *  Enable double bus fault monitor
685   *  Enable bus monitor for external cycles
686   *  1024 clocks for external timeout
687   */
688  m360.sypcr = 0xEC;
689
690  /*
691   * Step 9: Clear parameter RAM and reset communication processor module
692   */
693  for (i = 0 ; i < 192  ; i += sizeof (long)) {
694    *((long *)((char *)&m360 + 0xC00 + i)) = 0;
695    *((long *)((char *)&m360 + 0xD00 + i)) = 0;
696    *((long *)((char *)&m360 + 0xE00 + i)) = 0;
697    *((long *)((char *)&m360 + 0xF00 + i)) = 0;
698  }
699  M360ExecuteRISC (M360_CR_RST);
700
701  /*
702   * Step 10: Write PEPAR
703   *  SINTOUT not used (CPU32+ mode)
704   *  CF1MODE=00 (CONFIG1 input)
705   *  RAS1* double drive
706   *  WE0* - WE3*
707   *  OE* output
708   *  CAS2* - CAS3*
709   *  CAS0* - CAS1*
710   *  CS7*
711   *  AVEC*
712   * HARDWARE:
713   *  Change if you are using a different memory configuration
714   *  (static RAM, external address multiplexing, etc).
715   */
716  m360.pepar = 0x0180;
717
718  /*
719   * Step 11: Remap Chip Select 0 (CS0*), set up GMR
720   *  32-bit DRAM
721   *  Internal DRAM address multiplexing
722   *  60 nsec DRAM
723   *  180 nsec ROM (3 wait states)
724   *  15.36 usec DRAM refresh interval
725   *  The DRAM page size selection is not modified since this
726   *  startup code may be running in a bootstrap PROM or in
727   *  a program downloaded by the bootstrap PROM.
728   */
729  m360.gmr = (m360.gmr & 0x001C0000) | M360_GMR_RCNT(23) |
730          M360_GMR_RFEN | M360_GMR_RCYC(0) |
731          M360_GMR_DPS_32BIT | M360_GMR_NCS |
732          M360_GMR_GAMX;
733  m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP |
734                M360_MEMC_BR_V;
735  m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB |
736              M360_MEMC_OR_8BIT;
737
738  /*
739   * Step 12: Initialize the system RAM
740   * Do this only if the DRAM has not already been set up
741   */
742  if ((m360.memc[1].br & M360_MEMC_BR_V) == 0) {
743    /*
744     * Set up GMR DRAM page size, option and  base registers
745     *  Assume 16Mbytes of DRAM
746     *  60 nsec DRAM
747     */
748    m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(5);
749    m360.memc[1].or = M360_MEMC_OR_TCYC(0) |
750            M360_MEMC_OR_16MB |
751            M360_MEMC_OR_DRAM;
752    m360.memc[1].br = (unsigned long)&RamBase | M360_MEMC_BR_V;
753
754    /*
755     * Wait for chips to power up
756     *  Perform 8 read cycles
757     */
758    for (i = 0; i < 50000; i++)
759      continue;
760    for (i = 0; i < 8; ++i)
761      *RamBase_p;
762
763    /*
764     * Determine memory size (1, 4, or 16 Mbytes)
765     * Set GMR DRAM page size appropriately.
766     * The OR is left at 16 Mbytes.  The bootstrap PROM places its
767     * .data and .bss segments at the top of the 16 Mbyte space.
768     * A 1 Mbyte or 4 Mbyte DRAM will show up several times in
769     * the memory map, but will work with the same bootstrap PROM.
770     */
771    *(volatile char *)&RamBase = 0;
772    *((volatile char *)&RamBase+0x00C01800) = 1;
773    if (*(volatile char *)&RamBase) {
774      m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(1);
775    }
776    else {
777      *((volatile char *)&RamBase+0x00801000) = 1;
778      if (*(volatile char *)&RamBase) {
779        m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(3);
780      }
781    }
782
783    /*
784     * Enable parity checking
785     */
786    m360.memc[1].br |= M360_MEMC_BR_PAREN;
787  }
788  switch (m360.gmr & 0x001C0000) {
789  default:    ramSize =  4 * 1024 * 1024;  break;
790  case M360_GMR_PGS(1):  ramSize =  1 * 1024 * 1024;  break;
791  case M360_GMR_PGS(3):  ramSize =  4 * 1024 * 1024;  break;
792  case M360_GMR_PGS(5):  ramSize = 16 * 1024 * 1024;  break;
793  }
794
795  /*
796   * Step 13: Copy  the exception vector table to system RAM
797   */
798  m68k_get_vbr (vbr);
799  for (i = 0; i < 256; ++i)
800    M68Kvec[i] = vbr[i];
801  m68k_set_vbr (M68Kvec);
802
803  /*
804   * Step 14: More system initialization
805   * SDCR (Serial DMA configuration register)
806   *  Enable SDMA during FREEZE
807   *  Give SDMA priority over all interrupt handlers
808   *  Set DMA arbiration level to 4
809   * CICR (CPM interrupt configuration register):
810   *  SCC1 requests at SCCa position
811   *  SCC2 requests at SCCb position
812   *  SCC3 requests at SCCc position
813   *  SCC4 requests at SCCd position
814   *  Interrupt request level 4
815   *  Maintain original priority order
816   *  Vector base 128
817   *  SCCs priority grouped at top of table
818   */
819  m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4;
820  m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) |
821            (4 << 13) | (0x1F << 8) | (128);
822
823  /*
824   * Step 15: Set module configuration register
825   *  Disable timers during FREEZE
826   *  Enable bus monitor during FREEZE
827   *  BCLRO* arbitration level 3
828   *  No show cycles
829   *  User/supervisor access
830   *  Bus clear interrupt service level 7
831   *  SIM60 interrupt sources higher priority than CPM
832   */
833  m360.mcr = 0x4C7F;
834#endif
835
836  /*
837   * Copy data, clear BSS, switch stacks and call main()
838   * Must pass ramSize as argument since the data/bss segment
839   * may be overwritten.
840   */
841  _CopyDataClearBSSAndStart (ramSize);
842}
Note: See TracBrowser for help on using the repository browser.