aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Warren <swarren@wwwdotorg.org>2012-03-20 16:55:49 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-01 06:28:28 -0400
commit518de86ba106185212ec30fea501be024a12f5db (patch)
tree6822112c2ba0acad5e646599efed4aa6a3fbcd23
parent1ae93b9d34c26494eea6c127c179b4c88c78bab7 (diff)
ASoC: tegra: register 'platform' from DAIs, get rid of pdev
Previously, the ASoC 'platform' (PCM/DMA) object was instantiated via a platform_device. This didn't represent the hardware well, since there was no separate hardware associated with this platform_device; it was a virtual device with sole purpose to call snd_soc_register_platform(). This mechanism required all board files to register this device, and all ASoC machine drivers to create and register this device when booting using device tree. This change removes the platform_device completely. Each Tegra DAI now registers the ASoC 'platform' itself. Machine drivers are adjusted for the new 'platform' name. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/tegra/tegra_alc5632.c21
-rw-r--r--sound/soc/tegra/tegra_i2s.c11
-rw-r--r--sound/soc/tegra/tegra_pcm.c26
-rw-r--r--sound/soc/tegra/tegra_pcm.h5
-rw-r--r--sound/soc/tegra/tegra_spdif.c11
-rw-r--r--sound/soc/tegra/tegra_wm8903.c24
-rw-r--r--sound/soc/tegra/trimslice.c2
7 files changed, 41 insertions, 59 deletions
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
index 03ae0952ccd4..396181cd2c78 100644
--- a/sound/soc/tegra/tegra_alc5632.c
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -2,6 +2,7 @@
2 * tegra_alc5632.c -- Toshiba AC100(PAZ00) machine ASoC driver 2 * tegra_alc5632.c -- Toshiba AC100(PAZ00) machine ASoC driver
3 * 3 *
4 * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.lauchpad.net> 4 * Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.lauchpad.net>
5 * Copyright (C) 2012 - NVIDIA, Inc.
5 * 6 *
6 * Authors: Leon Romanovsky <leon@leon.nu> 7 * Authors: Leon Romanovsky <leon@leon.nu>
7 * Andrey Danin <danindrey@mail.ru> 8 * Andrey Danin <danindrey@mail.ru>
@@ -39,7 +40,6 @@
39 40
40struct tegra_alc5632 { 41struct tegra_alc5632 {
41 struct tegra_asoc_utils_data util_data; 42 struct tegra_asoc_utils_data util_data;
42 struct platform_device *pcm_dev;
43 int gpio_requested; 43 int gpio_requested;
44 int gpio_hp_det; 44 int gpio_hp_det;
45}; 45};
@@ -140,7 +140,6 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
140static struct snd_soc_dai_link tegra_alc5632_dai = { 140static struct snd_soc_dai_link tegra_alc5632_dai = {
141 .name = "ALC5632", 141 .name = "ALC5632",
142 .stream_name = "ALC5632 PCM", 142 .stream_name = "ALC5632 PCM",
143 .platform_name = "tegra-pcm-audio",
144 .codec_dai_name = "alc5632-hifi", 143 .codec_dai_name = "alc5632-hifi",
145 .init = tegra_alc5632_asoc_init, 144 .init = tegra_alc5632_asoc_init,
146 .ops = &tegra_alc5632_asoc_ops, 145 .ops = &tegra_alc5632_asoc_ops,
@@ -179,8 +178,6 @@ static __devinit int tegra_alc5632_probe(struct platform_device *pdev)
179 platform_set_drvdata(pdev, card); 178 platform_set_drvdata(pdev, card);
180 snd_soc_card_set_drvdata(card, alc5632); 179 snd_soc_card_set_drvdata(card, alc5632);
181 180
182 alc5632->pcm_dev = ERR_PTR(-EINVAL);
183
184 if (!(pdev->dev.of_node)) { 181 if (!(pdev->dev.of_node)) {
185 dev_err(&pdev->dev, "Must be instantiated using device tree\n"); 182 dev_err(&pdev->dev, "Must be instantiated using device tree\n");
186 ret = -EINVAL; 183 ret = -EINVAL;
@@ -214,18 +211,11 @@ static __devinit int tegra_alc5632_probe(struct platform_device *pdev)
214 goto err; 211 goto err;
215 } 212 }
216 213
217 alc5632->pcm_dev = platform_device_register_simple( 214 tegra_alc5632_dai.platform_of_node = tegra_alc5632_dai.cpu_dai_of_node;
218 "tegra-pcm-audio", -1, NULL, 0);
219 if (IS_ERR(alc5632->pcm_dev)) {
220 dev_err(&pdev->dev,
221 "Can't instantiate tegra-pcm-audio\n");
222 ret = PTR_ERR(alc5632->pcm_dev);
223 goto err;
224 }
225 215
226 ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev); 216 ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev);
227 if (ret) 217 if (ret)
228 goto err_unregister; 218 goto err;
229 219
230 ret = snd_soc_register_card(card); 220 ret = snd_soc_register_card(card);
231 if (ret) { 221 if (ret) {
@@ -238,9 +228,6 @@ static __devinit int tegra_alc5632_probe(struct platform_device *pdev)
238 228
239err_fini_utils: 229err_fini_utils:
240 tegra_asoc_utils_fini(&alc5632->util_data); 230 tegra_asoc_utils_fini(&alc5632->util_data);
241err_unregister:
242 if (!IS_ERR(alc5632->pcm_dev))
243 platform_device_unregister(alc5632->pcm_dev);
244err: 231err:
245 return ret; 232 return ret;
246} 233}
@@ -259,8 +246,6 @@ static int __devexit tegra_alc5632_remove(struct platform_device *pdev)
259 snd_soc_unregister_card(card); 246 snd_soc_unregister_card(card);
260 247
261 tegra_asoc_utils_fini(&machine->util_data); 248 tegra_asoc_utils_fini(&machine->util_data);
262 if (!IS_ERR(machine->pcm_dev))
263 platform_device_unregister(machine->pcm_dev);
264 249
265 return 0; 250 return 0;
266} 251}
diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c
index 33509de52540..546e29be8a24 100644
--- a/sound/soc/tegra/tegra_i2s.c
+++ b/sound/soc/tegra/tegra_i2s.c
@@ -2,7 +2,7 @@
2 * tegra_i2s.c - Tegra I2S driver 2 * tegra_i2s.c - Tegra I2S driver
3 * 3 *
4 * Author: Stephen Warren <swarren@nvidia.com> 4 * Author: Stephen Warren <swarren@nvidia.com>
5 * Copyright (C) 2010 - NVIDIA, Inc. 5 * Copyright (C) 2010,2012 - NVIDIA, Inc.
6 * 6 *
7 * Based on code copyright/by: 7 * Based on code copyright/by:
8 * 8 *
@@ -409,10 +409,18 @@ static __devinit int tegra_i2s_platform_probe(struct platform_device *pdev)
409 goto err_clk_put; 409 goto err_clk_put;
410 } 410 }
411 411
412 ret = tegra_pcm_platform_register(&pdev->dev);
413 if (ret) {
414 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
415 goto err_unregister_dai;
416 }
417
412 tegra_i2s_debug_add(i2s); 418 tegra_i2s_debug_add(i2s);
413 419
414 return 0; 420 return 0;
415 421
422err_unregister_dai:
423 snd_soc_unregister_dai(&pdev->dev);
416err_clk_put: 424err_clk_put:
417 clk_put(i2s->clk_i2s); 425 clk_put(i2s->clk_i2s);
418err: 426err:
@@ -423,6 +431,7 @@ static int __devexit tegra_i2s_platform_remove(struct platform_device *pdev)
423{ 431{
424 struct tegra_i2s *i2s = dev_get_drvdata(&pdev->dev); 432 struct tegra_i2s *i2s = dev_get_drvdata(&pdev->dev);
425 433
434 tegra_pcm_platform_unregister(&pdev->dev);
426 snd_soc_unregister_dai(&pdev->dev); 435 snd_soc_unregister_dai(&pdev->dev);
427 436
428 tegra_i2s_debug_remove(i2s); 437 tegra_i2s_debug_remove(i2s);
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index 8b4457137c7c..476b8ac3a24d 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -2,7 +2,7 @@
2 * tegra_pcm.c - Tegra PCM driver 2 * tegra_pcm.c - Tegra PCM driver
3 * 3 *
4 * Author: Stephen Warren <swarren@nvidia.com> 4 * Author: Stephen Warren <swarren@nvidia.com>
5 * Copyright (C) 2010 - NVIDIA, Inc. 5 * Copyright (C) 2010,2012 - NVIDIA, Inc.
6 * 6 *
7 * Based on code copyright/by: 7 * Based on code copyright/by:
8 * 8 *
@@ -39,8 +39,6 @@
39 39
40#include "tegra_pcm.h" 40#include "tegra_pcm.h"
41 41
42#define DRV_NAME "tegra-pcm-audio"
43
44static const struct snd_pcm_hardware tegra_pcm_hardware = { 42static const struct snd_pcm_hardware tegra_pcm_hardware = {
45 .info = SNDRV_PCM_INFO_MMAP | 43 .info = SNDRV_PCM_INFO_MMAP |
46 SNDRV_PCM_INFO_MMAP_VALID | 44 SNDRV_PCM_INFO_MMAP_VALID |
@@ -372,28 +370,18 @@ static struct snd_soc_platform_driver tegra_pcm_platform = {
372 .pcm_free = tegra_pcm_free, 370 .pcm_free = tegra_pcm_free,
373}; 371};
374 372
375static int __devinit tegra_pcm_platform_probe(struct platform_device *pdev) 373int __devinit tegra_pcm_platform_register(struct device *dev)
376{ 374{
377 return snd_soc_register_platform(&pdev->dev, &tegra_pcm_platform); 375 return snd_soc_register_platform(dev, &tegra_pcm_platform);
378} 376}
377EXPORT_SYMBOL_GPL(tegra_pcm_platform_register);
379 378
380static int __devexit tegra_pcm_platform_remove(struct platform_device *pdev) 379void __devexit tegra_pcm_platform_unregister(struct device *dev)
381{ 380{
382 snd_soc_unregister_platform(&pdev->dev); 381 snd_soc_unregister_platform(dev);
383 return 0;
384} 382}
385 383EXPORT_SYMBOL_GPL(tegra_pcm_platform_unregister);
386static struct platform_driver tegra_pcm_driver = {
387 .driver = {
388 .name = DRV_NAME,
389 .owner = THIS_MODULE,
390 },
391 .probe = tegra_pcm_platform_probe,
392 .remove = __devexit_p(tegra_pcm_platform_remove),
393};
394module_platform_driver(tegra_pcm_driver);
395 384
396MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); 385MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
397MODULE_DESCRIPTION("Tegra PCM ASoC driver"); 386MODULE_DESCRIPTION("Tegra PCM ASoC driver");
398MODULE_LICENSE("GPL"); 387MODULE_LICENSE("GPL");
399MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/sound/soc/tegra/tegra_pcm.h b/sound/soc/tegra/tegra_pcm.h
index dbb90339fe0d..985d418a35e7 100644
--- a/sound/soc/tegra/tegra_pcm.h
+++ b/sound/soc/tegra/tegra_pcm.h
@@ -2,7 +2,7 @@
2 * tegra_pcm.h - Definitions for Tegra PCM driver 2 * tegra_pcm.h - Definitions for Tegra PCM driver
3 * 3 *
4 * Author: Stephen Warren <swarren@nvidia.com> 4 * Author: Stephen Warren <swarren@nvidia.com>
5 * Copyright (C) 2010 - NVIDIA, Inc. 5 * Copyright (C) 2010,2012 - NVIDIA, Inc.
6 * 6 *
7 * Based on code copyright/by: 7 * Based on code copyright/by:
8 * 8 *
@@ -52,4 +52,7 @@ struct tegra_runtime_data {
52 struct tegra_dma_channel *dma_chan; 52 struct tegra_dma_channel *dma_chan;
53}; 53};
54 54
55int tegra_pcm_platform_register(struct device *dev);
56void tegra_pcm_platform_unregister(struct device *dev);
57
55#endif 58#endif
diff --git a/sound/soc/tegra/tegra_spdif.c b/sound/soc/tegra/tegra_spdif.c
index 475428cf270e..cd836cbcb0c9 100644
--- a/sound/soc/tegra/tegra_spdif.c
+++ b/sound/soc/tegra/tegra_spdif.c
@@ -2,7 +2,7 @@
2 * tegra_spdif.c - Tegra SPDIF driver 2 * tegra_spdif.c - Tegra SPDIF driver
3 * 3 *
4 * Author: Stephen Warren <swarren@nvidia.com> 4 * Author: Stephen Warren <swarren@nvidia.com>
5 * Copyright (C) 2011 - NVIDIA, Inc. 5 * Copyright (C) 2011-2012 - NVIDIA, Inc.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -306,10 +306,18 @@ static __devinit int tegra_spdif_platform_probe(struct platform_device *pdev)
306 goto err_unmap; 306 goto err_unmap;
307 } 307 }
308 308
309 ret = tegra_pcm_platform_register(&pdev->dev);
310 if (ret) {
311 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
312 goto err_unregister_dai;
313 }
314
309 tegra_spdif_debug_add(spdif); 315 tegra_spdif_debug_add(spdif);
310 316
311 return 0; 317 return 0;
312 318
319err_unregister_dai:
320 snd_soc_unregister_dai(&pdev->dev);
313err_unmap: 321err_unmap:
314 iounmap(spdif->regs); 322 iounmap(spdif->regs);
315err_release: 323err_release:
@@ -327,6 +335,7 @@ static int __devexit tegra_spdif_platform_remove(struct platform_device *pdev)
327 struct tegra_spdif *spdif = dev_get_drvdata(&pdev->dev); 335 struct tegra_spdif *spdif = dev_get_drvdata(&pdev->dev);
328 struct resource *res; 336 struct resource *res;
329 337
338 tegra_pcm_platform_unregister(&pdev->dev);
330 snd_soc_unregister_dai(&pdev->dev); 339 snd_soc_unregister_dai(&pdev->dev);
331 340
332 tegra_spdif_debug_remove(spdif); 341 tegra_spdif_debug_remove(spdif);
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index 566655e23b7d..fbd13357e1fd 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -2,7 +2,7 @@
2 * tegra_wm8903.c - Tegra machine ASoC driver for boards using WM8903 codec. 2 * tegra_wm8903.c - Tegra machine ASoC driver for boards using WM8903 codec.
3 * 3 *
4 * Author: Stephen Warren <swarren@nvidia.com> 4 * Author: Stephen Warren <swarren@nvidia.com>
5 * Copyright (C) 2010-2011 - NVIDIA, Inc. 5 * Copyright (C) 2010-2012 - NVIDIA, Inc.
6 * 6 *
7 * Based on code copyright/by: 7 * Based on code copyright/by:
8 * 8 *
@@ -61,7 +61,6 @@
61 61
62struct tegra_wm8903 { 62struct tegra_wm8903 {
63 struct tegra_wm8903_platform_data pdata; 63 struct tegra_wm8903_platform_data pdata;
64 struct platform_device *pcm_dev;
65 struct tegra_asoc_utils_data util_data; 64 struct tegra_asoc_utils_data util_data;
66 int gpio_requested; 65 int gpio_requested;
67}; 66};
@@ -354,7 +353,7 @@ static struct snd_soc_dai_link tegra_wm8903_dai = {
354 .name = "WM8903", 353 .name = "WM8903",
355 .stream_name = "WM8903 PCM", 354 .stream_name = "WM8903 PCM",
356 .codec_name = "wm8903.0-001a", 355 .codec_name = "wm8903.0-001a",
357 .platform_name = "tegra-pcm-audio", 356 .platform_name = "tegra-i2s.0",
358 .cpu_dai_name = "tegra-i2s.0", 357 .cpu_dai_name = "tegra-i2s.0",
359 .codec_dai_name = "wm8903-hifi", 358 .codec_dai_name = "wm8903-hifi",
360 .init = tegra_wm8903_init, 359 .init = tegra_wm8903_init,
@@ -392,7 +391,6 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
392 ret = -ENOMEM; 391 ret = -ENOMEM;
393 goto err; 392 goto err;
394 } 393 }
395 machine->pcm_dev = ERR_PTR(-EINVAL);
396 394
397 card->dev = &pdev->dev; 395 card->dev = &pdev->dev;
398 platform_set_drvdata(pdev, card); 396 platform_set_drvdata(pdev, card);
@@ -428,14 +426,9 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
428 goto err; 426 goto err;
429 } 427 }
430 428
431 machine->pcm_dev = platform_device_register_simple( 429 tegra_wm8903_dai.platform_name = NULL;
432 "tegra-pcm-audio", -1, NULL, 0); 430 tegra_wm8903_dai.platform_of_node =
433 if (IS_ERR(machine->pcm_dev)) { 431 tegra_wm8903_dai.cpu_dai_of_node;
434 dev_err(&pdev->dev,
435 "Can't instantiate tegra-pcm-audio\n");
436 ret = PTR_ERR(machine->pcm_dev);
437 goto err;
438 }
439 } else { 432 } else {
440 if (machine_is_harmony()) { 433 if (machine_is_harmony()) {
441 card->dapm_routes = harmony_audio_map; 434 card->dapm_routes = harmony_audio_map;
@@ -454,7 +447,7 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
454 447
455 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); 448 ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);
456 if (ret) 449 if (ret)
457 goto err_unregister; 450 goto err;
458 451
459 ret = snd_soc_register_card(card); 452 ret = snd_soc_register_card(card);
460 if (ret) { 453 if (ret) {
@@ -467,9 +460,6 @@ static __devinit int tegra_wm8903_driver_probe(struct platform_device *pdev)
467 460
468err_fini_utils: 461err_fini_utils:
469 tegra_asoc_utils_fini(&machine->util_data); 462 tegra_asoc_utils_fini(&machine->util_data);
470err_unregister:
471 if (!IS_ERR(machine->pcm_dev))
472 platform_device_unregister(machine->pcm_dev);
473err: 463err:
474 return ret; 464 return ret;
475} 465}
@@ -497,8 +487,6 @@ static int __devexit tegra_wm8903_driver_remove(struct platform_device *pdev)
497 snd_soc_unregister_card(card); 487 snd_soc_unregister_card(card);
498 488
499 tegra_asoc_utils_fini(&machine->util_data); 489 tegra_asoc_utils_fini(&machine->util_data);
500 if (!IS_ERR(machine->pcm_dev))
501 platform_device_unregister(machine->pcm_dev);
502 490
503 return 0; 491 return 0;
504} 492}
diff --git a/sound/soc/tegra/trimslice.c b/sound/soc/tegra/trimslice.c
index 2bdfc550cff8..6be9e0f747c9 100644
--- a/sound/soc/tegra/trimslice.c
+++ b/sound/soc/tegra/trimslice.c
@@ -119,7 +119,7 @@ static struct snd_soc_dai_link trimslice_tlv320aic23_dai = {
119 .name = "TLV320AIC23", 119 .name = "TLV320AIC23",
120 .stream_name = "AIC23", 120 .stream_name = "AIC23",
121 .codec_name = "tlv320aic23-codec.2-001a", 121 .codec_name = "tlv320aic23-codec.2-001a",
122 .platform_name = "tegra-pcm-audio", 122 .platform_name = "tegra-i2s.0",
123 .cpu_dai_name = "tegra-i2s.0", 123 .cpu_dai_name = "tegra-i2s.0",
124 .codec_dai_name = "tlv320aic23-hifi", 124 .codec_dai_name = "tlv320aic23-hifi",
125 .ops = &trimslice_asoc_ops, 125 .ops = &trimslice_asoc_ops,