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: 30404 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6CBFC203AB for ; Tue, 20 May 2014 04:35:48 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id i4sf35176558oah.5 for ; Mon, 19 May 2014 21:35: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:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Ker+59ts/ykJX0yrZjlukK7GGln9oo7icjX1xP2AkAc=; b=TVtLxjy5d9kIlkXarv6x4l6GnCw+KoQim5uumq41lMw3n2abug6f8FF1sRZ6eOOehR uuaIWMKptPKXfugX7t1E0UThDuAiaede+tK0usrTk2xlZro3GrZe23WXqPGnaU9QA2t/ CczTMk9TZ/GpLcdZnndGJSZ9zpfvpP4QuE4W0n5SKGFZS1uSFfNZTY4clRs2k52RJeyB sCvLyWvgQw6Qkc7t2DmhBXwk5cspwbjzLRyNddc5kZg+oWsYgQyb0HHD4B4ErUIQtkqL jpVbL99oShpW449MkWdM+5RL1eJL11A5F7KWXl/hs/CV1SVuYv39cJGvOMCU0AevrAsu 4wnA== X-Gm-Message-State: ALoCoQlZo+sAsLfSyjtSQGx+IfQXWT9WXZNA5KDPYacBySEm1cP4Ayxszj8y/ADe1zmPisZVNNcT X-Received: by 10.43.173.71 with SMTP id ob7mr16835768icc.19.1400560547783; Mon, 19 May 2014 21:35:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.17.19 with SMTP id 19ls88273qgc.69.gmail; Mon, 19 May 2014 21:35:47 -0700 (PDT) X-Received: by 10.220.98.143 with SMTP id q15mr71508vcn.38.1400560547673; Mon, 19 May 2014 21:35:47 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id fv3si24752vcb.89.2014.05.19.21.35.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 May 2014 21:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so10696994vcb.15 for ; Mon, 19 May 2014 21:35:47 -0700 (PDT) X-Received: by 10.220.53.72 with SMTP id l8mr1701470vcg.16.1400560547456; Mon, 19 May 2014 21:35:47 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp98vcb; Mon, 19 May 2014 21:35:47 -0700 (PDT) X-Received: by 10.66.221.99 with SMTP id qd3mr48288238pac.46.1400560137504; Mon, 19 May 2014 21:28:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cu4si47699pbb.182.2014.05.19.21.28.27; Mon, 19 May 2014 21:28:27 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751795AbaETE1s (ORCPT + 8 others); Tue, 20 May 2014 00:27:48 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:35933 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751603AbaETE1r (ORCPT ); Tue, 20 May 2014 00:27:47 -0400 Received: by mail-pb0-f42.google.com with SMTP id md12so6745829pbc.1 for ; Mon, 19 May 2014 21:27:47 -0700 (PDT) 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 Cc: lgirdwood@gmail.com, robh+dt@kernel.org, sbkim73@samsung.com, rdunlap@infradead.org, broonie@kernel.org, dianders@chromium.org, t.figa@samsung.com Subject: [PATCH] ASoC: samsung: Add 'mclk' handling for Snow sound-card driver 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 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tushar.behera@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);