aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2013-11-11 17:21:01 -0500
committerStephen Warren <swarren@nvidia.com>2013-12-11 18:43:57 -0500
commit5608bd3ed23e62bba96cc019030c742c78981b59 (patch)
treef441a68e603aea1baa49abedf19059fa167fdbde /sound
parentd59afb6a961519d81557f6b13d04ec1498c074fe (diff)
ASoC: tegra: convert to standard DMA DT bindings
By passing no flags when calling snd_dmaengine_pcm_register() from tegra_pcm.c, we end up using dma_request_slave_channel() rather than dmaengine_pcm_compat_request_channel(), and hence rely on the standard DMA DT bindings and stashing the DMA slave ID away during channel allocation. This means there's no need to use a custom DT property to store the slave ID. So, remove all the code that parsed it. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/tegra/tegra20_ac97.c11
-rw-r--r--sound/soc/tegra/tegra20_i2s.c20
-rw-r--r--sound/soc/tegra/tegra30_ahub.c23
-rw-r--r--sound/soc/tegra/tegra30_ahub.h9
-rw-r--r--sound/soc/tegra/tegra30_i2s.c14
-rw-r--r--sound/soc/tegra/tegra30_i2s.h3
-rw-r--r--sound/soc/tegra/tegra_pcm.c17
-rw-r--r--sound/soc/tegra/tegra_pcm.h5
8 files changed, 42 insertions, 60 deletions
diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c
index ae27bcd586d2..d8b98d70ff41 100644
--- a/sound/soc/tegra/tegra20_ac97.c
+++ b/sound/soc/tegra/tegra20_ac97.c
@@ -313,7 +313,6 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
313{ 313{
314 struct tegra20_ac97 *ac97; 314 struct tegra20_ac97 *ac97;
315 struct resource *mem; 315 struct resource *mem;
316 u32 of_dma[2];
317 void __iomem *regs; 316 void __iomem *regs;
318 int ret = 0; 317 int ret = 0;
319 318
@@ -348,14 +347,6 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
348 goto err_clk_put; 347 goto err_clk_put;
349 } 348 }
350 349
351 if (of_property_read_u32_array(pdev->dev.of_node,
352 "nvidia,dma-request-selector",
353 of_dma, 2) < 0) {
354 dev_err(&pdev->dev, "No DMA resource\n");
355 ret = -ENODEV;
356 goto err_clk_put;
357 }
358
359 ac97->reset_gpio = of_get_named_gpio(pdev->dev.of_node, 350 ac97->reset_gpio = of_get_named_gpio(pdev->dev.of_node,
360 "nvidia,codec-reset-gpio", 0); 351 "nvidia,codec-reset-gpio", 0);
361 if (gpio_is_valid(ac97->reset_gpio)) { 352 if (gpio_is_valid(ac97->reset_gpio)) {
@@ -380,12 +371,10 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
380 ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1; 371 ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1;
381 ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 372 ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
382 ac97->capture_dma_data.maxburst = 4; 373 ac97->capture_dma_data.maxburst = 4;
383 ac97->capture_dma_data.slave_id = of_dma[1];
384 374
385 ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1; 375 ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1;
386 ac97->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 376 ac97->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
387 ac97->playback_dma_data.maxburst = 4; 377 ac97->playback_dma_data.maxburst = 4;
388 ac97->playback_dma_data.slave_id = of_dma[1];
389 378
390 ret = tegra_asoc_utils_init(&ac97->util_data, &pdev->dev); 379 ret = tegra_asoc_utils_init(&ac97->util_data, &pdev->dev);
391 if (ret) 380 if (ret)
diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c
index 364bf6a907e1..1dc869c475e7 100644
--- a/sound/soc/tegra/tegra20_i2s.c
+++ b/sound/soc/tegra/tegra20_i2s.c
@@ -339,9 +339,7 @@ static const struct regmap_config tegra20_i2s_regmap_config = {
339static int tegra20_i2s_platform_probe(struct platform_device *pdev) 339static int tegra20_i2s_platform_probe(struct platform_device *pdev)
340{ 340{
341 struct tegra20_i2s *i2s; 341 struct tegra20_i2s *i2s;
342 struct resource *mem, *memregion, *dmareq; 342 struct resource *mem, *memregion;
343 u32 of_dma[2];
344 u32 dma_ch;
345 void __iomem *regs; 343 void __iomem *regs;
346 int ret; 344 int ret;
347 345
@@ -370,20 +368,6 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev)
370 goto err_clk_put; 368 goto err_clk_put;
371 } 369 }
372 370
373 dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0);
374 if (!dmareq) {
375 if (of_property_read_u32_array(pdev->dev.of_node,
376 "nvidia,dma-request-selector",
377 of_dma, 2) < 0) {
378 dev_err(&pdev->dev, "No DMA resource\n");
379 ret = -ENODEV;
380 goto err_clk_put;
381 }
382 dma_ch = of_dma[1];
383 } else {
384 dma_ch = dmareq->start;
385 }
386
387 memregion = devm_request_mem_region(&pdev->dev, mem->start, 371 memregion = devm_request_mem_region(&pdev->dev, mem->start,
388 resource_size(mem), DRV_NAME); 372 resource_size(mem), DRV_NAME);
389 if (!memregion) { 373 if (!memregion) {
@@ -410,12 +394,10 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev)
410 i2s->capture_dma_data.addr = mem->start + TEGRA20_I2S_FIFO2; 394 i2s->capture_dma_data.addr = mem->start + TEGRA20_I2S_FIFO2;
411 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 395 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
412 i2s->capture_dma_data.maxburst = 4; 396 i2s->capture_dma_data.maxburst = 4;
413 i2s->capture_dma_data.slave_id = dma_ch;
414 397
415 i2s->playback_dma_data.addr = mem->start + TEGRA20_I2S_FIFO1; 398 i2s->playback_dma_data.addr = mem->start + TEGRA20_I2S_FIFO1;
416 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 399 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
417 i2s->playback_dma_data.maxburst = 4; 400 i2s->playback_dma_data.maxburst = 4;
418 i2s->playback_dma_data.slave_id = dma_ch;
419 401
420 pm_runtime_enable(&pdev->dev); 402 pm_runtime_enable(&pdev->dev);
421 if (!pm_runtime_enabled(&pdev->dev)) { 403 if (!pm_runtime_enabled(&pdev->dev)) {
diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
index 7d146e6b7038..342cd4fff0a5 100644
--- a/sound/soc/tegra/tegra30_ahub.c
+++ b/sound/soc/tegra/tegra30_ahub.c
@@ -95,8 +95,8 @@ static int tegra30_ahub_runtime_resume(struct device *dev)
95} 95}
96 96
97int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, 97int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
98 dma_addr_t *fiforeg, 98 char *dmachan, int dmachan_len,
99 unsigned int *reqsel) 99 dma_addr_t *fiforeg)
100{ 100{
101 int channel; 101 int channel;
102 u32 reg, val; 102 u32 reg, val;
@@ -110,9 +110,9 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
110 __set_bit(channel, ahub->rx_usage); 110 __set_bit(channel, ahub->rx_usage);
111 111
112 *rxcif = TEGRA30_AHUB_RXCIF_APBIF_RX0 + channel; 112 *rxcif = TEGRA30_AHUB_RXCIF_APBIF_RX0 + channel;
113 snprintf(dmachan, dmachan_len, "rx%d", channel);
113 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_RXFIFO + 114 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_RXFIFO +
114 (channel * TEGRA30_AHUB_CHANNEL_RXFIFO_STRIDE); 115 (channel * TEGRA30_AHUB_CHANNEL_RXFIFO_STRIDE);
115 *reqsel = ahub->dma_sel + channel;
116 116
117 pm_runtime_get_sync(ahub->dev); 117 pm_runtime_get_sync(ahub->dev);
118 118
@@ -197,8 +197,8 @@ int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif)
197EXPORT_SYMBOL_GPL(tegra30_ahub_free_rx_fifo); 197EXPORT_SYMBOL_GPL(tegra30_ahub_free_rx_fifo);
198 198
199int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, 199int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
200 dma_addr_t *fiforeg, 200 char *dmachan, int dmachan_len,
201 unsigned int *reqsel) 201 dma_addr_t *fiforeg)
202{ 202{
203 int channel; 203 int channel;
204 u32 reg, val; 204 u32 reg, val;
@@ -212,9 +212,9 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
212 __set_bit(channel, ahub->tx_usage); 212 __set_bit(channel, ahub->tx_usage);
213 213
214 *txcif = TEGRA30_AHUB_TXCIF_APBIF_TX0 + channel; 214 *txcif = TEGRA30_AHUB_TXCIF_APBIF_TX0 + channel;
215 snprintf(dmachan, dmachan_len, "tx%d", channel);
215 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_TXFIFO + 216 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_TXFIFO +
216 (channel * TEGRA30_AHUB_CHANNEL_TXFIFO_STRIDE); 217 (channel * TEGRA30_AHUB_CHANNEL_TXFIFO_STRIDE);
217 *reqsel = ahub->dma_sel + channel;
218 218
219 pm_runtime_get_sync(ahub->dev); 219 pm_runtime_get_sync(ahub->dev);
220 220
@@ -510,7 +510,6 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
510 struct reset_control *rst; 510 struct reset_control *rst;
511 int i; 511 int i;
512 struct resource *res0, *res1, *region; 512 struct resource *res0, *res1, *region;
513 u32 of_dma[2];
514 void __iomem *regs_apbif, *regs_ahub; 513 void __iomem *regs_apbif, *regs_ahub;
515 int ret = 0; 514 int ret = 0;
516 515
@@ -573,16 +572,6 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
573 goto err_clk_put_d_audio; 572 goto err_clk_put_d_audio;
574 } 573 }
575 574
576 if (of_property_read_u32_array(pdev->dev.of_node,
577 "nvidia,dma-request-selector",
578 of_dma, 2) < 0) {
579 dev_err(&pdev->dev,
580 "Missing property nvidia,dma-request-selector\n");
581 ret = -ENODEV;
582 goto err_clk_put_d_audio;
583 }
584 ahub->dma_sel = of_dma[1];
585
586 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 575 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
587 if (!res0) { 576 if (!res0) {
588 dev_err(&pdev->dev, "No apbif memory resource\n"); 577 dev_err(&pdev->dev, "No apbif memory resource\n");
diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h
index 1383f8cd3572..fd7ba75ed814 100644
--- a/sound/soc/tegra/tegra30_ahub.h
+++ b/sound/soc/tegra/tegra30_ahub.h
@@ -465,15 +465,15 @@ enum tegra30_ahub_rxcif {
465}; 465};
466 466
467extern int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, 467extern int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
468 dma_addr_t *fiforeg, 468 char *dmachan, int dmachan_len,
469 unsigned int *reqsel); 469 dma_addr_t *fiforeg);
470extern int tegra30_ahub_enable_rx_fifo(enum tegra30_ahub_rxcif rxcif); 470extern int tegra30_ahub_enable_rx_fifo(enum tegra30_ahub_rxcif rxcif);
471extern int tegra30_ahub_disable_rx_fifo(enum tegra30_ahub_rxcif rxcif); 471extern int tegra30_ahub_disable_rx_fifo(enum tegra30_ahub_rxcif rxcif);
472extern int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif); 472extern int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif);
473 473
474extern int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, 474extern int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
475 dma_addr_t *fiforeg, 475 char *dmachan, int dmachan_len,
476 unsigned int *reqsel); 476 dma_addr_t *fiforeg);
477extern int tegra30_ahub_enable_tx_fifo(enum tegra30_ahub_txcif txcif); 477extern int tegra30_ahub_enable_tx_fifo(enum tegra30_ahub_txcif txcif);
478extern int tegra30_ahub_disable_tx_fifo(enum tegra30_ahub_txcif txcif); 478extern int tegra30_ahub_disable_tx_fifo(enum tegra30_ahub_txcif txcif);
479extern int tegra30_ahub_free_tx_fifo(enum tegra30_ahub_txcif txcif); 479extern int tegra30_ahub_free_tx_fifo(enum tegra30_ahub_txcif txcif);
@@ -524,7 +524,6 @@ struct tegra30_ahub {
524 struct device *dev; 524 struct device *dev;
525 struct clk *clk_d_audio; 525 struct clk *clk_d_audio;
526 struct clk *clk_apbif; 526 struct clk *clk_apbif;
527 int dma_sel;
528 resource_size_t apbif_addr; 527 resource_size_t apbif_addr;
529 struct regmap *regmap_apbif; 528 struct regmap *regmap_apbif;
530 struct regmap *regmap_ahub; 529 struct regmap *regmap_ahub;
diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
index 531a1ff2101d..362e8f728ddf 100644
--- a/sound/soc/tegra/tegra30_i2s.c
+++ b/sound/soc/tegra/tegra30_i2s.c
@@ -459,8 +459,9 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
459 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 459 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
460 i2s->playback_dma_data.maxburst = 4; 460 i2s->playback_dma_data.maxburst = 4;
461 ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif, 461 ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif,
462 &i2s->playback_dma_data.addr, 462 i2s->playback_dma_chan,
463 &i2s->playback_dma_data.slave_id); 463 sizeof(i2s->playback_dma_chan),
464 &i2s->playback_dma_data.addr);
464 if (ret) { 465 if (ret) {
465 dev_err(&pdev->dev, "Could not alloc TX FIFO: %d\n", ret); 466 dev_err(&pdev->dev, "Could not alloc TX FIFO: %d\n", ret);
466 goto err_suspend; 467 goto err_suspend;
@@ -475,8 +476,9 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
475 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 476 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
476 i2s->capture_dma_data.maxburst = 4; 477 i2s->capture_dma_data.maxburst = 4;
477 ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif, 478 ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif,
478 &i2s->capture_dma_data.addr, 479 i2s->capture_dma_chan,
479 &i2s->capture_dma_data.slave_id); 480 sizeof(i2s->capture_dma_chan),
481 &i2s->capture_dma_data.addr);
480 if (ret) { 482 if (ret) {
481 dev_err(&pdev->dev, "Could not alloc RX FIFO: %d\n", ret); 483 dev_err(&pdev->dev, "Could not alloc RX FIFO: %d\n", ret);
482 goto err_unroute_tx_fifo; 484 goto err_unroute_tx_fifo;
@@ -496,7 +498,9 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
496 goto err_unroute_rx_fifo; 498 goto err_unroute_rx_fifo;
497 } 499 }
498 500
499 ret = tegra_pcm_platform_register(&pdev->dev); 501 ret = tegra_pcm_platform_register_with_chan_names(&pdev->dev,
502 &i2s->dma_config, i2s->playback_dma_chan,
503 i2s->capture_dma_chan);
500 if (ret) { 504 if (ret) {
501 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); 505 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
502 goto err_unregister_component; 506 goto err_unregister_component;
diff --git a/sound/soc/tegra/tegra30_i2s.h b/sound/soc/tegra/tegra30_i2s.h
index 4d0b0a30dbfb..774fc6ad2026 100644
--- a/sound/soc/tegra/tegra30_i2s.h
+++ b/sound/soc/tegra/tegra30_i2s.h
@@ -238,11 +238,14 @@ struct tegra30_i2s {
238 struct clk *clk_i2s; 238 struct clk *clk_i2s;
239 enum tegra30_ahub_txcif capture_i2s_cif; 239 enum tegra30_ahub_txcif capture_i2s_cif;
240 enum tegra30_ahub_rxcif capture_fifo_cif; 240 enum tegra30_ahub_rxcif capture_fifo_cif;
241 char capture_dma_chan[8];
241 struct snd_dmaengine_dai_dma_data capture_dma_data; 242 struct snd_dmaengine_dai_dma_data capture_dma_data;
242 enum tegra30_ahub_rxcif playback_i2s_cif; 243 enum tegra30_ahub_rxcif playback_i2s_cif;
243 enum tegra30_ahub_txcif playback_fifo_cif; 244 enum tegra30_ahub_txcif playback_fifo_cif;
245 char playback_dma_chan[8];
244 struct snd_dmaengine_dai_dma_data playback_dma_data; 246 struct snd_dmaengine_dai_dma_data playback_dma_data;
245 struct regmap *regmap; 247 struct regmap *regmap;
248 struct snd_dmaengine_pcm_config dma_config;
246}; 249};
247 250
248#endif 251#endif
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index 7b2d23ba69b3..7ce5c334a660 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -61,12 +61,23 @@ static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = {
61 61
62int tegra_pcm_platform_register(struct device *dev) 62int tegra_pcm_platform_register(struct device *dev)
63{ 63{
64 return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 64 return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 0);
65 SND_DMAENGINE_PCM_FLAG_NO_DT |
66 SND_DMAENGINE_PCM_FLAG_COMPAT);
67} 65}
68EXPORT_SYMBOL_GPL(tegra_pcm_platform_register); 66EXPORT_SYMBOL_GPL(tegra_pcm_platform_register);
69 67
68int tegra_pcm_platform_register_with_chan_names(struct device *dev,
69 struct snd_dmaengine_pcm_config *config,
70 char *txdmachan, char *rxdmachan)
71{
72 *config = tegra_dmaengine_pcm_config;
73 config->dma_dev = dev->parent;
74 config->chan_names[0] = txdmachan;
75 config->chan_names[1] = rxdmachan;
76
77 return snd_dmaengine_pcm_register(dev, config, 0);
78}
79EXPORT_SYMBOL_GPL(tegra_pcm_platform_register_with_chan_names);
80
70void tegra_pcm_platform_unregister(struct device *dev) 81void tegra_pcm_platform_unregister(struct device *dev)
71{ 82{
72 return snd_dmaengine_pcm_unregister(dev); 83 return snd_dmaengine_pcm_unregister(dev);
diff --git a/sound/soc/tegra/tegra_pcm.h b/sound/soc/tegra/tegra_pcm.h
index 68ad901714a9..7883dec748a3 100644
--- a/sound/soc/tegra/tegra_pcm.h
+++ b/sound/soc/tegra/tegra_pcm.h
@@ -31,7 +31,12 @@
31#ifndef __TEGRA_PCM_H__ 31#ifndef __TEGRA_PCM_H__
32#define __TEGRA_PCM_H__ 32#define __TEGRA_PCM_H__
33 33
34struct snd_dmaengine_pcm_config;
35
34int tegra_pcm_platform_register(struct device *dev); 36int tegra_pcm_platform_register(struct device *dev);
37int tegra_pcm_platform_register_with_chan_names(struct device *dev,
38 struct snd_dmaengine_pcm_config *config,
39 char *txdmachan, char *rxdmachan);
35void tegra_pcm_platform_unregister(struct device *dev); 40void tegra_pcm_platform_unregister(struct device *dev);
36 41
37#endif 42#endif