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