From patchwork Thu May 22 09:17:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 4221241 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 92DEDBEEAB for ; Thu, 22 May 2014 09:20:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC77C202DD for ; Thu, 22 May 2014 09:20:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 93B1C202EC for ; Thu, 22 May 2014 09:20:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A5A63261A49; Thu, 22 May 2014 11:20:10 +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,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 3D97A2655A0; Thu, 22 May 2014 11:19:34 +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 C493F2655A0; Thu, 22 May 2014 11:19:32 +0200 (CEST) Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42]) by alsa0.perex.cz (Postfix) with ESMTP id C3401261A27 for ; Thu, 22 May 2014 11:19:26 +0200 (CEST) Received: by mail-pb0-f42.google.com with SMTP id md12so2345181pbc.29 for ; Thu, 22 May 2014 02:19:25 -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=dET2yG7fwedcOGUSExC4D1Ux6X+IEoAofAG66ojuA+Q=; b=BRmlZjMvlAec9LDLYkukfHsJLvwgTxSqvGqu881ERmuw+gMO+HkflGUqD9sZLVknja DvuE+2iwSnTh+lxN3nhfydjbWczGB+bxgm5nmpwIMDaY3RVlAFQ9xDeti8MdvcqD48Sf tRsIdmKvIxshO0OhqhKSU8V2tU0LlGXN9u3hR7rw0FYmm18fRM9bQRc3DVM4iKeCZAjp s3nqtDE9UzRg8HSNOBOpdvWfEUtAz0UjwV/DlJoTpVRMIVCFpl2WUwkz5OCrooSEZc7l S7VmEZwwDJnGK2nJ/1hMzNnVf+IVm46weJXzTGw6X4rW72Ztd1wtqnM2kJdB7wF7gXnY wxXg== X-Gm-Message-State: ALoCoQkAcQdhsXIpD7ox/ml+Z5J9QtXuLnIvEk8pCplIZd/gPnXoXh13f1S1y1MEJj4hEfn7L0qS X-Received: by 10.66.250.166 with SMTP id zd6mr402095pac.7.1400750365606; Thu, 22 May 2014 02:19:25 -0700 (PDT) Received: from linaro.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id im2sm12039249pbb.32.2014.05.22.02.19.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 May 2014 02:19:22 -0700 (PDT) From: Tushar Behera To: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Date: Thu, 22 May 2014 14:47:07 +0530 Message-Id: <1400750228-13750-2-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400750228-13750-1-git-send-email-tushar.behera@linaro.org> References: <1400750228-13750-1-git-send-email-tushar.behera@linaro.org> Cc: tiwai@suse.de, broonie@kernel.org, jerry.wong@maximintegrated.com, dianders@chromium.org Subject: [alsa-devel] [PATCH 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 | 13 +++++++++++++ sound/soc/codecs/max98090.h | 1 + 3 files changed, 20 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..41c61eb 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1929,6 +1930,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 +2219,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 (!IS_ERR(max98090->mclk)) + clk_prepare_enable(max98090->mclk); + max98090->codec = codec; /* Reset the codec, the DSP core, and disable all interrupts */ @@ -2308,6 +2318,9 @@ static int max98090_remove(struct snd_soc_codec *codec) cancel_delayed_work_sync(&max98090->jack_work); + if (!IS_ERR(max98090->mclk)) + clk_disable_unprepare(max98090->mclk); + return 0; } 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;