5fc2f1368f64c0e41dd180e0c3075cc68384ffde
[openwrt.git] / target / linux / omap / patches-3.12 / 403-ASoC-davinci-mcasp-Extract-DMA-channels-directly-fro.patch
1 From ad5d3e5a1218a599ec02c81a3bd599acedeea00f Mon Sep 17 00:00:00 2001
2 From: Jyri Sarha <jsarha@ti.com>
3 Date: Tue, 17 Sep 2013 12:09:30 +0300
4 Subject: [PATCH 214/752] ASoC: davinci-mcasp: Extract DMA channels directly
5  from DT
6
7 Extract DMA channels directly from DT as they can not be found from
8 platform resources anymore. This is a work-around until davinci audio
9 driver is updated to use dmaengine.
10
11 Signed-off-by: Jyri Sarha <jsarha@ti.com>
12 ---
13  .../bindings/sound/davinci-mcasp-audio.txt         |    5 +++
14  include/linux/platform_data/davinci_asp.h          |    2 +
15  sound/soc/davinci/davinci-mcasp.c                  |   47 +++++++++++++-------
16  3 files changed, 39 insertions(+), 15 deletions(-)
17
18 diff --git a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
19 index 63b67ae..68e0f47 100644
20 --- a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
21 +++ b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
22 @@ -18,6 +18,11 @@ Required properties:
23  - serial-dir : A list of serializer pin mode. The list number should be equal
24                 to "num-serializer" parameter. Each entry is a number indication
25                 serializer pin direction. (0 - INACTIVE, 1 - TX, 2 - RX)
26 +- dmas: two element list of DMA controller phandles and DMA request line
27 +        ordered pairs.
28 +- dma-names: identifier string for each DMA request line in the dmas property.
29 +            These strings correspond 1:1 with the ordered pairs in dmas. The dma
30 +            identifiers must be "rx" and "tx".
31  
32  Optional properties:
33  
34 diff --git a/include/linux/platform_data/davinci_asp.h b/include/linux/platform_data/davinci_asp.h
35 index 8db5ae0..689a856 100644
36 --- a/include/linux/platform_data/davinci_asp.h
37 +++ b/include/linux/platform_data/davinci_asp.h
38 @@ -84,6 +84,8 @@ struct snd_platform_data {
39         u8 version;
40         u8 txnumevt;
41         u8 rxnumevt;
42 +       int tx_dma_channel;
43 +       int rx_dma_channel;
44  };
45  
46  enum {
47 diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
48 index a056fc5..acbf5f8 100644
49 --- a/sound/soc/davinci/davinci-mcasp.c
50 +++ b/sound/soc/davinci/davinci-mcasp.c
51 @@ -1047,6 +1047,7 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
52         struct snd_platform_data *pdata = NULL;
53         const struct of_device_id *match =
54                         of_match_device(mcasp_dt_ids, &pdev->dev);
55 +       struct of_phandle_args dma_spec;
56  
57         const u32 *of_serial_dir32;
58         u8 *of_serial_dir;
59 @@ -1109,6 +1110,28 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
60                 pdata->serial_dir = of_serial_dir;
61         }
62  
63 +       ret = of_property_match_string(np, "dma-names", "tx");
64 +       if (ret < 0)
65 +               goto nodata;
66 +
67 +       ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret,
68 +                                        &dma_spec);
69 +       if (ret < 0)
70 +               goto nodata;
71 +
72 +       pdata->tx_dma_channel = dma_spec.args[0];
73 +
74 +       ret = of_property_match_string(np, "dma-names", "rx");
75 +       if (ret < 0)
76 +               goto nodata;
77 +
78 +       ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret,
79 +                                        &dma_spec);
80 +       if (ret < 0)
81 +               goto nodata;
82 +
83 +       pdata->rx_dma_channel = dma_spec.args[0];
84 +
85         ret = of_property_read_u32(np, "tx-num-evt", &val);
86         if (ret >= 0)
87                 pdata->txnumevt = val;
88 @@ -1139,7 +1162,7 @@ nodata:
89  static int davinci_mcasp_probe(struct platform_device *pdev)
90  {
91         struct davinci_pcm_dma_params *dma_data;
92 -       struct resource *mem, *ioarea, *res;
93 +       struct resource *mem, *ioarea, *res, *dma;
94         struct snd_platform_data *pdata;
95         struct davinci_audio_dev *dev;
96         int ret;
97 @@ -1213,15 +1236,11 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
98         dma_data->sram_size = pdata->sram_size_playback;
99         dma_data->dma_addr = dma->start + pdata->tx_dma_offset;
100  
101 -       /* first TX, then RX */
102         res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
103 -       if (!res) {
104 -               dev_err(&pdev->dev, "no DMA resource\n");
105 -               ret = -ENODEV;
106 -               goto err_release_clk;
107 -       }
108 -
109 -       dma_data->channel = res->start;
110 +       if (res)
111 +               dma_data->channel = res->start;
112 +       else
113 +               dma_data->channel = pdata->tx_dma_channel;
114  
115         dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
116         dma_data->asp_chan_q = pdata->asp_chan_q;
117 @@ -1231,13 +1250,11 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
118         dma_data->dma_addr = dma->start + pdata->rx_dma_offset;
119  
120         res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
121 -       if (!res) {
122 -               dev_err(&pdev->dev, "no DMA resource\n");
123 -               ret = -ENODEV;
124 -               goto err_release_clk;
125 -       }
126 +       if (res)
127 +               dma_data->channel = res->start;
128 +       else
129 +               dma_data->channel = pdata->rx_dma_channel;
130  
131 -       dma_data->channel = res->start;
132         dev_set_drvdata(&pdev->dev, dev);
133         ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
134                                          &davinci_mcasp_dai[pdata->op_mode], 1);
135 -- 
136 1.7.10.4
137