BCM WL 6.30.102.9 (r366174)
[tomato.git] / release / src-rt / cfe / build / broadcom / tiny / tiny_init.S
blob7e1a286a2df05dfa4edbec98d305eb54120afa66
1 /*  *********************************************************************
2     *  SB1250 Board Support Package
3     *  
4     *  Board-specific initialization            File: TINY_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 "bsp_config.h"
55 #include "tiny.h"
57                 .text
59 /*  *********************************************************************
60     *  Macros
61     ********************************************************************* */
65 /*  *********************************************************************
66     *  BOARD_EARLYINIT()
67     *  
68     *  Initialize board registers.  This is the earliest 
69     *  time the BSP gets control.  This routine cannot assume that
70     *  memory is operational, and therefore all code in this routine
71     *  must run from registers only.  The $ra register must not
72     *  be modified, as it contains the return address.
73     *
74     *  This routine will be called from uncached space, before
75     *  the caches are initialized.  If you want to make
76     *  subroutine calls from here, you must use the CALLKSEG1 macro.
77     *
78     *  Among other things, this is where the GPIO registers get 
79     *  programmed to make on-board LEDs function, or other startup
80     *  that has to be done before anything will work.
81     *  
82     *  Input parameters: 
83     *      nothing
84     *      
85     *  Return value:
86     *      nothing
87     ********************************************************************* */
89 LEAF(board_earlyinit)
91         #
92         # Reprogram the SCD to make sure UART0 is enabled.
93         # Some CSWARM boards have the SER0 enable bit when
94         # they're not supposed to, which switches the UART
95         # into synchronous mode.  Kill off the SCD bit.
96         # XXX this should be investigated in hardware, as 
97         # XXX it is a strap option on the CPU.
98         #
100                 li      t0,PHYS_TO_K1(A_SCD_SYSTEM_CFG)
101                 ld      t1,0(t0)
102                 dli     t2,~M_SYS_SER0_ENABLE
103                 and     t1,t1,t2
104                 sd      t1,0(t0)
106        #
107        # Configure the GPIOs
108        #
110                 li      t0,PHYS_TO_K1(A_GPIO_DIRECTION)
111                 li      t1,GPIO_OUTPUT_MASK
112                 sd      t1,0(t0)
114                 li      t0,PHYS_TO_K1(A_GPIO_INT_TYPE)
115                 li      t1,GPIO_INTERRUPT_MASK
116                 sd      t1,0(t0)
118        #
119        # Turn on the diagnostic LED and turn off the sturgeon NMI
120        #
121                 li      t0,PHYS_TO_K1(A_GPIO_PIN_SET)
122                 li      t1,M_GPIO_DEBUG_LED
123                 sd      t1,0(t0)
125                 li      t0,PHYS_TO_K1(A_GPIO_PIN_CLR)
126                 li      t1,M_GPIO_STURGEON_NMI
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)
151                 j       ra
153 END(board_earlyinit)
156 /*  *********************************************************************
157     *  BOARD_DRAMINFO
158     *  
159     *  Return the address of the DRAM information table.  Note that
160     *  the address must be obtained in a position-independent way,
161     *  so avoid the use of the "la" instruction.
162     *  
163     *  Input parameters: 
164     *      nothing
165     *      
166     *  Return value:
167     *      v0 - DRAM info table, return 0 to use default table
168     ********************************************************************* */
170 LEAF(board_draminfo)
172                 move    v0,zero
173                 j       ra
175 END(board_draminfo)
179 /*  *********************************************************************
180     *  BOARD_SETLEDS(x)
181     *  
182     *  Set LEDs for boot-time progress indication.  Not used if
183     *  the board does not have progress LEDs.  This routine
184     *  must not call any other routines, since it may be invoked
185     *  either from KSEG0 or KSEG1 and it may be invoked 
186     *  whether or not the icache is operational.
187     *  
188     *  Input parameters: 
189     *      a0 - LED value (8 bits per character, 4 characters)
190     *      
191     *  Return value:
192     *      nothing
193     *  
194     *  Registers used:
195     *      t0,t1,t2,t3
196     ********************************************************************* */
199 #define LED_CHAR0       (32+8*3)
200 #define LED_CHAR1       (32+8*2)
201 #define LED_CHAR2       (32+8*1)
202 #define LED_CHAR3       (32+8*0)
204 LEAF(board_setleds)
206                 li      t0,PHYS_TO_K1(LEDS_PHYS)
208                 rol     a0,a0,8
209                 and     t1,a0,0xFF
210                 sb      t1,LED_CHAR0(t0)
212                 rol     a0,a0,8
213                 and     t1,a0,0xFF
214                 sb      t1,LED_CHAR1(t0)
216                 rol     a0,a0,8
217                 and     t1,a0,0xFF
218                 sb      t1,LED_CHAR2(t0)
220                 rol     a0,a0,8
221                 and     t1,a0,0xFF
222                 sb      t1,LED_CHAR3(t0)
224                 j       ra
226 END(board_setleds)