diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/atmel-ssc.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 0516ecda54d3..b2a0340f277e 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c | |||
@@ -20,6 +20,8 @@ | |||
20 | 20 | ||
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | 22 | ||
23 | #include "../../sound/soc/atmel/atmel_ssc_dai.h" | ||
24 | |||
23 | /* Serialize access to ssc_list and user count */ | 25 | /* Serialize access to ssc_list and user count */ |
24 | static DEFINE_SPINLOCK(user_lock); | 26 | static DEFINE_SPINLOCK(user_lock); |
25 | static LIST_HEAD(ssc_list); | 27 | static LIST_HEAD(ssc_list); |
@@ -145,6 +147,49 @@ static inline const struct atmel_ssc_platform_data * __init | |||
145 | platform_get_device_id(pdev)->driver_data; | 147 | platform_get_device_id(pdev)->driver_data; |
146 | } | 148 | } |
147 | 149 | ||
150 | #ifdef CONFIG_SND_ATMEL_SOC_SSC | ||
151 | static int ssc_sound_dai_probe(struct ssc_device *ssc) | ||
152 | { | ||
153 | struct device_node *np = ssc->pdev->dev.of_node; | ||
154 | int ret; | ||
155 | int id; | ||
156 | |||
157 | ssc->sound_dai = false; | ||
158 | |||
159 | if (!of_property_read_bool(np, "#sound-dai-cells")) | ||
160 | return 0; | ||
161 | |||
162 | id = of_alias_get_id(np, "ssc"); | ||
163 | if (id < 0) | ||
164 | return id; | ||
165 | |||
166 | ret = atmel_ssc_set_audio(id); | ||
167 | ssc->sound_dai = !ret; | ||
168 | |||
169 | return ret; | ||
170 | } | ||
171 | |||
172 | static void ssc_sound_dai_remove(struct ssc_device *ssc) | ||
173 | { | ||
174 | if (!ssc->sound_dai) | ||
175 | return; | ||
176 | |||
177 | atmel_ssc_put_audio(of_alias_get_id(ssc->pdev->dev.of_node, "ssc")); | ||
178 | } | ||
179 | #else | ||
180 | static inline int ssc_sound_dai_probe(struct ssc_device *ssc) | ||
181 | { | ||
182 | if (of_property_read_bool(ssc->pdev->dev.of_node, "#sound-dai-cells")) | ||
183 | return -ENOTSUPP; | ||
184 | |||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | static inline void ssc_sound_dai_remove(struct ssc_device *ssc) | ||
189 | { | ||
190 | } | ||
191 | #endif | ||
192 | |||
148 | static int ssc_probe(struct platform_device *pdev) | 193 | static int ssc_probe(struct platform_device *pdev) |
149 | { | 194 | { |
150 | struct resource *regs; | 195 | struct resource *regs; |
@@ -204,6 +249,9 @@ static int ssc_probe(struct platform_device *pdev) | |||
204 | dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n", | 249 | dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n", |
205 | ssc->regs, ssc->irq); | 250 | ssc->regs, ssc->irq); |
206 | 251 | ||
252 | if (ssc_sound_dai_probe(ssc)) | ||
253 | dev_err(&pdev->dev, "failed to auto-setup ssc for audio\n"); | ||
254 | |||
207 | return 0; | 255 | return 0; |
208 | } | 256 | } |
209 | 257 | ||
@@ -211,6 +259,8 @@ static int ssc_remove(struct platform_device *pdev) | |||
211 | { | 259 | { |
212 | struct ssc_device *ssc = platform_get_drvdata(pdev); | 260 | struct ssc_device *ssc = platform_get_drvdata(pdev); |
213 | 261 | ||
262 | ssc_sound_dai_remove(ssc); | ||
263 | |||
214 | spin_lock(&user_lock); | 264 | spin_lock(&user_lock); |
215 | list_del(&ssc->list); | 265 | list_del(&ssc->list); |
216 | spin_unlock(&user_lock); | 266 | spin_unlock(&user_lock); |