bool FirmwareCheckReady(struct net_device *dev, u8 LoadFWStatus)
{
	struct r8192_priv  *priv = rtllib_priv(dev);
	bool rtStatus = true;
	rt_firmware  *pFirmware = priv->pFirmware;
	short  PollingCnt = 1000;
	u8   CPUStatus = 0;
	u32  tmpU4b;

	RT_TRACE(COMP_FIRMWARE, "--->%s(): LoadStaus(%d),", __FUNCTION__, LoadFWStatus);

	pFirmware->FWStatus = (FIRMWARE_8192S_STATUS)LoadFWStatus;	

	switch (LoadFWStatus) {
	case FW_STATUS_LOAD_IMEM:
		do {
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& IMEM_CODE_DONE)
				break;	
			udelay(5);
		} while (PollingCnt--);		
		if (!(CPUStatus & IMEM_CHK_RPT) || (PollingCnt <= 0)) {
			RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\r\n", CPUStatus);
			goto status_check_fail;			
		}
		break;

	case FW_STATUS_LOAD_EMEM:
		do {
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& EMEM_CODE_DONE)
				break;
			udelay(5);
		} while(PollingCnt--);		
		if (!(CPUStatus & EMEM_CHK_RPT) || (PollingCnt <= 0)) {
			RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\r\n", CPUStatus);
			goto status_check_fail;
		}

		rtStatus = FirmwareEnableCPU(dev);
		if (rtStatus != true) {
			RT_TRACE(COMP_ERR, "Enable CPU fail ! \n" );
			goto status_check_fail;
		}		
		break;

	case FW_STATUS_LOAD_DMEM:
		do {
			CPUStatus = read_nic_byte(dev, TCR);
			if (CPUStatus& DMEM_CODE_DONE)
				break;		
			udelay(5);
		} while(PollingCnt--);

		if (!(CPUStatus & DMEM_CODE_DONE) || (PollingCnt <= 0)) {
			RT_TRACE(COMP_ERR, "Polling  DMEM code done fail ! CPUStatus(%#x)\n", CPUStatus);
			goto status_check_fail;
		}

		RT_TRACE(COMP_FIRMWARE, "DMEM code download success, CPUStatus(%#x)\n", CPUStatus);		
		PollingCnt = 2000; 
		do {
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus & FWRDY)
				break;		
			udelay(40);
		} while(PollingCnt--);	

		RT_TRACE(COMP_FIRMWARE, "Polling Load Firmware ready, CPUStatus(%x)\n", CPUStatus);		
		if (((CPUStatus & LOAD_FW_READY) != LOAD_FW_READY) || (PollingCnt <= 0)) {
			RT_TRACE(COMP_ERR, "Polling Load Firmware ready fail ! CPUStatus(%x)\n", CPUStatus);
			goto status_check_fail;
		}

#ifdef RTL8192SE
#endif 

		tmpU4b = read_nic_dword(dev,TCR);
		write_nic_dword(dev, TCR, (tmpU4b&(~TCR_ICV)));

		tmpU4b = read_nic_dword(dev, RCR);
		write_nic_dword(dev, RCR, 
				(tmpU4b|RCR_APPFCS|RCR_APP_ICV|RCR_APP_MIC));

		RT_TRACE(COMP_FIRMWARE, "FirmwareCheckReady(): Current RCR settings(%#x)\n", tmpU4b);

#if 0
		priv->TransmitConfig = read_nic_dword_E(dev, TCR);
		RT_TRACE(COMP_FIRMWARE, "FirmwareCheckReady(): Current TCR settings(%#x)\n", priv->TransmitConfig);
#endif

		write_nic_byte(dev, LBKMD_SEL, LBK_NORMAL);		
		break;	
	default :
		RT_TRACE(COMP_FIRMWARE, "Unknown status check!\n");
		rtStatus = false;
		break;
	}

status_check_fail:
	RT_TRACE(COMP_FIRMWARE, "<---%s: LoadFWStatus(%d), rtStatus(%x)\n", __FUNCTION__,
			LoadFWStatus, rtStatus);
	return rtStatus;
}
Beispiel #2
0
bool
FirmwareCheckReady(struct net_device *dev,	u8 LoadFWStatus)
{
	struct r8192_priv 	*priv = ieee80211_priv(dev);
	RT_STATUS	rtStatus = RT_STATUS_SUCCESS;
	rt_firmware	*pFirmware = priv->pFirmware;
	int			PollingCnt = 1000;
	//u8	 	tmpU1b, CPUStatus = 0;
	u8	 	CPUStatus = 0;
	u32		tmpU4b;
	//bool		bOrgIMREnable;

	RT_TRACE(COMP_FIRMWARE, "--->FirmwareCheckReady(): LoadStaus(%d),", LoadFWStatus);

	pFirmware->FWStatus = (FIRMWARE_8192S_STATUS)LoadFWStatus;
	if( LoadFWStatus == FW_STATUS_LOAD_IMEM)
	{
		do
		{//Polling IMEM code done.
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& IMEM_CODE_DONE)
				break;

			udelay(5);
		}while(PollingCnt--);
		if(!(CPUStatus & IMEM_CHK_RPT) || PollingCnt <= 0)
		{
			RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\r\n", CPUStatus);
			return false;
		}
	}
	else if( LoadFWStatus == FW_STATUS_LOAD_EMEM)
	{//Check Put Code OK and Turn On CPU
		do
		{//Polling EMEM code done.
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& EMEM_CODE_DONE)
				break;

			udelay(5);
		}while(PollingCnt--);
		if(!(CPUStatus & EMEM_CHK_RPT))
		{
			RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\r\n", CPUStatus);
			return false;
		}

		// Turn On CPU
		rtStatus = FirmwareEnableCPU(dev);
		if(rtStatus != RT_STATUS_SUCCESS)
		{
			RT_TRACE(COMP_ERR, "Enable CPU fail ! \n" );
			return false;
		}
	}
	else if( LoadFWStatus == FW_STATUS_LOAD_DMEM)
	{
		do
		{//Polling DMEM code done
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& DMEM_CODE_DONE)
				break;

			udelay(5);
		}while(PollingCnt--);

		if(!(CPUStatus & DMEM_CODE_DONE))
		{
			RT_TRACE(COMP_ERR, "Polling  DMEM code done fail ! CPUStatus(%#x)\n", CPUStatus);
			return false;
		}

		RT_TRACE(COMP_FIRMWARE, "DMEM code download success, CPUStatus(%#x)\n", CPUStatus);

//              PollingCnt = 100; // Set polling cycle to 10ms.
              PollingCnt = 10000; // Set polling cycle to 10ms.

		do
		{//Polling Load Firmware ready
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus & FWRDY)
				break;

			udelay(100);
		}while(PollingCnt--);

		RT_TRACE(COMP_FIRMWARE, "Polling Load Firmware ready, CPUStatus(%x)\n", CPUStatus);

		//if(!(CPUStatus & LOAD_FW_READY))
		//if((CPUStatus & LOAD_FW_READY) != 0xff)
		if((CPUStatus & LOAD_FW_READY) != LOAD_FW_READY)
		{
			RT_TRACE(COMP_ERR, "Polling Load Firmware ready fail ! CPUStatus(%x)\n", CPUStatus);
			return false;
		}

	       //
              // <Roger_Notes> USB interface will update reserved followings parameters later!!
              // 2008.08.28.
              //

	       //
              // <Roger_Notes> If right here, we can set TCR/RCR to desired value
              // and config MAC lookback mode to normal mode. 2008.08.28.
              //
              tmpU4b = read_nic_dword(dev,TCR);
		write_nic_dword(dev, TCR, (tmpU4b&(~TCR_ICV)));

		tmpU4b = read_nic_dword(dev, RCR);
		write_nic_dword(dev, RCR,
			(tmpU4b|RCR_APPFCS|RCR_APP_ICV|RCR_APP_MIC));

		RT_TRACE(COMP_FIRMWARE, "FirmwareCheckReady(): Current RCR settings(%#x)\n", tmpU4b);


		// Set to normal mode.
		write_nic_byte(dev, LBKMD_SEL, LBK_NORMAL);

	}

	RT_TRACE(COMP_FIRMWARE, "<---FirmwareCheckReady(): LoadFWStatus(%d), rtStatus(%x)\n", LoadFWStatus, rtStatus);
	return (rtStatus == RT_STATUS_SUCCESS) ? true:false;
}
Beispiel #3
0
bool FirmwareCheckReady(struct net_device *dev, u8 LoadFWStatus)
{
	struct r8192_priv *priv = ieee80211_priv(dev);
	bool rtStatus = true;
	rt_firmware *pFirmware = priv->pFirmware;
	int PollingCnt = 1000;
	u8 CPUStatus = 0;
	u32 tmpU4b;

	pFirmware->FWStatus = (FIRMWARE_8192S_STATUS)LoadFWStatus;
	switch (LoadFWStatus) {
	case FW_STATUS_LOAD_IMEM:
		do { /* Polling IMEM code done. */
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& IMEM_CODE_DONE)
				break;
			udelay(5);
		} while (PollingCnt--);
		if (!(CPUStatus & IMEM_CHK_RPT) || PollingCnt <= 0) {
			RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\r\n", CPUStatus);
			goto FirmwareCheckReadyFail;
		}
		break;
	case FW_STATUS_LOAD_EMEM: /* Check Put Code OK and Turn On CPU */
		do { /* Polling EMEM code done. */
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& EMEM_CODE_DONE)
				break;
			udelay(5);
		} while (PollingCnt--);
		if (!(CPUStatus & EMEM_CHK_RPT)) {
			RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\r\n", CPUStatus);
			goto FirmwareCheckReadyFail;
		}
		/* Turn On CPU */
		if (FirmwareEnableCPU(dev) != true) {
			RT_TRACE(COMP_ERR, "%s(): failed to enable CPU",
								__func__);
			goto FirmwareCheckReadyFail;
		}
		break;
	case FW_STATUS_LOAD_DMEM:
		do { /* Polling DMEM code done */
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus& DMEM_CODE_DONE)
				break;

			udelay(5);
		} while (PollingCnt--);

		if (!(CPUStatus & DMEM_CODE_DONE)) {
			RT_TRACE(COMP_ERR, "Polling  DMEM code done fail ! CPUStatus(%#x)\n", CPUStatus);
			goto FirmwareCheckReadyFail;
		}

		RT_TRACE(COMP_FIRMWARE, "%s(): DMEM code download success, "
					"CPUStatus(%#x)",
					__func__, CPUStatus);

		PollingCnt = 10000; /* Set polling cycle to 10ms. */

		do { /* Polling Load Firmware ready */
			CPUStatus = read_nic_byte(dev, TCR);
			if(CPUStatus & FWRDY)
				break;
			udelay(100);
		} while (PollingCnt--);

		RT_TRACE(COMP_FIRMWARE, "%s(): polling load firmware ready, "
					"CPUStatus(%x)",
					__func__, CPUStatus);

		if ((CPUStatus & LOAD_FW_READY) != LOAD_FW_READY) {
			RT_TRACE(COMP_ERR, "Polling Load Firmware ready failed "
						"CPUStatus(%x)\n", CPUStatus);
			goto FirmwareCheckReadyFail;
		}
		/*
		 * USB interface will update
		 * reserved followings parameters later
		 */

	       //
              // <Roger_Notes> If right here, we can set TCR/RCR to desired value
              // and config MAC lookback mode to normal mode. 2008.08.28.
              //
              tmpU4b = read_nic_dword(dev,TCR);
		write_nic_dword(dev, TCR, (tmpU4b&(~TCR_ICV)));

		tmpU4b = read_nic_dword(dev, RCR);
		write_nic_dword(dev, RCR,
			(tmpU4b|RCR_APPFCS|RCR_APP_ICV|RCR_APP_MIC));

		RT_TRACE(COMP_FIRMWARE, "%s(): Current RCR settings(%#x)",
							__func__, tmpU4b);
		// Set to normal mode.
		write_nic_byte(dev, LBKMD_SEL, LBK_NORMAL);
		break;
	default:
		break;
	}
	RT_TRACE(COMP_FIRMWARE, "%s(): LoadFWStatus(%d), success",
							__func__, LoadFWStatus);
	return rtStatus;

FirmwareCheckReadyFail:
	rtStatus = false;
	RT_TRACE(COMP_FIRMWARE, "%s(): LoadFWStatus(%d), failed",
							__func__, LoadFWStatus);
	return rtStatus;
}