![]() |
|
|||
File indexing completed on 2025-05-11 08:23:45
0001 /* 0002 * MC68360 support routines 0003 */ 0004 0005 /* 0006 * Copyright (c) 1996 Eric Norum <eric@norum.ca> 0007 */ 0008 0009 #include <bsp.h> 0010 #include <rtems/m68k/m68360.h> 0011 0012 extern void _CopyDataClearBSSAndStart (unsigned long ramSize); 0013 extern void *RamBase; 0014 extern void *_RomBase; /* From linkcmds */ 0015 0016 /* 0017 * Declare the m360 structure here for the benefit of the debugger 0018 */ 0019 0020 volatile m360_t m360; 0021 0022 /* 0023 * Send a command to the CPM RISC processer 0024 */ 0025 0026 void M360ExecuteRISC(uint16_t command) 0027 { 0028 uint16_t sr; 0029 0030 m68k_disable_interrupts (sr); 0031 while (m360.cr & M360_CR_FLG) 0032 continue; 0033 m360.cr = command | M360_CR_FLG; 0034 m68k_enable_interrupts (sr); 0035 } 0036 0037 /* 0038 * Initialize MC68360 0039 */ 0040 void _Init68360 (void) 0041 { 0042 int i; 0043 rtems_isr_entry *vbr; 0044 unsigned long ramSize; 0045 0046 #if (defined (__mc68040__)) 0047 volatile unsigned long *RamBase_p; 0048 0049 RamBase_p = (volatile unsigned long *)&RamBase; 0050 0051 /* 0052 ******************************************* 0053 * Motorola 68040 and companion-mode 68360 * 0054 ******************************************* 0055 */ 0056 0057 /* 0058 * Step 6: Is this a power-up reset? 0059 * For now we just ignore this and do *all* the steps 0060 * Someday we might want to: 0061 * if (Hard, Loss of Clock, Power-up) 0062 * Do all steps 0063 * else if (Double bus fault, watchdog or soft reset) 0064 * Skip to step 12 0065 * else (must be a reset command) 0066 * Skip to step 14 0067 */ 0068 0069 /* 0070 * Step 7: Deal with clock synthesizer 0071 * HARDWARE: 0072 * Change if you're not using an external 25 MHz oscillator. 0073 */ 0074 m360.clkocr = 0x83; /* No more writes, full-power CLKO2 */ 0075 m360.pllcr = 0xD000; /* PLL, no writes, no prescale, 0076 no LPSTOP slowdown, PLL X1 */ 0077 m360.cdvcr = 0x8000; /* No more writes, no clock division */ 0078 0079 /* 0080 * Step 8: Initialize system protection 0081 * Enable watchdog 0082 * Watchdog causes system reset 0083 * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) 0084 * Enable double bus fault monitor 0085 * Enable bus monitor for external cycles 0086 * 1024 clocks for external timeout 0087 */ 0088 m360.sypcr = 0xEC; 0089 0090 /* 0091 * Step 9: Clear parameter RAM and reset communication processor module 0092 */ 0093 for (i = 0 ; i < 192 ; i += sizeof (long)) { 0094 *((long *)((char *)&m360 + 0xC00 + i)) = 0; 0095 *((long *)((char *)&m360 + 0xD00 + i)) = 0; 0096 *((long *)((char *)&m360 + 0xE00 + i)) = 0; 0097 *((long *)((char *)&m360 + 0xF00 + i)) = 0; 0098 } 0099 M360ExecuteRISC (M360_CR_RST); 0100 0101 /* 0102 * Step 10: Write PEPAR 0103 * SINTOUT standard M68000 family interrupt level encoding 0104 * CF1MODE=10 (BCLRO* output) 0105 * No RAS1* double drive 0106 * A31 - A28 0107 * AMUX output 0108 * CAS2* - CAS3* 0109 * CAS0* - CAS1* 0110 * CS7* 0111 * AVEC* 0112 */ 0113 m360.pepar = 0x3440; 0114 0115 /* 0116 * Step 11: Remap Chip Select 0 (CS0*), set up GMR 0117 */ 0118 /* 0119 * 512 addresses per DRAM page (256K DRAM chips) 0120 * 70 nsec DRAM 0121 * 180 nsec ROM (3 wait states) 0122 */ 0123 m360.gmr = M360_GMR_RCNT(23) | M360_GMR_RFEN | 0124 M360_GMR_RCYC(0) | M360_GMR_PGS(1) | 0125 M360_GMR_DPS_32BIT | M360_GMR_NCS | 0126 M360_GMR_TSS40; 0127 m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | 0128 M360_MEMC_BR_V; 0129 m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB | 0130 M360_MEMC_OR_32BIT; 0131 0132 /* 0133 * Step 12: Initialize the system RAM 0134 */ 0135 /* 0136 * Set up option/base registers 0137 * 1M DRAM 0138 * 70 nsec DRAM 0139 * Enable burst mode 0140 * No parity checking 0141 * Wait for chips to power up 0142 * Perform 8 read cycles 0143 */ 0144 ramSize = 1 * 1024 * 1024; 0145 m360.memc[1].or = M360_MEMC_OR_TCYC(0) | 0146 M360_MEMC_OR_1MB | 0147 M360_MEMC_OR_DRAM; 0148 m360.memc[1].br = (unsigned long)&RamBase | 0149 M360_MEMC_BR_BACK40 | 0150 M360_MEMC_BR_V; 0151 for (i = 0; i < 50000; i++) 0152 continue; 0153 for (i = 0; i < 8; ++i) { 0154 unsigned long rambase_value; 0155 rambase_value = *RamBase_p; 0156 (void) rambase_value; /* avoid set but not used warning */ 0157 } 0158 0159 /* 0160 * Step 13: Copy the exception vector table to system RAM 0161 */ 0162 m68k_get_vbr (vbr); 0163 for (i = 0; i < 256; ++i) 0164 M68Kvec[i] = vbr[i]; 0165 m68k_set_vbr (M68Kvec); 0166 0167 /* 0168 * Step 14: More system initialization 0169 * SDCR (Serial DMA configuration register) 0170 * Enable SDMA during FREEZE 0171 * Give SDMA priority over all interrupt handlers 0172 * Set DMA arbiration level to 4 0173 * CICR (CPM interrupt configuration register): 0174 * SCC1 requests at SCCa position 0175 * SCC2 requests at SCCb position 0176 * SCC3 requests at SCCc position 0177 * SCC4 requests at SCCd position 0178 * Interrupt request level 4 0179 * Maintain original priority order 0180 * Vector base 128 0181 * SCCs priority grouped at top of table 0182 */ 0183 m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; 0184 m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | 0185 (4 << 13) | (0x1F << 8) | (128); 0186 0187 /* 0188 * Step 15: Set module configuration register 0189 * Bus request MC68040 Arbitration ID 3 0190 * Bus asynchronous timing mode (work around bug in Rev. B) 0191 * Arbitration asynchronous timing mode 0192 * Disable timers during FREEZE 0193 * Disable bus monitor during FREEZE 0194 * BCLRO* arbitration level 3 0195 * No show cycles 0196 * User/supervisor access 0197 * Bus clear in arbitration ID level 3 0198 * SIM60 interrupt sources higher priority than CPM 0199 */ 0200 m360.mcr = 0x6000EC3F; 0201 0202 #elif (defined (M68360_ATLAS_HSB)) 0203 /* 0204 ****************************************** 0205 * Standalone Motorola 68360 -- ATLAS HSB * 0206 ****************************************** 0207 */ 0208 0209 /* 0210 * Step 6: Is this a power-up reset? 0211 * For now we just ignore this and do *all* the steps 0212 * Someday we might want to: 0213 * if (Hard, Loss of Clock, Power-up) 0214 * Do all steps 0215 * else if (Double bus fault, watchdog or soft reset) 0216 * Skip to step 12 0217 * else (must be a CPU32+ reset command) 0218 * Skip to step 14 0219 */ 0220 0221 /* 0222 * Step 7: Deal with clock synthesizer 0223 * HARDWARE: 0224 * Change if you're not using an external 25 MHz oscillator. 0225 */ 0226 m360.clkocr = 0x8F; /* No more writes, no clock outputs */ 0227 m360.pllcr = 0xD000; /* PLL, no writes, no prescale, 0228 no LPSTOP slowdown, PLL X1 */ 0229 m360.cdvcr = 0x8000; /* No more writes, no clock division */ 0230 0231 /* 0232 * Step 8: Initialize system protection 0233 * Enable watchdog 0234 * Watchdog causes system reset 0235 * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) 0236 * Enable double bus fault monitor 0237 * Enable bus monitor for external cycles 0238 * 1024 clocks for external timeout 0239 */ 0240 m360.sypcr = 0xEC; 0241 0242 /* 0243 * Step 9: Clear parameter RAM and reset communication processor module 0244 */ 0245 for (i = 0 ; i < 192 ; i += sizeof (long)) { 0246 *((long *)((char *)&m360 + 0xC00 + i)) = 0; 0247 *((long *)((char *)&m360 + 0xD00 + i)) = 0; 0248 *((long *)((char *)&m360 + 0xE00 + i)) = 0; 0249 *((long *)((char *)&m360 + 0xF00 + i)) = 0; 0250 } 0251 M360ExecuteRISC (M360_CR_RST); 0252 0253 /* 0254 * Step 10: Write PEPAR 0255 * SINTOUT not used (CPU32+ mode) 0256 * CF1MODE=00 (CONFIG1 input) 0257 * RAS1* double drive 0258 * WE0* - WE3* 0259 * OE* output 0260 * CAS2* - CAS3* 0261 * CAS0* - CAS1* 0262 * CS7* 0263 * AVEC* 0264 * HARDWARE: 0265 * Change if you are using a different memory configuration 0266 * (static RAM, external address multiplexing, etc). 0267 */ 0268 m360.pepar = 0x0180; 0269 0270 /* 0271 * Step 11: Remap Chip Select 0 (CS0*), set up GMR 0272 */ 0273 m360.gmr = M360_GMR_RCNT(12) | M360_GMR_RFEN | 0274 M360_GMR_RCYC(0) | M360_GMR_PGS(1) | 0275 M360_GMR_DPS_32BIT | M360_GMR_DWQ | 0276 M360_GMR_GAMX; 0277 m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | 0278 M360_MEMC_BR_V; 0279 m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB | 0280 M360_MEMC_OR_8BIT; 0281 0282 /* 0283 * Step 12: Initialize the system RAM 0284 */ 0285 ramSize = 2 * 1024 * 1024; 0286 /* first bank 1MByte DRAM */ 0287 m360.memc[1].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB | 0288 M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM; 0289 m360.memc[1].br = (unsigned long)&RamBase | M360_MEMC_BR_V; 0290 0291 /* second bank 1MByte DRAM */ 0292 m360.memc[2].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB | 0293 M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM; 0294 m360.memc[2].br = ((unsigned long)&RamBase + 0x100000) | 0295 M360_MEMC_BR_V; 0296 0297 /* flash rom socket U6 on CS5 */ 0298 m360.memc[5].br = (unsigned long)ATLASHSB_ROM_U6 | M360_MEMC_BR_WP | 0299 M360_MEMC_BR_V; 0300 m360.memc[5].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB | 0301 M360_MEMC_OR_8BIT; 0302 0303 /* CSRs on CS7 */ 0304 m360.memc[7].or = M360_MEMC_OR_TCYC(4) | M360_MEMC_OR_64KB | 0305 M360_MEMC_OR_8BIT; 0306 m360.memc[7].br = ATLASHSB_ESR | 0x01; 0307 for (i = 0; i < 50000; i++) 0308 continue; 0309 for (i = 0; i < 8; ++i) 0310 *((volatile unsigned long *)(unsigned long)&RamBase); 0311 0312 /* 0313 * Step 13: Copy the exception vector table to system RAM 0314 */ 0315 m68k_get_vbr (vbr); 0316 for (i = 0; i < 256; ++i) 0317 M68Kvec[i] = vbr[i]; 0318 m68k_set_vbr (M68Kvec); 0319 0320 /* 0321 * Step 14: More system initialization 0322 * SDCR (Serial DMA configuration register) 0323 * Enable SDMA during FREEZE 0324 * Give SDMA priority over all interrupt handlers 0325 * Set DMA arbiration level to 4 0326 * CICR (CPM interrupt configuration register): 0327 * SCC1 requests at SCCa position 0328 * SCC2 requests at SCCb position 0329 * SCC3 requests at SCCc position 0330 * SCC4 requests at SCCd position 0331 * Interrupt request level 4 0332 * Maintain original priority order 0333 * Vector base 128 0334 * SCCs priority grouped at top of table 0335 */ 0336 m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; 0337 m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | 0338 (4 << 13) | (0x1F << 8) | (128); 0339 0340 /* 0341 * Step 15: Set module configuration register 0342 * Disable timers during FREEZE 0343 * Enable bus monitor during FREEZE 0344 * BCLRO* arbitration level 3 0345 */ 0346 0347 #elif defined(PGH360) 0348 /* 0349 * Step 6: Is this a power-up reset? 0350 * For now we just ignore this and do *all* the steps 0351 * Someday we might want to: 0352 * if (Hard, Loss of Clock, Power-up) 0353 * Do all steps 0354 * else if (Double bus fault, watchdog or soft reset) 0355 * Skip to step 12 0356 * else (must be a CPU32+ reset command) 0357 * Skip to step 14 0358 */ 0359 0360 /* 0361 * Step 7: Deal with clock synthesizer 0362 * HARDWARE: 0363 * Change if you're not using an external 25 MHz oscillator. 0364 */ 0365 m360.clkocr = 0x8e; /* No more writes, CLKO1=1/3, CLKO2=off */ 0366 /* 0367 * adjust crystal to average between 4.19 MHz and 4.00 MHz 0368 * reprogram pll 0369 */ 0370 m360.pllcr = 0xA000+(24576000/((4000000+4194304)/2/128))-1; 0371 /* LPSTOP slowdown, PLL /128*??? */ 0372 m360.cdvcr = 0x8000; /* No more writes, no clock division */ 0373 0374 /* 0375 * Step 8: Initialize system protection 0376 * Enable watchdog 0377 * Watchdog causes system reset 0378 * 128 sec. watchdog timeout 0379 * Enable double bus fault monitor 0380 * Enable bus monitor external 0381 * 128 clocks for external timeout 0382 */ 0383 m360.sypcr = 0xEF; 0384 /* 0385 * also initialize the SWP bit in PITR to 1 0386 */ 0387 m360.pitr |= 0x0200; 0388 /* 0389 * and trigger SWSR twice to ensure, that interval starts right now 0390 */ 0391 m360.swsr = 0x55; 0392 m360.swsr = 0xAA; 0393 m360.swsr = 0x55; 0394 m360.swsr = 0xAA; 0395 /* 0396 * Step 9: Clear parameter RAM and reset communication processor module 0397 */ 0398 for (i = 0 ; i < 192 ; i += sizeof (long)) { 0399 *((long *)((char *)&m360 + 0xC00 + i)) = 0; 0400 *((long *)((char *)&m360 + 0xD00 + i)) = 0; 0401 *((long *)((char *)&m360 + 0xE00 + i)) = 0; 0402 *((long *)((char *)&m360 + 0xF00 + i)) = 0; 0403 } 0404 M360ExecuteRISC (M360_CR_RST); 0405 0406 /* 0407 * Step 10: Write PEPAR 0408 * SINTOUT not used (CPU32+ mode) 0409 * CF1MODE=00 (CONFIG1 input) 0410 * IPIPE1 0411 * WE0-3 0412 * OE* output 0413 * CAS2* / CAS3* 0414 * CAS0* / CAS1* 0415 * CS7* 0416 * AVEC* 0417 * HARDWARE: 0418 * Change if you are using a different memory configuration 0419 * (static RAM, external address multiplexing, etc). 0420 */ 0421 m360.pepar = 0x0080; 0422 /* 0423 * Step 11: Remap Chip Select 0 (CS0*), set up GMR 0424 * no DRAM support 0425 * HARDWARE: 0426 * Change if you are using a different memory configuration 0427 */ 0428 m360.gmr = M360_GMR_RCNT(23) | M360_GMR_RFEN | M360_GMR_RCYC(0) | 0429 M360_GMR_PGS(6) | M360_GMR_DPS_32BIT | M360_GMR_DWQ | 0430 M360_GMR_GAMX; 0431 0432 m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | 0433 M360_MEMC_BR_V; 0434 m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_512KB | 0435 M360_MEMC_OR_8BIT; 0436 0437 /* 0438 * Step 12: Initialize the system RAM 0439 * Set up option/base registers 0440 * 16 MB DRAM 0441 * 1 wait state 0442 * HARDWARE: 0443 * Change if you are using a different memory configuration 0444 * NOTE: no Page mode possible for EDO RAMs (?) 0445 */ 0446 ramSize = 16 * 1024 * 1024; 0447 m360.memc[7].or = M360_MEMC_OR_TCYC(1) | M360_MEMC_OR_16MB | 0448 M360_MEMC_OR_FCMC(0) | /* M360_MEMC_OR_PGME | */ 0449 M360_MEMC_OR_32BIT | M360_MEMC_OR_DRAM; 0450 m360.memc[7].br = (unsigned long)&RamBase | M360_MEMC_BR_V; 0451 0452 /* 0453 * FIXME: here we should wait for 8 refresh cycles... 0454 */ 0455 /* 0456 * Step 12a: test the ram, if wanted 0457 * FIXME: when do we call this? 0458 * -> only during firmware execution 0459 * -> perform intesive test only on request 0460 * -> ensure, that results are stored properly 0461 */ 0462 #if 0 /* FIXME: activate RAM tests again */ 0463 { 0464 void *ram_base, *ram_end, *code_loc; 0465 extern char ramtest_start,ramtest_end; 0466 ram_base = &ramtest_start; 0467 ram_end = &ramtest_end; 0468 code_loc = (void *)ramtest_exec; 0469 if ((ram_base < ram_end) && 0470 !((ram_base <= code_loc) && (code_loc < ram_end))) { 0471 ramtest_exec(ram_base,ram_end); 0472 } 0473 } 0474 #endif 0475 /* 0476 * Step 13: Copy the exception vector table to system RAM 0477 */ 0478 m68k_get_vbr (vbr); 0479 for (i = 0; i < 256; ++i) 0480 M68Kvec[i] = vbr[i]; 0481 m68k_set_vbr (M68Kvec); 0482 0483 /* 0484 * Step 14: More system initialization 0485 * SDCR (Serial DMA configuration register) 0486 * Disable SDMA during FREEZE 0487 * Give SDMA priority over all interrupt handlers 0488 * Set DMA arbiration level to 4 0489 * CICR (CPM interrupt configuration register): 0490 * SCC1 requests at SCCa position 0491 * SCC2 requests at SCCb position 0492 * SCC3 requests at SCCc position 0493 * SCC4 requests at SCCd position 0494 * Interrupt request level 4 0495 * Maintain original priority order 0496 * Vector base 128 0497 * SCCs priority grouped at top of table 0498 */ 0499 m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; 0500 m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | 0501 (4 << 13) | (0x1F << 8) | (128); 0502 0503 /* 0504 * Step 15: Set module configuration register 0505 * Disable timers during FREEZE 0506 * Enable bus monitor during FREEZE 0507 * BCLRO* arbitration level 3 0508 * No show cycles 0509 * User/supervisor access 0510 * Bus clear interupt service level 7 0511 * SIM60 interrupt sources higher priority than CPM 0512 */ 0513 m360.mcr = 0x4C7F; 0514 0515 #elif (defined (GEN68360_WITH_SRAM)) 0516 /* 0517 *************************************************** 0518 * Generic Standalone Motorola 68360 * 0519 * As described in MC68360 User's Manual * 0520 * But uses SRAM instead of DRAM * 0521 * CS0* - 512kx8 flash memory * 0522 * CS1* - 512kx32 static RAM * 0523 * CS2* - 512kx32 static RAM * 0524 *************************************************** 0525 */ 0526 0527 /* 0528 * Step 7: Deal with clock synthesizer 0529 * HARDWARE: 0530 * Change if you're not using an external oscillator which 0531 * oscillates at the system clock rate. 0532 */ 0533 m360.clkocr = 0x8F; /* No more writes, no clock outputs */ 0534 m360.pllcr = 0xD000; /* PLL, no writes, no prescale, 0535 no LPSTOP slowdown, PLL X1 */ 0536 m360.cdvcr = 0x8000; /* No more writes, no clock division */ 0537 0538 /* 0539 * Step 8: Initialize system protection 0540 * Enable watchdog 0541 * Watchdog causes system reset 0542 * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) 0543 * Enable double bus fault monitor 0544 * Enable bus monitor for external cycles 0545 * 1024 clocks for external timeout 0546 */ 0547 m360.sypcr = 0xEC; 0548 0549 /* 0550 * Step 9: Clear parameter RAM and reset communication processor module 0551 */ 0552 for (i = 0 ; i < 192 ; i += sizeof (long)) { 0553 *((long *)((char *)&m360 + 0xC00 + i)) = 0; 0554 *((long *)((char *)&m360 + 0xD00 + i)) = 0; 0555 *((long *)((char *)&m360 + 0xE00 + i)) = 0; 0556 *((long *)((char *)&m360 + 0xF00 + i)) = 0; 0557 } 0558 M360ExecuteRISC (M360_CR_RST); 0559 0560 /* 0561 * Step 10: Write PEPAR 0562 * SINTOUT not used (CPU32+ mode) 0563 * CF1MODE=00 (CONFIG1 input) 0564 * IPIPE1* 0565 * WE0* - WE3* 0566 * OE* output 0567 * CAS2* - CAS3* 0568 * CAS0* - CAS1* 0569 * CS7* 0570 * AVEC* 0571 * HARDWARE: 0572 * Change if you are using a different memory configuration 0573 * (static RAM, external address multiplexing, etc). 0574 */ 0575 m360.pepar = 0x0080; 0576 0577 /* 0578 * Step 11: Set up GMR 0579 * 0580 */ 0581 m360.gmr = 0x0; 0582 0583 /* 0584 * Step 11a: Remap 512Kx8 flash memory on CS0* 0585 * 2 wait states 0586 * Make it read-only for now 0587 */ 0588 m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | 0589 M360_MEMC_BR_V; 0590 m360.memc[0].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB | 0591 M360_MEMC_OR_8BIT; 0592 /* 0593 * Step 12: Set up main memory 0594 * 512Kx32 SRAM on CS1* 0595 * 512Kx32 SRAM on CS2* 0596 * 0 wait states 0597 */ 0598 ramSize = 4 * 1024 * 1024; 0599 m360.memc[1].br = (unsigned long)&RamBase | M360_MEMC_BR_V; 0600 m360.memc[1].or = M360_MEMC_OR_WAITS(0) | M360_MEMC_OR_2MB | 0601 M360_MEMC_OR_32BIT; 0602 m360.memc[2].br = ((unsigned long)&RamBase + 0x200000) | M360_MEMC_BR_V; 0603 m360.memc[2].or = M360_MEMC_OR_WAITS(0) | M360_MEMC_OR_2MB | 0604 M360_MEMC_OR_32BIT; 0605 /* 0606 * Step 13: Copy the exception vector table to system RAM 0607 */ 0608 m68k_get_vbr (vbr); 0609 for (i = 0; i < 256; ++i) 0610 M68Kvec[i] = vbr[i]; 0611 m68k_set_vbr (M68Kvec); 0612 0613 /* 0614 * Step 14: More system initialization 0615 * SDCR (Serial DMA configuration register) 0616 * Enable SDMA during FREEZE 0617 * Give SDMA priority over all interrupt handlers 0618 * Set DMA arbiration level to 4 0619 * CICR (CPM interrupt configuration register): 0620 * SCC1 requests at SCCa position 0621 * SCC2 requests at SCCb position 0622 * SCC3 requests at SCCc position 0623 * SCC4 requests at SCCd position 0624 * Interrupt request level 4 0625 * Maintain original priority order 0626 * Vector base 128 0627 * SCCs priority grouped at top of table 0628 */ 0629 m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; 0630 m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | 0631 (4 << 13) | (0x1F << 8) | (128); 0632 0633 /* 0634 * Step 15: Set module configuration register 0635 * Disable timers during FREEZE 0636 * Enable bus monitor during FREEZE 0637 * BCLRO* arbitration level 3 0638 * No show cycles 0639 * User/supervisor access 0640 * Bus clear interrupt service level 7 0641 * SIM60 interrupt sources higher priority than CPM 0642 */ 0643 m360.mcr = 0x4C7F; 0644 0645 #else 0646 volatile unsigned long *RamBase_p; 0647 0648 RamBase_p = (volatile unsigned long *)&RamBase; 0649 /* 0650 *************************************************** 0651 * Generic Standalone Motorola 68360 * 0652 * As described in MC68360 User's Manual * 0653 * Atlas ACE360 * 0654 *************************************************** 0655 */ 0656 0657 /* 0658 * Step 6: Is this a power-up reset? 0659 * For now we just ignore this and do *all* the steps 0660 * Someday we might want to: 0661 * if (Hard, Loss of Clock, Power-up) 0662 * Do all steps 0663 * else if (Double bus fault, watchdog or soft reset) 0664 * Skip to step 12 0665 * else (must be a CPU32+ reset command) 0666 * Skip to step 14 0667 */ 0668 0669 /* 0670 * Step 7: Deal with clock synthesizer 0671 * HARDWARE: 0672 * Change if you're not using an external 25 MHz oscillator. 0673 */ 0674 m360.clkocr = 0x8F; /* No more writes, no clock outputs */ 0675 m360.pllcr = 0xD000; /* PLL, no writes, no prescale, 0676 no LPSTOP slowdown, PLL X1 */ 0677 m360.cdvcr = 0x8000; /* No more writes, no clock division */ 0678 0679 /* 0680 * Step 8: Initialize system protection 0681 * Enable watchdog 0682 * Watchdog causes system reset 0683 * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) 0684 * Enable double bus fault monitor 0685 * Enable bus monitor for external cycles 0686 * 1024 clocks for external timeout 0687 */ 0688 m360.sypcr = 0xEC; 0689 0690 /* 0691 * Step 9: Clear parameter RAM and reset communication processor module 0692 */ 0693 for (i = 0 ; i < 192 ; i += sizeof (long)) { 0694 *((long *)((char *)&m360 + 0xC00 + i)) = 0; 0695 *((long *)((char *)&m360 + 0xD00 + i)) = 0; 0696 *((long *)((char *)&m360 + 0xE00 + i)) = 0; 0697 *((long *)((char *)&m360 + 0xF00 + i)) = 0; 0698 } 0699 M360ExecuteRISC (M360_CR_RST); 0700 0701 /* 0702 * Step 10: Write PEPAR 0703 * SINTOUT not used (CPU32+ mode) 0704 * CF1MODE=00 (CONFIG1 input) 0705 * RAS1* double drive 0706 * WE0* - WE3* 0707 * OE* output 0708 * CAS2* - CAS3* 0709 * CAS0* - CAS1* 0710 * CS7* 0711 * AVEC* 0712 * HARDWARE: 0713 * Change if you are using a different memory configuration 0714 * (static RAM, external address multiplexing, etc). 0715 */ 0716 m360.pepar = 0x0180; 0717 0718 /* 0719 * Step 11: Remap Chip Select 0 (CS0*), set up GMR 0720 * 32-bit DRAM 0721 * Internal DRAM address multiplexing 0722 * 60 nsec DRAM 0723 * 180 nsec ROM (3 wait states) 0724 * 15.36 usec DRAM refresh interval 0725 * The DRAM page size selection is not modified since this 0726 * startup code may be running in a bootstrap PROM or in 0727 * a program downloaded by the bootstrap PROM. 0728 */ 0729 m360.gmr = (m360.gmr & 0x001C0000) | M360_GMR_RCNT(23) | 0730 M360_GMR_RFEN | M360_GMR_RCYC(0) | 0731 M360_GMR_DPS_32BIT | M360_GMR_NCS | 0732 M360_GMR_GAMX; 0733 m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | 0734 M360_MEMC_BR_V; 0735 m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB | 0736 M360_MEMC_OR_8BIT; 0737 0738 /* 0739 * Step 12: Initialize the system RAM 0740 * Do this only if the DRAM has not already been set up 0741 */ 0742 if ((m360.memc[1].br & M360_MEMC_BR_V) == 0) { 0743 /* 0744 * Set up GMR DRAM page size, option and base registers 0745 * Assume 16Mbytes of DRAM 0746 * 60 nsec DRAM 0747 */ 0748 m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(5); 0749 m360.memc[1].or = M360_MEMC_OR_TCYC(0) | 0750 M360_MEMC_OR_16MB | 0751 M360_MEMC_OR_DRAM; 0752 m360.memc[1].br = (unsigned long)&RamBase | M360_MEMC_BR_V; 0753 0754 /* 0755 * Wait for chips to power up 0756 * Perform 8 read cycles 0757 */ 0758 for (i = 0; i < 50000; i++) 0759 continue; 0760 for (i = 0; i < 8; ++i) 0761 *RamBase_p; 0762 0763 /* 0764 * Determine memory size (1, 4, or 16 Mbytes) 0765 * Set GMR DRAM page size appropriately. 0766 * The OR is left at 16 Mbytes. The bootstrap PROM places its 0767 * .data and .bss segments at the top of the 16 Mbyte space. 0768 * A 1 Mbyte or 4 Mbyte DRAM will show up several times in 0769 * the memory map, but will work with the same bootstrap PROM. 0770 */ 0771 *(volatile char *)&RamBase = 0; 0772 *((volatile char *)&RamBase+0x00C01800) = 1; 0773 if (*(volatile char *)&RamBase) { 0774 m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(1); 0775 } 0776 else { 0777 *((volatile char *)&RamBase+0x00801000) = 1; 0778 if (*(volatile char *)&RamBase) { 0779 m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(3); 0780 } 0781 } 0782 0783 /* 0784 * Enable parity checking 0785 */ 0786 m360.memc[1].br |= M360_MEMC_BR_PAREN; 0787 } 0788 switch (m360.gmr & 0x001C0000) { 0789 default: ramSize = 4 * 1024 * 1024; break; 0790 case M360_GMR_PGS(1): ramSize = 1 * 1024 * 1024; break; 0791 case M360_GMR_PGS(3): ramSize = 4 * 1024 * 1024; break; 0792 case M360_GMR_PGS(5): ramSize = 16 * 1024 * 1024; break; 0793 } 0794 0795 /* 0796 * Step 13: Copy the exception vector table to system RAM 0797 */ 0798 m68k_get_vbr (vbr); 0799 for (i = 0; i < 256; ++i) 0800 M68Kvec[i] = vbr[i]; 0801 m68k_set_vbr (M68Kvec); 0802 0803 /* 0804 * Step 14: More system initialization 0805 * SDCR (Serial DMA configuration register) 0806 * Enable SDMA during FREEZE 0807 * Give SDMA priority over all interrupt handlers 0808 * Set DMA arbiration level to 4 0809 * CICR (CPM interrupt configuration register): 0810 * SCC1 requests at SCCa position 0811 * SCC2 requests at SCCb position 0812 * SCC3 requests at SCCc position 0813 * SCC4 requests at SCCd position 0814 * Interrupt request level 4 0815 * Maintain original priority order 0816 * Vector base 128 0817 * SCCs priority grouped at top of table 0818 */ 0819 m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; 0820 m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | 0821 (4 << 13) | (0x1F << 8) | (128); 0822 0823 /* 0824 * Step 15: Set module configuration register 0825 * Disable timers during FREEZE 0826 * Enable bus monitor during FREEZE 0827 * BCLRO* arbitration level 3 0828 * No show cycles 0829 * User/supervisor access 0830 * Bus clear interrupt service level 7 0831 * SIM60 interrupt sources higher priority than CPM 0832 */ 0833 m360.mcr = 0x4C7F; 0834 #endif 0835 0836 /* 0837 * Copy data, clear BSS, switch stacks and call main() 0838 * Must pass ramSize as argument since the data/bss segment 0839 * may be overwritten. 0840 */ 0841 _CopyDataClearBSSAndStart (ramSize); 0842 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |