[a800d09c] | 1 | /* |
---|
| 2 | * Intec SS555 initialization routines. |
---|
[f62c7daa] | 3 | */ |
---|
| 4 | |
---|
| 5 | /* |
---|
[a800d09c] | 6 | * SS555 port sponsored by Defence Research and Development Canada - Suffield |
---|
| 7 | * Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca) |
---|
| 8 | * |
---|
| 9 | * Derived from c/src/lib/libbsp/powerpc/mbx8xx/startup/imbx8xx.c: |
---|
| 10 | * |
---|
| 11 | * Copyright (c) 1999, National Research Council of Canada |
---|
| 12 | * |
---|
| 13 | * The license and distribution terms for this file may be |
---|
| 14 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[a800d09c] | 16 | */ |
---|
| 17 | |
---|
| 18 | #include <bsp.h> |
---|
| 19 | |
---|
| 20 | SPR_RW(ICTRL); |
---|
[cefcc5eb] | 21 | SPR_RW(PPC_DEC); |
---|
[a800d09c] | 22 | SPR_RW(TBWU); |
---|
| 23 | SPR_RW(TBWL); |
---|
| 24 | SPR_RO(IMMR); |
---|
| 25 | SPR_RW(MI_GRA); |
---|
| 26 | SPR_RW(L2U_GRA); |
---|
| 27 | SPR_RW(BBCMCR); |
---|
| 28 | |
---|
[af2af2b4] | 29 | extern char int_ram_top[]; /* top of internal ram */ |
---|
| 30 | |
---|
[a800d09c] | 31 | /* |
---|
| 32 | * Initialize SS555 |
---|
| 33 | */ |
---|
| 34 | void _InitSS555 (void) |
---|
| 35 | { |
---|
[76f9c44] | 36 | register uint32_t plprcr, msr; |
---|
[a800d09c] | 37 | |
---|
| 38 | /* |
---|
| 39 | * Initialize the System Protection Control Register (SYPCR). |
---|
| 40 | * The SYPCR can only be written once after Reset. |
---|
| 41 | */ |
---|
[6128a4a] | 42 | usiu.sypcr = |
---|
[a800d09c] | 43 | USIU_SYPCR_SWTC(WATCHDOG_TIMEOUT) /* set watchdog timeout */ |
---|
| 44 | | USIU_SYPCR_BMT(0xFF) /* set bus monitor timeout */ |
---|
| 45 | | USIU_SYPCR_BME /* enable bus monitor */ |
---|
| 46 | | USIU_SYPCR_SWF /* watchdog halted in freeze */ |
---|
| 47 | #if WATCHDOG_TIMEOUT != 0xFFFF |
---|
| 48 | | USIU_SYPCR_SWE /* enable watchdog */ |
---|
| 49 | #endif |
---|
| 50 | | USIU_SYPCR_SWRI /* watchdog forces reset */ |
---|
| 51 | | USIU_SYPCR_SWP; /* prescale watchdog by 2048 */ |
---|
| 52 | |
---|
| 53 | TICKLE_WATCHDOG(); /* restart watchdog timer */ |
---|
[6128a4a] | 54 | |
---|
| 55 | /* |
---|
[a800d09c] | 56 | * Re-tune the PLL to the desired system clock frequency. |
---|
| 57 | */ |
---|
| 58 | usiu.plprck = USIU_UNLOCK_KEY; /* unlock PLPRCR */ |
---|
[6128a4a] | 59 | usiu.plprcr = |
---|
[a800d09c] | 60 | USIU_PLPRCR_TEXPS /* assert TEXP always */ |
---|
| 61 | | USIU_PLPRCR_MF(BSP_CLOCK_HZ / BSP_CRYSTAL_HZ); |
---|
| 62 | /* PLL multiplication factor */ |
---|
| 63 | usiu.plprck = 0; /* lock PLPRCR */ |
---|
| 64 | |
---|
| 65 | while (((plprcr = usiu.plprcr) & USIU_PLPRCR_SPLS) == 0) |
---|
| 66 | ; /* wait for PLL to re-lock */ |
---|
[6128a4a] | 67 | |
---|
| 68 | /* |
---|
[a800d09c] | 69 | * Enable the timebase and decrementer, then initialize decrementer |
---|
| 70 | * register to a large value to guarantee that a decrementer interrupt |
---|
[6128a4a] | 71 | * will not be generated before the kernel is fully initialized. |
---|
[a800d09c] | 72 | * Initialize the timebase register to zero. |
---|
| 73 | */ |
---|
| 74 | usiu.tbscrk = USIU_UNLOCK_KEY; |
---|
| 75 | usiu.tbscr |= USIU_TBSCR_TBE; /* enable time base and decrementer */ |
---|
| 76 | usiu.tbscrk = 0; |
---|
| 77 | |
---|
| 78 | usiu.tbk = USIU_UNLOCK_KEY; |
---|
[cefcc5eb] | 79 | _write_PPC_DEC(0x7FFFFFFF); |
---|
[a800d09c] | 80 | _write_TBWU(0x00000000 ); |
---|
| 81 | _write_TBWL(0x00000000 ); |
---|
| 82 | usiu.tbk = 0; |
---|
| 83 | |
---|
| 84 | /* |
---|
| 85 | * Run the Inter-Module Bus at full speed. |
---|
| 86 | */ |
---|
| 87 | imb.uimb.umcr &= ~UIMB_UMCR_HSPEED; |
---|
[6128a4a] | 88 | |
---|
[a800d09c] | 89 | /* |
---|
| 90 | * Initialize Memory Controller for External RAM |
---|
| 91 | * |
---|
| 92 | * Initialize the Base and Option Registers (BR0-BR7 and OR0-OR7). Note |
---|
| 93 | * that for all chip selects, ORx should be programmed before BRx. |
---|
| 94 | * |
---|
| 95 | * If booting from internal flash ROM, configure the external RAM to |
---|
| 96 | * extend the internal RAM. If booting from external RAM, leave it at |
---|
| 97 | * zero but set it up appropriately. |
---|
| 98 | */ |
---|
| 99 | usiu.memc[0]._or = |
---|
| 100 | USIU_MEMC_OR_512K /* bank size */ |
---|
| 101 | | USIU_MEMC_OR_SCY(0) /* wait states in first beat of burst */ |
---|
| 102 | | USIU_MEMC_OR_BSCY(0); /* wait states in subsequent beats */ |
---|
[6128a4a] | 103 | |
---|
[a800d09c] | 104 | usiu.memc[0]._br = |
---|
[6128a4a] | 105 | USIU_MEMC_BR_BA(_read_IMMR() & IMMR_FLEN |
---|
[76f9c44] | 106 | ? (uint32_t)int_ram_top : 0) /* base address */ |
---|
[a800d09c] | 107 | | USIU_MEMC_BR_PS32 /* 32-bit data bus */ |
---|
| 108 | | USIU_MEMC_BR_TBDIP /* toggle bdip */ |
---|
| 109 | | USIU_MEMC_BR_V; /* base register valid */ |
---|
[6128a4a] | 110 | |
---|
[a800d09c] | 111 | /* |
---|
| 112 | * Initialize Memory Controller for External CPLD |
---|
| 113 | * |
---|
| 114 | * The SS555 board includes a CPLD to control on-board features and |
---|
| 115 | * off-board devices. (Configuration taken from Intec's hwhook.c) |
---|
| 116 | */ |
---|
| 117 | usiu.memc[3]._or = |
---|
| 118 | USIU_MEMC_OR_16M /* bank size */ |
---|
| 119 | | USIU_MEMC_OR_CSNT /* negate CS/WE early */ |
---|
| 120 | | USIU_MEMC_OR_ACS_HALF /* assert CS half cycle after address */ |
---|
| 121 | | USIU_MEMC_OR_SCY(15) /* wait states in first beat of burst */ |
---|
[6128a4a] | 122 | | USIU_MEMC_OR_TRLX; /* relaxed timing */ |
---|
[a800d09c] | 123 | |
---|
| 124 | usiu.memc[3]._br = |
---|
| 125 | USIU_MEMC_BR_BA(&cpld) /* base address */ |
---|
| 126 | | USIU_MEMC_BR_PS16 /* 16-bit data bus */ |
---|
| 127 | | USIU_MEMC_BR_BI /* inhibit bursting */ |
---|
| 128 | | USIU_MEMC_BR_V; /* base register valid */ |
---|
[6128a4a] | 129 | |
---|
[a800d09c] | 130 | /* |
---|
| 131 | * Disable show cycles and serialization so that burst accesses will work |
---|
| 132 | * properly. A different value, such as 0x0, may be more appropriate for |
---|
| 133 | * debugging, but can be set with the debugger, if needed. |
---|
| 134 | */ |
---|
| 135 | _write_ICTRL(0x00000007); |
---|
[6128a4a] | 136 | |
---|
[a800d09c] | 137 | /* |
---|
| 138 | * Set up Burst Buffer Controller (BBC) |
---|
| 139 | */ |
---|
| 140 | _write_BBCMCR( |
---|
| 141 | BBCMCR_ETRE /* enable exception relocation */ |
---|
| 142 | | BBCMCR_BE); /* enable burst accesses */ |
---|
| 143 | _isync; |
---|
| 144 | |
---|
| 145 | _CPU_MSR_GET(msr); |
---|
[6128a4a] | 146 | msr |= MSR_IP; /* set prefix for exception relocation */ |
---|
[a800d09c] | 147 | _CPU_MSR_SET(msr); |
---|
| 148 | } |
---|