diff options
Diffstat (limited to 'sound/soc/au1x/db1200.c')
-rw-r--r-- | sound/soc/au1x/db1200.c | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/sound/soc/au1x/db1200.c b/sound/soc/au1x/db1200.c index 1d3e258c9ea8..289312c14b99 100644 --- a/sound/soc/au1x/db1200.c +++ b/sound/soc/au1x/db1200.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * DB1200 ASoC audio fabric support code. | 2 | * DB1200 ASoC audio fabric support code. |
3 | * | 3 | * |
4 | * (c) 2008-9 Manuel Lauss <manuel.lauss@gmail.com> | 4 | * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com> |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | 7 | ||
@@ -21,6 +21,17 @@ | |||
21 | #include "../codecs/wm8731.h" | 21 | #include "../codecs/wm8731.h" |
22 | #include "psc.h" | 22 | #include "psc.h" |
23 | 23 | ||
24 | static struct platform_device_id db1200_pids[] = { | ||
25 | { | ||
26 | .name = "db1200-ac97", | ||
27 | .driver_data = 0, | ||
28 | }, { | ||
29 | .name = "db1200-i2s", | ||
30 | .driver_data = 1, | ||
31 | }, | ||
32 | {}, | ||
33 | }; | ||
34 | |||
24 | /*------------------------- AC97 PART ---------------------------*/ | 35 | /*------------------------- AC97 PART ---------------------------*/ |
25 | 36 | ||
26 | static struct snd_soc_dai_link db1200_ac97_dai = { | 37 | static struct snd_soc_dai_link db1200_ac97_dai = { |
@@ -89,36 +100,47 @@ static struct snd_soc_card db1200_i2s_machine = { | |||
89 | 100 | ||
90 | /*------------------------- COMMON PART ---------------------------*/ | 101 | /*------------------------- COMMON PART ---------------------------*/ |
91 | 102 | ||
92 | static struct platform_device *db1200_asoc_dev; | 103 | static struct snd_soc_card *db1200_cards[] __devinitdata = { |
104 | &db1200_ac97_machine, | ||
105 | &db1200_i2s_machine, | ||
106 | }; | ||
93 | 107 | ||
94 | static int __init db1200_audio_load(void) | 108 | static int __devinit db1200_audio_probe(struct platform_device *pdev) |
95 | { | 109 | { |
96 | int ret; | 110 | const struct platform_device_id *pid = platform_get_device_id(pdev); |
111 | struct snd_soc_card *card; | ||
97 | 112 | ||
98 | ret = -ENOMEM; | 113 | card = db1200_cards[pid->driver_data]; |
99 | db1200_asoc_dev = platform_device_alloc("soc-audio", 1); /* PSC1 */ | 114 | card->dev = &pdev->dev; |
100 | if (!db1200_asoc_dev) | 115 | return snd_soc_register_card(card); |
101 | goto out; | 116 | } |
102 | 117 | ||
103 | /* DB1200 board setup set PSC1MUX to preferred audio device */ | 118 | static int __devexit db1200_audio_remove(struct platform_device *pdev) |
104 | if (bcsr_read(BCSR_RESETS) & BCSR_RESETS_PSC1MUX) | 119 | { |
105 | platform_set_drvdata(db1200_asoc_dev, &db1200_i2s_machine); | 120 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
106 | else | 121 | snd_soc_unregister_card(card); |
107 | platform_set_drvdata(db1200_asoc_dev, &db1200_ac97_machine); | 122 | return 0; |
123 | } | ||
108 | 124 | ||
109 | ret = platform_device_add(db1200_asoc_dev); | 125 | static struct platform_driver db1200_audio_driver = { |
126 | .driver = { | ||
127 | .name = "db1200-ac97", | ||
128 | .owner = THIS_MODULE, | ||
129 | .pm = &snd_soc_pm_ops, | ||
130 | }, | ||
131 | .id_table = db1200_pids, | ||
132 | .probe = db1200_audio_probe, | ||
133 | .remove = __devexit_p(db1200_audio_remove), | ||
134 | }; | ||
110 | 135 | ||
111 | if (ret) { | 136 | static int __init db1200_audio_load(void) |
112 | platform_device_put(db1200_asoc_dev); | 137 | { |
113 | db1200_asoc_dev = NULL; | 138 | return platform_driver_register(&db1200_audio_driver); |
114 | } | ||
115 | out: | ||
116 | return ret; | ||
117 | } | 139 | } |
118 | 140 | ||
119 | static void __exit db1200_audio_unload(void) | 141 | static void __exit db1200_audio_unload(void) |
120 | { | 142 | { |
121 | platform_device_unregister(db1200_asoc_dev); | 143 | platform_driver_unregister(&db1200_audio_driver); |
122 | } | 144 | } |
123 | 145 | ||
124 | module_init(db1200_audio_load); | 146 | module_init(db1200_audio_load); |