]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ASoC: davinci-mcasp: Extract DMA channels directly from DT
authorJyri Sarha <jsarha@ti.com>
Fri, 18 Oct 2013 15:37:43 +0000 (18:37 +0300)
committerMark Brown <broonie@linaro.org>
Tue, 22 Oct 2013 11:03:21 +0000 (12:03 +0100)
Extract DMA channels directly from DT as they can not be found from
platform resources anymore. This is a work-around until davinci audio
driver is updated to use dmaengine.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
include/linux/platform_data/davinci_asp.h
sound/soc/davinci/davinci-mcasp.c

index c2ab8697e24af8d95367ed10ab86ea645215dceb..c3ccde71f97a43c20126efc00e477b7b71d10a1f 100644 (file)
@@ -18,6 +18,11 @@ Required properties:
 - serial-dir : A list of serializer pin mode. The list number should be equal
                to "num-serializer" parameter. Each entry is a number indication
                serializer pin direction. (0 - INACTIVE, 1 - TX, 2 - RX)
+- dmas: two element list of DMA controller phandles and DMA request line
+        ordered pairs.
+- dma-names: identifier string for each DMA request line in the dmas property.
+            These strings correspond 1:1 with the ordered pairs in dmas. The dma
+            identifiers must be "rx" and "tx".
 
 Optional properties:
 
index 8db5ae03b6e3f679c16988e492e8241f1567b2f5..689a856b86f90e1329515cf1ad9b80d3e2e7cdf5 100644 (file)
@@ -84,6 +84,8 @@ struct snd_platform_data {
        u8 version;
        u8 txnumevt;
        u8 rxnumevt;
+       int tx_dma_channel;
+       int rx_dma_channel;
 };
 
 enum {
index 806bec34e4d9bd644e052b0d28b3181ac4b920e4..4c207508348fc200f1fc2caa89598a30675ff20f 100644 (file)
@@ -1047,6 +1047,7 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
        struct snd_platform_data *pdata = NULL;
        const struct of_device_id *match =
                        of_match_device(mcasp_dt_ids, &pdev->dev);
+       struct of_phandle_args dma_spec;
 
        const u32 *of_serial_dir32;
        u8 *of_serial_dir;
@@ -1109,6 +1110,28 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
                pdata->serial_dir = of_serial_dir;
        }
 
+       ret = of_property_match_string(np, "dma-names", "tx");
+       if (ret < 0)
+               goto nodata;
+
+       ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret,
+                                        &dma_spec);
+       if (ret < 0)
+               goto nodata;
+
+       pdata->tx_dma_channel = dma_spec.args[0];
+
+       ret = of_property_match_string(np, "dma-names", "rx");
+       if (ret < 0)
+               goto nodata;
+
+       ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret,
+                                        &dma_spec);
+       if (ret < 0)
+               goto nodata;
+
+       pdata->rx_dma_channel = dma_spec.args[0];
+
        ret = of_property_read_u32(np, "tx-num-evt", &val);
        if (ret >= 0)
                pdata->txnumevt = val;
@@ -1213,15 +1236,11 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        dma_data->sram_size = pdata->sram_size_playback;
        dma_data->dma_addr = dat->start + pdata->tx_dma_offset;
 
-       /* first TX, then RX */
        res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-       if (!res) {
-               dev_err(&pdev->dev, "no DMA resource\n");
-               ret = -ENODEV;
-               goto err_release_clk;
-       }
-
-       dma_data->channel = res->start;
+       if (res)
+               dma_data->channel = res->start;
+       else
+               dma_data->channel = pdata->tx_dma_channel;
 
        dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
        dma_data->asp_chan_q = pdata->asp_chan_q;
@@ -1231,13 +1250,11 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        dma_data->dma_addr = dat->start + pdata->rx_dma_offset;
 
        res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-       if (!res) {
-               dev_err(&pdev->dev, "no DMA resource\n");
-               ret = -ENODEV;
-               goto err_release_clk;
-       }
+       if (res)
+               dma_data->channel = res->start;
+       else
+               dma_data->channel = pdata->rx_dma_channel;
 
-       dma_data->channel = res->start;
        dev_set_drvdata(&pdev->dev, dev);
        ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
                                         &davinci_mcasp_dai[pdata->op_mode], 1);