1 /* *********************************************************************
2 * SB1250 Board Support Package
4 * Board-specific initialization File: BCM91120C_INIT.S
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.
10 * Author: Mitch Lichtenberg (mpl@broadcom.com)
12 *********************************************************************
14 * Copyright 2000,2001,2002,2003
15 * Broadcom Corporation. All rights reserved.
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.
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.
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.
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 ********************************************************************* */
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 "bcm91120c.h"
58 #include "mipsmacros.h"
59 #include "sb1250_draminit.h"
63 #if defined(_BCM91120C_DIAG_CFG_)
64 #define _SERIAL_PORT_LEDS_
67 /* *********************************************************************
69 ********************************************************************* */
71 #ifdef _SERIAL_PORT_LEDS_
72 #define BOARD_PROMICE_BASE (0x1FDFFC00)
73 #define BOARD_PROMICE_ZERO (0)
74 #define BOARD_PROMICE_ONE (1)
75 #define BOARD_PROMICE_DATA (2)
76 #define BOARD_PROMICE_STATUS (3)
78 #define TDA 0x01 /* Target data available */
79 #define HDA 0x02 /* Host data available */
80 #define OVR 0x04 /* Host data overflow */
84 /* *********************************************************************
87 * Initialize board registers. This is the earliest
88 * time the BSP gets control. This routine cannot assume that
89 * memory is operational, and therefore all code in this routine
90 * must run from registers only. The $ra register must not
91 * be modified, as it contains the return address.
93 * This routine will be called from uncached space, before
94 * the caches are initialized. If you want to make
95 * subroutine calls from here, you must use the CALLKSEG1 macro.
97 * Among other things, this is where the GPIO registers get
98 * programmed to make on-board LEDs function, or other startup
99 * that has to be done before anything will work.
106 ********************************************************************* */
108 LEAF(board_earlyinit)
111 # Configure the GPIOs
114 li t0,PHYS_TO_K1(A_GPIO_DIRECTION)
115 li t1,GPIO_OUTPUT_MASK
118 li t0,PHYS_TO_K1(A_GPIO_INT_TYPE)
119 li t1,GPIO_INTERRUPT_MASK
123 # Set both loopback pins to "disable"
125 li t0,PHYS_TO_K1(A_GPIO_PIN_CLR)
126 li t1,M_GPIO_SERIAL0_LOOPBACK | M_GPIO_SERIAL1_LOOPBACK
134 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(LEDS_CS))
135 li t1,LEDS_PHYS >> S_IO_ADDRBASE
136 sd t1,R_IO_EXT_START_ADDR(t0)
138 li t1,LEDS_SIZE-1 /* Needs to be 1 smaller, se UM for details */
139 sd t1,R_IO_EXT_MULT_SIZE(t0)
142 sd t1,R_IO_EXT_TIME_CFG0(t0)
145 sd t1,R_IO_EXT_TIME_CFG1(t0)
148 sd t1,R_IO_EXT_CFG(t0)
153 # Configure the alternate boot ROM
156 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(ALT_BOOTROM_CS))
158 li t1,ALT_BOOTROM_PHYS >> S_IO_ADDRBASE
159 sd t1,R_IO_EXT_START_ADDR(t0)
161 li t1,ALT_BOOTROM_SIZE-1
162 sd t1,R_IO_EXT_MULT_SIZE(t0)
164 li t1,ALT_BOOTROM_TIMING0
165 sd t1,R_IO_EXT_TIME_CFG0(t0)
167 li t1,ALT_BOOTROM_TIMING1
168 sd t1,R_IO_EXT_TIME_CFG1(t0)
170 li t1,ALT_BOOTROM_CONFIG
171 sd t1,R_IO_EXT_CFG(t0)
177 # Configure the Big Flash
180 li t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(BIG_FLASH_CS))
182 li t1,BIG_FLASH_PHYS >> S_IO_ADDRBASE
183 sd t1,R_IO_EXT_START_ADDR(t0)
185 li t1,BIG_FLASH_SIZE-1
186 sd t1,R_IO_EXT_MULT_SIZE(t0)
188 li t1,BIG_FLASH_TIMING0
189 sd t1,R_IO_EXT_TIME_CFG0(t0)
191 li t1,BIG_FLASH_TIMING1
192 sd t1,R_IO_EXT_TIME_CFG1(t0)
194 li t1,BIG_FLASH_CONFIG
195 sd t1,R_IO_EXT_CFG(t0)
198 * If the CPU is a 1250 or hybrid, certain initialization has
199 * to be done so that the chip can be used like an 112x.
202 /* First, figure out what type of SOC we're on. */
203 ld t1, PHYS_TO_K1(A_SCD_SYSTEM_REVISION)
205 bne t3, K_SYS_SOC_TYPE_BCM1250, is_bcm112x
208 * We have a 1250 or hybrid. Initialize registers as appropriate.
212 * If we're not already running as a uniprocessor, get us there.
214 dsrl t1, t1, S_SYS_PART # part number now in t1
216 dsrl t3, t3, 8 # t3 = numcpus
218 ld t4, PHYS_TO_K1(A_SCD_SYSTEM_CFG)
219 or t4, t4, M_SYS_SB_SOFTRES
220 xor t4, t4, M_SYS_SB_SOFTRES
221 sd t4, PHYS_TO_K1(A_SCD_SYSTEM_CFG) /* clear soft reset */
225 or t4, t4, M_SYS_SB_SOFTRES | M_SYS_UNICPU0
226 sd t4, PHYS_TO_K1(A_SCD_SYSTEM_CFG) /* go unicpu */
236 li t0, PHYS_TO_K1(A_MC_BASE_0)
237 dli t1, V_MC_CONFIG_DEFAULT | M_MC_ECC_DISABLE | \
239 sd t1, R_MC_CONFIG(t0)
240 sd zero, R_MC_CS_START(t0)
241 sd zero, R_MC_CS_END(t0)
242 sd zero, R_MC_CS_INTERLEAVE(t0)
243 sd zero, R_MC_CS_ATTR(t0)
244 sd zero, R_MC_TEST_DATA(t0)
245 sd zero, R_MC_TEST_ECC(t0)
248 * Zero out MAC 2's address register. (This has
249 * undefined value after reset, but OSes may check
250 * it on some parts to see if they should init
251 * the interface. This is a convenient place
255 li t0, PHYS_TO_K1(A_MAC_BASE_2)
256 sd zero, R_MAC_ETHERNET_ADDR(t0)
265 /* *********************************************************************
268 * Return the address of the DRAM information table
274 * v0 - DRAM info table, return 0 to use default table
275 ********************************************************************* */
277 #define BOARD_CONFIG_STAKTEK 0
278 #define BOARD_CONFIG_NONSTAKTEK 1
279 #define BOARD_CONFIG_TBD1 2
280 #define BOARD_CONFIG_TBD2 3
287 /* First, figure out what type of SOC we're on. */
288 ld t3, PHYS_TO_K1(A_SCD_SYSTEM_REVISION)
291 /* t3 now contains "SOC type." */
294 * Read the config bits to decide if we have staktek rams or not
297 li t1,PHYS_TO_K1(A_SCD_SYSTEM_CFG)
298 ld t1,0(t1) /* read system config register */
299 dsrl t1,S_SYS_CONFIG /* move config bits to bottom */
300 and t1,3 /* isolate bottom 2 bits */
301 /* t1 now contains board config, t3 still has SOC type. */
304 * Pick from different init tables, depending on whether
305 * the chip is a hybrid.
309 * If not a bcm1250, must be real 112x (w/pass3 SOC features).
311 bne t3, K_SYS_SOC_TYPE_BCM1250, bcm1120y_pass2_or_later_draminit
313 /* If 1250 (hybrid), need to check rev. */
314 li t3, PHYS_TO_K1(A_SCD_SYSTEM_REVISION)
315 ld t3, 0(t3) /* read system rev register */
316 and t3, M_SYS_REVISION /* mask off all but rev */
317 dsrl t3, S_SYS_REVISION /* move rev bits to bottom */
319 /* Less than starting pass2 revision -> pass1 hybrid. */
320 blt t3, K_SYS_REVISION_PASS2, bcm1120y_pass1_draminit
323 * Pick the table for Pass2 BCM1120Y parts, or real BCM1120 parts.
325 bcm1120y_pass2_or_later_draminit:
326 beq t1, BOARD_CONFIG_NONSTAKTEK, non_staktek
328 LOADREL(v0,staktek_drams)
332 LOADREL(v0,non_staktek_drams)
337 LOADREL(v0,sim_drams)
345 * Pick the table for Pass1 BCM1120Y parts.
347 bcm1120y_pass1_draminit:
348 beq t1, BOARD_CONFIG_NONSTAKTEK, bcm1120y_pass1_non_staktek
350 LOADREL(v0,staktek_drams_bcm1120y_pass1)
353 bcm1120y_pass1_non_staktek:
354 LOADREL(v0,non_staktek_drams_bcm1120y_pass1)
361 * 512MB on MC 1 (JEDEC SDRAM)
364 * NOTE: THERE IS NO MC0 ON THE 11xx!
366 * Minimum tMEMCLK: 8.0ns (125Mhz max freq)
368 * CS0 Geometry: 13 rows, 9 columns, 2 bankbits
369 * CS1 Geometry: 13 rows, 9 columns, 2 bankbits
370 * CS2 Geometry: 13 rows, 9 columns, 2 bankbits
371 * CS3 Geometry: 13 rows, 9 columns, 2 bankbits
373 * 64khz refresh, CAS Latency 2.5
374 * Timing (ns): tCK=7.50 tRAS=45 tRP=20.0 tRRD=15.0 tRCD=20.0 tRFC=auto tRC=auto
376 * Clock Config: Addrskew 0x08, DQOskew 0x08, DQIskew 0x08,
377 * addrdrive 0x0f, datadrive 0x0f, clockdrive 0x0f
381 * Globals: Only one memory controller, no port interleaving
386 DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, CFG_DRAM_CSINTERLEAVE, CFG_DRAM_ECC, 0)
387 DRAM_CHAN_CLKCFG(0x08, 0x08, 0x08, 0x0f, 0x0f, 0x0f)
389 DRAM_CS_GEOM(MC_CS0, 13, 9, 2)
390 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
392 DRAM_CS_GEOM(MC_CS1, 13, 9, 2)
393 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
395 DRAM_CS_GEOM(MC_CS2, 13, 9, 2)
396 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
398 DRAM_CS_GEOM(MC_CS3, 13, 9, 2)
399 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
404 staktek_drams_bcm1120y_pass1:
407 * Same as above, but no DRAM_CHAN_CLKCFG line so that clock config
408 * is default, and OK for 1250pass1 die used in pass1 hybrids.
413 DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, CFG_DRAM_CSINTERLEAVE, CFG_DRAM_ECC, 0)
415 DRAM_CS_GEOM(MC_CS0, 13, 9, 2)
416 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
418 DRAM_CS_GEOM(MC_CS1, 13, 9, 2)
419 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
421 DRAM_CS_GEOM(MC_CS2, 13, 9, 2)
422 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
424 DRAM_CS_GEOM(MC_CS3, 13, 9, 2)
425 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
433 * 256MB on MC 1 (JEDEC SDRAM)
435 * NOTE: THERE IS NO MC0 ON THE 11xx!
437 * Minimum tMEMCLK: 8.0ns (125Mhz max freq)
439 * CS0 Geometry: 13 rows, 9 columns, 2 bankbits
440 * CS2 Geometry: 13 rows, 9 columns, 2 bankbits
442 * 64khz refresh, CAS Latency 2.5
443 * Timing (ns): tCK=7.50 tRAS=45 tRP=20.0 tRRD=15.0 tRCD=20.0 tRFC=auto tRC=auto
445 * Clock Config: Addrskew 0x08, DQOskew 0x08, DQIskew 0x08,
446 * addrdrive 0x0f, datadrive 0x0f, clockdrive 0x0f
450 * Globals: Only one memory controller, no port interleaving
455 DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, CFG_DRAM_CSINTERLEAVE, CFG_DRAM_ECC, 0)
456 DRAM_CHAN_CLKCFG(0x08, 0x08, 0x08, 0x0f, 0x0f, 0x0f)
458 DRAM_CS_GEOM(MC_CS0, 13, 9, 2)
459 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
461 DRAM_CS_GEOM(MC_CS2, 13, 9, 2)
462 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
467 non_staktek_drams_bcm1120y_pass1:
470 * Same as above, but no DRAM_CHAN_CLKCFG line so that clock config
471 * is default, and OK for 1250pass1 die used in pass1 hybrids.
476 DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, CFG_DRAM_CSINTERLEAVE, CFG_DRAM_ECC, 0)
478 DRAM_CS_GEOM(MC_CS0, 13, 9, 2)
479 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
481 DRAM_CS_GEOM(MC_CS2, 13, 9, 2)
482 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
489 /* Note: there is NO MC0 on the 11xx */
490 /* 64MB on MC1 CS0 (SDRAM) */
494 DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, CFG_DRAM_CSINTERLEAVE, CFG_DRAM_ECC, 0)
496 DRAM_CS_GEOM(MC_CS0, 12, 9, 2)
497 DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_64khz, JEDEC_CASLAT_25, 0, 45, DRT4(20,0), DRT4(15,0), DRT4(20,0), 0, 0)
506 /* *********************************************************************
509 * Transmit a single character via UART A
512 * a0 - character to transmit (low-order 8 bits)
519 ********************************************************************* */
521 #ifdef _SERIAL_PORT_LEDS_
523 LEAF(board_piai2_txchar)
525 # Wait until there is space in the transmit buffer
527 li t0,PHYS_TO_K1(BOARD_PROMICE_BASE)
529 1: lb t1,BOARD_PROMICE_STATUS(t0)
533 # Okay, now send the character.
535 sb a0,BOARD_PROMICE_ZERO(t0)
541 END(board_piai2_txchar)
544 /* *********************************************************************
547 * Set LEDs for boot-time progress indication. Not used if
548 * the board does not have progress LEDs. This routine
549 * must not call any other routines, since it may be invoked
550 * either from KSEG0 or KSEG1 and it may be invoked
551 * whether or not the icache is operational.
554 * a0 - LED value (8 bits per character, 4 characters)
561 ********************************************************************* */
563 #define LED_CHAR0 (32+8*3)
564 #define LED_CHAR1 (32+8*2)
565 #define LED_CHAR2 (32+8*1)
566 #define LED_CHAR3 (32+8*0)
570 #ifdef _SERIAL_PORT_LEDS_
575 bal board_piai2_txchar
579 li t0,PHYS_TO_K1(LEDS_PHYS)
581 bal board_piai2_txchar
584 li t0,PHYS_TO_K1(LEDS_PHYS)
586 bal board_piai2_txchar
589 li t0,PHYS_TO_K1(LEDS_PHYS)
591 bal board_piai2_txchar
594 li t0,PHYS_TO_K1(LEDS_PHYS)
596 bal board_piai2_txchar
599 bal board_piai2_txchar
601 bal board_piai2_txchar
603 bal board_piai2_txchar
611 li t0,PHYS_TO_K1(LEDS_PHYS)