Lines Matching +full:ring +full:- +full:disable +full:- +full:pullup

1 // SPDX-License-Identifier: GPL-2.0+
8 #include <linux/dma-mapping.h>
110 * per-endpoint register definitions *
241 dev_dbg(&(u)->pdev->dev, "%s() " fmt, __func__, ##__VA_ARGS__)
248 dev_dbg(&(e)->udc->pdev->dev, "%s():%s " fmt, __func__, \
249 (e)->ep.name, ##__VA_ARGS__)
256 dev_dbg(&(u)->pdev->dev, "%s() " fmt, __func__, ##__VA_ARGS__)
263 dev_dbg(&(u)->pdev->dev, "%s() " fmt, __func__, ##__VA_ARGS__)
268 /*-------------------------------------------------------------------------*/
270 readl((udc)->reg + (offset))
272 writel((val), (udc)->reg + (offset))
275 readl((ep)->ep_reg + (reg))
277 writel((val), (ep)->ep_reg + (reg))
279 /*-------------------------------------------------------------------------*/
284 struct ast_udc_dev *udc = ep->udc; in ast_udc_done()
287 req, req->req.actual, req->req.length, in ast_udc_done()
288 (u32)req->req.buf, ep->dir_in); in ast_udc_done()
290 list_del(&req->queue); in ast_udc_done()
292 if (req->req.status == -EINPROGRESS) in ast_udc_done()
293 req->req.status = status; in ast_udc_done()
295 status = req->req.status; in ast_udc_done()
297 if (status && status != -ESHUTDOWN) in ast_udc_done()
300 spin_unlock(&udc->lock); in ast_udc_done()
301 usb_gadget_giveback_request(&ep->ep, &req->req); in ast_udc_done()
302 spin_lock(&udc->lock); in ast_udc_done()
309 while (!list_empty(&ep->queue)) { in ast_udc_nuke()
312 req = list_entry(ep->queue.next, struct ast_udc_request, in ast_udc_nuke()
335 ep = &udc->ep[i]; in ast_udc_stop_activity()
336 ep->stopped = 1; in ast_udc_stop_activity()
337 ast_udc_nuke(ep, -ESHUTDOWN); in ast_udc_stop_activity()
346 struct ast_udc_dev *udc = ep->udc; in ast_udc_ep_enable()
353 if (!_ep || !ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT || in ast_udc_ep_enable()
354 maxpacket == 0 || maxpacket > ep->ep.maxpacket) { in ast_udc_ep_enable()
356 return -EINVAL; in ast_udc_ep_enable()
359 if (!udc->driver) { in ast_udc_ep_enable()
361 return -ESHUTDOWN; in ast_udc_ep_enable()
366 spin_lock_irqsave(&udc->lock, flags); in ast_udc_ep_enable()
368 ep->desc = desc; in ast_udc_ep_enable()
369 ep->stopped = 0; in ast_udc_ep_enable()
370 ep->ep.maxpacket = maxpacket; in ast_udc_ep_enable()
371 ep->chunk_max = AST_EP_DMA_DESC_MAX_LEN; in ast_udc_ep_enable()
380 ep->dir_in = dir_in; in ast_udc_ep_enable()
381 if (!ep->dir_in) in ast_udc_ep_enable()
399 ep->desc_mode = udc->desc_mode && ep->descs_dma && ep->dir_in; in ast_udc_ep_enable()
400 if (ep->desc_mode) { in ast_udc_ep_enable()
403 ast_ep_write(ep, ep->descs_dma, AST_UDC_EP_DMA_BUFF); in ast_udc_ep_enable()
409 ep->descs_wptr = 0; in ast_udc_ep_enable()
425 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_ep_enable()
433 struct ast_udc_dev *udc = ep->udc; in ast_udc_ep_disable()
436 spin_lock_irqsave(&udc->lock, flags); in ast_udc_ep_disable()
438 ep->ep.desc = NULL; in ast_udc_ep_disable()
439 ep->stopped = 1; in ast_udc_ep_disable()
441 ast_udc_nuke(ep, -ESHUTDOWN); in ast_udc_ep_disable()
444 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_ep_disable()
461 INIT_LIST_HEAD(&req->queue); in ast_udc_ep_alloc_request()
463 return &req->req; in ast_udc_ep_alloc_request()
477 struct ast_udc_dev *udc = ep->udc; in ast_dma_descriptor_setup()
478 struct device *dev = &udc->pdev->dev; in ast_dma_descriptor_setup()
483 if (!ep->descs) { in ast_dma_descriptor_setup()
485 ep->ep.name); in ast_dma_descriptor_setup()
486 return -EINVAL; in ast_dma_descriptor_setup()
493 "wptr", ep->descs_wptr, "dma_buf", dma_buf, in ast_dma_descriptor_setup()
499 ep->descs[ep->descs_wptr].des_0 = dma_buf + offset; in ast_dma_descriptor_setup()
501 if (chunk > ep->chunk_max) { in ast_dma_descriptor_setup()
502 ep->descs[ep->descs_wptr].des_1 = ep->chunk_max; in ast_dma_descriptor_setup()
504 ep->descs[ep->descs_wptr].des_1 = chunk; in ast_dma_descriptor_setup()
508 chunk -= ep->chunk_max; in ast_dma_descriptor_setup()
511 ep->descs_wptr, in ast_dma_descriptor_setup()
512 ep->descs[ep->descs_wptr].des_0, in ast_dma_descriptor_setup()
513 ep->descs[ep->descs_wptr].des_1); in ast_dma_descriptor_setup()
516 req->saved_dma_wptr = ep->descs_wptr; in ast_dma_descriptor_setup()
518 ep->descs_wptr++; in ast_dma_descriptor_setup()
521 if (ep->descs_wptr >= AST_UDC_DESCS_COUNT) in ast_dma_descriptor_setup()
522 ep->descs_wptr = 0; in ast_dma_descriptor_setup()
524 offset = ep->chunk_max * count; in ast_dma_descriptor_setup()
535 last = req->req.length - req->req.actual; in ast_udc_epn_kick()
536 tx_len = last > ep->ep.maxpacket ? ep->ep.maxpacket : last; in ast_udc_epn_kick()
539 req, tx_len, ep->dir_in); in ast_udc_epn_kick()
541 ast_ep_write(ep, req->req.dma + req->req.actual, AST_UDC_EP_DMA_BUFF); in ast_udc_epn_kick()
558 last = req->req.length - req->req.actual; in ast_udc_epn_kick_desc()
562 req, "tx_len", tx_len, "dir_in", ep->dir_in, in ast_udc_epn_kick_desc()
563 "dma", req->req.dma + req->req.actual, in ast_udc_epn_kick_desc()
564 req->req.actual, req->req.length, in ast_udc_epn_kick_desc()
567 if (!ast_dma_descriptor_setup(ep, req->req.dma + req->req.actual, in ast_udc_epn_kick_desc()
569 req->actual_dma_length += tx_len; in ast_udc_epn_kick_desc()
574 ast_ep_write(ep, ep->descs_wptr, AST_UDC_EP_DMA_STS); in ast_udc_epn_kick_desc()
577 ep->descs_wptr, in ast_udc_epn_kick_desc()
585 struct ast_udc_dev *udc = ep->udc; in ast_udc_ep0_queue()
589 last = req->req.length - req->req.actual; in ast_udc_ep0_queue()
590 tx_len = last > ep->ep.maxpacket ? ep->ep.maxpacket : last; in ast_udc_ep0_queue()
592 ast_udc_write(udc, req->req.dma + req->req.actual, in ast_udc_ep0_queue()
595 if (ep->dir_in) { in ast_udc_ep0_queue()
598 "buf", (u32)req->req.buf, in ast_udc_ep0_queue()
599 "dma", req->req.dma + req->req.actual, in ast_udc_ep0_queue()
601 req->req.actual, req->req.length, in ast_udc_ep0_queue()
602 "dir_in", ep->dir_in); in ast_udc_ep0_queue()
604 req->req.actual += tx_len; in ast_udc_ep0_queue()
612 "buf", (u32)req->req.buf, in ast_udc_ep0_queue()
613 "dma", req->req.dma + req->req.actual, in ast_udc_ep0_queue()
614 "len", req->req.actual, req->req.length, in ast_udc_ep0_queue()
615 "dir_in", ep->dir_in); in ast_udc_ep0_queue()
617 if (!req->req.length) { in ast_udc_ep0_queue()
620 ep->dir_in = 0x1; in ast_udc_ep0_queue()
631 struct ast_udc_dev *udc = ep->udc; in ast_udc_ep_queue()
632 struct device *dev = &udc->pdev->dev; in ast_udc_ep_queue()
636 if (unlikely(!_req || !_req->complete || !_req->buf || !_ep)) { in ast_udc_ep_queue()
638 return -EINVAL; in ast_udc_ep_queue()
641 if (ep->stopped) { in ast_udc_ep_queue()
642 dev_warn(dev, "%s is already stopped !\n", _ep->name); in ast_udc_ep_queue()
643 return -ESHUTDOWN; in ast_udc_ep_queue()
646 spin_lock_irqsave(&udc->lock, flags); in ast_udc_ep_queue()
648 list_add_tail(&req->queue, &ep->queue); in ast_udc_ep_queue()
650 req->req.actual = 0; in ast_udc_ep_queue()
651 req->req.status = -EINPROGRESS; in ast_udc_ep_queue()
652 req->actual_dma_length = 0; in ast_udc_ep_queue()
654 rc = usb_gadget_map_request(&udc->gadget, &req->req, ep->dir_in); in ast_udc_ep_queue()
663 _req->length, _req->dma, _req->zero, ep->dir_in); in ast_udc_ep_queue()
666 if (ep->ep.desc == NULL) { in ast_udc_ep_queue()
667 if ((req->req.dma % 4) != 0) { in ast_udc_ep_queue()
669 rc = -ESHUTDOWN; in ast_udc_ep_queue()
678 if (list_is_singular(&ep->queue)) { in ast_udc_ep_queue()
679 if (ep->desc_mode) in ast_udc_ep_queue()
686 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_ep_queue()
694 struct ast_udc_dev *udc = ep->udc; in ast_udc_ep_dequeue()
699 spin_lock_irqsave(&udc->lock, flags); in ast_udc_ep_dequeue()
702 list_for_each_entry(req, &ep->queue, queue) { in ast_udc_ep_dequeue()
703 if (&req->req == _req) { in ast_udc_ep_dequeue()
704 list_del_init(&req->queue); in ast_udc_ep_dequeue()
705 ast_udc_done(ep, req, -ESHUTDOWN); in ast_udc_ep_dequeue()
706 _req->status = -ECONNRESET; in ast_udc_ep_dequeue()
712 if (&req->req != _req) in ast_udc_ep_dequeue()
713 rc = -EINVAL; in ast_udc_ep_dequeue()
715 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_ep_dequeue()
723 struct ast_udc_dev *udc = ep->udc; in ast_udc_ep_set_halt()
730 spin_lock_irqsave(&udc->lock, flags); in ast_udc_ep_set_halt()
732 epnum = usb_endpoint_num(ep->desc); in ast_udc_ep_set_halt()
755 ep->stopped = value ? 1 : 0; in ast_udc_ep_set_halt()
758 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_ep_set_halt()
765 .disable = ast_udc_ep_disable,
776 ast_udc_write(udc, udc->ep0_buf_dma, AST_UDC_EP0_DATA_BUFF); in ast_udc_ep0_rx()
782 ast_udc_write(udc, udc->ep0_buf_dma, AST_UDC_EP0_DATA_BUFF); in ast_udc_ep0_tx()
788 struct device *dev = &udc->pdev->dev; in ast_udc_ep0_out()
789 struct ast_udc_ep *ep = &udc->ep[0]; in ast_udc_ep0_out()
793 if (list_empty(&ep->queue)) in ast_udc_ep0_out()
796 req = list_entry(ep->queue.next, struct ast_udc_request, queue); in ast_udc_ep0_out()
799 req->req.actual += rx_len; in ast_udc_ep0_out()
802 req->req.actual, req->req.length); in ast_udc_ep0_out()
804 if ((rx_len < ep->ep.maxpacket) || in ast_udc_ep0_out()
805 (req->req.actual == req->req.length)) { in ast_udc_ep0_out()
807 if (!ep->dir_in) in ast_udc_ep0_out()
811 if (rx_len > req->req.length) { in ast_udc_ep0_out()
814 req->req.actual, req->req.length); in ast_udc_ep0_out()
820 ep->dir_in = 0; in ast_udc_ep0_out()
829 struct ast_udc_ep *ep = &udc->ep[0]; in ast_udc_ep0_in()
832 if (list_empty(&ep->queue)) { in ast_udc_ep0_in()
833 if (udc->is_control_tx) { in ast_udc_ep0_in()
835 udc->is_control_tx = 0; in ast_udc_ep0_in()
841 req = list_entry(ep->queue.next, struct ast_udc_request, queue); in ast_udc_ep0_in()
844 req->req.actual, req->req.length); in ast_udc_ep0_in()
846 if (req->req.length == req->req.actual) { in ast_udc_ep0_in()
847 if (req->req.length) in ast_udc_ep0_in()
850 if (ep->dir_in) in ast_udc_ep0_in()
861 struct ast_udc_ep *ep = &udc->ep[ep_num]; in ast_udc_epn_handle()
865 if (list_empty(&ep->queue)) in ast_udc_epn_handle()
868 req = list_first_entry(&ep->queue, struct ast_udc_request, queue); in ast_udc_epn_handle()
871 req->req.actual += len; in ast_udc_epn_handle()
874 req->req.actual, req->req.length, "len", len); in ast_udc_epn_handle()
877 if (req->req.length == req->req.actual) { in ast_udc_epn_handle()
879 req = list_first_entry_or_null(&ep->queue, in ast_udc_epn_handle()
885 if (len < ep->ep.maxpacket) { in ast_udc_epn_handle()
887 req = list_first_entry_or_null(&ep->queue, in ast_udc_epn_handle()
900 struct ast_udc_ep *ep = &udc->ep[ep_num]; in ast_udc_epn_handle_desc()
901 struct device *dev = &udc->pdev->dev; in ast_udc_epn_handle_desc()
908 if (list_empty(&ep->queue)) { in ast_udc_epn_handle_desc()
909 dev_warn(dev, "%s request queue empty!\n", ep->ep.name); in ast_udc_epn_handle_desc()
913 req = list_first_entry(&ep->queue, struct ast_udc_request, queue); in ast_udc_epn_handle_desc()
938 i = req->saved_dma_wptr; in ast_udc_epn_handle_desc()
941 len_in_desc = EP_DESC1_IN_LEN(ep->descs[i].des_1); in ast_udc_epn_handle_desc()
950 req->req.actual += total_len; in ast_udc_epn_handle_desc()
953 req->req.actual, req->req.length, "len", total_len); in ast_udc_epn_handle_desc()
956 if (req->req.length == req->req.actual) { in ast_udc_epn_handle_desc()
958 req = list_first_entry_or_null(&ep->queue, in ast_udc_epn_handle_desc()
964 if (total_len < ep->ep.maxpacket) { in ast_udc_epn_handle_desc()
966 req = list_first_entry_or_null(&ep->queue, in ast_udc_epn_handle_desc()
973 if (req && (req->actual_dma_length == req->req.actual)) { in ast_udc_epn_handle_desc()
982 memcpy(udc->ep0_buf, tx_data, len); in ast_udc_ep0_data_tx()
984 ast_udc_write(udc, udc->ep0_buf_dma, AST_UDC_EP0_DATA_BUFF); in ast_udc_ep0_data_tx()
988 udc->is_control_tx = 1; in ast_udc_ep0_data_tx()
1001 memcpy_fromio(&crq, udc->creq, sizeof(crq)); in ast_udc_getstatus()
1014 status = udc->ep[epnum].stopped; in ast_udc_getstatus()
1020 ep = &udc->ep[epnum]; in ast_udc_getstatus()
1034 struct ast_udc_ep *ep = &udc->ep[0]; in ast_udc_ep0_handle_setup()
1041 memcpy_fromio(&crq, udc->creq, sizeof(crq)); in ast_udc_ep0_handle_setup()
1051 list_for_each_entry(req, &udc->ep[0].queue, queue) { in ast_udc_ep0_handle_setup()
1057 ast_udc_nuke(&udc->ep[0], -ETIMEDOUT); in ast_udc_ep0_handle_setup()
1059 udc->ep[0].dir_in = crq.bRequestType & USB_DIR_IN; in ast_udc_ep0_handle_setup()
1065 udc->gadget.speed = USB_SPEED_HIGH; in ast_udc_ep0_handle_setup()
1067 udc->gadget.speed = USB_SPEED_FULL; in ast_udc_ep0_handle_setup()
1095 if (udc->driver) { in ast_udc_ep0_handle_setup()
1097 udc->gadget.name); in ast_udc_ep0_handle_setup()
1099 spin_unlock(&udc->lock); in ast_udc_ep0_handle_setup()
1100 rc = udc->driver->setup(&udc->gadget, &crq); in ast_udc_ep0_handle_setup()
1101 spin_lock(&udc->lock); in ast_udc_ep0_handle_setup()
1128 spin_lock(&udc->lock); in ast_udc_isr()
1139 udc->gadget.speed = USB_SPEED_UNKNOWN; in ast_udc_isr()
1141 ep = &udc->ep[1]; in ast_udc_isr()
1145 if (udc->driver && udc->driver->reset) { in ast_udc_isr()
1146 spin_unlock(&udc->lock); in ast_udc_isr()
1147 udc->driver->reset(&udc->gadget); in ast_udc_isr()
1148 spin_lock(&udc->lock); in ast_udc_isr()
1154 udc->suspended_from = udc->gadget.state; in ast_udc_isr()
1155 usb_gadget_set_state(&udc->gadget, USB_STATE_SUSPENDED); in ast_udc_isr()
1157 if (udc->driver && udc->driver->suspend) { in ast_udc_isr()
1158 spin_unlock(&udc->lock); in ast_udc_isr()
1159 udc->driver->suspend(&udc->gadget); in ast_udc_isr()
1160 spin_lock(&udc->lock); in ast_udc_isr()
1166 usb_gadget_set_state(&udc->gadget, udc->suspended_from); in ast_udc_isr()
1168 if (udc->driver && udc->driver->resume) { in ast_udc_isr()
1169 spin_unlock(&udc->lock); in ast_udc_isr()
1170 udc->driver->resume(&udc->gadget); in ast_udc_isr()
1171 spin_lock(&udc->lock); in ast_udc_isr()
1198 for (i = 0; i < AST_UDC_NUM_ENDPOINTS - 1; i++) { in ast_udc_isr()
1200 ep = &udc->ep[i + 1]; in ast_udc_isr()
1201 if (ep->desc_mode) in ast_udc_isr()
1210 spin_unlock(&udc->lock); in ast_udc_isr()
1228 spin_lock_irqsave(&udc->lock, flags); in ast_udc_wake_work()
1234 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_wake_work()
1244 schedule_work(&udc->wake_work); in ast_udc_wakeup_all()
1253 spin_lock_irqsave(&udc->lock, flags); in ast_udc_wakeup()
1255 if (!udc->wakeup_en) { in ast_udc_wakeup()
1257 rc = -EINVAL; in ast_udc_wakeup()
1265 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_wakeup()
1278 spin_lock_irqsave(&udc->lock, flags); in ast_udc_pullup()
1288 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_pullup()
1301 spin_lock_irqsave(&udc->lock, flags); in ast_udc_start()
1304 udc->driver = driver; in ast_udc_start()
1305 udc->gadget.dev.of_node = udc->pdev->dev.of_node; in ast_udc_start()
1308 ep = &udc->ep[i]; in ast_udc_start()
1309 ep->stopped = 0; in ast_udc_start()
1312 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_start()
1323 spin_lock_irqsave(&udc->lock, flags); in ast_udc_stop()
1329 udc->gadget.speed = USB_SPEED_UNKNOWN; in ast_udc_stop()
1330 udc->driver = NULL; in ast_udc_stop()
1333 usb_gadget_set_state(&udc->gadget, USB_STATE_NOTATTACHED); in ast_udc_stop()
1335 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_stop()
1343 .pullup = ast_udc_pullup,
1359 ep = &udc->ep[i]; in ast_udc_init_ep()
1360 ep->ep.name = ast_ep_name[i]; in ast_udc_init_ep()
1362 ep->ep.caps.type_control = true; in ast_udc_init_ep()
1364 ep->ep.caps.type_iso = true; in ast_udc_init_ep()
1365 ep->ep.caps.type_bulk = true; in ast_udc_init_ep()
1366 ep->ep.caps.type_int = true; in ast_udc_init_ep()
1368 ep->ep.caps.dir_in = true; in ast_udc_init_ep()
1369 ep->ep.caps.dir_out = true; in ast_udc_init_ep()
1371 ep->ep.ops = &ast_udc_ep_ops; in ast_udc_init_ep()
1372 ep->udc = udc; in ast_udc_init_ep()
1374 INIT_LIST_HEAD(&ep->queue); in ast_udc_init_ep()
1377 usb_ep_set_maxpacket_limit(&ep->ep, in ast_udc_init_ep()
1382 ep->ep_reg = udc->reg + AST_UDC_EP_BASE + in ast_udc_init_ep()
1383 (AST_UDC_EP_OFFSET * (i - 1)); in ast_udc_init_ep()
1385 ep->epn_buf = udc->ep0_buf + (i * AST_UDC_EP_DMA_SIZE); in ast_udc_init_ep()
1386 ep->epn_buf_dma = udc->ep0_buf_dma + (i * AST_UDC_EP_DMA_SIZE); in ast_udc_init_ep()
1387 usb_ep_set_maxpacket_limit(&ep->ep, AST_UDC_EPn_MAX_PACKET); in ast_udc_init_ep()
1389 ep->descs = ep->epn_buf + AST_UDC_EPn_MAX_PACKET; in ast_udc_init_ep()
1390 ep->descs_dma = ep->epn_buf_dma + AST_UDC_EPn_MAX_PACKET; in ast_udc_init_ep()
1391 ep->descs_wptr = 0; in ast_udc_init_ep()
1393 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in ast_udc_init_ep()
1399 INIT_WORK(&udc->wake_work, ast_udc_wake_work); in ast_udc_init_dev()
1413 /* Set descriptor ring size */ in ast_udc_init_hw()
1443 usb_del_gadget_udc(&udc->gadget); in ast_udc_remove()
1444 if (udc->driver) in ast_udc_remove()
1445 return -EBUSY; in ast_udc_remove()
1447 spin_lock_irqsave(&udc->lock, flags); in ast_udc_remove()
1449 /* Disable upstream port connection */ in ast_udc_remove()
1453 clk_disable_unprepare(udc->clk); in ast_udc_remove()
1455 spin_unlock_irqrestore(&udc->lock, flags); in ast_udc_remove()
1457 if (udc->ep0_buf) in ast_udc_remove()
1458 dma_free_coherent(&pdev->dev, in ast_udc_remove()
1460 udc->ep0_buf, in ast_udc_remove()
1461 udc->ep0_buf_dma); in ast_udc_remove()
1463 udc->ep0_buf = NULL; in ast_udc_remove()
1471 struct device *dev = &pdev->dev; in ast_udc_probe()
1475 udc = devm_kzalloc(&pdev->dev, sizeof(struct ast_udc_dev), GFP_KERNEL); in ast_udc_probe()
1477 return -ENOMEM; in ast_udc_probe()
1479 udc->gadget.dev.parent = dev; in ast_udc_probe()
1480 udc->pdev = pdev; in ast_udc_probe()
1481 spin_lock_init(&udc->lock); in ast_udc_probe()
1483 udc->gadget.ops = &ast_udc_ops; in ast_udc_probe()
1484 udc->gadget.ep0 = &udc->ep[0].ep; in ast_udc_probe()
1485 udc->gadget.name = "aspeed-udc"; in ast_udc_probe()
1486 udc->gadget.dev.init_name = "gadget"; in ast_udc_probe()
1488 udc->reg = devm_platform_ioremap_resource(pdev, 0); in ast_udc_probe()
1489 if (IS_ERR(udc->reg)) { in ast_udc_probe()
1490 dev_err(&pdev->dev, "Failed to map resources\n"); in ast_udc_probe()
1491 return PTR_ERR(udc->reg); in ast_udc_probe()
1496 udc->clk = devm_clk_get(&pdev->dev, NULL); in ast_udc_probe()
1497 if (IS_ERR(udc->clk)) { in ast_udc_probe()
1498 rc = PTR_ERR(udc->clk); in ast_udc_probe()
1501 rc = clk_prepare_enable(udc->clk); in ast_udc_probe()
1503 dev_err(&pdev->dev, "Failed to enable clock (0x%x)\n", rc); in ast_udc_probe()
1508 max_speed = usb_get_maximum_speed(&pdev->dev); in ast_udc_probe()
1510 udc->force_usb1 = true; in ast_udc_probe()
1515 udc->ep0_buf = dma_alloc_coherent(&pdev->dev, in ast_udc_probe()
1518 &udc->ep0_buf_dma, GFP_KERNEL); in ast_udc_probe()
1520 udc->gadget.speed = USB_SPEED_UNKNOWN; in ast_udc_probe()
1521 udc->gadget.max_speed = USB_SPEED_HIGH; in ast_udc_probe()
1522 udc->creq = udc->reg + AST_UDC_SETUP0; in ast_udc_probe()
1528 udc->desc_mode = AST_UDC_DESC_MODE; in ast_udc_probe()
1530 dev_info(&pdev->dev, "DMA %s\n", udc->desc_mode ? in ast_udc_probe()
1533 INIT_LIST_HEAD(&udc->gadget.ep_list); in ast_udc_probe()
1534 INIT_LIST_HEAD(&udc->gadget.ep0->ep_list); in ast_udc_probe()
1546 udc->irq = platform_get_irq(pdev, 0); in ast_udc_probe()
1547 if (udc->irq < 0) { in ast_udc_probe()
1548 rc = udc->irq; in ast_udc_probe()
1552 rc = devm_request_irq(&pdev->dev, udc->irq, ast_udc_isr, 0, in ast_udc_probe()
1555 dev_err(&pdev->dev, "Failed to request interrupt\n"); in ast_udc_probe()
1559 rc = usb_add_gadget_udc(&pdev->dev, &udc->gadget); in ast_udc_probe()
1561 dev_err(&pdev->dev, "Failed to add gadget udc\n"); in ast_udc_probe()
1565 dev_info(&pdev->dev, "Initialized udc in USB%s mode\n", in ast_udc_probe()
1566 udc->force_usb1 ? "1" : "2"); in ast_udc_probe()
1571 dev_err(&pdev->dev, "Failed to udc probe, rc:0x%x\n", rc); in ast_udc_probe()
1578 { .compatible = "aspeed,ast2600-udc", },