int dthost_resume (void *host_priv) { int ret = 0; dthost_context_t *hctx = (dthost_context_t *) host_priv; ret = host_resume (hctx); return ret; }
static void check_vbus_state(struct tahvo_usb *tu) { int reg, prev_state; reg = tahvo_read_reg(TAHVO_REG_IDSR); if (reg & 0x01) { u32 l; vbus_active = 1; switch (tu->otg.state) { case OTG_STATE_B_IDLE: /* Enable the gadget driver */ if (tu->otg.gadget) usb_gadget_vbus_connect(tu->otg.gadget); /* Set B-session valid and not B-sessio ended to indicate * Vbus to be ok. */ l = omap_readl(OTG_CTRL); l &= ~OTG_BSESSEND; l |= OTG_BSESSVLD; omap_writel(l, OTG_CTRL); tu->otg.state = OTG_STATE_B_PERIPHERAL; break; case OTG_STATE_A_IDLE: /* Session is now valid assuming the USB hub is driving Vbus */ tu->otg.state = OTG_STATE_A_HOST; host_resume(tu); break; default: break; } printk("USB cable connected\n"); } else { switch (tu->otg.state) { case OTG_STATE_B_PERIPHERAL: if (tu->otg.gadget) usb_gadget_vbus_disconnect(tu->otg.gadget); tu->otg.state = OTG_STATE_B_IDLE; break; case OTG_STATE_A_HOST: tu->otg.state = OTG_STATE_A_IDLE; break; default: break; } printk("USB cable disconnected\n"); vbus_active = 0; } prev_state = tu->vbus_state; tu->vbus_state = reg & 0x01; if (prev_state != tu->vbus_state) sysfs_notify(&tu->pt_dev->dev.kobj, NULL, "vbus_state"); }
static void isp1301_work(struct work_struct *work) { struct isp1301 *isp = container_of(work, struct isp1301, work); int stop; /* implicit lock: we're the only task using this device */ isp->working = 1; do { stop = test_bit(WORK_STOP, &isp->todo); #ifdef CONFIG_USB_OTG /* transfer state from otg engine to isp1301 */ if (test_and_clear_bit(WORK_UPDATE_ISP, &isp->todo)) { otg_update_isp(isp); put_device(&isp->client->dev); } #endif /* transfer state from isp1301 to otg engine */ if (test_and_clear_bit(WORK_UPDATE_OTG, &isp->todo)) { u8 stat = isp1301_clear_latch(isp); isp_update_otg(isp, stat); put_device(&isp->client->dev); } if (test_and_clear_bit(WORK_HOST_RESUME, &isp->todo)) { u32 otg_ctrl; /* * skip A_WAIT_VRISE; hc transitions invisibly * skip A_WAIT_BCON; same. */ switch (isp->otg.state) { case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_VRISE: isp->otg.state = OTG_STATE_A_HOST; pr_debug(" --> a_host\n"); otg_ctrl = omap_readl(OTG_CTRL); otg_ctrl |= OTG_A_BUSREQ; otg_ctrl &= ~(OTG_BUSDROP|OTG_B_BUSREQ) & OTG_CTRL_MASK; omap_writel(otg_ctrl, OTG_CTRL); break; case OTG_STATE_B_WAIT_ACON: isp->otg.state = OTG_STATE_B_HOST; pr_debug(" --> b_host (acon)\n"); break; case OTG_STATE_B_HOST: case OTG_STATE_B_IDLE: case OTG_STATE_A_IDLE: break; default: pr_debug(" host resume in %s\n", state_name(isp)); } host_resume(isp); // mdelay(10); put_device(&isp->client->dev); } if (test_and_clear_bit(WORK_TIMER, &isp->todo)) { #ifdef VERBOSE dump_regs(isp, "timer"); if (!stop) mod_timer(&isp->timer, jiffies + TIMER_JIFFIES); #endif put_device(&isp->client->dev); } if (isp->todo) dev_vdbg(&isp->client->dev, "work done, todo = 0x%lx\n", isp->todo); if (stop) { dev_dbg(&isp->client->dev, "stop\n"); break; } } while (isp->todo); isp->working = 0; }