From patchwork Mon May 26 08:28:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 30922 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2FBC720E7A for ; Mon, 26 May 2014 08:30:55 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id jt11sf35864800pbb.2 for ; Mon, 26 May 2014 01:30:54 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=KPuJ9W8EA8pUmfKxOa1MRDH7795KqicrGv6VWiJHCo0=; b=QgECpACW3BpRN0kxTKjuvDMNvs2eO7WDslo1wZJs2woa6H1wJ1m7DA7exFw2iTxUkn CHZ9HqK3/uCO/aKlje1E+ljxpQxwmYAoeGczstK5iTgq6k66p+1tDJ2TGcJ0svT+t+xt gFMp408RPqI0xxhNprMItmoMNPDvppEKHPced2kvt6KiqI/jDcdfP9SIYeorF6qrPDV/ 2EdLXX56OigP3CgZNzkpqU+EkaO82b8BJgxk+QDSTjMt4y50YG5GVMKsmjousKTAS5ys LH1d1GdJyP6VI3T0L7/k2U3X53YvjjCnRbwwBpazeHh/X5LafayGyoi4MDbTOVh26FQ3 kSqg== X-Gm-Message-State: ALoCoQkRqNJFvQ2p86T/DP//k1Nh/CFb0mB4hGe+oir2h8Mk24/NqFeKh+D4gltG5ia7t7n+YW0+ X-Received: by 10.66.120.143 with SMTP id lc15mr7389045pab.28.1401093054507; Mon, 26 May 2014 01:30:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.16 with SMTP id r16ls2582638qga.71.gmail; Mon, 26 May 2014 01:30:54 -0700 (PDT) X-Received: by 10.220.82.133 with SMTP id b5mr20106610vcl.13.1401093054360; Mon, 26 May 2014 01:30:54 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id ww4si5910818vec.107.2014.05.26.01.30.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 01:30:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id oy12so8998818veb.10 for ; Mon, 26 May 2014 01:30:54 -0700 (PDT) X-Received: by 10.220.89.4 with SMTP id c4mr411896vcm.53.1401093054292; Mon, 26 May 2014 01:30:54 -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 ib8csp26660vcb; Mon, 26 May 2014 01:30:53 -0700 (PDT) X-Received: by 10.68.215.68 with SMTP id og4mr25819065pbc.112.1401093053374; Mon, 26 May 2014 01:30:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id as1si13646511pbc.116.2014.05.26.01.30.52 for ; Mon, 26 May 2014 01:30:52 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-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 S1751825AbaEZIat (ORCPT + 27 others); Mon, 26 May 2014 04:30:49 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:45077 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751618AbaEZIaq (ORCPT ); Mon, 26 May 2014 04:30:46 -0400 Received: by mail-pa0-f44.google.com with SMTP id ld10so7279620pab.17 for ; Mon, 26 May 2014 01:30:46 -0700 (PDT) X-Received: by 10.66.190.167 with SMTP id gr7mr25444570pac.75.1401093046067; Mon, 26 May 2014 01:30:46 -0700 (PDT) Received: from linaro.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id dz4sm10690642pab.47.2014.05.26.01.30.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 01:30:45 -0700 (PDT) From: Tushar Behera To: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: tiwai@suse.de, perex@perex.cz, broonie@kernel.org, dianders@chromium.org, swarren@wwwdotorg.org Subject: [PATCH 2/2] ASoC: max98095: Add master clock handling Date: Mon, 26 May 2014 13:58:22 +0530 Message-Id: <1401092902-20525-3-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1401092902-20525-1-git-send-email-tushar.behera@linaro.org> References: <1401092902-20525-1-git-send-email-tushar.behera@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.128.179 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: , If master clock is provided through device tree, then update the master clock frequency during set_sysclk. Documentation has been updated to reflect the change. Signed-off-by: Tushar Behera --- .../devicetree/bindings/sound/max98095.txt | 6 +++++ sound/soc/codecs/max98095.c | 24 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/max98095.txt b/Documentation/devicetree/bindings/sound/max98095.txt index bacbeaa..318a4c8 100644 --- a/Documentation/devicetree/bindings/sound/max98095.txt +++ b/Documentation/devicetree/bindings/sound/max98095.txt @@ -8,6 +8,12 @@ Required properties: - reg : The I2C address of the device. +Optional properties: + +- clocks: The phandle of the master clock to the CODEC + +- clock-names: Should be "mclk" + Example: max98095: codec@11 { diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index d6c1e4c..89ec004 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ struct max98095_priv { struct regmap *regmap; enum max98095_type devtype; struct max98095_pdata *pdata; + struct clk *mclk; unsigned int sysclk; struct max98095_cdata dai[3]; const char **eq_texts; @@ -1395,6 +1397,11 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai, if (freq == max98095->sysclk) return 0; + if (!IS_ERR(max98095->mclk)) { + freq = clk_round_rate(max98095->mclk, freq); + clk_set_rate(max98095->mclk, freq); + } + /* Setup clocks for slave mode, and using the PLL * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) * 0x02 (when master clk is 20MHz to 40MHz).. @@ -1634,6 +1641,19 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: + /* + * SND_SOC_BIAS_PREPARE is called while preparing for a + * transition to ON or away from ON. If current bias_level + * is SND_SOC_BIAS_ON, then it is preparing for a transition + * away from ON. Disable the clock in that case, otherwise + * enable it. + */ + if (!IS_ERR(max98095->mclk)) { + if (codec->dapm.bias_level == SND_SOC_BIAS_ON) + clk_disable_unprepare(max98095->mclk); + else + clk_prepare_enable(max98095->mclk); + } break; case SND_SOC_BIAS_STANDBY: @@ -2238,6 +2258,10 @@ static int max98095_probe(struct snd_soc_codec *codec) struct i2c_client *client; int ret = 0; + max98095->mclk = devm_clk_get(codec->dev, "mclk"); + if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + /* reset the codec, the DSP core, and disable all interrupts */ max98095_reset(codec);