コード例 #1
0
ファイル: InterfaceMisc.c プロジェクト: 3sOx/asuswrt-merlin
INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter)
{
	PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter);
	INT status = STATUS_SUCCESS ;

	/*
		 usb_clear_halt - tells device to clear endpoint halt/stall condition
		 @dev: device whose endpoint is halted
		 @pipe: endpoint "pipe" being cleared
		 @ Context: !in_interrupt ()

		usb_clear_halt is the synchrnous call and returns 0 on success else returns with error code.
		This is used to clear halt conditions for bulk and interrupt endpoints only.
		 Control and isochronous endpoints never halts.
		 
		Any URBs  queued for such an endpoint should normally be unlinked by the driver
		before clearing the halt condition.

	*/

	//Killing all the submitted urbs to different end points.	
	Bcm_kill_all_URBs(psIntfAdapter);	


	//clear the halted/stalled state for every end point
	status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sIntrIn.int_in_pipe);
	if(status != STATUS_SUCCESS)
			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Interrupt IN end point. :%d ", status);

	status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkIn.bulk_in_pipe);
	if(status != STATUS_SUCCESS)
			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk IN end point. :%d ", status);
	
	status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkOut.bulk_out_pipe);
	if(status != STATUS_SUCCESS)
			BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk OUT end point. :%d ", status);

	return status ;
}
コード例 #2
0
INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter)
{
	PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter);
	INT status = STATUS_SUCCESS;

	/*
                                                                        
                                         
                                        
                               
   
                                                                                                
                                                                                
                                                  
   
                                                                                   
                                       
   
  */

	/*                                                         */
	Bcm_kill_all_URBs(psIntfAdapter);

	/*                                                    */
	status = usb_clear_halt(psIntfAdapter->udev, psIntfAdapter->sIntrIn.int_in_pipe);
	if (status != STATUS_SUCCESS)
		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Interrupt IN end point. :%d ", status);

	status = usb_clear_halt(psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_pipe);
	if (status != STATUS_SUCCESS)
		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk IN end point. :%d ", status);

	status = usb_clear_halt(psIntfAdapter->udev, psIntfAdapter->sBulkOut.bulk_out_pipe);
	if (status != STATUS_SUCCESS)
		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk OUT end point. :%d ", status);

	return status;
}
コード例 #3
0
ファイル: InterfaceMisc.c プロジェクト: 3sOx/asuswrt-merlin
void shiftDetect(PMINI_ADAPTER Adapter) 
{   

    ULONG CurrentTime = 0;
    ULONG ulResetPattern[] = {HANDSHAKE_PATTERN1,HANDSHAKE_PATTERN2};
    UINT  uiRegRead = 0;
    int   status = 0;
    static ULONG uiHandShakeTime = 0;

    if( TRUE == Adapter->fw_download_done &&
	    FALSE == Adapter->bShutStatus &&
		FALSE == Adapter->IdleMode &&
        FALSE == Adapter->device_removed)   
    {

        //Need to read the one register to produce issue....

        status = rdmaltWithLock(Adapter,DUMMY_REG, &uiRegRead, sizeof(uiRegRead));
                
        if(status < 0) 
        {
        	BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
    	}
		else 
        {
            status = rdmaltWithLock(Adapter,CHIP_ID_REG, &uiRegRead, sizeof(uiRegRead));
            if(status < 0) 
            {
			    BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
	   		}
            else  
            { 
                if(Adapter->chip_id != uiRegRead)   
                {
                    CurrentTime = jiffies*1000/HZ;

					/* 
						Something wrong, not able to read chip id, lets try to reset and recover. 
						if does not recover after reset, try reset in TIME_TO_RESET intervals.
					*/
					
                    if((CurrentTime - uiHandShakeTime) >= TIME_TO_RESET)
					{
                        UINT uiRetries = 0;

						// Hold the RDMWRM Mutex so that RDM/WRM cannot happen while reset.
  					    
						/* 
						To ensure that InterruptOut doesn't get called 
						when device is in Idle mode...
						*/
                        			
						down(&Adapter->rdmwrmsync);  

						Adapter->StopAllXaction = TRUE;

						Bcm_kill_all_URBs(Adapter->pvInterfaceAdapter);	

						// As we are reseting the UDMA, existing mailbox counters wont be valid.
						// So mark the existing counters as used. 
						//  

						atomic_set(&Adapter->CurrNumFreeTxDesc, 0);

						((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bUDMAResetDone = FALSE;

						BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Resetting UDMA: Sending the pattern to INT OUT\n");

						/*  Send InterruptOut pattern to reset  */
						InterruptOut(Adapter,(PUCHAR)&ulResetPattern[0]);

						Adapter->StopAllXaction = FALSE;

						if(StartInterruptUrb((PS_INTERFACE_ADAPTER)Adapter->pvInterfaceAdapter))
						{
							BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB");
						}

						while(FALSE == (((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bUDMAResetDone))
						{
							uiRetries++;
							if(uiRetries >= UDMA_RST_HNDSHK_RETRY_CNT)
							{
							//
							// Handshake failed...perhaps older firmware.
							//						
								BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Resetting UDMA: Handshake failed...perhaps old fw\n");
								break;
							}
							msleep(10);
						}

						uiHandShakeTime = CurrentTime; 
						up(&Adapter->rdmwrmsync); 

					}

				}
			} 
		}
	}          
}