sentosa_devs.c
来自「一个很好的嵌入式linux平台下的bootloader」· C语言 代码 · 共 527 行 · 第 1/2 页
C
527 行
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 * * 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, sentosa_board_rev + 1); /* * 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); /* * 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"));#if CFG_PCI pci_add_devices(cfe_startflags & CFE_INIT_PCI);#endif /* * Real-time clock */ switch (sentosa_board_rev) { case SENTOSA_REV_1: /* * Rev1 Sentosas always have Xicor X1241 clock chips. */ cfe_add_device(&smbus_x1241clock,X1240_SMBUS_CHAN,X1240_SMBUS_DEV,0); break; default: case SENTOSA_REV_2: case SENTOSA_REV_3: /* * Some early rev2's have X1240s but most newer ones will have * ST Micro M41T81 clock chips. We'll need to probe for * the X1241 to know if we've got one. */ if (board_probe_x1241(X1240_SMBUS_CHAN,X1240_SMBUS_DEV)) { cfe_add_device(&smbus_x1241clock,X1240_SMBUS_CHAN,X1240_SMBUS_DEV,0); /* Might as well configure the X1240's EEPROM while we're here. */ cfe_add_device(&smbus_x1240eeprom,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); } } /* * Host download interface. */ cfe_add_device(&sb1250_pcihost,0,0,NULL); /* * Set variable that contains CPU speed, spit out config register */ printf("Config switch: %d\n", sentosa_config_switch); sb1250_show_cpu_type(); /* * Reset the MAC address for MAC 2, since it's not hooked * to anything. */ SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0);}/* ********************************************************************* * 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 not hooked * to anything. */ SBWRITECSR(A_MAC_REGISTER(2,R_MAC_ETHERNET_ADDR),0);}/* ********************************************************************* * board_blinkylight(arg) * * Blink the LED once per second * * Input parameters: * arg - not used * * Return value: * nothing ********************************************************************* */static void board_blinkylight(void *arg){ static int light = 0; intptr_t reg; if (TIMER_EXPIRED(blinky_timer)) { light = !light; reg = light ? A_GPIO_PIN_SET : A_GPIO_PIN_CLR; SBWRITECSR(reg,M_GPIO_DEBUG_LED); TIMER_SET(blinky_timer,CFE_HZ); }}/* ********************************************************************* * 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){ ui_init_cpu1cmds(); ui_init_swarmcmds(); ui_init_corecmds(); ui_init_soccmds(); ui_init_testcmds(); ui_init_resetcmds(); ui_init_tempsensorcmds(); ui_init_toyclockcmds(); ui_init_memtestcmds(); ui_init_phycmds(); ui_init_ethertestcmds(); ui_init_flashtestcmds(); cfe_bg_add(board_blinkylight,NULL); TIMER_SET(blinky_timer,CFE_HZ); if (cfe_startflags & DEVICE_DOWNLOAD) { cfe_device_download((cfe_startflags & DEVICE_EXECUTE), ""); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?