From patchwork Mon Sep 11 15:10:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 9947511 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 04FE46024A for ; Mon, 11 Sep 2017 15:11:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAD5B28AF1 for ; Mon, 11 Sep 2017 15:11:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF7A228B0C; Mon, 11 Sep 2017 15:11:52 +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 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 9D4A128AF1 for ; Mon, 11 Sep 2017 15:11:52 +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=S7hZiIBeuWpOMfqsyugCZTa21wKcQG0Zfdv1a8zKYHo=; b=Hq9itM0vbBdnwMTfBAjMn01FcN j4OmM2PcZH675Ln/LYux26TAUTt+whoKKdDu4AfjXccUe+N1NlDm9aXI5/bFiJvwNyRasqImxjjpY C2nJPRj3Ub/RRm5/FNQ8/RRUYe61tsc8TKS9tmH0nm6KB7DSZpbM16Pc7SxBLm04TjvPJZoSLD9ik Hz7lG7yzlD0IyGzUmTmCMivBOIjIGd9BWep0OE+RxSOZv0gWcOhMPZgKwr8Wdxsb+N8wZdDSWgLwY W9hF3iljEoUuqHc9wFo8YzI1x8S0ZzrdccecZIiKtGeTzOFadNYDaPyKhszhdxXi8rdByvGA4H7ZK SA491pqA==; 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 1drQNM-00039p-0g; Mon, 11 Sep 2017 15:11:52 +0000 Received: from regular1.263xmail.com ([211.150.99.140]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1drQMg-0002Wq-RU; Mon, 11 Sep 2017 15:11:13 +0000 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.223]) by regular1.263xmail.com (Postfix) with ESMTP id 098D44A3F; Mon, 11 Sep 2017 23:10:45 +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 4853C378; Mon, 11 Sep 2017 23:10:44 +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 22382EHK69J; Mon, 11 Sep 2017 23:10:47 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org, bhelgaas@google.com Subject: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq Date: Mon, 11 Sep 2017 23:10:27 +0800 Message-Id: <20170911151029.25185-2-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170911151029.25185-1-jeffy.chen@rock-chips.com> References: <20170911151029.25185-1-jeffy.chen@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170911_081111_263883_287FB410 X-CRM114-Status: UNSURE ( 8.26 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms 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-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=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 Acked-by: Shawn Lin Reviewed-by: Brian Norris Tested-by: Brian Norris --- Changes in v5: Rebase 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 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c index 9051c6c8fea4..a8b7272597a7 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 @@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) return err; } + /* Must init wakeup before setting dedicated wakeup irq. */ + device_init_wakeup(dev, true); + irq = platform_get_irq_byname(pdev, "wakeup"); + if (irq >= 0) { + err = dev_pm_set_dedicated_wake_irq(dev, irq); + if (err) + dev_err(dev, "failed to setup PCIe wakeup IRQ\n"); + } + return 0; } @@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err = rockchip_pcie_parse_dt(rockchip); if (err) - return err; + goto err_disable_wake; err = rockchip_pcie_enable_clocks(rockchip); if (err) - return err; + goto err_disable_wake; err = rockchip_pcie_set_vpcie(rockchip); if (err) { @@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev) regulator_disable(rockchip->vpcie0v9); err_set_vpcie: rockchip_pcie_disable_clocks(rockchip); +err_disable_wake: + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); return err; } @@ -1682,6 +1695,8 @@ static int rockchip_pcie_remove(struct platform_device *pdev) if (!IS_ERR(rockchip->vpcie0v9)) regulator_disable(rockchip->vpcie0v9); + dev_pm_clear_wake_irq(dev); + device_init_wakeup(dev, false); return 0; }