1/* ********************************************************************* 2 * SB1250 Board Support Package 3 * 4 * Board-specific initialization File: BCM91125C_INIT.S 5 * 6 * This module contains the assembly-language part of the init 7 * code for this board support package. The routine 8 * "board_earlyinit" lives here. 9 * 10 * Author: Mitch Lichtenberg 11 * 12 ********************************************************************* 13 * 14 * Copyright 2000,2001,2002,2003 15 * Broadcom Corporation. All rights reserved. 16 * 17 * This software is furnished under license and may be used and 18 * copied only in accordance with the following terms and 19 * conditions. Subject to these conditions, you may download, 20 * copy, install, use, modify and distribute modified or unmodified 21 * copies of this software in source and/or binary form. No title 22 * or ownership is transferred hereby. 23 * 24 * 1) Any source code used, modified or distributed must reproduce 25 * and retain this copyright notice and list of conditions 26 * as they appear in the source file. 27 * 28 * 2) No right is granted to use any trade name, trademark, or 29 * logo of Broadcom Corporation. The "Broadcom Corporation" 30 * name may not be used to endorse or promote products derived 31 * from this software without the prior written permission of 32 * Broadcom Corporation. 33 * 34 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 35 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 36 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 37 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 38 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 39 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 40 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 41 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 42 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 43 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 44 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 45 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 46 * THE POSSIBILITY OF SUCH DAMAGE. 47 ********************************************************************* */ 48 49 50#include "sbmips.h" 51#include "sb1250_genbus.h" 52#include "sb1250_regs.h" 53#include "sb1250_scd.h" 54#include "sb1250_mc.h" 55#include "sb1250_mac.h" 56#include "bsp_config.h" 57#include "cpu_config.h" 58#include "bcm91125pcix.h" 59#include "mipsmacros.h" 60#include "sb1250_draminit.h" 61 62 .text 63 64 65/* ********************************************************************* 66 * Macros 67 ********************************************************************* */ 68/* 69 * Define this to send the LED messages to the serial port instead 70 * of to the LEDs. 71 */ 72 73/*#define _SERIAL_PORT_LEDS_*/ 74 75#ifdef _SERIAL_PORT_LEDS_ 76#include "sb1250_uart.h" /* need this for serial defs */ 77#endif 78 79/* ********************************************************************* 80 * BOARD_EARLYINIT() 81 * 82 * Initialize board registers. This is the earliest 83 * time the BSP gets control. This routine cannot assume that 84 * memory is operational, and therefore all code in this routine 85 * must run from registers only. The $ra register must not 86 * be modified, as it contains the return address. 87 * 88 * This routine will be called from uncached space, before 89 * the caches are initialized. If you want to make 90 * subroutine calls from here, you must use the CALLKSEG1 macro. 91 * 92 * Among other things, this is where the GPIO registers get 93 * programmed to make on-board LEDs function, or other startup 94 * that has to be done before anything will work. 95 * 96 * Input parameters: 97 * nothing 98 * 99 * Return value: 100 * nothing 101 ********************************************************************* */ 102 103LEAF(board_earlyinit) 104 105 # 106 # Configure the GPIOs 107 # 108 109 li t0,PHYS_TO_K1(A_GPIO_DIRECTION) 110 li t1,GPIO_OUTPUT_MASK 111 sd t1,0(t0) 112 113 li t0,PHYS_TO_K1(A_GPIO_INT_TYPE) 114 li t1,GPIO_INTERRUPT_MASK 115 sd t1,0(t0) 116 117 118 # 119 # Configure the LEDs 120 # 121 122 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(LEDS_CS)) 123 li t1,LEDS_PHYS >> S_IO_ADDRBASE 124 sd t1,R_IO_EXT_START_ADDR(t0) 125 126 li t1,LEDS_SIZE-1 /* Needs to be 1 smaller, se UM for details */ 127 sd t1,R_IO_EXT_MULT_SIZE(t0) 128 129 li t1,LEDS_TIMING0 130 sd t1,R_IO_EXT_TIME_CFG0(t0) 131 132 li t1,LEDS_TIMING1 133 sd t1,R_IO_EXT_TIME_CFG1(t0) 134 135 li t1,LEDS_CONFIG 136 sd t1,R_IO_EXT_CFG(t0) 137 138 139 140 # 141 # Configure the alternate boot ROM 142 # 143 144 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(ALT_BOOTROM_CS)) 145 146 li t1,ALT_BOOTROM_PHYS >> S_IO_ADDRBASE 147 sd t1,R_IO_EXT_START_ADDR(t0) 148 149 li t1,ALT_BOOTROM_SIZE-1 150 sd t1,R_IO_EXT_MULT_SIZE(t0) 151 152 li t1,ALT_BOOTROM_TIMING0 153 sd t1,R_IO_EXT_TIME_CFG0(t0) 154 155 li t1,ALT_BOOTROM_TIMING1 156 sd t1,R_IO_EXT_TIME_CFG1(t0) 157 158 li t1,ALT_BOOTROM_CONFIG 159 sd t1,R_IO_EXT_CFG(t0) 160 161 162 163 # 164 # Configure USB1 165 # 166 167 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(USB1_CS)) 168 li t1,USB1_PHYS >> S_IO_ADDRBASE 169 sd t1,R_IO_EXT_START_ADDR(t0) 170 171 li t1,USB1_SIZE-1 /* Needs to be 1 smaller, se UM for details */ 172 sd t1,R_IO_EXT_MULT_SIZE(t0) 173 174 li t1,USB1_TIMING0 175 sd t1,R_IO_EXT_TIME_CFG0(t0) 176 177 li t1,USB1_TIMING1 178 sd t1,R_IO_EXT_TIME_CFG1(t0) 179 180 li t1,USB1_CONFIG 181 sd t1,R_IO_EXT_CFG(t0) 182 183 184 # 185 # Configure USB2 186 # 187 188 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(USB2_CS)) 189 li t1,USB2_PHYS >> S_IO_ADDRBASE 190 sd t1,R_IO_EXT_START_ADDR(t0) 191 192 li t1,USB2_SIZE-1 /* Needs to be 1 smaller, se UM for details */ 193 sd t1,R_IO_EXT_MULT_SIZE(t0) 194 195 li t1,USB2_TIMING0 196 sd t1,R_IO_EXT_TIME_CFG0(t0) 197 198 li t1,USB2_TIMING1 199 sd t1,R_IO_EXT_TIME_CFG1(t0) 200 201 li t1,USB2_CONFIG 202 sd t1,R_IO_EXT_CFG(t0) 203 204 205 # 206 # Configure PCMCIA 207 # 208 209 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(PCMCIA_CS)) 210 li t1,PCMCIA_PHYS >> S_IO_ADDRBASE 211 sd t1,R_IO_EXT_START_ADDR(t0) 212 213 li t1,PCMCIA_SIZE-1 /* Needs to be 1 smaller, se UM for details */ 214 sd t1,R_IO_EXT_MULT_SIZE(t0) 215 216 li t1,PCMCIA_TIMING0 217 sd t1,R_IO_EXT_TIME_CFG0(t0) 218 219 li t1,PCMCIA_TIMING1 220 sd t1,R_IO_EXT_TIME_CFG1(t0) 221 222 li t1,PCMCIA_CONFIG 223 sd t1,R_IO_EXT_CFG(t0) 224 225 226#ifdef _SERIAL_PORT_LEDS_ 227 228 # Program the mode register for 8 bits/char, no parity 229 230 li t0,PHYS_TO_K1(A_DUART_MODE_REG_1_A) 231 li t1,V_DUART_BITS_PER_CHAR_8 | V_DUART_PARITY_MODE_NONE 232 sd t1,(t0) 233 234 # Program the mode register for 1 stop bit, ignore CTS 235 236 li t0,PHYS_TO_K1(A_DUART_MODE_REG_2_A) 237 li t1,M_DUART_STOP_BIT_LEN_1 238 sd t1,(t0) 239 240 # Program the baud rate to 115200 241 242 li t0,PHYS_TO_K1(A_DUART_CLK_SEL_A) 243 li t1,V_DUART_BAUD_RATE(115200) 244 sd t1,(t0) 245 246 # Dont use any interrupts 247 248 li t0,PHYS_TO_K1(A_DUART_IMR) 249 ld t1,(t0) 250 and t1,~M_DUART_IMR_ALL_A 251 sd t1,(t0) 252 253 # Enable sending and receiving 254 255 li t0,PHYS_TO_K1(A_DUART_CMD_A) 256 li t1,M_DUART_RX_EN | M_DUART_TX_EN 257 sd t1,(t0) 258 259#endif 260 261 j ra 262 263END(board_earlyinit) 264 265 266/* ********************************************************************* 267 * BOARD_DRAMINFO 268 * 269 * Return the address of the DRAM information table 270 * 271 * Input parameters: 272 * nothing 273 * 274 * Return value: 275 * v0 - DRAM info table, return 0 to use default table 276 ********************************************************************* */ 277LEAF(board_draminfo) 278 279 la v0,myinfo 280 j ra 281 282myinfo: 283 /* 284 * Globals: Only one memory controller, no port interleaving 285 */ 286 DRAM_GLOBALS(0) 287 288 DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, CFG_DRAM_CSINTERLEAVE, CFG_DRAM_ECC, 0) 289 290 DRAM_CS_SPD(MC_CS0, 0, 0, 0x54) 291 DRAM_CS_SPD(MC_CS2, 0, 0, 0x55) 292 293 DRAM_EOT 294 295END(board_draminfo) 296 297/* ********************************************************************* 298 * BOARD_UARTA_TXCHAR 299 * 300 * Transmit a single character via UART A 301 * 302 * Input parameters: 303 * a0 - character to transmit (low-order 8 bits) 304 * 305 * Return value: 306 * nothing 307 * 308 * Registers used: 309 * t0,t1 310 ********************************************************************* */ 311#ifdef _SERIAL_PORT_LEDS_ 312LEAF(board_uarta_txchar) 313 314 # Wait until there is space in the transmit buffer 315 3161: li t0,PHYS_TO_K1(A_DUART_STATUS_A) 317 ld t1,(t0) # Get status bits 318 and t1,M_DUART_TX_RDY # test for ready 319 beq t1,0,1b # keep going till ready 320 321 # Okay, now send the character. 322 323 li t0,PHYS_TO_K1(A_DUART_TX_HOLD_A) 324 sd a0,(t0) 325 326 # done! 327 328 j ra 329 330END(board_uarta_txchar) 331#endif 332 333 334/* ********************************************************************* 335 * BOARD_SETLEDS(x) 336 * 337 * Set LEDs for boot-time progress indication. Not used if 338 * the board does not have progress LEDs. This routine 339 * must not call any other routines, since it may be invoked 340 * either from KSEG0 or KSEG1 and it may be invoked 341 * whether or not the icache is operational. 342 * 343 * Input parameters: 344 * a0 - LED value (8 bits per character, 4 characters) 345 * 346 * Return value: 347 * nothing 348 * 349 * Registers used: 350 * t0,t1,t2,t3 351 ********************************************************************* */ 352 353#define LED_CHAR0 (32+8*3) 354#define LED_CHAR1 (32+8*2) 355#define LED_CHAR2 (32+8*1) 356#define LED_CHAR3 (32+8*0) 357 358LEAF(board_setleds) 359 360#ifdef _SERIAL_PORT_LEDS_ 361 move t3,ra 362 move t2,a0 363 364 li a0,'[' 365 bal board_uarta_txchar 366 367 move a0,t2 368 rol a0,8 369 bal board_uarta_txchar 370 371 rol a0,8 372 bal board_uarta_txchar 373 374 rol a0,8 375 bal board_uarta_txchar 376 377 rol a0,8 378 bal board_uarta_txchar 379 380 li a0,']' 381 bal board_uarta_txchar 382 li a0,13 383 bal board_uarta_txchar 384 li a0,10 385 bal board_uarta_txchar 386 387 move ra,t3 388#else 389 390 li t0,PHYS_TO_K1(LEDS_PHYS) 391 392 rol a0,a0,8 393 and t1,a0,0xFF 394 sb t1,LED_CHAR0(t0) 395 396 rol a0,a0,8 397 and t1,a0,0xFF 398 sb t1,LED_CHAR1(t0) 399 400 rol a0,a0,8 401 and t1,a0,0xFF 402 sb t1,LED_CHAR2(t0) 403 404 rol a0,a0,8 405 and t1,a0,0xFF 406 sb t1,LED_CHAR3(t0) 407 408#endif 409 j ra 410 411END(board_setleds) 412