ALSA: platform: Check CONFIG_PM_SLEEP instead of CONFIG_PM
[linux-3.10.git] / sound / atmel / abdac.c
index 30468b3..98554f4 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/types.h>
 #include <linux/io.h>
 
 #include <sound/core.h>
@@ -133,7 +134,7 @@ static int atmel_abdac_prepare_dma(struct atmel_abdac *dac,
        period_len = frames_to_bytes(runtime, runtime->period_size);
 
        cdesc = dw_dma_cyclic_prep(chan, runtime->dma_addr, buffer_len,
-                       period_len, DMA_TO_DEVICE);
+                       period_len, DMA_MEM_TO_DEV);
        if (IS_ERR(cdesc)) {
                dev_dbg(&dac->pdev->dev, "could not prepare cyclic DMA\n");
                return PTR_ERR(cdesc);
@@ -467,15 +468,24 @@ static int __devinit atmel_abdac_probe(struct platform_device *pdev)
        snd_card_set_dev(card, &pdev->dev);
 
        if (pdata->dws.dma_dev) {
-               struct dw_dma_slave *dws = &pdata->dws;
                dma_cap_mask_t mask;
 
-               dws->tx_reg = regs->start + DAC_DATA;
-
                dma_cap_zero(mask);
                dma_cap_set(DMA_SLAVE, mask);
 
-               dac->dma.chan = dma_request_channel(mask, filter, dws);
+               dac->dma.chan = dma_request_channel(mask, filter, &pdata->dws);
+               if (dac->dma.chan) {
+                       struct dma_slave_config dma_conf = {
+                               .dst_addr = regs->start + DAC_DATA,
+                               .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+                               .src_maxburst = 1,
+                               .dst_maxburst = 1,
+                               .direction = DMA_MEM_TO_DEV,
+                               .device_fc = false,
+                       };
+
+                       dmaengine_slave_config(dac->dma.chan, &dma_conf);
+               }
        }
        if (!pdata->dws.dma_dev || !dac->dma.chan) {
                dev_dbg(&pdev->dev, "DMA not available\n");
@@ -524,10 +534,10 @@ out_put_pclk:
        return retval;
 }
 
-#ifdef CONFIG_PM
-static int atmel_abdac_suspend(struct platform_device *pdev, pm_message_t msg)
+#ifdef CONFIG_PM_SLEEP
+static int atmel_abdac_suspend(struct device *pdev)
 {
-       struct snd_card *card = platform_get_drvdata(pdev);
+       struct snd_card *card = dev_get_drvdata(pdev);
        struct atmel_abdac *dac = card->private_data;
 
        dw_dma_cyclic_stop(dac->dma.chan);
@@ -537,9 +547,9 @@ static int atmel_abdac_suspend(struct platform_device *pdev, pm_message_t msg)
        return 0;
 }
 
-static int atmel_abdac_resume(struct platform_device *pdev)
+static int atmel_abdac_resume(struct device *pdev)
 {
-       struct snd_card *card = platform_get_drvdata(pdev);
+       struct snd_card *card = dev_get_drvdata(pdev);
        struct atmel_abdac *dac = card->private_data;
 
        clk_enable(dac->pclk);
@@ -549,9 +559,11 @@ static int atmel_abdac_resume(struct platform_device *pdev)
 
        return 0;
 }
+
+static SIMPLE_DEV_PM_OPS(atmel_abdac_pm, atmel_abdac_suspend, atmel_abdac_resume);
+#define ATMEL_ABDAC_PM_OPS     &atmel_abdac_pm
 #else
-#define atmel_abdac_suspend NULL
-#define atmel_abdac_resume NULL
+#define ATMEL_ABDAC_PM_OPS     NULL
 #endif
 
 static int __devexit atmel_abdac_remove(struct platform_device *pdev)
@@ -579,9 +591,9 @@ static struct platform_driver atmel_abdac_driver = {
        .remove         = __devexit_p(atmel_abdac_remove),
        .driver         = {
                .name   = "atmel_abdac",
+               .owner  = THIS_MODULE,
+               .pm     = ATMEL_ABDAC_PM_OPS,
        },
-       .suspend        = atmel_abdac_suspend,
-       .resume         = atmel_abdac_resume,
 };
 
 static int __init atmel_abdac_init(void)
@@ -599,4 +611,4 @@ module_exit(atmel_abdac_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Driver for Atmel Audio Bitstream DAC (ABDAC)");
-MODULE_AUTHOR("Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>");
+MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>");