Lines Matching full:otg

3  * isp1301_omap - ISP 1301 USB transceiver, talking to OMAP OTG controller
19 #include <linux/usb/otg.h>
36 MODULE_DESCRIPTION("ISP1301 USB OTG Transceiver Driver");
55 # define WORK_UPDATE_ISP 0 /* update ISP from OTG */
56 # define WORK_UPDATE_OTG 1 /* update OTG from ISP */
111 * unless the OTG port is used only in B-peripheral mode. in enable_vbus_draw()
125 /* products will deliver OTG messages with LEDs, GUI, etc */
128 printk(KERN_NOTICE "OTG device not responding.\n"); in notresponding()
224 return usb_otg_state_string(isp->phy.otg->state); in state_name()
234 * while OTG is running.
239 isp->phy.otg->state = OTG_STATE_UNDEFINED; in power_down()
268 if (!isp->phy.otg->host) in host_suspend()
271 /* Currently ASSUMES only the OTG port matters; in host_suspend()
274 dev = isp->phy.otg->host->controller; in host_suspend()
286 if (!isp->phy.otg->host) in host_resume()
289 dev = isp->phy.otg->host->controller; in host_resume()
296 isp->phy.otg->gadget->b_hnp_enable = 0; in gadget_suspend()
297 isp->phy.otg->gadget->a_hnp_support = 0; in gadget_suspend()
298 isp->phy.otg->gadget->a_alt_hnp_support = 0; in gadget_suspend()
299 return usb_gadget_vbus_disconnect(isp->phy.otg->gadget); in gadget_suspend()
329 if (isp->phy.otg->state == OTG_STATE_A_IDLE) in a_idle()
332 isp->phy.otg->default_a = 1; in a_idle()
333 if (isp->phy.otg->host) { in a_idle()
334 isp->phy.otg->host->is_b_host = 0; in a_idle()
337 if (isp->phy.otg->gadget) { in a_idle()
338 isp->phy.otg->gadget->is_a_peripheral = 1; in a_idle()
341 isp->phy.otg->state = OTG_STATE_A_IDLE; in a_idle()
353 if (isp->phy.otg->state == OTG_STATE_B_IDLE) in b_idle()
356 isp->phy.otg->default_a = 0; in b_idle()
357 if (isp->phy.otg->host) { in b_idle()
358 isp->phy.otg->host->is_b_host = 1; in b_idle()
361 if (isp->phy.otg->gadget) { in b_idle()
362 isp->phy.otg->gadget->is_a_peripheral = 0; in b_idle()
365 isp->phy.otg->state = OTG_STATE_B_IDLE; in b_idle()
379 pr_debug("otg: %06x, %s %s, otg/%02x stat/%02x.%02x\n", in dump_regs()
390 * The OMAP OTG controller handles most of the OTG state transitions.
393 * OTG inputs; OTG outputs (mostly pullup/pulldown controls) and HNP state
464 if (isp->phy.otg->state == state && !extra) in check_state()
466 pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, in check_state()
488 else if (isp->phy.otg->state == OTG_STATE_A_WAIT_VFALL) { in update_otg1()
495 if (isp->phy.otg->state == OTG_STATE_B_IDLE in update_otg1()
496 || isp->phy.otg->state in update_otg1()
503 if (isp->phy.otg->state == OTG_STATE_A_IDLE in update_otg1()
504 || isp->phy.otg->state == OTG_STATE_UNDEFINED) { in update_otg1()
538 switch (isp->phy.otg->state) { in otg_update_isp()
544 if (isp->phy.otg->gadget->b_hnp_enable) { in otg_update_isp()
545 isp->phy.otg->state = OTG_STATE_B_WAIT_ACON; in otg_update_isp()
567 # define toggle(OTG,ISP) do { \ in otg_update_isp() argument
568 if (otg_ctrl & OTG) set |= ISP; \ in otg_update_isp()
572 if (!(isp->phy.otg->host)) in otg_update_isp()
575 switch (isp->phy.otg->state) { in otg_update_isp()
586 isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL; in otg_update_isp()
595 isp->phy.otg->state = OTG_STATE_A_WAIT_VRISE; in otg_update_isp()
615 switch (isp->phy.otg->state) { in otg_update_isp()
619 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; in otg_update_isp()
625 isp->phy.otg->state = OTG_STATE_A_PERIPHERAL; in otg_update_isp()
637 dump_regs(isp, "otg->isp1301"); in otg_update_isp()
646 struct usb_otg *otg = isp->phy.otg; in omap_otg_irq() local
648 /* update ISP1301 transceiver from OTG controller */ in omap_otg_irq()
656 pr_debug("otg: B_SRP_TIMEOUT, %06x\n", omap_readl(OTG_CTRL)); in omap_otg_irq()
663 if (isp->phy.otg->state == OTG_STATE_B_SRP_INIT) in omap_otg_irq()
671 pr_debug("otg: %s B_HNP_FAIL, %06x\n", in omap_otg_irq()
681 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; in omap_otg_irq()
689 pr_debug("otg: %s SRP_DETECT, %06x\n", in omap_otg_irq()
693 switch (isp->phy.otg->state) { in omap_otg_irq()
695 if (!otg->host) in omap_otg_irq()
717 pr_info("otg: BCON_TMOUT from %s, %06x\n", in omap_otg_irq()
724 isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL; in omap_otg_irq()
732 printk(KERN_ERR "otg: %s, VBUS_ERR %04x ctrl %06x\n", in omap_otg_irq()
738 isp->phy.otg->state = OTG_STATE_A_VBUS_ERR; in omap_otg_irq()
750 printk(KERN_NOTICE "otg: %s, SWITCH to %s, ctrl %06x\n", in omap_otg_irq()
759 switch (isp->phy.otg->state) { in omap_otg_irq()
775 if (otg->host) { in omap_otg_irq()
776 switch (isp->phy.otg->state) { in omap_otg_irq()
778 isp->phy.otg->state = OTG_STATE_B_HOST; in omap_otg_irq()
783 isp->phy.otg->state = OTG_STATE_A_HOST; in omap_otg_irq()
787 isp->phy.otg->state = OTG_STATE_A_WAIT_BCON; in omap_otg_irq()
801 usb_bus_start_enum(otg->host, otg->host->otg_port); in omap_otg_irq()
836 pr_debug("otg: %s, %s %06x\n", in isp1301_otg_init()
903 /* OTG controller isn't clocked */
916 usb_gadget_vbus_connect(isp->phy.otg->gadget); in b_peripheral()
926 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; in b_peripheral()
934 struct usb_otg *otg = isp->phy.otg; in isp_update_otg() local
936 enum usb_otg_state state = isp->phy.otg->state; in isp_update_otg()
939 pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); in isp_update_otg()
944 if (otg->default_a) { in isp_update_otg()
959 isp->phy.otg->state = OTG_STATE_A_HOST; in isp_update_otg()
967 isp->phy.otg->state = OTG_STATE_A_VBUS_ERR; in isp_update_otg()
976 usb_gadget_vbus_disconnect(otg->gadget); in isp_update_otg()
983 if (otg->host && state == OTG_STATE_A_IDLE) in isp_update_otg()
993 if (otg->default_a) { in isp_update_otg()
996 isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL; in isp_update_otg()
1009 isp->phy.otg->state = OTG_STATE_B_IDLE; in isp_update_otg()
1020 switch (isp->phy.otg->state) { in isp_update_otg()
1042 if (otg->gadget && (isp_bstat & OTG_B_SESS_VLD)) { in isp_update_otg()
1054 pr_debug("otg: unsupported b-device %s\n", in isp_update_otg()
1060 if (state != isp->phy.otg->state) in isp_update_otg()
1065 /* update the OTG controller state to match the isp1301; may in isp_update_otg()
1073 dump_regs(isp, "isp1301->otg"); in isp_update_otg()
1097 /* transfer state from otg engine to isp1301 */ in isp1301_work()
1103 /* transfer state from isp1301 to otg engine */ in isp1301_work()
1118 switch (isp->phy.otg->state) { in isp1301_work()
1121 isp->phy.otg->state = OTG_STATE_A_HOST; in isp1301_work()
1130 isp->phy.otg->state = OTG_STATE_B_HOST; in isp1301_work()
1193 kfree(isp->phy.otg); in isp1301_release()
1224 * - OTG mode (dual-role), required if there's a Mini-AB connector
1229 * support the OTG mode. Other modes help testing USB controllers
1230 * in isolation from (full) OTG support, or maybe so later board
1258 isp1301_set_host(struct usb_otg *otg, struct usb_bus *host) in isp1301_set_host() argument
1260 struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); in isp1301_set_host()
1268 otg->host = NULL; in isp1301_set_host()
1273 otg->host = host; in isp1301_set_host()
1276 if (otg->gadget) in isp1301_set_host()
1282 otg->host = host; in isp1301_set_host()
1297 * the Mini-A end of an OTG cable. (Or something nonstandard in isp1301_set_host()
1314 isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) in isp1301_set_peripheral() argument
1316 struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); in isp1301_set_peripheral()
1323 if (!otg->default_a) in isp1301_set_peripheral()
1325 usb_gadget_vbus_disconnect(otg->gadget); in isp1301_set_peripheral()
1326 otg->gadget = NULL; in isp1301_set_peripheral()
1332 otg->gadget = gadget; in isp1301_set_peripheral()
1335 if (otg->host) in isp1301_set_peripheral()
1340 otg->gadget = gadget; in isp1301_set_peripheral()
1353 isp->phy.otg->state = OTG_STATE_B_IDLE; in isp1301_set_peripheral()
1388 if (dev->otg->state == OTG_STATE_B_PERIPHERAL) in isp1301_set_power()
1394 isp1301_start_srp(struct usb_otg *otg) in isp1301_start_srp() argument
1396 struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); in isp1301_start_srp()
1399 if (isp != the_transceiver || isp->phy.otg->state != OTG_STATE_B_IDLE) in isp1301_start_srp()
1409 isp->phy.otg->state = OTG_STATE_B_SRP_INIT; in isp1301_start_srp()
1411 pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), in isp1301_start_srp()
1420 isp1301_start_hnp(struct usb_otg *otg) in isp1301_start_hnp() argument
1423 struct isp1301 *isp = container_of(otg->usb_phy, struct isp1301, phy); in isp1301_start_hnp()
1428 if (otg->default_a && (otg->host == NULL || !otg->host->b_hnp_enable)) in isp1301_start_hnp()
1430 if (!otg->default_a && (otg->gadget == NULL in isp1301_start_hnp()
1431 || !otg->gadget->b_hnp_enable)) in isp1301_start_hnp()
1437 switch (isp->phy.otg->state) { in isp1301_start_hnp()
1439 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL; in isp1301_start_hnp()
1449 usb_gadget_vbus_connect(otg->gadget); in isp1301_start_hnp()
1461 pr_debug("otg: HNP %s, %06x ...\n", in isp1301_start_hnp()
1487 isp->phy.otg = kzalloc(sizeof *isp->phy.otg, GFP_KERNEL); in isp1301_probe()
1488 if (!isp->phy.otg) { in isp1301_probe()
1536 dev_dbg(&i2c->dev, "can't bind OTG\n"); in isp1301_probe()
1574 isp->phy.otg->usb_phy = &isp->phy; in isp1301_probe()
1575 isp->phy.otg->set_host = isp1301_set_host; in isp1301_probe()
1576 isp->phy.otg->set_peripheral = isp1301_set_peripheral; in isp1301_probe()
1577 isp->phy.otg->start_srp = isp1301_start_srp; in isp1301_probe()
1578 isp->phy.otg->start_hnp = isp1301_start_hnp; in isp1301_probe()
1604 kfree(isp->phy.otg); in isp1301_probe()