1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * Board device initialization File: littlesur_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"
55 #include "lib_string.h"
57 #include "cfe_device.h"
58 #include "cfe_timer.h"
62 #include "sb1250_defs.h"
63 #include "sb1250_regs.h"
64 #include "sb1250_scd.h"
65 #include "sb1250_smbus.h"
66 #include "sb1250_wid.h"
68 #include "bsp_config.h"
70 #include "littlesur.h"
74 /* *********************************************************************
75 * Devices we're importing
76 ********************************************************************* */
78 extern cfe_driver_t promice_uart
; /* promice serial port */
79 extern cfe_driver_t ds17887_clock
; /* DS17887 RTC */
80 extern cfe_driver_t sb1250_uart
; /* SB1250 serial ports */
81 extern cfe_driver_t sb1250_ether
; /* SB1250 MACs */
82 extern cfe_driver_t sb1250_24lc128eeprom
; /* Microchip EEPROM */
83 extern cfe_driver_t idedrv
; /* IDE disk */
84 extern cfe_driver_t pcmciadrv
; /* PCMCIA card */
86 extern void pci_add_devices(int init
); /* driver collection du jour */
89 /* *********************************************************************
90 * UI command initialization
91 ********************************************************************* */
93 extern void ui_init_cpu1cmds(void);
94 extern void ui_init_littlesurcmds(void);
95 extern int ui_init_corecmds(void);
96 extern int ui_init_soccmds(void);
97 extern int ui_init_testcmds(void);
98 extern int ui_init_tempsensorcmds(void);
99 extern int ui_init_toyclockcmds(void);
100 extern int ui_init_memtestcmds(void);
101 extern int ui_init_resetcmds(void);
102 extern int ui_init_phycmds(void);
103 extern int ui_init_spdcmds(void);
104 extern int ui_init_disktestcmds(void);
105 extern int ui_init_ethertestcmds(void);
107 /* *********************************************************************
109 ********************************************************************* */
111 extern void sb1250_show_cpu_type(void);
113 /* *********************************************************************
114 * Some board-specific parameters
115 ********************************************************************* */
118 * Note! Configure the PROMICE for burst mode zero (one byte per
122 #define PROMICE_BASE (0x1FDFFC00)
123 #define PROMICE_WORDSIZE 1
125 /* *********************************************************************
126 * SysConfig switch settings and related parameters
127 ********************************************************************* */
129 #define CSWARM_PROMICE_CONSOLE 0x00000001
131 int littlesur_board_rev
;
132 int littlesur_config_switch
;
134 const unsigned int littlesur_startflags
[16] = {
135 0, /* 0 : UART console, no PCI */
136 CSWARM_PROMICE_CONSOLE
, /* 1 : PromICE console, no PCI */
137 CFE_INIT_PCI
, /* 2 : UART console, PCI */
138 CSWARM_PROMICE_CONSOLE
| CFE_INIT_PCI
, /* 3 : PromICE, PCI */
141 CFE_INIT_PCI
| CFE_LDT_SLAVE
, /* 6 : 2, plus LDT slave mode */
142 CFE_INIT_SAFE
, /* 7 : UART console, no pci, safe mode */
154 unsigned int cpu_revision
;
157 /* *********************************************************************
158 * board_console_init()
160 * Add the console device and set it to be the primary
168 ********************************************************************* */
170 void board_console_init(void)
175 syscfg
= SBREADCSR(A_SCD_SYSTEM_CFG
);
177 cpu_revision
= (unsigned int) (SBREADCSR(A_SCD_SYSTEM_REVISION
) &
178 (M_SYS_PART
| M_SYS_REVISION
));
181 * Read the config switch and decide how we are going to set up
182 * the console. This is actually board revision dependent.
184 * Note that the human-readable board revision is (littlesur_board_rev+1).
186 littlesur_board_rev
= G_SYS_CONFIG(syscfg
) & 0x3;
187 littlesur_config_switch
= (G_SYS_CONFIG(syscfg
) >> 2) & 0x0F;
189 cfe_startflags
= littlesur_startflags
[littlesur_config_switch
];
192 #if defined(_CSWARM_DIAG_CFG_) || defined(_CSWARM_DIAG3E_CFG_)
193 cfe_add_device(&promice_uart
,PROMICE_BASE
,PROMICE_WORDSIZE
,0);
194 cfe_set_console("promice0");
196 cfe_add_device(&sb1250_uart
,A_DUART
,0,0);
197 cfe_add_device(&promice_uart
,PROMICE_BASE
,PROMICE_WORDSIZE
,0);
200 * Read the config switch and decide how we are going to
201 * set up the console. The config switch sets
202 * bits 3..5 of the SYS_CONFIG field of the syscfg register.
205 if (cfe_startflags
& CSWARM_PROMICE_CONSOLE
) {
206 cfe_set_console("promice0");
209 cfe_set_console("uart0");
214 * Set variable that contains CPU speed, spit out config register
217 plldiv
= G_SYS_PLL_DIV(syscfg
);
223 cfe_cpu_speed
= 500000; /* wire func sim at 500KHz */
225 cfe_cpu_speed
= 50000000 * plldiv
; /* use PLL divisor */
231 cfe_add_device(&sb1250_24lc128eeprom
,BIGEEPROM_SMBUS_CHAN_1
,BIGEEPROM_SMBUS_DEV_1
,0);
233 cfe_set_envdevice("eeprom0"); /* Connect NVRAM subsystem to EEPROM */
236 /* *********************************************************************
237 * board_device_init()
239 * Initialize and add other devices. Add everything you need
240 * for bootstrap here, like disk drives, flash memory, UARTs,
241 * network controllers, etc.
248 ********************************************************************* */
250 void board_device_init(void)
253 * Print out the board version number.
255 printf("%s board revision %d\n", CFG_BOARDNAME
, littlesur_board_rev
+ 1);
261 cfe_add_device(&sb1250_uart
,A_DUART
,1,0);
265 * As a hack, we instantiate another flash at 0x1100_0000 (the PCMCIA area)
266 * when running in the functional simulator. We can preload an image into
267 * that region for faster booting. (see build/broadcom/sim/runcfe)
269 cfe_add_device(&newflashdrv
,0x11000000,64*1024*1024,NULL
);
273 * This is the 24LC128 on SMBus0. CFE doesn't use it for anything,
274 * but you can load data into it and then boot from it by changing a jumper.
277 cfe_add_device(&sb1250_24lc128eeprom
,BIGEEPROM_SMBUS_CHAN_0
,BIGEEPROM_SMBUS_DEV_0
,0);
280 * MACs - 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"));
284 #ifndef _CSWARM_DIAG_CFG_
285 cfe_add_device(&sb1250_ether
,A_MAC_BASE_1
,1,env_getenv("ETH1_HWADDR"));
286 cfe_add_device(&sb1250_ether
,A_MAC_BASE_2
,2,env_getenv("ETH2_HWADDR"));
293 #if !defined(_CSWARM_DIAG_CFG_) && !defined(_CSWARM_DIAG3E_CFG_)
294 cfe_add_device(&idedrv
,IDE_PHYS
+(0x1F0<<5),
295 IDE_PROBE_MASTER_TYPE(IDE_DEVTYPE_DISK
) |
296 IDE_PROBE_SLAVE_TYPE(IDE_DEVTYPE_NOPROBE
),
302 pci_add_devices(cfe_startflags
& CFE_INIT_PCI
);
308 cfe_add_device(&ds17887_clock
,RTC_PHYS
,0,NULL
);
311 * Set variable that contains CPU speed, spit out config register
314 printf("Config switch: %d\n", littlesur_config_switch
);
316 sb1250_show_cpu_type();
322 /* *********************************************************************
323 * board_device_reset()
325 * Reset devices. This call is done when the firmware is restarted,
326 * as might happen when an operating system exits, just before the
327 * "reset" command is applied to the installed devices. You can
328 * do whatever board-specific things are here to keep the system
329 * stable, like stopping DMA sources, interrupts, etc.
336 ********************************************************************* */
338 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)
361 ui_init_littlesurcmds();
365 ui_init_toyclockcmds();
366 ui_init_tempsensorcmds();
367 ui_init_memtestcmds();
371 ui_init_disktestcmds();
372 ui_init_ethertestcmds();