📄 swarm_devs.c
字号:
* Return value: * TRUE - X1241 is present * FALSE - not present ********************************************************************* */static int board_probe_x1241(int chan,int slaveaddr){ uintptr_t reg; int devaddr = 0; int err; /* * Make sure the bus is idle (probably should * ignore error here) */ if (board_smbus_waitready(chan) < 0) return FALSE; /* * Write the device address to the controller. There are two * parts, the high part goes in the "CMD" field, and the * low part is the data field. */ reg = PHYS_TO_K1(A_SMB_REGISTER(chan,R_SMB_CMD)); SBWRITECSR(reg,((devaddr >> 8) & 0x7)); /* * Write the data to the controller */ reg = PHYS_TO_K1(A_SMB_REGISTER(chan,R_SMB_DATA)); SBWRITECSR(reg,((devaddr & 0xFF) & 0xFF)); /* * Start the command */ reg = PHYS_TO_K1(A_SMB_REGISTER(chan,R_SMB_START)); SBWRITECSR(reg,V_SMB_TT(K_SMB_TT_WR2BYTE) | slaveaddr); /* * Wait till done */ err = board_smbus_waitready(chan); if (err < 0) return FALSE; return TRUE;}/* ********************************************************************* * board_device_init() * * Initialize and add other devices. Add everything you need * for bootstrap here, like disk drives, flash memory, UARTs, * network controllers, etc. * * Input parameters: * nothing * * Return value: * nothing ********************************************************************* */void board_device_init(void){ /* * Print out the board version number. */ printf("%s board revision %d\n", CFG_BOARDNAME, swarm_board_rev + 1); /* * UART channel B */ cfe_add_device(&sb1250_uart,A_DUART,1,0); /* * Boot ROM, using "new" flash driver */ cfe_add_device(&newflashdrv, BOOTROM_PHYS, REAL_BOOTROM_SIZE | FLASH_FLG_BUS8 | FLASH_FLG_DEV16, NULL); cfe_add_device(&newflashdrv, ALT_BOOTROM_PHYS, REAL_BOOTROM_SIZE | FLASH_FLG_BUS8 | FLASH_FLG_DEV16, NULL);#ifdef _FUNCSIM_ /* * As a hack, we instantiate another flash at 0x1100_0000 (the PCMCIA area) * when running in the functional simulator. We can preload an image into * that region for faster booting. (see build/broadcom/sim/runcfe) */ cfe_add_device(&newflashdrv,0x11000000,64*1024*1024,NULL);#endif /* * This is the 24LC128 on SMBus0. CFE doesn't use it for anything, * but you can load data into it and then boot from it by changing a jumper. */ cfe_add_device(&smbus_24lc128,BIGEEPROM_SMBUS_CHAN,BIGEEPROM_SMBUS_DEV,0); /* * MACs - must init after environment, since the hw address is stored there */ cfe_add_device(&sb1250_ether,A_MAC_BASE_0,0,env_getenv("ETH0_HWADDR")); cfe_add_device(&sb1250_ether,A_MAC_BASE_1,1,env_getenv("ETH1_HWADDR")); /* * IDE disks */ cfe_add_device(&idedrv,IDE_PHYS+(0x1F0<<5), IDE_PROBE_MASTER_TYPE(IDE_DEVTYPE_DISK) | IDE_PROBE_SLAVE_TYPE(IDE_DEVTYPE_NOPROBE), NULL); /* * PCMCIA support */ cfe_add_device(&pcmciadrv,PCMCIA_PHYS,0,NULL);#if CFG_PCI pci_add_devices(cfe_startflags & CFE_INIT_PCI);#endif /* * Clock - depends on the hardware version number, since the older * boards have Xicor clocks and the newer boards have ST Micro parts. */ switch (swarm_board_rev) { case SWARM_REV_1: cfe_add_device(&smbus_x1241clock,X1240_SMBUS_CHAN,X1240_SMBUS_DEV,0); break; default: case SWARM_REV_2: case SWARM_REV_3: if (board_probe_x1241(X1240_SMBUS_CHAN,X1240_SMBUS_DEV)) { cfe_add_device(&smbus_x1241clock,X1240_SMBUS_CHAN,X1240_SMBUS_DEV,0); } else { /* Add ST Micro clock driver here */ cfe_add_device(&smbus_m41t81clock,M41T81_SMBUS_CHAN,M41T81_SMBUS_DEV,0); } }#if CFG_VGACONSOLE /* * VGA Console - try to init a VGA console, fall back to * UART if not there. */ if (cfe_startflags & SWARM_VGA_CONSOLE) { cfe_ledstr("vgai"); vgainit_ok = vga_biosinit(); if (vgainit_ok == 0) cfe_set_console("pcconsole0"); else cfe_set_console("uart0"); }#endif /* * Set variable that contains CPU speed, spit out config register */ printf("Config switch: %d\n", swarm_config_switch); sb1250_show_cpu_type(); /* * Reset the MAC address for MAC 2, since it's hooked * to the video codec. This prevents the OS from * probing it. */ SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0); /* * Some misc devices go here, mostly for playing. */#if CFG_TCP cfe_add_device(&tcpconsole,0,0,0);#endif#if CFG_USB usb_init(NULL); cfe_add_device(&usb_disk,0,0,0); cfe_add_device(&usb_uart,0,0,0);#endif}/* ********************************************************************* * board_device_reset() * * Reset devices. This call is done when the firmware is restarted, * as might happen when an operating system exits, just before the * "reset" command is applied to the installed devices. You can * do whatever board-specific things are here to keep the system * stable, like stopping DMA sources, interrupts, etc. * * Input parameters: * nothing * * Return value: * nothing ********************************************************************* */void board_device_reset(void){ /* * Reset the MAC address for MAC 2, since it's hooked * to the video codec. This prevents the OS from * probing it. */ SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0);}/* ********************************************************************* * board_setup_autoboot() * * Set up autoboot methods. This routine sets up the list of * places to find a boot program. * * Input parameters: * nothing * * Return value: * nothing ********************************************************************* */static void board_setup_autoboot(void){ /* * First try PCMCIA. Try to load an elf file called 'autoboot' * from the root directory of the FAT filesystem on the PCMCIA card. */ cfe_add_autoboot(CFE_AUTOBOOT_DISK,0,"pcmcia0","elf","fat","autoboot"); /* * Uncomment to try IDE next. We leave this disabled for now due * to the long timeout if you don't have an IDE disk connected. */ /* cfe_add_autoboot(CFE_AUTOBOOT_DISK,0,"ide0.0","raw","raw",NULL); */ /* * If you had partitioned your flash, you could boot from it like this: */ /* cfe_add_autoboot(CFE_AUTOBOOT_RAW,0,"flash0.os","elf","raw",NULL); */ /* * Now try running a script (file containing CFE commands) from * the TFTP server. Your DHCP server must set option 130 * to contain the name of the script. Option 130 gets stored * in "BOOT_SCRIPT" when a DHCP reply is received. */ cfe_add_autoboot(CFE_AUTOBOOT_NETWORK,LOADFLG_BATCH, "eth0","raw","tftp","$BOOT_SERVER:$BOOT_SCRIPT"); /* * Finally, try loading whatever the DHCP server says is the boot * program. Do this as an ELF file, and failing that, try a * raw binary. */ cfe_add_autoboot(CFE_AUTOBOOT_NETWORK,0,"eth0","elf","tftp",NULL); cfe_add_autoboot(CFE_AUTOBOOT_NETWORK,0,"eth0","raw","tftp",NULL);}/* ********************************************************************* * board_final_init() * * Do any final initialization, such as adding commands to the * user interface. * * If you don't want a user interface, put the startup code here. * This routine is called just before CFE starts its user interface. * * Input parameters: * nothing * * Return value: * nothing ********************************************************************* */void board_final_init(void){#if CFG_UI ui_init_cpu1cmds(); ui_init_swarmcmds(); ui_init_corecmds(); ui_init_soccmds(); ui_init_testcmds(); ui_init_toyclockcmds(); ui_init_tempsensorcmds(); ui_init_memtestcmds(); ui_init_resetcmds(); ui_init_phycmds(); ui_init_spdcmds();#if CFG_USB ui_init_usbcmds();#endif ui_init_disktestcmds(); ui_init_ethertestcmds(); ui_init_flashtestcmds();#endif board_setup_autoboot();#if !CFG_UI cfe_autoboot(NULL,0);#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -