[alsa-devel] [RFC 0/7] mpc5200 ASoC and pcm030 board fixes
This series is a respin of "mpc5200 ASoC fixups"
The mpc5200 ASoC and pcm030 board code compiled, but did not run after the multi-codec patches. This series add the missing pieces into the mpc5200 ASoC drivers and updates the pcm030 board to the current api.
Eric Millbrandt (7): powerpc/52xx: define FSL_SOC ASoC: fsl: mpc5200 combine psc_dma platform data ASoC: fsl: mpc5200 add missing information to snd_soc_dai_driver ASoC: fsl: cleanup headers in pcm030-audio-fabric ASoC: fsl: convert pcm030-audio-fabric to a platform-driver ASoC: fsl: convert pcm030-audio-fabric to use snd_soc_register_card ASoC: fsl: register the wm9712-codec
arch/powerpc/platforms/52xx/Kconfig | 1 + sound/soc/fsl/mpc5200_dma.c | 24 ++------- sound/soc/fsl/mpc5200_dma.h | 3 + sound/soc/fsl/mpc5200_psc_ac97.c | 10 ++++ sound/soc/fsl/mpc5200_psc_i2s.c | 8 +++ sound/soc/fsl/pcm030-audio-fabric.c | 100 +++++++++++++++++++++++++--------- 6 files changed, 99 insertions(+), 47 deletions(-)
mpc52xx socs need to have FSL_SOC defined to build their drivers (i2c-mpc, ASoC)
Signed-off-by: Eric Millbrandt emillbrandt@dekaresearch.com
diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig index 90f4496..fb35944 100644 --- a/arch/powerpc/platforms/52xx/Kconfig +++ b/arch/powerpc/platforms/52xx/Kconfig @@ -1,6 +1,7 @@ config PPC_MPC52xx bool "52xx-based boards" depends on 6xx + select FSL_SOC select PPC_CLOCK select PPC_PCI_CHOICE
The mpc5200_psc_ac97 and mpc5200_psc_i2s modules rely on shared platform data with mpc5200_dma.
Signed-off-by: Eric Millbrandt emillbrandt@dekaresearch.com
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 9a3f7c5..9997c03 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -370,7 +370,7 @@ static struct snd_soc_platform_driver mpc5200_audio_dma_platform = { .pcm_free = &psc_dma_free, };
-static int mpc5200_hpcd_probe(struct platform_device *op) +int mpc5200_audio_dma_create(struct platform_device *op) { phys_addr_t fifo; struct psc_dma *psc_dma; @@ -487,8 +487,9 @@ out_unmap: iounmap(regs); return ret; } +EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create);
-static int mpc5200_hpcd_remove(struct platform_device *op) +int mpc5200_audio_dma_destroy(struct platform_device *op) { struct psc_dma *psc_dma = dev_get_drvdata(&op->dev);
@@ -510,24 +511,7 @@ static int mpc5200_hpcd_remove(struct platform_device *op)
return 0; } - -static struct of_device_id mpc5200_hpcd_match[] = { - { .compatible = "fsl,mpc5200-pcm", }, - {} -}; -MODULE_DEVICE_TABLE(of, mpc5200_hpcd_match); - -static struct platform_driver mpc5200_hpcd_of_driver = { - .probe = mpc5200_hpcd_probe, - .remove = mpc5200_hpcd_remove, - .driver = { - .owner = THIS_MODULE, - .name = "mpc5200-pcm-audio", - .of_match_table = mpc5200_hpcd_match, - } -}; - -module_platform_driver(mpc5200_hpcd_of_driver); +EXPORT_SYMBOL_GPL(mpc5200_audio_dma_destroy);
MODULE_AUTHOR("Grant Likely grant.likely@secretlab.ca"); MODULE_DESCRIPTION("Freescale MPC5200 PSC in DMA mode ASoC Driver"); diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index a3c0cd5..dff253f 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -81,4 +81,7 @@ to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma) return &psc_dma->playback; }
+int mpc5200_audio_dma_create(struct platform_device *op); +int mpc5200_audio_dma_destroy(struct platform_device *op); + #endif /* __SOUND_SOC_FSL_MPC5200_DMA_H__ */ diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index ffa00a2..9a09453 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -278,6 +278,10 @@ static int __devinit psc_ac97_of_probe(struct platform_device *op) struct snd_ac97 ac97; struct mpc52xx_psc __iomem *regs;
+ rc = mpc5200_audio_dma_create(op); + if (rc != 0) + return rc; + rc = snd_soc_register_dais(&op->dev, psc_ac97_dai, ARRAY_SIZE(psc_ac97_dai)); if (rc != 0) { dev_err(&op->dev, "Failed to register DAI\n"); @@ -303,6 +307,7 @@ static int __devinit psc_ac97_of_probe(struct platform_device *op)
static int __devexit psc_ac97_of_remove(struct platform_device *op) { + mpc5200_audio_dma_destroy(op); snd_soc_unregister_dais(&op->dev, ARRAY_SIZE(psc_ac97_dai)); return 0; } diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c index 7b53032..c0b7a23 100644 --- a/sound/soc/fsl/mpc5200_psc_i2s.c +++ b/sound/soc/fsl/mpc5200_psc_i2s.c @@ -156,6 +156,10 @@ static int __devinit psc_i2s_of_probe(struct platform_device *op) struct psc_dma *psc_dma; struct mpc52xx_psc __iomem *regs;
+ rc = mpc5200_audio_dma_create(op); + if (rc != 0) + return rc; + rc = snd_soc_register_dais(&op->dev, psc_i2s_dai, ARRAY_SIZE(psc_i2s_dai)); if (rc != 0) { pr_err("Failed to register DAI\n"); @@ -200,6 +204,7 @@ static int __devinit psc_i2s_of_probe(struct platform_device *op)
static int __devexit psc_i2s_of_remove(struct platform_device *op) { + mpc5200_audio_dma_destroy(op); snd_soc_unregister_dais(&op->dev, ARRAY_SIZE(psc_i2s_dai)); return 0; }
Add missing dai_driver information to avoid these runtime errors
[ 16.433788] asoc: error - multiple DAI f0002c00.i2s registered with no name [ 16.453551] Failed to register DAI [ 16.461222] mpc5200-psc-i2s: probe of f0002c00.i2s failed with error -22 [ 16.475242] asoc: error - multiple DAI f0002000.ac97 registered with no name [ 16.488087] mpc5200-psc-ac97 f0002000.ac97: Failed to register DAI [ 16.502222] mpc5200-psc-ac97: probe of f0002000.ac97 failed with error -22
Signed-off-by: Eric Millbrandt emillbrandt@dekaresearch.com
diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index 9a09453..a313c0a 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -237,15 +237,18 @@ static const struct snd_soc_dai_ops psc_ac97_digital_ops = {
static struct snd_soc_dai_driver psc_ac97_dai[] = { { + .name = "mpc5200-psc-ac97.0", .ac97_control = 1, .probe = psc_ac97_probe, .playback = { + .stream_name = "AC97 Playback", .channels_min = 1, .channels_max = 6, .rates = SNDRV_PCM_RATE_8000_48000, .formats = SNDRV_PCM_FMTBIT_S32_BE, }, .capture = { + .stream_name = "AC97 Capture", .channels_min = 1, .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_48000, @@ -254,8 +257,10 @@ static struct snd_soc_dai_driver psc_ac97_dai[] = { .ops = &psc_ac97_analog_ops, }, { + .name = "mpc5200-psc-ac97.1", .ac97_control = 1, .playback = { + .stream_name = "AC97 SPDIF", .channels_min = 1, .channels_max = 2, .rates = SNDRV_PCM_RATE_32000 | \ diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c index c0b7a23..ba1f0a6 100644 --- a/sound/soc/fsl/mpc5200_psc_i2s.c +++ b/sound/soc/fsl/mpc5200_psc_i2s.c @@ -130,13 +130,16 @@ static const struct snd_soc_dai_ops psc_i2s_dai_ops = { };
static struct snd_soc_dai_driver psc_i2s_dai[] = {{ + .name = "mpc5200-psc-i2s.0", .playback = { + .stream_name = "I2S Playback", .channels_min = 2, .channels_max = 2, .rates = PSC_I2S_RATES, .formats = PSC_I2S_FORMATS, }, .capture = { + .stream_name = "I2S Capture", .channels_min = 2, .channels_max = 2, .rates = PSC_I2S_RATES,
Remove unreferenced header files.
Signed-off-by: Eric Millbrandt emillbrandt@dekaresearch.com
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index b3af55d..1353e8f 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -12,22 +12,13 @@
#include <linux/init.h> #include <linux/module.h> -#include <linux/interrupt.h> #include <linux/device.h> -#include <linux/delay.h> #include <linux/of_device.h> #include <linux/of_platform.h> -#include <linux/dma-mapping.h>
-#include <sound/core.h> -#include <sound/pcm.h> -#include <sound/pcm_params.h> -#include <sound/initval.h> #include <sound/soc.h>
#include "mpc5200_dma.h" -#include "mpc5200_psc_ac97.h" -#include "../codecs/wm9712.h"
#define DRV_NAME "pcm030-audio-fabric"
This patch converts the pcm030-audio-fabric driver to a platform-driver and adds a remove function.
Signed-off-by: Eric Millbrandt emillbrandt@dekaresearch.com
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index 1353e8f..5c8e2d6 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -48,7 +48,7 @@ static struct snd_soc_card card = { .num_links = ARRAY_SIZE(pcm030_fabric_dai), };
-static __init int pcm030_fabric_init(void) +static int __init pcm030_fabric_probe(struct platform_device *op) { struct platform_device *pdev; int rc; @@ -62,6 +62,7 @@ static __init int pcm030_fabric_init(void) return -ENODEV; }
+ platform_set_drvdata(op, pdev); platform_set_drvdata(pdev, &card);
rc = platform_device_add(pdev); @@ -73,7 +74,32 @@ static __init int pcm030_fabric_init(void) return 0; }
-module_init(pcm030_fabric_init); +static int __devexit pcm030_fabric_remove(struct platform_device *op) +{ + struct platform_device *pdev = platform_get_drvdata(op); + + platform_device_unregister(pdev); + + return 0; +} + +static struct of_device_id pcm030_audio_match[] = { + { .compatible = "phytec,pcm030-audio-fabric", }, + {} +}; +MODULE_DEVICE_TABLE(of, pcm030_audio_match); + +static struct platform_driver pcm030_fabric_driver = { + .probe = pcm030_fabric_probe, + .remove = __devexit_p(pcm030_fabric_remove), + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + .of_match_table = pcm030_audio_match, + }, +}; + +module_platform_driver(pcm030_fabric_driver);
MODULE_AUTHOR("Jon Smirl jonsmirl@gmail.com");
On Thu, Sep 13, 2012 at 05:43:14PM -0400, Eric Millbrandt wrote:
+static int __devexit pcm030_fabric_remove(struct platform_device *op) +{
- struct platform_device *pdev = platform_get_drvdata(op);
- platform_device_unregister(pdev);
- return 0;
+}
This seems really confused... why is a platform device registering another platform device? Do you mean to convert to snd_soc_register_card()?
On 2012-09-18 Mark Brown wrote:
On Thu, Sep 13, 2012 at 05:43:14PM -0400, Eric Millbrandt wrote:
+static int __devexit pcm030_fabric_remove(struct platform_device *op) +{ + struct platform_device *pdev = platform_get_drvdata(op); +
- platform_device_unregister(pdev); + + return 0; +}
This seems really confused... why is a platform device registering another platform device? Do you mean to convert to snd_soc_register_card()?
That was an artifact of me splitting the changes to pcm030-audio-fabric.c into multiple patches. I changed the driver to a platform device in this patch and converted to snd_soc_register_card() in the next patch. I can merge the two patches back together if you think that is cleaner and easier to understand.
Thanks Eric
-DISCLAIMER: an automatically appended disclaimer may follow. By posting- -to a public e-mail mailing list I hereby grant permission to distribute- -and copy this message.-
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
Thank you.
Please consider the environment before printing this email.
On Wed, Sep 19, 2012 at 10:35:45AM -0400, Eric Millbrandt wrote:
That was an artifact of me splitting the changes to pcm030-audio-fabric.c into multiple patches. I changed the driver to a platform device in this patch and converted to snd_soc_register_card() in the next patch. I can merge the two patches back together if you think that is cleaner and easier to understand.
Yes, please.
This patch converts pcm030-audio-fabric to use the new snd_soc_register_card ASoC api instead of the older method of registering a separate platform device. It also creates the dai_link to the mpc5200_psc_ac97 platform using the device tree.
Signed-off-by: Eric Millbrandt emillbrandt@dekaresearch.com
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index 5c8e2d6..893e240 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -28,7 +28,6 @@ static struct snd_soc_dai_link pcm030_fabric_dai[] = { .stream_name = "AC97 Analog", .codec_dai_name = "wm9712-hifi", .cpu_dai_name = "mpc5200-psc-ac97.0", - .platform_name = "mpc5200-pcm-audio", .codec_name = "wm9712-codec", }, { @@ -36,12 +35,11 @@ static struct snd_soc_dai_link pcm030_fabric_dai[] = { .stream_name = "AC97 IEC958", .codec_dai_name = "wm9712-aux", .cpu_dai_name = "mpc5200-psc-ac97.1", - .platform_name = "mpc5200-pcm-audio", .codec_name = "wm9712-codec", }, };
-static struct snd_soc_card card = { +static struct snd_soc_card pcm030_card = { .name = "pcm030", .owner = THIS_MODULE, .dai_link = pcm030_fabric_dai, @@ -50,37 +48,42 @@ static struct snd_soc_card card = {
static int __init pcm030_fabric_probe(struct platform_device *op) { - struct platform_device *pdev; - int rc; + struct device_node *np = op->dev.of_node; + struct device_node *platform_np; + struct snd_soc_card *card = &pcm030_card; + int ret; + int i;
if (!of_machine_is_compatible("phytec,pcm030")) return -ENODEV;
- pdev = platform_device_alloc("soc-audio", 1); - if (!pdev) { - pr_err("pcm030_fabric_init: platform_device_alloc() failed\n"); + card->dev = &op->dev; + platform_set_drvdata(op, card); + + platform_np = of_parse_phandle(np, "asoc-platform", 0); + if (!platform_np) { + dev_err(&op->dev, "ac97 not registered\n"); return -ENODEV; }
- platform_set_drvdata(op, pdev); - platform_set_drvdata(pdev, &card); + for (i = 0; i < card->num_links; i++) + card->dai_link[i].platform_of_node = platform_np;
- rc = platform_device_add(pdev); - if (rc) { - pr_err("pcm030_fabric_init: platform_device_add() failed\n"); - platform_device_put(pdev); - return -ENODEV; - } - return 0; + ret = snd_soc_register_card(card); + if (ret) + dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); + + return ret; }
static int __devexit pcm030_fabric_remove(struct platform_device *op) { - struct platform_device *pdev = platform_get_drvdata(op); + struct snd_soc_card *card = platform_get_drvdata(op); + int ret;
- platform_device_unregister(pdev); + ret = snd_soc_unregister_card(card);
- return 0; + return ret; }
static struct of_device_id pcm030_audio_match[] = {
The mpc5200-psc-ac97 driver does not enumerate attached ac97 devices, so register the device here.
Signed-off-by: Eric Millbrandt emillbrandt@dekaresearch.com
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index 893e240..4b63ec8 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c @@ -22,6 +22,11 @@
#define DRV_NAME "pcm030-audio-fabric"
+struct pcm030_audio_data { + struct snd_soc_card *card; + struct platform_device *codec_device; +}; + static struct snd_soc_dai_link pcm030_fabric_dai[] = { { .name = "AC97", @@ -51,14 +56,22 @@ static int __init pcm030_fabric_probe(struct platform_device *op) struct device_node *np = op->dev.of_node; struct device_node *platform_np; struct snd_soc_card *card = &pcm030_card; + struct pcm030_audio_data *pdata; int ret; int i;
if (!of_machine_is_compatible("phytec,pcm030")) return -ENODEV;
+ pdata = devm_kzalloc(&op->dev, sizeof(struct pcm030_audio_data), + GFP_KERNEL); + if (!pdata) + return -ENOMEM; + card->dev = &op->dev; - platform_set_drvdata(op, card); + platform_set_drvdata(op, pdata); + + pdata->card = card;
platform_np = of_parse_phandle(np, "asoc-platform", 0); if (!platform_np) { @@ -69,6 +82,18 @@ static int __init pcm030_fabric_probe(struct platform_device *op) for (i = 0; i < card->num_links; i++) card->dai_link[i].platform_of_node = platform_np;
+ ret = request_module("snd-soc-wm9712"); + if (ret) + dev_err(&op->dev, "request_module returned: %d\n", ret); + + pdata->codec_device = platform_device_alloc("wm9712-codec", -1); + if (!pdata->codec_device) + dev_err(&op->dev, "platform_device_alloc() failed\n"); + + ret = platform_device_add(pdata->codec_device); + if (ret) + dev_err(&op->dev, "platform_device_add() failed: %d\n", ret); + ret = snd_soc_register_card(card); if (ret) dev_err(&op->dev, "snd_soc_register_card() failed: %d\n", ret); @@ -78,10 +103,11 @@ static int __init pcm030_fabric_probe(struct platform_device *op)
static int __devexit pcm030_fabric_remove(struct platform_device *op) { - struct snd_soc_card *card = platform_get_drvdata(op); + struct pcm030_audio_data *pdata = platform_get_drvdata(op); int ret;
- ret = snd_soc_unregister_card(card); + ret = snd_soc_unregister_card(pdata->card); + platform_device_unregister(pdata->codec_device);
return ret; }
participants (2)
-
Eric Millbrandt
-
Mark Brown