After the resync a big part of ci_udc.c is not used in u-boot. Remove
it.

Co-developed-by: Jerome Forissier <[email protected]>
Signed-off-by: Jerome Forissier <[email protected]>
Co-developed-by: Jens Wiklander <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
Signed-off-by: Anders Roxell <[email protected]>
---
 drivers/usb/gadget/ci_udc.c | 470 ------------------------------------
 1 file changed, 470 deletions(-)

diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index 4729570c5257..95efa4ae1644 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -84,62 +84,15 @@ static struct usb_endpoint_descriptor ep0_desc = {
 };
 
 static int ci_pullup(struct usb_gadget *gadget, int is_on);
-static int ci_ep_enable(struct usb_ep *ep,
-               const struct usb_endpoint_descriptor *desc);
-static int ci_ep_disable(struct usb_ep *ep);
-static int ci_ep_queue(struct usb_ep *ep,
-               struct usb_request *req, gfp_t gfp_flags);
-static int ci_ep_dequeue(struct usb_ep *ep, struct usb_request *req);
-static struct usb_request *
-ci_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags);
-static void ci_ep_free_request(struct usb_ep *ep, struct usb_request *_req);
 
 static const struct usb_gadget_ops ci_udc_ops = {
        .pullup = ci_pullup,
 };
 
-static const struct usb_ep_ops ci_ep_ops = {
-       .enable         = ci_ep_enable,
-       .disable        = ci_ep_disable,
-       .queue          = ci_ep_queue,
-       .dequeue        = ci_ep_dequeue,
-       .alloc_request  = ci_ep_alloc_request,
-       .free_request   = ci_ep_free_request,
-};
-
 __weak void ci_init_after_reset(struct ehci_ctrl *ctrl)
 {
 }
 
-/* Init values for USB endpoints. */
-static const struct usb_ep ci_ep_init[5] = {
-       [0] = { /* EP 0 */
-               .maxpacket      = 64,
-               .name           = "ep0",
-               .ops            = &ci_ep_ops,
-       },
-       [1] = {
-               .maxpacket      = 512,
-               .name           = "ep1in-bulk",
-               .ops            = &ci_ep_ops,
-       },
-       [2] = {
-               .maxpacket      = 512,
-               .name           = "ep2out-bulk",
-               .ops            = &ci_ep_ops,
-       },
-       [3] = {
-               .maxpacket      = 512,
-               .name           = "ep3in-int",
-               .ops            = &ci_ep_ops,
-       },
-       [4] = {
-               .maxpacket      = 512,
-               .name           = "ep-",
-               .ops            = &ci_ep_ops,
-       },
-};
-
 static struct ci_drv controller = {
        .gadget = {
                .name   = "ci_udc",
@@ -263,76 +216,6 @@ static void ci_invalidate_td(struct ept_queue_item *td)
        invalidate_dcache_range(start, end);
 }
 
-static struct usb_request *
-ci_ep_alloc_request(struct usb_ep *ep, unsigned int gfp_flags)
-{
-       struct ci_ep *ci_ep = container_of(ep, struct ci_ep, ep);
-       int num = -1;
-       struct ci_req *ci_req;
-
-       if (ci_ep->desc)
-               num = ci_ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-
-       if (num == 0 && controller.ep0_req) {
-               DBG("%s: already got controller.ep0_req = %p\n", __func__, 
controller.ep0_req);
-               return &controller.ep0_req->req;
-       }
-
-       ci_req = calloc(1, sizeof(*ci_req));
-       if (!ci_req)
-               return NULL;
-
-       INIT_LIST_HEAD(&ci_req->queue);
-
-       if (num == 0)
-               controller.ep0_req = ci_req;
-
-       return &ci_req->req;
-}
-
-static void ci_ep_free_request(struct usb_ep *ep, struct usb_request *req)
-{
-       struct ci_ep *ci_ep = container_of(ep, struct ci_ep, ep);
-       struct ci_req *ci_req = container_of(req, struct ci_req, req);
-       int num = -1;
-
-       if (ci_ep->desc)
-               num = ci_ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-       else
-               DBG("%s: no endpoint %p descriptor\n", __func__, ci_ep);
-
-       if (num == 0) {
-               if (!controller.ep0_req)
-                       return;
-               controller.ep0_req = 0;
-       }
-
-       if (ci_req->b_buf)
-               free(ci_req->b_buf);
-       free(ci_req);
-}
-
-static void request_complete(struct usb_ep *ep, struct ci_req *req, int status)
-{
-       if (req->req.status == -EINPROGRESS)
-               req->req.status = status;
-
-       DBG("%s: req %p complete: status %d, actual %u\n",
-           ep->name, req, req->req.status, req->req.actual);
-
-       req->req.complete(ep, &req->req);
-}
-
-static void request_complete_list(struct usb_ep *ep, struct list_head *list, 
int status)
-{
-       struct ci_req *req, *tmp_req;
-
-       list_for_each_entry_safe(req, tmp_req, list, queue) {
-               list_del_init(&req->queue);
-               request_complete(ep, req, status);
-       }
-}
-
 static void ep_enable(int num, int in, int maxpacket)
 {
        struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
@@ -353,145 +236,6 @@ static void ep_enable(int num, int in, int maxpacket)
        writel(n, &udc->epctrl[num]);
 }
 
-static int ci_ep_enable(struct usb_ep *ep,
-               const struct usb_endpoint_descriptor *desc)
-{
-       struct ci_ep *ci_ep = container_of(ep, struct ci_ep, ep);
-       int num, in;
-       num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-       in = (desc->bEndpointAddress & USB_DIR_IN) != 0;
-
-       if (ci_ep->desc) {
-               DBG("%s: endpoint num %d in %d already enabled\n", __func__, 
num, in);
-               return -EBUSY;
-       }
-
-       ci_ep->desc = desc;
-       ep->desc = desc;
-
-       if (num) {
-               int max = get_unaligned_le16(&desc->wMaxPacketSize);
-
-               if ((max > 64) && (controller.gadget.speed == USB_SPEED_FULL))
-                       max = 64;
-               if (ep->maxpacket != max) {
-                       DBG("%s: from %d to %d\n", __func__,
-                           ep->maxpacket, max);
-                       ep->maxpacket = max;
-               }
-       }
-       ep_enable(num, in, ep->maxpacket);
-       DBG("%s: num=%d maxpacket=%d\n", __func__, num, ep->maxpacket);
-       return 0;
-}
-
-static int ep_disable(int num, int in)
-{
-       struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
-       unsigned int ep_bit, enable_bit;
-       int err;
-
-       if (in) {
-               ep_bit = EPT_TX(num);
-               enable_bit = CTRL_TXE;
-       } else {
-               ep_bit = EPT_RX(num);
-               enable_bit = CTRL_RXE;
-       }
-
-       /* clear primed buffers */
-       do {
-               writel(ep_bit, &udc->epflush);
-               err = wait_for_bit_le32(&udc->epflush, ep_bit, false, 1000, 
false);
-               if (err)
-                       return err;
-       } while (readl(&udc->epstat) & ep_bit);
-
-       /* clear enable bit */
-       clrbits_le32(&udc->epctrl[num], enable_bit);
-
-       return 0;
-}
-
-static int ci_ep_disable(struct usb_ep *ep)
-{
-       struct ci_ep *ci_ep = container_of(ep, struct ci_ep, ep);
-       LIST_HEAD(req_list);
-       int num, in, err;
-
-       if (!ci_ep->desc) {
-               DBG("%s: attempt to disable a not enabled yet endpoint\n", 
__func__);
-               err = -EBUSY;
-               goto nodesc;
-       }
-
-       num = ci_ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-       in = (ci_ep->desc->bEndpointAddress & USB_DIR_IN) != 0;
-
-       list_splice_init(&ci_ep->queue, &req_list);
-       request_complete_list(ep, &req_list, -ESHUTDOWN);
-
-       err = ep_disable(num, in);
-       if (err)
-               return err;
-
-       ci_ep->desc = NULL;
-       err = 0;
-
-nodesc:
-       ep->desc = NULL;
-       ci_ep->req_primed = false;
-       return err;
-}
-
-static int ci_bounce(struct ci_req *ci_req, int in)
-{
-       struct usb_request *req = &ci_req->req;
-       unsigned long addr = (unsigned long)req->buf;
-       unsigned long hwaddr;
-       uint32_t aligned_used_len;
-
-       /* Input buffer address is not aligned. */
-       if (addr & (ARCH_DMA_MINALIGN - 1))
-               goto align;
-
-       /* Input buffer length is not aligned. */
-       if (req->length & (ARCH_DMA_MINALIGN - 1))
-               goto align;
-
-       /* The buffer is well aligned, only flush cache. */
-       ci_req->hw_len = req->length;
-       ci_req->hw_buf = req->buf;
-       goto flush;
-
-align:
-       if (ci_req->b_buf && req->length > ci_req->b_len) {
-               free(ci_req->b_buf);
-               ci_req->b_buf = 0;
-       }
-       if (!ci_req->b_buf) {
-               ci_req->b_len = roundup(req->length, ARCH_DMA_MINALIGN);
-               ci_req->b_buf = memalign(ARCH_DMA_MINALIGN, ci_req->b_len);
-               if (!ci_req->b_buf)
-                       return -ENOMEM;
-       }
-       ci_req->hw_len = ci_req->b_len;
-       ci_req->hw_buf = ci_req->b_buf;
-
-       if (in)
-               memcpy(ci_req->hw_buf, req->buf, req->length);
-
-flush:
-       hwaddr = (unsigned long)ci_req->hw_buf;
-       if (!hwaddr)
-               return 0;
-
-       aligned_used_len = roundup(req->length, ARCH_DMA_MINALIGN);
-       flush_dcache_range(hwaddr, hwaddr + aligned_used_len);
-
-       return 0;
-}
-
 static void ci_debounce(struct ci_req *ci_req, int in)
 {
        struct usb_request *req = &ci_req->req;
@@ -618,77 +362,6 @@ static void ci_ep_submit_next_request(struct ci_ep *ci_ep)
        writel(bit, &udc->epprime);
 }
 
-static int ci_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
-{
-       struct ci_ep *ci_ep = container_of(_ep, struct ci_ep, ep);
-       struct ci_req *ci_req;
-
-       list_for_each_entry(ci_req, &ci_ep->queue, queue) {
-               if (&ci_req->req == _req)
-                       break;
-       }
-
-       if (&ci_req->req != _req) {
-               DBG("%s: ci_req not found in the queue\n", __func__);
-               return -EINVAL;
-       }
-
-       list_del_init(&ci_req->queue);
-
-       if (ci_req->req.status == -EINPROGRESS) {
-               ci_req->req.status = -ECONNRESET;
-               if (ci_req->req.complete)
-                       ci_req->req.complete(_ep, _req);
-       }
-
-       return 0;
-}
-
-static int ci_ep_queue(struct usb_ep *ep,
-               struct usb_request *req, gfp_t gfp_flags)
-{
-       struct ci_ep *ci_ep = container_of(ep, struct ci_ep, ep);
-       struct ci_req *ci_req = container_of(req, struct ci_req, req);
-       int in, ret;
-       int __maybe_unused num;
-
-       if (!ci_ep->desc) {
-               DBG("%s: ci_ep->desc == NULL, nothing to do!\n", __func__);
-               return -EINVAL;
-       }
-
-       num = ci_ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-       in = (ci_ep->desc->bEndpointAddress & USB_DIR_IN) != 0;
-
-       if (!num && ci_ep->req_primed) {
-               /*
-                * The flipping of ep0 between IN and OUT relies on
-                * ci_ep_queue consuming the current IN/OUT setting
-                * immediately. If this is deferred to a later point when the
-                * req is pulled out of ci_req->queue, then the IN/OUT setting
-                * may have been changed since the req was queued, and state
-                * will get out of sync. This condition doesn't occur today,
-                * but could if bugs were introduced later, and this error
-                * check will save a lot of debugging time.
-                */
-               printf("%s: ep0 transaction already in progress\n", __func__);
-               return -EPROTO;
-       }
-
-       ret = ci_bounce(ci_req, in);
-       if (ret)
-               return ret;
-
-       DBG("ept%d %s pre-queue req %p, buffer %p\n",
-           num, in ? "in" : "out", ci_req, ci_req->hw_buf);
-       list_add_tail(&ci_req->queue, &ci_ep->queue);
-
-       if (!ci_ep->req_primed)
-               ci_ep_submit_next_request(ci_ep);
-
-       return 0;
-}
-
 static void flip_ep0_direction(void)
 {
        if (ep0_desc.bEndpointAddress == USB_DIR_IN) {
@@ -1034,149 +707,6 @@ static int ci_pullup(struct usb_gadget *gadget, int 
is_on)
        return 0;
 }
 
-static int ci_udc_probe(void)
-{
-       struct ept_queue_head *head;
-       int i;
-
-       const int num = 2 * NUM_ENDPOINTS;
-
-       const int eplist_min_align = 4096;
-       const int eplist_align = roundup(eplist_min_align, ARCH_DMA_MINALIGN);
-       const int eplist_raw_sz = num * sizeof(struct ept_queue_head);
-       const int eplist_sz = roundup(eplist_raw_sz, ARCH_DMA_MINALIGN);
-
-       /* The QH list must be aligned to 4096 bytes. */
-       controller.epts = memalign(eplist_align, eplist_sz);
-       if (!controller.epts)
-               return -ENOMEM;
-       memset(controller.epts, 0, eplist_sz);
-
-       controller.items_mem = memalign(ILIST_ALIGN, ILIST_SZ);
-       if (!controller.items_mem) {
-               free(controller.epts);
-               return -ENOMEM;
-       }
-       memset(controller.items_mem, 0, ILIST_SZ);
-
-       for (i = 0; i < 2 * NUM_ENDPOINTS; i++) {
-               /*
-                * Configure QH for each endpoint. The structure of the QH list
-                * is such that each two subsequent fields, N and N+1 where N is
-                * even, in the QH list represent QH for one endpoint. The Nth
-                * entry represents OUT configuration and the N+1th entry does
-                * represent IN configuration of the endpoint.
-                */
-               head = controller.epts + i;
-               if (i < 2)
-                       head->config = CFG_MAX_PKT(EP0_MAX_PACKET_SIZE)
-                               | CFG_ZLT | CFG_IOS;
-               else
-                       head->config = CFG_MAX_PKT(EP_MAX_PACKET_SIZE)
-                               | CFG_ZLT;
-               head->next = TERMINATE;
-               head->info = 0;
-
-               if (i & 1) {
-                       ci_flush_qh(i / 2);
-                       ci_flush_qtd(i / 2);
-               }
-       }
-
-       INIT_LIST_HEAD(&controller.gadget.ep_list);
-
-       /* Init EP 0 */
-       memcpy(&controller.ep[0].ep, &ci_ep_init[0], sizeof(*ci_ep_init));
-       controller.ep[0].desc = &ep0_desc;
-       INIT_LIST_HEAD(&controller.ep[0].queue);
-       controller.ep[0].req_primed = false;
-       controller.gadget.ep0 = &controller.ep[0].ep;
-       INIT_LIST_HEAD(&controller.gadget.ep0->ep_list);
-
-       /* Init EP 1..3 */
-       for (i = 1; i < 4; i++) {
-               memcpy(&controller.ep[i].ep, &ci_ep_init[i],
-                      sizeof(*ci_ep_init));
-               INIT_LIST_HEAD(&controller.ep[i].queue);
-               controller.ep[i].req_primed = false;
-               list_add_tail(&controller.ep[i].ep.ep_list,
-                             &controller.gadget.ep_list);
-       }
-
-       /* Init EP 4..n */
-       for (i = 4; i < NUM_ENDPOINTS; i++) {
-               memcpy(&controller.ep[i].ep, &ci_ep_init[4],
-                      sizeof(*ci_ep_init));
-               INIT_LIST_HEAD(&controller.ep[i].queue);
-               controller.ep[i].req_primed = false;
-               list_add_tail(&controller.ep[i].ep.ep_list,
-                             &controller.gadget.ep_list);
-       }
-
-       ci_ep_alloc_request(&controller.ep[0].ep, 0);
-       if (!controller.ep0_req) {
-               free(controller.items_mem);
-               free(controller.epts);
-               return -ENOMEM;
-       }
-
-       return 0;
-}
-
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
-{
-       int ret;
-
-       if (!driver)
-               return -EINVAL;
-       if (!driver->bind || !driver->setup || !driver->disconnect)
-               return -EINVAL;
-
-#if CONFIG_IS_ENABLED(DM_USB)
-       ret = usb_setup_ehci_gadget(&controller.ctrl);
-#else
-       ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl);
-#endif
-       if (ret)
-               return ret;
-
-       ret = ci_udc_probe();
-       if (ret) {
-               DBG("udc probe failed, returned %d\n", ret);
-               return ret;
-       }
-
-       ret = driver->bind(&controller.gadget);
-       if (ret) {
-               DBG("driver->bind() returned %d\n", ret);
-               return ret;
-       }
-       controller.driver = driver;
-
-       return 0;
-}
-
-int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
-{
-       udc_disconnect();
-
-       driver->unbind(&controller.gadget);
-       controller.driver = NULL;
-
-       ci_ep_free_request(&controller.ep[0].ep, &controller.ep0_req->req);
-       free(controller.items_mem);
-       free(controller.epts);
-
-#if CONFIG_IS_ENABLED(DM_USB)
-       usb_remove_ehci_gadget(&controller.ctrl);
-#else
-       usb_lowlevel_stop(0);
-       controller.ctrl = NULL;
-#endif
-
-       return 0;
-}
-
 bool dfu_usb_get_reset(void)
 {
        struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
-- 
2.53.0

Reply via email to