1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * Board device initialization File: c3_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 ********************************************************************* */
51 #include "lib_types.h"
52 #include "lib_queue.h"
53 #include "lib_printf.h"
55 #include "cfe_device.h"
56 #include "cfe_timer.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"
66 #include "dev_newflash.h"
68 #include "bsp_config.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 */
84 extern cfe_driver_t pciidedrv
; /* PCI IDE controller */
85 extern cfe_driver_t dc21143drv
; /* Tulip Ethernet */
87 extern cfe_driver_t bcm1250drv
; /* BCM1250 as a device */
91 extern cfe_driver_t sb1250_pcihost
; /* driver for host downloads */
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
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
132 ********************************************************************* */
134 void board_console_init(void)
139 syscfg
= SBREADCSR(A_SCD_SYSTEM_CFG
);
142 cfe_add_device(&promice_uart
,PROMICE_BASE
,PROMICE_WORDSIZE
,0);
143 cfe_add_device(&sb1250_uart
,A_DUART
,0,0);
146 cfe_startflags
= CFE_INIT_PCI
;
152 cfe_set_console("promice0");
154 cfe_set_console("uart0");
157 /* CPU Speed : read from PLL field of SYSCFG register */
158 plldiv
= G_SYS_PLL_DIV(syscfg
);
163 cfe_cpu_speed
= 500000; /* wire func sim at 500KHz */
165 cfe_cpu_speed
= 50000000 * plldiv
;
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.
183 ********************************************************************* */
185 void board_device_init(void)
190 #ifndef _C3_DIAG_CFG_
191 cfe_add_device(&newflashdrv
,
193 (BOOTROM_SIZE
*K64
) | FLASH_FLG_BUS8
| FLASH_FLG_DEV16
,
195 cfe_add_device(&newflashdrv
,
197 (ALT_BOOTROM_SIZE
*K64
) | FLASH_FLG_BUS8
| FLASH_FLG_DEV16
,
201 #ifdef _C3H_ /* Host Mode */
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"));
210 /* Access to bcm1250 in PCI device mode */
211 cfe_add_device(&bcm1250drv
,0,0,NULL
);
214 #else /* Device Mode */
216 * Host download interface.
218 cfe_add_device(&sb1250_pcihost
,0,0,NULL
);
221 syscfg
= SBREADCSR(A_SCD_SYSTEM_CFG
);
222 printf("SysCfg: %016llX [PLL_DIV: %d, IOB0_DIV: %s, IOB1_DIV: %s]\n",
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.
247 ********************************************************************* */
249 void board_device_reset(void)
256 /* *********************************************************************
259 * Do any final initialization, such as adding commands to the
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.
270 ********************************************************************* */
272 void board_final_init(void)
278 ui_init_tempsensorcmds();
279 ui_init_toyclockcmds();
280 ui_init_memtestcmds();
283 ui_init_c3_testcmds();
285 extern int cfe_device_download(int boot
, char *options
);
286 /* cfe_device_download(1, ""); */