From patchwork Thu May 22 11:55:08 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: 4221981 Return-Path: X-Original-To: patchwork-linux-arm@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 D31ABBEEAB for ; Thu, 22 May 2014 11:58:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DEACB20251 for ; Thu, 22 May 2014 11:58:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D0E5A201DD for ; Thu, 22 May 2014 11:58:55 +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 1WnRcI-0001s7-2q; Thu, 22 May 2014 11:56:58 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WnRcE-0001gm-95 for linux-arm-kernel@lists.infradead.org; Thu, 22 May 2014 11:56:55 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N5Z007FC567NL90@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 22 May 2014 20:56:31 +0900 (KST) X-AuditID: cbfee61a-b7fef6d00000200b-d8-537de5ef75df Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 9B.41.08203.FE5ED735; Thu, 22 May 2014 20:56:31 +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 <0N5Z0093X54K5M30@mmp1.samsung.com>; Thu, 22 May 2014 20:56:31 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Subject: [PATCH 2/2] ASoC: samsung: Add machine driver for odroidx2 Date: Thu, 22 May 2014 13:55:08 +0200 Message-id: <1400759708-25831-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1400759708-25831-1-git-send-email-s.nawrocki@samsung.com> References: <1400759708-25831-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprILMWRmVeSWpSXmKPExsVy+t9jAd33T2uDDXZvNLC4cvEQk8XUh0/Y LOYfOcdqsenxNVaLGef3MVkcftPOarH53T9WB3aPDZ+b2Dw2repk89i8pN6jb8sqRo/Pm+QC WKO4bFJSczLLUov07RK4Ml7PuMlc8Nqk4lDbQ6YGxg/aXYwcHBICJhIPvnB0MXICmWISF+6t Z+ti5OIQEljEKPH3xj52CKeDSaL91FxWkCo2AUOJ3qN9jCC2CFDH7TmdzCBFzAI3GSWuzrkJ ViQs4Cyxe8VkNhCbRUBV4tLjuSwgNq+Am8SSqWeZIDYrSMyZZAMS5hRwl/g3/Ro7SFgIqOTA cYUJjLwLGBlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgQH1DOpHYwrGywOMQpwMCrx8N44 XxMsxJpYVlyZe4hRgoNZSYTX8UltsBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHeA63WgUIC6Ykl qdmpqQWpRTBZJg5OqQbG45POd5yuesr1YeaJj/Me+ieHz39a+mN3zGrzm+e8S4p79v02d56R /az9Ss2R1rmXeXTPxP8V2cPnX29gVMZz8/WKT62ft5cxCT7x2LKH1/ibV9Tv/AKtmCO9cvHx Jt+M3rPO/qzabMxs1BtumxghXVxh/qFgtf7vn5ocWwOs/2nvT+8+uapQiaU4I9FQi7moOBEA MKhBvyQCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140522_045654_528569_AE1E01BF X-CRM114-Status: GOOD ( 18.34 ) X-Spam-Score: -5.7 (-----) 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chen Zhen This machine driver primary defines the audio path, the supported data formats and sample frequency. The codec works in I2S master mode, in order to achieve required exact audio sampling frequencies without a need to adjust the EPLL frequency to each sample rate at runtime. Signed-off-by: Chen Zhen [s.nawrocki@samsung.com: coding style changes, fixed of_match table name] Signed-off-by: Sylwester Nawrocki --- The only bits missing for v3.16 for audio on the Odroid X2/U3 to work now seem to be only my clock defaults setting patches [1] and the related dts updates. [1] http://www.spinics.net/lists/devicetree/msg34718.html sound/soc/samsung/Kconfig | 8 ++ sound/soc/samsung/Makefile | 2 + sound/soc/samsung/odroidx2_max98090.c | 150 +++++++++++++++++++++++++++++++++ 3 files changed, 160 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 f2e2891..aa5ce7c 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -231,3 +231,11 @@ config SND_SOC_LITTLEMILL select SND_SAMSUNG_I2S select MFD_WM8994 select SND_SOC_WM8994 + +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 86715d8..db89489 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile @@ -45,6 +45,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..c3065a9 --- /dev/null +++ b/sound/soc/samsung/odroidx2_max98090.c @@ -0,0 +1,150 @@ +/* + * 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" +#include "i2s-regs.h" + +/* The I2S CDCLK output clock frequency to the MAX98090 codec. */ +#define MAX98090_MCLK_FREQ 19200000 + +static int odroidx2_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S + | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S + | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, 3, MAX98090_MCLK_FREQ, + SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->dev, + "Unable to switch to FLL1: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_OPCLK, + 0, MOD_OPCLK_PCLK); + if (ret < 0) { + dev_err(cpu_dai->dev, + "Unable to set i2s opclk: 0x%x\n", ret); + return ret; + } + + /* Set the cpu DAI configuration in order to use CDCLK */ + ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_CDCLK, + 0, SND_SOC_CLOCK_OUT); + if (ret < 0) + return ret; + + dev_dbg(codec_dai->dev, + "HiFi DAI %s params: channel %d, rate %d as I2S slave\n", + ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? + "playback" : "capture"), params_channels(params), + params_rate(params)); + + return 0; +} + +static struct snd_soc_ops odroidx2_ops = { + .hw_params = odroidx2_hw_params, +}; + +static struct snd_soc_dai_link odroidx2_dai = { + .name = "MAX98090", + .stream_name = "MAX98090 PCM", + .codec_dai_name = "HiFi", + .ops = &odroidx2_ops, +}; + +static struct snd_soc_card odroidx2 = { + .name = "odroidx2", + .owner = THIS_MODULE, + .dai_link = &odroidx2_dai, + .num_links = 1, +}; + +static int odroidx2_audio_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct snd_soc_card *card = &odroidx2; + + if (!np) + return -ENODEV; + + card->dev = &pdev->dev; + + odroidx2_dai.codec_name = NULL; + odroidx2_dai.codec_of_node = of_parse_phandle(np, + "samsung,audio-codec", 0); + if (!odroidx2_dai.codec_of_node) { + dev_err(&pdev->dev, + "missing or invalid samsung,audio-codec property\n"); + return -EINVAL; + } + + odroidx2_dai.cpu_name = NULL; + odroidx2_dai.cpu_of_node = of_parse_phandle(np, + "samsung,i2s-controller", 0); + if (!odroidx2_dai.cpu_of_node) { + dev_err(&pdev->dev, + "missing or invalid samsung,i2s-controller property\n"); + return -EINVAL; + } + + odroidx2_dai.platform_of_node = odroidx2_dai.cpu_of_node; + + return snd_soc_register_card(card); +} + +static int odroidx2_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; +} + +static const struct of_device_id odroidx2_audio_of_match[] = { + { .compatible = "samsung,odroidx2-audio" }, + { }, +}; +MODULE_DEVICE_TABLE(of, odroidx2_audio_of_match); + +static struct platform_driver odroidx2_audio_driver = { + .driver = { + .name = "odroidx2-audio", + .owner = THIS_MODULE, + .of_match_table = odroidx2_audio_of_match, + }, + .probe = odroidx2_audio_probe, + .remove = odroidx2_audio_remove, +}; +module_platform_driver(odroidx2_audio_driver); + +MODULE_AUTHOR("zhen1.chen@samsung.com"); +MODULE_DESCRIPTION("ALSA SoC Odroidx2 Audio Support"); +MODULE_LICENSE("GPL v2");