From patchwork Thu Nov 14 02:33:11 2019 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: 11242939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD64C109A for ; Thu, 14 Nov 2019 02:33:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFBD3206EC for ; Thu, 14 Nov 2019 02:33:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="DE1IpPyB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbfKNCdp (ORCPT ); Wed, 13 Nov 2019 21:33:45 -0500 Received: from mailgw02.mediatek.com ([1.203.163.81]:10737 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726473AbfKNCdp (ORCPT ); Wed, 13 Nov 2019 21:33:45 -0500 X-UUID: 273aaed76625470ebb4fee21e3be15fe-20191114 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=jdpcBWc7HBlDBSHQj9W7l/lAc9ZUoty9ehXTUgWCTGw=; b=DE1IpPyBL+mC1m1knTLKZFTpztGf8k13sLrkBIVTY6cyZX7Le3W/Huc0mCBlTe82eBmGGdmRI5p6xCcEzGIWGgk0rWP47CbEBZXXM86lDwTe2Kf1M/dQ7CGelnvi8/9ZPZkvSYG2hjOKWWyv05Lh/pAkHSveOOjHJTh2Q9HLqt0=; X-UUID: 273aaed76625470ebb4fee21e3be15fe-20191114 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 2040405152; Thu, 14 Nov 2019 10:33:30 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 14 Nov 2019 10:33:21 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 14 Nov 2019 10:33:20 +0800 From: Chunfeng Yun To: Tianping Fang CC: Greg Kroah-Hartman , Matthias Brugger , Chunfeng Yun , , , , , Subject: [RFC PATCH] usb: mtu3: fix random remote wakeup Date: Thu, 14 Nov 2019 10:33:11 +0800 Message-ID: <1573698791-24310-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-TM-SNTS-SMTP: 2075714ACED72CBB15C4DCA956E5D8B2E8C542FC8427F2F77C2C39642685507E2000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Wakeup_signal will toggle status according to ssusb_ip_sleep signal after debounce time, so need add a delay time and wait for wakeup_signal toggle to complete, then enable the remote wakeup. Meanwhile reduce the debounce time of wakeup_signal. These will avoid spurious wakeup event. Signed-off-by: Tianping Fang Signed-off-by: Chunfeng Yun --- Note, depends on following patch not merged: [v3,3/7] usb: mtu3: support ip-sleep wakeup for MT8183 https://patchwork.kernel.org/patch/11123151/ --- drivers/usb/mtu3/mtu3_host.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c index 182c9439c15a..ca48ff751c8b 100644 --- a/drivers/usb/mtu3/mtu3_host.c +++ b/drivers/usb/mtu3/mtu3_host.c @@ -53,12 +53,12 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable) case SSUSB_UWK_V0: reg = ssusb->uwk_reg_base + PERI_WK_CTRL0; msk = (u32)(WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P); - val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0; + val = enable ? (WC0_IS_EN | WC0_IS_C(0x3)) : 0; break; case SSUSB_UWK_V1: reg = ssusb->uwk_reg_base + PERI_WK_CTRL1; msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P; - val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0; + val = enable ? (WC1_IS_EN | WC1_IS_C(0x3)) : 0; break; case SSUSB_UWK_V2: reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL; @@ -197,6 +197,8 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend) (value & SSUSB_IP_SLEEP_STS), 100, 100000); if (ret) dev_err(ssusb->dev, "ip sleep failed!!!\n"); + else /* wait for wakeup_signal toggle done after enter ip-sleep */ + usleep_range(245, 255); return ret; }