Lines Matching refs:vhub
34 struct ast_vhub *vhub = ep->vhub; in ast_vhub_done() local
45 usb_gadget_unmap_request_by_dev(&vhub->pdev->dev, in ast_vhub_done()
55 spin_unlock(&ep->vhub->lock); in ast_vhub_done()
57 spin_lock(&ep->vhub->lock); in ast_vhub_done()
96 struct ast_vhub *vhub = data; in ast_vhub_irq() local
101 if (!vhub->ep0_bufs) in ast_vhub_irq()
104 spin_lock(&vhub->lock); in ast_vhub_irq()
107 istat = readl(vhub->regs + AST_VHUB_ISR); in ast_vhub_irq()
110 writel(istat, vhub->regs + AST_VHUB_ISR); in ast_vhub_irq()
113 UDCVDBG(vhub, "irq status=%08x, ep_acks=%08x ep_nacks=%08x\n", in ast_vhub_irq()
115 readl(vhub->regs + AST_VHUB_EP_ACK_ISR), in ast_vhub_irq()
116 readl(vhub->regs + AST_VHUB_EP_NACK_ISR)); in ast_vhub_irq()
120 u32 ep_acks = readl(vhub->regs + AST_VHUB_EP_ACK_ISR); in ast_vhub_irq()
121 writel(ep_acks, vhub->regs + AST_VHUB_EP_ACK_ISR); in ast_vhub_irq()
123 for (i = 0; ep_acks && i < vhub->max_epns; i++) { in ast_vhub_irq()
126 ast_vhub_epn_ack_irq(&vhub->epns[i]); in ast_vhub_irq()
133 if (istat & vhub->port_irq_mask) { in ast_vhub_irq()
134 for (i = 0; i < vhub->max_ports; i++) { in ast_vhub_irq()
136 ast_vhub_dev_irq(&vhub->ports[i].dev); in ast_vhub_irq()
145 ast_vhub_ep0_handle_ack(&vhub->ep0, true); in ast_vhub_irq()
147 ast_vhub_ep0_handle_ack(&vhub->ep0, false); in ast_vhub_irq()
149 ast_vhub_ep0_handle_setup(&vhub->ep0); in ast_vhub_irq()
157 ast_vhub_hub_resume(vhub); in ast_vhub_irq()
159 ast_vhub_hub_suspend(vhub); in ast_vhub_irq()
161 ast_vhub_hub_reset(vhub); in ast_vhub_irq()
165 spin_unlock(&vhub->lock); in ast_vhub_irq()
169 void ast_vhub_init_hw(struct ast_vhub *vhub) in ast_vhub_init_hw() argument
173 UDCDBG(vhub,"(Re)Starting HW ...\n"); in ast_vhub_init_hw()
199 writel(ctrl, vhub->regs + AST_VHUB_CTRL); in ast_vhub_init_hw()
205 writel(ctrl, vhub->regs + AST_VHUB_CTRL); in ast_vhub_init_hw()
211 port_mask = GENMASK(vhub->max_ports, 1); in ast_vhub_init_hw()
215 port_mask, vhub->regs + AST_VHUB_SW_RESET); in ast_vhub_init_hw()
217 writel(0, vhub->regs + AST_VHUB_SW_RESET); in ast_vhub_init_hw()
220 epn_mask = GENMASK(vhub->max_epns - 1, 0); in ast_vhub_init_hw()
221 writel(0, vhub->regs + AST_VHUB_EP_ACK_IER); in ast_vhub_init_hw()
222 writel(0, vhub->regs + AST_VHUB_EP_NACK_IER); in ast_vhub_init_hw()
223 writel(epn_mask, vhub->regs + AST_VHUB_EP_ACK_ISR); in ast_vhub_init_hw()
224 writel(epn_mask, vhub->regs + AST_VHUB_EP_NACK_ISR); in ast_vhub_init_hw()
227 writel(0, vhub->regs + AST_VHUB_EP0_CTRL); in ast_vhub_init_hw()
230 vhub->regs + AST_VHUB_EP1_CTRL); in ast_vhub_init_hw()
231 writel(0, vhub->regs + AST_VHUB_EP1_STS_CHG); in ast_vhub_init_hw()
234 writel(vhub->ep0.buf_dma, vhub->regs + AST_VHUB_EP0_DATA); in ast_vhub_init_hw()
237 writel(0, vhub->regs + AST_VHUB_CONF); in ast_vhub_init_hw()
240 if (vhub->force_usb1) in ast_vhub_init_hw()
244 writel(ctrl, vhub->regs + AST_VHUB_CTRL); in ast_vhub_init_hw()
254 vhub->regs + AST_VHUB_IER); in ast_vhub_init_hw()
259 struct ast_vhub *vhub = platform_get_drvdata(pdev); in ast_vhub_remove() local
263 if (!vhub || !vhub->regs) in ast_vhub_remove()
267 for (i = 0; i < vhub->max_ports; i++) in ast_vhub_remove()
268 ast_vhub_del_dev(&vhub->ports[i].dev); in ast_vhub_remove()
270 spin_lock_irqsave(&vhub->lock, flags); in ast_vhub_remove()
273 writel(0, vhub->regs + AST_VHUB_IER); in ast_vhub_remove()
274 writel(VHUB_IRQ_ACK_ALL, vhub->regs + AST_VHUB_ISR); in ast_vhub_remove()
279 vhub->regs + AST_VHUB_CTRL); in ast_vhub_remove()
281 if (vhub->clk) in ast_vhub_remove()
282 clk_disable_unprepare(vhub->clk); in ast_vhub_remove()
284 spin_unlock_irqrestore(&vhub->lock, flags); in ast_vhub_remove()
286 if (vhub->ep0_bufs) in ast_vhub_remove()
289 (vhub->max_ports + 1), in ast_vhub_remove()
290 vhub->ep0_bufs, in ast_vhub_remove()
291 vhub->ep0_bufs_dma); in ast_vhub_remove()
292 vhub->ep0_bufs = NULL; in ast_vhub_remove()
300 struct ast_vhub *vhub; in ast_vhub_probe() local
305 vhub = devm_kzalloc(&pdev->dev, sizeof(*vhub), GFP_KERNEL); in ast_vhub_probe()
306 if (!vhub) in ast_vhub_probe()
310 &vhub->max_ports); in ast_vhub_probe()
312 vhub->max_ports = AST_VHUB_NUM_PORTS; in ast_vhub_probe()
314 vhub->ports = devm_kcalloc(&pdev->dev, vhub->max_ports, in ast_vhub_probe()
315 sizeof(*vhub->ports), GFP_KERNEL); in ast_vhub_probe()
316 if (!vhub->ports) in ast_vhub_probe()
320 &vhub->max_epns); in ast_vhub_probe()
322 vhub->max_epns = AST_VHUB_NUM_GEN_EPs; in ast_vhub_probe()
324 vhub->epns = devm_kcalloc(&pdev->dev, vhub->max_epns, in ast_vhub_probe()
325 sizeof(*vhub->epns), GFP_KERNEL); in ast_vhub_probe()
326 if (!vhub->epns) in ast_vhub_probe()
329 spin_lock_init(&vhub->lock); in ast_vhub_probe()
330 vhub->pdev = pdev; in ast_vhub_probe()
331 vhub->port_irq_mask = GENMASK(VHUB_IRQ_DEV1_BIT + vhub->max_ports - 1, in ast_vhub_probe()
335 vhub->regs = devm_ioremap_resource(&pdev->dev, res); in ast_vhub_probe()
336 if (IS_ERR(vhub->regs)) { in ast_vhub_probe()
338 return PTR_ERR(vhub->regs); in ast_vhub_probe()
340 UDCDBG(vhub, "vHub@%pR mapped @%p\n", res, vhub->regs); in ast_vhub_probe()
342 platform_set_drvdata(pdev, vhub); in ast_vhub_probe()
344 vhub->clk = devm_clk_get(&pdev->dev, NULL); in ast_vhub_probe()
345 if (IS_ERR(vhub->clk)) { in ast_vhub_probe()
346 rc = PTR_ERR(vhub->clk); in ast_vhub_probe()
349 rc = clk_prepare_enable(vhub->clk); in ast_vhub_probe()
358 vhub->force_usb1 = true; in ast_vhub_probe()
361 writel(0, vhub->regs + AST_VHUB_IER); in ast_vhub_probe()
362 writel(VHUB_IRQ_ACK_ALL, vhub->regs + AST_VHUB_ISR); in ast_vhub_probe()
365 vhub->irq = platform_get_irq(pdev, 0); in ast_vhub_probe()
366 if (vhub->irq < 0) { in ast_vhub_probe()
367 rc = vhub->irq; in ast_vhub_probe()
370 rc = devm_request_irq(&pdev->dev, vhub->irq, ast_vhub_irq, 0, in ast_vhub_probe()
371 KBUILD_MODNAME, vhub); in ast_vhub_probe()
381 vhub->ep0_bufs = dma_alloc_coherent(&pdev->dev, in ast_vhub_probe()
383 (vhub->max_ports + 1), in ast_vhub_probe()
384 &vhub->ep0_bufs_dma, GFP_KERNEL); in ast_vhub_probe()
385 if (!vhub->ep0_bufs) { in ast_vhub_probe()
390 UDCVDBG(vhub, "EP0 DMA buffers @%p (DMA 0x%08x)\n", in ast_vhub_probe()
391 vhub->ep0_bufs, (u32)vhub->ep0_bufs_dma); in ast_vhub_probe()
394 ast_vhub_init_ep0(vhub, &vhub->ep0, NULL); in ast_vhub_probe()
397 for (i = 0; i < vhub->max_ports && rc == 0; i++) in ast_vhub_probe()
398 rc = ast_vhub_init_dev(vhub, i); in ast_vhub_probe()
403 rc = ast_vhub_init_hub(vhub); in ast_vhub_probe()
408 ast_vhub_init_hw(vhub); in ast_vhub_probe()
411 vhub->force_usb1 ? 1 : 2); in ast_vhub_probe()