common: Move ARM cache operations out of common.h
[oweals/u-boot.git] / drivers / usb / host / xhci-ring.c
index 2675a8f6491538050a62040255fd6cfe267962fe..3cd6c8a0dcb4ea5561a4572fd6ab72dfce5a249c 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * USB HOST XHCI Controller stack
  *
  * Copyright (C) 2013 Samsung Electronics Co.Ltd
  * Authors: Vivek Gautam <gautam.vivek@samsung.com>
  *         Vikas Sajjan <vikas.sajjan@samsung.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <asm/byteorder.h>
 #include <usb.h>
 #include <asm/unaligned.h>
 #include <linux/errno.h>
 
-#include "xhci.h"
+#include <usb/xhci.h>
 
 /**
  * Is this TRB a link TRB or was the last TRB the last TRB in this event ring
@@ -280,8 +280,15 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, u32 slot_id,
        fields[0] = lower_32_bits(val_64);
        fields[1] = upper_32_bits(val_64);
        fields[2] = 0;
-       fields[3] = TRB_TYPE(cmd) | EP_ID_FOR_TRB(ep_index) |
-                   SLOT_ID_FOR_TRB(slot_id) | ctrl->cmd_ring->cycle_state;
+       fields[3] = TRB_TYPE(cmd) | SLOT_ID_FOR_TRB(slot_id) |
+                   ctrl->cmd_ring->cycle_state;
+
+       /*
+        * Only 'reset endpoint', 'stop endpoint' and 'set TR dequeue pointer'
+        * commands need endpoint id encoded.
+        */
+       if (cmd >= TRB_RESET_EP && cmd <= TRB_SET_DEQ)
+               fields[3] |= EP_ID_FOR_TRB(ep_index);
 
        queue_trb(ctrl, ctrl->cmd_ring, false, fields);
 
@@ -550,7 +557,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
 {
        int num_trbs = 0;
        struct xhci_generic_trb *start_trb;
-       bool first_trb = 0;
+       bool first_trb = false;
        int start_cycle;
        u32 field = 0;
        u32 length_field = 0;
@@ -821,7 +828,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
                field |= 0x1;
 
        /* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-       if (HC_VERSION(xhci_readl(&ctrl->hccr->cr_capbase)) == 0x100) {
+       if (HC_VERSION(xhci_readl(&ctrl->hccr->cr_capbase)) >= 0x100) {
                if (length > 0) {
                        if (req->requesttype & USB_DIR_IN)
                                field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);