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

📄 skgeinit.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 4 页
字号:
/****************************************************************************** * * Name:	skgeinit.c * Project:	GEnesis, PCI Gigabit Ethernet Adapter * Version:	$Revision: 1.63 $ * Date:	$Date: 2001/04/05 11:02:09 $ * Purpose:	Contains functions to initialize the GE HW * ******************************************************************************//****************************************************************************** * *	(C)Copyright 1998-2001 SysKonnect GmbH. * *	This program is free software; you can redistribute it and/or modify *	it under the terms of the GNU General Public License as published by *	the Free Software Foundation; either version 2 of the License, or *	(at your option) any later version. * *	The information in this file is provided "AS IS" without warranty. * ******************************************************************************//****************************************************************************** * * History: * *	$Log: skgeinit.c,v $ *	Revision 1.63  2001/04/05 11:02:09  rassmann *	Stop Port check of the STOP bit did not take 2/18 sec as wanted. *	 *	Revision 1.62  2001/02/07 07:54:21  rassmann *	Corrected copyright. *	 *	Revision 1.61  2001/01/31 15:31:40  gklug *	fix: problem with autosensing an SR8800 switch *	 *	Revision 1.60  2000/10/18 12:22:21  cgoos *	Added workaround for half duplex hangup. *	 *	Revision 1.59  2000/10/10 11:22:06  gklug *	add: in manual half duplex mode ignore carrier extension errors *	 *	Revision 1.58  2000/10/02 14:10:27  rassmann *	Reading BCOM PHY after releasing reset until it returns a valid value. *	 *	Revision 1.57  2000/08/03 14:55:28  rassmann *	Waiting for I2C to be ready before de-initializing adapter *	(prevents sensors from hanging up). *	 *	Revision 1.56  2000/07/27 12:16:48  gklug *	fix: Stop Port check of the STOP bit does now take 2/18 sec as wanted *	 *	Revision 1.55  1999/11/22 13:32:26  cgoos *	Changed license header to GPL. *	 *	Revision 1.54  1999/10/26 07:32:54  malthoff *	Initialize PHWLinkUp with SK_FALSE. Required for Diagnostics. *	 *	Revision 1.53  1999/08/12 19:13:50  malthoff *	Fix for 1000BT. Do not owerwrite XM_MMU_CMD when *	disabling receiver and transmitter. Other bits *	may be lost. *	 *	Revision 1.52  1999/07/01 09:29:54  gklug *	fix: DoInitRamQueue needs pAC *	 *	Revision 1.51  1999/07/01 08:42:21  gklug *	chg: use Store & forward for RAM buffer when Jumbos are used *	 *	Revision 1.50  1999/05/27 13:19:38  cgoos *	Added Tx PCI watermark initialization. *	Removed Tx RAM queue Store & Forward setting. *	 *	Revision 1.49  1999/05/20 14:32:45  malthoff *	SkGeLinkLED() is completly removed now. *	 *	Revision 1.48  1999/05/19 07:28:24  cgoos *	SkGeLinkLED no more available for drivers. *	Changes for 1000Base-T. *	 *	Revision 1.47  1999/04/08 13:57:45  gklug *	add: Init of new port struct fiels PLinkResCt *	chg: StopPort Timer check *	 *	Revision 1.46  1999/03/25 07:42:15  malthoff *	SkGeStopPort(): Add workaround for cache incoherency. *			Create error log entry, disable port, and *			exit loop if it does not terminate. *	Add XM_RX_LENERR_OK to the default value for the *	XMAC receive command register. *	 *	Revision 1.45  1999/03/12 16:24:47  malthoff *	Remove PPollRxD and PPollTxD. *	Add check for GIPollTimerVal. * *	Revision 1.44  1999/03/12 13:40:23  malthoff *	Fix: SkGeXmitLED(), SK_LED_TST mode does not work. *	Add: Jumbo frame support. *	Chg: Resolution of parameter IntTime in SkGeCfgSync(). * *	Revision 1.43  1999/02/09 10:29:46  malthoff *	Bugfix: The previous modification again also for the second location. * *	Revision 1.42  1999/02/09 09:35:16  malthoff *	Bugfix: The bits '66 MHz Capable' and 'NEWCAP are reset while *		clearing the error bits in the PCI status register. * *	Revision 1.41  1999/01/18 13:07:02  malthoff *	Bugfix: Do not use CFG cycles after during Init- or Runtime, because *		they may not be available after Boottime. * *	Revision 1.40  1999/01/11 12:40:49  malthoff *	Bug fix: PCI_STATUS: clearing error bits sets the UDF bit. * *	Revision 1.39  1998/12/11 15:17:33  gklug *	chg: Init LipaAutoNeg with Unknown * *	Revision 1.38  1998/12/10 11:02:57  malthoff *	Disable Error Log Message when calling SkGeInit(level 2) *	more than once. * *	Revision 1.37  1998/12/07 12:18:25  gklug *	add: refinement of autosense mode: take into account the autoneg cap of LiPa * *	Revision 1.36  1998/12/07 07:10:39  gklug *	fix: init values of LinkBroken/ Capabilities for management * *	Revision 1.35  1998/12/02 10:56:20  gklug *	fix: do NOT init LoinkSync Counter. * *	Revision 1.34  1998/12/01 10:53:21  gklug *	add: init of additional Counters for workaround * *	Revision 1.33  1998/12/01 10:00:49  gklug *	add: init PIsave var in Port struct * *	Revision 1.32  1998/11/26 14:50:40  gklug *	chg: Default is autosensing with AUTOFULL mode * *	Revision 1.31  1998/11/25 15:36:16  gklug *	fix: do NOT stop LED Timer when port should be stoped * *	Revision 1.30  1998/11/24 13:15:28  gklug *	add: Init PCkeckPar struct member * *	Revision 1.29  1998/11/18 13:19:27  malthoff *	Disable packet arbiter timeouts on receive side. *	Use maximum timeout value for packet arbiter *	transmit timeouts. *	Add TestStopBit() function to handle stop RX/TX *	problem with active descriptor poll timers. *	Bug Fix: Descriptor Poll Timer not started, beacuse *	GIPollTimerVal was initilaized with 0. * *	Revision 1.28  1998/11/13 14:24:26  malthoff *	Bug Fix: SkGeStopPort() may hang if a Packet Arbiter Timout *	is pending or occurs while waiting for TX_STOP and RX_STOP. *	The PA timeout is cleared now while waiting for TX- or RX_STOP. * *	Revision 1.27  1998/11/02 11:04:36  malthoff *	fix the last fix * *	Revision 1.26  1998/11/02 10:37:03  malthoff *	Fix: SkGePollTxD() enables always the synchronounous poll timer. * *	Revision 1.25  1998/10/28 07:12:43  cgoos *	Fixed "LED_STOP" in SkGeLnkSyncCnt, "== SK_INIT_IO" in SkGeInit. *	Removed: Reset of RAM Interface in SkGeStopPort. * *	Revision 1.24  1998/10/27 08:13:12  malthoff *	Remove temporary code. * *	Revision 1.23  1998/10/26 07:45:03  malthoff *	Add Address Calculation Workaround: If the EPROM byte *	Id is 3, the address offset is 512 kB. *	Initialize default values for PLinkMode and PFlowCtrlMode. * *	Revision 1.22  1998/10/22 09:46:47  gklug *	fix SysKonnectFileId typo * *	Revision 1.21  1998/10/20 12:11:56  malthoff *	Don't dendy the Queue config if the size of the unused *	rx qeueu is zero. * *	Revision 1.20  1998/10/19 07:27:58  malthoff *	SkGeInitRamIface() is public to be called by diagnostics. * *	Revision 1.19  1998/10/16 13:33:45  malthoff *	Fix: enabling descriptor polling is not allowed until *	the descriptor addresses are set. Descriptor polling *	must be handled by the driver. * *	Revision 1.18  1998/10/16 10:58:27  malthoff *	Remove temp. code for Diag prototype. *	Remove lint warning for dummy reads. *	Call SkGeLoadLnkSyncCnt() during SkGeInitPort(). * *	Revision 1.17  1998/10/14 09:16:06  malthoff *	Change parameter LimCount and programming of *	the limit counter in SkGeCfgSync(). * *	Revision 1.16  1998/10/13 09:21:16  malthoff *	Don't set XM_RX_SELF_RX in RxCmd Reg, because it's *	like a Loopback Mode in half duplex. * *	Revision 1.15  1998/10/09 06:47:40  malthoff *	SkGeInitMacArb(): set recovery counters init value *	to zero although this counters are not uesd. *	Bug fix in Rx Upper/Lower Pause Threshold calculation. *	Add XM_RX_SELF_RX to RxCmd. * *	Revision 1.14  1998/10/06 15:15:53  malthoff *	Make sure no pending IRQ is cleared in SkGeLoadLnkSyncCnt(). * *	Revision 1.13  1998/10/06 14:09:36  malthoff *	Add SkGeLoadLnkSyncCnt(). Modify *	the 'port stopped' condition according *	to the current problem report. * *	Revision 1.12  1998/10/05 08:17:21  malthoff *	Add functions: SkGePollRxD(), SkGePollTxD(), *	DoCalcAddr(), SkGeCheckQSize(), *	DoInitRamQueue(), and SkGeCfgSync(). *	Add coding for SkGeInitMacArb(), SkGeInitPktArb(), *	SkGeInitMacFifo(), SkGeInitRamBufs(), *	SkGeInitRamIface(), and SkGeInitBmu(). * *	Revision 1.11  1998/09/29 08:26:29  malthoff *	bug fix: SkGeInit0() 'i' should be increment. * *	Revision 1.10  1998/09/28 13:19:01  malthoff *	Coding time: Save the done work. *	Modify SkGeLinkLED(), add SkGeXmitLED(), *	define SkGeCheckQSize(), SkGeInitMacArb(), *	SkGeInitPktArb(), SkGeInitMacFifo(), *	SkGeInitRamBufs(), SkGeInitRamIface(), *	and SkGeInitBmu(). Do coding for SkGeStopPort(), *	SkGeInit1(), SkGeInit2(), and SkGeInit3(). *	Do coding for SkGeDinit() and SkGeInitPort(). * *	Revision 1.9  1998/09/16 14:29:05  malthoff *	Some minor changes. * *	Revision 1.8  1998/09/11 05:29:14  gklug *	add: init state of a port * *	Revision 1.7  1998/09/04 09:26:25  malthoff *	Short temporary modification. * *	Revision 1.6  1998/09/04 08:27:59  malthoff *	Remark the do-while in StopPort() because it never ends *	without a GE adapter. * *	Revision 1.5  1998/09/03 14:05:45  malthoff *	Change comment for SkGeInitPort(). Do not *	repair the queue sizes if invalid. * *	Revision 1.4  1998/09/03 10:03:19  malthoff *	Implement the new interface according to the *	reviewed interface specification. * *	Revision 1.3  1998/08/19 09:11:25  gklug *	fix: struct are removed from c-source (see CCC) * *	Revision 1.2  1998/07/28 12:33:58  malthoff *	Add 'IoC' parameter in function declaration and SK IO macros. * *	Revision 1.1  1998/07/23 09:48:57  malthoff *	Creation. First dummy 'C' file. *	SkGeInit(Level 0) is card_start for ML. *	SkGeDeInit() is card_stop for ML. * * ******************************************************************************/#include "h/skdrv1st.h"#include "h/xmac_ii.h"#include "h/skdrv2nd.h"/* defines ********************************************************************//* defines for SkGeXmitLed() */#define XMIT_LED_INI	0#define XMIT_LED_CNT	(RX_LED_VAL - RX_LED_INI)#define XMIT_LED_CTRL	(RX_LED_CTRL- RX_LED_INI)#define XMIT_LED_TST	(RX_LED_TST - RX_LED_INI)/* Queue Size units */#define QZ_UNITS	0x7/* Types of RAM Buffer Queues */#define SK_RX_SRAM_Q	1	/* small receive queue */#define SK_RX_BRAM_Q	2	/* big receive queue */#define SK_TX_RAM_Q	3	/* small or big transmit queue *//* typedefs *******************************************************************//* global variables ***********************************************************//* local variables ************************************************************/static const char SysKonnectFileId[] =	"@(#)$Id: skgeinit.c,v 1.63 2001/04/05 11:02:09 rassmann Exp $ (C) SK ";struct s_QOffTab {	int	RxQOff;		/* Receive Queue Address Offset */	int	XsQOff;		/* Sync Tx Queue Address Offset */	int	XaQOff;		/* Async Tx Queue Address Offset */};static struct s_QOffTab QOffTab[] = {	{Q_R1, Q_XS1, Q_XA1}, {Q_R2, Q_XS2, Q_XA2}};/****************************************************************************** * *	SkGePollRxD() - Enable/Disable Descriptor Polling of RxD Ring * * Description: *	Enable or disable the descriptor polling the receive descriptor *	ring (RxD) of port 'port'. *	The new configuration is *not* saved over any SkGeStopPort() and *	SkGeInitPort() calls. * * Returns: *	nothing */void SkGePollRxD(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port,		/* Port Index (MAC_1 + n) */SK_BOOL PollRxD)	/* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */{	SK_GEPORT *pPrt;	pPrt = &pAC->GIni.GP[Port];	if (PollRxD) {		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_ENA_POL);	}	else {		SK_OUT32(IoC, Q_ADDR(pPrt->PRxQOff, Q_CSR), CSR_DIS_POL);	}}	/* SkGePollRxD *//****************************************************************************** * *	SkGePollTxD() - Enable/Disable Descriptor Polling of TxD Rings * * Description: *	Enable or disable the descriptor polling the transmit descriptor *	ring(s) (RxD) of port 'port'. *	The new configuration is *not* saved over any SkGeStopPort() and *	SkGeInitPort() calls. * * Returns: *	nothing */void SkGePollTxD(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Port,		/* Port Index (MAC_1 + n) */SK_BOOL PollTxD)	/* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */{	SK_GEPORT *pPrt;	SK_U32	DWord;	pPrt = &pAC->GIni.GP[Port];	if (PollTxD) {		DWord = CSR_ENA_POL;	}	else {		DWord = CSR_DIS_POL;	}	if (pPrt->PXSQSize != 0) {		SK_OUT32(IoC, Q_ADDR(pPrt->PXsQOff, Q_CSR), DWord);	}	if (pPrt->PXAQSize != 0) {		SK_OUT32(IoC, Q_ADDR(pPrt->PXaQOff, Q_CSR), DWord);	}}	/* SkGePollTxD *//****************************************************************************** * *	SkGeYellowLED() - Switch the yellow LED on or off. * * Description: *	Switch the yellow LED on or off. * * Note: *	This function may be called any time after SkGeInit(Level 1). * * Returns: *	nothing */void	SkGeYellowLED(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		State)		/* yellow LED state, 0 = OFF, 0 != ON */{	if (State == 0) {		/* Switch yellow LED OFF */		SK_OUT8(IoC, B0_LED, LED_STAT_OFF);	}	else {		/* Switch yellow LED ON */		SK_OUT8(IoC, B0_LED, LED_STAT_ON);	}}	/* SkGeYellowLED *//****************************************************************************** * *	SkGeXmitLED() - Modify the Operational Mode of a transmission LED. * * Description: *	The Rx or Tx LED which is specified by 'Led' will be *	enabled, disabled or switched on in test mode. * * Note: *	'Led' must contain the address offset of the LEDs INI register. * * Usage: *	SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA); * * Returns: *	nothing */void	SkGeXmitLED(SK_AC	*pAC,		/* adapter context */SK_IOC	IoC,		/* IO context */int		Led,		/* offset to the LED Init Value register */int		Mode)		/* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */{	SK_U32	LedIni;	switch (Mode) {	case SK_LED_ENA:		LedIni = SK_XMIT_DUR * (SK_U32)pAC->GIni.GIHstClkFact / 100;		SK_OUT32(IoC, Led + XMIT_LED_INI, LedIni);		SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);		break;	case SK_LED_TST:		SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_ON);		SK_OUT32(IoC, Led + XMIT_LED_CNT, 100);		SK_OUT8(IoC, Led + XMIT_LED_CTRL, LED_START);		break;	case SK_LED_DIS:	default:		/*		 * Do NOT stop the LED Timer here. The LED might be		 * in on state. But it needs to go off.		 */		SK_OUT32(IoC, Led + XMIT_LED_CNT, 0);		SK_OUT8(IoC, Led + XMIT_LED_TST, LED_T_OFF);		break;	}				/*	 * 1000BT: The Transmit LED is driven by the PHY.	 * But the default LED configuration is used for	 * Level One and Broadcom PHYs.	 * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.)	 * (In this case it has to be added here. But we will see. XXX)	 */}	/* SkGeXmitLED *//****************************************************************************** * *	DoCalcAddr() - Calculates the start and the end address of a queue. * * Description: *	This function calculates the start- end the end address *	of a queue. Afterwards the 'StartVal' is incremented to the *	next start position. *	If the port is already initialized the calculated values *	will be checked against the configured values and an *	error will be returned, if they are not equal. *	If the port is not initialized the values will be written to *	*StartAdr and *EndAddr. * * Returns: *	0:	success *	1:	configuration error */static int DoCalcAddr(SK_AC		*pAC, 			/* adapter context */SK_GEPORT	*pPrt,			/* port index */int			QuSize,			/* size of the queue to configure in kB */SK_U32		*StartVal,		/* start value for address calculation */SK_U32		*QuStartAddr,	/* start addr to calculate */

⌨️ 快捷键说明

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