Lines Matching +full:usb +full:- +full:glue
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2010 ST-Ericsson AB
16 #include <linux/usb/musb-ux500.h>
32 #define glue_to_musb(g) platform_get_drvdata(g->musb)
43 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in ux500_musb_set_vbus()
46 if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) { in ux500_musb_set_vbus()
49 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); in ux500_musb_set_vbus()
54 while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) { in ux500_musb_set_vbus()
57 dev_err(musb->controller, in ux500_musb_set_vbus()
64 musb->is_active = 1; in ux500_musb_set_vbus()
65 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in ux500_musb_set_vbus()
70 musb->is_active = 0; in ux500_musb_set_vbus()
72 /* NOTE: we're skipping A_WAIT_VFALL -> A_IDLE and jumping in ux500_musb_set_vbus()
78 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); in ux500_musb_set_vbus()
89 dev_dbg(musb->controller, "VBUS %s, devctl %02x\n", in ux500_musb_set_vbus()
90 usb_otg_state_string(musb->xceiv->otg->state), in ux500_musb_set_vbus()
91 musb_readb(musb->mregs, MUSB_DEVCTL)); in ux500_musb_set_vbus()
99 dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n", in musb_otg_notifications()
100 event, usb_otg_state_string(musb->xceiv->otg->state)); in musb_otg_notifications()
104 dev_dbg(musb->controller, "ID GND\n"); in musb_otg_notifications()
108 dev_dbg(musb->controller, "VBUS Connect\n"); in musb_otg_notifications()
111 dev_dbg(musb->controller, "VBUS Disconnect\n"); in musb_otg_notifications()
115 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in musb_otg_notifications()
118 dev_dbg(musb->controller, "ID float\n"); in musb_otg_notifications()
130 spin_lock_irqsave(&musb->lock, flags); in ux500_musb_interrupt()
132 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); in ux500_musb_interrupt()
133 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); in ux500_musb_interrupt()
134 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); in ux500_musb_interrupt()
136 if (musb->int_usb || musb->int_tx || musb->int_rx) in ux500_musb_interrupt()
139 spin_unlock_irqrestore(&musb->lock, flags); in ux500_musb_interrupt()
148 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); in ux500_musb_init()
149 if (IS_ERR_OR_NULL(musb->xceiv)) { in ux500_musb_init()
150 pr_err("HS USB OTG: no transceiver configured\n"); in ux500_musb_init()
151 return -EPROBE_DEFER; in ux500_musb_init()
154 musb->nb.notifier_call = musb_otg_notifications; in ux500_musb_init()
155 status = usb_register_notifier(musb->xceiv, &musb->nb); in ux500_musb_init()
157 dev_dbg(musb->controller, "notification register failed\n"); in ux500_musb_init()
161 musb->isr = ux500_musb_interrupt; in ux500_musb_init()
168 usb_unregister_notifier(musb->xceiv, &musb->nb); in ux500_musb_exit()
170 usb_put_phy(musb->xceiv); in ux500_musb_exit()
195 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); in ux500_of_probe()
201 dev_err(&pdev->dev, "No 'dr_mode' property found\n"); in ux500_of_probe()
207 pdata->mode = MUSB_HOST; in ux500_of_probe()
209 pdata->mode = MUSB_OTG; in ux500_of_probe()
211 pdata->mode = MUSB_PERIPHERAL; in ux500_of_probe()
220 struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); in ux500_probe()
221 struct device_node *np = pdev->dev.of_node; in ux500_probe()
223 struct ux500_glue *glue; in ux500_probe() local
225 int ret = -ENOMEM; in ux500_probe()
233 pdev->dev.platform_data = pdata; in ux500_probe()
235 dev_err(&pdev->dev, "no pdata or device tree found\n"); in ux500_probe()
240 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); in ux500_probe()
241 if (!glue) in ux500_probe()
244 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); in ux500_probe()
246 dev_err(&pdev->dev, "failed to allocate musb device\n"); in ux500_probe()
250 clk = devm_clk_get(&pdev->dev, NULL); in ux500_probe()
252 dev_err(&pdev->dev, "failed to get clock\n"); in ux500_probe()
259 dev_err(&pdev->dev, "failed to enable clock\n"); in ux500_probe()
263 musb->dev.parent = &pdev->dev; in ux500_probe()
264 musb->dev.dma_mask = &pdev->dev.coherent_dma_mask; in ux500_probe()
265 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; in ux500_probe()
267 glue->dev = &pdev->dev; in ux500_probe()
268 glue->musb = musb; in ux500_probe()
269 glue->clk = clk; in ux500_probe()
271 pdata->platform_ops = &ux500_ops; in ux500_probe()
272 pdata->config = &ux500_musb_hdrc_config; in ux500_probe()
274 platform_set_drvdata(pdev, glue); in ux500_probe()
279 musb_resources[0].name = pdev->resource[0].name; in ux500_probe()
280 musb_resources[0].start = pdev->resource[0].start; in ux500_probe()
281 musb_resources[0].end = pdev->resource[0].end; in ux500_probe()
282 musb_resources[0].flags = pdev->resource[0].flags; in ux500_probe()
284 musb_resources[1].name = pdev->resource[1].name; in ux500_probe()
285 musb_resources[1].start = pdev->resource[1].start; in ux500_probe()
286 musb_resources[1].end = pdev->resource[1].end; in ux500_probe()
287 musb_resources[1].flags = pdev->resource[1].flags; in ux500_probe()
292 dev_err(&pdev->dev, "failed to add resources\n"); in ux500_probe()
298 dev_err(&pdev->dev, "failed to add platform_data\n"); in ux500_probe()
304 dev_err(&pdev->dev, "failed to register musb device\n"); in ux500_probe()
322 struct ux500_glue *glue = platform_get_drvdata(pdev); in ux500_remove() local
324 platform_device_unregister(glue->musb); in ux500_remove()
325 clk_disable_unprepare(glue->clk); in ux500_remove()
333 struct ux500_glue *glue = dev_get_drvdata(dev); in ux500_suspend() local
334 struct musb *musb = glue_to_musb(glue); in ux500_suspend()
337 usb_phy_set_suspend(musb->xceiv, 1); in ux500_suspend()
339 clk_disable_unprepare(glue->clk); in ux500_suspend()
346 struct ux500_glue *glue = dev_get_drvdata(dev); in ux500_resume() local
347 struct musb *musb = glue_to_musb(glue); in ux500_resume()
350 ret = clk_prepare_enable(glue->clk); in ux500_resume()
357 usb_phy_set_suspend(musb->xceiv, 0); in ux500_resume()
366 { .compatible = "stericsson,db8500-musb", },
376 .name = "musb-ux500",
382 MODULE_DESCRIPTION("UX500 MUSB Glue Layer");