From patchwork Wed Sep 2 06:13:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355526 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=pXBXraTT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDDm6sdFz9sSJ for ; Wed, 2 Sep 2020 16:14:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 818F382273; Wed, 2 Sep 2020 08:14:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="pXBXraTT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EAA482281; Wed, 2 Sep 2020 08:14:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout3.routing.net (mxout3.routing.net [IPv6:2a03:2900:1:a::8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ED07C80030 for ; Wed, 2 Sep 2020 08:13:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout3.routing.net (Postfix) with ESMTP id 4974E604E0; Wed, 2 Sep 2020 06:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O/149xmm+5fcoULlwfcdfiP1Qe56vFxXaXQYR6ILmVg=; b=pXBXraTTixDKoTnv/nPUfHi1gB++y/7CNthiPApaeVwJRrED1zt4oeAuhbkRghFBZY6/kJ /rgjgr95fy3J0QmP4nebZFMKP7ZjC2F5uiPatGbSeexSn8SwEa067DD/+VJpE9MjGQkxvD Rrut+X32VPU2foTzM9evaOgYokZjiEI= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id B04DA10021A; Wed, 2 Sep 2020 06:13:55 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 01/11] usb: xhci: add a member hci_version in xhci_ctrl struct Date: Wed, 2 Sep 2020 08:13:33 +0200 Message-Id: <20200902061343.3185-1-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Add a member to save xHCI version, it's used some times. Signed-off-by: Chunfeng Yun Reviewed-by: Bin Meng --- drivers/usb/host/xhci-ring.c | 4 ++-- drivers/usb/host/xhci.c | 1 + include/usb/xhci.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 092ed6eaf1..79bfc349f4 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -682,7 +682,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, field |= TRB_ISP; /* Set the TRB length, TD size, and interrupter fields. */ - if (HC_VERSION(xhci_readl(&ctrl->hccr->cr_capbase)) < 0x100) + if (ctrl->hci_version < 0x100) remainder = xhci_td_remainder(length - running_total); else remainder = xhci_v1_0_td_remainder(running_total, @@ -830,7 +830,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 (ctrl->hci_version >= 0x100) { if (length > 0) { if (req->requesttype & USB_DIR_IN) field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 126dabc11b..4be1411243 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1283,6 +1283,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl) reg = HC_VERSION(xhci_readl(&hccr->cr_capbase)); printf("USB XHCI %x.%02x\n", reg >> 8, reg & 0xff); + ctrl->hci_version = reg; return 0; } diff --git a/include/usb/xhci.h b/include/usb/xhci.h index 7d34103fd5..a3e5914b10 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -1227,6 +1227,7 @@ struct xhci_ctrl { struct xhci_scratchpad *scratchpad; struct xhci_virt_device *devs[MAX_HC_SLOTS]; int rootdev; + u16 hci_version; }; unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb); From patchwork Wed Sep 2 06:13:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355523 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=LAtARyD8; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDD95H0tz9sV8 for ; Wed, 2 Sep 2020 16:14:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB6B782286; Wed, 2 Sep 2020 08:14:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="LAtARyD8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 42B1382272; Wed, 2 Sep 2020 08:14:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout4.routing.net (mxout4.routing.net [IPv6:2a03:2900:1:a::9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 607E2808F1 for ; Wed, 2 Sep 2020 08:13:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout4.routing.net (Postfix) with ESMTP id D91101014DA; Wed, 2 Sep 2020 06:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NQ51DkM9NsFUwqRJnnLqMfZ/rWOzXk7Mb0O1ABe1y70=; b=LAtARyD8qZ70tCY3g6PA41EeaQzk+EC3ubcITKQVwYCaUgYN8KI/pOMenIB9TzGvtv40mc Y4P2qB6EbNH2dfsZUNnClmJ1UbzruUxGZpZojrqbAvPY8X1ebwiOF9OMv5LAyQE8YKi+y/ wZFBi6AtlP1rN+ey7hCV/VBOpV0QUpc= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 4D2831006D4; Wed, 2 Sep 2020 06:13:56 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 02/11] usb: xhci: create one unified function to calculate TRB TD remainder. Date: Wed, 2 Sep 2020 08:13:34 +0200 Message-Id: <20200902061343.3185-2-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun xhci versions 1.0 and later report the untransferred data remaining in a TD a bit differently than older hosts. We used to have separate functions for these, and needed to check host version before calling the right function. Now Mediatek host has an additional quirk on how it uses the TD Size field for remaining data. To prevent yet another function for calculating remainder we instead want to make one quirk friendly unified function. Porting from the Linux: c840d6ce772d("xhci: create one unified function to calculate TRB TD remainder.") 124c39371114("xhci: use boolean to indicate last trb in td remainder calculation") Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-ring.c | 105 +++++++++++++++++------------------ include/usb/xhci.h | 2 + 2 files changed, 52 insertions(+), 55 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 79bfc349f4..0f86b011f3 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -298,55 +298,52 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, u32 slot_id, xhci_writel(&ctrl->dba->doorbell[0], DB_VALUE_HOST); } -/** - * The TD size is the number of bytes remaining in the TD (including this TRB), - * right shifted by 10. - * It must fit in bits 21:17, so it can't be bigger than 31. +/* + * For xHCI 1.0 host controllers, TD size is the number of max packet sized + * packets remaining in the TD (*not* including this TRB). * - * @param remainder remaining packets to be sent - * @return remainder if remainder is less than max else max - */ -static u32 xhci_td_remainder(unsigned int remainder) -{ - u32 max = (1 << (21 - 17 + 1)) - 1; - - if ((remainder >> 10) >= max) - return max << 17; - else - return (remainder >> 10) << 17; -} - -/** - * Finds out the remanining packets to be sent + * Total TD packet count = total_packet_count = + * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize) + * + * Packets transferred up to and including this TRB = packets_transferred = + * rounddown(total bytes transferred including this TRB / wMaxPacketSize) + * + * TD size = total_packet_count - packets_transferred * - * @param running_total total size sent so far + * For xHCI 0.96 and older, TD size field should be the remaining bytes + * including this TRB, right shifted by 10 + * + * For all hosts it must fit in bits 21:17, so it can't be bigger than 31. + * This is taken care of in the TRB_TD_SIZE() macro + * + * The last TRB in a TD must have the TD size set to zero. + * + * @param ctrl host controller data structure + * @param transferred total size sent so far * @param trb_buff_len length of the TRB Buffer - * @param total_packet_count total packet count - * @param maxpacketsize max packet size of current pipe - * @param num_trbs_left number of TRBs left to be processed - * @return 0 if running_total or trb_buff_len is 0, else remainder + * @param td_total_len total packet count + * @param maxp max packet size of current pipe + * @param more_trbs_coming indicate last trb in TD + * @return remainder */ -static u32 xhci_v1_0_td_remainder(int running_total, - int trb_buff_len, - unsigned int total_packet_count, - int maxpacketsize, - unsigned int num_trbs_left) +static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred, + int trb_buff_len, unsigned int td_total_len, + int maxp, bool more_trbs_coming) { - int packets_transferred; + u32 total_packet_count; + + if (ctrl->hci_version < 0x100) + return ((td_total_len - transferred) >> 10); /* One TRB with a zero-length data packet. */ - if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0)) + if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) || + trb_buff_len == td_total_len) return 0; - /* - * All the TRB queueing functions don't count the current TRB in - * running_total. - */ - packets_transferred = (running_total + trb_buff_len) / maxpacketsize; + total_packet_count = DIV_ROUND_UP(td_total_len, maxp); - if ((total_packet_count - packets_transferred) > 31) - return 31 << 17; - return (total_packet_count - packets_transferred) << 17; + /* Queueing functions don't count the current TRB into transferred */ + return (total_packet_count - ((transferred + trb_buff_len) / maxp)); } /** @@ -572,7 +569,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, union xhci_trb *event; int running_total, trb_buff_len; - unsigned int total_packet_count; + bool more_trbs_coming = true; int maxpacketsize; u64 addr; int ret; @@ -636,8 +633,6 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, running_total = 0; maxpacketsize = usb_maxpacket(udev, pipe); - total_packet_count = DIV_ROUND_UP(length, maxpacketsize); - /* How much data is in the first TRB? */ /* * How much data is (potentially) left before the 64KB boundary? @@ -672,27 +667,24 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, * Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. */ - if (num_trbs > 1) + if (num_trbs > 1) { field |= TRB_CHAIN; - else + } else { field |= TRB_IOC; + more_trbs_coming = false; + } /* Only set interrupt on short packet for IN endpoints */ if (usb_pipein(pipe)) field |= TRB_ISP; /* Set the TRB length, TD size, and interrupter fields. */ - if (ctrl->hci_version < 0x100) - remainder = xhci_td_remainder(length - running_total); - else - remainder = xhci_v1_0_td_remainder(running_total, - trb_buff_len, - total_packet_count, - maxpacketsize, - num_trbs - 1); + remainder = xhci_td_remainder(ctrl, running_total, trb_buff_len, + length, maxpacketsize, + more_trbs_coming); length_field = ((trb_buff_len & TRB_LEN_MASK) | - remainder | + TRB_TD_SIZE(remainder) | ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT)); @@ -764,6 +756,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, struct xhci_virt_device *virt_dev = ctrl->devs[slot_id]; struct xhci_ring *ep_ring; union xhci_trb *event; + u32 remainder; debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n", req->request, req->request, @@ -866,12 +859,14 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, else field = (TRB_DATA << TRB_TYPE_SHIFT); - length_field = (length & TRB_LEN_MASK) | xhci_td_remainder(length) | + remainder = xhci_td_remainder(ctrl, 0, length, length, + usb_maxpacket(udev, pipe), 1); + length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) | ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT); debug("length_field = %d, length = %d," "xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n", length_field, (length & TRB_LEN_MASK), - xhci_td_remainder(length), 0); + TRB_TD_SIZE(remainder), 0); if (length > 0) { if (req->requesttype & USB_DIR_IN) diff --git a/include/usb/xhci.h b/include/usb/xhci.h index a3e5914b10..15926eb9f4 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -850,6 +850,8 @@ struct xhci_event_cmd { /* transfer_len bitmasks - bits 0:16 */ #define TRB_LEN(p) ((p) & 0x1ffff) #define TRB_LEN_MASK (0x1ffff) +/* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */ +#define TRB_TD_SIZE(p) (min((p), (u32)31) << 17) /* Interrupter Target - which MSI-X vector to target the completion event at */ #define TRB_INTR_TARGET_SHIFT (22) #define TRB_INTR_TARGET_MASK (0x3ff) From patchwork Wed Sep 2 06:13:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355524 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=lxgEvnYI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDDJ49LMz9sSJ for ; Wed, 2 Sep 2020 16:14:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 90B3981C31; Wed, 2 Sep 2020 08:14:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="lxgEvnYI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB9C581281; Wed, 2 Sep 2020 08:14:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout2.routing.net (mxout2.routing.net [IPv6:2a03:2900:1:a::b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CD16781281 for ; Wed, 2 Sep 2020 08:13:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout2.routing.net (Postfix) with ESMTP id 6FC445FC41; Wed, 2 Sep 2020 06:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MhqFfEl28OBH5X0sQqmh0G0s0BLp+hTQCely+YDbNXY=; b=lxgEvnYIWhCMLRNUvDSLibNq4c7YFJMI8yLDK3F4jR0QcyY4MRUgMFGHOWnLh56pDm1lFV ylMwfrMuggyY/Gputc/9Pf7Z9oNvEktxz5lOQuh2n3Raljc2ed5M62qp+SNf4OrT2BB/eL hDKTESw8r2XhkbZn42+LEYMvjsB00og= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id D9B681007D4; Wed, 2 Sep 2020 06:13:56 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun , Frank Wunderlich Subject: [RESEND PATCH v2 03/11] usb: xhci: add quirks flag to support MediaTek xHCI 0.96 Date: Wed, 2 Sep 2020 08:13:35 +0200 Message-Id: <20200902061343.3185-3-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun There some vendor quirks for MTK xHCI 0.96 host controller: 1. It defines some extra SW scheduling parameters for HW to minimize the scheduling effort for synchronous and interrupt endpoints. The parameters are put into reseved DWs of slot context and endpoint context. 2. Its TDS in Normal TRB defines a number of packets that remains to be transferred for a TD after processing all Max packets in all previous TRBs. Signed-off-by: Chunfeng Yun Tested-by: Frank Wunderlich --- drivers/usb/host/xhci-mtk.c | 1 + drivers/usb/host/xhci-ring.c | 9 +++++++-- drivers/usb/host/xhci.c | 2 +- include/usb/xhci.h | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 8ff71854fc..f3f181dae0 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -258,6 +258,7 @@ static int xhci_mtk_probe(struct udevice *dev) if (ret) goto ssusb_init_err; + mtk->ctrl.quirks = XHCI_MTK_HOST; hcor = (struct xhci_hcor *)((uintptr_t)mtk->hcd + HC_LENGTH(xhci_readl(&mtk->hcd->cr_capbase))); diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0f86b011f3..cf8b9d2362 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -332,7 +332,8 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred, { u32 total_packet_count; - if (ctrl->hci_version < 0x100) + /* MTK xHCI 0.96 contains some features from 1.0 */ + if (ctrl->hci_version < 0x100 && !(ctrl->quirks & XHCI_MTK_HOST)) return ((td_total_len - transferred) >> 10); /* One TRB with a zero-length data packet. */ @@ -340,6 +341,10 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred, trb_buff_len == td_total_len) return 0; + /* for MTK xHCI 0.96, TD size include this TRB, but not in 1.x */ + if ((ctrl->quirks & XHCI_MTK_HOST) && (ctrl->hci_version < 0x100)) + trb_buff_len = 0; + total_packet_count = DIV_ROUND_UP(td_total_len, maxp); /* Queueing functions don't count the current TRB into transferred */ @@ -823,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 (ctrl->hci_version >= 0x100) { + if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) { if (length > 0) { if (req->requesttype & USB_DIR_IN) field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 4be1411243..51edeb22c1 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -650,7 +650,7 @@ static int xhci_set_configuration(struct usb_device *udev) * are put into reserved DWs in Slot and Endpoint Contexts * for synchronous endpoints. */ - if (IS_ENABLED(CONFIG_USB_XHCI_MTK)) { + if (ctrl->quirks & XHCI_MTK_HOST) { ep_ctx[ep_index]->reserved[0] = cpu_to_le32(EP_BPKTS(1) | EP_BBM(1)); } diff --git a/include/usb/xhci.h b/include/usb/xhci.h index 15926eb9f4..3de46cd95e 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -1230,6 +1230,8 @@ struct xhci_ctrl { struct xhci_virt_device *devs[MAX_HC_SLOTS]; int rootdev; u16 hci_version; + u32 quirks; +#define XHCI_MTK_HOST BIT(0) }; unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb); From patchwork Wed Sep 2 06:13:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355528 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=hYHmxPpt; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDFK50xnz9sSJ for ; Wed, 2 Sep 2020 16:15:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CF795822C2; Wed, 2 Sep 2020 08:14:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="hYHmxPpt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0020E82281; Wed, 2 Sep 2020 08:14:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout1.routing.net (mxout1.routing.net [IPv6:2a03:2900:1:a::a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6751B81B79 for ; Wed, 2 Sep 2020 08:13:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout1.routing.net (Postfix) with ESMTP id 01C163FC27; Wed, 2 Sep 2020 06:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bcKAutToC+l9Lo7KFKgKWTXGYYzOo5THAh/duCQuPfE=; b=hYHmxPpt+V7Y6H0qiYHoCIeLmnNi9xtfpX46v97FpzYF6pxfUplbgQQuHBvrL6gWwuGMp4 CvuReSIu2Fbitx1AjuaYcySIh0yHep8ZNs9Sgqqffc4p/t4lcy44H6aqvu4ys+lcKeVytH wm6CIdaSBOofXMOO2lvxQknKGls1cKw= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 77EE81002E7; Wed, 2 Sep 2020 06:13:57 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 04/11] usb: xhci: convert to HCS_MAX_PORTS() Date: Wed, 2 Sep 2020 08:13:36 +0200 Message-Id: <20200902061343.3185-4-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use HCS_MAX_PORTS(p) instead of ((p & HCS_MAX_PORTS_MASK) >> HCS_MAX_PORTS_SHIFT) Signed-off-by: Chunfeng Yun Reviewed-by: Bin Meng --- drivers/usb/host/xhci.c | 3 +-- include/usb/xhci.h | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 51edeb22c1..5f3a0fba4b 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1257,8 +1257,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl) return -ENOMEM; reg = xhci_readl(&hccr->cr_hcsparams1); - descriptor.hub.bNbrPorts = ((reg & HCS_MAX_PORTS_MASK) >> - HCS_MAX_PORTS_SHIFT); + descriptor.hub.bNbrPorts = HCS_MAX_PORTS(reg); printf("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts); /* Port Indicators */ diff --git a/include/usb/xhci.h b/include/usb/xhci.h index 3de46cd95e..cf4c0208b2 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -101,8 +101,6 @@ struct xhci_hccr { /* bits 8:18, Max Interrupters */ #define HCS_MAX_INTRS(p) (((p) >> 8) & 0x7ff) /* bits 24:31, Max Ports - max value is 0x7F = 127 ports */ -#define HCS_MAX_PORTS_SHIFT 24 -#define HCS_MAX_PORTS_MASK (0xff << HCS_MAX_PORTS_SHIFT) #define HCS_MAX_PORTS(p) (((p) >> 24) & 0xff) /* HCSPARAMS2 - hcs_params2 - bitmasks */ From patchwork Wed Sep 2 06:13:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355525 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=GznPezSr; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDDX6rsDz9sSJ for ; Wed, 2 Sep 2020 16:14:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1CA78228A; Wed, 2 Sep 2020 08:14:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="GznPezSr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FDDD822A4; Wed, 2 Sep 2020 08:14:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout3.routing.net (mxout3.routing.net [IPv6:2a03:2900:1:a::8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D6C4E81C31 for ; Wed, 2 Sep 2020 08:13:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout3.routing.net (Postfix) with ESMTP id 8CF4C6050D; Wed, 2 Sep 2020 06:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s6nuRvRtiBEVhH2bCKfugSgDWA3MwSJ2AMlO6ULhYH4=; b=GznPezSrgRIP6qEg+ZLwsmYzJrAs7yWKq5HQQxfmtciZ3Asxlzp0qgSjzHY5Y90NA2cQ2t mDXQxODkLmaP+K0e50qu/915D+V8cMLbwTRgz4g9Kw6mN+1J08fMH0f1lNoyH1t9KTF67H 9bmJ0OVxBHXxeCvrtIx2Tnf02+7HG0I= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 0DCF41006D4; Wed, 2 Sep 2020 06:13:58 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 05/11] usb: xhci: convert to TRB_TYPE() Date: Wed, 2 Sep 2020 08:13:37 +0200 Message-Id: <20200902061343.3185-5-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use TRB_TYPE(p) instead of ((p) << TRB_TYPE_SHIFT) Signed-off-by: Chunfeng Yun Reviewed-by: Bin Meng --- drivers/usb/host/xhci-mem.c | 3 +-- drivers/usb/host/xhci-ring.c | 11 +++++------ include/usb/xhci.h | 1 - 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 1da0524aa0..d627aa5555 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -236,8 +236,7 @@ static void xhci_link_segments(struct xhci_segment *prev, */ val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control); val &= ~TRB_TYPE_BITMASK; - val |= (TRB_LINK << TRB_TYPE_SHIFT); - + val |= TRB_TYPE(TRB_LINK); prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); } } diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index cf8b9d2362..87891fdb58 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -696,7 +696,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, trb_fields[0] = lower_32_bits(addr); trb_fields[1] = upper_32_bits(addr); trb_fields[2] = length_field; - trb_fields[3] = field | (TRB_NORMAL << TRB_TYPE_SHIFT); + trb_fields[3] = field | TRB_TYPE(TRB_NORMAL); queue_trb(ctrl, ring, (num_trbs > 1), trb_fields); @@ -823,7 +823,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, /* Queue setup TRB - see section 6.4.1.2.1 */ /* FIXME better way to translate setup_packet into two u32 fields? */ field = 0; - field |= TRB_IDT | (TRB_SETUP << TRB_TYPE_SHIFT); + field |= TRB_IDT | TRB_TYPE(TRB_SETUP); if (start_cycle == 0) field |= 0x1; @@ -860,9 +860,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, /* If there's data, queue data TRBs */ /* Only set interrupt on short packet for IN endpoints */ if (usb_pipein(pipe)) - field = TRB_ISP | (TRB_DATA << TRB_TYPE_SHIFT); + field = TRB_ISP | TRB_TYPE(TRB_DATA); else - field = (TRB_DATA << TRB_TYPE_SHIFT); + field = TRB_TYPE(TRB_DATA); remainder = xhci_td_remainder(ctrl, 0, length, length, usb_maxpacket(udev, pipe), 1); @@ -904,8 +904,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT); /* Event on completion */ trb_fields[3] = field | TRB_IOC | - (TRB_STATUS << TRB_TYPE_SHIFT) | - ep_ring->cycle_state; + TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state; queue_trb(ctrl, ep_ring, false, trb_fields); diff --git a/include/usb/xhci.h b/include/usb/xhci.h index cf4c0208b2..bdba51df59 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -903,7 +903,6 @@ union xhci_trb { /* TRB bit mask */ #define TRB_TYPE_BITMASK (0xfc00) #define TRB_TYPE(p) ((p) << 10) -#define TRB_TYPE_SHIFT (10) #define TRB_FIELD_TO_TYPE(p) (((p) & TRB_TYPE_BITMASK) >> 10) /* TRB type IDs */ From patchwork Wed Sep 2 06:13:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355527 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=sEd8uFv+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDF23lVYz9sSJ for ; Wed, 2 Sep 2020 16:15:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6555822AF; Wed, 2 Sep 2020 08:14:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="sEd8uFv+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B858C821FF; Wed, 2 Sep 2020 08:14:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout3.routing.net (mxout3.routing.net [IPv6:2a03:2900:1:a::8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 810088221F for ; Wed, 2 Sep 2020 08:13:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout3.routing.net (Postfix) with ESMTP id 317B860543; Wed, 2 Sep 2020 06:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MXT3PHaHAmQ/teoA3FhbEBkbmTCFL+hya2pZs5+jfbI=; b=sEd8uFv+O4spCqwy2qkXgwuEQoPz0gUGrC0PhImnoiGI9EOoZsGvyBbM7qrugdE7Wl1dC+ c5ljQ+j4vgTs3gyj91elCO39ME9ai2Q8e0uy6A22UcZSzTkr1PSGTIxPn+adAVUmKc63GD X348IQ2R3p31wNTkypsor5zi4T8ugwE= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 9E4C71007D4; Wed, 2 Sep 2020 06:13:58 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 06/11] usb: xhci: convert to TRB_INTR_TARGET() Date: Wed, 2 Sep 2020 08:13:38 +0200 Message-Id: <20200902061343.3185-6-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use TRB_INTR_TARGET(x) instead of (((x) & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT) Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-ring.c | 10 ++++------ include/usb/xhci.h | 2 -- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 87891fdb58..16d2e02cfa 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -690,8 +690,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, length_field = ((trb_buff_len & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) | - ((0 & TRB_INTR_TARGET_MASK) << - TRB_INTR_TARGET_SHIFT)); + TRB_INTR_TARGET(0)); trb_fields[0] = lower_32_bits(addr); trb_fields[1] = upper_32_bits(addr); @@ -849,8 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, trb_fields[1] = le16_to_cpu(req->index) | le16_to_cpu(req->length) << 16; /* TRB_LEN | (TRB_INTR_TARGET) */ - trb_fields[2] = (8 | ((0 & TRB_INTR_TARGET_MASK) << - TRB_INTR_TARGET_SHIFT)); + trb_fields[2] = (8 | TRB_INTR_TARGET(0)); /* Immediate data in pointer */ trb_fields[3] = field; queue_trb(ctrl, ep_ring, true, trb_fields); @@ -867,7 +865,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, remainder = xhci_td_remainder(ctrl, 0, length, length, usb_maxpacket(udev, pipe), 1); length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) | - ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT); + TRB_INTR_TARGET(0); debug("length_field = %d, length = %d," "xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n", length_field, (length & TRB_LEN_MASK), @@ -901,7 +899,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, trb_fields[0] = 0; trb_fields[1] = 0; - trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT); + trb_fields[2] = TRB_INTR_TARGET(0); /* Event on completion */ trb_fields[3] = field | TRB_IOC | TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state; diff --git a/include/usb/xhci.h b/include/usb/xhci.h index bdba51df59..ca3d99b954 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -851,8 +851,6 @@ struct xhci_event_cmd { /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */ #define TRB_TD_SIZE(p) (min((p), (u32)31) << 17) /* Interrupter Target - which MSI-X vector to target the completion event at */ -#define TRB_INTR_TARGET_SHIFT (22) -#define TRB_INTR_TARGET_MASK (0x3ff) #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22) #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff) #define TRB_TBC(p) (((p) & 0x3) << 7) From patchwork Wed Sep 2 06:13:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355529 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=HwJNBlfw; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDFZ62y3z9sV8 for ; Wed, 2 Sep 2020 16:15:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCBC5822CE; Wed, 2 Sep 2020 08:14:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="HwJNBlfw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57535822A3; Wed, 2 Sep 2020 08:14:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout2.routing.net (mxout2.routing.net [IPv6:2a03:2900:1:a::b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 13BB88225E for ; Wed, 2 Sep 2020 08:14:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout2.routing.net (Postfix) with ESMTP id BEE3E5FC6D; Wed, 2 Sep 2020 06:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8ENVgtrS5G9UZABI0aHxszrxlC0R7CgfhoQEiOqFwCo=; b=HwJNBlfwSCrl9OCHEYfX8920k5LdkMJ9T4P+uf92yWklhC4niWYcq8s3MX63kzE9fRFQDe SThbUgKzN13qNKl/p+rXvUaiS6aLzGRLzVy6sVxKwf2Hh5092uQxY5bCsU+VIHDraobzW8 FaCIj7WxjjO94HMTBcs4cTliVc20qyI= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 3E5F51002E7; Wed, 2 Sep 2020 06:13:59 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 07/11] usb: xhci: convert to TRB_LEN() Date: Wed, 2 Sep 2020 08:13:39 +0200 Message-Id: <20200902061343.3185-7-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use TRB_LEN(x) instead of ((x) & TRB_LEN_MASK) Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-ring.c | 8 ++++---- include/usb/xhci.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 16d2e02cfa..99c84f95b3 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -688,7 +688,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, length, maxpacketsize, more_trbs_coming); - length_field = ((trb_buff_len & TRB_LEN_MASK) | + length_field = (TRB_LEN(trb_buff_len) | TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0)); @@ -848,7 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, trb_fields[1] = le16_to_cpu(req->index) | le16_to_cpu(req->length) << 16; /* TRB_LEN | (TRB_INTR_TARGET) */ - trb_fields[2] = (8 | TRB_INTR_TARGET(0)); + trb_fields[2] = (TRB_LEN(8) | TRB_INTR_TARGET(0)); /* Immediate data in pointer */ trb_fields[3] = field; queue_trb(ctrl, ep_ring, true, trb_fields); @@ -864,11 +864,11 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, remainder = xhci_td_remainder(ctrl, 0, length, length, usb_maxpacket(udev, pipe), 1); - length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) | + length_field = TRB_LEN(length) | TRB_TD_SIZE(remainder) | TRB_INTR_TARGET(0); debug("length_field = %d, length = %d," "xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n", - length_field, (length & TRB_LEN_MASK), + length_field, TRB_LEN(length), TRB_TD_SIZE(remainder), 0); if (length > 0) { diff --git a/include/usb/xhci.h b/include/usb/xhci.h index ca3d99b954..35c66042ba 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -847,7 +847,6 @@ struct xhci_event_cmd { /* Normal TRB fields */ /* transfer_len bitmasks - bits 0:16 */ #define TRB_LEN(p) ((p) & 0x1ffff) -#define TRB_LEN_MASK (0x1ffff) /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */ #define TRB_TD_SIZE(p) (min((p), (u32)31) << 17) /* Interrupter Target - which MSI-X vector to target the completion event at */ From patchwork Wed Sep 2 06:13:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355531 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=dHyvumig; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDFz3RXwz9sV8 for ; Wed, 2 Sep 2020 16:15:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25652822D5; Wed, 2 Sep 2020 08:14:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="dHyvumig"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1FAE38225A; Wed, 2 Sep 2020 08:14:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout3.routing.net (mxout3.routing.net [IPv6:2a03:2900:1:a::8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A28D3808F1 for ; Wed, 2 Sep 2020 08:14:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout3.routing.net (Postfix) with ESMTP id 5B01060549; Wed, 2 Sep 2020 06:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027240; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WIf7ey1juXJEwkIaOxh6HYH4GL2qOimrFmLi61M6wNc=; b=dHyvumig0jFrnrn2F/+373Z2cgx0lfUyb37T3ZsgQBPu2iF/uj4cM9RNLZ6jKihAB8Rkna srLhKMbGy2GOV8Z90xgQiTR+05U3dj5yz3HIBK/rxzifgynQ10wBSu5BCWmF2RMr67R82N m07Suy6PF1tN+SHEShMmCcDFyJ677Sc= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id CFF1D1002E7; Wed, 2 Sep 2020 06:13:59 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 08/11] usb: xhci: convert to TRB_TX_TYPE() Date: Wed, 2 Sep 2020 08:13:40 +0200 Message-Id: <20200902061343.3185-8-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use TRB_TX_TYPE() instead of (TRB_DATA_OUT/IN << TRB_TX_TYPE_SHIFT) Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-ring.c | 4 ++-- include/usb/xhci.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 99c84f95b3..ccf2a35b9f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -830,9 +830,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) { if (length > 0) { if (req->requesttype & USB_DIR_IN) - field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT); + field |= TRB_TX_TYPE(TRB_DATA_IN); else - field |= (TRB_DATA_OUT << TRB_TX_TYPE_SHIFT); + field |= TRB_TX_TYPE(TRB_DATA_OUT); } } diff --git a/include/usb/xhci.h b/include/usb/xhci.h index 35c66042ba..07b1aebc69 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -879,7 +879,6 @@ struct xhci_event_cmd { /* Control transfer TRB specific fields */ #define TRB_DIR_IN (1<<16) #define TRB_TX_TYPE(p) ((p) << 16) -#define TRB_TX_TYPE_SHIFT (16) #define TRB_DATA_OUT 2 #define TRB_DATA_IN 3 From patchwork Wed Sep 2 06:13:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355530 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=YREfn18z; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDFp19Sxz9sV8 for ; Wed, 2 Sep 2020 16:15:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E02CB822A6; Wed, 2 Sep 2020 08:14:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="YREfn18z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6CC908225E; Wed, 2 Sep 2020 08:14:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout2.routing.net (mxout2.routing.net [IPv6:2a03:2900:1:a::b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3183D8225A for ; Wed, 2 Sep 2020 08:14:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout2.routing.net (Postfix) with ESMTP id DD0515FC82; Wed, 2 Sep 2020 06:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027240; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b9zdQ73+edzJeRPB8BKUcYnlbPJXqVe385XvYWNaUYc=; b=YREfn18zhU+HFzOqlqdoyUvj9q4GPr9IXLfGJCcWou/KUqpK7EWdKLd9QnvlEqWsiCQuWq IT3HAu+1a3JjdsgHCtk6TlXc2VtZm52LdXaWECv1jUu/CuTTqcZp+2hvRSrg6VwVTluZDF koasKmeHRprZ4Urf4o8fxSH18DHA/a0= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 62CB21006D4; Wed, 2 Sep 2020 06:14:00 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 09/11] usb: xhci: convert to EP_TYPE() Date: Wed, 2 Sep 2020 08:13:41 +0200 Message-Id: <20200902061343.3185-9-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use EP_TYPE(type) macro instead of ((type) << EP_TYPE_SHIFT) Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mem.c | 2 +- drivers/usb/host/xhci.c | 3 +-- include/usb/xhci.h | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index d627aa5555..6292542210 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -825,7 +825,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, /* Step 4 - ring already allocated */ /* Step 5 */ - ep0_ctx->ep_info2 = cpu_to_le32(CTRL_EP << EP_TYPE_SHIFT); + ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP)); debug("SPEED = %d\n", speed); switch (speed) { diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 5f3a0fba4b..6244f25c33 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -618,8 +618,7 @@ static int xhci_set_configuration(struct usb_device *udev) cpu_to_le32(EP_MAX_ESIT_PAYLOAD_HI(max_esit_payload) | EP_INTERVAL(interval) | EP_MULT(mult)); - ep_ctx[ep_index]->ep_info2 = - cpu_to_le32(ep_type << EP_TYPE_SHIFT); + ep_ctx[ep_index]->ep_info2 = cpu_to_le32(EP_TYPE(ep_type)); ep_ctx[ep_index]->ep_info2 |= cpu_to_le32(MAX_PACKET (get_unaligned(&endpt_desc->wMaxPacketSize))); diff --git a/include/usb/xhci.h b/include/usb/xhci.h index 07b1aebc69..c534297cc0 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -636,7 +636,6 @@ struct xhci_ep_ctx { #define ERROR_COUNT_MASK (0x3) #define CTX_TO_EP_TYPE(p) (((p) >> 3) & 0x7) #define EP_TYPE(p) ((p) << 3) -#define EP_TYPE_SHIFT (3) #define ISOC_OUT_EP 1 #define BULK_OUT_EP 2 #define INT_OUT_EP 3 From patchwork Wed Sep 2 06:13:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355532 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=YwnAtjI/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDGB3Dxkz9sSJ for ; Wed, 2 Sep 2020 16:16:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4001B822DF; Wed, 2 Sep 2020 08:14:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="YwnAtjI/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C9BA382292; Wed, 2 Sep 2020 08:14:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout1.routing.net (mxout1.routing.net [IPv6:2a03:2900:1:a::a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C18D882272 for ; Wed, 2 Sep 2020 08:14:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout1.routing.net (Postfix) with ESMTP id 770313FF52; Wed, 2 Sep 2020 06:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XFHfNg6Q08kBX2jn+WdlYPWuHX7hwp7irCzHuVSexHM=; b=YwnAtjI/4L451VV5R4MfGzXQQ0YrfKgFI73rIld5/ErYthyDualVNUuqBqm0cWHkLRQT+6 FWsbHqRRZof9nR269Ly2F0QcCsCcgA1tafp9e0UA5BcKpHlzcOHqpT04oQj0WNfpyy5Pyb gGcjyxNCnGDm/vnF4UlcKsvmV3I7JEw= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id E56B41002E7; Wed, 2 Sep 2020 06:14:00 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 10/11] usb: xhci: use macros with parameter to fill ep_info2 Date: Wed, 2 Sep 2020 08:13:42 +0200 Message-Id: <20200902061343.3185-10-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use macros with parameter to fill ep_info2, then some macros for MASK and SHIFT can be removed Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mem.c | 13 ++++--------- drivers/usb/host/xhci.c | 3 +-- include/usb/xhci.h | 5 ----- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 6292542210..0b49614995 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -830,20 +830,17 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, switch (speed) { case USB_SPEED_SUPER: - ep0_ctx->ep_info2 |= cpu_to_le32(((512 & MAX_PACKET_MASK) << - MAX_PACKET_SHIFT)); + ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(512)); debug("Setting Packet size = 512bytes\n"); break; case USB_SPEED_HIGH: /* USB core guesses at a 64-byte max packet first for FS devices */ case USB_SPEED_FULL: - ep0_ctx->ep_info2 |= cpu_to_le32(((64 & MAX_PACKET_MASK) << - MAX_PACKET_SHIFT)); + ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(64)); debug("Setting Packet size = 64bytes\n"); break; case USB_SPEED_LOW: - ep0_ctx->ep_info2 |= cpu_to_le32(((8 & MAX_PACKET_MASK) << - MAX_PACKET_SHIFT)); + ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(8)); debug("Setting Packet size = 8bytes\n"); break; default: @@ -852,9 +849,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl, } /* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */ - ep0_ctx->ep_info2 |= - cpu_to_le32(((0 & MAX_BURST_MASK) << MAX_BURST_SHIFT) | - ((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT)); + ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3)); trb_64 = virt_to_phys(virt_dev->eps[0].ring->first_seg->trbs); ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6244f25c33..fe30101d93 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -831,8 +831,7 @@ int xhci_check_maxpacket(struct usb_device *udev) ctrl->devs[slot_id]->out_ctx, ep_index); in_ctx = ctrl->devs[slot_id]->in_ctx; ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index); - ep_ctx->ep_info2 &= cpu_to_le32(~((0xffff & MAX_PACKET_MASK) - << MAX_PACKET_SHIFT)); + ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET(MAX_PACKET_MASK)); ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size)); /* diff --git a/include/usb/xhci.h b/include/usb/xhci.h index c534297cc0..e1d382369a 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -632,8 +632,6 @@ struct xhci_ep_ctx { */ #define FORCE_EVENT (0x1) #define ERROR_COUNT(p) (((p) & 0x3) << 1) -#define ERROR_COUNT_SHIFT (1) -#define ERROR_COUNT_MASK (0x3) #define CTX_TO_EP_TYPE(p) (((p) >> 3) & 0x7) #define EP_TYPE(p) ((p) << 3) #define ISOC_OUT_EP 1 @@ -646,13 +644,10 @@ struct xhci_ep_ctx { /* bit 6 reserved */ /* bit 7 is Host Initiate Disable - for disabling stream selection */ #define MAX_BURST(p) (((p)&0xff) << 8) -#define MAX_BURST_MASK (0xff) -#define MAX_BURST_SHIFT (8) #define CTX_TO_MAX_BURST(p) (((p) >> 8) & 0xff) #define MAX_PACKET(p) (((p)&0xffff) << 16) #define MAX_PACKET_MASK (0xffff) #define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) -#define MAX_PACKET_SHIFT (16) /* Get max packet size from ep desc. Bit 10..0 specify the max packet size. * USB2.0 spec 9.6.6. From patchwork Wed Sep 2 06:13:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1355533 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.a=rsa-sha256 header.s=20200217 header.b=M2OPXlNF; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDGM5tFPz9sV8 for ; Wed, 2 Sep 2020 16:16:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1F08F822E8; Wed, 2 Sep 2020 08:14:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=mailerdienst.de header.i=@mailerdienst.de header.b="M2OPXlNF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF3A88225E; Wed, 2 Sep 2020 08:14:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mxout4.routing.net (mxout4.routing.net [IPv6:2a03:2900:1:a::9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63F0582273 for ; Wed, 2 Sep 2020 08:14:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=fw-web.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux@fw-web.de Received: from mxbox2.masterlogin.de (unknown [192.168.10.89]) by mxout4.routing.net (Postfix) with ESMTP id 0EEDB1014FE; Wed, 2 Sep 2020 06:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1599027242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rn5y3uHkczP4m2BguZB1uNaMM6iqeU3gHldBsgB0bhU=; b=M2OPXlNFUtfaDaWqedameHZoPfU91v08id2am0dXt7cXHw5hqz0706dmmqV1LQdEhOb9D5 XE9gFxu4172fNr00hKSoY8psgVboj4qYZlvBWz8RPrHxJgrH/+RDrfC+Bm4OMYxN4o+9r9 I2aH6eUKonBAFnECIU0Mhj8hmv+s65o= Received: from localhost.localdomain (fttx-pool-217.61.156.255.bambit.de [217.61.156.255]) by mxbox2.masterlogin.de (Postfix) with ESMTPSA id 83ED61006D4; Wed, 2 Sep 2020 06:14:01 +0000 (UTC) From: Frank Wunderlich To: u-boot@lists.denx.de, Marek Vasut Cc: Chunfeng Yun , GSS_MTK_Uboot_upstream , Chunfeng Yun Subject: [RESEND PATCH v2 11/11] usb: xhci: convert to readx_poll_sleep_timeout() Date: Wed, 2 Sep 2020 08:13:43 +0200 Message-Id: <20200902061343.3185-11-linux@fw-web.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200902061343.3185-1-linux@fw-web.de> References: <20200902061343.3185-1-linux@fw-web.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Use readx_poll_sleep_timeout() to poll the register status Change-Id: If05a68baf52c54ab30029279e349be6076f1d0ca Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index fe30101d93..3547a9bad1 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT @@ -143,23 +144,19 @@ struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev) * @param usec time to wait till * @return 0 if handshake is success else < 0 on failure */ -static int handshake(uint32_t volatile *ptr, uint32_t mask, - uint32_t done, int usec) +static int +handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec) { uint32_t result; + int ret; + + ret = readx_poll_sleep_timeout(xhci_readl, ptr, result, + (result & mask) == done || result == U32_MAX, + 1, usec); + if (result == U32_MAX) /* card removed */ + return -ENODEV; - do { - result = xhci_readl(ptr); - if (result == ~(uint32_t)0) - return -ENODEV; - result &= mask; - if (result == done) - return 0; - usec--; - udelay(1); - } while (usec > 0); - - return -ETIMEDOUT; + return ret; } /**