aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/ep93xx/edb93xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/ep93xx/edb93xx.c')
-rw-r--r--sound/soc/ep93xx/edb93xx.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/sound/soc/ep93xx/edb93xx.c b/sound/soc/ep93xx/edb93xx.c
index d3aa15119d2..51930b6a83a 100644
--- a/sound/soc/ep93xx/edb93xx.c
+++ b/sound/soc/ep93xx/edb93xx.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/module.h>
24#include <sound/core.h> 25#include <sound/core.h>
25#include <sound/pcm.h> 26#include <sound/pcm.h>
26#include <sound/soc.h> 27#include <sound/soc.h>
@@ -28,12 +29,6 @@
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include "ep93xx-pcm.h" 30#include "ep93xx-pcm.h"
30 31
31#define edb93xx_has_audio() (machine_is_edb9301() || \
32 machine_is_edb9302() || \
33 machine_is_edb9302a() || \
34 machine_is_edb9307a() || \
35 machine_is_edb9315a())
36
37static int edb93xx_hw_params(struct snd_pcm_substream *substream, 32static int edb93xx_hw_params(struct snd_pcm_substream *substream,
38 struct snd_pcm_hw_params *params) 33 struct snd_pcm_hw_params *params)
39{ 34{
@@ -94,49 +89,61 @@ static struct snd_soc_card snd_soc_edb93xx = {
94 .num_links = 1, 89 .num_links = 1,
95}; 90};
96 91
97static struct platform_device *edb93xx_snd_device; 92static int __devinit edb93xx_probe(struct platform_device *pdev)
98
99static int __init edb93xx_init(void)
100{ 93{
94 struct snd_soc_card *card = &snd_soc_edb93xx;
101 int ret; 95 int ret;
102 96
103 if (!edb93xx_has_audio())
104 return -ENODEV;
105
106 ret = ep93xx_i2s_acquire(EP93XX_SYSCON_DEVCFG_I2SONAC97, 97 ret = ep93xx_i2s_acquire(EP93XX_SYSCON_DEVCFG_I2SONAC97,
107 EP93XX_SYSCON_I2SCLKDIV_ORIDE | 98 EP93XX_SYSCON_I2SCLKDIV_ORIDE |
108 EP93XX_SYSCON_I2SCLKDIV_SPOL); 99 EP93XX_SYSCON_I2SCLKDIV_SPOL);
109 if (ret) 100 if (ret)
110 return ret; 101 return ret;
111 102
112 edb93xx_snd_device = platform_device_alloc("soc-audio", -1); 103 card->dev = &pdev->dev;
113 if (!edb93xx_snd_device) { 104
114 ret = -ENOMEM; 105 ret = snd_soc_register_card(card);
115 goto free_i2s; 106 if (ret) {
107 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
108 ret);
109 ep93xx_i2s_release();
116 } 110 }
117 111
118 platform_set_drvdata(edb93xx_snd_device, &snd_soc_edb93xx); 112 return ret;
119 ret = platform_device_add(edb93xx_snd_device); 113}
120 if (ret)
121 goto device_put;
122 114
123 return 0; 115static int __devexit edb93xx_remove(struct platform_device *pdev)
116{
117 struct snd_soc_card *card = platform_get_drvdata(pdev);
124 118
125device_put: 119 snd_soc_unregister_card(card);
126 platform_device_put(edb93xx_snd_device);
127free_i2s:
128 ep93xx_i2s_release(); 120 ep93xx_i2s_release();
129 return ret; 121
122 return 0;
123}
124
125static struct platform_driver edb93xx_driver = {
126 .driver = {
127 .name = "edb93xx-audio",
128 .owner = THIS_MODULE,
129 },
130 .probe = edb93xx_probe,
131 .remove = __devexit_p(edb93xx_remove),
132};
133
134static int __init edb93xx_init(void)
135{
136 return platform_driver_register(&edb93xx_driver);
130} 137}
131module_init(edb93xx_init); 138module_init(edb93xx_init);
132 139
133static void __exit edb93xx_exit(void) 140static void __exit edb93xx_exit(void)
134{ 141{
135 platform_device_unregister(edb93xx_snd_device); 142 platform_driver_unregister(&edb93xx_driver);
136 ep93xx_i2s_release();
137} 143}
138module_exit(edb93xx_exit); 144module_exit(edb93xx_exit);
139 145
140MODULE_AUTHOR("Alexander Sverdlin <subaparts@yandex.ru>"); 146MODULE_AUTHOR("Alexander Sverdlin <subaparts@yandex.ru>");
141MODULE_DESCRIPTION("ALSA SoC EDB93xx"); 147MODULE_DESCRIPTION("ALSA SoC EDB93xx");
142MODULE_LICENSE("GPL"); 148MODULE_LICENSE("GPL");
149MODULE_ALIAS("platform:edb93xx-audio");