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: 4240521 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41D31BF90B for ; Mon, 26 May 2014 08:32:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5AD6C201BB for ; Mon, 26 May 2014 08:32:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id EAD7A20123 for ; Mon, 26 May 2014 08:32:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1203F2651B5; Mon, 26 May 2014 10:32:11 +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 D53E8264FEE; Mon, 26 May 2014 10:30:51 +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 C13FC264F3A; Mon, 26 May 2014 10:30:50 +0200 (CEST) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by alsa0.perex.cz (Postfix) with ESMTP id ACE7D26087B for ; Mon, 26 May 2014 10:30:43 +0200 (CEST) Received: by mail-pb0-f46.google.com with SMTP id rq2so7330001pbb.5 for ; Mon, 26 May 2014 01:30:42 -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=XOfkcfzpHglgZTucl9THs0uF9ESk19vQFJzyNQnm9N8=; b=BZLDFrOy18CYA9Mr9Dtabqmp9U98Hm3rKbc2asYDYbgG0bTs+6uiBZsfHMCRUCO/fu 6iHywWfLzP8gR7BuYY/t4SLXc8cJOP2jZosq04kV91eH8QOqLvLVq+07TJaGJKOSZDXb r5We+ddZx0vMko19KPtRVxxtzvIjFehKjwX+0fLcBNssaPlxncE48BVpi6juNohGZ4fd hN6ifXUdce61YVE3sYzMO5cdU0fW+j3+0cp6TW/iQwktP9QeON8v0/gSd3dRWQrcBIhM b7Gbtnv/spcH75VDVfAmy3B6/fpj0LktJUoMuBNqbaF/3/Ob/OdZuJux1dQxD2JwJV2R 6JtQ== X-Gm-Message-State: ALoCoQnBa9Q590KMf6sxToogMalnpIxqeJlA6ZsQN+dt3+isui6Tx9V/sH/ewvk4YellsFMDNiMy 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 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> Cc: tiwai@suse.de, broonie@kernel.org, dianders@chromium.org, swarren@wwwdotorg.org Subject: [alsa-devel] [PATCH V2 1/2] ASoC: max98090: 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/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;