dra7xx: Add PM support to PCIe
v5 cover dra7xx: Add PM support to PCIe
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 v4:
*) Fixed a bug caused by sending incomplete patch.
Changes from v3:
*) Fix compilation errors when individual patches are applied
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(-)
Signature · 1 line
1.7.9.5
PATCH v5 1/3 PCI: host: pci-dra7xx: Disable pm_runtime on get_sync failure
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.
--- drivers/pci/host/pci-dra7xx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/host/pci-dra7xx.c +3 -1
@@ -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:
Signature · 1 line
1.7.9.5
PATCH v5 2/3 PCI: host: pci-dra7xx: add pm support to pci dra7xx
In reply to Kishon Vijay Abraham IAdd PM support to pci-dra7xx so that PCI clocks can be disabled during suspend and enabled back during resume without affecting PCI functionality.
--- drivers/pci/host/pci-dra7xx.c | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/pci/host/pci-dra7xx.c +51 -0
@@ -433,6 +433,56 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_PM_SLEEP +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_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 +494,7 @@ static struct platform_driver dra7xx_pcie_driver = { .driver = { .name = "dra7-pcie", .of_match_table = of_dra7xx_pcie_match, + .pm = &dra7xx_pcie_pm_ops, }, };
Signature · 1 line
1.7.9.5
PATCH v5 3/3 PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
In reply to Kishon Vijay Abraham IDRA7xx 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.
--- drivers/pci/host/pci-dra7xx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/pci/host/pci-dra7xx.c +40 -0
@@ -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);
@@ -434,6 +445,34 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev) }#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; +u32 val; + +/* clear MSE */ + val =dra7xx_pcie_readl_rc (pp,PCI_COMMAND ); + val &= ~PCI_COMMAND_MEMORY ; +dra7xx_pcie_writel_rc (pp,PCI_COMMAND , val); + +return 0 ; +} + +static int dra7xx_pcie_resume (struct device *dev) +{ +struct dra7xx_pcie *dra7xx =dev_get_drvdata (dev); +struct pcie_port *pp = &dra7xx->pp; +u32 val; + +/* set MSE */ + val =dra7xx_pcie_readl_rc (pp,PCI_COMMAND ); + val |=PCI_COMMAND_MEMORY ; +dra7xx_pcie_writel_rc (pp,PCI_COMMAND , val); + +return 0 ; +} +static int dra7xx_pcie_suspend_noirq (struct device *dev) {struct dra7xx_pcie *dra7xx =dev_get_drvdata (dev);
@@ -479,6 +518,7 @@ err_phy:#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) };
Signature · 1 line
1.7.9.5
Quoted 18 lines · Kishon Vijay Abraham I
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 v4:
*) Fixed a bug caused by sending incomplete patch.Changes from v3:
*) Fix compilation errors when individual patches are appliedChanges from v2:
*) UsedSET_SYSTEM_SLEEP_PM_OPSandSET_NOIRQ_SYSTEM_SLEEP_PM_OPSfor
populating PM ops.Changes from v1:
*) Moved resetting and setting of MSE bit to pci-dra7xx.
Quoted 8 lines
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: Disablepm_runtimeonget_syncfailure
PCI: host: pci-dra7xx: add pm support to pci dra7xx
PCI: host: pci-dra7xx: Idle the module by disabling MSE bit
Hi Kishon,
Looks good! :-)
Best regards,
Jingoo Han
Quoted 6 lines
drivers/pci/host/pci-dra7xx.c | 95 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-)--
1.7.9.5
Bjorn Helgaas
maintainer Reviewed-by Jingoo Han Reviewed-by Jingoo Han Reviewed-by Jingoo Han on the v5 seriesQuoted 21 lines · Kishon Vijay Abraham I
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 v4:
*) Fixed a bug caused by sending incomplete patch.Changes from v3:
*) Fix compilation errors when individual patches are appliedChanges from v2:
*) UsedSET_SYSTEM_SLEEP_PM_OPSandSET_NOIRQ_SYSTEM_SLEEP_PM_OPSfor
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.
Quoted 7 lines
Kishon Vijay Abraham I (3):
PCI: host: pci-dra7xx: Disablepm_runtimeonget_syncfailure
PCI: host: pci-dra7xx: add pm support to pci dra7xx
PCI: host: pci-dra7xx: Idle the module by disabling MSE bitdrivers/pci/host/pci-dra7xx.c | 95 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-)
Applied with Jingoo's Reviewed-by to pci/host-dra7xx for v4.3, thanks!
I tweaked the changelogs as follows:
commit 0e2bdb0e7abf4b5170874e415ec42df547916dd3
Author: Kishon Vijay Abraham I <[email protected]> Date: Fri Jul 31 17:55:10 2015 +0530
PCI: dra7xx: Disable pm_runtime on get_sync failure
Fix the error handling when pm_runtime_get_sync() fails.
If pm_runtime_get_sync() fails, call pm_runtime_disable() so there are no unbalanced pm_runtime_enable() calls.
commit e52eb445ea1d97bf7fb92d2297e487a305392136
Author: Kishon Vijay Abraham I <[email protected]> Date: Fri Jul 31 17:55:11 2015 +0530
PCI: dra7xx: Add PM support
Add PM support to pci-dra7xx so PCI clocks can be disabled during suspend and enabled during resume without affecting PCI functionality.
commit 389c7094ec241ee8ebe358ba10fe392018692c8c
Author: Kishon Vijay Abraham I <[email protected]> Date: Fri Jul 31 17:55:12 2015 +0530
PCI: dra7xx: Clear MSE bit during suspend so clocks will idle
DRA7xx requires the 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).
Clear the MSE bit on suspend and enable it on resume. Clearing MSE bit is required to get clocks to be idled after suspend.
Quoted 74 lines · Bjorn Helgaas
Quoted 21 lines · Kishon Vijay Abraham I
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 v4:
*) Fixed a bug caused by sending incomplete patch.Changes from v3:
*) Fix compilation errors when individual patches are appliedChanges from v2:
*) UsedSET_SYSTEM_SLEEP_PM_OPSandSET_NOIRQ_SYSTEM_SLEEP_PM_OPSfor
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.
Quoted 7 lines
Kishon Vijay Abraham I (3):
PCI: host: pci-dra7xx: Disablepm_runtimeonget_syncfailure
PCI: host: pci-dra7xx: add pm support to pci dra7xx
PCI: host: pci-dra7xx: Idle the module by disabling MSE bitdrivers/pci/host/pci-dra7xx.c | 95 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-)Applied with Jingoo's Reviewed-by to pci/host-dra7xx for v4.3, thanks!
I tweaked the changelogs as follows:
commit
0e2bdb0e7abf4b5170874e415ec42df547916dd3Author: Kishon Vijay Abraham I <[email protected]> Date: Fri Jul 31 17:55:10 2015 +0530PCI: dra7xx: Disable
pm_runtimeonget_syncfailureFix the error handling when
pm_runtime_get_sync()fails.If
pm_runtime_get_sync()fails, callpm_runtime_disable()so there are no unbalancedpm_runtime_enable()calls.Signed-off-by Kishon Vijay Abraham I <[email protected]>Signed-off-by Bjorn Helgaas <[email protected]>Reviewed-by Jingoo Han <[email protected]>commit
e52eb445ea1d97bf7fb92d2297e487a305392136Author: Kishon Vijay Abraham I <[email protected]> Date: Fri Jul 31 17:55:11 2015 +0530PCI: dra7xx: Add PM support
Add PM support to pci-dra7xx so PCI clocks can be disabled during suspend and enabled during resume without affecting PCI functionality.
Signed-off-by Kishon Vijay Abraham I <[email protected]>Signed-off-by Bjorn Helgaas <[email protected]>Reviewed-by Jingoo Han <[email protected]>commit
389c7094ec241ee8ebe358ba10fe392018692c8cAuthor: Kishon Vijay Abraham I <[email protected]> Date: Fri Jul 31 17:55:12 2015 +0530PCI: dra7xx: Clear MSE bit during suspend so clocks will idle
DRA7xx requires the 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).
Quoted 7 lines
Clear the MSE bit on suspend and enable it on resume. Clearing MSE bit is required to get clocks to be idled after suspend.
Signed-off-by Kishon Vijay Abraham I <[email protected]>Signed-off-by Sekhar Nori <[email protected]>Signed-off-by Bjorn Helgaas <[email protected]>Reviewed-by Jingoo Han <[email protected]>
Thanks Bjorn!
-Kishon