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: 4524631 Return-Path: X-Original-To: patchwork-linux-arm@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 901309F26C for ; Thu, 10 Jul 2014 16:16:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6F9220200 for ; Thu, 10 Jul 2014 16:16:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 35CBB20204 for ; Thu, 10 Jul 2014 16:15:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X5Gxb-0007v9-0z; Thu, 10 Jul 2014 16:12:39 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X5GxX-0007t0-Nb for linux-arm-kernel@lists.infradead.org; Thu, 10 Jul 2014 16:12:36 +0000 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 linux-arm-kernel@lists.infradead.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 Subject: [PATCH] ASoC: samsung-i2s: Maintain CDCLK settings across i2s_{shutdown/startup} 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== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140710_091235_941243_D9BC331A X-CRM114-Status: GOOD ( 15.11 ) X-Spam-Score: -5.7 (-----) 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.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;