1 /* Memory sub-system initialization code */
4 #include <asm/regdef.h>
5 #include <asm/au1x00.h>
6 #include <asm/mipsregs.h>
8 #define AU1500_SYS_ADDR 0xB1900000
9 #define sys_endian 0x0038
10 #define CP0_Config0 $16
11 #define CPU_SCALE ((CONFIG_SYS_MHZ) / 12) /* CPU clock is a multiple of 12 MHz */
12 #define MEM_1MS ((CONFIG_SYS_MHZ) * 1000)
21 * Step 1) Establish CPU endian mode.
23 * Switch S1.1 Off(bit7 reads 1) is Little Endian
24 * Switch S1.1 On (bit7 reads 0) is Big Endian
26 #ifdef CONFIG_DBAU1550
52 li t0, DB1XX0_BCSR_ADDR
55 beq zero,t1,big_endian
59 /* Change Au1 core to little endian */
60 li t0, AU1500_SYS_ADDR
68 /* Big Endian is default so nothing to do but fall through */
73 * Step 2) Establish Status Register
74 * (set BEV, clear ERL, clear EXL, clear IE)
80 * Step 3) Establish CP0 Config0
87 * Step 4) Disable Watchpoint facilities
93 * Step 5) Disable the performance counters
95 mtc0 zero, CP0_PERFORMANCE
99 * Step 6) Establish EJTAG Debug register
105 * Step 7) Establish Cause
111 /* Establish Wired (and Random) */
115 #ifdef CONFIG_DBAU1550
116 /* No workaround if running from ram */
120 bne t1, t3, noCacheJump
123 /*** From AMD YAMON ***/
125 * Step 8) Initialize the caches
135 bne t2, t3, cacheloop
138 /* Save return address */
141 /* Run from cacheable space now */
145 li t1, ~0x20000000 /* convert to KSEG0 */
147 addi t0, 5*4 /* 5 insns beyond cachehere */
151 /* Restore return address */
155 * Step 9) Initialize the TLB
157 li t0, 0 # index value
158 li t1, 0x00000000 # entryhi value
159 li t2, 32 # 32 entries
162 /* Probe TLB for matching EntryHi */
167 /* Examine Index[P], 1=no matching entry */
171 addiu t1, t1, 1 # increment t1 (asid)
172 beq zero, t3, tlbloop
175 /* Initialize the TLB entry */
177 mtc0 zero, CP0_ENTRYLO0
178 mtc0 zero, CP0_ENTRYLO1
179 mtc0 zero, CP0_PAGEMASK
187 #endif /* CONFIG_DBAU1550 */
189 /* First setup pll:s to make serial work ok */
190 /* We have a 12 MHz crystal */
192 li t1, CPU_SCALE /* CPU clock */
198 /* wait 1mS for clocks to settle */
205 li t1, 0x20 /* 96 MHz */
206 sw t1, 0(t0) /* aux pll */
209 #ifdef CONFIG_DBAU1550
210 /* Static memory controller */
211 /* RCE0 - can not change while fetching, do so from icache */
212 move t2, ra /* Store return address */
218 move ra, t2 /* Move return addess back */
222 /*** /From YAMON ***/
225 #endif /* CONFIG_DBAU1550 */
227 #ifdef CONFIG_DBAU1550
232 /* RCE0 AMD MirrorBit Flash (?) */
240 #else /* CONFIG_DBAU1550 */
245 /* RCE0 AMD 29LV640M MirrorBit Flash */
253 #endif /* CONFIG_DBAU1550 */
255 /* RCE1 CPLD Board Logic */
268 #ifdef CONFIG_DBAU1550
269 /* RCE2 CPLD Board Logic */
295 /* RCE3 PCMCIA 250ns */
310 /* Set peripherals to a known state */
336 li t0, IC0_FALLINGCLR
369 li t0, IC1_FALLINGCLR
389 li t0, SYS_PININPUTEN
411 /* wait 1mS before setup */
417 #ifdef CONFIG_DBAU1550
418 /* SDCS 0,1,2 DDR SDRAM */
446 li t1, 0x9030060a /* Program refresh - disabled */
455 li t0, MEM_SDPRECMD /* Precharge all */
490 li t0, MEM_SDPRECMD /* Precharge all */
494 /* Issue 2 autoref */
505 li t1, 0x9830060a /* Program refresh - enabled */
509 #else /* CONFIG_DBAU1550 */
539 li t1, 0x64000C24 /* Disable */
554 li t1, 0x66000C24 /* Enable */
568 #endif /* CONFIG_DBAU1550 */
569 /* wait 1mS after setup */