BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / cfe / cfe / arch / mips / board / bcm91125c / src / bcm91125c_init.S
blob6c7f0dfcb8e3808b7330c5aad00047142ee5bb45
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 (mpl@broadcom.com)
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     ********************************************************************* */
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 "bcm91125c.h"
58 #include "mipsmacros.h"
59 #include "sb1250_draminit.h"
61                 .text
63 #if defined(_BCM91125C_DIAG_CFG_)
64 #define _SERIAL_PORT_LEDS_
65 #endif
67 /*  *********************************************************************
68     *  Macros
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 */
81 #endif
84 /*  *********************************************************************
85     *  BOARD_EARLYINIT()
86     *  
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.
92     *
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.
96     *
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.
100     *  
101     *  Input parameters: 
102     *      nothing
103     *      
104     *  Return value:
105     *      nothing
106     ********************************************************************* */
108 LEAF(board_earlyinit)
110        #
111        # Configure the GPIOs
112        #
114                 li      t0,PHYS_TO_K1(A_GPIO_DIRECTION)
115                 li      t1,GPIO_OUTPUT_MASK
116                 sd      t1,0(t0)
118                 li      t0,PHYS_TO_K1(A_GPIO_INT_TYPE)
119                 li      t1,GPIO_INTERRUPT_MASK
120                 sd      t1,0(t0)
122        #
123        # Set both loopback pins to "disable"
124        #
125                 li      t0,PHYS_TO_K1(A_GPIO_PIN_CLR)
126                 li      t1,M_GPIO_SERIAL0_LOOPBACK | M_GPIO_SERIAL1_LOOPBACK
127                 sd      t1,0(t0)
130        #
131        # Configure the LEDs
132        #     
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)
141                 li      t1,LEDS_TIMING0
142                 sd      t1,R_IO_EXT_TIME_CFG0(t0)
144                 li      t1,LEDS_TIMING1
145                 sd      t1,R_IO_EXT_TIME_CFG1(t0)
147                 li      t1,LEDS_CONFIG
148                 sd      t1,R_IO_EXT_CFG(t0)
152        #
153        # Configure the alternate boot ROM
154        #     
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)
176        #
177        # Configure the Big Flash
178        #     
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)
197         /*
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.
200          */
202         /* First, figure out what type of SOC we're on. */
203         ld      t1, PHYS_TO_K1(A_SCD_SYSTEM_REVISION)
204         SYS_SOC_TYPE(t3, t1)
205         bne     t3, K_SYS_SOC_TYPE_BCM1250, is_bcm112x
207         /*
208          * We have a 1250 or hybrid.  Initialize registers as appropriate.
209          */
211         /*
212          * If we're not already running as a uniprocessor, get us there.
213          */
214         dsrl    t1, t1, S_SYS_PART      # part number now in t1
215         and     t3, t1, 0xf00
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 */
223         beq     t3, 1, 2f
225         or      t4, t4, M_SYS_SB_SOFTRES | M_SYS_UNICPU0
226         sd      t4, PHYS_TO_K1(A_SCD_SYSTEM_CFG)        /* go unicpu */
227         sync
229         b       1b
231         
232         /*
233          * Clean up MC 0.
234          */
236         li      t0, PHYS_TO_K1(A_MC_BASE_0)
237         dli     t1, V_MC_CONFIG_DEFAULT | M_MC_ECC_DISABLE | \
238                     V_MC_CS_MODE_MSB_CS
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)
247         /*
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
252          * to zero it.)
253          */
255         li      t0, PHYS_TO_K1(A_MAC_BASE_2)
256         sd      zero, R_MAC_ETHERNET_ADDR(t0)
258 is_bcm112x:
260         j       ra
262 END(board_earlyinit)
265 /*  *********************************************************************
266     *  BOARD_DRAMINFO
267     *  
268     *  Return the address of the DRAM information table
269     *  
270     *  Input parameters: 
271     *      nothing
272     *      
273     *  Return value:
274     *      v0 - DRAM info table, return 0 to use default table
275     ********************************************************************* */
276 LEAF(board_draminfo)
278                 move    t0,ra
280                 LOADREL(v0,myinfo)
282                 move    ra,t0
283                 j       ra
285 myinfo:
286         /*
287          * Globals: Only one memory controller, no port interleaving
288          */
289         DRAM_GLOBALS(0)
291         DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, CFG_DRAM_CSINTERLEAVE, CFG_DRAM_ECC, 0)
293         DRAM_CS_SPD(MC_CS0, 0, 0, 0x54)
294         DRAM_CS_SPD(MC_CS2, 0, 0, 0x55)
296         DRAM_EOT
298 END(board_draminfo)
301 /*  *********************************************************************
302     *  BOARD_PIAI2_TXCHAR
303     *  
304     *  Transmit a single character via UART A
305     *  
306     *  Input parameters: 
307     *      a0 - character to transmit (low-order 8 bits)
308     *      
309     *  Return value:
310     *      nothing
311     *      
312     *  Registers used:
313     *      t0,t1
314     ********************************************************************* */
316 #ifdef _SERIAL_PORT_LEDS_
318 LEAF(board_piai2_txchar)
320         # Wait until there is space in the transmit buffer
322                 li      t0,PHYS_TO_K1(BOARD_PROMICE_BASE)
324 1:              lb      t1,BOARD_PROMICE_STATUS(t0)
325                 andi    t1,TDA
326                 bne     t1,zero,1b
328         # Okay, now send the character.
330                 sb      a0,BOARD_PROMICE_ZERO(t0)
332         # done!
334                 j       ra
336 END(board_piai2_txchar)
337 #endif
339 /*  *********************************************************************
340     *  BOARD_SETLEDS(x)
341     *  
342     *  Set LEDs for boot-time progress indication.  Not used if
343     *  the board does not have progress LEDs.  This routine
344     *  must not call any other routines, since it may be invoked
345     *  either from KSEG0 or KSEG1 and it may be invoked 
346     *  whether or not the icache is operational.
347     *  
348     *  Input parameters: 
349     *      a0 - LED value (8 bits per character, 4 characters)
350     *      
351     *  Return value:
352     *      nothing
353     *  
354     *  Registers used:
355     *      t0,t1,t2,t3
356     ********************************************************************* */
358 #define LED_CHAR0       (32+8*3)
359 #define LED_CHAR1       (32+8*2)
360 #define LED_CHAR2       (32+8*1)
361 #define LED_CHAR3       (32+8*0)
363 LEAF(board_setleds)
365 #ifdef _SERIAL_PORT_LEDS_
366                 move    t3,ra
367                 move    t2,a0
369                 li      a0,'['
370                 bal     board_piai2_txchar
372                 move    a0,t2
373                 rol     a0,8
374                 li      t0,PHYS_TO_K1(LEDS_PHYS)
375                 sb      a0,LED_CHAR0(t0)
376                 bal     board_piai2_txchar
378                 rol     a0,8
379                 li      t0,PHYS_TO_K1(LEDS_PHYS)
380                 sb      a0,LED_CHAR1(t0)
381                 bal     board_piai2_txchar
383                 rol     a0,8
384                 li      t0,PHYS_TO_K1(LEDS_PHYS)
385                 sb      a0,LED_CHAR2(t0)
386                 bal     board_piai2_txchar
388                 rol     a0,8
389                 li      t0,PHYS_TO_K1(LEDS_PHYS)
390                 sb      a0,LED_CHAR3(t0)
391                 bal     board_piai2_txchar
393                 li      a0,']'
394                 bal     board_piai2_txchar
395                 li      a0,13
396                 bal     board_piai2_txchar
397                 li      a0,10
398                 bal     board_piai2_txchar
400                 move    ra,t3
401 #else
403         /*
404          * Sending to LEDs
405          */
406                 li      t0,PHYS_TO_K1(LEDS_PHYS)
408                 rol     a0,a0,8
409                 and     t1,a0,0xFF
410                 sb      t1,LED_CHAR0(t0)
412                 rol     a0,a0,8
413                 and     t1,a0,0xFF
414                 sb      t1,LED_CHAR1(t0)
416                 rol     a0,a0,8
417                 and     t1,a0,0xFF
418                 sb      t1,LED_CHAR2(t0)
420                 rol     a0,a0,8
421                 and     t1,a0,0xFF
422                 sb      t1,LED_CHAR3(t0)
424 #endif
425                 j       ra
427 END(board_setleds)