From patchwork Tue May 20 04:25:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 4207271 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5A1C19F32A for ; Tue, 20 May 2014 04:28:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 808362020F for ; Tue, 20 May 2014 04:28:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D33A6201FA for ; Tue, 20 May 2014 04:28:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4EF9B2618ED; Tue, 20 May 2014 06:28:15 +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 201D126167D; Tue, 20 May 2014 06:28:05 +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 4452B261683; Tue, 20 May 2014 06:28:04 +0200 (CEST) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by alsa0.perex.cz (Postfix) with ESMTP id 38A9D2615F3 for ; Tue, 20 May 2014 06:27:48 +0200 (CEST) Received: by mail-pb0-f50.google.com with SMTP id ma3so6714524pbc.9 for ; Mon, 19 May 2014 21:27:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dZMH3qb8/8Q4V6NWABggPkfVMO7S+j+jW+MdYKPCN2k=; b=cWJ3XRfj+0qbhGKMkN3SzdwoWdF7ODWsB/1RQypk/e0e3BpUecAA2FaF+9f1IzMWph TPygS6wRvjUTPr5nQ9jk/AQ46iKhg4ZSezTv34QoxmeJ1L+lQ58Ku1AS9OVnD/fiPsAr B1TUKeV08SVBHEkLvbaCpTYeQb2TU8G7UNOvAQ/RMGWDSVvgXTaskUVdgifst8V4N/A2 NTjZIKw2bEmueL939LBmbdpWFMGv0jbN4cqv2RmXD58jXogTR5uUQrmqvnA92SUs+AfP KUQIAOp/qKRqQJ3EpCv1WQ0NA7slzi24IXh4p9JzOKacoS9gdNfXVV030MmRxrafML1F Vgfg== X-Gm-Message-State: ALoCoQldghQdARjRZy36oZHNW7jlQXDon5+2pXfp3RWbRtnXj0kzDWzP5PuTMu/1WONwXEAx9y/I X-Received: by 10.66.192.73 with SMTP id he9mr47700438pac.88.1400560067202; Mon, 19 May 2014 21:27:47 -0700 (PDT) Received: from linaro.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id be7sm84166626pad.9.2014.05.19.21.27.43 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 May 2014 21:27:46 -0700 (PDT) From: Tushar Behera To: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org Date: Tue, 20 May 2014 09:55:42 +0530 Message-Id: <1400559942-5666-1-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.9.5 Cc: sbkim73@samsung.com, t.figa@samsung.com, rdunlap@infradead.org, lgirdwood@gmail.com, robh+dt@kernel.org, dianders@chromium.org, broonie@kernel.org Subject: [alsa-devel] [PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver 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 For audio to work on Snow board, we need the codec master clock 'mclk' to be properly configured. Currently XCLKOUT is configured as 'mclk' for codec chip and it is required to be clocked at 24MHz for the codec to work properly. Add appropriate clock handling within Snow sound-card driver to set 'mclk' to operate at 24MHz. Signed-off-by: Tushar Behera --- Documentation/devicetree/bindings/sound/snow.txt | 7 ++++++ sound/soc/samsung/snow.c | 26 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/snow.txt b/Documentation/devicetree/bindings/sound/snow.txt index 678b191..94dd29c 100644 --- a/Documentation/devicetree/bindings/sound/snow.txt +++ b/Documentation/devicetree/bindings/sound/snow.txt @@ -7,6 +7,10 @@ Required properties: - samsung,i2s-controller: The phandle of the Samsung I2S controller - samsung,audio-codec: The phandle of the audio codec +Optional properties: +- clocks: The phandle of the master clock to audio codec +- clock-names: Should be "mclk" + Example: sound { @@ -14,4 +18,7 @@ sound { samsung,i2s-controller = <&i2s0>; samsung,audio-codec = <&max98095>; + + clocks = <&pmu_system_controller>; + clock-names = "mclk"; }; diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c index 014c177..c910739 100644 --- a/sound/soc/samsung/snow.c +++ b/sound/soc/samsung/snow.c @@ -15,13 +15,18 @@ #include #include #include +#include #include #include "i2s.h" +/* Desired clock rate for codec mclk */ #define FIN_PLL_RATE 24000000 +static struct clk *mclk; +static unsigned long mclk_rate; + static struct snd_soc_dai_link snow_dai[] = { { .name = "Primary", @@ -41,7 +46,7 @@ static int snow_late_probe(struct snd_soc_card *card) /* Set the MCLK rate for the codec */ ret = snd_soc_dai_set_sysclk(codec_dai, 0, - FIN_PLL_RATE, SND_SOC_CLOCK_IN); + mclk_rate, SND_SOC_CLOCK_IN); if (ret < 0) return ret; @@ -68,6 +73,16 @@ static int snow_probe(struct platform_device *pdev) struct device_node *i2s_node, *codec_node; int i, ret; + /* The codec MCLK should be clocked at 24MHz */ + mclk = devm_clk_get(&pdev->dev, "mclk"); + if (!IS_ERR(mclk)) { + clk_prepare_enable(mclk); + clk_set_rate(mclk, FIN_PLL_RATE); + mclk_rate = clk_get_rate(mclk); + } else { + mclk_rate = FIN_PLL_RATE; + } + i2s_node = of_parse_phandle(pdev->dev.of_node, "samsung,i2s-controller", 0); if (!i2s_node) { @@ -101,6 +116,14 @@ static int snow_probe(struct platform_device *pdev) return ret; } +static int snow_remove(struct platform_device *pdev) +{ + if (!IS_ERR(mclk)) + clk_disable_unprepare(mclk); + + return 0; +} + static const struct of_device_id snow_of_match[] = { { .compatible = "google,snow-audio-max98090", }, { .compatible = "google,snow-audio-max98095", }, @@ -115,6 +138,7 @@ static struct platform_driver snow_driver = { .of_match_table = snow_of_match, }, .probe = snow_probe, + .remove = snow_remove, }; module_platform_driver(snow_driver);