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>
137 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_mod_timer()
141 wait = msecs_to_jiffies(glue->wrp->poll_timeout); in dsps_mod_timer()
145 mod_timer(&musb->dev_timer, jiffies + wait); in dsps_mod_timer()
153 if (glue->vbus_irq) in dsps_mod_timer_optional()
156 dsps_mod_timer(glue, -1); in dsps_mod_timer_optional()
167 * dsps_musb_enable - enable interrupts
171 struct device *dev = musb->controller; in dsps_musb_enable()
172 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_enable()
173 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_enable()
174 void __iomem *reg_base = musb->ctrl_base; in dsps_musb_enable()
178 epmask = ((musb->epmask & wrp->txep_mask) << wrp->txep_shift) | in dsps_musb_enable()
179 ((musb->epmask & wrp->rxep_mask) << wrp->rxep_shift); in dsps_musb_enable()
180 coremask = (wrp->usb_bitmap & ~MUSB_INTR_SOF); in dsps_musb_enable()
182 musb_writel(reg_base, wrp->epintr_set, epmask); in dsps_musb_enable()
183 musb_writel(reg_base, wrp->coreintr_set, coremask); in dsps_musb_enable()
186 * and for ID change in dual-role idle mode. in dsps_musb_enable()
188 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) in dsps_musb_enable()
189 dsps_mod_timer(glue, -1); in dsps_musb_enable()
193 * dsps_musb_disable - disable HDRC and flush interrupts
197 struct device *dev = musb->controller; in dsps_musb_disable()
198 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_disable()
199 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_disable()
200 void __iomem *reg_base = musb->ctrl_base; in dsps_musb_disable()
202 musb_writel(reg_base, wrp->coreintr_clear, wrp->usb_bitmap); in dsps_musb_disable()
203 musb_writel(reg_base, wrp->epintr_clear, in dsps_musb_disable()
204 wrp->txep_bitmap | wrp->rxep_bitmap); in dsps_musb_disable()
205 del_timer_sync(&musb->dev_timer); in dsps_musb_disable()
208 /* Caller must take musb->lock */
211 void __iomem *mregs = musb->mregs; in dsps_check_status()
212 struct device *dev = musb->controller; in dsps_check_status()
213 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_check_status()
214 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_check_status()
218 if (glue->vbus_irq) in dsps_check_status()
219 del_timer(&musb->dev_timer); in dsps_check_status()
222 * We poll because DSPS IP's won't expose several OTG-critical in dsps_check_status()
226 dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, in dsps_check_status()
227 usb_otg_state_string(musb->xceiv->otg->state)); in dsps_check_status()
229 switch (musb->xceiv->otg->state) { in dsps_check_status()
231 if (musb->port_mode == MUSB_HOST) { in dsps_check_status()
232 musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; in dsps_check_status()
239 /* keep VBUS on for host-only mode */ in dsps_check_status()
240 if (musb->port_mode == MUSB_HOST) { in dsps_check_status()
244 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); in dsps_check_status()
250 if (!glue->vbus_irq) { in dsps_check_status()
252 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in dsps_check_status()
255 musb->xceiv->otg->state = OTG_STATE_A_IDLE; in dsps_check_status()
259 if (musb->port_mode == MUSB_PERIPHERAL) in dsps_check_status()
269 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in dsps_check_status()
270 musb_writel(musb->ctrl_base, wrp->coreintr_set, in dsps_check_status()
271 MUSB_INTR_VBUSERROR << wrp->usb_shift); in dsps_check_status()
283 struct device *dev = musb->controller; in otg_timer()
288 if ((err != -EINPROGRESS) && err < 0) { in otg_timer()
295 spin_lock_irqsave(&musb->lock, flags); in otg_timer()
299 spin_unlock_irqrestore(&musb->lock, flags); in otg_timer()
307 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); in dsps_musb_clear_ep_rxintr()
308 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_clear_ep_rxintr()
310 /* musb->lock might already been held */ in dsps_musb_clear_ep_rxintr()
311 epintr = (1 << epnum) << wrp->rxep_shift; in dsps_musb_clear_ep_rxintr()
312 musb_writel(musb->ctrl_base, wrp->epintr_status, epintr); in dsps_musb_clear_ep_rxintr()
318 void __iomem *reg_base = musb->ctrl_base; in dsps_interrupt()
319 struct device *dev = musb->controller; in dsps_interrupt()
320 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_interrupt()
321 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_interrupt()
326 spin_lock_irqsave(&musb->lock, flags); in dsps_interrupt()
329 epintr = musb_readl(reg_base, wrp->epintr_status); in dsps_interrupt()
330 musb->int_rx = (epintr & wrp->rxep_bitmap) >> wrp->rxep_shift; in dsps_interrupt()
331 musb->int_tx = (epintr & wrp->txep_bitmap) >> wrp->txep_shift; in dsps_interrupt()
334 musb_writel(reg_base, wrp->epintr_status, epintr); in dsps_interrupt()
337 usbintr = musb_readl(reg_base, wrp->coreintr_status); in dsps_interrupt()
341 musb->int_usb = (usbintr & wrp->usb_bitmap) >> wrp->usb_shift; in dsps_interrupt()
343 musb_writel(reg_base, wrp->coreintr_status, usbintr); in dsps_interrupt()
345 dev_dbg(musb->controller, "usbintr (%x) epintr(%x)\n", in dsps_interrupt()
348 if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { in dsps_interrupt()
349 int drvvbus = musb_readl(reg_base, wrp->status); in dsps_interrupt()
350 void __iomem *mregs = musb->mregs; in dsps_interrupt()
354 err = musb->int_usb & MUSB_INTR_VBUSERROR; in dsps_interrupt()
359 * means it's not uncommon for bus-powered devices in dsps_interrupt()
363 * seems to allow a better one: "re"-starting sessions in dsps_interrupt()
367 musb->int_usb &= ~MUSB_INTR_VBUSERROR; in dsps_interrupt()
368 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; in dsps_interrupt()
373 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in dsps_interrupt()
376 musb->is_active = 0; in dsps_interrupt()
378 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in dsps_interrupt()
381 /* NOTE: this must complete power-on within 100 ms. */ in dsps_interrupt()
382 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", in dsps_interrupt()
384 usb_otg_state_string(musb->xceiv->otg->state), in dsps_interrupt()
390 if (musb->int_tx || musb->int_rx || musb->int_usb) in dsps_interrupt()
394 switch (musb->xceiv->otg->state) { in dsps_interrupt()
404 spin_unlock_irqrestore(&musb->lock, flags); in dsps_interrupt()
414 sprintf(buf, "%s.dsps", dev_name(musb->controller)); in dsps_musb_dbg_init()
416 glue->dbgfs_root = root; in dsps_musb_dbg_init()
418 glue->regset.regs = dsps_musb_regs; in dsps_musb_dbg_init()
419 glue->regset.nregs = ARRAY_SIZE(dsps_musb_regs); in dsps_musb_dbg_init()
420 glue->regset.base = musb->ctrl_base; in dsps_musb_dbg_init()
422 debugfs_create_regset32("regdump", S_IRUGO, root, &glue->regset); in dsps_musb_dbg_init()
428 struct device *dev = musb->controller; in dsps_musb_init()
429 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_init()
430 struct platform_device *parent = to_platform_device(dev->parent); in dsps_musb_init()
431 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_init()
441 musb->ctrl_base = reg_base; in dsps_musb_init()
444 musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent, "phys", 0); in dsps_musb_init()
445 if (IS_ERR(musb->xceiv)) in dsps_musb_init()
446 return PTR_ERR(musb->xceiv); in dsps_musb_init()
448 musb->phy = devm_phy_get(dev->parent, "usb2-phy"); in dsps_musb_init()
450 /* Returns zero if e.g. not clocked */ in dsps_musb_init()
451 rev = musb_readl(reg_base, wrp->revision); in dsps_musb_init()
453 return -ENODEV; in dsps_musb_init()
455 if (IS_ERR(musb->phy)) { in dsps_musb_init()
456 musb->phy = NULL; in dsps_musb_init()
458 ret = phy_init(musb->phy); in dsps_musb_init()
461 ret = phy_power_on(musb->phy); in dsps_musb_init()
463 phy_exit(musb->phy); in dsps_musb_init()
468 timer_setup(&musb->dev_timer, otg_timer, 0); in dsps_musb_init()
471 musb_writel(reg_base, wrp->control, (1 << wrp->reset)); in dsps_musb_init()
473 musb->isr = dsps_interrupt; in dsps_musb_init()
476 val = musb_readl(reg_base, wrp->phy_utmi); in dsps_musb_init()
477 val &= ~(1 << wrp->otg_disable); in dsps_musb_init()
478 musb_writel(musb->ctrl_base, wrp->phy_utmi, val); in dsps_musb_init()
486 val = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_musb_init()
488 glue->sw_babble_enabled = true; in dsps_musb_init()
490 musb_writeb(musb->mregs, MUSB_BABBLE_CTL, val); in dsps_musb_init()
493 dsps_mod_timer(glue, -1); in dsps_musb_init()
500 struct device *dev = musb->controller; in dsps_musb_exit()
501 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_exit()
503 del_timer_sync(&musb->dev_timer); in dsps_musb_exit()
504 phy_power_off(musb->phy); in dsps_musb_exit()
505 phy_exit(musb->phy); in dsps_musb_exit()
506 debugfs_remove_recursive(glue->dbgfs_root); in dsps_musb_exit()
513 struct device *dev = musb->controller; in dsps_musb_set_mode()
514 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_set_mode()
515 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_musb_set_mode()
516 void __iomem *ctrl_base = musb->ctrl_base; in dsps_musb_set_mode()
519 reg = musb_readl(ctrl_base, wrp->mode); in dsps_musb_set_mode()
523 reg &= ~(1 << wrp->iddig); in dsps_musb_set_mode()
526 * if we're setting mode to host-only or device-only, we're in dsps_musb_set_mode()
530 reg |= (1 << wrp->iddig_mux); in dsps_musb_set_mode()
532 musb_writel(ctrl_base, wrp->mode, reg); in dsps_musb_set_mode()
533 musb_writel(ctrl_base, wrp->phy_utmi, 0x02); in dsps_musb_set_mode()
536 reg |= (1 << wrp->iddig); in dsps_musb_set_mode()
539 * if we're setting mode to host-only or device-only, we're in dsps_musb_set_mode()
543 reg |= (1 << wrp->iddig_mux); in dsps_musb_set_mode()
545 musb_writel(ctrl_base, wrp->mode, reg); in dsps_musb_set_mode()
548 musb_writel(ctrl_base, wrp->phy_utmi, 0x02); in dsps_musb_set_mode()
551 dev_err(glue->dev, "unsupported mode %d\n", mode); in dsps_musb_set_mode()
552 return -EINVAL; in dsps_musb_set_mode()
563 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
564 dev_dbg(musb->controller, "babble: MUSB_BABBLE_CTL value %x\n", in dsps_sw_babble_control()
570 dev_dbg(musb->controller, "STUCK_J is %s\n", in dsps_sw_babble_control()
580 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
582 musb_writeb(musb->mregs, MUSB_BABBLE_CTL, babble_ctl); in dsps_sw_babble_control()
585 dev_dbg(musb->controller, "Set TXIDLE, wait J to clear\n"); in dsps_sw_babble_control()
587 babble_ctl = musb_readb(musb->mregs, MUSB_BABBLE_CTL); in dsps_sw_babble_control()
589 } while ((babble_ctl & MUSB_BABBLE_STUCK_J) && timeout--); in dsps_sw_babble_control()
598 dev_dbg(musb->controller, "J not cleared, misc (%x)\n", in dsps_sw_babble_control()
611 struct device *dev = musb->controller; in dsps_musb_recover()
612 struct dsps_glue *glue = dev_get_drvdata(dev->parent); in dsps_musb_recover()
615 if (glue->sw_babble_enabled) in dsps_musb_recover()
620 return session_restart ? 0 : -EPIPE; in dsps_musb_recover()
623 /* Similar to am35x, dm81xx support only 32-bit read operation */
626 void __iomem *fifo = hw_ep->fifo; in dsps_read_fifo32()
644 struct musb *musb = c->musb; in dsps_dma_controller_callback()
645 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); in dsps_dma_controller_callback()
646 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_callback()
658 struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); in dsps_dma_controller_create()
659 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_create()
666 controller->dma_callback = dsps_dma_controller_callback; in dsps_dma_controller_create()
674 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_suspend()
681 void __iomem *usbss_base = glue->usbss_base; in dsps_dma_controller_resume()
729 struct device *dev = &parent->dev; in dsps_create_musb_pdev()
732 struct device_node *dn = parent->dev.of_node; in dsps_create_musb_pdev()
739 return -EINVAL; in dsps_create_musb_pdev()
753 musb = platform_device_alloc("musb-hdrc", in dsps_create_musb_pdev()
757 return -ENOMEM; in dsps_create_musb_pdev()
760 musb->dev.parent = dev; in dsps_create_musb_pdev()
761 musb->dev.dma_mask = &musb_dmamask; in dsps_create_musb_pdev()
762 musb->dev.coherent_dma_mask = musb_dmamask; in dsps_create_musb_pdev()
763 device_set_of_node_from_dev(&musb->dev, &parent->dev); in dsps_create_musb_pdev()
765 glue->musb = musb; in dsps_create_musb_pdev()
774 config = devm_kzalloc(&parent->dev, sizeof(*config), GFP_KERNEL); in dsps_create_musb_pdev()
776 ret = -ENOMEM; in dsps_create_musb_pdev()
782 config->num_eps = get_int_prop(dn, "mentor,num-eps"); in dsps_create_musb_pdev()
783 config->ram_bits = get_int_prop(dn, "mentor,ram-bits"); in dsps_create_musb_pdev()
784 config->host_port_deassert_reset_at_resume = 1; in dsps_create_musb_pdev()
791 config->multipoint = true; in dsps_create_musb_pdev()
793 config->maximum_speed = usb_get_maximum_speed(&parent->dev); in dsps_create_musb_pdev()
794 switch (config->maximum_speed) { in dsps_create_musb_pdev()
800 "(super-speed) setting in dts"); in dsps_create_musb_pdev()
803 config->maximum_speed = USB_SPEED_HIGH; in dsps_create_musb_pdev()
827 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_vbus_threaded_irq()
832 dev_dbg(glue->dev, "VBUS interrupt\n"); in dsps_vbus_threaded_irq()
843 glue->vbus_irq = platform_get_irq_byname(pdev, "vbus"); in dsps_setup_optional_vbus_irq()
844 if (glue->vbus_irq == -EPROBE_DEFER) in dsps_setup_optional_vbus_irq()
845 return -EPROBE_DEFER; in dsps_setup_optional_vbus_irq()
847 if (glue->vbus_irq <= 0) { in dsps_setup_optional_vbus_irq()
848 glue->vbus_irq = 0; in dsps_setup_optional_vbus_irq()
852 error = devm_request_threaded_irq(glue->dev, glue->vbus_irq, in dsps_setup_optional_vbus_irq()
857 glue->vbus_irq = 0; in dsps_setup_optional_vbus_irq()
860 dev_dbg(glue->dev, "VBUS irq %i configured\n", glue->vbus_irq); in dsps_setup_optional_vbus_irq()
872 if (!strcmp(pdev->name, "musb-hdrc")) in dsps_probe()
873 return -ENODEV; in dsps_probe()
875 match = of_match_node(musb_dsps_of_match, pdev->dev.of_node); in dsps_probe()
877 dev_err(&pdev->dev, "fail to get matching of_match struct\n"); in dsps_probe()
878 return -EINVAL; in dsps_probe()
880 wrp = match->data; in dsps_probe()
882 if (of_device_is_compatible(pdev->dev.of_node, "ti,musb-dm816")) in dsps_probe()
886 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); in dsps_probe()
888 return -ENOMEM; in dsps_probe()
890 glue->dev = &pdev->dev; in dsps_probe()
891 glue->wrp = wrp; in dsps_probe()
892 glue->usbss_base = of_iomap(pdev->dev.parent->of_node, 0); in dsps_probe()
893 if (!glue->usbss_base) in dsps_probe()
894 return -ENXIO; in dsps_probe()
897 pm_runtime_enable(&pdev->dev); in dsps_probe()
902 if (usb_get_dr_mode(&pdev->dev) == USB_DR_MODE_PERIPHERAL) { in dsps_probe()
911 platform_device_unregister(glue->musb); in dsps_probe()
913 pm_runtime_disable(&pdev->dev); in dsps_probe()
914 iounmap(glue->usbss_base); in dsps_probe()
922 platform_device_unregister(glue->musb); in dsps_remove()
924 pm_runtime_disable(&pdev->dev); in dsps_remove()
925 iounmap(glue->usbss_base); in dsps_remove()
962 { .compatible = "ti,musb-am33xx",
964 { .compatible = "ti,musb-dm816",
974 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_suspend()
975 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_suspend()
980 /* This can happen if the musb device is in -EPROBE_DEFER */ in dsps_suspend()
989 del_timer_sync(&musb->dev_timer); in dsps_suspend()
991 mbase = musb->ctrl_base; in dsps_suspend()
992 glue->context.control = musb_readl(mbase, wrp->control); in dsps_suspend()
993 glue->context.epintr = musb_readl(mbase, wrp->epintr_set); in dsps_suspend()
994 glue->context.coreintr = musb_readl(mbase, wrp->coreintr_set); in dsps_suspend()
995 glue->context.phy_utmi = musb_readl(mbase, wrp->phy_utmi); in dsps_suspend()
996 glue->context.mode = musb_readl(mbase, wrp->mode); in dsps_suspend()
997 glue->context.tx_mode = musb_readl(mbase, wrp->tx_mode); in dsps_suspend()
998 glue->context.rx_mode = musb_readl(mbase, wrp->rx_mode); in dsps_suspend()
1008 const struct dsps_musb_wrapper *wrp = glue->wrp; in dsps_resume()
1009 struct musb *musb = platform_get_drvdata(glue->musb); in dsps_resume()
1017 mbase = musb->ctrl_base; in dsps_resume()
1018 musb_writel(mbase, wrp->control, glue->context.control); in dsps_resume()
1019 musb_writel(mbase, wrp->epintr_set, glue->context.epintr); in dsps_resume()
1020 musb_writel(mbase, wrp->coreintr_set, glue->context.coreintr); in dsps_resume()
1021 musb_writel(mbase, wrp->phy_utmi, glue->context.phy_utmi); in dsps_resume()
1022 musb_writel(mbase, wrp->mode, glue->context.mode); in dsps_resume()
1023 musb_writel(mbase, wrp->tx_mode, glue->context.tx_mode); in dsps_resume()
1024 musb_writel(mbase, wrp->rx_mode, glue->context.rx_mode); in dsps_resume()
1025 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && in dsps_resume()
1026 musb->port_mode == MUSB_OTG) in dsps_resume()
1027 dsps_mod_timer(glue, -1); in dsps_resume()
1041 .name = "musb-dsps",