[omap]: refresh/rename patches
[openwrt.git] / target / linux / omap / patches-3.12 / 402-ASoC-davinci-mcasp-Add-DMA-register-locations-to-DT.patch
1 From fb2002dbc326d2e408698038b668b19741567a48 Mon Sep 17 00:00:00 2001
2 From: Jyri Sarha <jsarha@ti.com>
3 Date: Fri, 6 Sep 2013 12:15:00 +0300
4 Subject: [PATCH 213/752] ASoC: davinci-mcasp: Add DMA register locations to
5  DT
6
7 This patch adds DMA register location to mcasp DT bindings. On am33xx
8 SoCs the McASP registers are mapped trough L4 interconnect, which is
9 not accessible by the DMA controller, so McASP data port is mapped
10 trough L3 to a different location.
11
12 Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>
13 Signed-off-by: Darren Etheridge <detheridge@ti.com>
14 Signed-off-by: Jyri Sarha <jsarha@ti.com>
15 ---
16  .../bindings/sound/davinci-mcasp-audio.txt         |    8 ++-
17  sound/soc/davinci/davinci-mcasp.c                  |   59 +++++++++++++-------
18  2 files changed, 46 insertions(+), 21 deletions(-)
19
20 --- a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
21 +++ b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
22 @@ -6,7 +6,11 @@ Required properties:
23         "ti,da830-mcasp-audio"  : for both DA830 & DA850 platforms
24         "ti,omap2-mcasp-audio"  : for OMAP2 platforms (TI81xx, AM33xx)
25  
26 -- reg : Should contain McASP registers offset and length
27 +- reg : Should contain McASP registers address and length for mpu and
28 +       optionally for dma controller access.
29 +- reg-names : The mandatory reg-range must be named "mpu" and the optional DMA
30 +             reg-range must be named "dma". For backward compatibility it is
31 +             good to keep "mpu" first in the list.
32  - interrupts : Interrupt number for McASP
33  - op-mode : I2S/DIT ops mode.
34  - tdm-slots : Slots for TDM operation.
35 @@ -15,7 +19,6 @@ Required properties:
36                 to "num-serializer" parameter. Each entry is a number indication
37                 serializer pin direction. (0 - INACTIVE, 1 - TX, 2 - RX)
38  
39 -
40  Optional properties:
41  
42  - ti,hwmods : Must be "mcasp<n>", n is controller instance starting 0
43 @@ -31,6 +34,7 @@ mcasp0: mcasp0@1d00000 {
44         #address-cells = <1>;
45         #size-cells = <0>;
46         reg = <0x100000 0x3000>;
47 +       reg-names "mpu";
48         interrupts = <82 83>;
49         op-mode = <0>;          /* MCASP_IIS_MODE */
50         tdm-slots = <2>;
51 --- a/sound/soc/davinci/davinci-mcasp.c
52 +++ b/sound/soc/davinci/davinci-mcasp.c
53 @@ -1001,18 +1001,40 @@ static const struct snd_soc_component_dr
54         .name           = "davinci-mcasp",
55  };
56  
57 +/* Some HW specific values and defaults. The rest is filled in from DT. */
58 +static struct snd_platform_data dm646x_mcasp_pdata = {
59 +       .tx_dma_offset = 0x400,
60 +       .rx_dma_offset = 0x400,
61 +       .asp_chan_q = EVENTQ_0,
62 +       .version = MCASP_VERSION_1,
63 +};
64 +
65 +static struct snd_platform_data da830_mcasp_pdata = {
66 +       .tx_dma_offset = 0x2000,
67 +       .rx_dma_offset = 0x2000,
68 +       .asp_chan_q = EVENTQ_0,
69 +       .version = MCASP_VERSION_2,
70 +};
71 +
72 +static struct snd_platform_data omap2_mcasp_pdata = {
73 +       .tx_dma_offset = 0,
74 +       .rx_dma_offset = 0,
75 +       .asp_chan_q = EVENTQ_0,
76 +       .version = MCASP_VERSION_3,
77 +};
78 +
79  static const struct of_device_id mcasp_dt_ids[] = {
80         {
81                 .compatible = "ti,dm646x-mcasp-audio",
82 -               .data = (void *)MCASP_VERSION_1,
83 +               .data = &dm646x_mcasp_pdata,
84         },
85         {
86                 .compatible = "ti,da830-mcasp-audio",
87 -               .data = (void *)MCASP_VERSION_2,
88 +               .data = &da830_mcasp_pdata,
89         },
90         {
91                 .compatible = "ti,omap2-mcasp-audio",
92 -               .data = (void *)MCASP_VERSION_3,
93 +               .data = &omap2_mcasp_pdata,
94         },
95         { /* sentinel */ }
96  };
97 @@ -1035,20 +1057,13 @@ static struct snd_platform_data *davinci
98                 pdata = pdev->dev.platform_data;
99                 return pdata;
100         } else if (match) {
101 -               pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
102 -               if (!pdata) {
103 -                       ret = -ENOMEM;
104 -                       goto nodata;
105 -               }
106 +               pdata = (struct snd_platform_data *) match->data;
107         } else {
108                 /* control shouldn't reach here. something is wrong */
109                 ret = -EINVAL;
110                 goto nodata;
111         }
112  
113 -       if (match->data)
114 -               pdata->version = (u8)((int)match->data);
115 -
116         ret = of_property_read_u32(np, "op-mode", &val);
117         if (ret >= 0)
118                 pdata->op_mode = val;
119 @@ -1145,10 +1160,15 @@ static int davinci_mcasp_probe(struct pl
120                 return -EINVAL;
121         }
122  
123 -       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
124 +       mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
125         if (!mem) {
126 -               dev_err(&pdev->dev, "no mem resource?\n");
127 -               return -ENODEV;
128 +               dev_warn(dev->dev,
129 +                        "\"mpu\" mem resource not found, using index 0\n");
130 +               mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
131 +               if (!mem) {
132 +                       dev_err(&pdev->dev, "no mem resource?\n");
133 +                       return -ENODEV;
134 +               }
135         }
136  
137         ioarea = devm_request_mem_region(&pdev->dev, mem->start,
138 @@ -1182,13 +1202,16 @@ static int davinci_mcasp_probe(struct pl
139         dev->rxnumevt = pdata->rxnumevt;
140         dev->dev = &pdev->dev;
141  
142 +       dma = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
143 +       if (!dma)
144 +               dma = mem;
145 +
146         dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
147         dma_data->asp_chan_q = pdata->asp_chan_q;
148         dma_data->ram_chan_q = pdata->ram_chan_q;
149         dma_data->sram_pool = pdata->sram_pool;
150         dma_data->sram_size = pdata->sram_size_playback;
151 -       dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
152 -                                                       mem->start);
153 +       dma_data->dma_addr = dma->start + pdata->tx_dma_offset;
154  
155         /* first TX, then RX */
156         res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
157 @@ -1205,8 +1228,7 @@ static int davinci_mcasp_probe(struct pl
158         dma_data->ram_chan_q = pdata->ram_chan_q;
159         dma_data->sram_pool = pdata->sram_pool;
160         dma_data->sram_size = pdata->sram_size_capture;
161 -       dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
162 -                                                       mem->start);
163 +       dma_data->dma_addr = dma->start + pdata->rx_dma_offset;
164  
165         res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
166         if (!res) {
167 @@ -1266,4 +1288,3 @@ module_platform_driver(davinci_mcasp_dri
168  MODULE_AUTHOR("Steve Chen");
169  MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface");
170  MODULE_LICENSE("GPL");
171 -