From patchwork Thu May 22 09:17:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 4221281 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 47C56BEEAB for ; Thu, 22 May 2014 09:21:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72EE2202C8 for ; Thu, 22 May 2014 09:21:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3C82120154 for ; Thu, 22 May 2014 09:21:06 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 40FD22655F0; Thu, 22 May 2014 11:21:05 +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 7EB352655B8; Thu, 22 May 2014 11:20:11 +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 91CA12655B8; Thu, 22 May 2014 11:20:09 +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 4F5DF261A27 for ; Thu, 22 May 2014 11:19:33 +0200 (CEST) Received: by mail-pb0-f42.google.com with SMTP id md12so2345290pbc.29 for ; Thu, 22 May 2014 02:19:32 -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=UVuKhGRUs/FrfplhU6G81GbyAMtGxxuy/+4hzQi6qhQ=; b=FucpwdZOrq+uthyfvCQpw/EvB020c6T79K0FNoGIdBvx0errO09+dVTw6HQ1gS9lWz mzVjRn2gqkj3XW+09UHhMSXM5KfcQI3pKtf00TJn6aGlTzt5zhFMLWNq599HoeNvGlH8 SWQwVGZrlTXQIjLVmqj2B9/JuMrCvIF+YVXoGvoTpEiUQ6SsqgdF38NQeHLowdoIwxV9 uV53z1AII5UiFTkun/RyzHW/WOanjsiSXo7SVQkWPo5ZU4xtALuo0hGjpAMU9dq+s+/G hRnUTZL7bm5OvP1M6L9CnGYYC/eGqmtYjHrpANIeb8GadDsVmHM11Rq/xVPrejlZrK2g JlYA== X-Gm-Message-State: ALoCoQkyIwZyjJirAcfzMmc2rtjfi/Lk7RRRNVQUD1mDZVSbMedhVpPKlWhu7hfWn6/FKrAToswf X-Received: by 10.66.192.73 with SMTP id he9mr65981468pac.88.1400750372475; Thu, 22 May 2014 02:19:32 -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.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 May 2014 02:19:28 -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:08 +0530 Message-Id: <1400750228-13750-3-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 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 | 14 ++++++++++++++ 2 files changed, 20 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..4d66b95 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).. @@ -2238,6 +2245,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 (!IS_ERR(max98095->mclk)) + clk_prepare_enable(max98095->mclk); + /* reset the codec, the DSP core, and disable all interrupts */ max98095_reset(codec); @@ -2340,6 +2351,9 @@ static int max98095_remove(struct snd_soc_codec *codec) if (max98095->headphone_jack || max98095->mic_jack) max98095_jack_detect_disable(codec); + if (!IS_ERR(max98095->mclk)) + clk_disable_unprepare(max98095->mclk); + if (client->irq) free_irq(client->irq, codec);