2 * BCM947XX Boot code for standalone apps.
4 * Code should be position-independent until it copies itself to SDRAM.
6 * Copyright 2004, Broadcom Corporation
9 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
10 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
11 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
12 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
27 li a0,KSEG1ADDR(SB_ENUM_BASE)
29 # XXX: the following code snipet sets clk frequency to 200M
30 # correct pll clk freq to real speed in the 5350 case.
31 # unless its vsim which we detect as pkg option 1 (should be 0xe)
33 li a3,BCM5350_CHIP_ID # 5350 ChipID
34 lw t1,CC_CHIPID(a0) # ChipID register
35 li t2,CID_ID_MASK # chip id is bit 0-15
37 bne t2,a3,2f # if not 5350 then skip
40 li t2,CID_PKG_MASK # if it is a vsim 5350, also skip
42 li a3,(HDLSIM5350_PKG_ID << CID_PKG_SHIFT)
43 beq t2,a3,2f # if pkg opt 1 then skip
48 beq a3,t1,2f # move ahead if clk freq set correctly
50 sw a3,CC_CLKC_N(a0) # set control N1 to select 6
52 sw t1,CC_WATCHDOG(a0) # set WatchDog Reset
58 lw t1,CC_CHIPID(a0) # ChipID register
59 li t2,CID_ID_MASK # chip id is bit 0-15
60 li a3,BCM5354_CHIP_ID # 5354 ChipID
62 bne t2,a3,ramcheck # if not 5354 then skip
65 li t2,0x1 # Need define
66 sw t2,PMU_REG_CONTROL_ADDR(a0)
67 li t3,0x6800000 # Should only affect the switch bits
68 sw t3,PMU_REG_CONTROL_DATA(a0)
71 * Trim the output voltage of the 1.2V BB switcher and 2.5V
72 * regulator to the correct value.
75 sw t2,PMU_REG_CONTROL_ADDR(a0)
76 li t3,0x2000 # Reduce the output voltage of
77 sw t3,PMU_REG_CONTROL_DATA(a0) # BB switcher to get 1.2V
79 sw t2,PMU_REG_CONTROL_ADDR(a0)
80 li t3,0x02000000 # Increase the output voltage
81 sw t3,PMU_REG_CONTROL_DATA(a0) # of VDDP LDO to get 2.5V
83 lw t2,PMU_CTL(a0) # Check if PLL has been programmed
84 andi t2,t2,PCTL_XTALFREQ_MASK
85 bnez t2,3f # Yup, leave it alone
87 li t2,0x7ffff # Should only turn off the PLL bit
88 sw t2,PMU_MIN_RES_MASK(a0) # Disable base band PLL
89 sw t2,PMU_MAX_RES_MASK(a0)
92 /* Init code for FF4 space without TLB, enabling RAC */
93 3: li t0,0x1fa0000c # Set up CBR to 0x1fax_xxxx
97 or t3,t2,0xc0000000 # enable ffxx_xxxx space # without programming TLB
99 li t0,0xff40000c # change CBR to ff4x_xxxx
104 /* Check if we booted from SDRAM */
107 1: li t0,PHYSADDR_MASK
113 /* Call draminit to size memory */
120 /* Is this chipc rev 11 or 12 and a serial flash? */
121 li t0,KSEG1ADDR(SB_ENUM_BASE)
122 lw t1,(SBCONFIGOFF + SBIDHIGH)(t0)
123 and t2,t1,SBIDH_CC_MASK
124 srl t2,t2,SBIDH_CC_SHIFT
125 bne t2,SB_CC,checkcon /* Not chipc */
127 and t2,t1,SBIDH_RC_MASK
128 and t3,t1,SBIDH_RCE_MASK
129 srl t3,t3,SBIDH_RCE_SHIFT
131 ble t2,10,checkcon /* ccrev <= 10 */
133 bge t2,13,checkcon /* ccrev >= 13 */
135 lw t0,CC_CAPABILITIES(t0)
136 and t0,t0,CC_CAP_FLASH_MASK
137 beq t0,SFLASH_AT,switchkseg0 /* Atmel sflash */
139 beq t0,SFLASH_ST,switchkseg0 /* ST sflash */
144 /* Check if the caches are already on */
147 beq t0,CONF_CM_UNCACHED,initcaches
154 /* Turn on the caches in the CP0 register */
155 mfc0 t0,C0_DIAGNOSTIC
156 or t0,(BRCM_IC_ENABLE | BRCM_DC_ENABLE) /* Enable both I$ and D$ */
157 mtc0 t0,C0_DIAGNOSTIC
160 1: /* Get cache sizes */
170 srl s1,CONF1_DL_SHIFT
172 sll s1,t0,s1 /* s1 has D$ cache line size */
176 srl s2,CONF1_DA_SHIFT
177 addiu s2,CONF1_DA_BASE /* s2 now has D$ associativity */
181 srl t0,CONF1_DS_SHIFT
183 sll s3,s3,t0 /* s3 has D$ sets per way */
185 multu s2,s3 /* sets/way * associativity */
186 mflo t0 /* total cache lines */
188 multu s1,t0 /* D$ linesize * lines */
189 mflo s2 /* s2 is now D$ size in bytes */
191 /* Initilize the D$: */
195 li t0,KSEG0 /* Just an address for the first $ line */
196 addu t1,t0,s2 /* + size of cache == end */
199 1: cache Index_Store_Tag_D,0(t0)
205 /* Now we get to do it all again for the I$ */
212 srl t0,CONF1_IL_SHIFT
214 sll s3,t0 /* s3 has I$ cache line size */
218 srl t0,CONF1_IA_SHIFT
219 addiu s4,t0,CONF1_IA_BASE /* s4 now has I$ associativity */
223 srl t0,CONF1_IS_SHIFT
225 sll s5,t0 /* s5 has I$ sets per way */
227 multu s4,s5 /* sets/way * associativity */
228 mflo t0 /* s4 is not total cache lines */
230 multu s3,t0 /* I$ linesize * lines */
231 mflo s4 /* s4 is cache size in bytes */
233 /* Initilize the I$: */
237 li t0,KSEG0 /* Just an address for the first $ line */
238 addu t1,t0,s4 /* + size of cache == end */
241 1: cache Index_Store_Tag_I,0(t0)
247 /* Caches initialized, change cacheability */
249 and t0,~CONF_CM_CMASK
250 or t0,CONF_CM_CACHABLE_NONCOHERENT
255 /* And now jump to KSEG0 */
256 li t0,KSEG1ADDR(SB_FLASH1)
267 /* Initialize SDRAM */
268 li t0,KSEG0ADDR(SB_FLASH1)
276 /* v0 now contains memory size in bytes */
278 /* Copy self to SDRAM */
284 li a0,KSEG0ADDR(SB_FLASH1)
286 and a1,PHYSADDR_MASK /* Uncached writes to avoid a flush */
301 /* Black hole for traps with BEV on */
313 /* Record the size of the binary */
326 .globl embedded_nvram
328 .fill 0x100,4,~(0x48534c46)
331 /* Record the memory size */
335 /* Set up stack pointer */
347 /* Setup trap handlers */
349 li t0,KSEG0ADDR(SB_FLASH1)
367 /* In case c_main returns */