From patchwork Mon Nov 2 07:18:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 11873071 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 DD91B1130 for ; Mon, 2 Nov 2020 07:19:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0662208A9 for ; Mon, 2 Nov 2020 07:19:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="nsZLsvQc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgKBHTZ (ORCPT ); Mon, 2 Nov 2020 02:19:25 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:45793 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727306AbgKBHTZ (ORCPT ); Mon, 2 Nov 2020 02:19:25 -0500 X-UUID: 9a98dd67755a4dcfa854f04c12e4bed8-20201102 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=kZvapf7pIFQLgezOg35dcW/H2iGzgefNvWKVVQEly1I=; b=nsZLsvQcckE23itrZnczCPTFpmeugos0n+XlbNRGCnr7DHYdLD3AfHOQzhyI5Y5mMtcscT+eJobaDCvHpRca9pLu1EZfEFf6wk/t+AsDxNBJC8tlOsnkBKUe0DTeC1sn2DOkXg+F6hm8rvKGpNVsSBXr0mFM5AQXYheor0z646E=; X-UUID: 9a98dd67755a4dcfa854f04c12e4bed8-20201102 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1505547485; Mon, 02 Nov 2020 15:19:01 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 2 Nov 2020 15:18:59 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 2 Nov 2020 15:18:59 +0800 From: Macpaul Lin To: Greg Kroah-Hartman , Rob Herring , Matthias Brugger , Mathias Nyman , Chunfeng Yun , , , , , CC: Ainge Hsu , Eddie Hung , Mediatek WSD Upstream , Macpaul Lin , Macpaul Lin Subject: [PATCH 1/2] dt-bindings: usb: mediatek,mtk-xhci: add keep-clock-on Date: Mon, 2 Nov 2020 15:18:48 +0800 Message-ID: <1604301530-31546-1-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Option "mediatek,keep-clock-on" means to keep clock on during system suspend and resume. Some platform will flush register settings if clock has been disabled when system is suspended. Set this option to avoid clock off. Signed-off-by: Macpaul Lin --- .../devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml index ea696c8..a956dde 100644 --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml @@ -104,6 +104,12 @@ properties: description: enable USB remote wakeup, see power/wakeup-source.txt type: boolean + mediatek,keep-clock-on: + description: | + Keep clock on during system suspend and resume. Some platform will flush + register settings if clock has been disabled when system is suspended. + type: boolean + mediatek,syscon-wakeup: $ref: /schemas/types.yaml#/definitions/phandle-array maxItems: 1 @@ -175,6 +181,7 @@ examples: imod-interval-ns = <10000>; mediatek,syscon-wakeup = <&pericfg 0x400 1>; wakeup-source; + mediatek,keep-clock-on; usb3-lpm-capable; }; ... From patchwork Mon Nov 2 07:18:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 11873083 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 8D6421130 for ; Mon, 2 Nov 2020 07:29:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 684F222275 for ; Mon, 2 Nov 2020 07:29:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="MJI4YynX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728074AbgKBH31 (ORCPT ); Mon, 2 Nov 2020 02:29:27 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:54779 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727743AbgKBH30 (ORCPT ); Mon, 2 Nov 2020 02:29:26 -0500 X-UUID: 61977ac1706346fc9e706c7ab32b53f0-20201102 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:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=EwMAk6C90zx3ggLjTVwBgHjheE+if1MCBTaw2ieul20=; b=MJI4YynXNnuMC61TASrV2gd2iOeqQ1Sf9E/FmvR4m3nq0/0Scz6pyi2e+eARahtjaC9vg/mE3h+UizLw4xU/2AmYoDnkgGzORyNHLxZSO8wn5SQ+W7jdErVnW2RAbnwv57vZlsuNupFabzzh90Y5EKGShM1bajzRwUIm1dX/dxg=; X-UUID: 61977ac1706346fc9e706c7ab32b53f0-20201102 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 436479442; Mon, 02 Nov 2020 15:19:03 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 2 Nov 2020 15:19:01 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 2 Nov 2020 15:19:01 +0800 From: Macpaul Lin To: Greg Kroah-Hartman , Rob Herring , Matthias Brugger , Mathias Nyman , Chunfeng Yun , , , , , CC: Ainge Hsu , Eddie Hung , Mediatek WSD Upstream , Macpaul Lin , Macpaul Lin Subject: [PATCH 2/2] usb: host: XHCI: xhci-mtk.c: support mediatek,keep-clock-on Date: Mon, 2 Nov 2020 15:18:49 +0800 Message-ID: <1604301530-31546-2-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1604301530-31546-1-git-send-email-macpaul.lin@mediatek.com> References: <1604301530-31546-1-git-send-email-macpaul.lin@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some platform dose not support turn off clock when system suspending. We add an option "mediatek,keep-clock-on" for distinquish these platforms. When "mediatek,keep-clock-on" has been set, xhci-mtk driver will skip turning clock on and off during system suspend and resume. Signed-off-by: Macpaul Lin --- drivers/usb/host/xhci-mtk.c | 9 +++++++-- drivers/usb/host/xhci-mtk.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 4311d4c..c6c2804 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -464,6 +464,9 @@ static int xhci_mtk_probe(struct platform_device *pdev) of_property_read_u32(node, "mediatek,u3p-dis-msk", &mtk->u3p_dis_msk); + /* keep clock on when suspending on some platform */ + mtk->keep_clk_on = of_property_read_bool(node, "mediatek,keep-clock-on"); + ret = usb_wakeup_of_property_parse(mtk, node); if (ret) { dev_err(dev, "failed to parse uwk property\n"); @@ -624,7 +627,8 @@ static int __maybe_unused xhci_mtk_suspend(struct device *dev) del_timer_sync(&xhci->shared_hcd->rh_timer); xhci_mtk_host_disable(mtk); - xhci_mtk_clks_disable(mtk); + if (!mtk->keep_clk_on) + xhci_mtk_clks_disable(mtk); usb_wakeup_set(mtk, true); return 0; } @@ -636,7 +640,8 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); usb_wakeup_set(mtk, false); - xhci_mtk_clks_enable(mtk); + if (!mtk->keep_clk_on) + xhci_mtk_clks_enable(mtk); xhci_mtk_host_enable(mtk); xhci_dbg(xhci, "%s: restart port polling\n", __func__); diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index a93cfe8..37639c5 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -152,6 +152,7 @@ struct xhci_hcd_mtk { struct regmap *uwk; u32 uwk_reg_base; u32 uwk_vers; + bool keep_clk_on; }; static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)