| 1 | /************************************************************************* |
|---|
| 2 | ** Broadcom Corp. Confidential |
|---|
| 3 | ** Copyright 2010 Broadcom Corp. All Rights Reserved. |
|---|
| 4 | ** |
|---|
| 5 | ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 6 | ** AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 7 | ** EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 8 | ** |
|---|
| 9 | ** File: bl.S |
|---|
| 10 | ** Description: low level board dependent startup code |
|---|
| 11 | ** Created: alex[ |
|---|
| 12 | ** |
|---|
| 13 | ** REVISION: |
|---|
| 14 | ** |
|---|
| 15 | ***************************************************************************/ |
|---|
| 16 | |
|---|
| 17 | #include "bmips3300.h" |
|---|
| 18 | #include "bchp_common.h" |
|---|
| 19 | #include "bchp_sun_top_ctrl.h" |
|---|
| 20 | #include "bchp_memc_ddr23_aphy_ac_0.h" |
|---|
| 21 | #include "memc_0_config.h" |
|---|
| 22 | |
|---|
| 23 | #define SHMOO_STACK_START 0x80000000 |
|---|
| 24 | #define SHMOO_STACK_SIZE 0x4000 |
|---|
| 25 | |
|---|
| 26 | #define BCHP_REG_BASE PHYS_TO_K1(BCHP_PHYSICAL_OFFSET) |
|---|
| 27 | #define INITIAL_SR ((CP0_STATUS_SR_MASK | CP0_STATUS_CU1_MASK | CP0_STATUS_BEV_MASK | CP0_STATUS_IE_MASK) & ~( CP0_STATUS_ERL_MASK | CP0_STATUS_EXL_MASK)) |
|---|
| 28 | BL_STACK_SIZE = 0x1000 |
|---|
| 29 | |
|---|
| 30 | .lcomm bl_stack, BL_STACK_SIZE |
|---|
| 31 | .text |
|---|
| 32 | .globl __start |
|---|
| 33 | .set noreorder |
|---|
| 34 | |
|---|
| 35 | __start: |
|---|
| 36 | b init_cpu |
|---|
| 37 | nop |
|---|
| 38 | .org __start+0x380 |
|---|
| 39 | rom_gen_ex: # general exception will loop here |
|---|
| 40 | b rom_gen_ex |
|---|
| 41 | nop |
|---|
| 42 | nop |
|---|
| 43 | nop |
|---|
| 44 | .globl key1 |
|---|
| 45 | key1: |
|---|
| 46 | /* .fill 0x80, 1, 0xaa */ |
|---|
| 47 | /* test public key generated from privkey.pem */ |
|---|
| 48 | .word 0x9A231766,0x5903DAB5,0x9BA09842,0x8C8E0A10 |
|---|
| 49 | .word 0xA81264B2,0xF011A39C,0xE515793F,0x99900060 |
|---|
| 50 | .word 0xDAA137F4,0xBA0C6075,0xE78D15D9,0x2A48DDD3 |
|---|
| 51 | .word 0x71F3AE65,0x7CF04AFC,0x6AD79335,0x8EC267B5 |
|---|
| 52 | .word 0xE5F95530,0x7CB71669,0xBA23B801,0x643A8299 |
|---|
| 53 | .word 0xF2882267,0x8C5ECE15,0x8A9C7AD1,0x231F8D2B |
|---|
| 54 | .word 0x19CF89F2,0xAE2905A2,0xD764A002,0x557C855E |
|---|
| 55 | .word 0xC5640D61,0x4C27B99C,0x5B74E4B4,0xFEF0D90B |
|---|
| 56 | key1_header: |
|---|
| 57 | .fill 0x40, 1, 0xbb |
|---|
| 58 | key1_signature: |
|---|
| 59 | .fill 0x80, 1, 0xcc |
|---|
| 60 | external_root_key: |
|---|
| 61 | .fill 0x80, 1, 0xdd |
|---|
| 62 | bootloader_signature: |
|---|
| 63 | .fill 0x80, 1, 0xee |
|---|
| 64 | bootloader_header: |
|---|
| 65 | .fill 0x40, 1, 0x55 |
|---|
| 66 | |
|---|
| 67 | init_cpu: |
|---|
| 68 | li t0, INITIAL_SR |
|---|
| 69 | mtc0 t0, CP0_STATUS |
|---|
| 70 | nop |
|---|
| 71 | nop |
|---|
| 72 | |
|---|
| 73 | move $28, $0 |
|---|
| 74 | /* cache off: clear top 2 bits of CP0, $22 select $2 */ |
|---|
| 75 | mfc0 $2, $22, 0 |
|---|
| 76 | and $2, $2, ~0xc0000000 |
|---|
| 77 | mtc0 $2, $22, 0 |
|---|
| 78 | nop |
|---|
| 79 | /* Bring everything out of reset except external system reset */ |
|---|
| 80 | li t0, BCHP_REG_BASE | BCHP_SUN_TOP_CTRL_SW_RESET |
|---|
| 81 | li t3, (BCHP_SUN_TOP_CTRL_SW_RESET_aio_sw_reset_MASK |\ |
|---|
| 82 | BCHP_SUN_TOP_CTRL_SW_RESET_bvn_sw_reset_MASK |\ |
|---|
| 83 | BCHP_SUN_TOP_CTRL_SW_RESET_vec_sw_reset_MASK |\ |
|---|
| 84 | BCHP_SUN_TOP_CTRL_SW_RESET_xpt_sw_reset_MASK |\ |
|---|
| 85 | BCHP_SUN_TOP_CTRL_SW_RESET_sundry_sw_reset_MASK |\ |
|---|
| 86 | BCHP_SUN_TOP_CTRL_SW_RESET_memc_sw_reset_MASK) |
|---|
| 87 | sw t3,0(t0) |
|---|
| 88 | sync |
|---|
| 89 | li t3,0 |
|---|
| 90 | sw t3,0(t0) |
|---|
| 91 | |
|---|
| 92 | #if 1 /* Surendra and Andrew indicate this is needed in the bootloader */ |
|---|
| 93 | /* DRAM for HD DTA */ |
|---|
| 94 | li t0, BCHP_REG_BASE | BCHP_MEMC_DDR23_APHY_AC_0_PLL_FREQ_CNTL |
|---|
| 95 | lw t2, 0(t0) |
|---|
| 96 | and t3, t2, ~BCHP_MEMC_DDR23_APHY_AC_0_PLL_FREQ_CNTL_MDIV_MASK |
|---|
| 97 | or t3, (5 << BCHP_MEMC_DDR23_APHY_AC_0_PLL_FREQ_CNTL_MDIV_SHIFT) |
|---|
| 98 | sw t3, 0(t0) |
|---|
| 99 | sync |
|---|
| 100 | #endif |
|---|
| 101 | bal init_serial |
|---|
| 102 | nop |
|---|
| 103 | |
|---|
| 104 | bal _writeasm |
|---|
| 105 | li a0, '$' |
|---|
| 106 | |
|---|
| 107 | bal init_mips |
|---|
| 108 | nop |
|---|
| 109 | |
|---|
| 110 | bal do_chip_init |
|---|
| 111 | nop |
|---|
| 112 | |
|---|
| 113 | bal init_serial |
|---|
| 114 | nop |
|---|
| 115 | |
|---|
| 116 | li a0, SHMOO_STACK_START |
|---|
| 117 | li a1, SHMOO_STACK_SIZE |
|---|
| 118 | bal lock_d_cache |
|---|
| 119 | nop |
|---|
| 120 | |
|---|
| 121 | /* now initialize sp to stack start */ |
|---|
| 122 | la sp, (SHMOO_STACK_START + SHMOO_STACK_SIZE - 48) |
|---|
| 123 | # create a stack space for the the memc_init arguments. |
|---|
| 124 | addiu sp, -16 |
|---|
| 125 | # load parameters in a0-a3 for memc_init |
|---|
| 126 | |
|---|
| 127 | /*int memc_init(int32_t memc_num_to_shmoo, int32_t write_dqs_shmoo_range, uint32_t num_byte_slices, uint32_t gate_value) |
|---|
| 128 | */ |
|---|
| 129 | li a0, 0x0 |
|---|
| 130 | lui a1, MEMC_0_DEFAULT_WRITE_DQS_PHASE_RANGE_UPPER |
|---|
| 131 | ori a1, MEMC_0_DEFAULT_WRITE_DQS_PHASE_RANGE_LOWER |
|---|
| 132 | li a2, 2 #16bit DDR |
|---|
| 133 | li a3, MEMC_0_DEFAULT_GATE_VALUE |
|---|
| 134 | |
|---|
| 135 | la t0, memc_init |
|---|
| 136 | jalr t0 |
|---|
| 137 | nop |
|---|
| 138 | |
|---|
| 139 | bal _writeasm |
|---|
| 140 | li a0, 'H' |
|---|
| 141 | |
|---|
| 142 | bal invalidate_all_i_cache |
|---|
| 143 | nop |
|---|
| 144 | |
|---|
| 145 | bal _writeasm |
|---|
| 146 | li a0, 'E' |
|---|
| 147 | |
|---|
| 148 | bal clear_all_d_cache |
|---|
| 149 | nop |
|---|
| 150 | bal _writeasm |
|---|
| 151 | li a0, 'L' |
|---|
| 152 | |
|---|
| 153 | /* copy data segment */ |
|---|
| 154 | la a0, _etext |
|---|
| 155 | la a1, _fdata |
|---|
| 156 | la t2,_edata |
|---|
| 157 | subu a2,t2,a1 |
|---|
| 158 | |
|---|
| 159 | beqz a2, 2f |
|---|
| 160 | nop |
|---|
| 161 | 1: |
|---|
| 162 | lw t0, 0(a0) |
|---|
| 163 | sw t0, 0(a1) |
|---|
| 164 | sub a2, a2, 4 |
|---|
| 165 | addi a0, a0, 4 |
|---|
| 166 | addi a1, a1, 4 |
|---|
| 167 | bnez a2, 1b |
|---|
| 168 | nop |
|---|
| 169 | 2: |
|---|
| 170 | bal _writeasm |
|---|
| 171 | li a0, 'L' |
|---|
| 172 | |
|---|
| 173 | /* clear bss segment */ |
|---|
| 174 | la a0,_fbss |
|---|
| 175 | la a1,_end |
|---|
| 176 | subu a1,a1,a0 |
|---|
| 177 | |
|---|
| 178 | beqz a1, 2f |
|---|
| 179 | nop |
|---|
| 180 | 1: |
|---|
| 181 | sw zero,0(a0) |
|---|
| 182 | sub a1, a1, 4 |
|---|
| 183 | addi a0, a0, 4 |
|---|
| 184 | bnez a1, 1b |
|---|
| 185 | nop |
|---|
| 186 | 2: |
|---|
| 187 | bal _writeasm |
|---|
| 188 | li a0, 'O' |
|---|
| 189 | |
|---|
| 190 | /* load stack pointer*/ |
|---|
| 191 | la sp, bl_stack + BL_STACK_SIZE - 24 |
|---|
| 192 | /* jump in to cached segment */ |
|---|
| 193 | la t0, bootloader_main |
|---|
| 194 | jalr t0 |
|---|
| 195 | move a0, zero |
|---|
| 196 | loop: |
|---|
| 197 | b loop |
|---|
| 198 | nop |
|---|
| 199 | |
|---|
| 200 | LEAF(aligned_copy) |
|---|
| 201 | |
|---|
| 202 | 1: |
|---|
| 203 | lw v0, 0(a0) |
|---|
| 204 | addiu a2, a2, -4 |
|---|
| 205 | sw v0, 0(a1) |
|---|
| 206 | addiu a0, a0, 4 |
|---|
| 207 | bnez a2, 1b |
|---|
| 208 | addiu a1, a1, 4 |
|---|
| 209 | |
|---|
| 210 | jr ra |
|---|
| 211 | nop |
|---|
| 212 | |
|---|
| 213 | END(aligned_copy) |
|---|
| 214 | |
|---|
| 215 | #include "uart.s" |
|---|
| 216 | #include "chip.s" |
|---|
| 217 | #undef RelAddrPrintChar |
|---|
| 218 | #undef RelAddrPrintHex32 |
|---|
| 219 | #undef SHMOO_STACK_START |
|---|
| 220 | #undef SHMOO_STACK_SIZE |
|---|
| 221 | #include "common_routines.s" |
|---|
| 222 | #include "cache_lib.s" |
|---|
| 223 | #include "mips_libs.s" |
|---|
| 224 | #include "memc_0_client_prog.s" |
|---|
| 225 | #include "memc_0_access.s" |
|---|
| 226 | #include "run_shmoo.s" |
|---|
| 227 | |
|---|