From patchwork Thu May 10 05:47:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 10391215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 315F66053D for ; Thu, 10 May 2018 05:53:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D2F7286E2 for ; Thu, 10 May 2018 05:53:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 121E128816; Thu, 10 May 2018 05:53:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D2FA8286E2 for ; Thu, 10 May 2018 05:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9lBqCAQvc1AXH9oiTkLAiq/IESFFF0d/1V2nbYanJYw=; b=QpAGnNTa2OJZqS Rn0I2EcQeUmn9Vamy8c+LOLA11AwM3apTUtbRN81W8Wrdg4Pj0FEiqdjITV9QUpRRNOOPhqe+zvdU b5GyK+V6q9FEiiouz4qMpO2u0mnQUmL8PCJk8RNik9sGYATawMmerIVNvkW5I61IxJHP987MEWznn JafaCaLMtNyFjf90fH6OvkXuox3uXNMSoCIGB8icYoN25Ay2VDrKfEXyG0hdUD5ABSO8XUWqTCF85 cOMaW2c8gz/dcVEfGRKudI/Kt+PLgj0fTyuFzne6P3f9vq54cJD0PoI5sEqtEVV1JxWjNh9FewuTR 5a/cUQJUR1w4R2o+Jf2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGeW4-0001mb-Kw; Thu, 10 May 2018 05:53:24 +0000 Received: from [1.203.163.81] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGeQb-0006Tg-7B; Thu, 10 May 2018 05:47:48 +0000 X-UUID: b697d99f450d43fbb78745a43d8b7a19-20180510 Received: from mtkcas35.mediatek.inc [(172.27.4.250)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 188568909; Thu, 10 May 2018 13:47:22 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 10 May 2018 13:47:21 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Thu, 10 May 2018 13:47:20 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v2 4/7] usb: mtu3: fix operation failure when test TEST_J/K Date: Thu, 10 May 2018 13:47:09 +0800 Message-ID: <572648c3e38d9d7947ecc397eb964178e140e40d.1525930818.git.chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <6b82c11302a81368bd6936424d081ede3340b431.1525930818.git.chunfeng.yun@mediatek.com> References: <6b82c11302a81368bd6936424d081ede3340b431.1525930818.git.chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180509_224745_494310_78459B60 X-CRM114-Status: GOOD ( 11.19 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Chunfeng Yun , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There is an error dialog popped up in PC when test TEST_J/K by EHSETT tool, due to not waiting for the completion of control transfer. Here fix it by entering test mode after Status Stage finish. Signed-off-by: Chunfeng Yun --- v2: 1. reset test_mode as default value when controller is reset 2. use readl_poll_timeout_atomic() --- drivers/usb/mtu3/mtu3_gadget.c | 1 + drivers/usb/mtu3/mtu3_gadget_ep0.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c index de0de01..5c60a8c 100644 --- a/drivers/usb/mtu3/mtu3_gadget.c +++ b/drivers/usb/mtu3/mtu3_gadget.c @@ -719,4 +719,5 @@ void mtu3_gadget_reset(struct mtu3 *mtu) mtu->u1_enable = 0; mtu->u2_enable = 0; mtu->delayed_status = false; + mtu->test_mode = false; } diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c b/drivers/usb/mtu3/mtu3_gadget_ep0.c index d67b540..d3fc51b 100644 --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c @@ -7,6 +7,7 @@ * Author: Chunfeng.Yun */ +#include #include #include "mtu3.h" @@ -263,6 +264,7 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup) { void __iomem *mbase = mtu->mac_base; int handled = 1; + u32 value; switch (le16_to_cpu(setup->wIndex) >> 8) { case TEST_J: @@ -292,6 +294,14 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup) if (mtu->test_mode_nr == TEST_PACKET_MODE) ep0_load_test_packet(mtu); + /* send status before entering test mode. */ + value = mtu3_readl(mbase, U3D_EP0CSR) & EP0_W1C_BITS; + mtu3_writel(mbase, U3D_EP0CSR, value | EP0_SETUPPKTRDY | EP0_DATAEND); + + /* wait for ACK status sent by host, ignore timeout error */ + readl_poll_timeout_atomic(mbase + U3D_EP0CSR, value, + !(value & EP0_DATAEND), 100, 5000); + mtu3_writel(mbase, U3D_USB2_TEST_MODE, mtu->test_mode_nr); mtu->ep0_state = MU3D_EP0_STATE_SETUP;