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

4.115
Last change on this file since c186f2ed was c186f2ed, checked in by Joel Sherrill <joel.sherrill@…>, on 10/15/14 at 22:17:08

m68k/mvme162: Fix warnings

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