container_of(work, dwc_otg_pcd_t, check_vbus_work.work);
struct dwc_otg_device *otg_dev = _pcd->otg_dev;
struct dwc_otg_platform_data *pldata = otg_dev->pldata;
+ int bvalid = pldata->get_status(USB_STATUS_BVABLID);
+ int iddig = pldata->get_status(USB_STATUS_ID);
+ u8 usb_mode = otg_dev->core_if->usb_mode;
- if (pldata->get_status(USB_STATUS_BVABLID) &&
- pldata->get_status(USB_STATUS_ID)) {
- /* if usb not connect before ,then start connect */
+ if (bvalid && (iddig || (usb_mode == USB_MODE_FORCE_DEVICE))) {
+ /* If usb not connect before, then start connect */
if (_pcd->vbus_status == USB_BC_TYPE_DISCNT) {
printk("***************vbus detect*****************\n");
- if( pldata->bc_detect_cb != NULL )
- pldata->bc_detect_cb(_pcd->vbus_status =
- usb_battery_charger_detect(1));
+
+ if (pldata->bc_detect_cb && iddig)
+ pldata->bc_detect_cb(_pcd->vbus_status =
+ usb_battery_charger_detect(1));
else
_pcd->vbus_status = USB_BC_TYPE_SDP;
+
if (_pcd->conn_en) {
goto connect;
} else if (pldata->phy_status == USB_PHY_ENABLED) {
- /* do not allow to connect, suspend phy */
+ /* Do not allow to connect, suspend phy */
pldata->phy_suspend(pldata, USB_PHY_SUSPEND);
udelay(3);
pldata->clock_enable(pldata, 0);
printk("**************soft reconnect**************\n");
goto connect;
} else if (_pcd->conn_status == 2) {
- /* release pcd->wake_lock if fail to connect,
- * allow system to enter second sleep.
+ /*
+ * Release pcd->wake_lock if fail to connect,
+ * and allow system to enter deep sleep.
*/
dwc_otg_msc_unlock(_pcd);
_pcd->conn_status++;
- if (pldata->bc_detect_cb != NULL) {
+
+ if (pldata->bc_detect_cb && iddig) {
pldata->bc_detect_cb(_pcd->vbus_status =
usb_battery_charger_detect(1));
} else {
_pcd->vbus_status = USB_BC_TYPE_DCP;
}
- /* fail to connect, suspend usb phy and disable clk */
+
+ /* Fail to connect, suspend usb phy and disable clk */
if (pldata->phy_status == USB_PHY_ENABLED) {
pldata->phy_suspend(pldata, USB_PHY_SUSPEND);
udelay(3);
}
}
} else {
- if (pldata->bc_detect_cb != NULL)
+ if (pldata->bc_detect_cb && iddig)
pldata->bc_detect_cb(_pcd->vbus_status =
usb_battery_charger_detect(0));
else
}
if (pldata->phy_status == USB_PHY_ENABLED) {
- /* release wake lock */
+ /* Release wake lock */
dwc_otg_msc_unlock(_pcd);
- if (pldata->get_status(USB_STATUS_ID)) {
- /* no vbus detect here , close usb phy */
+
+ if (iddig || (usb_mode == USB_MODE_FORCE_DEVICE)) {
+ /* No vbus detect here , suspend usb phy */
pldata->phy_suspend(pldata, USB_PHY_SUSPEND);
udelay(3);
pldata->clock_enable(pldata, 0);
}
}
- /* usb phy bypass to uart mode */
+ /* Bypass usb phy to uart mode */
if (pldata->dwc_otg_uart_mode != NULL)
pldata->dwc_otg_uart_mode(pldata, PHY_UART_MODE);
}
- if (pldata->get_status(USB_STATUS_ID))
+ if (iddig || (usb_mode == USB_MODE_FORCE_DEVICE))
schedule_delayed_work(&_pcd->check_vbus_work, HZ);
return;
if (_pcd->conn_status == 0)
dwc_otg_msc_lock(_pcd);
- schedule_delayed_work(&_pcd->reconnect, 8); /* delay 8 jiffies */
+ schedule_delayed_work(&_pcd->reconnect, 8);
schedule_delayed_work(&_pcd->check_vbus_work, (HZ));
+
return;
}