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_devs.c
blobd4f58143be036f8c2a703da100885b2278c18505
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Board device initialization File: c3_devs.c
5 *
6 * This is the "C" part of the board support package. The
7 * routines to create and initialize the console, wire up
8 * device drivers, and do other customization live here.
9 *
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 ********************************************************************* */
50 #include "sbmips.h"
51 #include "lib_types.h"
52 #include "lib_queue.h"
53 #include "lib_printf.h"
54 #include "cfe_iocb.h"
55 #include "cfe_device.h"
56 #include "cfe_timer.h"
57 #include "env_subr.h"
58 #include "cfe.h"
60 #include "sb1250_defs.h"
61 #include "sb1250_regs.h"
62 #include "sb1250_pci.h"
63 #include "sb1250_ldt.h"
64 #include "sb1250_scd.h"
65 #include "dev_ide.h"
66 #include "dev_newflash.h"
68 #include "bsp_config.h"
70 #include "c3.h"
72 /* *********************************************************************
73 * Devices we're importing
74 ********************************************************************* */
76 extern cfe_driver_t promice_uart; /* promice serial port */
77 extern cfe_driver_t sb1250_uart; /* SB1250 serial ports */
78 extern cfe_driver_t sb1250_x1240eeprom; /* Xicor SMBus NVRAM */
79 extern cfe_driver_t newflashdrv; /* AMD-style flash */
80 extern cfe_driver_t jtagconsole; /* SB1250 JTAG unit */
82 #ifdef _C3H_
83 #if CFG_PCI
84 extern cfe_driver_t pciidedrv; /* PCI IDE controller */
85 extern cfe_driver_t dc21143drv; /* Tulip Ethernet */
86 #if CFG_DOWNLOAD
87 extern cfe_driver_t bcm1250drv; /* BCM1250 as a device */
88 #endif
89 #endif
90 #else
91 extern cfe_driver_t sb1250_pcihost; /* driver for host downloads */
92 #endif /* _C3H_ */
95 extern void ui_init_cpu1cmds(void);
96 extern int ui_init_corecmds(void);
97 extern int ui_init_soccmds(void);
98 extern int ui_init_testcmds(void);
99 extern int ui_init_resetcmds(void);
100 extern int ui_init_tempsensorcmds(void);
101 extern int ui_init_toyclockcmds(void);
102 extern int ui_init_memtestcmds(void);
104 extern int ui_init_c3_testcmds(void);
106 /* *********************************************************************
107 * Some board-specific parameters
108 ********************************************************************* */
111 * Note! Configure the PROMICE for burst mode zero (one byte per
112 * access).
115 #define PROMICE_BASE (0x1FDFFC00)
116 #define PROMICE_WORDSIZE 1
118 #define X1240_SMBUS_CHANNEL 1
119 #define X1240_SMBUS_DEVICE 0x57
121 /* *********************************************************************
122 * board_console_init()
124 * Add the console device and set it to be the primary
125 * console.
127 * Input parameters:
128 * nothing
130 * Return value:
131 * nothing
132 ********************************************************************* */
134 void board_console_init(void)
136 uint64_t syscfg;
137 int plldiv;
139 syscfg = SBREADCSR(A_SCD_SYSTEM_CFG);
141 /* Console */
142 cfe_add_device(&promice_uart,PROMICE_BASE,PROMICE_WORDSIZE,0);
143 cfe_add_device(&sb1250_uart,A_DUART,0,0);
145 #if CFG_PCI
146 cfe_startflags = CFE_INIT_PCI;
147 #else
148 cfe_startflags = 0;
149 #endif
151 #ifdef _C3_DIAG_CFG_
152 cfe_set_console("promice0");
153 #else
154 cfe_set_console("uart0");
155 #endif
157 /* CPU Speed : read from PLL field of SYSCFG register */
158 plldiv = G_SYS_PLL_DIV(syscfg);
159 if (plldiv == 0) {
160 plldiv = 6;
162 #ifdef _FUNCSIM_
163 cfe_cpu_speed = 500000; /* wire func sim at 500KHz */
164 #else
165 cfe_cpu_speed = 50000000 * plldiv;
166 #endif
171 /* *********************************************************************
172 * board_device_init()
174 * Initialize and add other devices. Add everything you need
175 * for bootstrap here, like disk drives, flash memory, UARTs,
176 * network controllers, etc.
178 * Input parameters:
179 * nothing
181 * Return value:
182 * nothing
183 ********************************************************************* */
185 void board_device_init(void)
187 uint64_t syscfg;
189 /* Boot ROM */
190 #ifndef _C3_DIAG_CFG_
191 cfe_add_device(&newflashdrv,
192 BOOTROM_PHYS,
193 (BOOTROM_SIZE*K64) | FLASH_FLG_BUS8 | FLASH_FLG_DEV16,
194 NULL);
195 cfe_add_device(&newflashdrv,
196 ALT_BOOTROM_PHYS,
197 (ALT_BOOTROM_SIZE*K64) | FLASH_FLG_BUS8 | FLASH_FLG_DEV16,
198 NULL);
199 #endif
201 #ifdef _C3H_ /* Host Mode */
202 #if CFG_PCI
204 * Add some sample PCI devices
206 cfe_add_device(&pciidedrv,0,IDE_PROBE_MASTER_TYPE(IDE_DEVTYPE_DISK),NULL);
207 cfe_add_device(&dc21143drv,0,0,env_getenv("TULIP0_HWADDR"));
209 #if CFG_DOWNLOAD
210 /* Access to bcm1250 in PCI device mode */
211 cfe_add_device(&bcm1250drv,0,0,NULL);
212 #endif
213 #endif
214 #else /* Device Mode */
216 * Host download interface.
218 cfe_add_device(&sb1250_pcihost,0,0,NULL);
219 #endif /* _C3H_ */
221 syscfg = SBREADCSR(A_SCD_SYSTEM_CFG);
222 printf("SysCfg: %016llX [PLL_DIV: %d, IOB0_DIV: %s, IOB1_DIV: %s]\n",
223 syscfg,
224 (int)G_SYS_PLL_DIV(syscfg),
225 (syscfg & M_SYS_IOB0_DIV) ? "CPUCLK/3" : "CPUCLK/4",
226 (syscfg & M_SYS_IOB1_DIV) ? "CPUCLK/2" : "CPUCLK/3");
227 if (G_SYS_PLL_DIV(syscfg) == 0) {
228 printf("PLL_DIV of zero found, assuming 6 (300MHz)\n");
233 /* *********************************************************************
234 * board_device_reset()
236 * Reset devices. This call is done when the firmware is restarted,
237 * as might happen when an operating system exits, just before the
238 * "reset" command is applied to the installed devices. You can
239 * do whatever board-specific things are here to keep the system
240 * stable, like stopping DMA sources, interrupts, etc.
242 * Input parameters:
243 * nothing
245 * Return value:
246 * nothing
247 ********************************************************************* */
249 void board_device_reset(void)
256 /* *********************************************************************
257 * board_final_init()
259 * Do any final initialization, such as adding commands to the
260 * user interface.
262 * If you don't want a user interface, put the startup code here.
263 * This routine is called just before CFE starts its user interface.
265 * Input parameters:
266 * nothing
268 * Return value:
269 * nothing
270 ********************************************************************* */
272 void board_final_init(void)
274 ui_init_corecmds();
275 ui_init_soccmds();
276 ui_init_testcmds();
277 ui_init_resetcmds();
278 ui_init_tempsensorcmds();
279 ui_init_toyclockcmds();
280 ui_init_memtestcmds();
282 #ifndef _C3H_
283 ui_init_c3_testcmds();
285 extern int cfe_device_download(int boot, char *options);
286 /* cfe_device_download(1, ""); */
288 #endif