From patchwork Sat Dec 9 08:45:32 2017 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: 10103611 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 3D30D60329 for ; Sat, 9 Dec 2017 08:48:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A3B228FF6 for ; Sat, 9 Dec 2017 08:48:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C3DB29011; Sat, 9 Dec 2017 08:48:08 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 9E6C528FF6 for ; Sat, 9 Dec 2017 08:48:07 +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=zPNLDqGPLFjDDkatSuqy1fmsnpQMZg/7PjkU6m+XFQE=; b=d16qr2xpA2lffS A3MVLot+Fa6BRgi8LTVZ+BIq6/MwK5gVtA7LqBnj0Rn3bwacy89Kkkd3CrK/Z4DtlO3m+B2qheUEB s3HZIG4fPlMF9BIZZw/RpWBwrtbzlhaIkcqo0fGz5f7wt1CCubIXV+EjoD80tmJArBySoPcPaaxLO CK0Z+pdEiNWQh5kDDePfqN7N7jf6zRLScpyCKuXJFJGOEoPvC11ba9H6WJ2A1n4Gs1XNnE3BIFQqP K7Hu9YUjW1WXk7Vs+8W6813IPEdXlTkHElnFVtHgdoImnV/KRZLOf+TtXaMIXJ0R5z8/eCpgwr62V A6ddAoIF9XIScQTxaG2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eNanl-0007p8-Fh; Sat, 09 Dec 2017 08:48:05 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eNan7-0007Bu-PZ; Sat, 09 Dec 2017 08:47:27 +0000 X-UUID: d81476b102bf40eba7e579f37b62273f-20171209 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1066184038; Sat, 09 Dec 2017 16:46:56 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Sat, 9 Dec 2017 16:46:55 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Sat, 9 Dec 2017 16:46:55 +0800 From: Chunfeng Yun To: Rob Herring , Felipe Balbi , Matthias Brugger , Mathias Nyman Subject: [PATCH 3/7] usb: xhci-mtk: use APIs of mtu_wakeup to support remote wakeup Date: Sat, 9 Dec 2017 16:45:32 +0800 Message-ID: <1512809136-2779-4-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun@mediatek.com> References: <1512809136-2779-1-git-send-email-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-20171209_004726_025384_FF6900EA X-CRM114-Status: GOOD ( 19.03 ) 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: Mark Rutland , devicetree@vger.kernel.org, linux-usb@vger.kernel.org, Greg Kroah-Hartman , Sean Wang , Will Deacon , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Chunfeng Yun , Jean Delvare Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On some platforms, there are two xHCI IPs, but the old way of usb wakeup doesn't support it, so use the new APIs of mtu_wakeup to support it. Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mtk.c | 39 +++++++++++++++++++++++---------------- drivers/usb/host/xhci-mtk.h | 2 ++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index b62a1d2..3176a10 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "xhci.h" #include "xhci-mtk.h" @@ -366,7 +367,9 @@ static void usb_wakeup_line_state_dis(struct xhci_hcd_mtk *mtk) static void usb_wakeup_enable(struct xhci_hcd_mtk *mtk) { - if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) + if (mtk->wakeup) + mtu_wakeup_enable(mtk->uwk); + else if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) usb_wakeup_ip_sleep_en(mtk); else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE) usb_wakeup_line_state_en(mtk); @@ -374,7 +377,9 @@ static void usb_wakeup_enable(struct xhci_hcd_mtk *mtk) static void usb_wakeup_disable(struct xhci_hcd_mtk *mtk) { - if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) + if (mtk->wakeup) + mtu_wakeup_disable(mtk->uwk); + else if (mtk->wakeup_src == SSUSB_WK_IP_SLEEP) usb_wakeup_ip_sleep_dis(mtk); else if (mtk->wakeup_src == SSUSB_WK_LINE_STATE) usb_wakeup_line_state_dis(mtk); @@ -383,24 +388,26 @@ static void usb_wakeup_disable(struct xhci_hcd_mtk *mtk) static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, struct device_node *dn) { - struct device *dev = mtk->dev; + /* try the new way first */ + mtk->wakeup = of_property_read_bool(dn, "wakeup-source"); + if (mtk->wakeup) { + mtk->uwk = devm_of_uwk_get_by_index(mtk->dev, dn, 0); + if (IS_ERR(mtk->uwk)) + dev_err(mtk->dev, "fail to get uwk\n"); + + return PTR_ERR_OR_ZERO(mtk->uwk); + } - /* - * wakeup function is optional, so it is not an error if this property - * does not exist, and in such case, no need to get relative - * properties anymore. - */ + /* wakeup function is optional (deprecated, use the new way instead) */ of_property_read_u32(dn, "mediatek,wakeup-src", &mtk->wakeup_src); - if (!mtk->wakeup_src) - return 0; - - mtk->pericfg = syscon_regmap_lookup_by_phandle(dn, + if (mtk->wakeup_src) { + mtk->pericfg = syscon_regmap_lookup_by_phandle(dn, "mediatek,syscon-wakeup"); - if (IS_ERR(mtk->pericfg)) { - dev_err(dev, "fail to get pericfg regs\n"); - return PTR_ERR(mtk->pericfg); + if (IS_ERR(mtk->pericfg)) { + dev_err(mtk->dev, "fail to get pericfg regs\n"); + return PTR_ERR(mtk->pericfg); + } } - return 0; } diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index 6b74ce5..95bd6ca 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -124,6 +124,8 @@ struct xhci_hcd_mtk { int num_phys; int wakeup_src; bool lpm_support; + struct mtu_wakeup *uwk; + bool wakeup; }; static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)