Lines Matching refs:musb

34 	struct platform_device	*musb;  member
40 static void tusb_musb_set_vbus(struct musb *musb, int is_on);
49 static u8 tusb_get_revision(struct musb *musb) in tusb_get_revision() argument
51 void __iomem *tbase = musb->ctrl_base; in tusb_get_revision()
66 static void tusb_print_revision(struct musb *musb) in tusb_print_revision() argument
68 void __iomem *tbase = musb->ctrl_base; in tusb_print_revision()
71 rev = musb->tusb_revision; in tusb_print_revision()
99 static void tusb_wbus_quirk(struct musb *musb, int enabled) in tusb_wbus_quirk() argument
101 void __iomem *tbase = musb->ctrl_base; in tusb_wbus_quirk()
114 dev_dbg(musb->controller, "Enabled tusb wbus quirk ctrl %08x ena %08x\n", in tusb_wbus_quirk()
123 dev_dbg(musb->controller, "Disabled tusb wbus quirk ctrl %08x ena %08x\n", in tusb_wbus_quirk()
227 struct musb *musb = hw_ep->musb; in tusb_write_fifo() local
234 dev_dbg(musb->controller, "%cX ep%d fifo %p count %d buf %p\n", in tusb_write_fifo()
277 struct musb *musb = hw_ep->musb; in tusb_read_fifo() local
282 dev_dbg(musb->controller, "%cX ep%d fifo %p count %d buf %p\n", in tusb_read_fifo()
322 static struct musb *the_musb;
332 struct musb *musb = the_musb; in tusb_draw_power() local
333 void __iomem *tbase = musb->ctrl_base; in tusb_draw_power()
346 if (x->otg->default_a || mA < (musb->min_power << 1)) in tusb_draw_power()
351 musb->is_bus_powered = 1; in tusb_draw_power()
354 musb->is_bus_powered = 0; in tusb_draw_power()
359 dev_dbg(musb->controller, "draw max %d mA VBUS\n", mA); in tusb_draw_power()
367 static void tusb_set_clock_source(struct musb *musb, unsigned mode) in tusb_set_clock_source() argument
369 void __iomem *tbase = musb->ctrl_base; in tusb_set_clock_source()
394 static void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) in tusb_allow_idle() argument
396 void __iomem *tbase = musb->ctrl_base; in tusb_allow_idle()
400 && (musb->tusb_revision == TUSB_REV_30)) in tusb_allow_idle()
401 tusb_wbus_quirk(musb, 1); in tusb_allow_idle()
403 tusb_set_clock_source(musb, 0); in tusb_allow_idle()
415 if (is_host_active(musb)) { in tusb_allow_idle()
425 dev_dbg(musb->controller, "idle, wake on %02x\n", wakeup_enables); in tusb_allow_idle()
431 static int tusb_musb_vbus_status(struct musb *musb) in tusb_musb_vbus_status() argument
433 void __iomem *tbase = musb->ctrl_base; in tusb_musb_vbus_status()
460 struct musb *musb = from_timer(musb, t, dev_timer); in musb_do_idle() local
463 spin_lock_irqsave(&musb->lock, flags); in musb_do_idle()
465 switch (musb->xceiv->otg->state) { in musb_do_idle()
467 if ((musb->a_wait_bcon != 0) in musb_do_idle()
468 && (musb->idle_timeout == 0 in musb_do_idle()
469 || time_after(jiffies, musb->idle_timeout))) { in musb_do_idle()
470 dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n", in musb_do_idle()
471 usb_otg_state_string(musb->xceiv->otg->state)); in musb_do_idle()
475 tusb_musb_set_vbus(musb, 0); in musb_do_idle()
481 if (!musb->is_active) { in musb_do_idle()
485 if (is_host_active(musb) && (musb->port1_status >> 16)) in musb_do_idle()
488 if (!musb->gadget_driver) { in musb_do_idle()
496 tusb_allow_idle(musb, wakeups); in musb_do_idle()
499 spin_unlock_irqrestore(&musb->lock, flags); in musb_do_idle()
515 static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout) in tusb_musb_try_idle() argument
524 if (musb->is_active || ((musb->a_wait_bcon == 0) in tusb_musb_try_idle()
525 && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) { in tusb_musb_try_idle()
526 dev_dbg(musb->controller, "%s active, deleting timer\n", in tusb_musb_try_idle()
527 usb_otg_state_string(musb->xceiv->otg->state)); in tusb_musb_try_idle()
528 del_timer(&musb->dev_timer); in tusb_musb_try_idle()
534 if (!timer_pending(&musb->dev_timer)) in tusb_musb_try_idle()
537 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring\n"); in tusb_musb_try_idle()
543 dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n", in tusb_musb_try_idle()
544 usb_otg_state_string(musb->xceiv->otg->state), in tusb_musb_try_idle()
546 mod_timer(&musb->dev_timer, timeout); in tusb_musb_try_idle()
556 static void tusb_musb_set_vbus(struct musb *musb, int is_on) in tusb_musb_set_vbus() argument
558 void __iomem *tbase = musb->ctrl_base; in tusb_musb_set_vbus()
561 struct usb_otg *otg = musb->xceiv->otg; in tusb_musb_set_vbus()
570 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in tusb_musb_set_vbus()
575 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in tusb_musb_set_vbus()
579 MUSB_HST_MODE(musb); in tusb_musb_set_vbus()
588 switch (musb->xceiv->otg->state) { in tusb_musb_set_vbus()
591 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; in tusb_musb_set_vbus()
594 musb->xceiv->otg->state = OTG_STATE_A_IDLE; in tusb_musb_set_vbus()
597 musb->xceiv->otg->state = OTG_STATE_A_IDLE; in tusb_musb_set_vbus()
599 musb->is_active = 0; in tusb_musb_set_vbus()
601 MUSB_HST_MODE(musb); in tusb_musb_set_vbus()
603 musb->is_active = 0; in tusb_musb_set_vbus()
605 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in tusb_musb_set_vbus()
606 MUSB_DEV_MODE(musb); in tusb_musb_set_vbus()
617 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); in tusb_musb_set_vbus()
619 dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n", in tusb_musb_set_vbus()
620 usb_otg_state_string(musb->xceiv->otg->state), in tusb_musb_set_vbus()
621 musb_readb(musb->mregs, MUSB_DEVCTL), in tusb_musb_set_vbus()
633 static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) in tusb_musb_set_mode() argument
635 void __iomem *tbase = musb->ctrl_base; in tusb_musb_set_mode()
663 dev_dbg(musb->controller, "Trying to set mode %i\n", musb_mode); in tusb_musb_set_mode()
683 tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) in tusb_otg_ints() argument
687 struct usb_otg *otg = musb->xceiv->otg; in tusb_otg_ints()
694 dev_dbg(musb->controller, "Default-%c\n", default_a ? 'A' : 'B'); in tusb_otg_ints()
696 tusb_musb_set_vbus(musb, default_a); in tusb_otg_ints()
709 musb->port1_status &= in tusb_otg_ints()
718 dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n"); in tusb_otg_ints()
719 if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) { in tusb_otg_ints()
721 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in tusb_otg_ints()
722 musb->int_usb |= MUSB_INTR_DISCONNECT; in tusb_otg_ints()
724 musb->is_active = 0; in tusb_otg_ints()
726 dev_dbg(musb->controller, "vbus change, %s, otg %03x\n", in tusb_otg_ints()
727 usb_otg_state_string(musb->xceiv->otg->state), otg_stat); in tusb_otg_ints()
729 schedule_delayed_work(&musb->irq_work, 0); in tusb_otg_ints()
732 dev_dbg(musb->controller, "vbus change, %s, otg %03x\n", in tusb_otg_ints()
733 usb_otg_state_string(musb->xceiv->otg->state), otg_stat); in tusb_otg_ints()
735 switch (musb->xceiv->otg->state) { in tusb_otg_ints()
737 dev_dbg(musb->controller, "Got SRP, turning on VBUS\n"); in tusb_otg_ints()
738 musb_platform_set_vbus(musb, 1); in tusb_otg_ints()
741 if (musb->a_wait_bcon != 0) in tusb_otg_ints()
742 musb->is_active = 0; in tusb_otg_ints()
744 musb->is_active = 1; in tusb_otg_ints()
762 if (musb->vbuserr_retry) { in tusb_otg_ints()
763 musb->vbuserr_retry--; in tusb_otg_ints()
764 tusb_musb_set_vbus(musb, 1); in tusb_otg_ints()
766 musb->vbuserr_retry in tusb_otg_ints()
768 tusb_musb_set_vbus(musb, 0); in tusb_otg_ints()
781 dev_dbg(musb->controller, "%s timer, %03x\n", in tusb_otg_ints()
782 usb_otg_state_string(musb->xceiv->otg->state), otg_stat); in tusb_otg_ints()
784 switch (musb->xceiv->otg->state) { in tusb_otg_ints()
789 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in tusb_otg_ints()
793 dev_dbg(musb->controller, "devctl %02x\n", devctl); in tusb_otg_ints()
796 musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; in tusb_otg_ints()
797 musb->is_active = 0; in tusb_otg_ints()
799 + msecs_to_jiffies(musb->a_wait_bcon); in tusb_otg_ints()
803 tusb_musb_set_vbus(musb, 0); in tusb_otg_ints()
807 if (musb->a_wait_bcon != 0) in tusb_otg_ints()
809 + msecs_to_jiffies(musb->a_wait_bcon); in tusb_otg_ints()
819 schedule_delayed_work(&musb->irq_work, 0); in tusb_otg_ints()
826 struct musb *musb = __hci; in tusb_musb_interrupt() local
827 void __iomem *tbase = musb->ctrl_base; in tusb_musb_interrupt()
831 spin_lock_irqsave(&musb->lock, flags); in tusb_musb_interrupt()
838 dev_dbg(musb->controller, "TUSB IRQ %08x\n", int_src); in tusb_musb_interrupt()
840 musb->int_usb = (u8) int_src; in tusb_musb_interrupt()
847 if (musb->tusb_revision == TUSB_REV_30) in tusb_musb_interrupt()
848 tusb_wbus_quirk(musb, 0); in tusb_musb_interrupt()
859 dev_dbg(musb->controller, "TUSB NOR not ready\n"); in tusb_musb_interrupt()
863 tusb_set_clock_source(musb, 1); in tusb_musb_interrupt()
868 musb->is_active = 1; in tusb_musb_interrupt()
869 schedule_delayed_work(&musb->irq_work, 0); in tusb_musb_interrupt()
871 dev_dbg(musb->controller, "wake %sactive %02x\n", in tusb_musb_interrupt()
872 musb->is_active ? "" : "in", reg); in tusb_musb_interrupt()
878 del_timer(&musb->dev_timer); in tusb_musb_interrupt()
884 idle_timeout = tusb_otg_ints(musb, int_src, tbase); in tusb_musb_interrupt()
893 dev_dbg(musb->controller, "DMA IRQ %08x\n", dma_src); in tusb_musb_interrupt()
902 musb->int_rx = (((musb_src >> 16) & 0xffff) << 1); in tusb_musb_interrupt()
903 musb->int_tx = (musb_src & 0xffff); in tusb_musb_interrupt()
905 musb->int_rx = 0; in tusb_musb_interrupt()
906 musb->int_tx = 0; in tusb_musb_interrupt()
910 musb_interrupt(musb); in tusb_musb_interrupt()
916 tusb_musb_try_idle(musb, idle_timeout); in tusb_musb_interrupt()
919 spin_unlock_irqrestore(&musb->lock, flags); in tusb_musb_interrupt()
931 static void tusb_musb_enable(struct musb *musb) in tusb_musb_enable() argument
933 void __iomem *tbase = musb->ctrl_base; in tusb_musb_enable()
957 irq_set_irq_type(musb->nIrq, IRQ_TYPE_LEVEL_LOW); in tusb_musb_enable()
975 static void tusb_musb_disable(struct musb *musb) in tusb_musb_disable() argument
977 void __iomem *tbase = musb->ctrl_base; in tusb_musb_disable()
987 del_timer(&musb->dev_timer); in tusb_musb_disable()
1000 static void tusb_setup_cpu_interface(struct musb *musb) in tusb_setup_cpu_interface() argument
1002 void __iomem *tbase = musb->ctrl_base; in tusb_setup_cpu_interface()
1027 static int tusb_musb_start(struct musb *musb) in tusb_musb_start() argument
1029 struct tusb6010_glue *glue = dev_get_drvdata(musb->controller->parent); in tusb_musb_start()
1030 void __iomem *tbase = musb->ctrl_base; in tusb_musb_start()
1050 spin_lock_irqsave(&musb->lock, flags); in tusb_musb_start()
1058 musb->tusb_revision = tusb_get_revision(musb); in tusb_musb_start()
1059 tusb_print_revision(musb); in tusb_musb_start()
1060 if (musb->tusb_revision < 2) { in tusb_musb_start()
1062 musb->tusb_revision); in tusb_musb_start()
1071 tusb_set_clock_source(musb, 1); in tusb_musb_start()
1082 tusb_setup_cpu_interface(musb); in tusb_musb_start()
1093 spin_unlock_irqrestore(&musb->lock, flags); in tusb_musb_start()
1098 spin_unlock_irqrestore(&musb->lock, flags); in tusb_musb_start()
1106 static int tusb_musb_init(struct musb *musb) in tusb_musb_init() argument
1113 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); in tusb_musb_init()
1114 if (IS_ERR_OR_NULL(musb->xceiv)) in tusb_musb_init()
1117 pdev = to_platform_device(musb->controller); in tusb_musb_init()
1126 musb->async = mem->start; in tusb_musb_init()
1135 musb->sync = mem->start; in tusb_musb_init()
1143 musb->sync_va = sync; in tusb_musb_init()
1148 musb->mregs += TUSB_BASE_OFFSET; in tusb_musb_init()
1150 ret = tusb_musb_start(musb); in tusb_musb_init()
1156 musb->isr = tusb_musb_interrupt; in tusb_musb_init()
1158 musb->xceiv->set_power = tusb_draw_power; in tusb_musb_init()
1159 the_musb = musb; in tusb_musb_init()
1161 timer_setup(&musb->dev_timer, musb_do_idle, 0); in tusb_musb_init()
1168 usb_put_phy(musb->xceiv); in tusb_musb_init()
1173 static int tusb_musb_exit(struct musb *musb) in tusb_musb_exit() argument
1175 struct tusb6010_glue *glue = dev_get_drvdata(musb->controller->parent); in tusb_musb_exit()
1177 del_timer_sync(&musb->dev_timer); in tusb_musb_exit()
1183 iounmap(musb->sync_va); in tusb_musb_exit()
1185 usb_put_phy(musb->xceiv); in tusb_musb_exit()
1226 struct platform_device *musb; in tusb_probe() local
1273 glue->musb = musb = platform_device_register_full(&pinfo); in tusb_probe()
1274 if (IS_ERR(musb)) { in tusb_probe()
1275 ret = PTR_ERR(musb); in tusb_probe()
1287 platform_device_unregister(glue->musb); in tusb_remove()