GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / arch / mips / board / bigsur / src / bigsur_devs.c
blob80115c6978c5ce8692f29fc937f446f67bb82f5f
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Board device initialization File: bigsur_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 ********************************************************************* */
51 #include "sbmips.h"
52 #include "lib_types.h"
53 #include "lib_queue.h"
54 #include "lib_printf.h"
55 #include "cfe_iocb.h"
56 #include "cfe_device.h"
57 #include "cfe_timer.h"
58 #include "env_subr.h"
59 #include "cfe.h"
61 #include "bcm1400_defs.h"
62 #include "bcm1400_regs.h"
63 #include "bcm1400_scd.h"
64 #ifdef NYI
65 #include "sb1250_smbus.h"
66 #endif
68 #include "bsp_config.h"
70 #include "bigsur.h"
72 #include "dev_newflash.h"
74 /* *********************************************************************
75 * Devices we're importing
76 ********************************************************************* */
78 extern cfe_driver_t promice_uart; /* promice serial port */
79 extern cfe_driver_t bcm1400_uart; /* BCM1400 serial ports */
80 extern cfe_driver_t sb1250_ether; /* SB1250 MAC */
81 extern cfe_driver_t newflashdrv; /* AMD-style flash */
82 #ifdef NYI
83 extern cfe_driver_t sb1250_24lc128eeprom; /* Microchip EEPROM */
84 extern cfe_driver_t m41t81_clock; /* M41T81 SMBus RTC */
85 #endif
87 #if CFG_PCI
88 extern void pci_add_devices(int init);
89 #endif
91 /* *********************************************************************
92 * Commands we're importing
93 ********************************************************************* */
95 extern void ui_init_cpu1cmds(void);
96 extern void ui_init_swarmcmds(void);
97 extern int ui_init_corecmds(void);
98 extern int ui_init_soccmds(void);
99 extern int ui_init_testcmds(void);
100 extern int ui_init_resetcmds(void);
101 extern int ui_init_phycmds(void);
102 extern int ui_init_tempsensorcmds(void);
103 extern int ui_init_toyclockcmds(void);
104 extern int ui_init_memtestcmds(void);
105 extern int ui_init_ethertestcmds(void);
106 extern int ui_init_flashtestcmds(void);
107 extern int ui_init_testcmds2(void);
108 extern int ui_init_tracecmds(void);
110 /* *********************************************************************
111 * Some other stuff we use
112 ********************************************************************* */
114 extern void sb1250_show_cpu_type(void);
115 extern int cfe_device_download(int boot, char *options);
117 /* *********************************************************************
118 * Some board-specific parameters
119 ********************************************************************* */
122 * Note! Configure the PROMICE for burst mode zero (one byte per
123 * access).
126 #define PROMICE_BASE (0x1FDFFC00)
127 #define PROMICE_WORDSIZE 1
129 #define REAL_BOOTROM_SIZE (2*1024*1024) /* region is 4MB, but rom is 2MB */
131 /* *********************************************************************
132 * SysConfig switch settings and related parameters
133 ********************************************************************* */
135 int bigsur_board_rev;
136 int bigsur_config_switch;
138 #define SWARM_PROMICE_CONSOLE 0x00000001
139 #define DEVICE_DOWNLOAD 0x00000002
140 #define DEVICE_EXECUTE 0x00000004
141 #define DEVICE_REBOOT (DEVICE_DOWNLOAD|DEVICE_EXECUTE)
143 const unsigned int bigsur_startflags[16] = {
144 0, /* 0 : UART console, no PCI */
145 SWARM_PROMICE_CONSOLE, /* 1 : PromICE console, no PCI */
146 CFE_INIT_PCI, /* 2 : UART console, PCI */
147 CFE_INIT_PCI | SWARM_PROMICE_CONSOLE, /* 3 : PromICE console, PCI */
148 0, /* 4 : unused */
149 0, /* 5 : unused */
150 CFE_INIT_PCI | CFE_LDT_SLAVE, /* 6 : 2, plus LDT slave mode */
151 CFE_INIT_SAFE, /* 7 : UART console, no pci, safe mode */
152 CFE_INIT_PCI | DEVICE_DOWNLOAD, /* 8 : UART console, PCI, download */
153 CFE_INIT_PCI | DEVICE_REBOOT, /* 9 : UART console, PCI, reboot */
154 0, /* 10 : unused */
155 0, /* 11 : unused */
156 0, /* 12 : unused */
157 0, /* 13 : unused */
158 0, /* 14 : unused */
159 0, /* 15 : unused */
163 /* *********************************************************************
164 * board_console_init()
166 * Add the console device and set it to be the primary
167 * console.
169 * Input parameters:
170 * nothing
172 * Return value:
173 * nothing
174 ********************************************************************* */
176 void board_console_init(void)
178 uint64_t syscfg;
179 int plldiv;
181 syscfg = SBREADCSR(A_SCD_SYSTEM_CFG);
183 /* Console */
184 cfe_add_device(&bcm1400_uart,A_DUART(0),0,0);
185 cfe_add_device(&promice_uart,PROMICE_BASE,PROMICE_WORDSIZE,0);
188 * Read the config switch and decide how we are going to set up
189 * the console. This is actually board revision dependent.
191 * Note that the human-readable board revision is (bigsur_board_rev+1).
193 bigsur_board_rev = G_SYS_CONFIG(syscfg) & 0x3;
194 bigsur_config_switch = (G_SYS_CONFIG(syscfg) >> 2) & 0x0F;
196 cfe_startflags = bigsur_startflags[bigsur_config_switch];
198 if (cfe_startflags & SWARM_PROMICE_CONSOLE) {
199 cfe_set_console("promice0");
201 else {
202 cfe_set_console("uart0");
206 * Set variable that contains CPU speed, spit out config register
209 plldiv = G_SYS_PLL_DIV(syscfg);
210 if (plldiv == 0) {
211 plldiv = 6;
214 #ifdef _FUNCSIM_
215 cfe_cpu_speed = 500000; /* wire func sim at 500KHz */
216 #else
217 cfe_cpu_speed = 50000000 * plldiv; /* use PLL divisor */
218 #endif
220 #if !CFG_MINIMAL_SIZE
221 #ifdef NYI
223 * NVRAM (environment variables)
226 switch (bigsur_board_rev) {
227 case BIGSUR_REV_1:
228 default:
230 * Add the NVRAM device on SMBus 1 first. This will be our environment
233 cfe_add_device(&sb1250_24lc128eeprom,BIGEEPROM1_SMBUS_CHAN,BIGEEPROM1_SMBUS_DEV,0);
237 cfe_set_envdevice("eeprom0"); /* Connect NVRAM subsystem to EEPROM */
238 #endif
239 #endif /* CFG_MINIMAL_SIZE */
243 /* *********************************************************************
244 * board_device_init()
246 * Initialize and add other devices. Add everything you need
247 * for bootstrap here, like disk drives, flash memory, UARTs,
248 * network controllers, etc.
250 * Input parameters:
251 * nothing
253 * Return value:
254 * nothing
255 ********************************************************************* */
257 void board_device_init(void)
260 * Print out the board version number.
262 printf("%s board revision %d\n", CFG_BOARDNAME, bigsur_board_rev + 1);
264 #ifndef _FUNCSIM_
266 * Boot ROM, using "new" flash driver
269 cfe_add_device(&newflashdrv,
270 BOOTROM_PHYS,
271 REAL_BOOTROM_SIZE | FLASH_FLG_BUS8 | FLASH_FLG_DEV16,
272 NULL);
273 cfe_add_device(&newflashdrv,
274 ALT_BOOTROM_PHYS,
275 REAL_BOOTROM_SIZE | FLASH_FLG_BUS8 | FLASH_FLG_DEV16,
276 NULL);
277 #endif /*_FUNCSIM_*/
279 #if !CFG_MINIMAL_SIZE
281 * MAC - must init after environment, since the hw address is stored there
283 cfe_add_device(&sb1250_ether,A_MAC_BASE_0,0,env_getenv("ETH0_HWADDR"));
285 #if CFG_PCI
286 pci_add_devices(cfe_startflags & CFE_INIT_PCI);
287 #endif
289 #ifdef NYI
291 * Real-time clock
294 switch (bigsur_board_rev) {
295 case BIGSUR_REV_1:
296 default:
297 /* Add ST Micro clock driver here */
298 cfe_add_device(&m41t81_clock,M41T81_SMBUS_CHAN,M41T81_SMBUS_DEV,0);
300 #endif
301 #endif
304 * Set variable that contains CPU speed, spit out config register
307 printf("Config switch: %d\n", bigsur_config_switch);
309 #ifdef NYI
310 sb1250_show_cpu_type();
311 #endif
316 /* *********************************************************************
317 * board_device_reset()
319 * Reset devices. This call is done when the firmware is restarted,
320 * as might happen when an operating system exits, just before the
321 * "reset" command is applied to the installed devices. You can
322 * do whatever board-specific things are here to keep the system
323 * stable, like stopping DMA sources, interrupts, etc.
325 * Input parameters:
326 * nothing
328 * Return value:
329 * nothing
330 ********************************************************************* */
332 void board_device_reset(void)
337 /* *********************************************************************
338 * board_final_init()
340 * Do any final initialization, such as adding commands to the
341 * user interface.
343 * If you don't want a user interface, put the startup code here.
344 * This routine is called just before CFE starts its user interface.
346 * Input parameters:
347 * nothing
349 * Return value:
350 * nothing
351 ********************************************************************* */
353 void board_final_init(void)
355 #if !CFG_MINIMAL_SIZE
356 ui_init_cpu1cmds();
357 ui_init_swarmcmds();
358 #ifdef NYI
359 ui_init_corecmds();
360 #endif
361 ui_init_soccmds();
362 #ifdef NYI
363 ui_init_testcmds();
364 ui_init_testcmds2();
365 #endif
366 ui_init_resetcmds();
367 #ifdef NYI
368 ui_init_tempsensorcmds();
369 ui_init_toyclockcmds();
370 ui_init_memtestcmds();
371 ui_init_tracecmds();
372 #endif
373 ui_init_phycmds();
374 ui_init_ethertestcmds();
375 ui_init_flashtestcmds();
377 #endif