* [PATCH v3 0/3] dra7xx: Add PM support to PCIe
@ 2015-07-27 6:24 Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure Kishon Vijay Abraham I
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-27 6:24 UTC (permalink / raw)
To: bhelgaas, linux-omap, linux-pci, linux-kernel; +Cc: nsekhar, kishon
This series adds PM support to pci-dra7xx so that PCI clocks can be disabled
during suspend and enabled back during resume without affecting
PCI functionality.
Changes from v2:
*) Used SET_SYSTEM_SLEEP_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS for
populating PM ops.
Changes from v1:
*) Moved resetting and setting of MSE bit to pci-dra7xx.
The comment to reset and set ISE is not done now since I don't have a card
with IO space. Once I get to test that, I'll post a separate patch for
handling that.
Kishon Vijay Abraham I (3):
PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure
PCI: host: pci-dra7xx: add pm support to pci dra7xx
PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
drivers/pci/host/pci-dra7xx.c | 95 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure
2015-07-27 6:24 [PATCH v3 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
@ 2015-07-27 6:24 ` Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 2/3] PCI: host: pci-dra7xx: add pm support to pci dra7xx Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 3/3] PCI: host: pci-dra7xx: Idle the module by disabling MSE bit Kishon Vijay Abraham I
2 siblings, 0 replies; 4+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-27 6:24 UTC (permalink / raw)
To: bhelgaas, linux-omap, linux-pci, linux-kernel; +Cc: nsekhar, kishon
Fix the error handling code in case pm_runtime_get_sync fails. Now
when pm_runtime_get_sync fails pm_runtime_disable is invoked so that
there is no unbalanced pm_runtime_enable calls.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/host/pci-dra7xx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 80db09e..d8b6d66 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -384,7 +384,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
ret = pm_runtime_get_sync(dev);
if (IS_ERR_VALUE(ret)) {
dev_err(dev, "pm_runtime_get_sync failed\n");
- goto err_phy;
+ goto err_get_sync;
}
reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_DEVICE_CMD);
@@ -401,6 +401,8 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
err_add_port:
pm_runtime_put(dev);
+
+err_get_sync:
pm_runtime_disable(dev);
err_phy:
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/3] PCI: host: pci-dra7xx: add pm support to pci dra7xx
2015-07-27 6:24 [PATCH v3 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure Kishon Vijay Abraham I
@ 2015-07-27 6:24 ` Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 3/3] PCI: host: pci-dra7xx: Idle the module by disabling MSE bit Kishon Vijay Abraham I
2 siblings, 0 replies; 4+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-27 6:24 UTC (permalink / raw)
To: bhelgaas, linux-omap, linux-pci, linux-kernel; +Cc: nsekhar, kishon
Add PM support to pci-dra7xx so that PCI clocks can be disabled
during suspend and enabled back during resume without affecting
PCI functionality.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/host/pci-dra7xx.c | 72 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index d8b6d66..7599201 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -433,6 +433,77 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int dra7xx_pcie_suspend(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ struct pcie_port *pp = &dra7xx->pp;
+
+ dw_pcie_suspend_rc(pp);
+
+ return 0;
+}
+
+static int dra7xx_pcie_resume(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ struct pcie_port *pp = &dra7xx->pp;
+
+ dw_pcie_resume_rc(pp);
+
+ return 0;
+}
+
+static int dra7xx_pcie_suspend_noirq(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ int count = dra7xx->phy_count;
+
+ while (count--) {
+ phy_power_off(dra7xx->phy[count]);
+ phy_exit(dra7xx->phy[count]);
+ }
+
+ return 0;
+}
+
+static int dra7xx_pcie_resume_noirq(struct device *dev)
+{
+ struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
+ int phy_count = dra7xx->phy_count;
+ int ret;
+ int i;
+
+ for (i = 0; i < phy_count; i++) {
+ ret = phy_init(dra7xx->phy[i]);
+ if (ret < 0)
+ goto err_phy;
+
+ ret = phy_power_on(dra7xx->phy[i]);
+ if (ret < 0) {
+ phy_exit(dra7xx->phy[i]);
+ goto err_phy;
+ }
+ }
+
+ return 0;
+
+err_phy:
+ while (--i >= 0) {
+ phy_power_off(dra7xx->phy[i]);
+ phy_exit(dra7xx->phy[i]);
+ }
+
+ return ret;
+}
+#endif
+
+static const struct dev_pm_ops dra7xx_pcie_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend, dra7xx_pcie_resume)
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dra7xx_pcie_suspend_noirq,
+ dra7xx_pcie_resume_noirq)
+};
+
static const struct of_device_id of_dra7xx_pcie_match[] = {
{ .compatible = "ti,dra7-pcie", },
{},
@@ -444,6 +515,7 @@ static struct platform_driver dra7xx_pcie_driver = {
.driver = {
.name = "dra7-pcie",
.of_match_table = of_dra7xx_pcie_match,
+ .pm = &dra7xx_pcie_pm_ops,
},
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
2015-07-27 6:24 [PATCH v3 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 2/3] PCI: host: pci-dra7xx: add pm support to pci dra7xx Kishon Vijay Abraham I
@ 2015-07-27 6:24 ` Kishon Vijay Abraham I
2 siblings, 0 replies; 4+ messages in thread
From: Kishon Vijay Abraham I @ 2015-07-27 6:24 UTC (permalink / raw)
To: bhelgaas, linux-omap, linux-pci, linux-kernel; +Cc: nsekhar, kishon
DRA7xx require MSE bit to be cleared to set the master in
standby mode. (In DRA7xx TRM_vE, section 24.9.4.5.2.2.1 PCIe
Controller Master Standby Behavior advises to use the clearing
of the local MSE bit to set the master in standby. Without this
some of the clocks do not idle).
Cleared the MSE bit on suspend and enabled it back on resume.
Clearing MSE bit is required to get clocks to be idled after
suspend.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
drivers/pci/host/pci-dra7xx.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c
index 7599201..7acc833 100644
--- a/drivers/pci/host/pci-dra7xx.c
+++ b/drivers/pci/host/pci-dra7xx.c
@@ -83,6 +83,17 @@ static inline void dra7xx_pcie_writel(struct dra7xx_pcie *pcie, u32 offset,
writel(value, pcie->base + offset);
}
+static inline u32 dra7xx_pcie_readl_rc(struct pcie_port *pp, u32 offset)
+{
+ return readl(pp->dbi_base + offset);
+}
+
+static inline void dra7xx_pcie_writel_rc(struct pcie_port *pp, u32 offset,
+ u32 value)
+{
+ writel(value, pp->dbi_base + offset);
+}
+
static int dra7xx_pcie_link_up(struct pcie_port *pp)
{
struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pp);
@@ -438,8 +449,12 @@ static int dra7xx_pcie_suspend(struct device *dev)
{
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
struct pcie_port *pp = &dra7xx->pp;
+ u32 val;
- dw_pcie_suspend_rc(pp);
+ /* clear MSE */
+ val = dra7xx_pcie_readl_rc(pp, PCI_COMMAND);
+ val &= ~PCI_COMMAND_MEMORY;
+ dra7xx_pcie_writel_rc(pp, PCI_COMMAND, val);
return 0;
}
@@ -448,8 +463,12 @@ static int dra7xx_pcie_resume(struct device *dev)
{
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
struct pcie_port *pp = &dra7xx->pp;
+ u32 val;
- dw_pcie_resume_rc(pp);
+ /* clear MSE */
+ val = dra7xx_pcie_readl_rc(pp, PCI_COMMAND);
+ val |= PCI_COMMAND_MEMORY;
+ dra7xx_pcie_writel_rc(pp, PCI_COMMAND, val);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-27 6:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-27 6:24 [PATCH v3 0/3] dra7xx: Add PM support to PCIe Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 1/3] PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 2/3] PCI: host: pci-dra7xx: add pm support to pci dra7xx Kishon Vijay Abraham I
2015-07-27 6:24 ` [PATCH v3 3/3] PCI: host: pci-dra7xx: Idle the module by disabling MSE bit Kishon Vijay Abraham I
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).