From patchwork Tue Aug 22 03:19:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 9914137 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 9242360381 for ; Tue, 22 Aug 2017 03:21:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 898A428583 for ; Tue, 22 Aug 2017 03:21:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E2A62882F; Tue, 22 Aug 2017 03:21:49 +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=-0.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, URIBL_BLACK autolearn=no 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 16DB8287DC for ; Tue, 22 Aug 2017 03:21:49 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=jsZiAFLz4RcCV5oKOT5P36d5AdsNS8vWU3XnkQLMF98=; b=LGmL/gZmrFy9WRdgRG6trxRybM FEsD8693Kld/K2B6Ozp6pNwYLMRByjZTaOWppzjlpBITaCqKb0wOQ3AeKxs1/5x0jXd/khuJxyZcF ihZ6A4PlgzlMYyfameUfirnoBPxjjw3Nih303Z9Ty/ANzaO+eD2NPL17u0ldlnUNvQd45Rl0jZW93 iHm7+cmAu951kINWktggTzAhSW/FRkZZPqpTDPu93YnqmcczhEfTpjn5AqDNzFc+tGWYn/xI/7gLX 8s7ba81qRGxv0cm2zjDNVL3ok4G1Z24RC+yf1Hlr3pHucCatOVYDYOtXKM2Be5/5qv17Zi/0h3fVj f6IuM81Q==; 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 1djzlC-0001w4-Jh; Tue, 22 Aug 2017 03:21:46 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1djzkd-0001fi-3A; Tue, 22 Aug 2017 03:21:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2LbrUQtLBYm6GPfWYjNz7PyJC2LP5NVWaF7yTL6nI48=; b=KkpItY51wo+fTtUOGdAcXFjb6 q1L+UavFH9wlkuDNXYoQPHjxmuj06YKL5deAGy1DXMACIfhT0kTEpKlUg956z0qe/Nl2aiYYu2+nC sXaB49hYAeWf9m1UjqY7xvVlr31akSbnHXX8Td60ZM1gETpo6C5Wt5PIlWrrKmQ2sVgp2I7IzV3TD 8f2BUzg0g341PELJ1XslRAhy7lbTNCUSBoF+UdtHRjCDf/xVUbcwKEcDFMiLKYty/+iUO//xiRwR4 FnhFSApDWM5DD/kg/U5Z7Co5GHZUXyFvH8dXOZeoI3xPNhWaX1N6iyP3bjz3t3LEFIYgTrml8yncK LAWO76Y/Q==; Received: from regular1.263xmail.com ([211.150.99.138]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1djzkX-0006Q4-IL; Tue, 22 Aug 2017 03:21:09 +0000 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.164]) by regular1.263xmail.com (Postfix) with ESMTP id 4461A7A58; Tue, 22 Aug 2017 11:20:11 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id E750E384; Tue, 22 Aug 2017 11:20:07 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 12756P6OFN9; Tue, 22 Aug 2017 11:20:11 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org, bhelgaas@google.com Subject: [PATCH v4 2/4] PCI: rockchip: Add support for pcie wake irq Date: Tue, 22 Aug 2017 11:19:32 +0800 Message-Id: <20170822031934.8675-3-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170822031934.8675-1-jeffy.chen@rock-chips.com> References: <20170822031934.8675-1-jeffy.chen@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170822_042106_455926_CF2A778D X-CRM114-Status: GOOD ( 11.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeffy Chen , Heiko Stuebner , linux-pci@vger.kernel.org, shawn.lin@rock-chips.com, briannorris@chromium.org, dianders@chromium.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for PCIE_WAKE pin in rockchip pcie driver. Signed-off-by: Jeffy Chen --- Changes in v4: None Changes in v3: Fix error handling Changes in v2: Use dev_pm_set_dedicated_wake_irq -- Suggested by Brian Norris drivers/pci/host/pcie-rockchip.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c index 5d85ec2e2fb0..a0f7267984da 100644 --- a/drivers/pci/host/pcie-rockchip.c +++ b/drivers/pci/host/pcie-rockchip.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -1111,6 +1112,15 @@ static int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) return err; } + /* Must init wakeup before setting dedicated wake irq. */ + device_init_wakeup(dev, true); + irq = platform_get_irq_byname(pdev, "wake"); + if (irq >= 0) { + err = dev_pm_set_dedicated_wake_irq(dev, irq); + if (err) + dev_err(dev, "failed to setup PCIe wake IRQ\n"); + } + rockchip->vpcie12v = devm_regulator_get_optional(dev, "vpcie12v"); if (IS_ERR(rockchip->vpcie12v)) { if (PTR_ERR(rockchip->vpcie12v) == -EPROBE_DEFER) @@ -1493,12 +1503,13 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err = rockchip_pcie_parse_dt(rockchip); if (err) - return err; + /* It's safe to disable wake even not enabled */ + goto err_disable_wake; err = clk_prepare_enable(rockchip->aclk_pcie); if (err) { dev_err(dev, "unable to enable aclk_pcie clock\n"); - return err; + goto err_disable_wake; } err = clk_prepare_enable(rockchip->aclk_perf_pcie); @@ -1633,6 +1644,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev) clk_disable_unprepare(rockchip->aclk_perf_pcie); err_disable_aclk_pcie: clk_disable_unprepare(rockchip->aclk_pcie); +err_disable_wake: + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); return err; } @@ -1662,6 +1676,9 @@ static int rockchip_pcie_remove(struct platform_device *pdev) if (!IS_ERR(rockchip->vpcie12v)) regulator_disable(rockchip->vpcie12v); + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); + return 0; }