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: 4240531 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 C72B99F1E7 for ; Mon, 26 May 2014 08:32:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9574201DE for ; Mon, 26 May 2014 08:32:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id B4841201D3 for ; Mon, 26 May 2014 08:32:51 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id DD8EE265290; Mon, 26 May 2014 10:32:50 +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 02CAA2650BA; Mon, 26 May 2014 10:30:56 +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 3CA8C26506E; Mon, 26 May 2014 10:30:54 +0200 (CEST) Received: from mail-pb0-f52.google.com (mail-pb0-f52.google.com [209.85.160.52]) by alsa0.perex.cz (Postfix) with ESMTP id 1BD6F26170F for ; Mon, 26 May 2014 10:30:46 +0200 (CEST) Received: by mail-pb0-f52.google.com with SMTP id rr13so7395521pbb.39 for ; Mon, 26 May 2014 01:30:46 -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:in-reply-to :references; bh=eEEUQVof/QyfvrUzj3KXWjjDZ/ZZLMFtMbRxmJikMj8=; b=j+T+rjH6rnOn7/rIFLm4gaotxQf3QIoE+s5imgjJ1cniVusExKS+v+zZGvGaGMrAdh h+weP/yaIUc7G397DG2qMhZwow7+vtmyn/2cAngiRX7+oZrXuOATqKwdBT7aSOvXeiN9 UZqwd+UfkP1TbxGZs7mWDA05/YbsotOm9FC1IcX79jszzeSQtLTdx49GIbPPlwk3Vnm0 50t98VHrdLaBPloG+iDdv2nWz/0v0N3ff2Ehpwfye7u/+DSWIwYSqyNUZsUbE0i9fd5l DyBWSvS7rRC/b7QA7qxUI0iiGX1YtUuCfKrwpEhD+W7LvtTegG5h9Khat4O7FFli0a3d deEg== X-Gm-Message-State: ALoCoQm6E9ohhM3nRlh8sNqoVIn9H1AMJ7ISwsH6Lkt9spKkmQILJL/8REqy69PvYZp/9LN+K9hL 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 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> Cc: tiwai@suse.de, broonie@kernel.org, dianders@chromium.org, swarren@wwwdotorg.org Subject: [alsa-devel] [PATCH 2/2] ASoC: max98095: Add master clock handling 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 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);