Lines Matching +full:usb +full:- +full:glue

1 // SPDX-License-Identifier: GPL-2.0
3 * PolarFire SoC (MPFS) MUSB Glue Layer
5 * Copyright (c) 2020-2022 Microchip Corporation. All rights reserved.
11 #include <linux/dma-mapping.h>
17 #include <linux/usb/usb_phy_generic.h>
57 spin_lock_irqsave(&musb->lock, flags); in mpfs_musb_interrupt()
59 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); in mpfs_musb_interrupt()
60 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); in mpfs_musb_interrupt()
61 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); in mpfs_musb_interrupt()
63 if (musb->int_usb || musb->int_tx || musb->int_rx) { in mpfs_musb_interrupt()
64 musb_writeb(musb->mregs, MUSB_INTRUSB, musb->int_usb); in mpfs_musb_interrupt()
65 musb_writew(musb->mregs, MUSB_INTRTX, musb->int_tx); in mpfs_musb_interrupt()
66 musb_writew(musb->mregs, MUSB_INTRRX, musb->int_rx); in mpfs_musb_interrupt()
70 spin_unlock_irqrestore(&musb->lock, flags); in mpfs_musb_interrupt()
84 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); in mpfs_musb_set_vbus()
87 musb->is_active = 1; in mpfs_musb_set_vbus()
88 musb->xceiv->otg->default_a = 1; in mpfs_musb_set_vbus()
89 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; in mpfs_musb_set_vbus()
93 musb->is_active = 0; in mpfs_musb_set_vbus()
96 * NOTE: skipping A_WAIT_VFALL -> A_IDLE and in mpfs_musb_set_vbus()
99 musb->xceiv->otg->default_a = 0; in mpfs_musb_set_vbus()
100 musb->xceiv->otg->state = OTG_STATE_B_IDLE; in mpfs_musb_set_vbus()
106 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); in mpfs_musb_set_vbus()
108 dev_dbg(musb->controller, "VBUS %s, devctl %02x\n", in mpfs_musb_set_vbus()
109 usb_otg_state_string(musb->xceiv->otg->state), in mpfs_musb_set_vbus()
110 musb_readb(musb->mregs, MUSB_DEVCTL)); in mpfs_musb_set_vbus()
115 struct device *dev = musb->controller; in mpfs_musb_init()
117 musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in mpfs_musb_init()
118 if (IS_ERR(musb->xceiv)) { in mpfs_musb_init()
120 return PTR_ERR(musb->xceiv); in mpfs_musb_init()
123 musb->dyn_fifo = true; in mpfs_musb_init()
124 musb->isr = mpfs_musb_interrupt; in mpfs_musb_init()
144 struct musb_hdrc_platform_data *pdata = dev_get_platdata(&pdev->dev); in mpfs_probe()
145 struct mpfs_glue *glue; in mpfs_probe() local
147 struct device *dev = &pdev->dev; in mpfs_probe()
151 glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); in mpfs_probe()
152 if (!glue) in mpfs_probe()
153 return -ENOMEM; in mpfs_probe()
155 musb_pdev = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); in mpfs_probe()
158 return -ENOMEM; in mpfs_probe()
161 clk = devm_clk_get(&pdev->dev, NULL); in mpfs_probe()
163 dev_err(&pdev->dev, "failed to get clock\n"); in mpfs_probe()
170 dev_err(&pdev->dev, "failed to enable clock\n"); in mpfs_probe()
174 musb_pdev->dev.parent = dev; in mpfs_probe()
175 musb_pdev->dev.coherent_dma_mask = DMA_BIT_MASK(39); in mpfs_probe()
176 musb_pdev->dev.dma_mask = &musb_pdev->dev.coherent_dma_mask; in mpfs_probe()
177 device_set_of_node_from_dev(&musb_pdev->dev, dev); in mpfs_probe()
179 glue->dev = dev; in mpfs_probe()
180 glue->musb = musb_pdev; in mpfs_probe()
181 glue->clk = clk; in mpfs_probe()
185 ret = -ENOMEM; in mpfs_probe()
189 pdata->config = &mpfs_musb_hdrc_config; in mpfs_probe()
190 pdata->platform_ops = &mpfs_ops; in mpfs_probe()
192 pdata->mode = usb_get_dr_mode(dev); in mpfs_probe()
193 if (pdata->mode == USB_DR_MODE_UNKNOWN) { in mpfs_probe()
195 pdata->mode = USB_DR_MODE_OTG; in mpfs_probe()
198 glue->phy = usb_phy_generic_register(); in mpfs_probe()
199 if (IS_ERR(glue->phy)) { in mpfs_probe()
200 dev_err(dev, "failed to register usb-phy %ld\n", in mpfs_probe()
201 PTR_ERR(glue->phy)); in mpfs_probe()
202 ret = PTR_ERR(glue->phy); in mpfs_probe()
206 platform_set_drvdata(pdev, glue); in mpfs_probe()
208 ret = platform_device_add_resources(musb_pdev, pdev->resource, pdev->num_resources); in mpfs_probe()
226 dev_info(&pdev->dev, "Registered MPFS MUSB driver\n"); in mpfs_probe()
233 usb_phy_generic_unregister(glue->phy); in mpfs_probe()
240 struct mpfs_glue *glue = platform_get_drvdata(pdev); in mpfs_remove() local
242 clk_disable_unprepare(glue->clk); in mpfs_remove()
243 platform_device_unregister(glue->musb); in mpfs_remove()
251 { .compatible = "microchip,mpfs-musb" },
261 .name = "mpfs-musb",
268 MODULE_DESCRIPTION("PolarFire SoC MUSB Glue Layer");