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()){ queue_delayed_work(d->cable2pc_wq, &d->cable2pc,CABLE_TIMEOUT); __udc_startup(); } } else { pr_info("usb detect plug out,vbus pull down\n"); cancel_delayed_work_sync(&d->cable2pc); __udc_shutdown(); hotplug_callback(VBUS_PLUG_OUT, cable_is_usb()); } mutex_unlock(&udc_lock); switch_set_state(&d->sdev, !!plug_in); }
static int pullup(struct usb_gadget *gadget, int is_on) { struct gadget_wrapper *d; int action = is_on; #ifndef DWC_DEVICE_ONLY if(!usb_get_id_state()) return 0; #endif if (gadget == 0) return -ENODEV; else d = container_of(gadget, struct gadget_wrapper, gadget); d->softconnect = is_on; #ifdef CONFIG_USB_EXTERNAL_DETECT if (!d->enabled || !d->vbus) { printk("usb: %s, d->enable = %d, d->vbus=%d \r\n",__func__, d->enabled, d->vbus); return 0; } mutex_lock(&udc_lock); if (action) { __udc_startup(); } else { __udc_shutdown(); } mutex_unlock(&udc_lock); #else if (!d->enabled || !d->vbus) action = 0; mutex_lock(&udc_lock); if (action) { queue_delayed_work(d->cable2pc_wq, &d->cable2pc,CABLE_TIMEOUT); __udc_startup(); } else { /* *this is soft disconnct, and maybe the timer started *by plugin still work, need cancel this timer like plugout */ cancel_delayed_work_sync(&d->cable2pc); __udc_shutdown(); } mutex_unlock(&udc_lock); #endif return 0; }
void dwc_udc_startup(void) { //if usb cable not connect, do nothing if (!cable_is_connected()) { pr_warning("usb cable is not connect\n"); return; } //udc not startup, startup udc and get a wacklock mutex_lock(&udc_lock); __udc_startup(); mutex_unlock(&udc_lock); }
void dwc_udc_startup(void) { //if usb cable not connect, do nothing #if 0 // not to check cable status temporary if (!cable_is_connected()) { pr_warning("usb cable is not connect\n"); return; } #endif //udc not startup, startup udc and get a wacklock mutex_lock(&udc_lock); __udc_startup(); mutex_unlock(&udc_lock); }
static int pullup(struct usb_gadget *gadget, int is_on) { struct gadget_wrapper *d; int action = is_on; if (gadget == 0) return -ENODEV; else d = container_of(gadget, struct gadget_wrapper, gadget); if (is_on) { static int enum_enabled = 0; if (unlikely(!enum_enabled)) { enum_enabled = 1; enumeration_enable(); // return 0; } } if (!d->enabled || !d->vbus) action = 0; mutex_lock(&udc_lock); if (action) { mod_timer(&d->cable_timer, jiffies + CABLE_TIMEOUT); __udc_startup(); } else { /* *this is soft disconnct, and maybe the timer started *by plugin still work, need cancel this timer like plugout */ if(timer_pending(&d->cable_timer)) del_timer(&d->cable_timer); __udc_shutdown(); } mutex_unlock(&udc_lock); return 0; }
static int pullup(struct usb_gadget *gadget, int is_on) { struct gadget_wrapper *d; int action = is_on; #ifndef DWC_DEVICE_ONLY if(!usb_get_id_state()) return 0; #endif if (gadget == 0) return -ENODEV; else d = container_of(gadget, struct gadget_wrapper, gadget); #ifdef CONFIG_USB_INTERRUPT_BY_MUIC // need to check vbus again if (!d->enabled) action = 0; #else if (!d->enabled || !d->vbus) action = 0; #endif mutex_lock(&udc_lock); if (action) { queue_delayed_work(d->cable2pc_wq, &d->cable2pc,CABLE_TIMEOUT); __udc_startup(); } else { /* *this is soft disconnct, and maybe the timer started *by plugin still work, need cancel this timer like plugout */ cancel_delayed_work_sync(&d->cable2pc); __udc_shutdown(); } mutex_unlock(&udc_lock); return 0; }