diff options
author | Robert Jarzmik <robert.jarzmik@free.fr> | 2017-09-13 15:37:20 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-09-19 12:09:35 -0400 |
commit | 2ed1a8e0ce8db6d36f849526db61ce3c85a9f8d1 (patch) | |
tree | 9e34c781ff820bcccb6dae247972a779d5eab496 | |
parent | 9bd400cadae05a26c3a22dd8393081cb96d0e26a (diff) |
ASoC: wm9712: 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>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/Kconfig | 3 | ||||
-rw-r--r-- | sound/soc/codecs/wm9712.c | 44 |
2 files changed, 32 insertions, 15 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 807901cac1b3..655388d456be 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -215,7 +215,7 @@ config SND_SOC_ALL_CODECS | |||
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 |
218 | select SND_SOC_WM9712 if SND_SOC_AC97_BUS | 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 |
221 | Normally ASoC codec drivers are only built if a machine driver which | 221 | Normally ASoC codec drivers are only built if a machine driver which |
@@ -1132,6 +1132,7 @@ config SND_SOC_WM9705 | |||
1132 | config SND_SOC_WM9712 | 1132 | config SND_SOC_WM9712 |
1133 | tristate | 1133 | tristate |
1134 | select REGMAP_AC97 | 1134 | select REGMAP_AC97 |
1135 | select AC97_BUS_COMPAT if AC97_BUS_NEW | ||
1135 | 1136 | ||
1136 | config SND_SOC_WM9713 | 1137 | config SND_SOC_WM9713 |
1137 | tristate | 1138 | tristate |
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 1a3e1797994a..1e228bf9f1ae 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/mfd/wm97xx.h> | ||
15 | #include <linux/module.h> | 16 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
17 | #include <linux/device.h> | 18 | #include <linux/device.h> |
@@ -19,6 +20,8 @@ | |||
19 | #include <sound/core.h> | 20 | #include <sound/core.h> |
20 | #include <sound/pcm.h> | 21 | #include <sound/pcm.h> |
21 | #include <sound/ac97_codec.h> | 22 | #include <sound/ac97_codec.h> |
23 | #include <sound/ac97/codec.h> | ||
24 | #include <sound/ac97/compat.h> | ||
22 | #include <sound/initval.h> | 25 | #include <sound/initval.h> |
23 | #include <sound/soc.h> | 26 | #include <sound/soc.h> |
24 | #include <sound/tlv.h> | 27 | #include <sound/tlv.h> |
@@ -30,6 +33,7 @@ struct wm9712_priv { | |||
30 | struct snd_ac97 *ac97; | 33 | struct snd_ac97 *ac97; |
31 | unsigned int hp_mixer[2]; | 34 | unsigned int hp_mixer[2]; |
32 | struct mutex lock; | 35 | struct mutex lock; |
36 | struct wm97xx_platform_data *mfd_pdata; | ||
33 | }; | 37 | }; |
34 | 38 | ||
35 | static const struct reg_default wm9712_reg_defaults[] = { | 39 | static const struct reg_default wm9712_reg_defaults[] = { |
@@ -636,18 +640,25 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) | |||
636 | struct regmap *regmap; | 640 | struct regmap *regmap; |
637 | int ret; | 641 | int ret; |
638 | 642 | ||
639 | wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID, | 643 | if (wm9712->mfd_pdata) { |
640 | WM9712_VENDOR_ID_MASK); | 644 | wm9712->ac97 = wm9712->mfd_pdata->ac97; |
641 | if (IS_ERR(wm9712->ac97)) { | 645 | regmap = wm9712->mfd_pdata->regmap; |
642 | ret = PTR_ERR(wm9712->ac97); | 646 | } else { |
643 | dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); | 647 | #ifdef CONFIG_SND_SOC_AC97_BUS |
644 | return ret; | 648 | wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID, |
645 | } | 649 | WM9712_VENDOR_ID_MASK); |
646 | 650 | if (IS_ERR(wm9712->ac97)) { | |
647 | regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config); | 651 | ret = PTR_ERR(wm9712->ac97); |
648 | if (IS_ERR(regmap)) { | 652 | dev_err(codec->dev, |
649 | ret = PTR_ERR(regmap); | 653 | "Failed to register AC97 codec: %d\n", ret); |
650 | goto err_free_ac97_codec; | 654 | return ret; |
655 | } | ||
656 | |||
657 | regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config); | ||
658 | if (IS_ERR(regmap)) { | ||
659 | ret = PTR_ERR(regmap); | ||
660 | goto err_free_ac97_codec; | ||
661 | #endif | ||
651 | } | 662 | } |
652 | 663 | ||
653 | snd_soc_codec_init_regmap(codec, regmap); | 664 | snd_soc_codec_init_regmap(codec, regmap); |
@@ -663,10 +674,14 @@ err_free_ac97_codec: | |||
663 | 674 | ||
664 | static int wm9712_soc_remove(struct snd_soc_codec *codec) | 675 | static int wm9712_soc_remove(struct snd_soc_codec *codec) |
665 | { | 676 | { |
677 | #ifdef CONFIG_SND_SOC_AC97_BUS | ||
666 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); | 678 | struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); |
667 | 679 | ||
668 | snd_soc_codec_exit_regmap(codec); | 680 | if (!wm9712->mfd_pdata) { |
669 | snd_soc_free_ac97_codec(wm9712->ac97); | 681 | snd_soc_codec_exit_regmap(codec); |
682 | snd_soc_free_ac97_codec(wm9712->ac97); | ||
683 | } | ||
684 | #endif | ||
670 | return 0; | 685 | return 0; |
671 | } | 686 | } |
672 | 687 | ||
@@ -697,6 +712,7 @@ static int wm9712_probe(struct platform_device *pdev) | |||
697 | 712 | ||
698 | mutex_init(&wm9712->lock); | 713 | mutex_init(&wm9712->lock); |
699 | 714 | ||
715 | wm9712->mfd_pdata = dev_get_platdata(&pdev->dev); | ||
700 | platform_set_drvdata(pdev, wm9712); | 716 | platform_set_drvdata(pdev, wm9712); |
701 | 717 | ||
702 | return snd_soc_register_codec(&pdev->dev, | 718 | return snd_soc_register_codec(&pdev->dev, |