SPDX: Convert all of our single license tags to Linux Kernel style
[oweals/u-boot.git] / drivers / usb / gadget / ci_udc.c
index c0d23a444bf251bb7af90eb48c8153ad25c8b4ff..2b9dbf06b991d527965a91e0694cc18c805725fc 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2011, Marvell Semiconductor Inc.
  * Lei Wen <leiwen@marvell.com>
  *
- * SPDX-License-Identifier:    GPL-2.0+
- *
  * Back ported to the 8xx platform (from the 8260 platform) by
  * Murray.Jensen@cmst.csiro.au, 27-Jan-01.
  */
@@ -14,7 +13,7 @@
 #include <net.h>
 #include <malloc.h>
 #include <asm/byteorder.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/unaligned.h>
 #include <linux/types.h>
@@ -426,7 +425,7 @@ static void ci_ep_submit_next_request(struct ci_ep *ci_ep)
        int bit, num, len, in;
        struct ci_req *ci_req;
        u8 *buf;
-       uint32_t length, actlen;
+       uint32_t len_left, len_this_dtd;
        struct ept_queue_item *dtd, *qtd;
 
        ci_ep->req_primed = true;
@@ -444,25 +443,23 @@ static void ci_ep_submit_next_request(struct ci_ep *ci_ep)
 
        ci_req->dtd_count = 0;
        buf = ci_req->hw_buf;
-       actlen = 0;
+       len_left = len;
        dtd = item;
 
        do {
-               length = min(ci_req->req.length - actlen,
-                            (unsigned)EP_MAX_LENGTH_TRANSFER);
+               len_this_dtd = min(len_left, (unsigned)EP_MAX_LENGTH_TRANSFER);
 
-               dtd->info = INFO_BYTES(length) | INFO_ACTIVE;
+               dtd->info = INFO_BYTES(len_this_dtd) | INFO_ACTIVE;
                dtd->page0 = (unsigned long)buf;
                dtd->page1 = ((unsigned long)buf & 0xfffff000) + 0x1000;
                dtd->page2 = ((unsigned long)buf & 0xfffff000) + 0x2000;
                dtd->page3 = ((unsigned long)buf & 0xfffff000) + 0x3000;
                dtd->page4 = ((unsigned long)buf & 0xfffff000) + 0x4000;
 
-               len -= length;
-               actlen += length;
-               buf += length;
+               len_left -= len_this_dtd;
+               buf += len_this_dtd;
 
-               if (len) {
+               if (len_left) {
                        qtd = (struct ept_queue_item *)
                               memalign(ILIST_ALIGN, ILIST_ENT_SZ);
                        dtd->next = (unsigned long)qtd;
@@ -471,7 +468,7 @@ static void ci_ep_submit_next_request(struct ci_ep *ci_ep)
                }
 
                ci_req->dtd_count++;
-       } while (len);
+       } while (len_left);
 
        item = dtd;
        /*
@@ -1020,18 +1017,10 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                return ret;
 
        ret = ci_udc_probe();
-#if defined(CONFIG_USB_EHCI_MX6) || defined(CONFIG_USB_EHCI_MXS)
-       /*
-        * FIXME: usb_lowlevel_init()->ehci_hcd_init() should be doing all
-        * HW-specific initialization, e.g. ULPI-vs-UTMI PHY selection
-        */
-       if (!ret) {
-               struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
-
-               /* select ULPI phy */
-               writel(PTS(PTS_ENABLE) | PFSC, &udc->portsc);
+       if (ret) {
+               DBG("udc probe failed, returned %d\n", ret);
+               return ret;
        }
-#endif
 
        ret = driver->bind(&controller.gadget);
        if (ret) {