static void usb_detect_works(struct work_struct *work)
{
	struct gadget_wrapper *d;
	unsigned long flags;
	int plug_in;

	d = gadget_wrapper;

	spin_lock_irqsave(&d->lock, flags);
	plug_in = d->vbus;
	spin_unlock_irqrestore(&d->lock, flags);

	mutex_lock(&udc_lock);
	if (plug_in){
		pr_info("usb detect plug in,vbus pull up\n");
		hotplug_callback(VBUS_PLUG_IN, 0);
		if(get_usb_first_enable_store_flag()){ 
		mod_timer(&d->cable_timer, jiffies + CABLE_TIMEOUT);
		__udc_startup();
 		} 
	} else {
		pr_info("usb detect plug out,vbus pull down\n");
		del_timer(&d->cable_timer);
		__udc_shutdown();
		hotplug_callback(VBUS_PLUG_OUT, cable_is_usb());
	}
	mutex_unlock(&udc_lock);
	switch_set_state(&d->sdev, !!plug_in);
}
static void cable_detect_handler(unsigned long data)
{
	int usb_cable;
	static int reenum_cnt = REENUM_CNT;
	usb_cable = cable_is_usb();

	/* in factory mode, we know the cable must be usb, so we enumerate
	 * again
	 */
	if (in_factory_mode() && !usb_cable && reenum_cnt){
		pr_info("try usb enumertation again\n");
		reenum_cnt--;
		mutex_lock(&udc_lock);
		__udc_shutdown();
		mod_timer(&gadget_wrapper->cable_timer, jiffies +
				CABLE_TIMEOUT);
		__udc_startup();
		mutex_unlock(&udc_lock);
		return;
	}

	mutex_lock(&udc_lock);
	if (!usb_cable) {
		pr_info("cable is ac adapter\n");
		__udc_shutdown();
	}
	mutex_unlock(&udc_lock);
	return;
}
static void cable2pc_detect_works(struct work_struct *work)
{
	int usb_cable;
	static int reenum_cnt = REENUM_CNT;
	struct gadget_wrapper *d;
	d = gadget_wrapper;
	usb_cable = cable_is_usb();

	/* in factory mode, we know the cable must be usb, so we enumerate
	 * again
	 */
	if (in_factory_mode() && !usb_cable && reenum_cnt){
		pr_info("try usb enumertation again\n");
		reenum_cnt--;
		mutex_lock(&udc_lock);
		__udc_shutdown();
		queue_delayed_work(d->cable2pc_wq, &d->cable2pc,CABLE_TIMEOUT);
		__udc_startup();
		mutex_unlock(&udc_lock);
		return;
	}

	mutex_lock(&udc_lock);
	if (!usb_cable) {
		pr_info("cable is ac adapter\n");
		__udc_shutdown();
	}
	mutex_unlock(&udc_lock);
	return;
}