From patchwork Fri May 27 20:26:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Jarzmik X-Patchwork-Id: 9138965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3287660221 for ; Fri, 27 May 2016 20:29:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B4082830A for ; Fri, 27 May 2016 20:29:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BDAD28302; Fri, 27 May 2016 20:29:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=2.0 tests=BAYES_00,FREEMAIL_FROM, FSL_HELO_HOME,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9322628300 for ; Fri, 27 May 2016 20:29:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b6OMl-0000Ie-S6; Fri, 27 May 2016 20:28:19 +0000 Received: from smtp12.smtpout.orange.fr ([80.12.242.134] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b6OMG-00006X-S6 for linux-arm-kernel@lists.infradead.org; Fri, 27 May 2016 20:27:51 +0000 Received: from belgarion.home ([109.222.221.176]) by mwinf5d23 with ME id zYTJ1s00H3oxeSt03YTSpG; Fri, 27 May 2016 22:27:27 +0200 X-ME-Helo: belgarion.home X-ME-Date: Fri, 27 May 2016 22:27:27 +0200 X-ME-IP: 109.222.221.176 From: Robert Jarzmik To: Robert Jarzmik , Daniel Mack , Haojian Zhuang , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown Subject: [RFC PATCH v2 4/7] ASoC: wm9713: add ac97 new bus support Date: Fri, 27 May 2016 22:26:56 +0200 Message-Id: <1464380819-19075-5-git-send-email-robert.jarzmik@free.fr> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464380819-19075-1-git-send-email-robert.jarzmik@free.fr> References: <1464380819-19075-1-git-send-email-robert.jarzmik@free.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160527_132749_430332_5366A244 X-CRM114-Status: GOOD ( 15.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for the new ac97 bus model, where devices are automatically discovered on AC-Links. Signed-off-by: Robert Jarzmik --- sound/soc/codecs/Kconfig | 1 + sound/soc/codecs/wm9713.c | 62 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 649e92a252ae..2566962c990e 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -977,6 +977,7 @@ config SND_SOC_WM9712 config SND_SOC_WM9713 tristate select REGMAP_AC97 + select AC97_BUS_COMPAT # Amp config SND_SOC_LM4857 diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 9849643ef809..6cbbf4eda5fc 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -1207,14 +1208,13 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct regmap *regmap; - wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID, - WM9713_VENDOR_ID_MASK); + wm9713->ac97 = compat_alloc_snd_ac97_codec(codec); if (IS_ERR(wm9713->ac97)) return PTR_ERR(wm9713->ac97); regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9713->ac97); + compat_release_snd_ac97_codec(wm9713->ac97); return PTR_ERR(regmap); } @@ -1231,7 +1231,7 @@ static int wm9713_soc_remove(struct snd_soc_codec *codec) struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9713->ac97); + compat_release_snd_ac97_codec(wm9713->ac97); return 0; } @@ -1281,7 +1281,57 @@ static struct platform_driver wm9713_codec_driver = { .remove = wm9713_remove, }; -module_platform_driver(wm9713_codec_driver); +static int wm9713_ac97_probe(struct ac97_codec_device *adev) +{ + struct wm9713_priv *wm9713; + + wm9713 = devm_kzalloc(ac97_codec_dev2dev(adev), + sizeof(*wm9713), GFP_KERNEL); + if (wm9713 == NULL) + return -ENOMEM; + + mutex_init(&wm9713->lock); + + ac97_set_drvdata(adev, wm9713); + + return snd_soc_register_codec(ac97_codec_dev2dev(adev), + &soc_codec_dev_wm9713, wm9713_dai, + ARRAY_SIZE(wm9713_dai)); +} + +static int wm9713_ac97_remove(struct ac97_codec_device *adev) +{ + snd_soc_unregister_codec(ac97_codec_dev2dev(adev)); + return 0; +} + +static struct ac97_id wm9713_ac97_ids[] = { + { .id = WM9713_VENDOR_ID, .mask = WM9713_VENDOR_ID_MASK }, + { } +}; + +static struct ac97_codec_driver wm9713_ac97_driver = { + .driver = { + .name = "wm9713-codec", + }, + .probe = wm9713_ac97_probe, + .remove = wm9713_ac97_remove, + .id_table = wm9713_ac97_ids, +}; + +static int __init wm9713_init(void) +{ + snd_ac97_codec_driver_register(&wm9713_ac97_driver); + return platform_driver_register(&wm9713_codec_driver); +} +module_init(wm9713_init); + +static void __exit wm9713_exit(void) +{ + snd_ac97_codec_driver_unregister(&wm9713_ac97_driver); + return platform_driver_unregister(&wm9713_codec_driver); +} +module_exit(wm9713_exit); MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver"); MODULE_AUTHOR("Liam Girdwood");