Lines Matching +full:debounce +full:- +full:exit
1 // SPDX-License-Identifier: GPL-2.0
8 * Copyright (c) 2008-2009, MontaVista Software, Inc. <source@mvista.com>
21 #include <linux/dma-mapping.h>
27 #include "linux-compat.h"
83 #define glue_to_musb(g) platform_get_drvdata(g->musb)
86 * am35x_musb_enable - enable interrupts
94 void __iomem *reg_base = musb->ctrl_base; in am35x_musb_enable()
98 epmask = ((musb->epmask & AM35X_TX_EP_MASK) << AM35X_INTR_TX_SHIFT) | in am35x_musb_enable()
99 ((musb->epmask & AM35X_RX_EP_MASK) << AM35X_INTR_RX_SHIFT); in am35x_musb_enable()
114 * am35x_musb_disable - disable HDRC and flush interrupts
118 void __iomem *reg_base = musb->ctrl_base; in am35x_musb_disable()
123 musb_writeb(musb->mregs, MUSB_DEVCTL, 0); in am35x_musb_disable()
142 void __iomem *mregs = musb->mregs; in otg_timer()
147 * We poll because AM35x's won't expose several OTG-critical in otg_timer()
151 dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, in otg_timer()
152 otg_state_string(musb->xceiv->state)); in otg_timer()
154 spin_lock_irqsave(&musb->lock, flags); in otg_timer()
155 switch (musb->xceiv->state) { in otg_timer()
158 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); in otg_timer()
160 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in otg_timer()
162 musb->xceiv->state = OTG_STATE_B_IDLE; in otg_timer()
165 musb->xceiv->state = OTG_STATE_A_IDLE; in otg_timer()
170 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; in otg_timer()
171 musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG, in otg_timer()
182 musb->xceiv->state = OTG_STATE_A_IDLE; in otg_timer()
187 spin_unlock_irqrestore(&musb->lock, flags); in otg_timer()
201 if (musb->is_active || (musb->a_wait_bcon == 0 && in am35x_musb_try_idle()
202 musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { in am35x_musb_try_idle()
203 dev_dbg(musb->controller, "%s active, deleting timer\n", in am35x_musb_try_idle()
204 otg_state_string(musb->xceiv->state)); in am35x_musb_try_idle()
211 dev_dbg(musb->controller, "Longer idle timer already pending, ignoring...\n"); in am35x_musb_try_idle()
216 dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", in am35x_musb_try_idle()
217 otg_state_string(musb->xceiv->state), in am35x_musb_try_idle()
218 jiffies_to_msecs(timeout - jiffies)); in am35x_musb_try_idle()
226 void __iomem *reg_base = musb->ctrl_base; in am35x_musb_interrupt()
228 struct device *dev = musb->controller; in am35x_musb_interrupt()
229 struct musb_hdrc_platform_data *plat = dev->platform_data; in am35x_musb_interrupt()
230 struct omap_musb_board_data *data = plat->board_data; in am35x_musb_interrupt()
231 struct usb_otg *otg = musb->xceiv->otg; in am35x_musb_interrupt()
234 (struct omap_musb_board_data *)musb->controller; in am35x_musb_interrupt()
248 spin_lock_irqsave(&musb->lock, flags); in am35x_musb_interrupt()
256 musb->int_rx = in am35x_musb_interrupt()
258 musb->int_tx = in am35x_musb_interrupt()
270 musb->int_usb = in am35x_musb_interrupt()
284 void __iomem *mregs = musb->mregs; in am35x_musb_interrupt()
288 err = is_host_enabled(musb) && (musb->int_usb & in am35x_musb_interrupt()
292 * The Mentor core doesn't debounce VBUS as needed in am35x_musb_interrupt()
294 * means it's not uncommon for bus-powered devices in am35x_musb_interrupt()
298 * seems to allow a better one: "re"-starting sessions in am35x_musb_interrupt()
302 musb->int_usb &= ~MUSB_INTR_VBUSERROR; in am35x_musb_interrupt()
303 musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; in am35x_musb_interrupt()
308 otg->default_a = 1; in am35x_musb_interrupt()
309 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; in am35x_musb_interrupt()
310 portstate(musb->port1_status |= USB_PORT_STAT_POWER); in am35x_musb_interrupt()
313 musb->is_active = 0; in am35x_musb_interrupt()
315 otg->default_a = 0; in am35x_musb_interrupt()
316 musb->xceiv->state = OTG_STATE_B_IDLE; in am35x_musb_interrupt()
317 portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); in am35x_musb_interrupt()
320 /* NOTE: this must complete power-on within 100 ms. */ in am35x_musb_interrupt()
321 dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", in am35x_musb_interrupt()
323 otg_state_string(musb->xceiv->state), in am35x_musb_interrupt()
330 if (musb->int_tx || musb->int_rx || musb->int_usb) in am35x_musb_interrupt()
334 /* EOI needs to be written for the IRQ to be re-asserted. */ in am35x_musb_interrupt()
337 if (data->clear_irq) in am35x_musb_interrupt()
338 data->clear_irq(data->dev); in am35x_musb_interrupt()
345 if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE) in am35x_musb_interrupt()
349 spin_unlock_irqrestore(&musb->lock, flags); in am35x_musb_interrupt()
357 struct device *dev = musb->controller; in am35x_musb_set_mode()
358 struct musb_hdrc_platform_data *plat = dev->platform_data; in am35x_musb_set_mode()
359 struct omap_musb_board_data *data = plat->board_data; in am35x_musb_set_mode()
362 if (data->set_mode) in am35x_musb_set_mode()
363 data->set_mode(musb_mode); in am35x_musb_set_mode()
365 retval = -EIO; in am35x_musb_set_mode()
374 struct device *dev = musb->controller; in am35x_musb_init()
375 struct musb_hdrc_platform_data *plat = dev->platform_data; in am35x_musb_init()
376 struct omap_musb_board_data *data = plat->board_data; in am35x_musb_init()
379 (struct omap_musb_board_data *)musb->controller; in am35x_musb_init()
381 void __iomem *reg_base = musb->ctrl_base; in am35x_musb_init()
384 musb->mregs += USB_MENTOR_CORE_OFFSET; in am35x_musb_init()
389 return -ENODEV; in am35x_musb_init()
393 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); in am35x_musb_init()
394 if (IS_ERR_OR_NULL(musb->xceiv)) in am35x_musb_init()
395 return -ENODEV; in am35x_musb_init()
402 if (data->reset) in am35x_musb_init()
403 data->reset(data->dev); in am35x_musb_init()
408 /* Start the on-chip PHY and its PLL. */ in am35x_musb_init()
409 if (data && data->set_phy_power) in am35x_musb_init()
410 data->set_phy_power(data->dev, 1); in am35x_musb_init()
414 musb->isr = am35x_musb_interrupt; in am35x_musb_init()
417 if (data->clear_irq) in am35x_musb_init()
418 data->clear_irq(data->dev); in am35x_musb_init()
426 struct device *dev = musb->controller; in am35x_musb_exit()
427 struct musb_hdrc_platform_data *plat = dev->platform_data; in am35x_musb_exit()
428 struct omap_musb_board_data *data = plat->board_data; in am35x_musb_exit()
431 (struct omap_musb_board_data *)musb->controller; in am35x_musb_exit()
439 /* Shutdown the on-chip PHY and its PLL. */ in am35x_musb_exit()
440 if (data && data->set_phy_power) in am35x_musb_exit()
441 data->set_phy_power(data->dev, 0); in am35x_musb_exit()
444 usb_put_phy(musb->xceiv); in am35x_musb_exit()
454 void __iomem *fifo = hw_ep->fifo; in musb_read_fifo()
458 /* Read for 32bit-aligned destination address */ in musb_read_fifo()
487 .exit = am35x_musb_exit,
505 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; in am35x_probe()
512 int ret = -ENOMEM; in am35x_probe()
516 dev_err(&pdev->dev, "failed to allocate glue context\n"); in am35x_probe()
520 musb = platform_device_alloc("musb-hdrc", -1); in am35x_probe()
522 dev_err(&pdev->dev, "failed to allocate musb device\n"); in am35x_probe()
526 phy_clk = clk_get(&pdev->dev, "fck"); in am35x_probe()
528 dev_err(&pdev->dev, "failed to get PHY clock\n"); in am35x_probe()
533 clk = clk_get(&pdev->dev, "ick"); in am35x_probe()
535 dev_err(&pdev->dev, "failed to get clock\n"); in am35x_probe()
542 dev_err(&pdev->dev, "failed to enable PHY clock\n"); in am35x_probe()
548 dev_err(&pdev->dev, "failed to enable clock\n"); in am35x_probe()
552 musb->dev.parent = &pdev->dev; in am35x_probe()
553 musb->dev.dma_mask = &am35x_dmamask; in am35x_probe()
554 musb->dev.coherent_dma_mask = am35x_dmamask; in am35x_probe()
556 glue->dev = &pdev->dev; in am35x_probe()
557 glue->musb = musb; in am35x_probe()
558 glue->phy_clk = phy_clk; in am35x_probe()
559 glue->clk = clk; in am35x_probe()
561 pdata->platform_ops = &am35x_ops; in am35x_probe()
565 ret = platform_device_add_resources(musb, pdev->resource, in am35x_probe()
566 pdev->num_resources); in am35x_probe()
568 dev_err(&pdev->dev, "failed to add resources\n"); in am35x_probe()
574 dev_err(&pdev->dev, "failed to add platform_data\n"); in am35x_probe()
580 dev_err(&pdev->dev, "failed to register musb device\n"); in am35x_probe()
612 platform_device_del(glue->musb); in am35x_remove()
613 platform_device_put(glue->musb); in am35x_remove()
614 clk_disable(glue->clk); in am35x_remove()
615 clk_disable(glue->phy_clk); in am35x_remove()
616 clk_put(glue->clk); in am35x_remove()
617 clk_put(glue->phy_clk); in am35x_remove()
627 struct musb_hdrc_platform_data *plat = dev->platform_data; in am35x_suspend()
628 struct omap_musb_board_data *data = plat->board_data; in am35x_suspend()
630 /* Shutdown the on-chip PHY and its PLL. */ in am35x_suspend()
631 if (data && data->set_phy_power) in am35x_suspend()
632 data->set_phy_power(data->dev, 0); in am35x_suspend()
634 clk_disable(glue->phy_clk); in am35x_suspend()
635 clk_disable(glue->clk); in am35x_suspend()
643 struct musb_hdrc_platform_data *plat = dev->platform_data; in am35x_resume()
644 struct omap_musb_board_data *data = plat->board_data; in am35x_resume()
647 /* Start the on-chip PHY and its PLL. */ in am35x_resume()
648 if (data && data->set_phy_power) in am35x_resume()
649 data->set_phy_power(data->dev, 1); in am35x_resume()
651 ret = clk_enable(glue->phy_clk); in am35x_resume()
657 ret = clk_enable(glue->clk); in am35x_resume()
680 .name = "musb-am35x",