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; } /**