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: 30578 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B8CDB20369 for ; Thu, 22 May 2014 09:19:49 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id pa12sf11256870veb.3 for ; Thu, 22 May 2014 02:19:49 -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=YruRNiCisKVKsE9aupUGaVFP+WEKApxT292oQdLlU4w=; b=XiFtjpxXZ7mdzey6oqoC0hd6dvRfA00PFKKqMwMSCTiEIsXDrS4/lNjNy/0hFqXrX3 WijV3KL6sxa3Bvn6EJP+Bc23a2Kauo2xsI7ADWxxfdj8IS0cq7f6hO+rjdB/5XpGKIhw et7zWLhbgYU3i/lXFBSAkReYSGO3Vimu67uxoUT5pLii7YMvgyE2jvwk9oumW3L6z5em sKFEEYmbFjfxBlOFoi/Pr88itqWgNkvwqJCXS/gn83DmhWI/BQAKo52XXTcr3KPlnjH9 KCUdJ2LtByE1CrwfIh8EkQ9BZ2j138xwBz9X6s8WYhwOMCXHOeyeltpA7ZfD1i1KIB/2 ffIQ== X-Gm-Message-State: ALoCoQlWj5XuPUSY/xrCkcOl0H+ciEreiNXl32PV4U3kADp0uSnUGquWzw3hoxdBBJSmrDHGjEr1 X-Received: by 10.236.89.114 with SMTP id b78mr22159258yhf.13.1400750389404; Thu, 22 May 2014 02:19:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.43.135 with SMTP id e7ls1195616qga.70.gmail; Thu, 22 May 2014 02:19:49 -0700 (PDT) X-Received: by 10.58.195.231 with SMTP id ih7mr34181893vec.32.1400750389294; Thu, 22 May 2014 02:19:49 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id im2si2036675veb.47.2014.05.22.02.19.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 May 2014 02:19:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id id10so680834vcb.20 for ; Thu, 22 May 2014 02:19:49 -0700 (PDT) X-Received: by 10.58.29.106 with SMTP id j10mr9143281veh.31.1400750389209; Thu, 22 May 2014 02:19:49 -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 ib8csp181949vcb; Thu, 22 May 2014 02:19:48 -0700 (PDT) X-Received: by 10.68.193.193 with SMTP id hq1mr35691513pbc.107.1400750388465; Thu, 22 May 2014 02:19:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gu3si9788254pbb.232.2014.05.22.02.19.47; Thu, 22 May 2014 02:19:47 -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 S1754265AbaEVJTg (ORCPT + 27 others); Thu, 22 May 2014 05:19:36 -0400 Received: from mail-pb0-f49.google.com ([209.85.160.49]:53047 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754244AbaEVJTc (ORCPT ); Thu, 22 May 2014 05:19:32 -0400 Received: by mail-pb0-f49.google.com with SMTP id jt11so2322529pbb.22 for ; Thu, 22 May 2014 02:19:32 -0700 (PDT) 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 Cc: tiwai@suse.de, perex@perex.cz, broonie@kernel.org, dianders@chromium.org, jerry.wong@maximintegrated.com Subject: [PATCH 2/2] ASoC: max98095: Add master clock handling 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> 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.175 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/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);