⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skgeinit.c

📁 F:worksip2440a board可启动u-boot-like.tar.gz F:worksip2440a board可启动u-boot-like.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
 *	SkGeInitPktArb() - Initialize the Packet Arbiter * * Description: *	This function initializes the Packet Arbiter. *	It must not be called if there is still an *	initialized or active port. * * Returns: *	nothing */static void SkGeInitPktArb(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC)		/* IO context */{	/* release local reset */	SK_OUT16(IoC, B3_PA_CTRL, PA_RST_CLR);	/* configure timeout values */	SK_OUT16(IoC, B3_PA_TOINI_RX1, SK_PKT_TO_MAX);	SK_OUT16(IoC, B3_PA_TOINI_RX2, SK_PKT_TO_MAX);	SK_OUT16(IoC, B3_PA_TOINI_TX1, SK_PKT_TO_MAX);	SK_OUT16(IoC, B3_PA_TOINI_TX2, SK_PKT_TO_MAX);	/*	 * enable timeout timers if jumbo frames not used	 * NOTE: the packet arbiter timeout interrupt is needed for	 * half duplex hangup workaround	 */	if (pAC->GIni.GIPortUsage != SK_JUMBO_LINK) {		if (pAC->GIni.GIMacsFound == 1) {			SK_OUT16(IoC, B3_PA_CTRL, PA_ENA_TO_TX1);		}		else {			SK_OUT16(IoC, B3_PA_CTRL, PA_ENA_TO_TX1 | PA_ENA_TO_TX2);		}	}}	/* SkGeInitPktArb *//****************************************************************************** * *	SkGeInitMacFifo() - Initialize the MAC FIFOs * * Description: *	Initialize all MAC FIFOs of the specified port * * Returns: *	nothing */static void SkGeInitMacFifo(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port)		/* Port Index (MAC_1 + n) */{	SK_U16	Word;#ifdef VCPU	SK_U32	DWord;#endif /* VCPU */	/*	 * For each FIFO:	 *	- release local reset	 *	- use default value for MAC FIFO size	 *	- setup defaults for the control register	 *	- enable the FIFO	 */	Word = GMF_RX_CTRL_DEF;	if (pAC->GIni.GIGenesis) {		/* Configure Rx MAC FIFO */		SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_RST_CLR);		SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_RX_CTRL_DEF);		SK_OUT8(IoC, MR_ADDR(Port, RX_MFF_CTRL2), MFF_ENA_OP_MD);		/* Configure Tx MAC FIFO */		SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_RST_CLR);		SK_OUT16(IoC, MR_ADDR(Port, TX_MFF_CTRL1), MFF_TX_CTRL_DEF);		SK_OUT8(IoC, MR_ADDR(Port, TX_MFF_CTRL2), MFF_ENA_OP_MD);		/* Enable frame flushing if jumbo frames used */		if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK) {			SK_OUT16(IoC, MR_ADDR(Port, RX_MFF_CTRL1), MFF_ENA_FLUSH);		}	}	else {		/* set Rx GMAC FIFO Flush Mask */		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_MSK), (SK_U16)RX_FF_FL_DEF_MSK);		if (pAC->GIni.GIYukonLite && pAC->GIni.GIChipId == CHIP_ID_YUKON) {			Word &= ~GMF_RX_F_FL_ON;		}		/* Configure Rx MAC FIFO */		SK_OUT8(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_CTRL_T), Word);		/* set Rx GMAC FIFO Flush Threshold (default: 0x0a -> 56 bytes) */		SK_OUT16(IoC, MR_ADDR(Port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF);		/* Configure Tx MAC FIFO */		SK_OUT8(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U8)GMF_RST_CLR);		SK_OUT16(IoC, MR_ADDR(Port, TX_GMF_CTRL_T), (SK_U16)GMF_TX_CTRL_DEF);#ifdef VCPU		SK_IN32(IoC, MR_ADDR(Port, RX_GMF_AF_THR), &DWord);		SK_IN32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), &DWord);#endif /* VCPU */		/* set Tx GMAC FIFO Almost Empty Threshold *//*		SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), 0); */	}}	/* SkGeInitMacFifo *//****************************************************************************** * *	SkGeLoadLnkSyncCnt() - Load the Link Sync Counter and starts counting * * Description: *	This function starts the Link Sync Counter of the specified *	port and enables the generation of an Link Sync IRQ. *	The Link Sync Counter may be used to detect an active link, *	if autonegotiation is not used. * * Note: *	o To ensure receiving the Link Sync Event the LinkSyncCounter *	  should be initialized BEFORE clearing the XMAC's reset! *	o Enable IS_LNK_SYNC_M1 and IS_LNK_SYNC_M2 after calling this *	  function. * * Returns: *	nothing */void SkGeLoadLnkSyncCnt(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port,		/* Port Index (MAC_1 + n) */SK_U32	CntVal)		/* Counter value */{	SK_U32	OrgIMsk;	SK_U32	NewIMsk;	SK_U32	ISrc;	SK_BOOL	IrqPend;	/* stop counter */	SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_STOP);	/*	 * ASIC problem:	 * Each time starting the Link Sync Counter an IRQ is generated	 * by the adapter. See problem report entry from 21.07.98	 *	 * Workaround:	Disable Link Sync IRQ and clear the unexpeced IRQ	 *		if no IRQ is already pending.	 */	IrqPend = SK_FALSE;	SK_IN32(IoC, B0_ISRC, &ISrc);	SK_IN32(IoC, B0_IMSK, &OrgIMsk);	if (Port == MAC_1) {		NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M1;		if ((ISrc & IS_LNK_SYNC_M1) != 0) {			IrqPend = SK_TRUE;		}	}	else {		NewIMsk = OrgIMsk & ~IS_LNK_SYNC_M2;		if ((ISrc & IS_LNK_SYNC_M2) != 0) {			IrqPend = SK_TRUE;		}	}	if (!IrqPend) {		SK_OUT32(IoC, B0_IMSK, NewIMsk);	}	/* load counter */	SK_OUT32(IoC, MR_ADDR(Port, LNK_SYNC_INI), CntVal);	/* start counter */	SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_START);	if (!IrqPend) {		/* clear the unexpected IRQ, and restore the interrupt mask */		SK_OUT8(IoC, MR_ADDR(Port, LNK_SYNC_CTRL), LED_CLR_IRQ);		SK_OUT32(IoC, B0_IMSK, OrgIMsk);	}}	/* SkGeLoadLnkSyncCnt*//****************************************************************************** * *	SkGeCfgSync() - Configure synchronous bandwidth for this port. * * Description: *	This function may be used to configure synchronous bandwidth *	to the specified port. This may be done any time after *	initializing the port. The configuration values are NOT saved *	in the HWAC port structure and will be overwritten any *	time when stopping and starting the port. *	Any values for the synchronous configuration will be ignored *	if the size of the synchronous queue is zero! * *	The default configuration for the synchronous service is *	TXA_ENA_FSYNC. This means if the size of *	the synchronous queue is unequal zero but no specific *	synchronous bandwidth is configured, the synchronous queue *	will always have the 'unlimited' transmit priority! * *	This mode will be restored if the synchronous bandwidth is *	deallocated ('IntTime' = 0 and 'LimCount' = 0). * * Returns: *	0:	success *	1:	parameter configuration error *	2:	try to configure quality of service although no *		synchronous queue is configured */int SkGeCfgSync(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port,		/* Port Index (MAC_1 + n) */SK_U32	IntTime,	/* Interval Timer Value in units of 8ns */SK_U32	LimCount,	/* Number of bytes to transfer during IntTime */int		SyncMode)	/* Sync Mode: TXA_ENA_ALLOC | TXA_DIS_ALLOC | 0 */{	int Rtv;	Rtv = 0;	/* check the parameters */	if (LimCount > IntTime ||		(LimCount == 0 && IntTime != 0) ||		(LimCount != 0 && IntTime == 0)) {		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);		return(1);	}	if (pAC->GIni.GP[Port].PXSQSize == 0) {		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E009, SKERR_HWI_E009MSG);		return(2);	}	/* calculate register values */	IntTime = (IntTime / 2) * pAC->GIni.GIHstClkFact / 100;	LimCount = LimCount / 8;	if (IntTime > TXA_MAX_VAL || LimCount > TXA_MAX_VAL) {		SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_HWI_E010, SKERR_HWI_E010MSG);		return(1);	}	/*	 * - Enable 'Force Sync' to ensure the synchronous queue	 *   has the priority while configuring the new values.	 * - Also 'disable alloc' to ensure the settings complies	 *   to the SyncMode parameter.	 * - Disable 'Rate Control' to configure the new values.	 * - write IntTime and LimCount	 * - start 'Rate Control' and disable 'Force Sync'	 *   if Interval Timer or Limit Counter not zero.	 */	SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),		TXA_ENA_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);	SK_OUT32(IoC, MR_ADDR(Port, TXA_ITI_INI), IntTime);	SK_OUT32(IoC, MR_ADDR(Port, TXA_LIM_INI), LimCount);	SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL),		(SK_U8)(SyncMode & (TXA_ENA_ALLOC | TXA_DIS_ALLOC)));	if (IntTime != 0 || LimCount != 0) {		SK_OUT8(IoC, MR_ADDR(Port, TXA_CTRL), TXA_DIS_FSYNC | TXA_START_RC);	}	return(0);}	/* SkGeCfgSync *//****************************************************************************** * *	DoInitRamQueue() - Initialize the RAM Buffer Address of a single Queue * * Desccription: *	If the queue is used, enable and initialize it. *	Make sure the queue is still reset, if it is not used. * * Returns: *	nothing */static void DoInitRamQueue(SK_AC	*pAC,			/* adapter context */SK_IOC	IoC,			/* IO context */int		QuIoOffs,		/* Queue IO Address Offset */SK_U32	QuStartAddr,	/* Queue Start Address */SK_U32	QuEndAddr,		/* Queue End Address */int		QuType)			/* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */{	SK_U32	RxUpThresVal;	SK_U32	RxLoThresVal;	if (QuStartAddr != QuEndAddr) {		/* calculate thresholds, assume we have a big Rx queue */		RxUpThresVal = (QuEndAddr + 1 - QuStartAddr - SK_RB_ULPP) / 8;		RxLoThresVal = (QuEndAddr + 1 - QuStartAddr - SK_RB_LLPP_B)/8;		/* build HW address format */		QuStartAddr = QuStartAddr / 8;		QuEndAddr = QuEndAddr / 8;		/* release local reset */		SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_CLR);		/* configure addresses */		SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_START), QuStartAddr);		SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_END), QuEndAddr);		SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_WP), QuStartAddr);		SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RP), QuStartAddr);		switch (QuType) {		case SK_RX_SRAM_Q:			/* configure threshold for small Rx Queue */			RxLoThresVal += (SK_RB_LLPP_B - SK_RB_LLPP_S) / 8;			/* continue with SK_RX_BRAM_Q */		case SK_RX_BRAM_Q:			/* write threshold for Rx Queue */			SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_UTPP), RxUpThresVal);			SK_OUT32(IoC, RB_ADDR(QuIoOffs, RB_RX_LTPP), RxLoThresVal);			/* the high priority threshold not used */			break;		case SK_TX_RAM_Q:			/*			 * Do NOT use Store & Forward under normal operation due to			 * performance optimization (GENESIS only).			 * But if Jumbo Frames are configured (XMAC Tx FIFO is only 4 kB)			 * or YUKON is used ((GMAC Tx FIFO is only 1 kB)			 * we NEED Store & Forward of the RAM buffer.			 */			if (pAC->GIni.GIPortUsage == SK_JUMBO_LINK ||				!pAC->GIni.GIGenesis) {				/* enable Store & Forward Mode for the Tx Side */				SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_STFWD);			}			break;		}		/* set queue operational */		SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_ENA_OP_MD);	}	else {		/* ensure the queue is still disabled */		SK_OUT8(IoC, RB_ADDR(QuIoOffs, RB_CTRL), RB_RST_SET);	}}	/* DoInitRamQueue *//****************************************************************************** * *	SkGeInitRamBufs() - Initialize the RAM Buffer Queues * * Description: *	Initialize all RAM Buffer Queues of the specified port * * Returns: *	nothing */static void SkGeInitRamBufs(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port)		/* Port Index (MAC_1 + n) */{	SK_GEPORT *pPrt;	int RxQType;	pPrt = &pAC->GIni.GP[Port];	if (pPrt->PRxQSize == SK_MIN_RXQ_SIZE) {		RxQType = SK_RX_SRAM_Q; 	/* small Rx Queue */	}	else {		RxQType = SK_RX_BRAM_Q;		/* big Rx Queue */	}	DoInitRamQueue(pAC, IoC, pPrt->PRxQOff, pPrt->PRxQRamStart,		pPrt->PRxQRamEnd, RxQType);	DoInitRamQueue(pAC, IoC, pPrt->PXsQOff, pPrt->PXsQRamStart,		pPrt->PXsQRamEnd, SK_TX_RAM_Q);	DoInitRamQueue(pAC, IoC, pPrt->PXaQOff, pPrt->PXaQRamStart,		pPrt->PXaQRamEnd, SK_TX_RAM_Q);}	/* SkGeInitRamBufs *//****************************************************************************** * *	SkGeInitRamIface() - Initialize the RAM Interface * * Description: *	This function initializes the Adapters RAM Interface. * * Note: *	This function is used in the diagnostics. * * Returns: *	nothing */void SkGeInitRamIface(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC)		/* IO context */{	/* release local reset */	SK_OUT16(IoC, B3_RI_CTRL, RI_RST_CLR);	/* configure timeout values */	SK_OUT8(IoC, B3_RI_WTO_R1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XA1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XS1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_R1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XA1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XS1, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_R2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XA2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_WTO_XS2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_R2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XA2, SK_RI_TO_53);	SK_OUT8(IoC, B3_RI_RTO_XS2, SK_RI_TO_53);}	/* SkGeInitRamIface *//****************************************************************************** * *	SkGeInitBmu() - Initialize the BMU state machines * * Description: *	Initialize all BMU state machines of the specified port * * Returns: *	nothing

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -