GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / arch / mips / board / c3 / src / c3_init.S
blobaa03575c3f514e4e6bbb5fd5f24d36e08a1c3153
1 /*  *********************************************************************
2     *  SB1250 Board Support Package
3     *  
4     *  Board-specific initialization            File: C3_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_uart.h"
53 #include "sb1250_regs.h"
54 #include "bsp_config.h"
55 #include "c3.h"
56 #include "mipsmacros.h"
57 #include "sb1250_draminit.h"
59                 .text
61 /*#define _SERIAL_PORT_LEDS_*/
63 /*  *********************************************************************
64     *  Macros
65     ********************************************************************* */
68 /*  *********************************************************************
69     *  BOARD_EARLYINIT()
70     *  
71     *  Initialize board registers.  This is the earliest 
72     *  time the BSP gets control.  This routine cannot assume that
73     *  memory is operational, and therefore all code in this routine
74     *  must run from registers only.  The $ra register must not
75     *  be modified, as it contains the return address.
76     *
77     *  This routine will be called from uncached space, before
78     *  the caches are initialized.  If you want to make
79     *  subroutine calls from here, you must use the CALLKSEG1 macro.
80     *
81     *  Among other things, this is where the GPIO registers get 
82     *  programmed to make on-board LEDs function, or other startup
83     *  that has to be done before anything will work.
84     *  
85     *  Input parameters: 
86     *      nothing
87     *      
88     *  Return value:
89     *      nothing
90     ********************************************************************* */
92 LEAF(board_earlyinit)
94        #
95        # Configure the GPIOs
96        #
98                 li      t0,PHYS_TO_K1(A_GPIO_INT_TYPE)
99                 li      t1,GPIO_INTERRUPT_MASK
100                 sd      t1,0(t0)
102        #
103        # Turn off the diagnostic LED.
104        #
105                 li      t0,PHYS_TO_K1(A_GPIO_PIN_CLR)
106                 li      t1,M_GPIO_DEBUG_LED
107                 sd      t1,0(t0)
109       #
110       # Set the PGM_L pin to '1' to allow programming via JTAG
111       #
113                 li      t0,PHYS_TO_K1(A_GPIO_PIN_SET)
114                 li      t1,M_GPIO_XPROG_X_PGM_L
115                 sd      t1,0(t0)
117       #
118       # Set direction pin
119       #
122                 li      t0,PHYS_TO_K1(A_GPIO_DIRECTION)
123                 li      t1,GPIO_OUTPUT_MASK
124                 sd      t1,0(t0)
128        #
129        # Configure the alternate boot ROM
130        #     
132                 li      t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(ALT_BOOTROM_CS))
134                 li      t1,ALT_BOOTROM_PHYS >> S_IO_ADDRBASE
135                 sd      t1,R_IO_EXT_START_ADDR(t0)
137                 li      t1,ALT_BOOTROM_SIZE-1
138                 sd      t1,R_IO_EXT_MULT_SIZE(t0)
140                 li      t1,ALT_BOOTROM_TIMING0
141                 sd      t1,R_IO_EXT_TIME_CFG0(t0)
143                 li      t1,ALT_BOOTROM_TIMING1
144                 sd      t1,R_IO_EXT_TIME_CFG1(t0)
146                 li      t1,ALT_BOOTROM_CONFIG
147                 sd      t1,R_IO_EXT_CFG(t0)
149        #
150        # Configure the Xilinx
151        #     
153                 li      t0,PHYS_TO_K1(A_IO_EXT_CS_BASE(XILINX_CS))
155                 li      t1,XILINX_PHYS >> S_IO_ADDRBASE
156                 sd      t1,R_IO_EXT_START_ADDR(t0)
158                 li      t1,XILINX_SIZE-1
159                 sd      t1,R_IO_EXT_MULT_SIZE(t0)
161                 li      t1,XILINX_TIMING0
162                 sd      t1,R_IO_EXT_TIME_CFG0(t0)
164                 li      t1,XILINX_TIMING1
165                 sd      t1,R_IO_EXT_TIME_CFG1(t0)
167                 li      t1,XILINX_CONFIG
168                 sd      t1,R_IO_EXT_CFG(t0)
170         #
171         # Make sure that the mailbox register is cleared
172         #
174                 li      t0,PHYS_TO_K1(A_IMR_REGISTER(0,R_IMR_MAILBOX_CLR_CPU))
175                 nor     t1, zero, zero
176                 sd      t1,(t0)
177         
178 #ifdef _SERIAL_PORT_LEDS_
180         # Program the mode register for 8 bits/char, no parity
182                 li      t0,PHYS_TO_K1(A_DUART_MODE_REG_1_A)     
183                 li      t1,V_DUART_BITS_PER_CHAR_8 | V_DUART_PARITY_MODE_NONE
184                 sd      t1,(t0)
186         # Program the mode register for 1 stop bit, ignore CTS
188                 li      t0,PHYS_TO_K1(A_DUART_MODE_REG_2_A)     
189                 li      t1,M_DUART_STOP_BIT_LEN_1
190                 sd      t1,(t0)
192         # Program the baud rate to 115200
194                 li      t0,PHYS_TO_K1(A_DUART_CLK_SEL_A)
195                 li      t1,V_DUART_BAUD_RATE(115200)
196                 sd      t1,(t0)
198         # Dont use any interrupts
200                 li      t0,PHYS_TO_K1(A_DUART_IMR)
201                 ld      t1,(t0)
202                 and     t1,~M_DUART_IMR_ALL_A
203                 sd      t1,(t0)
205         # Enable sending and receiving
207                 li      t0,PHYS_TO_K1(A_DUART_CMD_A)
208                 li      t1,M_DUART_RX_EN | M_DUART_TX_EN
209                 sd      t1,(t0)
211 #endif
214                 j       ra
216 END(board_earlyinit)
219 /*  *********************************************************************
220     *  BOARD_DRAMINFO
221     *  
222     *  Return the address of the DRAM information table
223     *  
224     *  Input parameters: 
225     *      nothing
226     *      
227     *  Return value:
228     *      v0 - DRAM info table, return 0 to use default table
229     ********************************************************************* */
232 LEAF(board_draminfo)
234         #
235         # This board has soldered-down memory.
236         #
238                 move    t0,ra
240                 LOADREL(v0,dramtab)
242                 move    ra,t0
243                 j       ra
245 dramtab:
247 #if defined(_C3_) || defined(_C3H_) || defined(_SIM_C3_)
249         /*
250          * C3: SGRAMs and SDRAMs 
251          *
252          * This board has soldered-down memory.
253          */
255         DRAM_GLOBALS(MC_NOPORTINTLV)            /* no port interleaving */
256         
257         /* 
258          * 16MB on MC 0 (SGRAM) 
259          * Micron MT46V2M32LG-65
260          *
261          * Minimum tMEMCLK: 8.0ns (125Mhz max freq)
262          *
263          * CS0 Geometry: 11 rows, 8 columns, 2 bankbits
264          *
265          * 128khz refresh, CAS Latency 3.0
266          * Timing (ns):   tCK=7.50 tRAS=40 tRP=19.50 tRRD=13.0 tRCD=19.50 tRFC=66 tRC=59
267          *
268          * Clock Config: Addrskew 0x0F, DQOskew 0x08, DQIskew 0x08, addrdrive 0x07, datadrive 0x07, clockdrive 0x00
269          */
272         DRAM_CHAN_CFG(MC_CHAN0, DRT10(8,0), SGRAM, CASCHECK, BLKSIZE32, NOCSINTLV, CFG_DRAM_ECC, 0)
273         DRAM_CHAN_CLKCFG(0x0F, 0x08, 0x08, 0x07, 0x07, 0x00)
275         DRAM_CS_GEOM(MC_CS0, 11, 8, 2)
276         DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_128khz, JEDEC_CASLAT_30, 0,  40,  DRT4(19,50) ,DRT4(13,0),  DRT4(19,50),  66 , 59)
278         /* 
279          * 512MB on MC 1 (JEDEC SDRAM)
280          * <<mfr name>>
281          *
282          * Minimum tMEMCLK: 8.0ns (125Mhz max freq)
283          *
284          * CS0 Geometry : 13 rows, 10 columns, 2 bankbits
285          * CS1 Geometry : 13 rows, 10 columns, 2 bankbits
286          *
287          * 64khz refresh, CAS Latency 2.5
288          * Timing (ns):   tCK=7.50 tRAS=45 tRP=20.0 tRRD=15.0 tRCD=20.0 tRFC=auto tRC=auto
289          *
290          * Clock Config: Default
291          */
294         DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), JEDEC, CASCHECK, BLKSIZE32, NOCSINTLV, CFG_DRAM_ECC, 0)
295         DRAM_CHAN_CLKCFG(0x0F, 0x08, 0x08, 0x0F, 0x0F, 0x00)
297         DRAM_CS_GEOM(MC_CS0, 13, 10, 2)
298         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)
300         DRAM_CS_GEOM(MC_CS1, 13, 10, 2)
301         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)
303         DRAM_EOT;
306 #elif defined(_C3F_)
308         /* 
309          * C3F: SGRAMs and FCRAMs 
310          *
311          * This board has soldered-down memory.
312          */
314         DRAM_GLOBALS(MC_NOPORTINTLV)                    /* interleave not supported */
316         /* 
317          * 16MB on MC 0 (SGRAM) 
318          * Micron MT46V2M32LG-65
319          *
320          * Minimum tMEMCLK: 8.0ns (125Mhz max freq)
321          *
322          * CS0 Geometry: 11 rows, 8 columns, 2 bankbits
323          *
324          * 128khz refresh, CAS Latency 3.0
325          * Timing (ns):   tCK=7.50 tRAS=40 tRP=19.50 tRRD=13.0 tRCD=19.50 tRFC=66 tRC=59
326          *
327          * Clock Config: Addrskew 0x0F, DQOskew 0x08, DQIskew 0x08, addrdrive 0x07, datadrive 0x07, clockdrive 0x00
328          */
330         DRAM_CHAN_CFG(MC_CHAN0, DRT10(8,0), SGRAM, CASCHECK, BLKSIZE32, NOCSINTLV, CFG_DRAM_ECC, 0)
331         DRAM_CHAN_CLKCFG(0x0F, 0x08, 0x08, 0x07, 0x07, 0x00)
333         DRAM_CS_GEOM(MC_CS0, 11, 8, 2)
334         DRAM_CS_TIMING(DRT10(7,5), JEDEC_RFSH_128khz, JEDEC_CASLAT_30, 0,  40,  DRT4(19,50) ,DRT4(13,0),  DRT4(19,50),  66 , 59)
336         /* 
337          * 256MB on MC 1 (FCRAM) 
338          * Toshiba TC59LM806BFT-22
339          *
340          * Minimum tMEMCLK: 8.0ns (125Mhz max freq)
341          *
342          * CS0 Geometry : 15 rows, 8 columns, 2 bankbits
343          *
344          * 128khz refresh, CAS Latency 3.0
345          * Timing (ns):   tCK=6.50 tRAS=26 tRP=6.50 tRRD=13.0 tRCD=6.50 tRFC=97 tRC=auto
346          *
347          * Clock Config: Addrskew 0x08, DQOskew 0x08, DQIskew 0x08, addrdrive 0x07, datadrive 0x07, clockdrive 0x07
348          */
350         DRAM_CHAN_CFG(MC_CHAN1, DRT10(8,0), FCRAM, CLOSED, BLKSIZE32, NOCSINTLV, CFG_DRAM_ECC, 0)
351         DRAM_CHAN_CLKCFG(0x08,0x08,0x08,0x07,0x07,0x07)
353         DRAM_CS_GEOM(MC_CS0, 15, 8, 2)
354         DRAM_CS_TIMING(DRT10(6,5), JEDEC_RFSH_128khz, JEDEC_CASLAT_30, 0,  26,  DRT4(6,50) ,DRT4(13,0),  DRT4(6,50),  97 , 0)
356         DRAM_EOT;
357 #else
358 #error "Board type not defined"
359 #endif
362 END(board_draminfo)
366 /*  *********************************************************************
367     *  BOARD_UARTA_TXCHAR
368     *  
369     *  Transmit a single character via UART A
370     *  
371     *  Input parameters: 
372     *      a0 - character to transmit (low-order 8 bits)
373     *      
374     *  Return value:
375     *      nothing
376     *      
377     *  Registers used:
378     *      t0,t1
379     ********************************************************************* */
381 #ifdef _SERIAL_PORT_LEDS_
382 LEAF(board_uarta_txchar)
384         # Wait until there is space in the transmit buffer
386 1:              li      t0,PHYS_TO_K1(A_DUART_STATUS_A)
387                 ld      t1,(t0)                 # Get status bits
388                 and     t1,M_DUART_TX_RDY       # test for ready
389                 beq     t1,0,1b                 # keep going till ready
391         # Okay, now send the character.
393                 li      t0,PHYS_TO_K1(A_DUART_TX_HOLD_A)
394                 sd      a0,(t0)
396         # done!
398                 j       ra
400 END(board_uarta_txchar)
401 #endif
403 /*  *********************************************************************
404     *  BOARD_SETLEDS(x)
405     *  
406     *  Set LEDs for boot-time progress indication.  Not used if
407     *  the board does not have progress LEDs.  This routine
408     *  must not call any other routines, since it may be invoked
409     *  either from KSEG0 or KSEG1 and it may be invoked 
410     *  whether or not the icache is operational.
411     *  
412     *  Input parameters: 
413     *      a0 - LED value (8 bits per character, 4 characters)
414     *      
415     *  Return value:
416     *      nothing
417     *  
418     *  Registers used:
419     *      t0,t1,t2,t3
420     ********************************************************************* */
423 LEAF(board_setleds)
425 #ifdef _SERIAL_PORT_LEDS_
426                 move    t3,ra
427                 move    t2,a0
429                 li      a0,'['
430                 bal     board_uarta_txchar
432                 move    a0,t2
433                 rol     a0,8
434                 bal     board_uarta_txchar
435                 rol     a0,8
436                 bal     board_uarta_txchar
437                 rol     a0,8
438                 bal     board_uarta_txchar
439                 rol     a0,8
440                 bal     board_uarta_txchar
442                 li      a0,']'
443                 bal     board_uarta_txchar
445                 move    ra,t3
447 #endif
449                 j       ra
451 END(board_setleds)