From patchwork Thu Jul 10 16:11:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 4524661 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 918779F1C4 for ; Thu, 10 Jul 2014 16:33:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC471201F4 for ; Thu, 10 Jul 2014 16:33:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DC12C2020F for ; Thu, 10 Jul 2014 16:33:26 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id F17E2265062; Thu, 10 Jul 2014 18:33:24 +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 C6475265083; Thu, 10 Jul 2014 18:26:48 +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 309F1265083; Thu, 10 Jul 2014 18:26:47 +0200 (CEST) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by alsa0.perex.cz (Postfix) with ESMTP id 4FE4C265510 for ; Thu, 10 Jul 2014 18:12:14 +0200 (CEST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N8I00D7C7OBDT00@mailout4.samsung.com> for alsa-devel@alsa-project.org; Fri, 11 Jul 2014 01:12:11 +0900 (KST) X-AuditID: cbfee61b-f79f86d00000144c-ff-53bebb5bd301 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 34.6C.05196.B5BBEB35; Fri, 11 Jul 2014 01:12:11 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N8I007O57MT4A80@mmp2.samsung.com>; Fri, 11 Jul 2014 01:12:11 +0900 (KST) From: Sylwester Nawrocki To: broonie@kernel.org Date: Thu, 10 Jul 2014 18:11:13 +0200 Message-id: <1405008673-15994-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPJMWRmVeSWpSXmKPExsVy+t9jQd3o3fuCDc7sUrO4cvEQk8XUh0/Y LB7Nf8xssenxNVaLGef3MVkcftPOarH53T9WB3aPDZ+b2DwWfc/y2LSqk81j85J6j74tqxg9 Pm+SC2CL4rJJSc3JLEst0rdL4Mr4PPMca0Evf8Xi649YGhjn8XQxcnJICJhINM55ygJhi0lc uLeerYuRi0NIYDqjxPpp+9ghnA4mid8XTzCCVLEJGEr0Hu0Ds0WAOm7P6WQGKWIWuMgocW3F VmaQhLBAtMSHybOYQGwWAVWJCUdus4PYvAJuEvP2PgWKcwCtU5CYM8lmAiP3AkaGVYyiqQXJ BcVJ6blGesWJucWleel6yfm5mxjBwfJMegfjqgaLQ4wCHIxKPLwn1uwLFmJNLCuuzD3EKMHB rCTCW74CKMSbklhZlVqUH19UmpNafIhRmoNFSZz3YKt1oJBAemJJanZqakFqEUyWiYNTqoEx OjTubvw2l/4lM59dWa6bvKJAo3wp/4Ge6PWrJvtYOmXU7vdf1R0TsXrHJkm+1QJ/BWudNVM5 Vs2RUlrN9kRF+PpHCZuUZR4B7fkBbP3NJ5Zv+BtamM0rwyoVu6eRg/VUfNd9XeXLracqn147 qDVxCvPPBT5frH/9bTmcPD1Nl/3vleY3rzSUWIozEg21mIuKEwEmrMFTEgIAAA== Cc: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, Chen Zhen , drake@endlessm.com, Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH] ASoC: samsung-i2s: Maintain CDCLK settings across i2s_{shutdown/startup} 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 Currently configuration of the CDCLK pad is being overwritten in the i2s_shutdown() callback in order to gate the SoC output clock. However if an ASoC machine driver doesn't restore that clock settings each time after opening the sound device this results in the CDCLK pin being permanently configured into input mode. I.e. the output clock will always stay disabled. Fix that by saving the CDCLKCON bit state in i2s_shutdown() and and restoring it in the i2s_startup() callback. Signed-off-by: Chen Zhen Signed-off-by: Sylwester Nawrocki --- sound/soc/samsung/i2s.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 2ac76fa..3cb3e95 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -68,6 +68,8 @@ struct i2s_dai { #define DAI_OPENED (1 << 0) /* Dai is opened */ #define DAI_MANAGER (1 << 1) /* Dai is the manager */ unsigned mode; + /* CDCLK pin direction: 0 - input, 1 - output */ + unsigned int cdclk_out:1; /* Driver for this DAI */ struct snd_soc_dai_driver i2s_dai_drv; /* DMA parameters */ @@ -737,6 +739,9 @@ static int i2s_startup(struct snd_pcm_substream *substream, spin_unlock_irqrestore(&lock, flags); + if (!is_opened(other) && i2s->cdclk_out) + i2s_set_sysclk(dai, SAMSUNG_I2S_CDCLK, + 0, SND_SOC_CLOCK_OUT); return 0; } @@ -752,9 +757,13 @@ static void i2s_shutdown(struct snd_pcm_substream *substream, i2s->mode &= ~DAI_OPENED; i2s->mode &= ~DAI_MANAGER; - if (is_opened(other)) + if (is_opened(other)) { other->mode |= DAI_MANAGER; - + } else { + u32 mod = readl(i2s->addr + I2SMOD); + i2s->cdclk_out = !(mod & MOD_CDCLKCON); + other->cdclk_out = i2s->cdclk_out; + } /* Reset any constraint on RFS and BFS */ i2s->rfs = 0; i2s->bfs = 0;