diff options
author | Robert Jarzmik <robert.jarzmik@free.fr> | 2017-09-13 15:37:22 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-09-19 12:09:36 -0400 |
commit | aaafcfed9290349555a326fff1147460a54c34f2 (patch) | |
tree | 962478cef613000b89f9f3b148faaa0e059b7c1b | |
parent | c6e46e52b7b3301dda529830226e578cf773151c (diff) |
ASoC: wm9705: add ac97 new bus support
Add support for the new ac97 bus model, where devices are automatically
discovered on AC-Links.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/Kconfig | 3 | ||||
-rw-r--r-- | sound/soc/codecs/wm9705.c | 42 |
2 files changed, 31 insertions, 14 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 655388d456be..0838ae710941 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -214,7 +214,7 @@ config SND_SOC_ALL_CODECS | |||
214 | select SND_SOC_WM8998 if MFD_WM8998 | 214 | select SND_SOC_WM8998 if MFD_WM8998 |
215 | select SND_SOC_WM9081 if I2C | 215 | select SND_SOC_WM9081 if I2C |
216 | select SND_SOC_WM9090 if I2C | 216 | select SND_SOC_WM9090 if I2C |
217 | select SND_SOC_WM9705 if SND_SOC_AC97_BUS | 217 | select SND_SOC_WM9705 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) |
218 | select SND_SOC_WM9712 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) | 218 | select SND_SOC_WM9712 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) |
219 | select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) | 219 | select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) |
220 | help | 220 | help |
@@ -1128,6 +1128,7 @@ config SND_SOC_WM9090 | |||
1128 | config SND_SOC_WM9705 | 1128 | config SND_SOC_WM9705 |
1129 | tristate | 1129 | tristate |
1130 | select REGMAP_AC97 | 1130 | select REGMAP_AC97 |
1131 | select AC97_BUS_COMPAT if AC97_BUS_NEW | ||
1131 | 1132 | ||
1132 | config SND_SOC_WM9712 | 1133 | config SND_SOC_WM9712 |
1133 | tristate | 1134 | tristate |
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index 08477d040028..68c204e3599f 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/mfd/wm97xx.h> | ||
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
16 | #include <linux/device.h> | 17 | #include <linux/device.h> |
@@ -18,6 +19,8 @@ | |||
18 | #include <sound/core.h> | 19 | #include <sound/core.h> |
19 | #include <sound/pcm.h> | 20 | #include <sound/pcm.h> |
20 | #include <sound/ac97_codec.h> | 21 | #include <sound/ac97_codec.h> |
22 | #include <sound/ac97/codec.h> | ||
23 | #include <sound/ac97/compat.h> | ||
21 | #include <sound/initval.h> | 24 | #include <sound/initval.h> |
22 | #include <sound/soc.h> | 25 | #include <sound/soc.h> |
23 | 26 | ||
@@ -26,6 +29,7 @@ | |||
26 | 29 | ||
27 | struct wm9705_priv { | 30 | struct wm9705_priv { |
28 | struct snd_ac97 *ac97; | 31 | struct snd_ac97 *ac97; |
32 | struct wm97xx_platform_data *mfd_pdata; | ||
29 | }; | 33 | }; |
30 | 34 | ||
31 | static const struct reg_default wm9705_reg_defaults[] = { | 35 | static const struct reg_default wm9705_reg_defaults[] = { |
@@ -319,17 +323,24 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec) | |||
319 | struct regmap *regmap; | 323 | struct regmap *regmap; |
320 | int ret; | 324 | int ret; |
321 | 325 | ||
322 | wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, | 326 | if (wm9705->mfd_pdata) { |
323 | WM9705_VENDOR_ID_MASK); | 327 | wm9705->ac97 = wm9705->mfd_pdata->ac97; |
324 | if (IS_ERR(wm9705->ac97)) { | 328 | regmap = wm9705->mfd_pdata->regmap; |
325 | dev_err(codec->dev, "Failed to register AC97 codec\n"); | 329 | } else { |
326 | return PTR_ERR(wm9705->ac97); | 330 | #ifdef CONFIG_SND_SOC_AC97_BUS |
327 | } | 331 | wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, |
328 | 332 | WM9705_VENDOR_ID_MASK); | |
329 | regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); | 333 | if (IS_ERR(wm9705->ac97)) { |
330 | if (IS_ERR(regmap)) { | 334 | dev_err(codec->dev, "Failed to register AC97 codec\n"); |
331 | ret = PTR_ERR(regmap); | 335 | return PTR_ERR(wm9705->ac97); |
332 | goto err_free_ac97_codec; | 336 | } |
337 | |||
338 | regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); | ||
339 | if (IS_ERR(regmap)) { | ||
340 | ret = PTR_ERR(regmap); | ||
341 | goto err_free_ac97_codec; | ||
342 | } | ||
343 | #endif | ||
333 | } | 344 | } |
334 | 345 | ||
335 | snd_soc_codec_set_drvdata(codec, wm9705->ac97); | 346 | snd_soc_codec_set_drvdata(codec, wm9705->ac97); |
@@ -343,10 +354,14 @@ err_free_ac97_codec: | |||
343 | 354 | ||
344 | static int wm9705_soc_remove(struct snd_soc_codec *codec) | 355 | static int wm9705_soc_remove(struct snd_soc_codec *codec) |
345 | { | 356 | { |
357 | #ifdef CONFIG_SND_SOC_AC97_BUS | ||
346 | struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); | 358 | struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); |
347 | 359 | ||
348 | snd_soc_codec_exit_regmap(codec); | 360 | if (!wm9705->mfd_pdata) { |
349 | snd_soc_free_ac97_codec(wm9705->ac97); | 361 | snd_soc_codec_exit_regmap(codec); |
362 | snd_soc_free_ac97_codec(wm9705->ac97); | ||
363 | } | ||
364 | #endif | ||
350 | return 0; | 365 | return 0; |
351 | } | 366 | } |
352 | 367 | ||
@@ -374,6 +389,7 @@ static int wm9705_probe(struct platform_device *pdev) | |||
374 | if (wm9705 == NULL) | 389 | if (wm9705 == NULL) |
375 | return -ENOMEM; | 390 | return -ENOMEM; |
376 | 391 | ||
392 | wm9705->mfd_pdata = dev_get_platdata(&pdev->dev); | ||
377 | platform_set_drvdata(pdev, wm9705); | 393 | platform_set_drvdata(pdev, wm9705); |
378 | 394 | ||
379 | return snd_soc_register_codec(&pdev->dev, | 395 | return snd_soc_register_codec(&pdev->dev, |