RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / arch / mips / board / cswarm / src / cswarm_devs.c
blobf130d1815ac7365428b31b3a56142cdb1c0d3c1e
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * Board device initialization File: cswarm_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)
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 "sbmips.h"
52 #include "lib_types.h"
53 #include "lib_queue.h"
54 #include "lib_printf.h"
55 #include "cfe_iocb.h"
56 #include "cfe_device.h"
57 #include "cfe_timer.h"
58 #include "env_subr.h"
59 #include "cfe.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"
70 #include "cswarm.h"
71 #include "dev_ide.h"
72 #include "dev_newflash.h"
75 * This lets us override the WID by poking values into our PromICE
77 #ifdef _MAGICWID_
78 #undef A_SCD_SYSTEM_REVISION
79 #define A_SCD_SYSTEM_REVISION 0x1FC00010
80 #define SB1250_REFCLK (*((uint64_t *) 0xBFC00018))
81 #endif
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 */
96 #if CFG_PCI
97 extern cfe_driver_t pciidedrv; /* PCI IDE controller */
98 extern cfe_driver_t dc21143drv; /* Tulip Ethernet */
99 #endif
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);
112 #if CFG_VGACONSOLE
113 extern int vga_biosinit(void);
114 #endif
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
124 * access).
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 */
143 0, /* 4 : unused */
144 0, /* 5 : unused */
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
158 * console.
160 * Input parameters:
161 * nothing
163 * Return value:
164 * nothing
165 ********************************************************************* */
167 void board_console_init(void)
169 uint64_t syscfg;
170 int plldiv;
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);
178 /* Console */
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");
182 #else
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");
197 else {
198 cfe_set_console("uart0");
200 #endif
203 * Set variable that contains CPU speed, spit out config register
206 plldiv = G_SYS_PLL_DIV(syscfg);
207 if (plldiv == 0) {
208 plldiv = 6;
211 #ifdef _FUNCSIM_
212 cfe_cpu_speed = 500000; /* wire func sim at 500KHz */
213 #else
214 cfe_cpu_speed = 50000000 * plldiv; /* use PLL divisor */
215 #endif
217 #if CFG_VGACONSOLE
218 vga_biosinit();
219 #endif
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.
238 * Input parameters:
239 * nothing
241 * Return value:
242 * nothing
243 ********************************************************************* */
245 void board_device_init(void)
247 uint64_t syscfg;
250 * Boot ROM
252 #if !defined(_CSWARM_DIAG_CFG_)
253 cfe_add_device(&newflashdrv,
254 BOOTROM_PHYS,
255 (BOOTROM_SIZE*K64) | FLASH_FLG_BUS8 | FLASH_FLG_DEV16,
256 NULL);
257 cfe_add_device(&newflashdrv,
258 ALT_BOOTROM_PHYS,
259 (ALT_BOOTROM_SIZE*K64) | FLASH_FLG_BUS8 | FLASH_FLG_DEV16,
260 NULL);
261 #endif
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"));
272 #endif
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),
284 * NULL);
288 * Uncomment to enable PCMCIA support
290 * cfe_add_device(&pcmciadrv,PCMCIA_PHYS,0,NULL);
292 #endif
294 #if CFG_PCI
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"));
302 #endif
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));
311 #ifdef _MAGICWID_
312 printf("Reference Clock: %dMhz\n",(uint32_t)SB1250_REFCLK);
313 #endif
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.
329 * Input parameters:
330 * nothing
332 * Return value:
333 * nothing
334 ********************************************************************* */
336 void board_device_reset(void)
342 /* *********************************************************************
343 * board_final_init()
345 * Do any final initialization, such as adding commands to the
346 * user interface.
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.
351 * Input parameters:
352 * nothing
354 * Return value:
355 * nothing
356 ********************************************************************* */
358 void board_final_init(void)
360 ui_init_cpu1cmds();
361 ui_init_swarmcmds();
362 ui_init_corecmds();
363 ui_init_soccmds();
364 ui_init_testcmds();
365 ui_init_resetcmds();
366 ui_init_tempsensorcmds();
367 ui_init_memtestcmds();
368 ui_init_toyclockcmds();
369 ui_init_phycmds();