From patchwork Mon Aug 8 14:35:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 9269213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 225A8607D6 for ; Mon, 8 Aug 2016 19:12:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F0D927F95 for ; Mon, 8 Aug 2016 19:12:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03BE127FE4; Mon, 8 Aug 2016 19:12:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C52327F95 for ; Mon, 8 Aug 2016 19:12:29 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 679132670AF; Mon, 8 Aug 2016 21:12:28 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E26C7269270; Mon, 8 Aug 2016 19:47:52 +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 950A7266DE3; Mon, 8 Aug 2016 19:47:50 +0200 (CEST) Received: from mail1.bemta6.messagelabs.com (mail1.bemta6.messagelabs.com [85.158.143.251]) by alsa0.perex.cz (Postfix) with ESMTP id 770B0266DE2 for ; Mon, 8 Aug 2016 16:35:26 +0200 (CEST) Received: from [85.158.140.195] by server-4.bemta-6.messagelabs.com id 95/E9-07858-DA898A75; Mon, 08 Aug 2016 14:35:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRWlGSWpSXmKPExsUSt3Opse7aGSv CDW7dV7K4cvEQk8XUh0/YLL5d6WCyuLxrDptF565+VosN39cyOrB5bPjcxOaxc9Zddo9NqzrZ PPa9XcbmsX7LVRaPz5vkAtiiWDPzkvIrElgzply4wFqwXqCiecIPlgbGbbxdjFwcQgLrGCWW/ e5i6WLkBHIqJE4eWcsGYvMKZEpMWjCVHcTmFHCXWP1zC1MXIwdQjZvEt3OlIGE2AQuJyScegJ WzCKhIvH50gQ2kRFggQuLXFi+Q8SICXYwSq189BhvDLFAuseXTRGaI8YISJ2c+YYGIS0gcfPG CGeIEA4nTCxrB4hIC9hLT319lBpkpIaAv0XgsFiJsKPF91jeoEnOJpUv3MU5gFJyFZOosJFMX MDKtYlQvTi0qSy3StdBLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMfQYg2ME4+ 7L/IUZJDiYlUV75qSvChfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwRk4HygkWpaanVqRl5gCjEC YtwcGjJMI7ESTNW1yQmFucmQ6ROsWoKCXOqwySEABJZJTmwbXBIv8So6yUMC8j0CFCPAWpRbm ZJajyrxjFORiVhHnng0zhycwrgZv+CmgxE9DiJFWwxSWJCCmpBsYDr5dVbOl679+5fNXPYOty 329OTFf3yderN7bPEJtu/n+twjGdG4W1ezlW7XUK4dUsjy5en7LJeucU+Z/Rt2RFWrd//On2z LV/xsR5pmIsk+dXcwQ35p39H7gy2qcg6tn7U4f1PTJ1ztZsOKNuctnC8fXyzf19Hr9Wad14cm PLpbLzQvsW+ZQpsRRnJBpqMRcVJwIAxOrCT/cCAAA= X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-6.tower-193.messagelabs.com!1470666925!47724985!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25681 invoked from network); 8 Aug 2016 14:35:25 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-6.tower-193.messagelabs.com with AES128-SHA encrypted SMTP; 8 Aug 2016 14:35:25 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.248.2; Mon, 8 Aug 2016 15:35:25 +0100 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id D00AD3FBBB; Mon, 8 Aug 2016 15:35:24 +0100 (BST) Message-ID: In-Reply-To: References: From: Adam Thomson Date: Mon, 8 Aug 2016 15:35:24 +0100 To: Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai MIME-Version: 1.0 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 08/08/2016 08:46:00 Cc: alsa-devel@alsa-project.org, Support Opensource , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH 2/2] ASoC: da7218: Improve driver efficiency with regards to MCLK usage 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Currently MCLK remains enabled during bias STANDBY state, and this is not necessary. This patch updates the code to handle enabling and disabling of MCLK, if provided, when moving between STANDBY and PREPARE states, therefore saving power when no active streams present. Signed-off-by: Adam Thomson --- sound/soc/codecs/da7218.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c index f443519..e7f3e4c 100644 --- a/sound/soc/codecs/da7218.c +++ b/sound/soc/codecs/da7218.c @@ -2583,20 +2583,22 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: - case SND_SOC_BIAS_PREPARE: break; - case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - /* MCLK */ + case SND_SOC_BIAS_PREPARE: + /* Enable MCLK for transition to ON state */ + if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { if (da7218->mclk) { ret = clk_prepare_enable(da7218->mclk); if (ret) { - dev_err(codec->dev, - "Failed to enable mclk\n"); + dev_err(codec->dev, "Failed to enable mclk\n"); return ret; } } + } + break; + case SND_SOC_BIAS_STANDBY: + if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { /* Master bias */ snd_soc_update_bits(codec, DA7218_REFERENCES, DA7218_BIAS_EN_MASK, @@ -2606,6 +2608,10 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, snd_soc_update_bits(codec, DA7218_LDO_CTRL, DA7218_LDO_EN_MASK, DA7218_LDO_EN_MASK); + } else { + /* Remove MCLK */ + if (da7218->mclk) + clk_disable_unprepare(da7218->mclk); } break; case SND_SOC_BIAS_OFF: @@ -2619,10 +2625,6 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, snd_soc_update_bits(codec, DA7218_REFERENCES, DA7218_BIAS_EN_MASK, 0); } - - /* MCLK */ - if (da7218->mclk) - clk_disable_unprepare(da7218->mclk); break; }