From patchwork Sat Apr 10 05:10:02 2021 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: 12195375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C62F0C433B4 for ; Sat, 10 Apr 2021 05:13:08 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3AB3C60FDB for ; Sat, 10 Apr 2021 05:13:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AB3C60FDB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=jZIJS9spoO94CjNJylvxdy9OO5U/VVM5I/yT6VQqg2w=; b=OuFRL0RxeYvjfe36zMM+3HRc6p UIl7JN1aumXLQP3/rxwvH0munHVciZ5+PVn4rSo4pmECiiu5GFMCpD9yuUKscRy0R9U0gIhLFtr4i qIsEKNoj4m7ypN+DIwqO1g94H6hRfEybV7SzGus7Qui+4KdZ8LvjtB7QEGYxC91JMwAGotgHdwylp bZ5DujDqG579F/xDNLZ4Rrt7WLGylGQHIm1XLYA/tO1xaAyxxU77WtniHhO6rxgKbk6yDAOBlTtKt ocp+at5O92GmY5Lmdn2rcNEBL94gEvlAd7UK3ey8wEe16s25bOwdDW8Y3SiX82xwWgON+S06jIB3s eFR2oE8g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lV5tz-002Buf-0t; Sat, 10 Apr 2021 05:11:23 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t6-002BnC-3c; Sat, 10 Apr 2021 05:10:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-ID:Content-Description:In-Reply-To:References; bh=m34EP+vtULrb01573Z6/tRKTrlVuQzPz01IbHzGKP18=; b=mJSak0PTX70Ba/+XUYG1RK+A9e UmgYtxeW0ljRNmdRJAXFoEjL4ofZWbtDfvZXQfZuYBGoDWqXTYXJbKq7EcCLex/D7FkcgE95YybHr N0qUZyWG/h5lw5RlRqpjkuOOQpL2d0Bm5x0UoADIJSKKSWLHavWNfeXf69a3oBm6GqLtWa6mLtxMN /z1F0vx4oMCOceLWGXxLFHTNjJfWqjGx9pkk8swWeTLruDz6awFQsoh7+94eP43lw5Ox3XaKiJCvq fRUKtrSrgntYIqZnhUcsRd9TS+KDSzl4BCOG4wnMNuxg6okpo+afyTSC9sc9Es+olHr21cxt4ZEvk jj6w4o+w==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t2-004wG5-EG; Sat, 10 Apr 2021 05:10:25 +0000 X-UUID: 6827273441ed46ffb3a626205ee2643e-20210409 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=m34EP+vtULrb01573Z6/tRKTrlVuQzPz01IbHzGKP18=; b=Ke65rZHxGwonM1CDjnwB09RCN+lqKdZs4zMmY1o7YWIqZdMgObs43uYZRcyF8+Ttlpg+PTPAcF0ISoKJEJa+7lhqmdvTmjSQKCotD+ceb5r+wBCtBNhKiQXOGKEyanqkcil/MI+Ssnx2tm2OeYTwJuNt3pC6SApNnsiD9pfKGI0=; X-UUID: 6827273441ed46ffb3a626205ee2643e-20210409 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1578271561; Fri, 09 Apr 2021 22:10:20 -0700 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Apr 2021 22:10:18 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 13:10:17 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 13:10:09 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Mathias Nyman CC: Chunfeng Yun , Rob Herring , Matthias Brugger , "Rafael J. Wysocki" , Len Brown , Pavel Machek , , , , , , , Tony Lindgren , Tianping Fang , Eddie Hung , "Ikjoon Jang" , Nicolas Boichat Subject: [PATCH v2 1/5] usb: xhci-mtk: check return value in suspend/resume hooks Date: Sat, 10 Apr 2021 13:10:02 +0800 Message-ID: <1618031406-15347-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210409_221024_509109_139D03DF X-CRM114-Status: GOOD ( 15.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Return error number if encounter errors during suspend and resume. Signed-off-by: Chunfeng Yun --- v2: no changes --- drivers/usb/host/xhci-mtk.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index c1bc40289833..a74764ab914a 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -630,18 +630,12 @@ static int xhci_mtk_remove(struct platform_device *dev) return 0; } -/* - * if ip sleep fails, and all clocks are disabled, access register will hang - * AHB bus, so stop polling roothubs to avoid regs access on bus suspend. - * and no need to check whether ip sleep failed or not; this will cause SPM - * to wake up system immediately after system suspend complete if ip sleep - * fails, it is what we wanted. - */ static int __maybe_unused xhci_mtk_suspend(struct device *dev) { struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); struct usb_hcd *hcd = mtk->hcd; struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; xhci_dbg(xhci, "%s: stop port polling\n", __func__); clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); @@ -649,10 +643,21 @@ static int __maybe_unused xhci_mtk_suspend(struct device *dev) clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); del_timer_sync(&xhci->shared_hcd->rh_timer); - xhci_mtk_host_disable(mtk); + ret = xhci_mtk_host_disable(mtk); + if (ret) + goto restart_poll_rh; + xhci_mtk_clks_disable(mtk); usb_wakeup_set(mtk, true); return 0; + +restart_poll_rh: + xhci_dbg(xhci, "%s: restart port polling\n", __func__); + set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); + usb_hcd_poll_rh_status(xhci->shared_hcd); + set_bit(HCD_FLAG_POLL_RH, &hcd->flags); + usb_hcd_poll_rh_status(hcd); + return ret; } static int __maybe_unused xhci_mtk_resume(struct device *dev) @@ -660,10 +665,16 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); struct usb_hcd *hcd = mtk->hcd; struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; usb_wakeup_set(mtk, false); - xhci_mtk_clks_enable(mtk); - xhci_mtk_host_enable(mtk); + ret = xhci_mtk_clks_enable(mtk); + if (ret) + goto enable_wakeup; + + ret = xhci_mtk_host_enable(mtk); + if (ret) + goto disable_clks; xhci_dbg(xhci, "%s: restart port polling\n", __func__); set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); @@ -671,6 +682,12 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) set_bit(HCD_FLAG_POLL_RH, &hcd->flags); usb_hcd_poll_rh_status(hcd); return 0; + +disable_clks: + xhci_mtk_clks_disable(mtk); +enable_wakeup: + usb_wakeup_set(mtk, true); + return ret; } static const struct dev_pm_ops xhci_mtk_pm_ops = { From patchwork Sat Apr 10 05:10:03 2021 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: 12195371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 459CAC433B4 for ; Sat, 10 Apr 2021 05:13:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D76A3611AE for ; Sat, 10 Apr 2021 05:12:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D76A3611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=B13O1oSBXYy52xRpLD49QE2ZXGk3dvyKr8FgFWZ2T2Q=; b=pvKb9LIqCBQsH+s36qfzUFS2V bGSmTdadZXw4+2TW6VJSwxGXigagQBmRrvNwpsQrRA0mjjhI/ZGEMmKK1gQFejhbxme/oD+5ZyLUn MRJe7HPmtgntYdW5/9kdzsl30qMysZQqH5dp4r8U14r2b5avfMBDDtSj2tn2o+njcjHnqk7cJBMjG a0ezjVJzg6/b31TThs7kXhYL5SgweHXPf0UUB2L9QmEWF9iNZQVeGOMbp8Kq4QnlTubdgpyKXkjuV Q26J7bOiMqF3/6xNy57oe7c70+KrdfrTANJH//rLM0if0o8QIKibZ2xTHVxyL+/PsT70OhYAP1j/6 w/fQmqdCA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lV5tX-002Br0-9U; Sat, 10 Apr 2021 05:10:55 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t6-002BnD-3c; Sat, 10 Apr 2021 05:10:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=Jqu5mgmnwtoA/IJe+oC6Vlro2lgKuNDVMxjmkW3RzQw=; b=3xBs9/al2JdRDTtZSvXMHUQLl1 sdMlyiIKuAtst0O5/WD3or8xAthBFsJlicfn6EgEYkwYqfvEhKqbmmMi9IHnr1tUJ1i0fpYA6lGmO Y2l0s6LUSSTeGSAaDQ/Zthnm0TyfaPY8hrgXY3Nvqfeo0Cr+LSBx60aDxzv8nEhCz6wA0d3iU3tJ0 QHqRc3t/6l8DT52dNJgxpMk0GdkdwULENQBEqWUy8xrv2lyZHU6SjlWPUgx5tvXJHPyFgrCDbdgwX O4OW4pBK1Tkxkmn5nKvV67plASSjlwWF7ndYkzEtKqbOyzM9unbRYUvfjClU0H2HfdHMnuOetdBeH JTeCMzDA==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t2-004wG6-Kj; Sat, 10 Apr 2021 05:10:25 +0000 X-UUID: aec4f3f5b6a446b0882928d5553b6309-20210409 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=Jqu5mgmnwtoA/IJe+oC6Vlro2lgKuNDVMxjmkW3RzQw=; b=fkbUdwUANkS5x5R/SdqMu/ZUgH6Uu4uEtBH5JBOSRI/GQBZ2EpIKxrruU/19y8LmvnS/KoiH5A/6WQchuCx5KpB5Kt54Xsjj34Km+3Re9XwSVg5e4kPRCYD77n68W2CUU11lKmt3hH4W6za/uDRhJgCxOzOqFgIc4Aetj+wm4RM=; X-UUID: aec4f3f5b6a446b0882928d5553b6309-20210409 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 269019712; Fri, 09 Apr 2021 22:10:22 -0700 Received: from MTKMBS06N2.mediatek.inc (172.21.101.130) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Apr 2021 22:10:20 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 13:10:18 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 13:10:17 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Mathias Nyman CC: Chunfeng Yun , Rob Herring , Matthias Brugger , "Rafael J. Wysocki" , Len Brown , Pavel Machek , , , , , , , Tony Lindgren , Tianping Fang , Eddie Hung , "Ikjoon Jang" , Nicolas Boichat Subject: [PATCH v2 2/5] dt-bindings: usb: mtk-xhci: add wakeup interrupt Date: Sat, 10 Apr 2021 13:10:03 +0800 Message-ID: <1618031406-15347-2-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1618031406-15347-1-git-send-email-chunfeng.yun@mediatek.com> References: <1618031406-15347-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: E17103FB531DAC6961A975A9761F7CACEEA0AA56C5433C513A7E3E175D64DE182000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210409_221024_705347_A34D5858 X-CRM114-Status: GOOD ( 11.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add an interrupt which is EINT usually to support runtime PM, meanwhile add "interrupt-names" property, for backward compatibility, it's optional and used when wakeup interrupt exists Reviewed-by: Rob Herring Signed-off-by: Chunfeng Yun --- v2: add Reviewed-by Rob --- .../devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml index 45bf4ea00c9e..4fe8a301d03f 100644 --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml @@ -46,7 +46,18 @@ properties: - const: ippc # optional, only needed for case 1. interrupts: - maxItems: 1 + description: + use "interrupts-extended" when the interrupts are connected to the + separate interrupt controllers + minItems: 1 + items: + - description: xHCI host controller interrupt + - description: optional, wakeup interrupt used to support runtime PM + + interrupt-names: + items: + - const: host + - const: wakeup power-domains: description: A phandle to USB power domain node to control USB's MTCMOS From patchwork Sat Apr 10 05:10:04 2021 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: 12195373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91989C43460 for ; Sat, 10 Apr 2021 05:13:02 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 124AC611AE for ; Sat, 10 Apr 2021 05:13:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 124AC611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LqG3f4myWmhU87xSfDOnebxcDXI4cN49phaPAvzCTA8=; b=BhRSRtWPgcZ5RyvgE/NFPMRWW ThJsesgxDqHfy+kRzQVDRbIcgszpRxiYu2min7deC3W5AYVXVK4wii30kFC49JStRybv188BdQy2i 15VXDgeD0APwYx8RPGkuZ+WGYNgwxhoqWPMiOe3E6VGygbgMu89BLtKsRAQ3y4++RkCAaOsTIGh/N HvbLE2k1PVlSoDzgtgZi9xJGyjPDuUlb9UBUTCFXe1sffo75bYC3KR9aWYCRdgI/6+6F2b1w8u3ko 1xNt1ZFKgut6+p1anc8yfT0fh5vzu+x58FXYTbdD+rZdFXsJUkmnVc3xuV81U5YCqr37lbKF4wiwO k94UpxGrQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lV5tk-002Bsb-PQ; Sat, 10 Apr 2021 05:11:08 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t7-002BnP-1t; Sat, 10 Apr 2021 05:10:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=dBk2j9PMy+AVYLFdFIoNW1NJ02hfEqwt80XAxoaeQYc=; b=kPzm5La7QmZREMUFB99dP4g7sk kB4hOmUsYh84Nr0xuc3o3Du4cilYqt++fr8+ebihCJOyJ9A2g74j2kpeCM8IJTandhXKTPdlei7Ag gA5UVIbcAvILUZ6O0BNERWYOk/3h1rHJAtpUr2syYP4kdRHFqNhgODdYn0ok/EtE3wV+CQB3RTvme cm5Uw+KH1cAE9IuNiUEPJFvRdYg5EvZ5CxMpwtNud7oO1hJh95bGACdDleBJFcnZIzHXOMr4MvqkB L0kXs/uoZb0zUq/+LfDLDPirSoeV2BtfTUBF5Tl7TCRhXnDYKG3YuANdNm4zsU+2dfBmPt3o/aFiD d5npDnjA==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t3-004wGe-VM; Sat, 10 Apr 2021 05:10:27 +0000 X-UUID: 5e61d00168c148e9baba80cb9838b8b5-20210409 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=dBk2j9PMy+AVYLFdFIoNW1NJ02hfEqwt80XAxoaeQYc=; b=LalLV9NjvJzy/18197moXkmg+QU1v4dEgAQJkqjNlGtfd1UTBdEICnrXoEocr0dLriPbQAE42Wriqz7fXQtcM+oKEXQn8vxpA9P0ijfe8kVVVKslhRsfqSGvz5iFAqroVoI28PmUY+q1X+OnbMIGXN4lnaLyzBAKh+vaLWS6tQc=; X-UUID: 5e61d00168c148e9baba80cb9838b8b5-20210409 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 646612587; Fri, 09 Apr 2021 22:10:22 -0700 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Apr 2021 22:10:20 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 13:10:19 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 13:10:18 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Mathias Nyman CC: Chunfeng Yun , Rob Herring , Matthias Brugger , "Rafael J. Wysocki" , Len Brown , Pavel Machek , , , , , , , Tony Lindgren , Tianping Fang , Eddie Hung , "Ikjoon Jang" , Nicolas Boichat Subject: [PATCH v2 3/5] usb: xhci-mtk: add support runtime PM Date: Sat, 10 Apr 2021 13:10:04 +0800 Message-ID: <1618031406-15347-3-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1618031406-15347-1-git-send-email-chunfeng.yun@mediatek.com> References: <1618031406-15347-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-20210409_221026_062285_52C7CB9F X-CRM114-Status: GOOD ( 25.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A dedicated wakeup irq will be used to handle runtime suspend/resume, we use dev_pm_set_dedicated_wake_irq API to take care of requesting and attaching wakeup irq, then the suspend/resume framework will help to enable/disable wakeup irq. The runtime PM is default off since some platforms may not support it. users can enable it via power/control (set "auto") in sysfs. Signed-off-by: Chunfeng Yun --- v2: no changes, but abandon dependent patch [1], use falling edge type interrupt [1] [1/6] PM: runtime: enable wake irq after runtime_suspend hook called https://patchwork.kernel.org/project/linux-mediatek/patch/1617874514-12282-1-git-send-email-chunfeng.yun@mediatek.com/ --- drivers/usb/host/xhci-mtk.c | 140 +++++++++++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index a74764ab914a..30927f4064d4 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -358,7 +359,6 @@ static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, mtk->uwk_reg_base, mtk->uwk_vers); return PTR_ERR_OR_ZERO(mtk->uwk); - } static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable) @@ -458,6 +458,7 @@ static int xhci_mtk_probe(struct platform_device *pdev) struct resource *res; struct usb_hcd *hcd; int ret = -ENODEV; + int wakeup_irq; int irq; if (usb_disabled()) @@ -485,6 +486,21 @@ static int xhci_mtk_probe(struct platform_device *pdev) if (ret) return ret; + irq = platform_get_irq_byname_optional(pdev, "host"); + if (irq < 0) { + if (irq == -EPROBE_DEFER) + return irq; + + /* for backward compatibility */ + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + } + + wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup"); + if (wakeup_irq == -EPROBE_DEFER) + return wakeup_irq; + mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); /* optional property, ignore the error if it does not exist */ of_property_read_u32(node, "mediatek,u3p-dis-msk", @@ -496,9 +512,11 @@ static int xhci_mtk_probe(struct platform_device *pdev) return ret; } + pm_runtime_set_active(dev); + pm_runtime_use_autosuspend(dev); + pm_runtime_set_autosuspend_delay(dev, 4000); pm_runtime_enable(dev); pm_runtime_get_sync(dev); - device_enable_async_suspend(dev); ret = xhci_mtk_ldos_enable(mtk); if (ret) @@ -508,12 +526,6 @@ static int xhci_mtk_probe(struct platform_device *pdev) if (ret) goto disable_ldos; - irq = platform_get_irq(pdev, 0); - if (irq < 0) { - ret = irq; - goto disable_clk; - } - hcd = usb_create_hcd(driver, dev, dev_name(dev)); if (!hcd) { ret = -ENOMEM; @@ -579,8 +591,26 @@ static int xhci_mtk_probe(struct platform_device *pdev) if (ret) goto dealloc_usb2_hcd; + if (wakeup_irq > 0) { + ret = dev_pm_set_dedicated_wake_irq(dev, wakeup_irq); + if (ret) { + dev_err(dev, "set wakeup irq %d failed\n", wakeup_irq); + goto dealloc_usb3_hcd; + } + dev_info(dev, "wakeup irq %d\n", wakeup_irq); + } + + device_enable_async_suspend(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + pm_runtime_forbid(dev); + return 0; +dealloc_usb3_hcd: + usb_remove_hcd(xhci->shared_hcd); + xhci->shared_hcd = NULL; + dealloc_usb2_hcd: usb_remove_hcd(hcd); @@ -601,25 +631,26 @@ static int xhci_mtk_probe(struct platform_device *pdev) xhci_mtk_ldos_disable(mtk); disable_pm: - pm_runtime_put_sync(dev); + pm_runtime_put_sync_autosuspend(dev); pm_runtime_disable(dev); return ret; } -static int xhci_mtk_remove(struct platform_device *dev) +static int xhci_mtk_remove(struct platform_device *pdev) { - struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev); + struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev); struct usb_hcd *hcd = mtk->hcd; struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct usb_hcd *shared_hcd = xhci->shared_hcd; + struct device *dev = &pdev->dev; - pm_runtime_put_noidle(&dev->dev); - pm_runtime_disable(&dev->dev); + pm_runtime_get_sync(dev); + xhci->xhc_state |= XHCI_STATE_REMOVING; + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); usb_remove_hcd(shared_hcd); xhci->shared_hcd = NULL; - device_init_wakeup(&dev->dev, false); - usb_remove_hcd(hcd); usb_put_hcd(shared_hcd); usb_put_hcd(hcd); @@ -627,6 +658,10 @@ static int xhci_mtk_remove(struct platform_device *dev) xhci_mtk_clks_disable(mtk); xhci_mtk_ldos_disable(mtk); + pm_runtime_disable(dev); + pm_runtime_put_noidle(dev); + pm_runtime_set_suspended(dev); + return 0; } @@ -690,10 +725,83 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) return ret; } +static int check_rhub_status(struct xhci_hcd *xhci, struct xhci_hub *rhub) +{ + u32 suspended_ports; + u32 status; + int num_ports; + int i; + + num_ports = rhub->num_ports; + suspended_ports = rhub->bus_state.suspended_ports; + for (i = 0; i < num_ports; i++) { + if (!(suspended_ports & BIT(i))) { + status = readl(rhub->ports[i]->addr); + if (status & PORT_CONNECT) + return -EBUSY; + } + } + + return 0; +} + +/* + * check the bus whether it could suspend or not + * the bus will suspend if the downstream ports are already suspended, + * or no devices connected. + */ +static int check_bus_status(struct xhci_hcd *xhci) +{ + int ret; + + ret = check_rhub_status(xhci, &xhci->usb3_rhub); + if (ret) + return ret; + + return check_rhub_status(xhci, &xhci->usb2_rhub); +} + +static int __maybe_unused xhci_mtk_runtime_suspend(struct device *dev) +{ + struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); + struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); + int ret = 0; + + if (xhci->xhc_state) + return -ESHUTDOWN; + + if (device_may_wakeup(dev)) { + ret = check_bus_status(xhci); + if (!ret) + ret = xhci_mtk_suspend(dev); + } + + /* -EBUSY: let PM automatically reschedule another autosuspend */ + return ret ? -EBUSY : 0; +} + +static int __maybe_unused xhci_mtk_runtime_resume(struct device *dev) +{ + struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); + struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd); + int ret = 0; + + if (xhci->xhc_state) + return -ESHUTDOWN; + + if (device_may_wakeup(dev)) + ret = xhci_mtk_resume(dev); + + return ret; +} + static const struct dev_pm_ops xhci_mtk_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(xhci_mtk_suspend, xhci_mtk_resume) + SET_RUNTIME_PM_OPS(xhci_mtk_runtime_suspend, + xhci_mtk_runtime_resume, NULL) }; -#define DEV_PM_OPS IS_ENABLED(CONFIG_PM) ? &xhci_mtk_pm_ops : NULL + +#define DEV_PM_OPS (IS_ENABLED(CONFIG_PM) ? &xhci_mtk_pm_ops : NULL) static const struct of_device_id mtk_xhci_of_match[] = { { .compatible = "mediatek,mt8173-xhci"}, From patchwork Sat Apr 10 05:10:05 2021 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: 12195369 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AB94C433B4 for ; Sat, 10 Apr 2021 05:12:53 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A56AE610CF for ; Sat, 10 Apr 2021 05:12:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A56AE610CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xtVXZwr+smaRqnE24kdDHUo9eBDgsWKRDO566ssvdUc=; b=ebRietEkzhsYSDvG0E7f5dssb jYLRlrPtnZL5DiGkdpS0yP1sUS8IvsaarVmgXKV9YP369YLKewho8sU6qA/TZhuUBS0yHeGKTTa3D 4E/iLcr0RJqhPXfU43YOpJpXhz0VcaW+KC5MQ5wC3G5nCsg7iciBZugkoSNZ8XrPXudXyQMpbzGiF l5GCfaW/BVlAMcoX3effnl6YI114gJF3QF/bYcHnj8pjdycxep4wqp08mRfJ3lp2FqON7cmCLjE9B /5o34pmSNkefpVV0axPhCuxFwtY4zqc3GQF4kZtx8ADtN/YnBHLeNiCY0wR36DdrrDqBht5UtQi74 +uqj3qMaQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lV5tI-002Bp1-0K; Sat, 10 Apr 2021 05:10:40 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t7-002BnQ-Oy; Sat, 10 Apr 2021 05:10:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=Fn1iUg6z1RjceEPXTwLr2EfU4RaExIVd5Dvqso8rjEM=; b=JarRt6ag2CJTOWeYeDMsALKPHr 8xvJs5kdxNRrcgBpzlyewKGsf/vB9vdB71VENfmD738P0DdWSTuxceA7Olw3aDyzRpulaMjEk7uLS UqtCqHgUSgX+RMEjP07VE1JSHCnXz1NjxYWoduHbbAz2eVufO+KlxH6+EHblV0BusI425pVBKu9zS +XUf0W7yRbaj4L5BoCcOG0P22Cox02F4hicZjTf+un1JMt7ZEP8T8OjWAb0cwlNq5WNxNSlh34yGy aWTa28QzmI/ff2oPkQDjsdQaLKRsMCr+rVs7fE770pFmG4hGZmDJssWL6x7GqDxjhpoYyOsqe5aiO JMcMr/HQ==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV5t4-004wGz-VG; Sat, 10 Apr 2021 05:10:28 +0000 X-UUID: 53a9306d501b4cec996a4fcfe3038b89-20210409 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=Fn1iUg6z1RjceEPXTwLr2EfU4RaExIVd5Dvqso8rjEM=; b=K10uYg50ovvuswct5wsHlIy2m2CK11gFEL68+rjeAuPtxliOFH+X8CrGNShfl60oFmMZNqltnvQqQ5KiZvPHscpJjs+tkr9AqxhBIWB8oIHKfx65+ZSrvX4iv7swBgzL4N7eSWIFla8pjwKYAEwcwJXHvAtT8RLrI8hyr/+X9Us=; X-UUID: 53a9306d501b4cec996a4fcfe3038b89-20210409 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1669994066; Fri, 09 Apr 2021 22:10:24 -0700 Received: from MTKMBS06N2.mediatek.inc (172.21.101.130) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Apr 2021 22:10:22 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 13:10:20 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 13:10:19 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Mathias Nyman CC: Chunfeng Yun , Rob Herring , Matthias Brugger , "Rafael J. Wysocki" , Len Brown , Pavel Machek , , , , , , , Tony Lindgren , Tianping Fang , Eddie Hung , "Ikjoon Jang" , Nicolas Boichat Subject: [PATCH v2 4/5] usb: xhci-mtk: use clock bulk to get clocks Date: Sat, 10 Apr 2021 13:10:05 +0800 Message-ID: <1618031406-15347-4-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1618031406-15347-1-git-send-email-chunfeng.yun@mediatek.com> References: <1618031406-15347-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 3408E7EF8C2E42DC0C4F27BD6ECB1B867776072322ACE32B3E880F291C4878E82000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210409_221027_034753_65CF3A17 X-CRM114-Status: GOOD ( 16.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use clock bulk helpers to get/enable/disable clocks, meanwhile make sys_ck optional, then will be easier to handle clocks. Signed-off-by: Chunfeng Yun --- v2: no changes --- drivers/usb/host/xhci-mtk.c | 109 +++++++----------------------------- drivers/usb/host/xhci-mtk.h | 10 ++-- 2 files changed, 24 insertions(+), 95 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 30927f4064d4..d4c455eecb8d 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -7,7 +7,6 @@ * Chunfeng Yun */ -#include #include #include #include @@ -220,89 +219,6 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) return xhci_mtk_host_enable(mtk); } -static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) -{ - struct device *dev = mtk->dev; - - mtk->sys_clk = devm_clk_get(dev, "sys_ck"); - if (IS_ERR(mtk->sys_clk)) { - dev_err(dev, "fail to get sys_ck\n"); - return PTR_ERR(mtk->sys_clk); - } - - mtk->xhci_clk = devm_clk_get_optional(dev, "xhci_ck"); - if (IS_ERR(mtk->xhci_clk)) - return PTR_ERR(mtk->xhci_clk); - - mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck"); - if (IS_ERR(mtk->ref_clk)) - return PTR_ERR(mtk->ref_clk); - - mtk->mcu_clk = devm_clk_get_optional(dev, "mcu_ck"); - if (IS_ERR(mtk->mcu_clk)) - return PTR_ERR(mtk->mcu_clk); - - mtk->dma_clk = devm_clk_get_optional(dev, "dma_ck"); - return PTR_ERR_OR_ZERO(mtk->dma_clk); -} - -static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) -{ - int ret; - - ret = clk_prepare_enable(mtk->ref_clk); - if (ret) { - dev_err(mtk->dev, "failed to enable ref_clk\n"); - goto ref_clk_err; - } - - ret = clk_prepare_enable(mtk->sys_clk); - if (ret) { - dev_err(mtk->dev, "failed to enable sys_clk\n"); - goto sys_clk_err; - } - - ret = clk_prepare_enable(mtk->xhci_clk); - if (ret) { - dev_err(mtk->dev, "failed to enable xhci_clk\n"); - goto xhci_clk_err; - } - - ret = clk_prepare_enable(mtk->mcu_clk); - if (ret) { - dev_err(mtk->dev, "failed to enable mcu_clk\n"); - goto mcu_clk_err; - } - - ret = clk_prepare_enable(mtk->dma_clk); - if (ret) { - dev_err(mtk->dev, "failed to enable dma_clk\n"); - goto dma_clk_err; - } - - return 0; - -dma_clk_err: - clk_disable_unprepare(mtk->mcu_clk); -mcu_clk_err: - clk_disable_unprepare(mtk->xhci_clk); -xhci_clk_err: - clk_disable_unprepare(mtk->sys_clk); -sys_clk_err: - clk_disable_unprepare(mtk->ref_clk); -ref_clk_err: - return ret; -} - -static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) -{ - clk_disable_unprepare(mtk->dma_clk); - clk_disable_unprepare(mtk->mcu_clk); - clk_disable_unprepare(mtk->xhci_clk); - clk_disable_unprepare(mtk->sys_clk); - clk_disable_unprepare(mtk->ref_clk); -} - /* only clocks can be turn off for ip-sleep wakeup mode */ static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable) { @@ -367,6 +283,19 @@ static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable) usb_wakeup_ip_sleep_set(mtk, enable); } +static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) +{ + struct clk_bulk_data *clks = mtk->clks; + + clks[0].id = "sys_ck"; + clks[1].id = "xhci_ck"; + clks[2].id = "ref_ck"; + clks[3].id = "mcu_ck"; + clks[4].id = "dma_ck"; + + return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks); +} + static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk) { int ret; @@ -522,7 +451,7 @@ static int xhci_mtk_probe(struct platform_device *pdev) if (ret) goto disable_pm; - ret = xhci_mtk_clks_enable(mtk); + ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); if (ret) goto disable_ldos; @@ -625,7 +554,7 @@ static int xhci_mtk_probe(struct platform_device *pdev) usb_put_hcd(hcd); disable_clk: - xhci_mtk_clks_disable(mtk); + clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); disable_ldos: xhci_mtk_ldos_disable(mtk); @@ -655,7 +584,7 @@ static int xhci_mtk_remove(struct platform_device *pdev) usb_put_hcd(shared_hcd); usb_put_hcd(hcd); xhci_mtk_sch_exit(mtk); - xhci_mtk_clks_disable(mtk); + clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); xhci_mtk_ldos_disable(mtk); pm_runtime_disable(dev); @@ -682,7 +611,7 @@ static int __maybe_unused xhci_mtk_suspend(struct device *dev) if (ret) goto restart_poll_rh; - xhci_mtk_clks_disable(mtk); + clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); usb_wakeup_set(mtk, true); return 0; @@ -703,7 +632,7 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) int ret; usb_wakeup_set(mtk, false); - ret = xhci_mtk_clks_enable(mtk); + ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks); if (ret) goto enable_wakeup; @@ -719,7 +648,7 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) return 0; disable_clks: - xhci_mtk_clks_disable(mtk); + clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); enable_wakeup: usb_wakeup_set(mtk, true); return ret; diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index 621ec1a85009..11996edc1967 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -9,8 +9,12 @@ #ifndef _XHCI_MTK_H_ #define _XHCI_MTK_H_ +#include + #include "xhci.h" +#define BULK_CLKS_NUM 5 + /** * To simplify scheduler algorithm, set a upper limit for ESIT, * if a synchromous ep's ESIT is larger than @XHCI_MTK_MAX_ESIT, @@ -140,11 +144,7 @@ struct xhci_hcd_mtk { int u3p_dis_msk; struct regulator *vusb33; struct regulator *vbus; - struct clk *sys_clk; /* sys and mac clock */ - struct clk *xhci_clk; - struct clk *ref_clk; - struct clk *mcu_clk; - struct clk *dma_clk; + struct clk_bulk_data clks[BULK_CLKS_NUM]; struct regmap *pericfg; struct phy **phys; int num_phys; From patchwork Sat Apr 10 05:10:06 2021 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: 12195387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7A7DC433B4 for ; Sat, 10 Apr 2021 05:22:40 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A7CD6102A for ; Sat, 10 Apr 2021 05:22:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A7CD6102A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CvUPQLuNksuoX+MxiMh+0L94ek3zIYU8Mbr8Ghic9DE=; b=ojr73hLisCdVcE2E5R/lqwzqj A0YHHejd5UKbmjS1+f6WqgXSTxlkI3tMP6Le504dfhraGf+Gr3dHYzVMyynL75gz+A4p3G1RbnAGI 5oFslSmGAanVQ3V7lW9kcjtqp2QTAoV2ijbvxga+Hx+vcUbRpi7dLWsgCDXLnEibS1aStPM0aAVZf OEhagUvVDSKqyudSb6cepBKqvG677/NsWq42b/JizO9/J7slLg7rrWDLcK4NOMEz12HSDmmvVGhZb PfBl+gY9rsMAAWa6oXfPvtGY2LTqke+sG6P9L+/2H1ARoSftBtyJs7oTJe8tUJvPtj9jIrxvJHweN bgkV8avog==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lV62q-002Di6-I9; Sat, 10 Apr 2021 05:20:32 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV62n-002Dhv-6E; Sat, 10 Apr 2021 05:20:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=TdnV7ploCt97Wq8AY62rYREnf3mFASpW9KBwsMtCtMI=; b=yzN2CxL8TfcdlOK6Xf1K5604oF S5uG8vQuH1CTGJ1eEXpYUr4hrjV2tYnPIGf50yOiSegjo2gDMbddSwdMLkNO5/OtCwOIIGbbPMS/g FWxFxsN8s/pKb25ol7btda6Lm11e+AYS4WCcJ6ru0hUui6CVim5AgJPHZmMwkugkRqWdBHHpJwnVf 3gPGZCVVA3VO74x1vAOnhcU1y68Gs91GLyETVNEqyTEZLQo+HvxKPGFCB/mStaneW7k4XMXVKsT8E lTBab/tAfpvXo+WiFVxS8gzYjYDuqGjsgDOGQxqyVHxEs2z6NvlJOj9WrZJ42qjR93HSToVRYq/r2 4aWWbnsg==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lV62k-004wQF-7g; Sat, 10 Apr 2021 05:20:27 +0000 X-UUID: b63bebe15f97460d9aa3154ecadebfed-20210409 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=TdnV7ploCt97Wq8AY62rYREnf3mFASpW9KBwsMtCtMI=; b=LQ7WBY7JlQabFhrX8TGWOWkwX0z8VX0CI2IJBsxDmtQofv+36/mC8Ea5RqXYXp2NaOF3IDmSL+AYNMu+k9Sb5SGw1Co5Ef0nFD2fhIz0ePp6g+8tLEpMYtSMVh2K+qJo2pE+uhBi8c02hwQ5bTGk4fKlcTQCgm4AAg2f2Q6koDs=; X-UUID: b63bebe15f97460d9aa3154ecadebfed-20210409 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 48433483; Fri, 09 Apr 2021 22:20:24 -0700 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Apr 2021 22:10:22 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 13:10:21 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 13:10:20 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Mathias Nyman CC: Chunfeng Yun , Rob Herring , Matthias Brugger , "Rafael J. Wysocki" , Len Brown , Pavel Machek , , , , , , , Tony Lindgren , Tianping Fang , Eddie Hung , "Ikjoon Jang" , Nicolas Boichat Subject: [PATCH v2 5/5] usb: xhci-mtk: remove unused members Date: Sat, 10 Apr 2021 13:10:06 +0800 Message-ID: <1618031406-15347-5-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1618031406-15347-1-git-send-email-chunfeng.yun@mediatek.com> References: <1618031406-15347-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-20210409_222026_303324_0E1F510C X-CRM114-Status: GOOD ( 10.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now some members about phys and wakeup are not used anymore, remove them. Signed-off-by: Chunfeng Yun --- v2: no changes --- drivers/usb/host/xhci-mtk.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index 11996edc1967..7940593a3445 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -145,9 +145,6 @@ struct xhci_hcd_mtk { struct regulator *vusb33; struct regulator *vbus; struct clk_bulk_data clks[BULK_CLKS_NUM]; - struct regmap *pericfg; - struct phy **phys; - int num_phys; bool lpm_support; /* usb remote wakeup */ bool uwk_en;