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
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.
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>
16 .../bindings/sound/davinci-mcasp-audio.txt | 8 ++-
17 sound/soc/davinci/davinci-mcasp.c | 59 +++++++++++++-------
18 2 files changed, 46 insertions(+), 21 deletions(-)
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)
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)
44 - ti,hwmods : Must be "mcasp<n>", n is controller instance starting 0
45 @@ -31,6 +34,7 @@ mcasp0: mcasp0@1d00000 {
48 reg = <0x100000 0x3000>;
51 op-mode = <0>; /* MCASP_IIS_MODE */
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",
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,
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,
76 +static struct snd_platform_data omap2_mcasp_pdata = {
79 + .asp_chan_q = EVENTQ_0,
80 + .version = MCASP_VERSION_3,
83 static const struct of_device_id mcasp_dt_ids[] = {
85 .compatible = "ti,dm646x-mcasp-audio",
86 - .data = (void *)MCASP_VERSION_1,
87 + .data = &dm646x_mcasp_pdata,
90 .compatible = "ti,da830-mcasp-audio",
91 - .data = (void *)MCASP_VERSION_2,
92 + .data = &da830_mcasp_pdata,
95 .compatible = "ti,omap2-mcasp-audio",
96 - .data = (void *)MCASP_VERSION_3,
97 + .data = &omap2_mcasp_pdata,
101 @@ -1035,20 +1057,13 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
102 pdata = pdev->dev.platform_data;
105 - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
110 + pdata = (struct snd_platform_data *) match->data;
112 /* control shouldn't reach here. something is wrong */
118 - pdata->version = (u8)((int)match->data);
120 ret = of_property_read_u32(np, "op-mode", &val);
122 pdata->op_mode = val;
123 @@ -1145,10 +1160,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
127 - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
128 + mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
130 - dev_err(&pdev->dev, "no mem resource?\n");
133 + "\"mpu\" mem resource not found, using index 0\n");
134 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
136 + dev_err(&pdev->dev, "no mem resource?\n");
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;
146 + dma = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
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 +
157 + dma_data->dma_addr = dma->start + pdata->tx_dma_offset;
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 +
167 + dma_data->dma_addr = dma->start + pdata->rx_dma_offset;
169 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
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");