Lines Matching refs:musb

143 	struct platform_device *musb;	/* child musb pdev */  member
172 static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) in dsps_musb_try_idle() argument
174 struct device *dev = musb->controller; in dsps_musb_try_idle()
181 if (musb->is_active || (musb->a_wait_bcon == 0 && in dsps_musb_try_idle()
182 musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) { in dsps_musb_try_idle()
183 dev_dbg(musb->controller, "%s active, deleting timer\n", in dsps_musb_try_idle()
184 usb_otg_state_string(musb->xceiv->otg->state)); in dsps_musb_try_idle()
189 if (musb->port_mode != MUSB_PORT_MODE_DUAL_ROLE) in dsps_musb_try_idle()
192 if (!musb->g.dev.driver) in dsps_musb_try_idle()
197 dev_dbg(musb->controller, in dsps_musb_try_idle()
203 dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", in dsps_musb_try_idle()
204 usb_otg_state_string(musb->xceiv->otg->state), in dsps_musb_try_idle()
212 static void dsps_musb_enable(struct musb *musb) in dsps_musb_enable() argument
214 struct device *dev = musb->controller; in dsps_musb_enable()
218 void __iomem *reg_base = musb->ctrl_base; in dsps_musb_enable()
222 epmask = ((musb->epmask & wrp->txep_mask) << wrp->txep_shift) | in dsps_musb_enable()
223 ((musb->epmask & wrp->rxep_mask) << wrp->rxep_shift); in dsps_musb_enable()
229 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && in dsps_musb_enable()
230 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) in dsps_musb_enable()
233 dsps_musb_try_idle(musb, 0); in dsps_musb_enable()
239 static void dsps_musb_disable(struct musb *musb) in dsps_musb_disable() argument
241 struct device *dev = musb->controller; in dsps_musb_disable()
245 void __iomem *reg_base = musb->ctrl_base; in dsps_musb_disable()
250 dsps_writeb(musb->mregs, MUSB_DEVCTL, 0); in dsps_musb_disable()
255 struct musb *musb = (void *)_musb; in otg_timer() local
256 void __iomem *mregs = musb->mregs; in otg_timer()
257 struct device *dev = musb->controller; in otg_timer()
269 dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, in otg_timer()
270 usb_otg_state_string(musb->xceiv->otg->state)); in otg_timer()
272 spin_lock_irqsave(&musb->lock, flags); in otg_timer()
273 switch (musb->xceiv->otg->state) { in otg_timer()
275 dsps_writeb(musb->mregs, MUSB_DEVCTL, 0); in otg_timer()
282 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in otg_timer()
283 MUSB_DEV_MODE(musb); in otg_timer()
285 musb->xceiv->otg->state = OTG_STATE_A_IDLE; in otg_timer()
286 MUSB_HST_MODE(musb); in otg_timer()
294 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in otg_timer()
295 dsps_writel(musb->ctrl_base, wrp->coreintr_set, in otg_timer()
301 spin_unlock_irqrestore(&musb->lock, flags); in otg_timer()
306 struct musb *musb = hci; in dsps_interrupt() local
307 void __iomem *reg_base = musb->ctrl_base; in dsps_interrupt()
308 struct device *dev = musb->controller; in dsps_interrupt()
315 spin_lock_irqsave(&musb->lock, flags); in dsps_interrupt()
319 musb->int_rx = (epintr & wrp->rxep_bitmap) >> wrp->rxep_shift; in dsps_interrupt()
320 musb->int_tx = (epintr & wrp->txep_bitmap) >> wrp->txep_shift; in dsps_interrupt()
330 musb->int_usb = (usbintr & wrp->usb_bitmap) >> wrp->usb_shift; in dsps_interrupt()
334 dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n", in dsps_interrupt()
339 void __iomem *mregs = musb->mregs; in dsps_interrupt()
343 err = musb->int_usb & MUSB_INTR_VBUSERROR; in dsps_interrupt()
356 musb->int_usb &= ~MUSB_INTR_VBUSERROR; in dsps_interrupt()
357 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; in dsps_interrupt()
362 MUSB_HST_MODE(musb); in dsps_interrupt()
363 musb->xceiv->otg->default_a = 1; in dsps_interrupt()
364 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in dsps_interrupt()
367 musb->is_active = 0; in dsps_interrupt()
368 MUSB_DEV_MODE(musb); in dsps_interrupt()
369 musb->xceiv->otg->default_a = 0; in dsps_interrupt()
370 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in dsps_interrupt()
374 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", in dsps_interrupt()
376 usb_otg_state_string(musb->xceiv->otg->state), in dsps_interrupt()
382 if (musb->int_tx || musb->int_rx || musb->int_usb) in dsps_interrupt()
383 ret |= musb_interrupt(musb); in dsps_interrupt()
386 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && in dsps_interrupt()
387 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) in dsps_interrupt()
391 spin_unlock_irqrestore(&musb->lock, flags); in dsps_interrupt()
396 static int dsps_musb_dbg_init(struct musb *musb, struct dsps_glue *glue) in dsps_musb_dbg_init() argument
402 sprintf(buf, "%s.dsps", dev_name(musb->controller)); in dsps_musb_dbg_init()
410 glue->regset.base = musb->ctrl_base; in dsps_musb_dbg_init()
420 static int dsps_musb_init(struct musb *musb) in dsps_musb_init() argument
422 struct device *dev = musb->controller; in dsps_musb_init()
435 musb->ctrl_base = reg_base; in dsps_musb_init()
438 musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent, "phys", 0); in dsps_musb_init()
439 if (IS_ERR(musb->xceiv)) in dsps_musb_init()
440 return PTR_ERR(musb->xceiv); in dsps_musb_init()
442 musb->phy = devm_phy_get(dev->parent, "usb2-phy"); in dsps_musb_init()
449 usb_phy_init(musb->xceiv); in dsps_musb_init()
450 if (IS_ERR(musb->phy)) { in dsps_musb_init()
451 musb->phy = NULL; in dsps_musb_init()
453 ret = phy_init(musb->phy); in dsps_musb_init()
456 ret = phy_power_on(musb->phy); in dsps_musb_init()
458 phy_exit(musb->phy); in dsps_musb_init()
463 setup_timer(&glue->timer, otg_timer, (unsigned long) musb); in dsps_musb_init()
468 musb->isr = dsps_interrupt; in dsps_musb_init()
473 dsps_writel(musb->ctrl_base, wrp->phy_utmi, val); in dsps_musb_init()
481 val = dsps_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_musb_init()
485 dsps_writeb(musb->mregs, MUSB_BABBLE_CTL, val); in dsps_musb_init()
488 return dsps_musb_dbg_init(musb, glue); in dsps_musb_init()
491 static int dsps_musb_exit(struct musb *musb) in dsps_musb_exit() argument
493 struct device *dev = musb->controller; in dsps_musb_exit()
497 usb_phy_shutdown(musb->xceiv); in dsps_musb_exit()
498 phy_power_off(musb->phy); in dsps_musb_exit()
499 phy_exit(musb->phy); in dsps_musb_exit()
505 static int dsps_musb_set_mode(struct musb *musb, u8 mode) in dsps_musb_set_mode() argument
507 struct device *dev = musb->controller; in dsps_musb_set_mode()
510 void __iomem *ctrl_base = musb->ctrl_base; in dsps_musb_set_mode()
552 static bool dsps_sw_babble_control(struct musb *musb) in dsps_sw_babble_control() argument
557 babble_ctl = dsps_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
558 dev_dbg(musb->controller, "babble: MUSB_BABBLE_CTL value %x\n", in dsps_sw_babble_control()
564 dev_dbg(musb->controller, "STUCK_J is %s\n", in dsps_sw_babble_control()
574 babble_ctl = dsps_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
576 dsps_writeb(musb->mregs, MUSB_BABBLE_CTL, babble_ctl); in dsps_sw_babble_control()
579 dev_dbg(musb->controller, "Set TXIDLE, wait J to clear\n"); in dsps_sw_babble_control()
581 babble_ctl = dsps_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
592 dev_dbg(musb->controller, "J not cleared, misc (%x)\n", in dsps_sw_babble_control()
603 static int dsps_musb_recover(struct musb *musb) in dsps_musb_recover() argument
605 struct device *dev = musb->controller; in dsps_musb_recover()
610 session_restart = dsps_sw_babble_control(musb); in dsps_musb_recover()
692 struct platform_device *musb; in dsps_create_musb_pdev() local
712 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); in dsps_create_musb_pdev()
713 if (!musb) { in dsps_create_musb_pdev()
718 musb->dev.parent = dev; in dsps_create_musb_pdev()
719 musb->dev.dma_mask = &musb_dmamask; in dsps_create_musb_pdev()
720 musb->dev.coherent_dma_mask = musb_dmamask; in dsps_create_musb_pdev()
722 glue->musb = musb; in dsps_create_musb_pdev()
724 ret = platform_device_add_resources(musb, resources, in dsps_create_musb_pdev()
763 ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); in dsps_create_musb_pdev()
769 ret = platform_device_add(musb); in dsps_create_musb_pdev()
777 platform_device_put(musb); in dsps_create_musb_pdev()
835 platform_device_unregister(glue->musb); in dsps_remove()
889 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_suspend() local
894 if (!musb) in dsps_suspend()
898 mbase = musb->ctrl_base; in dsps_suspend()
914 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_resume() local
917 if (!musb) in dsps_resume()
920 mbase = musb->ctrl_base; in dsps_resume()
928 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && in dsps_resume()
929 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) in dsps_resume()