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

📄 skgeasf.c

📁 这是Marvell Technology Group Ltd. 4355 (rev 12)网卡在linux下的驱动程序源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
		// Nothing to do here if card return from suspend...		if (pAC->ReturningFromSuspend == 1) {		  pAC->ReturningFromSuspend = 0;		  break;		}#endif#ifdef ASF_CHECK_HIDDEN_ID  // here we will check hidden id _and_ chip id		/* check chip id */		SK_IN8( IoC, B2_CHIP_ID, &Tmp1Val8 );		switch(Tmp1Val8)		{#ifdef CHIP_ID_YUKON_EX							case CHIP_ID_YUKON_EX:		  pAC->AsfData.ChipMode = SK_GEASF_CHIP_EX;		  		  //pAC->AsfData.FlashOffs 	= ASF_FLASH_EX_OFFS;		  //pAC->AsfData.FlashOffsVer 	= ASF_FLASH_EX_OFFS_VER;		  //pAC->AsfData.FlashOffsRev 	= ASF_FLASH_EX_OFFS_REV;		  //pAC->AsfData.FlashOffsCs 	= ASF_FLASH_EX_OFFS_CS;		  //pAC->AsfData.FlashOffsGuid	= ASF_FLASH_EX_OFFS_GUID;		  //pAC->AsfData.FlashOffsAcpi	= ASF_FLASH_EX_OFFS_ACPI;		  break;#endif  //  CHIP_ID_YUKON_EX		case CHIP_ID_YUKON_EC:			/* YUKON_EC */			/* chip-id is ok, check hidden id */			SK_IN8( IoC, B2_MAC_CFG, &Tmp2Val8 );			Tmp2Val8 &= 0x03;			if( (Tmp2Val8 != 1) &&       //  88E8052				(Tmp2Val8 != 3) ) {      //  88E8050				RetCode = SK_ASF_PNMI_ERR_GENERAL;			} else {				pAC->AsfData.ChipMode = SK_GEASF_CHIP_EC;			}			break;		case CHIP_ID_YUKON_XL:			/* YUKON_2 */                        /* chip-id is ok, check hidden id */			SK_IN8( IoC, B2_MAC_CFG, &Tmp2Val8 );			Tmp2Val8 &= 0x03;			if(Tmp2Val8 != 0) {				RetCode = SK_ASF_PNMI_ERR_GENERAL;			} else {				pAC->AsfData.ChipMode = SK_GEASF_CHIP_Y2;			}			break;		default:			/* Nothing to do. Chip id does not match */			RetCode = SK_ASF_PNMI_ERR_GENERAL;			break;		}		if (RetCode != SK_ASF_PNMI_ERR_OK) {			pAC->AsfData.InitState = ASF_INIT_ERROR_CHIP_ID;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF/IPMI NOT SUPPORTED ***\n"));			/* hidden ID doesn't match (which card do we access?)			// do not set any registers			AsfDisable(pAC, IoC);			AsfResetCpu(pAC, IoC);       // reset cpu			// disable all pattern for asf/ipmi			YlciDisablePattern(pAC, IoC, 0, 4);			YlciDisablePattern(pAC, IoC, 0, 5);			YlciDisablePattern(pAC, IoC, 0, 6);			if ( (CHIP_ID_YUKON_2(pAC)) && (pAC->GIni.GIMacsFound == 2) ) {				// do not forget the second link				// disable all pattern for asf/ipmi				YlciDisablePattern(pAC, IoC, 1, 4);				YlciDisablePattern(pAC, IoC, 1, 5);				YlciDisablePattern(pAC, IoC, 1, 6);			}			*/			break;		}#endif		/* CHECK the ASF hint bits...		 * all YukonII:		 * Application Information Register auf 0x011e, Bit 7:6		 * 		 * Kodierung:		 *      0b00    kein "hint"; jetziger Zustand		 *      0b01    customer wants ASF to be loaded		 *      0b10    customer wants IPMI to be loaded		 *      0b11    customer does not want ASF or IPMI to go in here		 * 		 *  Alle bisherigen EEPROM Versionen bringen 0b00.		 */		SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** CHECK ASF hint bits ***\n"));		SK_IN32(IoC, B2_Y2_HW_RES, &TmpVal32);		switch(TmpVal32 & 0xc0) {		case 0xc0:			AsfHintBit  = 0;			IpmiHintBit = 0;			NoHintBit   = 1;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF hint bits: NO ASF/IPMI ***\n"));			break;		case 0x40:			AsfHintBit  = 1;			IpmiHintBit = 0;			NoHintBit   = 0;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF hint bits: ASF ***\n"));			break;		case 0x80:			AsfHintBit  = 0;			IpmiHintBit = 1;			NoHintBit   = 0;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF hint bits: IPMI ***\n"));			break;		default:			AsfHintBit  = 0;			IpmiHintBit = 0;			NoHintBit   = 1;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF hint bits: Default ASF/IPMI ***\n"));			break;		}		/* here we do not know which firmware we must load (ipmi or asf)... */		pAC->AsfData.OpMode = SK_GEASF_MODE_UNKNOWN;		AsfFlag  = 0;		IpmiFlag = 0;		AsfDashFlag = 0;		/* try to open the ASF binary */		if ( fw_file_exists(pAC, AsfFileName) ) {			/* here we have found the asf binary */						SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF binary file found...\n"));			AsfFlag = 1;			FwFileNameS1 = AsfFileName;			FwFileNameS2 = NULL;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("*** AsfFlag = 1 ***\n"));		} else {			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF binary file _NOT_ found!\n"));		}#ifdef USE_ASF_DASH_FW		AsfDashFlag = 1;#else		/* try to open IPMI binary */		if ( fw_file_exists(pAC, IpmiFileNameS1)  && 			fw_file_exists(pAC, IpmiFileNameS2) ) {			/* here we have found the ipmi binary */			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** IPMI binary file found...\n"));			IpmiFlag = 1;			FwFileNameS1 = IpmiFileNameS1;			FwFileNameS2 = IpmiFileNameS2;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("*** IpmiFlag = 1 ***\n"));		} else {			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** IPMI binary file _NOT_ found!\n"));		}#endif		/* set the operation mode */		if ( (AsfFlag == 1) && ( (AsfHintBit == 1) && (IpmiHintBit == 0) && (NoHintBit == 0) ) ) {		/* we are in the ASF mode */			if ( (pAC->AsfData.ChipMode == SK_GEASF_CHIP_EC) ||				(pAC->AsfData.ChipMode == SK_GEASF_CHIP_Y2) ) {				/* ASF can run on YukonEC and Yukon2 */				pAC->AsfData.OpMode = SK_GEASF_MODE_ASF;				SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** SK_GEASF_MODE_ASF ***\n"));				YlciDisablePattern(pAC, IoC, 0, 5);  //  Disable ARP pattern, OS is now responsible for ARP handling			}		} else {		/* are we in the ipmi mode ? */			if ( (IpmiFlag == 1) && ( (IpmiHintBit == 1) && (AsfHintBit == 0) && (NoHintBit == 0) ) ) {				SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("*** Ipmi bits OK - ChipMode: %x ***\n", pAC->AsfData.ChipMode));				if (pAC->AsfData.ChipMode == SK_GEASF_CHIP_Y2) {					/* IPMI can run only on Yukon2 */					pAC->AsfData.OpMode = SK_GEASF_MODE_IPMI;					/* set ASF enable bit in general register (0x0004)					 * and set the AsfEnable byte in pAC structure					 * (pAC->GIni.GIAsfEnabled = SK_TRUE)					 */					AsfEnable(pAC, IoC);					/* check if we have a dual port adapter */					if ( (CHIP_ID_YUKON_2(pAC)) && (pAC->GIni.GIMacsFound == 2) ) {						pAC->AsfData.DualMode = SK_GEASF_Y2_DUALPORT;					} else {						pAC->AsfData.DualMode = SK_GEASF_Y2_SINGLEPORT;					}					SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,						("SkAsfInit: *** SK_GEASF_MODE_IPMI (%d) ***\n", pAC->AsfData.DualMode));#if 0					/*  Disable ARP pattern, OS is now responsible for ARP handling */					YlciDisablePattern(pAC, IoC, 0, 5);					// AsfSetUpPattern(pAC, IoC, 0);					if (pAC->AsfData.DualMode == SK_GEASF_Y2_DUALPORT) {					/* Disable ARP pattern, OS is now responsible for ARP handling */						YlciDisablePattern(pAC, IoC, 1, 5);						// AsfSetUpPattern(pAC, IoC, 1);					}#endif				}			}		}#ifdef USE_ASF_DASH_FW		//  run Dash without hint bit		if (pAC->AsfData.OpMode == SK_GEASF_MODE_UNKNOWN) {		  if( (  (pAC->AsfData.ChipMode == SK_GEASF_CHIP_EC)|| 			 (pAC->AsfData.ChipMode == SK_GEASF_CHIP_EX)  ) && 		      (AsfDashFlag == 1) && (NoHintBit == 1) ) {		    // Otherwise the transmitter and the receiver will deactivated		    // if we shut down the network interface		    AsfEnable(pAC, IoC);                    // ASF can run on YukonEC without hint bits                    pAC->AsfData.OpMode = SK_GEASF_MODE_DASH;                    SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_INIT,							   ("SkAsfInit: *** DASH EC/EX(0x3) *** Chip: 0x%x DashFlag: %d NoHintBit: %d\n",								pAC->AsfData.ChipMode, AsfDashFlag, NoHintBit));		    		    /* Too early, we need to do this if interface is up */                    // YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_ARP );  //  Disable ARP pattern, OS is now responsible for ARP handling                    // YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_ICMP);  //  Disable ICMP pattern, OS is now responsible for ICMP handling		  }		}#endif		if (pAC->AsfData.OpMode == SK_GEASF_MODE_UNKNOWN) {			if( (pAC->AsfData.ChipMode == SK_GEASF_CHIP_EC) && (AsfFlag == 1) && (NoHintBit == 1) ) {			/* ASF can run on YukonEC without hint bits */				pAC->AsfData.OpMode = SK_GEASF_MODE_ASF;				SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** SK_GEASF_MODE_ASF EC ***\n"));				YlciDisablePattern(pAC, IoC, 0, 5);  //  Disable ARP pattern, OS is now responsible for ARP handling			} else {			/* error - we could not find our operation mode! */				pAC->AsfData.InitState = ASF_INIT_ERROR_OPMODE;				RetCode = SK_ASF_PNMI_ERR_GENERAL;				SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF/IPMI UNKNOWN OPMODE ***\n"));				AsfDisable(pAC, IoC);    // disable pattern matching for ASF/IPMI				AsfResetCpu(pAC, IoC);       // reset cpu				/* disable all pattern for asf/ipmi */				YlciDisablePattern(pAC, IoC, 0, 4);				YlciDisablePattern(pAC, IoC, 0, 5);				YlciDisablePattern(pAC, IoC, 0, 6);				if ( (CHIP_ID_YUKON_2(pAC)) && (pAC->GIni.GIMacsFound == 2) ) {				/* do not forget the second link				 * disable all pattern for asf/ipmi				 */					YlciDisablePattern(pAC, IoC, 1, 4);					YlciDisablePattern(pAC, IoC, 1, 5);					YlciDisablePattern(pAC, IoC, 1, 6);				}				break; // leave "case SK_INIT_IO"			}		}		/* Send CheckAlive command to CPU */		if ( ((pAC->AsfData.OpMode == SK_GEASF_MODE_ASF) ||		      (pAC->AsfData.OpMode == SK_GEASF_MODE_IPMI) ||		      (pAC->AsfData.OpMode == SK_GEASF_MODE_DASH)) &&		     (RetCode == SK_ASF_PNMI_ERR_OK) ) {		  if( AsfCheckAliveCpu( pAC, IoC ) != 1 )  { //  Not alive		    SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("           ******************************\n"));		    SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("SkAsfInit: *     CPU is NOT running !   *\n"));		    SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("           ******************************\n"));		    pAC->AsfData.CpuAlive = 0;		  } else  {		    SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("           ******************************\n"));		    SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("SkAsfInit: *        CPU is running      *\n"));		    SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("           ******************************\n"));		    pAC->AsfData.CpuAlive = 1;		    		    if( AsfHciSendCommand( pAC, IoC, YASF_HOSTCMD_DRV_HELLO, 0, 0, 0, ASF_HCI_WAIT, 3 ) != HCI_EN_CMD_READY )  {			// Nothing to say currently		    } else {			// Nothing to say currently		    }		  }		}#ifdef USE_ASF_DASH_FW		// Activate VAUX as optional powersupply		SK_OUT8(IoC, GLB_PCTRL, GLB_PCTRL_SW_VCC_OFF | GLB_PCTRL_SW_VAUX_ON | GLB_PCTRL_SW_VCC_ENA | GLB_PCTRL_SW_VAUX_ENA);		SK_IN8(IoC, GLB_PCTRL, &TmpVal8);#endif		AsfSetOsPresentBit( pAC, IoC );		break;	case SK_INIT_RUN:		SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("SkAsfInit: SK_INIT_RUN\n"));		if( pAC->AsfData.InitState != ASF_INIT_UNDEFINED ) {#ifdef USE_ASF_DASH_FW		  /* We need to reenable the OS here and the ARPs done by the HOST */		  /* as we will leave this function directly with quick break*/		  /*  Set OS Present Flag in ASF Status and Command Register */		  AsfSetOsPresentBit( pAC, IoC );		  /*  Disable ARP pattern, host system takes over the ARP handling */		  YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MAC );		  YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_MUL);		  YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_BDC);		  YlciDisablePattern(pAC, IoC, 0, ASF_DASH_PATTERN_NUM_ICMPV6);		  AsfDisableFlushFifo( pAC, IoC );		  AsfHciSendCommand( pAC, IoC, YASF_HOSTCMD_DRV_HELLO, 0, 0, 0, ASF_HCI_WAIT, 3 );#endif		  		  break;		}#ifdef USE_ASF_DASH_FW		/* try to open ASF DASH binary */		if ( fw_file_exists(pAC, DashFileNameS1)  && 			fw_file_exists(pAC, DashFileNameS2) ) {			/* here we have found the ASF DASH binary */			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF DASH binary file found...\n"));			FwFileNameS1 = DashFileNameS1;			FwFileNameS2 = DashFileNameS2;			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("*** IpmiFlag = 1 ***\n"));		} else {			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL, ("SkAsfInit: *** ASF DASH binary file _NOT_ found!\n"));		}#endif		/* START FLASH PROC */		/* Try to open the FW image file    */		if (fw_read(pAC,FwFileNameS1,&pAsfFwS1,&FileLengthS1) && 			fw_read(pAC,FwFileNameS2,&pAsfFwS2,&FileLengthS2)) {#ifndef FLASH_FROM_BINARY			printk("sk98lin: Using flash image from header file\n");#else			printk("sk98lin: Using flash image from binary file\n");#endif			/* Set the flash offset to 128k */			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("    Flash files opened:\n"));			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("          %s: size: 0x%d offs:0x%x\n", FwFileNameS1, FileLengthS1, FlashOffset));			SK_DBG_MSG(pAC, SK_DBGMOD_ASF, SK_DBGCAT_CTRL,("          %s: size: 0x%d offs:0x%x\n", FwFileNameS2, FileLengthS2, FlashOffset));#ifdef USE_ASF_DASH_FW			/*  calculate CS of the FW image */			pTmp32 = (SK_U32 *) pAsfFwS1;			for( i=0, FwCs=0; i<ASF_DASH_FLASH_SIZE_1; i+=4 )  {

⌨️ 快捷键说明

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