From patchwork Thu Oct 12 20:52:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10002917 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 8B8BF6028A for ; Thu, 12 Oct 2017 21:06:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D8D628EAD for ; Thu, 12 Oct 2017 21:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7257A28ED2; Thu, 12 Oct 2017 21:06:54 +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 E4C8228EAD for ; Thu, 12 Oct 2017 21:06:53 +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=8T3CoP5Cas6ocECOdSWOo53x66RV/3zs1o+f9YwzncM=; b=T83ltsXIUtHNHLBQGmniHiBv4n qB/gqY82Y1ksaynEiSMzk5G5kP4BjdrC+N8dxjIwUZJroqyQUKmYBA06KlVz3aLecQNapjD3Uay1m jrbVPDDaqA1L2klt0wFv3KTDctNHoqA/Cwg5ZoAUuy/3J4SpwgFpNOqYA5+3CNfeYGYONyfzKZXT5 RPO7P+5t8MJ4KLiMOWQn+O5G0Wrk2nrUeQZP3iws+Rgf0RDR567N+FebI8kyE32ZzjND5F8qG4jW3 TI48phxxeTkOgh0mq4G9xVxmwezLVZ1NM6DejUOVOxKzWLQHKj4F21Waxc/lMZSTOG6fylqh3UCWr V5ct2SQA==; 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 1e2kgv-0005lU-6B; Thu, 12 Oct 2017 21:06:53 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2kTO-0007Qu-07 for linux-rockchip@lists.infradead.org; Thu, 12 Oct 2017 20:52:57 +0000 Received: by mail-pf0-x22f.google.com with SMTP id x7so6609035pfa.1 for ; Thu, 12 Oct 2017 13:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dnH5A9agN+AqHbnjhAY8RChCdBxo0Fr8J2aLGGv5zBU=; b=W92V2BnouHD7lgjA6ZVAfwMuhe9hyWL95tsd5GyJV3/wom2tXc+yZf03S46jbz7GeW MnG1iJhuHbMDh+CUl7OYVyoZcBhaUpkdfdXO5t57wN9LGDfS/UJBqzH+wkxQZWcVG5h2 IEONh+BBqXZNBXss8d6Sie2zuw+kxyDQim1P4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dnH5A9agN+AqHbnjhAY8RChCdBxo0Fr8J2aLGGv5zBU=; b=ktUxacYjUsj8D0qU7dc3h8TTb8MyjiAk9eZ9XMP9MZl3rTMej1G+Clg1GetXEO3meX dVA/ZWpOOlPSunJUN2PTTX8e47bfG2XL6RU10EWnKXyGyz0QQQSl8iijaT5i8tgOcXEI B2NvMeevr94aQk2Fct0UrV0j3JLNolzhgjJ3Ja6Eg4RJXy9BfwKrfum4sg4XKM91y9qK zHlG6Mro1fmMf2z2dLMHzIjVOY09lCSIr6yuDEqNMqlBZu2qPkftZ3nz63wXOCcCvOg6 zP3J82LtWTzxjjEfe2D6DEoAyvDMkB8JKLpmdc5DQUGkF1FDzCSf8c3Yg0jNN5HJ4WYT IDcw== X-Gm-Message-State: AMCzsaWJLLIznTVz0PFFES05sH5UCCSzOqMlbv3BbtYOL93nWukhAHzj ELdh1VJP9KEKqV7AJML2x0Z4RQ== X-Google-Smtp-Source: AOwi7QBlyTauwjzQ/g322s6jzdis7/MH92T885b/e1mC3PKBwYJgpircxpWYeiD2vRW/64gNiF3uog== X-Received: by 10.84.129.65 with SMTP id 59mr1181421plb.442.1507841553498; Thu, 12 Oct 2017 13:52:33 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.113.17]) by smtp.gmail.com with ESMTPSA id h1sm25048704pgp.37.2017.10.12.13.52.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 13:52:33 -0700 (PDT) From: Brian Norris To: Bjorn Helgaas Subject: [PATCH 2/3] of/pci: Add of_pci_get_pcie_reset_suspend() to parse pcie-reset-suspend Date: Thu, 12 Oct 2017 13:52:19 -0700 Message-Id: <20171012205220.130048-3-briannorris@chromium.org> X-Mailer: git-send-email 2.15.0.rc0.271.g36b669edcc-goog In-Reply-To: <20171012205220.130048-1-briannorris@chromium.org> References: <20171012205220.130048-1-briannorris@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171012_135254_065223_596374C8 X-CRM114-Status: GOOD ( 11.49 ) 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: Mark Rutland , devicetree@vger.kernel.org, Heiko Stuebner , linux-pci@vger.kernel.org, Shawn Lin , Brian Norris , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Rob Herring , Rajat Jain , Frank Rowand , 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 This helper can be used by drivers to determine the expected PERST# behavior when in low-power system suspend (e.g., S3). I've found the expected behavior to vary across a few different endpoint implementations. Signed-off-by: Brian Norris --- drivers/of/of_pci.c | 25 +++++++++++++++++++++++++ include/linux/of_pci.h | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index e9ec931f5b9a..ab2586f86094 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -137,6 +137,31 @@ int of_pci_get_max_link_speed(struct device_node *node) } EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed); +/** + * This function returns true if the PCIe controller should assert PCIe Reset + * (PERST#) when entering system suspend (e.g., S3). + * + * @node: device tree node with the reset property + * + * Returns 1 (meaning "assert reset") or 0 ("don't assert reset"), if the DT + * defined a valid behavior. Otherwise, returns a negative error code. + */ +int of_pci_get_pcie_reset_suspend(struct device_node *node) +{ + int ret; + u32 val; + + ret = of_property_read_u32(node, "pcie-reset-suspend", &val); + if (ret) + return ret; + + if (val > 1) + return -EINVAL; + + return val; +} +EXPORT_SYMBOL_GPL(of_pci_get_pcie_reset_suspend); + /** * of_pci_check_probe_only - Setup probe only mode if linux,pci-probe-only * is present and valid diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 518c8d20647a..df453893080b 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -17,6 +17,7 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); int of_pci_parse_bus_range(struct device_node *node, struct resource *res); int of_get_pci_domain_nr(struct device_node *node); int of_pci_get_max_link_speed(struct device_node *node); +int of_pci_get_pcie_reset_suspend(struct device_node *node); void of_pci_check_probe_only(void); int of_pci_map_rid(struct device_node *np, u32 rid, const char *map_name, const char *map_mask_name, @@ -69,6 +70,12 @@ of_pci_get_max_link_speed(struct device_node *node) return -EINVAL; } +static inline int +of_pci_get_pcie_reset_suspend(struct device_node *node) +{ + return -EINVAL; +} + static inline void of_pci_check_probe_only(void) { } #endif