/* ============================================================================
* Copyright (c) Texas Instruments Inc 2011
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
* ===========================================================================
*/
/** ============================================================================
example for SRIO configuration and transfer driver on Keystone DSP
* =============================================================================
* Revision History
* ===============
* 10-June-2011 Brighton file created
* 13-June-2011 Zhan update
* =============================================================================*/
#include "csl_srioAux.h"
#include "Keystone_SRIO_init_drv.h"
#include "KeyStone_Navigator_init_drv.h"
CSL_SrioRegs * srioRegs = (CSL_SrioRegs *)CSL_SRIO_CONFIG_REGS;
SerdesRegs * srioSerdesRegs;
/*enable globally used blocks including MMR block in SRIO*/
void Keystone_SRIO_GlobalEnable(void)
{
srioRegs->RIO_GBL_EN = 1;
srioRegs->BLOCK_ENABLE_STATUS[0].RIO_BLK_EN= 1; //MMR_EN
//wait for enable completion
while(0x3 != (srioRegs->RIO_GBL_EN_STAT&0x3));
}
/*Enable SRIO blocks*/
void Keystone_SRIO_enable_blocks(
SRIO_Block_Enable * blockEn)
{
srioRegs->BLOCK_ENABLE_STATUS[5].RIO_BLK_EN= blockEn->bBLK5_8_Port_Datapath_EN[0];
srioRegs->BLOCK_ENABLE_STATUS[6].RIO_BLK_EN= blockEn->bBLK5_8_Port_Datapath_EN[1];
srioRegs->BLOCK_ENABLE_STATUS[7].RIO_BLK_EN= blockEn->bBLK5_8_Port_Datapath_EN[2];
srioRegs->BLOCK_ENABLE_STATUS[8].RIO_BLK_EN= blockEn->bBLK5_8_Port_Datapath_EN[3];
srioRegs->BLOCK_ENABLE_STATUS[1].RIO_BLK_EN= blockEn->bBLK1_LSU_EN ;
srioRegs->BLOCK_ENABLE_STATUS[2].RIO_BLK_EN= blockEn->bBLK2_MAU_EN ;
srioRegs->BLOCK_ENABLE_STATUS[3].RIO_BLK_EN= blockEn->bBLK3_TXU_EN ;
srioRegs->BLOCK_ENABLE_STATUS[4].RIO_BLK_EN= blockEn->bBLK4_RXU_EN ;
while(srioRegs->BLOCK_ENABLE_STATUS[5].RIO_BLK_EN_STAT != blockEn->bBLK5_8_Port_Datapath_EN[0]);
while(srioRegs->BLOCK_ENABLE_STATUS[6].RIO_BLK_EN_STAT != blockEn->bBLK5_8_Port_Datapath_EN[1]);
while(srioRegs->BLOCK_ENABLE_STATUS[7].RIO_BLK_EN_STAT != blockEn->bBLK5_8_Port_Datapath_EN[2]);
while(srioRegs->BLOCK_ENABLE_STATUS[8].RIO_BLK_EN_STAT != blockEn->bBLK5_8_Port_Datapath_EN[3]);
while(srioRegs->BLOCK_ENABLE_STATUS[1].RIO_BLK_EN_STAT != blockEn->bBLK1_LSU_EN );
while(srioRegs->BLOCK_ENABLE_STATUS[2].RIO_BLK_EN_STAT != blockEn->bBLK2_MAU_EN );
while(srioRegs->BLOCK_ENABLE_STATUS[3].RIO_BLK_EN_STAT != blockEn->bBLK3_TXU_EN );
while(srioRegs->BLOCK_ENABLE_STATUS[4].RIO_BLK_EN_STAT != blockEn->bBLK4_RXU_EN );
}
/*Disable all SRIO blocks*/
void Keystone_SRIO_disable_all_blocks()
{
srioRegs->BLOCK_ENABLE_STATUS[1].RIO_BLK_EN= 0; //LSU_EN
srioRegs->BLOCK_ENABLE_STATUS[2].RIO_BLK_EN= 0; //MAU_EN
srioRegs->BLOCK_ENABLE_STATUS[3].RIO_BLK_EN= 0; //TXU_EN
srioRegs->BLOCK_ENABLE_STATUS[4].RIO_BLK_EN= 0; //RXU_EN
srioRegs->BLOCK_ENABLE_STATUS[5].RIO_BLK_EN= 0; //PORT0_EN
srioRegs->BLOCK_ENABLE_STATUS[6].RIO_BLK_EN= 0; //PORT1_EN
srioRegs->BLOCK_ENABLE_STATUS[7].RIO_BLK_EN= 0; //PORT2_EN
srioRegs->BLOCK_ENABLE_STATUS[8].RIO_BLK_EN= 0; //PORT3_EN
srioRegs->BLOCK_ENABLE_STATUS[0].RIO_BLK_EN= 0; //MMR_EN
srioRegs->RIO_GBL_EN = 0;
//wait for disable completion
while(srioRegs->RIO_GBL_EN_STAT&1);
}
/*soft shutdown and reset SRIO*/
void Keystone_SRIO_soft_reset()
{
int i, j, k;
/*shut down TXU/RXU transaction*/
for(i=0; i<SRIO_PKTDMA_MAX_CH_NUM; i++)
{
KeyStone_pktDma_RxCh_teardown(srioDmaRxChCfgRegs, i);
KeyStone_pktDma_TxCh_teardown(srioDmaTxChCfgRegs, i);
}
for(i= 0; i<SRIO_MAX_LSU_NUM ; i++)
{
/*flash LSU transfer for all Source ID*/
for(j=0; j< SRIO_MAX_DEVICEID_NUM; j++)
{
srioRegs->LSU_CMD[i].RIO_LSU_REG6 =
CSL_SRIO_RIO_LSU_REG6_FLUSH_MASK| /*flash*/
(j<<CSL_SRIO_RIO_LSU_REG6_SCRID_MAP_SHIFT);
/*This can take more than one cycle to do the flush.
wait for a while*/
for(k=0; k< 100; k++)
asm(" nop 5");
}
}
/*disable the PEREN bit of the PCR register to stop all
new logical layer transactions.*/
srioRegs->RIO_PCR &= (~CSL_SRIO_RIO_PCR_PEREN_MASK);
/*Wait one second to finish any current DMA transfer.*/
for(i=0; i< 100000000; i++)
asm(" nop 5");
//reset all logic blocks in SRIO
Keystone_SRIO_disable_all_blocks();
//disable Serdes
Keystone_Serdes_disable(srioSerdesRegs, 4);
//disable SRIO through PSC
Keystone_disable_PSC_module(CSL_PSC_PD_SRIO, CSL_PSC_LPSC_SRIO);
Keystone_disable_PSC_Power_Domain(CSL_PSC_PD_SRIO);
}
/*configure SRIO 1x 2x or 4x path mode*/
void Keystone_SRIO_set_1x2x4x_Path(
SRIO_1x2x4x_Path_Control srio_1x2x4x_path_control)
{
/*This register is a global register, even though it can be accessed
from any port. So you do not need to program from each port, it is
basically a single register.
The PathID is a RO value, that is driven by the H/W. You cannot modify it*/
srioRegs->RIO_PLM[0].RIO_PLM_SP_PATH_CTL=
(srioRegs->RIO_PLM[0].RIO_PLM_SP_PATH_CTL&(~SRIO_1x2x4x_PATH_CONTROL_MASK))|
srio_1x2x4x_path_control;
}
/*SRIO timeout configuration in microsecond*/
void Keystone_SRIO_Timeout_Config(SRIO_Config * srio_cfg,
Uint32 logicalRepsonseTimeout_us,
Uint32 physicalPortTimeout_us,
Uint32 linkInitSilenceTimeout_us)
{
Uint32 uiTimeout, uiMaxTimeout;
/*PRESCALAR_SELECT is used to divide VBUSM clock(normally 333 to 400MHz,
here use 350MHz), (VBUS_M clock)/(PRESCALAR_SELECT+1),
to get about 50MHz clock with about 20ns period.*/
srioRegs->RIO_PER_SET_CNTL= (srioRegs->RIO_PER_SET_CNTL
&(~CSL_SRIO_RIO_PER_SET_CNTL_PRESCALER_SELECT_MASK))
|((350/50-1)<<CSL_SRIO_RIO_PER_SET_CNTL_PRESCALER_SELECT_SHIFT);
/*logical layer response timeout
logicalRepsonseTimeout = 15 x (scaled VBUS_M clock period) x TIMEOUT_VALUE),
TIMEOUT_VALUE = logicalRepsonseTimeout/(scaled VBUS_M clock period)/15 */
uiTimeout= logicalRepsonseTimeout_us*1000/20/15;
uiMaxTimeout=CSL_SRIO_RIO_SP_RT_CTL_TVAL_MASK
>>CSL_SRIO_RIO_SP_RT_CTL_TVAL_SHIFT;
if(uiTimeout>uiMaxTimeout)
uiTimeout= uiMaxTimeout;
if(0==uiTimeout)
uiTimeout= 1;
srioRegs->RIO_SP_RT_CTL= uiTimeout<<CSL_SRIO_RIO_SP_RT_CTL_TVAL_SHIFT;
/*PRESCALAR_SRV_CLK is used to divide SRIO reference clock to get about
10MHz SRV_CLK with about 100ns period. */
srioRegs->RIO_PRESCALAR_SRV_CLK=
(Uint32)srio_cfg->serdes_cfg->commonSetup.inputRefClock_MHz/10;
/*physical layer response timeout.
physicalPortTimeout = SRV_CLK period * TIMEOUT_VALUE * 3,
TIMEOUT_VALUE = physicalPortTimeout/SRV_CLK period/3 */
uiTimeout= physicalPortTimeout_us*1000/100/3;
uiMaxTimeout=CSL_SRIO_RIO_SP_LT_CTL_TVAL_MASK
>>CSL_SRIO_RIO_SP_LT_CTL_TVAL_SHIFT;
if(uiTimeout>uiMaxTimeout)
uiTimeout= uiMaxTimeout;
if(0==uiTimeout)
uiTimeout= 1;
srioRegs->RIO_SP_LT_CTL= uiTimeout<<CSL_SRIO_RIO_SP_LT_CTL_TVAL_SHIFT;
/*port silence timeout
The SRIO starts in the SILENT state. The link output driver is disabled
to force the link partner to initialize regardless of its current state.
The duration of the SILENT state is controlled by the silence_timer.
The duration must be long enough to ensure that the link partner detects
the silence (as a loss of lane_sync) and is forced to initialize but short
enough that it is readily distinguished from a link break.
linkInitSilenceTimeout is SRV_CLK period X 410 X SILENCE_TIMER,
SILENCE_TIMER= linkInitSilenceTimeout/SRV_CLK period/410*/
uiTimeout= linkInitSilenceTimeout_us*1000/100/410;
uiMaxTimeout=CSL_SRIO_RIO_PLM_SP_SILENCE_TIMER_SILENCE_TIMER_MASK
>>CSL_SRIO_RIO_PLM_SP_SILENCE_TIMER_SILENCE_TIMER_SHIFT;
if(uiTimeout>uiMaxTimeout)
uiTimeout= uiMaxTimeout;
if(0==uiTimeout)
uiTimeout= 1;
uiTimeout= uiTime
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
C6678_EMIF_test_package.zip (70个子文件)
common
KeyStone_HyperLink_Init.h 8KB
KeyStone_SRIO_Init_drv.h 24KB
KeyStone_HyperLink_Init.c 5KB
KeyStone_Navigator_init_drv.h 31KB
KeyStone_Navigator_init_drv.c 26KB
Keystone_I2C_init_drv.c 8KB
KeyStone_DDR_Init.c 41KB
KeyStone_common.c 35KB
KeyStone_common.h 7KB
KeyStone_SRIO_Init_drv.c 50KB
KeyStone_DDR_Init.h 2KB
KeyStone_SPI_Init.h 3KB
KeyStone_Packet_Descriptor.h 11KB
KeyStone_SPI_Init.c 6KB
Keystone_I2C_init_drv.h 2KB
Keystone_Serdes_init.c 9KB
KeyStone_EMIF16_Init.c 5KB
KeyStone_UART_Init_drv.h 5KB
Keystone_Serdes_init.h 10KB
KeyStone_EMIF16_Init.h 3KB
KeyStone_UART_Init_drv.c 5KB
EMIF
.project 3KB
Debug
ccsObjs.opt 234B
EMIF.map 23KB
objects.mk 268B
subdir_rules.mk 289B
src
EMIF_main.pp 4KB
EMIF_FLASH_mem_test.pp 503B
EMIF_FLASH_mem_test.obj 19KB
EMIF_NOR_FLASH_test.pp 4KB
subdir_rules.mk 4KB
FLASH
flash_nor.pp 4KB
subdir_rules.mk 2KB
flash_debug.pp 715B
ccsSrcs.opt 56B
flash_debug.obj 11KB
subdir_vars.mk 740B
flash_nor.obj 145KB
EMIF_NOR_FLASH_test.obj 97KB
ccsSrcs.opt 222B
KeyStone_common.pp 4KB
EMIF_main.obj 107KB
subdir_vars.mk 1KB
KeyStone_common.obj 142KB
KeyStone_EMIF16_Init.obj 23KB
KeyStone_EMIF16_Init.pp 1KB
sources.mk 2KB
ccsSrcs.opt 0B
EMIF.out 385KB
subdir_vars.mk 326B
makefile 4KB
KeyStone.cmd 1KB
src
EMIF_FLASH_mem_test.h 573B
EMIF_NOR_FLASH_test.h 2KB
FLASH
flash_debug.h 2KB
flash_debug.c 3KB
flash_nand.c 28KB
flash_nor.c 29KB
flash_util.h 3KB
flash_nand_table.h 2KB
flash_nor.h 8KB
flash_nand.h 6KB
EMIF_FLASH_mem_test.c 6KB
EMIF_NOR_FLASH_test.c 3KB
EMIF_main.c 5KB
.ccsproject 433B
.settings
org.eclipse.cdt.codan.core.prefs 93B
org.eclipse.core.resources.prefs 421B
org.eclipse.cdt.debug.core.prefs 154B
.cproject 18KB
共 70 条
- 1
cc552200
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页