From patchwork Mon May 26 08:28:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 30921 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 4857E20491 for ; Mon, 26 May 2014 08:30:54 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id i4sf40719432oah.5 for ; Mon, 26 May 2014 01:30:53 -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=1P+jpTjr42nKeSj4d1VZ8v2RXDSv7mIf5HWZOSN1E0c=; b=Wm30+l7sCrxmRJh5QGABa8VdLflhdBc87pC85zpTKC7zzKaiTx4BFgHcDaWFhbdGIo jibxOTCVACcB/LM3l6oUvxQ88pC5mxyeqQ8NcrrBF91+y0zLIYmWa25PBguxkr+yr5zh pv2JEkCyYSrX6QnnxsmbcHsYYc0R55TsagNwUpettP0AQNsK7+ONwJqEyeIwGlPyQwCd BQ3MblZbSqxxzOG9HmyShPyfMsJMXJbchSWRHuCi4RiH5C7TNZcbH0H9HCXp3/hrBDF6 zUmo1wDhPYDmIsAHGYbFLFfR8VbrHGJh7qErjLPnf/mleldWa6UwTsryFDUxYchXd2fk 1+Mw== X-Gm-Message-State: ALoCoQnw0m+3nftTGQHGVWDlp+NM1WCo9aZcEF7wTBLe6PivsQugsQg5mUTjrsF8YDXFnrN2JOZ+ X-Received: by 10.182.20.17 with SMTP id j17mr9829179obe.24.1401093053903; Mon, 26 May 2014 01:30:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.200 with SMTP id m66ls2596131qge.83.gmail; Mon, 26 May 2014 01:30:53 -0700 (PDT) X-Received: by 10.52.137.83 with SMTP id qg19mr952189vdb.60.1401093053747; Mon, 26 May 2014 01:30:53 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id ul5si5934467veb.7.2014.05.26.01.30.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 01:30:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id id10so5493046vcb.35 for ; Mon, 26 May 2014 01:30:53 -0700 (PDT) X-Received: by 10.58.219.166 with SMTP id pp6mr20540437vec.1.1401093053660; Mon, 26 May 2014 01:30:53 -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 ib8csp26657vcb; Mon, 26 May 2014 01:30:53 -0700 (PDT) X-Received: by 10.68.139.36 with SMTP id qv4mr26548089pbb.82.1401093052698; Mon, 26 May 2014 01:30:52 -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 S1751767AbaEZIap (ORCPT + 27 others); Mon, 26 May 2014 04:30:45 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:42508 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751694AbaEZIan (ORCPT ); Mon, 26 May 2014 04:30:43 -0400 Received: by mail-pa0-f53.google.com with SMTP id kp14so7224826pab.26 for ; Mon, 26 May 2014 01:30:42 -0700 (PDT) X-Received: by 10.66.244.140 with SMTP id xg12mr20530340pac.23.1401093042597; Mon, 26 May 2014 01:30:42 -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.39 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 01:30:42 -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 V2 1/2] ASoC: max98090: Add master clock handling Date: Mon, 26 May 2014 13:58:21 +0530 Message-Id: <1401092902-20525-2-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.220.176 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/max98090.txt | 6 +++++ sound/soc/codecs/max98090.c | 23 ++++++++++++++++++++ sound/soc/codecs/max98090.h | 1 + 3 files changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt index e4c8b36..a5e63fa 100644 --- a/Documentation/devicetree/bindings/sound/max98090.txt +++ b/Documentation/devicetree/bindings/sound/max98090.txt @@ -10,6 +10,12 @@ Required properties: - interrupts : The CODEC's interrupt output. +Optional properties: + +- clocks: The phandle of the master clock to the CODEC + +- clock-names: Should be "mclk" + Pins on the device (for linking into audio routes): * MIC1 diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 9b76f5a..9275785 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1800,6 +1801,19 @@ static int max98090_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(max98090->mclk)) { + if (codec->dapm.bias_level == SND_SOC_BIAS_ON) + clk_disable_unprepare(max98090->mclk); + else + clk_prepare_enable(max98090->mclk); + } break; case SND_SOC_BIAS_STANDBY: @@ -1929,6 +1943,11 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, if (freq == max98090->sysclk) return 0; + if (!IS_ERR(max98090->mclk)) { + freq = clk_round_rate(max98090->mclk, freq); + clk_set_rate(max98090->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).. @@ -2213,6 +2232,10 @@ static int max98090_probe(struct snd_soc_codec *codec) dev_dbg(codec->dev, "max98090_probe\n"); + max98090->mclk = devm_clk_get(codec->dev, "mclk"); + if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + max98090->codec = codec; /* Reset the codec, the DSP core, and disable all interrupts */ diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h index 5a3c8d0..cf1b606 100644 --- a/sound/soc/codecs/max98090.h +++ b/sound/soc/codecs/max98090.h @@ -1524,6 +1524,7 @@ struct max98090_priv { struct snd_soc_codec *codec; enum max98090_type devtype; struct max98090_pdata *pdata; + struct clk *mclk; unsigned int sysclk; unsigned int bclk; unsigned int lrclk;