1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * Board device initialization File: bigsur_devs.c
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.
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 ********************************************************************* */
52 #include "lib_types.h"
53 #include "lib_queue.h"
54 #include "lib_printf.h"
56 #include "cfe_device.h"
57 #include "cfe_timer.h"
61 #include "bcm1400_defs.h"
62 #include "bcm1400_regs.h"
63 #include "bcm1400_scd.h"
65 #include "sb1250_smbus.h"
68 #include "bsp_config.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 */
83 extern cfe_driver_t sb1250_24lc128eeprom
; /* Microchip EEPROM */
84 extern cfe_driver_t m41t81_clock
; /* M41T81 SMBus RTC */
88 extern void pci_add_devices(int init
);
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
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 */
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 */
163 /* *********************************************************************
164 * board_console_init()
166 * Add the console device and set it to be the primary
174 ********************************************************************* */
176 void board_console_init(void)
181 syscfg
= SBREADCSR(A_SCD_SYSTEM_CFG
);
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");
202 cfe_set_console("uart0");
206 * Set variable that contains CPU speed, spit out config register
209 plldiv
= G_SYS_PLL_DIV(syscfg
);
215 cfe_cpu_speed
= 500000; /* wire func sim at 500KHz */
217 cfe_cpu_speed
= 50000000 * plldiv
; /* use PLL divisor */
220 #if !CFG_MINIMAL_SIZE
223 * NVRAM (environment variables)
226 switch (bigsur_board_rev
) {
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 */
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.
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);
266 * Boot ROM, using "new" flash driver
269 cfe_add_device(&newflashdrv
,
271 REAL_BOOTROM_SIZE
| FLASH_FLG_BUS8
| FLASH_FLG_DEV16
,
273 cfe_add_device(&newflashdrv
,
275 REAL_BOOTROM_SIZE
| FLASH_FLG_BUS8
| FLASH_FLG_DEV16
,
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"));
286 pci_add_devices(cfe_startflags
& CFE_INIT_PCI
);
294 switch (bigsur_board_rev
) {
297 /* Add ST Micro clock driver here */
298 cfe_add_device(&m41t81_clock
,M41T81_SMBUS_CHAN
,M41T81_SMBUS_DEV
,0);
304 * Set variable that contains CPU speed, spit out config register
307 printf("Config switch: %d\n", bigsur_config_switch
);
310 sb1250_show_cpu_type();
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.
330 ********************************************************************* */
332 void board_device_reset(void)
337 /* *********************************************************************
340 * Do any final initialization, such as adding commands to the
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.
351 ********************************************************************* */
353 void board_final_init(void)
355 #if !CFG_MINIMAL_SIZE
368 ui_init_tempsensorcmds();
369 ui_init_toyclockcmds();
370 ui_init_memtestcmds();
374 ui_init_ethertestcmds();
375 ui_init_flashtestcmds();