Lines Matching +full:jz4740 +full:- +full:musb

1 // SPDX-License-Identifier: GPL-2.0+
3 * Ingenic JZ4740 "glue layer"
9 #include <linux/dma-mapping.h>
23 struct musb *musb; member
32 struct musb *musb = __hci; in jz4740_musb_interrupt() local
34 if (IS_ENABLED(CONFIG_USB_INVENTRA_DMA) && musb->dma_controller) in jz4740_musb_interrupt()
35 retval_dma = dma_controller_irq(irq, musb->dma_controller); in jz4740_musb_interrupt()
37 spin_lock_irqsave(&musb->lock, flags); in jz4740_musb_interrupt()
39 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); in jz4740_musb_interrupt()
40 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); in jz4740_musb_interrupt()
41 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); in jz4740_musb_interrupt()
45 * undefined. Mask them to make sure that the musb driver core will in jz4740_musb_interrupt()
48 musb->int_usb &= MUSB_INTR_SUSPEND | MUSB_INTR_RESUME | in jz4740_musb_interrupt()
51 if (musb->int_usb || musb->int_tx || musb->int_rx) in jz4740_musb_interrupt()
52 retval = musb_interrupt(musb); in jz4740_musb_interrupt()
54 spin_unlock_irqrestore(&musb->lock, flags); in jz4740_musb_interrupt()
83 struct usb_phy *phy = glue->musb->xceiv; in jz4740_musb_role_switch_set()
90 atomic_notifier_call_chain(&phy->notifier, USB_EVENT_NONE, phy); in jz4740_musb_role_switch_set()
93 atomic_notifier_call_chain(&phy->notifier, USB_EVENT_VBUS, phy); in jz4740_musb_role_switch_set()
96 atomic_notifier_call_chain(&phy->notifier, USB_EVENT_ID, phy); in jz4740_musb_role_switch_set()
103 static int jz4740_musb_init(struct musb *musb) in jz4740_musb_init() argument
105 struct device *dev = musb->controller->parent; in jz4740_musb_init()
114 glue->musb = musb; in jz4740_musb_init()
117 musb->phy = devm_of_phy_get_by_index(dev, dev->of_node, 0); in jz4740_musb_init()
118 if (IS_ERR(musb->phy)) { in jz4740_musb_init()
119 err = PTR_ERR(musb->phy); in jz4740_musb_init()
120 if (err != -ENODEV) { in jz4740_musb_init()
125 musb->phy = NULL; in jz4740_musb_init()
129 if (musb->phy) { in jz4740_musb_init()
130 err = phy_init(musb->phy); in jz4740_musb_init()
136 err = phy_power_on(musb->phy); in jz4740_musb_init()
142 if (dev->of_node) in jz4740_musb_init()
143 musb->xceiv = devm_usb_get_phy_by_phandle(dev, "phys", 0); in jz4740_musb_init()
145 musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); in jz4740_musb_init()
146 if (IS_ERR(musb->xceiv)) { in jz4740_musb_init()
148 return PTR_ERR(musb->xceiv); in jz4740_musb_init()
152 glue->role_sw = usb_role_switch_register(dev, &role_sw_desc); in jz4740_musb_init()
153 if (IS_ERR(glue->role_sw)) { in jz4740_musb_init()
155 err = PTR_ERR(glue->role_sw); in jz4740_musb_init()
163 musb->dyn_fifo = true; in jz4740_musb_init()
165 musb->isr = jz4740_musb_interrupt; in jz4740_musb_init()
170 if (musb->phy) in jz4740_musb_init()
171 phy_power_off(musb->phy); in jz4740_musb_init()
173 if (musb->phy) in jz4740_musb_init()
174 phy_exit(musb->phy); in jz4740_musb_init()
178 static int jz4740_musb_exit(struct musb *musb) in jz4740_musb_exit() argument
180 struct jz4740_glue *glue = dev_get_drvdata(musb->controller->parent); in jz4740_musb_exit()
182 usb_role_switch_unregister(glue->role_sw); in jz4740_musb_exit()
183 if (musb->phy) { in jz4740_musb_exit()
184 phy_power_off(musb->phy); in jz4740_musb_exit()
185 phy_exit(musb->phy); in jz4740_musb_exit()
237 struct device *dev = &pdev->dev; in jz4740_probe()
239 struct platform_device *musb; in jz4740_probe() local
246 return -ENOMEM; in jz4740_probe()
251 return -EINVAL; in jz4740_probe()
254 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); in jz4740_probe()
255 if (!musb) { in jz4740_probe()
256 dev_err(dev, "failed to allocate musb device\n"); in jz4740_probe()
257 return -ENOMEM; in jz4740_probe()
273 musb->dev.parent = dev; in jz4740_probe()
274 musb->dev.dma_mask = &musb->dev.coherent_dma_mask; in jz4740_probe()
275 musb->dev.coherent_dma_mask = DMA_BIT_MASK(32); in jz4740_probe()
276 device_set_of_node_from_dev(&musb->dev, dev); in jz4740_probe()
278 glue->pdev = musb; in jz4740_probe()
279 glue->clk = clk; in jz4740_probe()
283 ret = platform_device_add_resources(musb, pdev->resource, in jz4740_probe()
284 pdev->num_resources); in jz4740_probe()
290 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); in jz4740_probe()
296 ret = platform_device_add(musb); in jz4740_probe()
298 dev_err(dev, "failed to register musb device\n"); in jz4740_probe()
307 platform_device_put(musb); in jz4740_probe()
315 platform_device_unregister(glue->pdev); in jz4740_remove()
316 clk_disable_unprepare(glue->clk); in jz4740_remove()
320 { .compatible = "ingenic,jz4740-musb", .data = &jz4740_musb_pdata },
321 { .compatible = "ingenic,jz4770-musb", .data = &jz4770_musb_pdata },
330 .name = "musb-jz4740",
335 MODULE_DESCRIPTION("JZ4740 MUSB Glue Layer");