]> git.sur5r.net Git - u-boot/blobdiff - drivers/usb/dwc3/gadget.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / drivers / usb / dwc3 / gadget.c
index a8335b3964cfcf59bb4ee058691a1f3d377ffa13..d45fae044c4a0c04cc34236aec11ca4c6327bb98 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /**
  * gadget.c - DesignWare USB3 DRD Controller Gadget Framework Link
  *
  * to uboot.
  *
  * commit 8e74475b0e : usb: dwc3: gadget: use udc-core's reset notifier
- *
- * SPDX-License-Identifier:     GPL-2.0
  */
 
 #include <common.h>
 #include <malloc.h>
 #include <asm/dma-mapping.h>
 #include <usb/lin_gadget_compat.h>
+#include <linux/bug.h>
 #include <linux/list.h>
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
-#include <asm/arch/sys_proto.h>
 
 #include "core.h"
 #include "gadget.h"
@@ -244,7 +243,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
 
        list_del(&req->list);
        req->trb = NULL;
-       dwc3_flush_cache((int)req->request.dma, req->request.length);
+       dwc3_flush_cache((uintptr_t)req->request.dma, req->request.length);
 
        if (req->request.status == -EINPROGRESS)
                req->request.status = status;
@@ -771,8 +770,8 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
 
        trb->ctrl |= DWC3_TRB_CTRL_HWO;
 
-       dwc3_flush_cache((int)dma, length);
-       dwc3_flush_cache((int)trb, sizeof(*trb));
+       dwc3_flush_cache((uintptr_t)dma, length);
+       dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
 }
 
 /*
@@ -1605,7 +1604,7 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
                } else {
                        int             ret;
 
-                       usb_ep_set_maxpacket_limit(&dep->endpoint, 1024);
+                       usb_ep_set_maxpacket_limit(&dep->endpoint, 512);
                        dep->endpoint.max_streams = 15;
                        dep->endpoint.ops = &dwc3_gadget_ep_ops;
                        list_add_tail(&dep->endpoint.ep_list,
@@ -1755,33 +1754,23 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep,
        struct dwc3_request     *req;
        struct dwc3_trb         *trb;
        unsigned int            slot;
-       int                     ret;
 
-       do {
-               req = next_request(&dep->req_queued);
-               if (!req) {
-                       WARN_ON_ONCE(1);
-                       return 1;
-               }
-
-               slot = req->start_slot;
-               if ((slot == DWC3_TRB_NUM - 1) &&
-                       usb_endpoint_xfer_isoc(dep->endpoint.desc))
-                       slot++;
-               slot %= DWC3_TRB_NUM;
-               trb = &dep->trb_pool[slot];
-
-               dwc3_flush_cache((int)trb, sizeof(*trb));
-               ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb,
-                               event, status);
-               if (ret)
-                       break;
+       req = next_request(&dep->req_queued);
+       if (!req) {
+               WARN_ON_ONCE(1);
+               return 1;
+       }
 
-               dwc3_gadget_giveback(dep, req, status);
+       slot = req->start_slot;
+       if ((slot == DWC3_TRB_NUM - 1) &&
+           usb_endpoint_xfer_isoc(dep->endpoint.desc))
+               slot++;
+       slot %= DWC3_TRB_NUM;
+       trb = &dep->trb_pool[slot];
 
-               if (ret)
-                       break;
-       } while (1);
+       dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
+       __dwc3_cleanup_done_trbs(dwc, dep, req, trb, event, status);
+       dwc3_gadget_giveback(dep, req, status);
 
        if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
                        list_empty(&dep->req_queued)) {
@@ -2678,11 +2667,12 @@ void dwc3_gadget_uboot_handle_interrupt(struct dwc3 *dwc)
                int i;
                struct dwc3_event_buffer *evt;
 
+               dwc3_thread_interrupt(0, dwc);
+
+               /* Clean + Invalidate the buffers after touching them */
                for (i = 0; i < dwc->num_event_buffers; i++) {
                        evt = dwc->ev_buffs[i];
-                       dwc3_flush_cache((int)evt->buf, evt->length);
+                       dwc3_flush_cache((uintptr_t)evt->buf, evt->length);
                }
-
-               dwc3_thread_interrupt(0, dwc);
        }
 }