Lines Matching +full:re +full:- +full:clocked

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2005-2006 by Texas Instruments
18 #include <linux/dma-mapping.h>
24 #include <asm/mach-types.h>
54 /* power everything up; start the on-chip PHY and its PLL */ in phy_on()
68 /* powerdown the on-chip PHY, its PLL, and the OTG block */ in phy_off()
81 tmp = (musb->epmask & DAVINCI_USB_TX_ENDPTS_MASK) in davinci_musb_enable()
83 musb_writel(musb->ctrl_base, DAVINCI_USB_INT_MASK_SET_REG, tmp); in davinci_musb_enable()
85 tmp = (musb->epmask & (0xfffe & DAVINCI_USB_RX_ENDPTS_MASK)) in davinci_musb_enable()
87 musb_writel(musb->ctrl_base, DAVINCI_USB_INT_MASK_SET_REG, tmp); in davinci_musb_enable()
92 musb_writel(musb->ctrl_base, DAVINCI_USB_INT_MASK_SET_REG, tmp); in davinci_musb_enable()
101 musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG, in davinci_musb_enable()
111 * - not read/write INTRUSB/INTRUSBE in davinci_musb_disable()
112 * - (except during initial setup, as workaround) in davinci_musb_disable()
113 * - use INTSETR/INTCLRR instead in davinci_musb_disable()
115 musb_writel(musb->ctrl_base, DAVINCI_USB_INT_MASK_CLR_REG, in davinci_musb_disable()
119 musb_writel(musb->ctrl_base, DAVINCI_USB_EOI_REG, 0); in davinci_musb_disable()
129 * VBUS SWITCHING IS BOARD-SPECIFIC ... at least for the DM6446 EVM,
146 gpiod_set_value_cansleep(glue->vbus, glue->vbus_state); in evm_deferred_drvvbus()
147 glue->vbus_state = !glue->vbus_state; in evm_deferred_drvvbus()
153 struct davinci_glue *glue = dev_get_drvdata(musb->controller->parent); in davinci_musb_source_power()
156 if (!glue->vbus) in davinci_musb_source_power()
162 if (glue->vbus_state == is_on) in davinci_musb_source_power()
164 /* 0/1 vs "-1 == unknown/init" */ in davinci_musb_source_power()
165 glue->vbus_state = !is_on; in davinci_musb_source_power()
169 gpiod_set_value_cansleep(glue->vbus, glue->vbus_state); in davinci_musb_source_power()
171 schedule_work(&glue->vbus_work); in davinci_musb_source_power()
174 glue->vbus_state = is_on; in davinci_musb_source_power()
189 void __iomem *mregs = musb->mregs; in otg_timer()
193 /* We poll because DaVinci's won't expose several OTG-critical in otg_timer()
197 dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl, in otg_timer()
198 usb_otg_state_string(musb->xceiv->otg->state)); in otg_timer()
200 spin_lock_irqsave(&musb->lock, flags); in otg_timer()
201 switch (musb->xceiv->otg->state) { in otg_timer()
204 * seems to mis-handle session "start" otherwise (or in our in otg_timer()
209 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ); in otg_timer()
212 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in otg_timer()
213 musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG, in otg_timer()
218 * There's no ID-changed IRQ, so we have no good way to tell in otg_timer()
219 * when to switch to the A-Default state machine (by setting in otg_timer()
222 * Workaround: whenever we're in B_IDLE, try setting the in otg_timer()
224 * grounded and we're now in the A-Default state machine. in otg_timer()
233 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ); in otg_timer()
235 musb->xceiv->otg->state = OTG_STATE_A_IDLE; in otg_timer()
240 spin_unlock_irqrestore(&musb->lock, flags); in otg_timer()
248 struct usb_otg *otg = musb->xceiv->otg; in davinci_musb_interrupt()
249 void __iomem *tibase = musb->ctrl_base; in davinci_musb_interrupt()
253 spin_lock_irqsave(&musb->lock, flags); in davinci_musb_interrupt()
267 cppi = container_of(musb->dma_controller, struct cppi, controller); in davinci_musb_interrupt()
268 if (is_cppi_enabled(musb) && musb->dma_controller && !cppi->irq) in davinci_musb_interrupt()
271 /* ack and handle non-CPPI interrupts */ in davinci_musb_interrupt()
274 dev_dbg(musb->controller, "IRQ %08x\n", tmp); in davinci_musb_interrupt()
276 musb->int_rx = (tmp & DAVINCI_USB_RXINT_MASK) in davinci_musb_interrupt()
278 musb->int_tx = (tmp & DAVINCI_USB_TXINT_MASK) in davinci_musb_interrupt()
280 musb->int_usb = (tmp & DAVINCI_USB_USBINT_MASK) in davinci_musb_interrupt()
292 void __iomem *mregs = musb->mregs; in davinci_musb_interrupt()
294 int err = musb->int_usb & MUSB_INTR_VBUSERROR; in davinci_musb_interrupt()
296 err = musb->int_usb & MUSB_INTR_VBUSERROR; in davinci_musb_interrupt()
300 * means it's not uncommon for bus-powered devices in davinci_musb_interrupt()
304 * seems to allow a better one: "re"starting sessions in davinci_musb_interrupt()
308 musb->int_usb &= ~MUSB_INTR_VBUSERROR; in davinci_musb_interrupt()
309 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL; in davinci_musb_interrupt()
310 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ); in davinci_musb_interrupt()
314 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in davinci_musb_interrupt()
315 portstate(musb->port1_status |= USB_PORT_STAT_POWER); in davinci_musb_interrupt()
316 del_timer(&musb->dev_timer); in davinci_musb_interrupt()
318 musb->is_active = 0; in davinci_musb_interrupt()
320 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in davinci_musb_interrupt()
321 portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); in davinci_musb_interrupt()
328 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", in davinci_musb_interrupt()
330 usb_otg_state_string(musb->xceiv->otg->state), in davinci_musb_interrupt()
336 if (musb->int_tx || musb->int_rx || musb->int_usb) in davinci_musb_interrupt()
343 if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) in davinci_musb_interrupt()
344 mod_timer(&musb->dev_timer, jiffies + POLL_SECONDS * HZ); in davinci_musb_interrupt()
346 spin_unlock_irqrestore(&musb->lock, flags); in davinci_musb_interrupt()
354 return -EIO; in davinci_musb_set_mode()
359 void __iomem *tibase = musb->ctrl_base; in davinci_musb_init()
361 int ret = -ENODEV; in davinci_musb_init()
363 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); in davinci_musb_init()
364 if (IS_ERR_OR_NULL(musb->xceiv)) { in davinci_musb_init()
365 ret = -EPROBE_DEFER; in davinci_musb_init()
369 musb->mregs += DAVINCI_BASE_OFFSET; in davinci_musb_init()
371 /* returns zero if e.g. not clocked */ in davinci_musb_init()
376 timer_setup(&musb->dev_timer, otg_timer, 0); in davinci_musb_init()
380 /* dm355 EVM swaps D+/D- for signal integrity, and in davinci_musb_init()
381 * is clocked from the main 24 MHz crystal. in davinci_musb_init()
391 /* On dm355, the default-A state machine needs DRVVBUS control. in davinci_musb_init()
404 /* start the on-chip PHY and its PLL */ in davinci_musb_init()
409 /* NOTE: irqs are in mixed mode, not bypass to pure-musb */ in davinci_musb_init()
414 musb->isr = davinci_musb_interrupt; in davinci_musb_init()
418 usb_put_phy(musb->xceiv); in davinci_musb_init()
429 del_timer_sync(&musb->dev_timer); in davinci_musb_exit()
448 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in davinci_musb_exit()
453 dev_dbg(musb->controller, "VBUS %d\n", in davinci_musb_exit()
457 maxdelay--; in davinci_musb_exit()
462 dev_dbg(musb->controller, "VBUS off timeout (devctl %02x)\n", devctl); in davinci_musb_exit()
466 usb_put_phy(musb->xceiv); in davinci_musb_exit()
489 .name = "musb-hdrc",
497 struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); in davinci_probe()
503 int ret = -ENOMEM; in davinci_probe()
505 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); in davinci_probe()
509 clk = devm_clk_get(&pdev->dev, "usb"); in davinci_probe()
511 dev_err(&pdev->dev, "failed to get clock\n"); in davinci_probe()
518 dev_err(&pdev->dev, "failed to enable clock\n"); in davinci_probe()
522 glue->dev = &pdev->dev; in davinci_probe()
523 glue->clk = clk; in davinci_probe()
525 pdata->platform_ops = &davinci_ops; in davinci_probe()
527 glue->vbus = devm_gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW); in davinci_probe()
528 if (IS_ERR(glue->vbus)) { in davinci_probe()
529 ret = PTR_ERR(glue->vbus); in davinci_probe()
532 glue->vbus_state = -1; in davinci_probe()
533 INIT_WORK(&glue->vbus_work, evm_deferred_drvvbus); in davinci_probe()
542 musb_resources[0].name = pdev->resource[0].name; in davinci_probe()
543 musb_resources[0].start = pdev->resource[0].start; in davinci_probe()
544 musb_resources[0].end = pdev->resource[0].end; in davinci_probe()
545 musb_resources[0].flags = pdev->resource[0].flags; in davinci_probe()
547 musb_resources[1].name = pdev->resource[1].name; in davinci_probe()
548 musb_resources[1].start = pdev->resource[1].start; in davinci_probe()
549 musb_resources[1].end = pdev->resource[1].end; in davinci_probe()
550 musb_resources[1].flags = pdev->resource[1].flags; in davinci_probe()
556 musb_resources[2].name = pdev->resource[2].name; in davinci_probe()
557 musb_resources[2].start = pdev->resource[2].start; in davinci_probe()
558 musb_resources[2].end = pdev->resource[2].end; in davinci_probe()
559 musb_resources[2].flags = pdev->resource[2].flags; in davinci_probe()
562 pinfo.parent = &pdev->dev; in davinci_probe()
568 glue->musb = musb = platform_device_register_full(&pinfo); in davinci_probe()
571 dev_err(&pdev->dev, "failed to register musb device: %d\n", ret); in davinci_probe()
588 platform_device_unregister(glue->musb); in davinci_remove()
590 clk_disable(glue->clk); in davinci_remove()
599 .name = "musb-davinci",