2 * BCM947XX DRAM init & sizing
4 * Used by both cfe and shared/boot.
6 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
15 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
17 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 * $Id: sisdram.S,v 1.8 2008-12-04 01:08:42 Exp $
29 /* Debug macro - write a number to a chipc reg - use it with caution,
30 * it changes k0 and k1 registers.
33 #if defined(IL_BIGENDIAN) && defined(BCMHND74K)
41 #define TRACEINIT(x) \
42 li k0,KSEG1ADDR(0x18000040); \
61 * This file exists because board_draminit is an entry point for cfe as well
62 * as for hndrte & min_osl. Because of the former case, we cannot assume
63 * any of the register settings from boot.S,
73 /* Figure out if we have an SB or AI chip */
74 li s2,KSEG1ADDR(SI_ENUM_BASE) # s2 = SI_ENUM_BASE
76 lw s6,CC_CHIPID(s2) # s6 = ChipId reg
78 srl s7,t1,CID_TYPE_SHIFT # s7 = ChipType (0 for SB, = 1 for AI)
80 /* Check if we booted from flash, compute reloc for text addresses */
84 1: li t0,PHYSADDR_MASK
90 sub s5,ra,t0 # s5: Relocation factor
92 /* Call appropriate draminit for chip type */
94 #if !defined(BCMCHIPTYPE) || (BCMCHIPTYPE == 0)
100 #if !defined(BCMCHIPTYPE) || (BCMCHIPTYPE == 1)
107 /* BCMCHIPTYPE defined but does not match this chip */
117 /* Size memory if needed (Need to reinit TRACE after sb_draminit) */
122 li a0,-1 # -1 means no controller
136 li s3,KSEG1 # s3 = KSEG1
144 lw t1,0x3c(t0) # Read back to ensure completion
152 /* Didn't find an alias, must be 128MB */