allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / cfe / cfe / arch / mips / board / lausanne / src / lausanne_devs.c
blob02c42591aeedac90ed08169e751f0fa565caffaa
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Board device initialization File: lausanne_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)
11 * Lausanne edits: Jeffrey Cheng (chengj@broadcom.com)
13 *********************************************************************
15 * Copyright 2000,2001,2002,2003
16 * Broadcom Corporation. All rights reserved.
18 * This software is furnished under license and may be used and
19 * copied only in accordance with the following terms and
20 * conditions. Subject to these conditions, you may download,
21 * copy, install, use, modify and distribute modified or unmodified
22 * copies of this software in source and/or binary form. No title
23 * or ownership is transferred hereby.
25 * 1) Any source code used, modified or distributed must reproduce
26 * and retain this copyright notice and list of conditions
27 * as they appear in the source file.
29 * 2) No right is granted to use any trade name, trademark, or
30 * logo of Broadcom Corporation. The "Broadcom Corporation"
31 * name may not be used to endorse or promote products derived
32 * from this software without the prior written permission of
33 * Broadcom Corporation.
35 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
36 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
37 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
39 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
40 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
41 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
42 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
43 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
44 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
45 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
46 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
47 * THE POSSIBILITY OF SUCH DAMAGE.
48 ********************************************************************* */
52 #include "sbmips.h"
53 #include "lib_types.h"
54 #include "lib_queue.h"
55 #include "lib_printf.h"
56 #include "cfe_iocb.h"
57 #include "cfe_device.h"
58 #include "cfe_timer.h"
59 #include "env_subr.h"
60 #include "cfe.h"
62 #include "sb1250_defs.h"
63 #include "sb1250_regs.h"
64 #include "sb1250_scd.h"
66 #include "bsp_config.h"
68 #include "lausanne.h"
69 #include "dev_ide.h"
71 /* *********************************************************************
72 * Devices we're importing
73 ********************************************************************* */
75 extern cfe_driver_t promice_uart; /* promice serial port */
76 extern cfe_driver_t sb1250_uart; /* SB1250 serial ports */
77 extern cfe_driver_t sb1250_ether; /* SB1250 MACs */
78 extern cfe_driver_t sb1250_24lc128eeprom; /* Microchip EEPROM */
79 extern cfe_driver_t lausanne_flashdrv; /* Intel-style flash */
80 #if CFG_PCI
81 extern void pci_add_devices(int init); /* driver collection du jour */
82 #endif
84 extern void ui_init_cpu1cmds(void);
85 extern void ui_init_swarmcmds(void);
86 extern int ui_init_corecmds(void);
87 extern int ui_init_soccmds(void);
88 extern int ui_init_testcmds(void);
89 extern int ui_init_cpldcmds(void);
90 extern int ui_init_tempsensorcmds(void);
91 extern int ui_init_toyclockcmds(void);
92 extern int ui_init_memtestcmds(void);
93 extern int ui_init_resetcmds(void);
94 extern int ui_init_ethertestcmds(void);
95 extern int ui_init_flashtestcmds(void);
96 extern int ui_init_phycmds(void);
97 extern int ui_init_spdcmds(void);
99 extern void sb1250_show_cpu_type(void);
101 /* *********************************************************************
102 * Some board-specific parameters
103 ********************************************************************* */
106 * Note! Configure the PROMICE for burst mode zero (one byte per
107 * access).
110 #define PROMICE_BASE (0x1FDFFC00)
111 #define PROMICE_WORDSIZE 1
113 #define REAL_BOOTROM_SIZE (2*1024*1024) /* region is 4MB, but rom is 2MB */
114 #define BOOTROM (16*1024*1024)
115 /* *********************************************************************
116 * SysConfig switch settings and related parameters
117 ********************************************************************* */
119 int lausanne_board_rev;
120 int lausanne_config_switch;
122 #define SWARM_PROMICE_CONSOLE 0x00000001
124 const unsigned int lausanne_startflags[16] = {
125 0, /* 0 : UART console, no PCI */
126 SWARM_PROMICE_CONSOLE, /* 1 : PromICE console, no PCI */
127 CFE_INIT_PCI, /* 2 : UART console, PCI */
128 CFE_INIT_PCI | SWARM_PROMICE_CONSOLE, /* 3 : PromICE console, PCI */
129 0, /* 4 : unused */
130 0, /* 5 : unused */
131 CFE_INIT_PCI | CFE_LDT_SLAVE, /* 6 : 2, plus LDT slave mode */
132 CFE_INIT_SAFE, /* 7 : UART console, no pci, safe mode */
133 0, /* 8 : unused */
134 0, /* 9 : unused */
135 0, /* 10 : unused */
136 0, /* 11 : unused */
137 0, /* 12 : unused */
138 0, /* 13 : unused */
139 0, /* 14 : unused */
140 0, /* 15 : unused */
144 unsigned int cpu_revision;
146 #define SB1250_PASS1 (V_SYS_PART(K_SYS_PART_SB1250) | V_SYS_REVISION(K_SYS_REVISION_PASS1))
147 #define SB1250_PASS2 (V_SYS_PART(K_SYS_PART_SB1250) | V_SYS_REVISION(K_SYS_REVISION_PASS2))
149 /* *********************************************************************
150 * board_console_init()
152 * Add the console device and set it to be the primary
153 * console.
155 * Input parameters:
156 * nothing
158 * Return value:
159 * nothing
160 ********************************************************************* */
162 void board_console_init(void)
164 uint64_t syscfg;
165 int plldiv;
167 syscfg = SBREADCSR(A_SCD_SYSTEM_CFG);
169 cpu_revision = (unsigned int) (SBREADCSR(A_SCD_SYSTEM_REVISION) &
170 (M_SYS_PART | M_SYS_REVISION));
172 /* Console */
173 cfe_add_device(&sb1250_uart,A_DUART,0,0);
174 cfe_add_device(&promice_uart,PROMICE_BASE,PROMICE_WORDSIZE,0);
177 * Read the config switch and decide how we are going to set up
178 * the console. This is actually board revision dependent.
180 * Note that the human-readable board revision is (lausanne_board_rev+1).
182 lausanne_board_rev = G_SYS_CONFIG(syscfg) & 0x3;
183 lausanne_config_switch = (G_SYS_CONFIG(syscfg) >> 2) & 0x0f;
185 cfe_startflags = lausanne_startflags[lausanne_config_switch];
187 if (cfe_startflags & SWARM_PROMICE_CONSOLE) {
188 cfe_set_console("promice0");
190 else {
191 cfe_set_console("uart0");
195 * Set variable that contains CPU speed, spit out config register
198 plldiv = G_SYS_PLL_DIV(syscfg);
199 if (plldiv == 0) {
200 plldiv = 6;
203 #ifdef _FUNCSIM_
204 cfe_cpu_speed = 500000; /* wire func sim at 500KHz */
205 #else
206 cfe_cpu_speed = 50000000 * plldiv; /* use PLL divisor */
207 #endif
210 * NVRAM (environment variables)
212 cfe_add_device(&sb1250_24lc128eeprom,BIGEEPROM_SMBUS_CHAN,BIGEEPROM_SMBUS_DEV,0);
213 cfe_set_envdevice("eeprom0"); /* Connect NVRAM subsystem to EEPROM */
218 /* *********************************************************************
219 * board_device_init()
221 * Initialize and add other devices. Add everything you need
222 * for bootstrap here, like disk drives, flash memory, UARTs,
223 * network controllers, etc.
225 * Input parameters:
226 * nothing
228 * Return value:
229 * nothing
230 ********************************************************************* */
232 void board_device_init(void)
234 uint64_t syscfg;
237 * Print out the board version number.
239 printf("%s board revision %d\n", CFG_BOARDNAME, lausanne_board_rev + 1);
242 * UART channel B
245 cfe_add_device(&sb1250_uart,A_DUART,1,0);
248 * Boot ROM
250 cfe_add_device(&lausanne_flashdrv,BOOTROM_PHYS, REAL_BOOTROM_SIZE ,NULL);
251 cfe_add_device(&lausanne_flashdrv,ALT_BOOTROM_PHYS, BOOTROM ,NULL);
252 #ifdef _FUNCSIM_
253 cfe_add_device(&lausanne_flashdrv,0x11000000,64*1024*1024,NULL);
254 #endif
257 * MACs - must init after environment, since the hw address is stored there
259 cfe_add_device(&sb1250_ether,A_MAC_BASE_0,0,env_getenv("ETH0_HWADDR"));
260 cfe_add_device(&sb1250_ether,A_MAC_BASE_1,1,env_getenv("ETH1_HWADDR"));
262 #if CFG_PCI
263 pci_add_devices(cfe_startflags & CFE_INIT_PCI);
264 #endif
267 * Clock
269 /*No clock on this board, SDA0 and SCL0 pull high*/
273 * Set variable that contains CPU speed, spit out config register
276 sb1250_show_cpu_type();
278 syscfg = SBREADCSR(A_SCD_SYSTEM_CFG);
279 printf("Config switch: %d\n", lausanne_config_switch);
280 if (G_SYS_PLL_DIV(syscfg) == 0) {
281 printf("PLL_DIV of zero found, assuming 6 (300MHz)\n");
285 * Reset the MAC address for MAC 2, since it's hooked
286 * to the video codec. This prevents the OS from
287 * probing it.
289 SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0);
294 /* *********************************************************************
295 * board_device_reset()
297 * Reset devices. This call is done when the firmware is restarted,
298 * as might happen when an operating system exits, just before the
299 * "reset" command is applied to the installed devices. You can
300 * do whatever board-specific things are here to keep the system
301 * stable, like stopping DMA sources, interrupts, etc.
303 * Input parameters:
304 * nothing
306 * Return value:
307 * nothing
308 ********************************************************************* */
310 void board_device_reset(void)
313 * Reset the MAC address for MAC 2, since it's hooked
314 * to the video codec. This prevents the OS from
315 * probing it.
317 SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0);
321 /* *********************************************************************
322 * board_final_init()
324 * Do any final initialization, such as adding commands to the
325 * user interface.
327 * If you don't want a user interface, put the startup code here.
328 * This routine is called just before CFE starts its user interface.
330 * Input parameters:
331 * nothing
333 * Return value:
334 * nothing
335 ********************************************************************* */
337 void board_final_init(void)
339 ui_init_cpu1cmds();
340 ui_init_swarmcmds();
341 ui_init_corecmds();
342 ui_init_soccmds();
343 ui_init_testcmds();
344 ui_init_cpldcmds();
345 ui_init_tempsensorcmds();
346 ui_init_memtestcmds();
347 ui_init_resetcmds();
348 ui_init_ethertestcmds();
349 ui_init_flashtestcmds();
350 ui_init_phycmds();
351 ui_init_spdcmds();