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 11 * Lausanne edits: Jeffrey Cheng 12 * 13 ********************************************************************* 14 * 15 * Copyright 2000,2001,2002,2003,2004 16 * Broadcom Corporation. All rights reserved. 17 * 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. 24 * 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. 28 * 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. 34 * 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 ********************************************************************* */ 49 50 51#include "cfe.h" 52#include "sbmips.h" 53 54#include "env_subr.h" 55#include "cfe_smbus.h" 56#include "dev_newflash.h" 57 58#include "sb1250_defs.h" 59#include "sb1250_regs.h" 60#include "sb1250_scd.h" 61 62#include "lausanne.h" 63 64/* ********************************************************************* 65 * Devices we're importing 66 ********************************************************************* */ 67 68extern cfe_driver_t promice_uart; /* promice serial port */ 69extern cfe_driver_t sb1250_uart; /* SB1250 serial ports */ 70extern cfe_driver_t sb1250_ether; /* SB1250 MACs */ 71extern cfe_driver_t newflashdrv; /* AMD and Intel-style flash */ 72#if CFG_PCI 73extern void pci_add_devices(int init); /* driver collection du jour */ 74#endif 75#if CFG_TCP 76extern cfe_driver_t tcpconsole; /* TCP/IP console */ 77#endif 78extern cfe_smbus_t sb1250_smbus; 79extern cfe_driver_t smbus_24lc128; /* Microchip EEPROM */ 80 81 82extern void ui_init_cpu1cmds(void); 83extern void ui_init_swarmcmds(void); 84extern int ui_init_corecmds(void); 85extern int ui_init_soccmds(void); 86extern int ui_init_testcmds(void); 87extern int ui_init_cpldcmds(void); 88extern int ui_init_tempsensorcmds(void); 89extern int ui_init_toyclockcmds(void); 90extern int ui_init_memtestcmds(void); 91extern int ui_init_resetcmds(void); 92extern int ui_init_ethertestcmds(void); 93extern int ui_init_flashtestcmds(void); 94extern int ui_init_phycmds(void); 95extern int ui_init_spdcmds(void); 96 97extern void sb1250_show_cpu_type(void); 98 99/* ********************************************************************* 100 * Some board-specific parameters 101 ********************************************************************* */ 102 103/* 104 * Note! Configure the PROMICE for burst mode zero (one byte per 105 * access). 106 */ 107 108#define PROMICE_BASE (0x1FDFFC00) 109#define PROMICE_WORDSIZE 1 110 111#define REAL_BOOTROM_SIZE (2*1024*1024) /* region is 4MB, but rom is 2MB */ 112 113/* ********************************************************************* 114 * SysConfig switch settings and related parameters 115 ********************************************************************* */ 116 117int lausanne_board_rev; 118int lausanne_config_switch; 119 120#define SWARM_PROMICE_CONSOLE 0x00000001 121 122const unsigned int lausanne_startflags[16] = { 123 0, /* 0 : UART console, no PCI */ 124 SWARM_PROMICE_CONSOLE, /* 1 : PromICE console, no PCI */ 125 CFE_INIT_PCI, /* 2 : UART console, PCI */ 126 CFE_INIT_PCI | SWARM_PROMICE_CONSOLE, /* 3 : PromICE console, PCI */ 127 0, /* 4 : unused */ 128 0, /* 5 : unused */ 129 CFE_INIT_PCI | CFE_LDT_SLAVE, /* 6 : 2, plus LDT slave mode */ 130 CFE_INIT_SAFE, /* 7 : UART console, no pci, safe mode */ 131 0, /* 8 : unused */ 132 0, /* 9 : unused */ 133 0, /* 10 : unused */ 134 0, /* 11 : unused */ 135 0, /* 12 : unused */ 136 0, /* 13 : unused */ 137 0, /* 14 : unused */ 138 0, /* 15 : unused */ 139}; 140 141 142unsigned int cpu_revision; 143 144#define SB1250_PASS1 (V_SYS_PART(K_SYS_PART_SB1250) | V_SYS_REVISION(K_SYS_REVISION_PASS1)) 145#define SB1250_PASS2 (V_SYS_PART(K_SYS_PART_SB1250) | V_SYS_REVISION(K_SYS_REVISION_PASS2)) 146 147/* ********************************************************************* 148 * board_console_init() 149 * 150 * Add the console device and set it to be the primary 151 * console. 152 * 153 * Input parameters: 154 * nothing 155 * 156 * Return value: 157 * nothing 158 ********************************************************************* */ 159 160void board_console_init(void) 161{ 162 uint64_t syscfg; 163 164 syscfg = SBREADCSR(A_SCD_SYSTEM_CFG); 165 166 cpu_revision = (unsigned int) (SBREADCSR(A_SCD_SYSTEM_REVISION) & 167 (M_SYS_PART | M_SYS_REVISION)); 168 169 /* Console */ 170 cfe_add_device(&sb1250_uart,A_DUART,0,0); 171 cfe_add_device(&promice_uart,PROMICE_BASE,PROMICE_WORDSIZE,0); 172 173 /* 174 * Read the config switch and decide how we are going to set up 175 * the console. This is actually board revision dependent. 176 * 177 * Note that the human-readable board revision is (lausanne_board_rev+1). 178 */ 179 lausanne_board_rev = G_SYS_CONFIG(syscfg) & 0x3; 180 lausanne_config_switch = (G_SYS_CONFIG(syscfg) >> 2) & 0x0f; 181 182 cfe_startflags = lausanne_startflags[lausanne_config_switch]; 183 184 if (cfe_startflags & SWARM_PROMICE_CONSOLE) { 185 cfe_set_console("promice0"); 186 } 187 else { 188 cfe_set_console("uart0"); 189 } 190 191 /* 192 * SMBus buses - need to be initialized before we attach 193 * devices that use them. 194 */ 195 196 cfe_add_smbus(&sb1250_smbus,A_SMB_BASE(0),0); 197 cfe_add_smbus(&sb1250_smbus,A_SMB_BASE(1),0); 198 199 /* 200 * NVRAM (environment variables) 201 */ 202 cfe_add_device(&smbus_24lc128,BIGEEPROM_SMBUS_CHAN,BIGEEPROM_SMBUS_DEV,0); 203 cfe_set_envdevice("eeprom0"); /* Connect NVRAM subsystem to EEPROM */ 204} 205 206 207 208/* ********************************************************************* 209 * board_device_init() 210 * 211 * Initialize and add other devices. Add everything you need 212 * for bootstrap here, like disk drives, flash memory, UARTs, 213 * network controllers, etc. 214 * 215 * Input parameters: 216 * nothing 217 * 218 * Return value: 219 * nothing 220 ********************************************************************* */ 221 222void board_device_init(void) 223{ 224 uint64_t syscfg; 225 226 /* 227 * Print out the board version number. 228 */ 229 printf("%s board revision %d\n", CFG_BOARDNAME, lausanne_board_rev + 1); 230 231 /* 232 * UART channel B 233 */ 234 235 cfe_add_device(&sb1250_uart,A_DUART,1,0); 236 237 /* 238 * Boot ROM 239 */ 240 cfe_add_device(&newflashdrv, 241 BOOTROM_PHYS, 242 REAL_BOOTROM_SIZE | FLASH_FLG_BUS8 | FLASH_FLG_DEV16, 243 NULL); 244 cfe_add_device(&newflashdrv, 245 ALT_BOOTROM_PHYS, 246 (ALT_BOOTROM_SIZE*K64) | FLASH_FLG_BUS8 | FLASH_FLG_DEV16, 247 NULL); 248#ifdef _FUNCSIM_ 249 cfe_add_device(&newflashdrv,0x11000000,64*1024*1024,NULL); 250#endif 251 252 /* 253 * MACs - must init after environment, since the hw address is stored there 254 */ 255 cfe_add_device(&sb1250_ether,A_MAC_BASE_0,0,env_getenv("ETH0_HWADDR")); 256 cfe_add_device(&sb1250_ether,A_MAC_BASE_1,1,env_getenv("ETH1_HWADDR")); 257 258#if CFG_PCI 259 pci_add_devices(cfe_startflags & CFE_INIT_PCI); 260#endif 261 262 /* 263 * Clock 264 */ 265 /*No clock on this board, SDA0 and SCL0 pull high*/ 266 267 268 /* 269 * Set variable that contains CPU speed, spit out config register 270 */ 271 272 sb1250_show_cpu_type(); 273 274 syscfg = SBREADCSR(A_SCD_SYSTEM_CFG); 275 printf("Config switch: %d\n", lausanne_config_switch); 276 if (G_SYS_PLL_DIV(syscfg) == 0) { 277 /* XXX: keep in synch with setting of CPU speed, above. */ 278 printf("PLL_DIV of zero found, assuming 6 (300MHz)\n"); 279 } 280 281 /* 282 * Reset the MAC address for MAC 2, since it's hooked 283 * to the video codec. This prevents the OS from 284 * probing it. 285 */ 286 SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0); 287 288#if CFG_TCP 289 cfe_add_device(&tcpconsole,0,0,0); 290#endif 291} 292 293 294 295/* ********************************************************************* 296 * board_device_reset() 297 * 298 * Reset devices. This call is done when the firmware is restarted, 299 * as might happen when an operating system exits, just before the 300 * "reset" command is applied to the installed devices. You can 301 * do whatever board-specific things are here to keep the system 302 * stable, like stopping DMA sources, interrupts, etc. 303 * 304 * Input parameters: 305 * nothing 306 * 307 * Return value: 308 * nothing 309 ********************************************************************* */ 310 311void board_device_reset(void) 312{ 313 /* 314 * Reset the MAC address for MAC 2, since it's hooked 315 * to the video codec. This prevents the OS from 316 * probing it. 317 */ 318 SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0); 319} 320 321 322/* ********************************************************************* 323 * board_final_init() 324 * 325 * Do any final initialization, such as adding commands to the 326 * user interface. 327 * 328 * If you don't want a user interface, put the startup code here. 329 * This routine is called just before CFE starts its user interface. 330 * 331 * Input parameters: 332 * nothing 333 * 334 * Return value: 335 * nothing 336 ********************************************************************* */ 337 338void board_final_init(void) 339{ 340 ui_init_cpu1cmds(); 341 ui_init_swarmcmds(); 342 ui_init_corecmds(); 343 ui_init_soccmds(); 344 ui_init_testcmds(); 345 ui_init_cpldcmds(); 346 ui_init_tempsensorcmds(); 347 ui_init_memtestcmds(); 348 ui_init_resetcmds(); 349 ui_init_ethertestcmds(); 350 ui_init_flashtestcmds(); 351 ui_init_phycmds(); 352 ui_init_spdcmds(); 353} 354 355