📄 swarm_devs.c
字号:
/* ********************************************************************* * Broadcom Common Firmware Environment (CFE) * * Board device initialization File: swarm_devs.c * * This is the "C" part of the board support package. The * routines to create and initialize the console, wire up * device drivers, and do other customization live here. * * Author: Mitch Lichtenberg * ********************************************************************* * * Copyright 2000,2001,2002,2003 * Broadcom Corporation. All rights reserved. * * This software is furnished under license and may be used and * copied only in accordance with the following terms and * conditions. Subject to these conditions, you may download, * copy, install, use, modify and distribute modified or unmodified * copies of this software in source and/or binary form. No title * or ownership is transferred hereby. * * 1) Any source code used, modified or distributed must reproduce * and retain this copyright notice and list of conditions * as they appear in the source file. * * 2) No right is granted to use any trade name, trademark, or * logo of Broadcom Corporation. The "Broadcom Corporation" * name may not be used to endorse or promote products derived * from this software without the prior written permission of * Broadcom Corporation. * * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************* */#include "cfe.h"#include "sbmips.h"#include "cfe_smbus.h"#include "env_subr.h"#include "sb1250_defs.h"#include "sb1250_regs.h"#include "sb1250_scd.h"#include "sb1250_smbus.h"#include "sb1250_wid.h"#include "swarm.h"#include "dev_ide.h"#include "dev_newflash.h"#include "cfe_loader.h"#include "cfe_autoboot.h"/* ********************************************************************* * Devices we're importing ********************************************************************* */extern cfe_driver_t promice_uart; /* promice serial port */extern cfe_driver_t sb1250_uart; /* SB1250 serial ports */extern cfe_driver_t sb1250_ether; /* SB1250 MACs */extern cfe_driver_t newflashdrv; /* flash */extern cfe_driver_t idedrv; /* IDE disk */extern cfe_driver_t pcmciadrv; /* PCMCIA card */#if CFG_PCIextern void pci_add_devices(int init); /* driver collection du jour */#endif#if CFG_TCPextern cfe_driver_t tcpconsole; /* TCP/IP console */#endif#if CFG_VGACONSOLEextern cfe_driver_t pcconsole2; /* VGA Console */static int vgainit_ok = FALSE;extern int vga_biosinit(void);#endif#if CFG_USBextern int usb_init(uint32_t addr);extern cfe_driver_t usb_disk; /* USB mass-storage */extern cfe_driver_t usb_uart; /* USB serial ports */#endifextern cfe_smbus_t sb1250_smbus; /* BCM1250 SMBus controller */extern cfe_driver_t smbus_24lc128; /* Microchip 24lc128 eeprom */extern cfe_driver_t smbus_x1241clock; /* Xicor clock */extern cfe_driver_t smbus_m41t81clock; /* ST Micro clock */extern cfe_driver_t smbus_x1240eeprom; /* Xicor EEPROM *//* ********************************************************************* * UI command initialization ********************************************************************* */extern void ui_init_cpu1cmds(void);extern void ui_init_swarmcmds(void);extern int ui_init_corecmds(void);extern int ui_init_soccmds(void);extern int ui_init_testcmds(void);extern int ui_init_tempsensorcmds(void);extern int ui_init_toyclockcmds(void);extern int ui_init_memtestcmds(void);extern int ui_init_resetcmds(void);extern int ui_init_phycmds(void);extern int ui_init_spdcmds(void);extern int ui_init_disktestcmds(void);extern int ui_init_ethertestcmds(void);extern int ui_init_flashtestcmds(void);#if CFG_USBextern int ui_init_usbcmds(void);#endif/* ********************************************************************* * Other externs ********************************************************************* */extern void sb1250_show_cpu_type(void);/* ********************************************************************* * Some board-specific parameters ********************************************************************* *//* * Note! Configure the PROMICE for burst mode zero (one byte per * access). */#define PROMICE_BASE (0x1FDFFC00)#define PROMICE_WORDSIZE 1#define REAL_BOOTROM_SIZE (2*1024*1024) /* region is 4MB, but rom is 2MB *//* ********************************************************************* * SysConfig switch settings and related parameters ********************************************************************* */int swarm_board_rev;int swarm_config_switch;#define SWARM_PROMICE_CONSOLE 0x00000001#define SWARM_VGA_CONSOLE 0x00000002const unsigned int swarm_startflags[16] = { 0, /* 0 : UART console, no PCI */ SWARM_PROMICE_CONSOLE, /* 1 : PromICE console, no PCI */ CFE_INIT_PCI, /* 2 : UART console, PCI */ CFE_INIT_PCI | SWARM_PROMICE_CONSOLE, /* 3 : PromICE console, PCI */ 0, /* 4 : unused */ 0, /* 5 : unused */ CFE_INIT_PCI | CFE_LDT_SLAVE, /* 6 : 2, plus LDT slave mode */ CFE_INIT_SAFE, /* 7 : UART console, no pci, safe mode */ 0, /* 8 : unused */ 0, /* 9 : unused */ CFE_INIT_PCI | SWARM_VGA_CONSOLE, /* 10 : PCI, VGA Console */ 0, /* 11 : unused */ 0, /* 12 : unused */ 0, /* 13 : unused */ 0, /* 14 : unused */ 0 /* 15 : unused */};unsigned int cpu_revision;/* ********************************************************************* * board_console_init() * * Add the console device and set it to be the primary * console. * * Input parameters: * nothing * * Return value: * nothing ********************************************************************* */void board_console_init(void){ uint64_t syscfg = SBREADCSR(A_SCD_SYSTEM_CFG); cpu_revision = (unsigned int) (SBREADCSR(A_SCD_SYSTEM_REVISION) & (M_SYS_PART | M_SYS_REVISION)); /* Console */ cfe_add_device(&sb1250_uart,A_DUART,0,0); cfe_add_device(&promice_uart,PROMICE_BASE,PROMICE_WORDSIZE,0);#if CFG_VGACONSOLE /* VGA console, for the truly adventurous! */ cfe_add_device(&pcconsole2,0,0,0);#endif /* * Read the config switch and decide how we are going to set up * the console. This is actually board revision dependent. * * Note that the human-readable board revision is (swarm_board_rev+1). */ swarm_board_rev = G_SYS_CONFIG(syscfg) & 0x3; switch (swarm_board_rev) { case 0: /* * Board revision 0. The config switch sets bits 3..5 of the * SYS_CONFIG field of the syscfg register. */ swarm_config_switch = (G_SYS_CONFIG(syscfg) >> 3) & 0x07; break; default: /* * In later board revisions, the config switch sets bits 2..5. */ swarm_config_switch = (G_SYS_CONFIG(syscfg) >> 2) & 0x0f; break; } cfe_startflags = swarm_startflags[swarm_config_switch]; /* * Choose which console we're going to use. Our three choices * are the PromICE AI2 port, the "VGA" console, and * the UART. * * The UART is the "normal" console, of course. */ if (cfe_startflags & SWARM_PROMICE_CONSOLE) { cfe_set_console("promice0"); }#if CFG_VGACONSOLE /* * If VGA console, "buffer" the console messages until the * PCI is ready. */ else if (cfe_startflags & SWARM_VGA_CONSOLE) { cfe_set_console(CFE_BUFFER_CONSOLE); }#endif else { cfe_set_console("uart0"); } /* * SMBus buses - need to be initialized before we attach * devices that use them. */ cfe_add_smbus(&sb1250_smbus,A_SMB_BASE(0),0); cfe_add_smbus(&sb1250_smbus,A_SMB_BASE(1),0); /* * NVRAM (environment variables - These depend on the SWARM * board version since SWARM rev3 (and later) do not have Xicor * clock chips. Instead, a second 24lc128 is on SMBus 1. */ switch (swarm_board_rev) { case SWARM_REV_1: case SWARM_REV_2: cfe_add_device(&smbus_x1240eeprom,X1240_SMBUS_CHAN,X1240_SMBUS_DEV,0); break; default: case SWARM_REV_3: cfe_add_device(&smbus_24lc128,BIGEEPROM_SMBUS_CHAN_1,BIGEEPROM_SMBUS_DEV_1,0); } cfe_set_envdevice("eeprom0"); /* Connect NVRAM subsystem to EEPROM */}/* ********************************************************************* * board_smbus_waitready(chan) * * Wait until the SMBus channel is ready. We simply poll * the busy bit until it clears. * * Input parameters: * chan - channel (0 or 1) * * Return value: * nothing ********************************************************************* */static int board_smbus_waitready(int chan){ uintptr_t reg; uint64_t status; reg = PHYS_TO_K1(A_SMB_REGISTER(chan,R_SMB_STATUS)); for (;;) { status = SBREADCSR(reg); if (status & M_SMB_BUSY) continue; break; } if (status & M_SMB_ERROR) { SBWRITECSR(reg,(status & M_SMB_ERROR)); return -1; } return 0;}/* ********************************************************************* * board_probe_x1241(chan,dev) * * Probe for a Xicor X1241 at the specified device and channel. * * Actually, we just probe for anything at this address, and * assume it's a Xicor. * * Input parameters: * chan - SMBus channel * dev - device ID *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -