1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * Board device initialization File: cswarm_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 "sb1250_defs.h"
62 #include "sb1250_regs.h"
63 #include "sb1250_pci.h"
64 #include "sb1250_ldt.h"
65 #include "sb1250_scd.h"
66 #include "sb1250_wid.h"
68 #include "bsp_config.h"
72 #include "dev_newflash.h"
75 * This lets us override the WID by poking values into our PromICE
78 #undef A_SCD_SYSTEM_REVISION
79 #define A_SCD_SYSTEM_REVISION 0x1FC00010
80 #define SB1250_REFCLK (*((uint64_t *) 0xBFC00018))
84 /* *********************************************************************
85 * Devices we're importing
86 ********************************************************************* */
88 extern cfe_driver_t promice_uart
; /* promice serial port */
89 extern cfe_driver_t sb1250_uart
; /* SB1250 serial ports */
90 extern cfe_driver_t sb1250_ether
; /* SB1250 MACs */
91 extern cfe_driver_t sb1250_x1240eeprom
; /* Xicor SMBus NVRAM */
92 extern cfe_driver_t sb1250_24lc128eeprom
; /* Microchip EEPROM */
93 extern cfe_driver_t newflashdrv
; /* AMD-style flash */
94 extern cfe_driver_t idedrv
; /* IDE disk */
95 extern cfe_driver_t pcmciadrv
; /* PCMCIA card */
97 extern cfe_driver_t pciidedrv
; /* PCI IDE controller */
98 extern cfe_driver_t dc21143drv
; /* Tulip Ethernet */
101 extern void ui_init_cpu1cmds(void);
102 extern void ui_init_swarmcmds(void);
103 extern int ui_init_corecmds(void);
104 extern int ui_init_soccmds(void);
105 extern int ui_init_testcmds(void);
106 extern int ui_init_resetcmds(void);
107 extern int ui_init_phycmds(void);
108 extern int ui_init_tempsensorcmds(void);
109 extern int ui_init_memtestcmds(void);
110 extern int ui_init_toyclockcmds(void);
113 extern int vga_biosinit(void);
116 extern void sb1250_show_cpu_type(void);
118 /* *********************************************************************
119 * Some board-specific parameters
120 ********************************************************************* */
123 * Note! Configure the PROMICE for burst mode zero (one byte per
127 #define PROMICE_BASE (0x1FDFFC00)
128 #define PROMICE_WORDSIZE 1
130 #define REAL_BOOTROM_SIZE (2*1024*1024) /* region is 4MB, but rom is 2MB */
132 /* *********************************************************************
133 * SysConfig switch settings
134 ********************************************************************* */
136 #define CSWARM_PROMICE_CONSOLE 0x00000001
138 const unsigned int cswarm_startflags
[8] = {
139 0, /* 0 : UART console, no PCI */
140 CSWARM_PROMICE_CONSOLE
, /* 1 : PromICE console, no PCI */
141 CFE_INIT_PCI
, /* 2 : UART console, PCI */
142 CFE_INIT_PCI
| CSWARM_PROMICE_CONSOLE
, /* 3 : PromICE console, PCI */
145 CFE_INIT_PCI
| CFE_LDT_SLAVE
, /* 6 : 2, plus LDT slave mode */
146 CFE_INIT_SAFE
/* 7 : UART console, no pci, safe mode */
149 static unsigned int cpu_pass
;
150 static unsigned int cpu_revision
;
154 /* *********************************************************************
155 * board_console_init()
157 * Add the console device and set it to be the primary
165 ********************************************************************* */
167 void board_console_init(void)
172 syscfg
= SBREADCSR(A_SCD_SYSTEM_CFG
);
174 cpu_revision
= (unsigned int) (SBREADCSR(A_SCD_SYSTEM_REVISION
) &
175 (M_SYS_PART
| M_SYS_REVISION
));
176 cpu_pass
= G_SYS_REVISION(cpu_revision
);
179 #if defined(_CSWARM_DIAG_CFG_) || defined(_CSWARM_DIAG3E_CFG_)
180 cfe_add_device(&promice_uart
,PROMICE_BASE
,PROMICE_WORDSIZE
,0);
181 cfe_set_console("promice0");
183 cfe_add_device(&sb1250_uart
,A_DUART
,0,0);
184 cfe_add_device(&promice_uart
,PROMICE_BASE
,PROMICE_WORDSIZE
,0);
187 * Read the config switch and decide how we are going to
188 * set up the console. The config switch sets
189 * bits 3..5 of the SYS_CONFIG field of the syscfg register.
192 cfe_startflags
= cswarm_startflags
[(G_SYS_CONFIG(syscfg
)/8) & 0x07];
194 if (cfe_startflags
& CSWARM_PROMICE_CONSOLE
) {
195 cfe_set_console("promice0");
198 cfe_set_console("uart0");
203 * Set variable that contains CPU speed, spit out config register
206 plldiv
= G_SYS_PLL_DIV(syscfg
);
212 cfe_cpu_speed
= 500000; /* wire func sim at 500KHz */
214 cfe_cpu_speed
= 50000000 * plldiv
; /* use PLL divisor */
222 * NVRAM (environment variables
224 cfe_add_device(&sb1250_x1240eeprom
,X1240_SMBUS_CHAN
,X1240_SMBUS_DEV
,0);
225 cfe_set_envdevice("eeprom0"); /* Connect NVRAM subsystem to EEPROM */
231 /* *********************************************************************
232 * board_device_init()
234 * Initialize and add other devices. Add everything you need
235 * for bootstrap here, like disk drives, flash memory, UARTs,
236 * network controllers, etc.
243 ********************************************************************* */
245 void board_device_init(void)
252 #if !defined(_CSWARM_DIAG_CFG_)
253 cfe_add_device(&newflashdrv
,
255 (BOOTROM_SIZE
*K64
) | FLASH_FLG_BUS8
| FLASH_FLG_DEV16
,
257 cfe_add_device(&newflashdrv
,
259 (ALT_BOOTROM_SIZE
*K64
) | FLASH_FLG_BUS8
| FLASH_FLG_DEV16
,
263 cfe_add_device(&sb1250_24lc128eeprom
,BIGEEPROM_SMBUS_CHAN
,BIGEEPROM_SMBUS_DEV
,0);
266 * MACs - must init after environment, since the hw address is stored there
268 cfe_add_device(&sb1250_ether
,A_MAC_BASE_0
,0,env_getenv("ETH0_HWADDR"));
269 #ifndef _CSWARM_DIAG_CFG_
270 cfe_add_device(&sb1250_ether
,A_MAC_BASE_1
,1,env_getenv("ETH1_HWADDR"));
271 cfe_add_device(&sb1250_ether
,A_MAC_BASE_2
,2,env_getenv("ETH2_HWADDR"));
275 * IDE disks and PCMCIA
277 #if !defined(_CSWARM_DIAG_CFG_) && !defined(_CSWARM_DIAG3E_CFG_)
279 * Uncomment to enable IDE disks
281 * cfe_add_device(&idedrv,IDE_PHYS+(0x1F0<<5),
282 * IDE_PROBE_MASTER_TYPE(IDE_DEVTYPE_DISK) |
283 * IDE_PROBE_SLAVE_TYPE(IDE_DEVTYPE_NOPROBE),
288 * Uncomment to enable PCMCIA support
290 * cfe_add_device(&pcmciadrv,PCMCIA_PHYS,0,NULL);
296 * Add some sample PCI devices
298 if (cfe_startflags
& CFE_INIT_PCI
) {
299 cfe_add_device(&pciidedrv
,0,IDE_PROBE_MASTER_TYPE(IDE_DEVTYPE_DISK
),NULL
);
300 cfe_add_device(&dc21143drv
,0,0,env_getenv("TULIP0_HWADDR"));
305 * Set variable that contains CPU speed, spit out config register
308 syscfg
= SBREADCSR(A_SCD_SYSTEM_CFG
);
309 printf("Config switch: %d\n",G_SYS_CONFIG(syscfg
));
312 printf("Reference Clock: %dMhz\n",(uint32_t)SB1250_REFCLK
);
315 sb1250_show_cpu_type();
320 /* *********************************************************************
321 * board_device_reset()
323 * Reset devices. This call is done when the firmware is restarted,
324 * as might happen when an operating system exits, just before the
325 * "reset" command is applied to the installed devices. You can
326 * do whatever board-specific things are here to keep the system
327 * stable, like stopping DMA sources, interrupts, etc.
334 ********************************************************************* */
336 void board_device_reset(void)
342 /* *********************************************************************
345 * Do any final initialization, such as adding commands to the
348 * If you don't want a user interface, put the startup code here.
349 * This routine is called just before CFE starts its user interface.
356 ********************************************************************* */
358 void board_final_init(void)
366 ui_init_tempsensorcmds();
367 ui_init_memtestcmds();
368 ui_init_toyclockcmds();