/*****************************************************************************
 *
 * 	toggleLeds - Changes the LED state of an adapter
 *
 * Description:
 *	This function changes the current state of all LEDs of an adapter so
 *	that it can be located by a user. If the requested time interval for
 *	this test has elapsed, this function cleans up everything that was 
 *	temporarily setup during the locate NIC test. This involves of course
 *	also closing or opening any adapter so that the initial board state 
 *	is recovered.
 *
 * Returns:	N/A
 *
 */
static void toggleLeds(
unsigned long ptr)  /* holds the pointer to adapter control context */
{
	DEV_NET              *pNet      = (DEV_NET*) ptr;
	SK_AC                *pAC       = pNet->pAC;
	int                   port      = pNet->PortNr;
	SK_IOC                IoC       = pAC->IoBase;
	struct SK_NET_DEVICE *pDev      = pAC->dev[port];
	int                   OtherPort = (port) ? 0 : 1;
	struct SK_NET_DEVICE *pOtherDev = pAC->dev[OtherPort];
	SK_U16                PageSelect;
	SK_BOOL               YukLedState;

	SK_U16  YukLedOn = (PHY_M_LED_MO_DUP(MO_LED_ON)  |
			    PHY_M_LED_MO_10(MO_LED_ON)   |
			    PHY_M_LED_MO_100(MO_LED_ON)  |
			    PHY_M_LED_MO_1000(MO_LED_ON) | 
			    PHY_M_LED_MO_RX(MO_LED_ON));
	SK_U16  YukLedOff = (PHY_M_LED_MO_DUP(MO_LED_OFF)  |
			     PHY_M_LED_MO_10(MO_LED_OFF)   |
			     PHY_M_LED_MO_100(MO_LED_OFF)  |
			     PHY_M_LED_MO_1000(MO_LED_OFF) | 
			     PHY_M_LED_MO_RX(MO_LED_OFF) | 
			     PHY_M_LED_MO_TX(MO_LED_OFF));

	nbrBlinkQuarterSeconds--;
	if (nbrBlinkQuarterSeconds <= 0) {
	  /*
	   * We have to stop the device again in case the device has no
	   * been up.
	   */

	  if (!boardWasDown[0]) {
	    /*
	     * The board is already up as we bring it up in case it is not.
	     */
	  } else {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
	    (*pDev->netdev_ops->ndo_stop)(pDev);
#else
	    (*pDev->stop)(pDev);
#endif
	  }
	  if (isDualNetCard) {
	    if (!boardWasDown[1]) {
	      /*
	       * The board is already up as we bring it up in case it is not.
	       */
	    } else {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
	      (*pOtherDev->netdev_ops->ndo_stop)(pOtherDev);
#else
	      (*pOtherDev->stop)(pOtherDev);
#endif
	    }
	    
	  }

	  isDualNetCard      = SK_FALSE;
	  isLocateNICrunning = SK_FALSE;
	  return;
	}
	doSwitchLEDsOn = (doSwitchLEDsOn) ? SK_FALSE : SK_TRUE;

	if ( (doSwitchLEDsOn) && (nbrBlinkQuarterSeconds > 2) ){
		if ( (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) ||
			(pAC->GIni.GIChipId == CHIP_ID_YUKON_2(pAC)) ||
			(pAC->GIni.GIChipId == CHIP_ID_YUKON_EC_U) ) {

			YukLedOn = 0;
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_INIT_CTRL(YukLedState ? 9 : 8);
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_STA1_CTRL(YukLedState ? 9 : 8);
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_STA0_CTRL(YukLedState ? 9 : 8);
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_LOS_CTRL(YukLedState ? 9 : 8);

			/* save page register */
			SkGmPhyRead(pAC, IoC, port, PHY_MARV_EXT_ADR, &PageSelect);

			/* select page 3 for LED control */
			SkGmPhyWrite(pAC, IoC, port, PHY_MARV_EXT_ADR, 3);

			SkGmPhyWrite(pAC, IoC, port, PHY_MARV_PHY_CTRL, YukLedOn);
		    
			/* restore page register */
			SkGmPhyWrite(pAC, IoC, port, PHY_MARV_EXT_ADR, PageSelect);
		} else {
			SkGmPhyWrite(pAC,IoC,port,PHY_MARV_LED_OVER,YukLedOn);	
		}
	} else {
		if ( (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) ||
			(pAC->GIni.GIChipId == CHIP_ID_YUKON_2(pAC)) ||
			(pAC->GIni.GIChipId == CHIP_ID_YUKON_EC_U) ) {

			YukLedOn = 0;
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_INIT_CTRL(YukLedState ? 9 : 8);
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_STA1_CTRL(YukLedState ? 9 : 8);
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_STA0_CTRL(YukLedState ? 9 : 8);
			YukLedState = 1;
			YukLedOn |= PHY_M_LEDC_LOS_CTRL(YukLedState ? 9 : 8);

			/* save page register */
			SkGmPhyRead(pAC, IoC, port, PHY_MARV_EXT_ADR, &PageSelect);
		    
			/* select page 3 for LED control */
			SkGmPhyWrite(pAC, IoC, port, PHY_MARV_EXT_ADR, 3);
		    
			SkGmPhyWrite(pAC, IoC, port, PHY_MARV_PHY_CTRL, YukLedOff);
		    
			/* restore page register */
			SkGmPhyWrite(pAC, IoC, port, PHY_MARV_EXT_ADR, PageSelect);
		} else {
			SkGmPhyWrite(pAC,IoC,port,PHY_MARV_LED_OVER,YukLedOff);	
		}
	}

	locateNICtimer.function = toggleLeds;
	locateNICtimer.data     = (unsigned long) pNet;
	locateNICtimer.expires  = jiffies + (HZ/4);
	add_timer(&locateNICtimer);
} 
Example #2
0
/*****************************************************************************
 *
 * 	toggleLeds - Changes the LED state of an adapter
 *
 * Description:
 *	This function changes the current state of all LEDs of an adapter so
 *	that it can be located by a user. If the requested time interval for
 *	this test has elapsed, this function cleans up everything that was 
 *	temporarily setup during the locate NIC test. This involves of course
 *	also closing or opening any adapter so that the initial board state 
 *	is recovered.
 *
 * Returns:	N/A
 *
 */
static void toggleLeds(
unsigned long ptr)  /* holds the pointer to adapter control context */
{
	DEV_NET              *pNet      = (DEV_NET*) ptr;
	SK_AC                *pAC       = pNet->pAC;
	int                   port      = pNet->PortNr;
	SK_IOC                IoC       = pAC->IoBase;
	struct SK_NET_DEVICE *pDev      = pAC->dev[port];
	int                   OtherPort = (port) ? 0 : 1;
	struct SK_NET_DEVICE *pOtherDev = pAC->dev[OtherPort];
	SK_U16                PageSelect;
	SK_BOOL               YukLedState;

	SK_U16  YukLedOn = (PHY_M_LED_MO_DUP(MO_LED_ON)  |
			    PHY_M_LED_MO_10(MO_LED_ON)   |
			    PHY_M_LED_MO_100(MO_LED_ON)  |
			    PHY_M_LED_MO_1000(MO_LED_ON) | 
			    PHY_M_LED_MO_RX(MO_LED_ON));
	SK_U16  YukLedOff = (PHY_M_LED_MO_DUP(MO_LED_OFF)  |
			     PHY_M_LED_MO_10(MO_LED_OFF)   |
			     PHY_M_LED_MO_100(MO_LED_OFF)  |
			     PHY_M_LED_MO_1000(MO_LED_OFF) | 
			     PHY_M_LED_MO_RX(MO_LED_OFF) | 
			     PHY_M_LED_MO_TX(MO_LED_OFF));

	nbrBlinkQuarterSeconds--;
	if (nbrBlinkQuarterSeconds <= 0) {
	  /*
	   * We have to stop the device again in case the device has no
	   * been up.
	   */

	  if (!boardWasDown[0]) {
	    /*
	     * The board is already up as we bring it up in case it is not.
	     */
	  } else {
	    (*pDev->netdev_ops->ndo_stop)(pDev);
	  }
	  if (isDualNetCard) {
	    if (!boardWasDown[1]) {
	      /*
	       * The board is already up as we bring it up in case it is not.
	       */
	    } else {
	      (*pOtherDev->netdev_ops->ndo_stop)(pOtherDev);
	    }
	    
	  }

	  isDualNetCard      = SK_FALSE;
	  isLocateNICrunning = SK_FALSE;
	  return;
	}
	doSwitchLEDsOn = (doSwitchLEDsOn) ? SK_FALSE : SK_TRUE;

	if ( (doSwitchLEDsOn) && (nbrBlinkQuarterSeconds > 2) ){
		if (pAC->GIni.GIGenesis) {
			SK_OUT8(IoC,MR_ADDR(port,LNK_LED_REG),(SK_U8)SK_LNK_ON);
			SkGeYellowLED(pAC,IoC,LED_ON >> 1);
			SkGeXmitLED(pAC,IoC,MR_ADDR(port,RX_LED_INI),SK_LED_TST);
			if (pAC->GIni.GP[port].PhyType == SK_PHY_BCOM) {
				SkXmPhyWrite(pAC,IoC,port,PHY_BCOM_P_EXT_CTRL,PHY_B_PEC_LED_ON);
			} else if (pAC->GIni.GP[port].PhyType == SK_PHY_LONE) {
				SkXmPhyWrite(pAC,IoC,port,PHY_LONE_LED_CFG,0x0800);
			} else {
				SkGeXmitLED(pAC,IoC,MR_ADDR(port,TX_LED_INI),SK_LED_TST);
			}
		} else {
		  if ( (pAC->GIni.GIChipId == CHIP_ID_YUKON_XL) ||