Beispiel #1
0
static int 
usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
	int retval =0 ;	
   	PMINI_ADAPTER psAdapter = NULL;
	PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
	struct usb_device      *udev = NULL;

//	BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usbbcm probe!!");
	if((intf == NULL) || (id == NULL))
	{
	//	BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf or id is NULL");
		return -EINVAL;
	}

	/* Allocate Adapter structure */
	if((psAdapter = kmalloc(sizeof(MINI_ADAPTER), GFP_KERNEL)) == NULL)
	{
		//BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
		return -ENOMEM;
	}
	
	memset(psAdapter, 0, sizeof(MINI_ADAPTER));

    /* Init default driver debug state */

    psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
	psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
	memset (psAdapter->stDebugState.subtype, 0, sizeof (psAdapter->stDebugState.subtype));

    /* Technically, one can start using BCM_DEBUG_PRINT after this point.
	 * However, realize that by default the Type/Subtype bitmaps are all zero now;
	 * so no prints will actually appear until the TestApp turns on debug paths via 
	 * the ioctl(); so practically speaking, in early init, no logging happens.
	 *
	 * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT
	 * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug
	 * during early init.
	 * Further, we turn this OFF once init_module() completes.
	 */

    psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff;
	BCM_SHOW_DEBUG_BITMAP(psAdapter);

	retval = InitAdapter(psAdapter);
	if(retval)
	{
		BCM_DEBUG_PRINT (psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InitAdapter Failed\n");
		AdapterFree(psAdapter);
		return retval;
	}

	/* Allocate interface adapter structure */
	if((psAdapter->pvInterfaceAdapter = 
		kmalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL)) == NULL)
	{
		BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
		AdapterFree (psAdapter);
		return -ENOMEM;
	}
	memset(psAdapter->pvInterfaceAdapter, 0, sizeof(S_INTERFACE_ADAPTER));

	psIntfAdapter = InterfaceAdapterGet(psAdapter);
	psIntfAdapter->psAdapter = psAdapter;
	
	/* Store usb interface in Interface Adapter */
	psIntfAdapter->interface = intf;
	usb_set_intfdata(intf, psIntfAdapter);

	BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%x",(unsigned int)psIntfAdapter);
	retval = InterfaceAdapterInit(psIntfAdapter);
	if(retval)
	{	
		/* If the Firmware/Cfg File is not present
 		 * then return success, let the application
 		 * download the files. 
 		 */
		if(-ENOENT == retval){
			BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "File Not Found, Use App to Download\n");
			return STATUS_SUCCESS;
		}
		BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapterInit Failed \n");
		usb_set_intfdata(intf, NULL);	
		udev = interface_to_usbdev (intf);
		usb_put_dev(udev);
		if(psAdapter->bUsbClassDriverRegistered == TRUE)
				usb_deregister_dev (intf, &usbbcm_class);
		InterfaceAdapterFree(psIntfAdapter);
		return retval ;
	}
	if(psAdapter->chip_id > T3)
	{
		uint32_t uiNackZeroLengthInt=4;
		if(wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt)))
		{
			return -EIO;;
		}
	}

	udev = interface_to_usbdev (intf);
	/* Check whether the USB-Device Supports remote Wake-Up */
	if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes) 
	{
		/* If Suspend then only support dynamic suspend */
		if(psAdapter->bDoSuspend) 
		{
			udev->autosuspend_delay = 0;
			intf->needs_remote_wakeup = 1;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
			udev->autosuspend_disabled = 0;
#else
			usb_enable_autosuspend(udev);
#endif
			device_init_wakeup(&intf->dev,1);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
			usb_autopm_disable(intf);
#endif
			INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend);
			BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Enabling USB Auto-Suspend\n");
		}
		else
		{ 
			intf->needs_remote_wakeup = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
			udev->autosuspend_disabled = 1;
#else
			usb_disable_autosuspend(udev);
#endif
		}
	}

    psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0;
    return retval;
}
void rts51x_try_to_exit_ss(struct rts51x_chip *chip)
{
	RTS51X_DEBUGP("Exit from SS state\n");
	usb_autopm_disable(chip->usb->pusb_intf);
}