From patchwork Fri Jul 4 13:13:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 4481151 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE097BEEAA for ; Fri, 4 Jul 2014 13:15:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A8A9B203F1 for ; Fri, 4 Jul 2014 13:15:28 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 40C4E203E5 for ; Fri, 4 Jul 2014 13:15:27 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 54BA6265A12; Fri, 4 Jul 2014 15:15:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 37FD1265A16; Fri, 4 Jul 2014 15:15:09 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2F9C4265A17; Fri, 4 Jul 2014 15:15:08 +0200 (CEST) Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by alsa0.perex.cz (Postfix) with ESMTP id 36D2E2654C4 for ; Fri, 4 Jul 2014 15:14:38 +0200 (CEST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N86002FOVGCWO80@mailout1.samsung.com> for alsa-devel@alsa-project.org; Fri, 04 Jul 2014 22:14:36 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-f9-53b6a8bbeed8 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 06.7B.04943.BB8A6B35; Fri, 04 Jul 2014 22:14:36 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N86007A2VF0OZ50@mmp1.samsung.com>; Fri, 04 Jul 2014 22:14:35 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Date: Fri, 04 Jul 2014 15:13:45 +0200 Message-id: <1404479625-25385-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1404479625-25385-1-git-send-email-s.nawrocki@samsung.com> References: <1404479625-25385-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprILMWRmVeSWpSXmKPExsVy+t9jAd09K7YFG9x9ymhx5eIhJoupD5+w Wcw/co7VYtPja6wWM87vY7I4/Kad1WLzu3+sDuweGz43sXlsWtXJ5rF5Sb1H35ZVjB6fN8kF sEZx2aSk5mSWpRbp2yVwZez+olPw36piz+oDLA2Mhw27GDk5JARMJJo/r2eFsMUkLtxbzwZi CwksYpR4cS2wi5ELyO5gklh9pg+siE3AUKL3aB8jiC0C1HB7TiczSBGzwE1GiSnz/7GAJIQF vCQW7F4MVsQioCpx7fMfZhCbV8BN4syar0A2B9A2BYk5k2xAwpwC7hKHb/cxQyx2kzjy9yTr BEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzGCA+qZ1A7GlQ0WhxgFOBiVeHg9irYG C7EmlhVX5h5ilOBgVhLh1ZqzLViINyWxsiq1KD++qDQntfgQozQHi5I474FW60AhgfTEktTs 1NSC1CKYLBMHp1QDo8VCk+cHpyy+0X/H/7pz26pnWW3aAm/acnNLom+sFGXp79z0Q5/V7N/v +LprN/5tXmfgPYdh9cFL8ofOyXeJKC+zureN48sO1bdzb809IXl10ypvCUWX45U7bYQZms+7 Pb3y723zhSv8C0T3fNrw9+qi8/trJ944fUe1gfl9D3dwV5bnRZkN22WUWIozEg21mIuKEwES flj9JAIAAA== Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, Chen Zhen , Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH V3 2/2] ASoC: samsung: Add machine driver for Odroid X2/U3 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the sound subsystem driver for Odroid-X2 and Odroid-U3 boards. The codec works in I2S master mode; there are two separate audio routing paths defined, as there are differences in the signal routing between the X2 and U3 boards, i.e. U3 uses single jack for headphones and microphone. Signed-off-by: Chen Zhen Signed-off-by: Sylwester Nawrocki --- Changes since v2: - clock settings moved to late_probe, odroidx2_ops removed; - added missing driver.pm ops initialization; - minor cleanups. --- sound/soc/samsung/Kconfig | 8 ++ sound/soc/samsung/Makefile | 2 + sound/soc/samsung/odroidx2_max98090.c | 177 +++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 sound/soc/samsung/odroidx2_max98090.c -- 1.7.9.5 diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index 3be49cd..333d645 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -237,3 +237,11 @@ config SND_SOC_SNOW help Say Y if you want to add audio support for various Snow boards based on Exynos5 series of SoCs. + +config SND_SOC_ODROIDX2 + tristate "Audio support for Odroid-X2 and Odroid-U3" + depends on SND_SOC_SAMSUNG + select SND_SOC_MAX98090 + select SND_SAMSUNG_I2S + help + Say Y here to enable audio support for the Odroid-X2/U3. diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile index 6469199..e8d9ccd 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile @@ -44,6 +44,7 @@ snd-soc-tobermory-objs := tobermory.o snd-soc-lowland-objs := lowland.o snd-soc-littlemill-objs := littlemill.o snd-soc-bells-objs := bells.o +snd-soc-odroidx2-max98090-objs := odroidx2_max98090.o obj-$(CONFIG_SND_SOC_SAMSUNG_JIVE_WM8750) += snd-soc-jive-wm8750.o obj-$(CONFIG_SND_SOC_SAMSUNG_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o @@ -69,3 +70,4 @@ obj-$(CONFIG_SND_SOC_TOBERMORY) += snd-soc-tobermory.o obj-$(CONFIG_SND_SOC_LOWLAND) += snd-soc-lowland.o obj-$(CONFIG_SND_SOC_LITTLEMILL) += snd-soc-littlemill.o obj-$(CONFIG_SND_SOC_BELLS) += snd-soc-bells.o +obj-$(CONFIG_SND_SOC_ODROIDX2) += snd-soc-odroidx2-max98090.o diff --git a/sound/soc/samsung/odroidx2_max98090.c b/sound/soc/samsung/odroidx2_max98090.c new file mode 100644 index 0000000..278edf9 --- /dev/null +++ b/sound/soc/samsung/odroidx2_max98090.c @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2014 Samsung Electronics Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include "i2s.h" + +struct odroidx2_drv_data { + const struct snd_soc_dapm_widget *dapm_widgets; + unsigned int num_dapm_widgets; +}; + +/* The I2S CDCLK output clock frequency for the MAX98090 codec */ +#define MAX98090_MCLK 19200000 + +static int odroidx2_late_probe(struct snd_soc_card *card) +{ + struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; + struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai; + int ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, 0, MAX98090_MCLK, + SND_SOC_CLOCK_IN); + if (ret < 0) + return ret; + + /* Set the cpu DAI configuration in order to use CDCLK */ + return snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_CDCLK, + 0, SND_SOC_CLOCK_OUT); +} + +static const struct snd_soc_dapm_widget odroidx2_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Mic Jack", NULL), + SND_SOC_DAPM_MIC("DMIC", NULL), +}; + +static const struct snd_soc_dapm_widget odroidu3_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_SPK("Speakers", NULL), +}; + +static struct snd_soc_dai_link odroidx2_dai[] = { + { + .name = "MAX98090", + .stream_name = "MAX98090 PCM", + .codec_dai_name = "HiFi", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM, + } +}; + +static struct snd_soc_card odroidx2 = { + .owner = THIS_MODULE, + .dai_link = odroidx2_dai, + .num_links = ARRAY_SIZE(odroidx2_dai), + .fully_routed = true, + .late_probe = odroidx2_late_probe, +}; + +struct odroidx2_drv_data odroidx2_drvdata = { + .dapm_widgets = odroidx2_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(odroidx2_dapm_widgets), +}; + +struct odroidx2_drv_data odroidu3_drvdata = { + .dapm_widgets = odroidu3_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(odroidu3_dapm_widgets), +}; + +static const struct of_device_id odroidx2_audio_of_match[] = { + { + .compatible = "samsung,odroidx2-audio", + .data = &odroidx2_drvdata, + }, { + .compatible = "samsung,odroidu3-audio", + .data = &odroidu3_drvdata, + }, + { }, +}; +MODULE_DEVICE_TABLE(of, odroidx2_audio_of_match); + +static int odroidx2_audio_probe(struct platform_device *pdev) +{ + struct device_node *snd_node = pdev->dev.of_node; + struct snd_soc_card *card = &odroidx2; + struct device_node *i2s_node, *codec_node; + struct odroidx2_drv_data *dd; + const struct of_device_id *of_id; + int ret; + + of_id = of_match_node(odroidx2_audio_of_match, snd_node); + dd = (struct odroidx2_drv_data *)of_id->data; + + card->num_dapm_widgets = dd->num_dapm_widgets; + card->dapm_widgets = dd->dapm_widgets; + + card->dev = &pdev->dev; + + ret = snd_soc_of_parse_card_name(card, "samsung,model"); + if (ret < 0) + return ret; + + ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing"); + if (ret < 0) + return ret; + + codec_node = of_parse_phandle(snd_node, "samsung,audio-codec", 0); + if (!codec_node) { + dev_err(&pdev->dev, + "Failed parsing samsung,i2s-codec property\n"); + return -EINVAL; + } + + i2s_node = of_parse_phandle(snd_node, "samsung,i2s-controller", 0); + if (!i2s_node) { + dev_err(&pdev->dev, + "Failed parsing samsung,i2s-controller property\n"); + ret = -EINVAL; + goto err_put_codec_n; + } + + odroidx2_dai[0].codec_of_node = codec_node; + odroidx2_dai[0].cpu_of_node = i2s_node; + odroidx2_dai[0].platform_of_node = i2s_node; + + ret = snd_soc_register_card(card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", + ret); + goto err_put_i2s_n; + } + return 0; + +err_put_i2s_n: + of_node_put(i2s_node); +err_put_codec_n: + of_node_put(codec_node); + return ret; +} + +static int odroidx2_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + of_node_put((struct device_node *)odroidx2_dai[0].cpu_of_node); + of_node_put((struct device_node *)odroidx2_dai[0].codec_of_node); + + return 0; +} + +static struct platform_driver odroidx2_audio_driver = { + .driver = { + .name = "odroidx2-audio", + .owner = THIS_MODULE, + .of_match_table = odroidx2_audio_of_match, + .pm = &snd_soc_pm_ops, + }, + .probe = odroidx2_audio_probe, + .remove = odroidx2_audio_remove, +}; +module_platform_driver(odroidx2_audio_driver); + +MODULE_AUTHOR("Chen Zhen "); +MODULE_AUTHOR("Sylwester Nawrocki "); +MODULE_DESCRIPTION("ALSA SoC Odroid X2/U3 Audio Support"); +MODULE_LICENSE("GPL v2");