[linux-yocto] [PATCH 04/29] dma: dw: Implement suspend/resume callbacks

rebecca.swee.fun.chang at intel.com rebecca.swee.fun.chang at intel.com
Mon Apr 7 08:17:55 PDT 2014


From: "Chew, Chiau Ee" <chiau.ee.chew at intel.com>

This will add PCI mode suspend and resume callbacks
to support system suspend to and resume from S3.

Signed-off-by: Chew, Chiau Ee <chiau.ee.chew at intel.com>
Signed-off-by: Maurice Petallo <mauricex.r.petallo at intel.com>
---
 drivers/dma/dw/pci.c |   36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
index e89fc24..a47cac0 100644
--- a/drivers/dma/dw/pci.c
+++ b/drivers/dma/dw/pci.c
@@ -75,6 +75,39 @@ static void dw_pci_remove(struct pci_dev *pdev)
 		dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
 }
 
+static int dw_dmac_pci_resume(struct device *dev)
+{
+	struct pci_dev *pci = to_pci_dev(dev);
+	struct dw_dma_chip *chip = pci_get_drvdata(pci);
+	int ret;
+
+	pci_set_power_state(pci, PCI_D0);
+	pci_restore_state(pci);
+	ret = pci_enable_device(pci);
+	if (ret)
+		return ret;
+	return dw_dma_resume(chip);
+};
+
+static int dw_dmac_pci_suspend(struct device *dev)
+{
+	struct pci_dev *pci = to_pci_dev(dev);
+	struct dw_dma_chip *chip = pci_get_drvdata(pci);
+	int ret;
+	ret = dw_dma_suspend(chip);
+	if (ret)
+		return ret;
+	pci_save_state(pci);
+	pci_disable_device(pci);
+	pci_set_power_state(pci, PCI_D3hot);
+	return 0;
+};
+
+static const struct dev_pm_ops dw_dma_pm_ops = {
+	.resume_noirq	= dw_dmac_pci_resume,
+	.suspend_noirq	= dw_dmac_pci_suspend,
+};
+
 static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
 	/* Medfield */
 	{ PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata },
@@ -92,6 +125,9 @@ static struct pci_driver dw_pci_driver = {
 	.id_table	= dw_pci_id_table,
 	.probe		= dw_pci_probe,
 	.remove		= dw_pci_remove,
+	.driver		= {
+		.pm	= &dw_dma_pm_ops,
+	},
 };
 
 module_pci_driver(dw_pci_driver);
-- 
1.7.10.4



More information about the linux-yocto mailing list