Skip to content

Commit c912fa9

Browse files
Eric Millbrandtbroonie
authored andcommitted
ASoC: fsl: register the wm9712-codec
The mpc5200-psc-ac97 driver does not enumerate attached ac97 devices, so register the device here. Signed-off-by: Eric Millbrandt <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 0840116 commit c912fa9

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

sound/soc/fsl/pcm030-audio-fabric.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
#define DRV_NAME "pcm030-audio-fabric"
2424

25+
struct pcm030_audio_data {
26+
struct snd_soc_card *card;
27+
struct platform_device *codec_device;
28+
};
29+
2530
static struct snd_soc_dai_link pcm030_fabric_dai[] = {
2631
{
2732
.name = "AC97",
@@ -51,14 +56,22 @@ static int __init pcm030_fabric_probe(struct platform_device *op)
5156
struct device_node *np = op->dev.of_node;
5257
struct device_node *platform_np;
5358
struct snd_soc_card *card = &pcm030_card;
59+
struct pcm030_audio_data *pdata;
5460
int ret;
5561
int i;
5662

5763
if (!of_machine_is_compatible("phytec,pcm030"))
5864
return -ENODEV;
5965

66+
pdata = devm_kzalloc(&op->dev, sizeof(struct pcm030_audio_data),
67+
GFP_KERNEL);
68+
if (!pdata)
69+
return -ENOMEM;
70+
6071
card->dev = &op->dev;
61-
platform_set_drvdata(op, card);
72+
platform_set_drvdata(op, pdata);
73+
74+
pdata->card = card;
6275

6376
platform_np = of_parse_phandle(np, "asoc-platform", 0);
6477
if (!platform_np) {
@@ -69,6 +82,18 @@ static int __init pcm030_fabric_probe(struct platform_device *op)
6982
for (i = 0; i < card->num_links; i++)
7083
card->dai_link[i].platform_of_node = platform_np;
7184

85+
ret = request_module("snd-soc-wm9712");
86+
if (ret)
87+
dev_err(&op->dev, "request_module returned: %d\n", ret);
88+
89+
pdata->codec_device = platform_device_alloc("wm9712-codec", -1);
90+
if (!pdata->codec_device)
91+
dev_err(&op->dev, "platform_device_alloc() failed\n");
92+
93+
ret = platform_device_add(pdata->codec_device);
94+
if (ret)
95+
dev_err(&op->dev, "platform_device_add() failed: %d\n", ret);
96+
7297
ret = snd_soc_register_card(card);
7398
if (ret)
7499
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)
78103

79104
static int __devexit pcm030_fabric_remove(struct platform_device *op)
80105
{
81-
struct snd_soc_card *card = platform_get_drvdata(op);
106+
struct pcm030_audio_data *pdata = platform_get_drvdata(op);
82107
int ret;
83108

84-
ret = snd_soc_unregister_card(card);
109+
ret = snd_soc_unregister_card(pdata->card);
110+
platform_device_unregister(pdata->codec_device);
85111

86112
return ret;
87113
}

0 commit comments

Comments
 (0)