From patchwork Tue May 10 15:11:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 9058821 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C09BD9F1C1 for ; Tue, 10 May 2016 15:12:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E965920154 for ; Tue, 10 May 2016 15:12:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DAF4020148 for ; Tue, 10 May 2016 15:12:24 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C7AF0266046; Tue, 10 May 2016 17:12:23 +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, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 33ECA265CA5; Tue, 10 May 2016 17:11:20 +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 8F81D265B3E; Tue, 10 May 2016 17:11:18 +0200 (CEST) Received: from mail1.bemta5.messagelabs.com (mail1.bemta5.messagelabs.com [195.245.231.145]) by alsa0.perex.cz (Postfix) with ESMTP id 3F63726527E for ; Tue, 10 May 2016 17:11:06 +0200 (CEST) Received: from [85.158.139.51] by server-9.bemta-5.messagelabs.com id 25/B6-12567-A0AF1375; Tue, 10 May 2016 15:11:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRWlGSWpSXmKPExsUSt3OpsS7nL8N wg/0/zSyuXDzEZDH14RM2i29XOpgsLu+aw2bRuauf1WLD97WMDmweGz43sXnsnHWX3WPTqk42 j31vl7F5rN9ylcXj8ya5ALYo1sy8pPyKBNaMOSdPsRf0CFe82VvdwPicv4uRi0NIYD2jxLIPj YxdjJxAToXEryMv2EFsXoFMiR1vFoDZnALuEh/3r2GBqHGTODi1CSzOJmAhMfnEA7YuRg4OFg FViVWd3iBhYYFwia0PZ7KCzBcR6GKUWP3qMVg9s0C5xNlNi9gg5gtKnJz5hAUiLiFx8MULZoj 5BhKnFzSCxSUE7CWmv7/KDDJfQkBfovFYLETYUOL7rG9QJeYS5xdMY5/AKDgLydRZSKYuYGRa xahRnFpUllqka2iml1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFSsl5yfu4kRGPwMQLCD8fxpz 0OMkhxMSqK8glMMw4X4kvJTKjMSizPii0pzUosPMcpwcChJ8LL8BMoJFqWmp1akZeYA4xAmLc HBoyTCm/oDKM1bXJCYW5yZDpE6xagoJc47ASQhAJLIKM2Da4PF/iVGWSlhXkagQ4R4ClKLcjN LUOVfMYpzMCoJ8zKBbOfJzCuBm/4KaDET0GI5Nn2QxSWJCCmpBsbVD9d78gTrh+3kK7eZffH1 +5urK/RkLRjqnkuU9iSGOt6NaFtsdf7Q9tXe50WDHOe+L/v7amL3148RMUHZSeZ7/X9ckLq9k r39xLolrmYhIvfmCmikJH1W+xSmn2J/Qd08sOx1grXZvMkTFSVdP/yQW5fy0Cc+z+rGpZ1Hyz iXmO3Ovmg5T0uJpTgj0VCLuag4EQC86tXx+AIAAA== X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-15.tower-180.messagelabs.com!1462893065!23393129!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28688 invoked from network); 10 May 2016 15:11:05 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-15.tower-180.messagelabs.com with AES128-SHA encrypted SMTP; 10 May 2016 15:11:05 -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; Tue, 10 May 2016 16:11:06 +0100 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 6600E3FAFC; Tue, 10 May 2016 16:11:05 +0100 (BST) Message-ID: <5e2ccd9429829fc8cacf94ee8595efa6d11834f4.1462892732.git.Adam.Thomson.Opensource@diasemi.com> In-Reply-To: References: From: Adam Thomson Date: Tue, 10 May 2016 16:11:05 +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: 10/05/2016 13:08:00 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Support Opensource Subject: [alsa-devel] [PATCH 2/5] ASoC: da7213: Add checking of SRM lock status before enabling DAI 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 When the codec is DAI clk slave, and the SRM feature of the PLL is being used, the enabling of the DAI should occur only after the PLL has locked to the incoming WCLK. This update adds checking to the the DAI widget event, so it waits for SRM to lock. There is also a timeout if that lock doesn't occur within a given time. Signed-off-by: Adam Thomson --- sound/soc/codecs/da7213.c | 23 +++++++++++++++++++++++ sound/soc/codecs/da7213.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 701bd62..680d111 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -734,6 +734,9 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, { struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + u8 pll_ctrl, pll_status; + int i = 0; + bool srm_lock = false; switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -742,6 +745,26 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, snd_soc_update_bits(codec, DA7213_DAI_CLK_MODE, DA7213_DAI_CLK_EN_MASK, DA7213_DAI_CLK_EN_MASK); + + /* Slave mode, if SRM not enabled no need for status checks */ + pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL); + if (!(pll_ctrl & DA7213_PLL_SRM_EN)) + return 0; + + /* Check SRM has locked */ + do { + pll_status = snd_soc_read(codec, DA7213_PLL_STATUS); + if (pll_status & DA7219_PLL_SRM_LOCK) { + srm_lock = true; + } else { + ++i; + msleep(50); + } + } while ((i < DA7213_SRM_CHECK_RETRIES) & (!srm_lock)); + + if (!srm_lock) + dev_warn(codec->dev, "SRM failed to lock\n"); + return 0; case SND_SOC_DAPM_POST_PMD: /* Disable DAI clks if in master mode */ diff --git a/sound/soc/codecs/da7213.h b/sound/soc/codecs/da7213.h index 5de5c29..af75340 100644 --- a/sound/soc/codecs/da7213.h +++ b/sound/soc/codecs/da7213.h @@ -142,6 +142,9 @@ * Bit fields */ +/* DA7213_PLL_STATUS = 0x03 */ +#define DA7219_PLL_SRM_LOCK (0x1 << 1) + /* DA7213_SR = 0x22 */ #define DA7213_SR_8000 (0x1 << 0) #define DA7213_SR_11025 (0x2 << 0) @@ -502,6 +505,7 @@ #define DA7213_PLL_INDIV_10_20_MHZ_VAL 4 #define DA7213_PLL_INDIV_20_40_MHZ_VAL 8 #define DA7213_PLL_INDIV_40_54_MHZ_VAL 16 +#define DA7213_SRM_CHECK_RETRIES 8 enum da7213_clk_src { DA7213_CLKSRC_MCLK = 0,