Lines Matching +full:re +full:- +full:clocked
1 // SPDX-License-Identifier: GPL-2.0
21 #include <linux/dma-mapping.h>
25 #include <linux/platform_data/usb-omap.h>
135 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_mod_timer()
139 wait = msecs_to_jiffies(glue->wrp->poll_timeout); in dsps_mod_timer()
143 mod_timer(&musb->dev_timer, jiffies + wait); in dsps_mod_timer()
151 if (glue->vbus_irq) in dsps_mod_timer_optional()
154 dsps_mod_timer(glue, -1); in dsps_mod_timer_optional()
165 * dsps_musb_enable - enable interrupts
169 struct device *dev = musb->controller; in dsps_musb_enable()
170 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_enable()
171 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_enable()
172 void __iomem *reg_base = musb->ctrl_base; in dsps_musb_enable()
176 epmask = ((musb->epmask & wrp->txep_mask) << wrp->txep_shift) | in dsps_musb_enable()
177 ((musb->epmask & wrp->rxep_mask) << wrp->rxep_shift); in dsps_musb_enable()
178 coremask = (wrp->usb_bitmap & ~MUSB_INTR_SOF); in dsps_musb_enable()
180 musb_writel(reg_base, wrp->epintr_set, epmask); in dsps_musb_enable()
181 musb_writel(reg_base, wrp->coreintr_set, coremask); in dsps_musb_enable()
184 * and for ID change in dual-role idle mode. in dsps_musb_enable()
186 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) in dsps_musb_enable()
187 dsps_mod_timer(glue, -1); in dsps_musb_enable()
191 * dsps_musb_disable - disable HDRC and flush interrupts
195 struct device *dev = musb->controller; in dsps_musb_disable()
196 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_disable()
197 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_disable()
198 void __iomem *reg_base = musb->ctrl_base; in dsps_musb_disable()
200 musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap); in dsps_musb_disable()
201 musb_writel(reg_base, wrp->epintr_clear, in dsps_musb_disable()
202 wrp->txep_bitmap | wrp->rxep_bitmap); in dsps_musb_disable()
203 del_timer_sync(&musb->dev_timer); in dsps_musb_disable()
206 /* Caller must take musb->lock */
209 void __iomem *mregs = musb->mregs; in dsps_check_status()
210 struct device *dev = musb->controller; in dsps_check_status()
211 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_check_status()
212 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_check_status()
216 if (glue->vbus_irq) in dsps_check_status()
217 del_timer(&musb->dev_timer); in dsps_check_status()
220 * We poll because DSPS IP's won't expose several OTG-critical in dsps_check_status()
224 dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, in dsps_check_status()
225 usb_otg_state_string(musb->xceiv->otg->state)); in dsps_check_status()
227 switch (musb->xceiv->otg->state) { in dsps_check_status()
229 if (musb->port_mode == MUSB_HOST) { in dsps_check_status()
230 musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; in dsps_check_status()
237 /* keep VBUS on for host-only mode */ in dsps_check_status()
238 if (musb->port_mode == MUSB_HOST) { in dsps_check_status()
242 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); in dsps_check_status()
248 if (!glue->vbus_irq) { in dsps_check_status()
250 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in dsps_check_status()
253 musb->xceiv->otg->state = OTG_STATE_A_IDLE; in dsps_check_status()
257 if (musb->port_mode == MUSB_PERIPHERAL) in dsps_check_status()
267 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in dsps_check_status()
268 musb_writel(musb->ctrl_base, wrp->coreintr_set, in dsps_check_status()
269 MUSB_INTR_VBUSERROR << wrp->usb_shift); in dsps_check_status()
281 struct device *dev = musb->controller; in otg_timer()
286 if ((err != -EINPROGRESS) && err < 0) { in otg_timer()
293 spin_lock_irqsave(&musb->lock, flags); in otg_timer()
297 spin_unlock_irqrestore(&musb->lock, flags); in otg_timer()
305 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); in dsps_musb_clear_ep_rxintr()
306 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_clear_ep_rxintr()
308 /* musb->lock might already been held */ in dsps_musb_clear_ep_rxintr()
309 epintr = (1 << epnum) << wrp->rxep_shift; in dsps_musb_clear_ep_rxintr()
310 musb_writel(musb->ctrl_base, wrp->epintr_status, epintr); in dsps_musb_clear_ep_rxintr()
316 void __iomem *reg_base = musb->ctrl_base; in dsps_interrupt()
317 struct device *dev = musb->controller; in dsps_interrupt()
318 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_interrupt()
319 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_interrupt()
324 spin_lock_irqsave(&musb->lock, flags); in dsps_interrupt()
327 epintr = musb_readl(reg_base, wrp->epintr_status); in dsps_interrupt()
328 musb->int_rx = (epintr & wrp->rxep_bitmap) >> wrp->rxep_shift; in dsps_interrupt()
329 musb->int_tx = (epintr & wrp->txep_bitmap) >> wrp->txep_shift; in dsps_interrupt()
332 musb_writel(reg_base, wrp->epintr_status, epintr); in dsps_interrupt()
335 usbintr = musb_readl(reg_base, wrp->coreintr_status); in dsps_interrupt()
339 musb->int_usb = (usbintr & wrp->usb_bitmap) >> wrp->usb_shift; in dsps_interrupt()
341 musb_writel(reg_base, wrp->coreintr_status, usbintr); in dsps_interrupt()
343 dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n", in dsps_interrupt()
346 if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { in dsps_interrupt()
347 int drvvbus = musb_readl(reg_base, wrp->status); in dsps_interrupt()
348 void __iomem *mregs = musb->mregs; in dsps_interrupt()
352 err = musb->int_usb & MUSB_INTR_VBUSERROR; in dsps_interrupt()
357 * means it's not uncommon for bus-powered devices in dsps_interrupt()
361 * seems to allow a better one: "re"-starting sessions in dsps_interrupt()
365 musb->int_usb &= ~MUSB_INTR_VBUSERROR; in dsps_interrupt()
366 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; in dsps_interrupt()
371 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in dsps_interrupt()
374 musb->is_active = 0; in dsps_interrupt()
376 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in dsps_interrupt()
379 /* NOTE: this must complete power-on within 100 ms. */ in dsps_interrupt()
380 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", in dsps_interrupt()
382 usb_otg_state_string(musb->xceiv->otg->state), in dsps_interrupt()
388 if (musb->int_tx || musb->int_rx || musb->int_usb) in dsps_interrupt()
392 switch (musb->xceiv->otg->state) { in dsps_interrupt()
402 spin_unlock_irqrestore(&musb->lock, flags); in dsps_interrupt()
412 sprintf(buf, "%s.dsps", dev_name(musb->controller)); in dsps_musb_dbg_init()
414 glue->dbgfs_root = root; in dsps_musb_dbg_init()
416 glue->regset.regs = dsps_musb_regs; in dsps_musb_dbg_init()
417 glue->regset.nregs = ARRAY_SIZE(dsps_musb_regs); in dsps_musb_dbg_init()
418 glue->regset.base = musb->ctrl_base; in dsps_musb_dbg_init()
420 debugfs_create_regset32("regdump", S_IRUGO, root, &glue->regset); in dsps_musb_dbg_init()
426 struct device *dev = musb->controller; in dsps_musb_init()
427 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_init()
428 struct platform_device *parent = to_platform_device(dev->parent); in dsps_musb_init()
429 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_init()
439 musb->ctrl_base = reg_base; in dsps_musb_init()
442 musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent, "phys", 0); in dsps_musb_init()
443 if (IS_ERR(musb->xceiv)) in dsps_musb_init()
444 return PTR_ERR(musb->xceiv); in dsps_musb_init()
446 musb->phy = devm_phy_get(dev->parent, "usb2-phy"); in dsps_musb_init()
448 /* Returns zero if e.g. not clocked */ in dsps_musb_init()
449 rev = musb_readl(reg_base, wrp->revision); in dsps_musb_init()
451 return -ENODEV; in dsps_musb_init()
453 if (IS_ERR(musb->phy)) { in dsps_musb_init()
454 musb->phy = NULL; in dsps_musb_init()
456 ret = phy_init(musb->phy); in dsps_musb_init()
459 ret = phy_power_on(musb->phy); in dsps_musb_init()
461 phy_exit(musb->phy); in dsps_musb_init()
466 timer_setup(&musb->dev_timer, otg_timer, 0); in dsps_musb_init()
469 musb_writel(reg_base, wrp->control, (1 << wrp->reset)); in dsps_musb_init()
471 musb->isr = dsps_interrupt; in dsps_musb_init()
474 val = musb_readl(reg_base, wrp->phy_utmi); in dsps_musb_init()
475 val &= ~(1 << wrp->otg_disable); in dsps_musb_init()
476 musb_writel(musb->ctrl_base, wrp->phy_utmi, val); in dsps_musb_init()
484 val = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_musb_init()
486 glue->sw_babble_enabled = true; in dsps_musb_init()
488 musb_writeb(musb->mregs, MUSB_BABBLE_CTL, val); in dsps_musb_init()
491 dsps_mod_timer(glue, -1); in dsps_musb_init()
498 struct device *dev = musb->controller; in dsps_musb_exit()
499 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_exit()
501 del_timer_sync(&musb->dev_timer); in dsps_musb_exit()
502 phy_power_off(musb->phy); in dsps_musb_exit()
503 phy_exit(musb->phy); in dsps_musb_exit()
504 debugfs_remove_recursive(glue->dbgfs_root); in dsps_musb_exit()
511 struct device *dev = musb->controller; in dsps_musb_set_mode()
512 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_set_mode()
513 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_set_mode()
514 void __iomem *ctrl_base = musb->ctrl_base; in dsps_musb_set_mode()
517 reg = musb_readl(ctrl_base, wrp->mode); in dsps_musb_set_mode()
521 reg &= ~(1 << wrp->iddig); in dsps_musb_set_mode()
524 * if we're setting mode to host-only or device-only, we're in dsps_musb_set_mode()
528 reg |= (1 << wrp->iddig_mux); in dsps_musb_set_mode()
530 musb_writel(ctrl_base, wrp->mode, reg); in dsps_musb_set_mode()
531 musb_writel(ctrl_base, wrp->phy_utmi, 0x02); in dsps_musb_set_mode()
534 reg |= (1 << wrp->iddig); in dsps_musb_set_mode()
537 * if we're setting mode to host-only or device-only, we're in dsps_musb_set_mode()
541 reg |= (1 << wrp->iddig_mux); in dsps_musb_set_mode()
543 musb_writel(ctrl_base, wrp->mode, reg); in dsps_musb_set_mode()
546 musb_writel(ctrl_base, wrp->phy_utmi, 0x02); in dsps_musb_set_mode()
549 dev_err(glue->dev, "unsupported mode %d\n", mode); in dsps_musb_set_mode()
550 return -EINVAL; in dsps_musb_set_mode()
561 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
562 dev_dbg(musb->controller, "babble: MUSB_BABBLE_CTL value %x\n", in dsps_sw_babble_control()
568 dev_dbg(musb->controller, "STUCK_J is %s\n", in dsps_sw_babble_control()
578 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
580 musb_writeb(musb->mregs, MUSB_BABBLE_CTL, babble_ctl); in dsps_sw_babble_control()
583 dev_dbg(musb->controller, "Set TXIDLE, wait J to clear\n"); in dsps_sw_babble_control()
585 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
587 } while ((babble_ctl & MUSB_BABBLE_STUCK_J) && timeout--); in dsps_sw_babble_control()
596 dev_dbg(musb->controller, "J not cleared, misc (%x)\n", in dsps_sw_babble_control()
609 struct device *dev = musb->controller; in dsps_musb_recover()
610 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_recover()
613 if (glue->sw_babble_enabled) in dsps_musb_recover()
618 return session_restart ? 0 : -EPIPE; in dsps_musb_recover()
621 /* Similar to am35x, dm81xx support only 32-bit read operation */
624 void __iomem *fifo = hw_ep->fifo; in dsps_read_fifo32()
642 struct musb *musb = c->musb; in dsps_dma_controller_callback()
643 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); in dsps_dma_controller_callback()
644 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_callback()
656 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); in dsps_dma_controller_create()
657 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_create()
664 controller->dma_callback = dsps_dma_controller_callback; in dsps_dma_controller_create()
672 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_suspend()
679 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_resume()
727 struct device *dev = &parent->dev; in dsps_create_musb_pdev()
730 struct device_node *dn = parent->dev.of_node; in dsps_create_musb_pdev()
737 return -EINVAL; in dsps_create_musb_pdev()
751 musb = platform_device_alloc("musb-hdrc", in dsps_create_musb_pdev()
755 return -ENOMEM; in dsps_create_musb_pdev()
758 musb->dev.parent = dev; in dsps_create_musb_pdev()
759 musb->dev.dma_mask = &musb_dmamask; in dsps_create_musb_pdev()
760 musb->dev.coherent_dma_mask = musb_dmamask; in dsps_create_musb_pdev()
761 device_set_of_node_from_dev(&musb->dev, &parent->dev); in dsps_create_musb_pdev()
763 glue->musb = musb; in dsps_create_musb_pdev()
772 config = devm_kzalloc(&parent->dev, sizeof(*config), GFP_KERNEL); in dsps_create_musb_pdev()
774 ret = -ENOMEM; in dsps_create_musb_pdev()
780 config->num_eps = get_int_prop(dn, "mentor,num-eps"); in dsps_create_musb_pdev()
781 config->ram_bits = get_int_prop(dn, "mentor,ram-bits"); in dsps_create_musb_pdev()
782 config->host_port_deassert_reset_at_resume = 1; in dsps_create_musb_pdev()
789 config->multipoint = true; in dsps_create_musb_pdev()
791 config->maximum_speed = usb_get_maximum_speed(&parent->dev); in dsps_create_musb_pdev()
792 switch (config->maximum_speed) { in dsps_create_musb_pdev()
798 "(super-speed) setting in dts"); in dsps_create_musb_pdev()
801 config->maximum_speed = USB_SPEED_HIGH; in dsps_create_musb_pdev()
825 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_vbus_threaded_irq()
830 dev_dbg(glue->dev, "VBUS interrupt\n"); in dsps_vbus_threaded_irq()
841 glue->vbus_irq = platform_get_irq_byname(pdev, "vbus"); in dsps_setup_optional_vbus_irq()
842 if (glue->vbus_irq == -EPROBE_DEFER) in dsps_setup_optional_vbus_irq()
843 return -EPROBE_DEFER; in dsps_setup_optional_vbus_irq()
845 if (glue->vbus_irq <= 0) { in dsps_setup_optional_vbus_irq()
846 glue->vbus_irq = 0; in dsps_setup_optional_vbus_irq()
850 error = devm_request_threaded_irq(glue->dev, glue->vbus_irq, in dsps_setup_optional_vbus_irq()
855 glue->vbus_irq = 0; in dsps_setup_optional_vbus_irq()
858 dev_dbg(glue->dev, "VBUS irq %i configured\n", glue->vbus_irq); in dsps_setup_optional_vbus_irq()
870 if (!strcmp(pdev->name, "musb-hdrc")) in dsps_probe()
871 return -ENODEV; in dsps_probe()
873 match = of_match_node(musb_dsps_of_match, pdev->dev.of_node); in dsps_probe()
875 dev_err(&pdev->dev, "fail to get matching of_match struct\n"); in dsps_probe()
876 return -EINVAL; in dsps_probe()
878 wrp = match->data; in dsps_probe()
880 if (of_device_is_compatible(pdev->dev.of_node, "ti,musb-dm816")) in dsps_probe()
884 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); in dsps_probe()
886 return -ENOMEM; in dsps_probe()
888 glue->dev = &pdev->dev; in dsps_probe()
889 glue->wrp = wrp; in dsps_probe()
890 glue->usbss_base = of_iomap(pdev->dev.parent->of_node, 0); in dsps_probe()
891 if (!glue->usbss_base) in dsps_probe()
892 return -ENXIO; in dsps_probe()
895 pm_runtime_enable(&pdev->dev); in dsps_probe()
900 if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) { in dsps_probe()
909 platform_device_unregister(glue->musb); in dsps_probe()
911 pm_runtime_disable(&pdev->dev); in dsps_probe()
912 iounmap(glue->usbss_base); in dsps_probe()
920 platform_device_unregister(glue->musb); in dsps_remove()
922 pm_runtime_disable(&pdev->dev); in dsps_remove()
923 iounmap(glue->usbss_base); in dsps_remove()
958 { .compatible = "ti,musb-am33xx",
960 { .compatible = "ti,musb-dm816",
970 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_suspend()
971 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_suspend()
976 /* This can happen if the musb device is in -EPROBE_DEFER */ in dsps_suspend()
985 del_timer_sync(&musb->dev_timer); in dsps_suspend()
987 mbase = musb->ctrl_base; in dsps_suspend()
988 glue->context.control = musb_readl(mbase, wrp->control); in dsps_suspend()
989 glue->context.epintr = musb_readl(mbase, wrp->epintr_set); in dsps_suspend()
990 glue->context.coreintr = musb_readl(mbase, wrp->coreintr_set); in dsps_suspend()
991 glue->context.phy_utmi = musb_readl(mbase, wrp->phy_utmi); in dsps_suspend()
992 glue->context.mode = musb_readl(mbase, wrp->mode); in dsps_suspend()
993 glue->context.tx_mode = musb_readl(mbase, wrp->tx_mode); in dsps_suspend()
994 glue->context.rx_mode = musb_readl(mbase, wrp->rx_mode); in dsps_suspend()
1004 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_resume()
1005 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_resume()
1013 mbase = musb->ctrl_base; in dsps_resume()
1014 musb_writel(mbase, wrp->control, glue->context.control); in dsps_resume()
1015 musb_writel(mbase, wrp->epintr_set, glue->context.epintr); in dsps_resume()
1016 musb_writel(mbase, wrp->coreintr_set, glue->context.coreintr); in dsps_resume()
1017 musb_writel(mbase, wrp->phy_utmi, glue->context.phy_utmi); in dsps_resume()
1018 musb_writel(mbase, wrp->mode, glue->context.mode); in dsps_resume()
1019 musb_writel(mbase, wrp->tx_mode, glue->context.tx_mode); in dsps_resume()
1020 musb_writel(mbase, wrp->rx_mode, glue->context.rx_mode); in dsps_resume()
1021 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && in dsps_resume()
1022 musb->port_mode == MUSB_OTG) in dsps_resume()
1023 dsps_mod_timer(glue, -1); in dsps_resume()
1037 .name = "musb-dsps",