From: Phil Edworthy <phil.edworthy@renesas.com>
To: Simon Horman <horms@verge.net.au>, Bjorn Helgaas <bhelgaas@google.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
Geert Uytterhoeven <geert@linux-m68k.org>,
<linux-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>,
<linux-sh@vger.kernel.org>,
Phil Edworthy <phil.edworthy@renesas.com>
Subject: [PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar
Date: Tue, 5 Jan 2016 13:00:30 +0000 [thread overview]
Message-ID: <1451998831-27705-4-git-send-email-phil.edworthy@renesas.com> (raw)
In-Reply-To: <1451998831-27705-1-git-send-email-phil.edworthy@renesas.com>
If runtime PM is enabled in the kernel config, simply enable the
clocks once during probe.
Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
v2:
- No changes.
---
drivers/pci/host/pcie-rcar.c | 44 ++++++++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 31ad93a..7e13fbb 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -27,6 +27,7 @@
#include <linux/of_platform.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/slab.h>
#define DRV_NAME "rcar-pcie"
@@ -1025,32 +1026,51 @@ static int rcar_pcie_probe(struct platform_device *pdev)
if (err)
return err;
- if (IS_ENABLED(CONFIG_PCI_MSI)) {
- err = rcar_pcie_enable_msi(pcie);
- if (err < 0) {
- dev_err(&pdev->dev,
- "failed to enable MSI support: %d\n",
- err);
- return err;
- }
- }
-
of_id = of_match_device(rcar_pcie_of_match, pcie->dev);
if (!of_id || !of_id->data)
return -EINVAL;
hw_init_fn = of_id->data;
+ pm_runtime_enable(pcie->dev);
+ err = pm_runtime_get_sync(pcie->dev);
+ if (err < 0) {
+ dev_err(pcie->dev, "pm_runtime_get_sync failed\n");
+ goto err_pm_disable;
+ }
+
/* Failure to get a link might just be that no cards are inserted */
err = hw_init_fn(pcie);
if (err) {
dev_info(&pdev->dev, "PCIe link down\n");
- return 0;
+ err = 0;
+ goto err_pm_put;
}
data = rcar_pci_read_reg(pcie, MACSR);
dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f);
- return rcar_pcie_enable(pcie);
+ if (IS_ENABLED(CONFIG_PCI_MSI)) {
+ err = rcar_pcie_enable_msi(pcie);
+ if (err < 0) {
+ dev_err(&pdev->dev,
+ "failed to enable MSI support: %d\n",
+ err);
+ goto err_pm_put;
+ }
+ }
+
+ err = rcar_pcie_enable(pcie);
+ if (err)
+ goto err_pm_put;
+
+ return 0;
+
+err_pm_put:
+ pm_runtime_put(pcie->dev);
+
+err_pm_disable:
+ pm_runtime_disable(pcie->dev);
+ return err;
}
static struct platform_driver rcar_pcie_driver = {
--
2.5.0
next prev parent reply other threads:[~2016-01-05 13:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 13:00 [PATCH v2 0/4] Various R-Car PCIe patches Phil Edworthy
2016-01-05 13:00 ` [PATCH v2 1/4] PCI: rcar: remove unused pci_sys_data structure in pcie-rcar Phil Edworthy
2016-01-08 1:50 ` Simon Horman
2016-01-08 21:06 ` Bjorn Helgaas
2016-01-11 11:23 ` Phil Edworthy
2016-01-05 13:00 ` [PATCH v2 2/4] PCI: rcar: Support runtime PM link state L1 handling " Phil Edworthy
2016-01-06 8:35 ` Wolfram Sang
2016-01-08 21:31 ` Bjorn Helgaas
2016-01-11 11:42 ` Phil Edworthy
2016-01-13 16:58 ` Phil Edworthy
2016-01-05 13:00 ` Phil Edworthy [this message]
2016-01-06 8:35 ` [PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar Wolfram Sang
2016-01-06 8:45 ` Geert Uytterhoeven
2016-01-06 8:50 ` Wolfram Sang
2016-01-05 13:00 ` [PATCH v2 4/4] PCI: rcar: Add Gen2 PHY setup " Phil Edworthy
2016-01-06 8:39 ` Wolfram Sang
2016-01-11 14:48 ` [PATCH v2 0/4] Various R-Car PCIe patches Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1451998831-27705-4-git-send-email-phil.edworthy@renesas.com \
--to=phil.edworthy@renesas.com \
--cc=bhelgaas@google.com \
--cc=geert@linux-m68k.org \
--cc=horms@verge.net.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®