From patchwork Tue Aug 2 15:05:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Niederpr=C3=BCm?= X-Patchwork-Id: 9258749 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 EB80A60865 for ; Tue, 2 Aug 2016 16:32:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCE9628572 for ; Tue, 2 Aug 2016 16:32:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1BD528577; Tue, 2 Aug 2016 16:32:23 +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=ham 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 B2F7C28572 for ; Tue, 2 Aug 2016 16:32:21 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D319E266B8C; Tue, 2 Aug 2016 18:32:20 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 77AE826689B; Tue, 2 Aug 2016 18:26:03 +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 73D47266898; Tue, 2 Aug 2016 18:26:02 +0200 (CEST) Received: from mailgw1.uni-kl.de (mailgw1.uni-kl.de [131.246.120.220]) by alsa0.perex.cz (Postfix) with ESMTP id 6B83B266909 for ; Tue, 2 Aug 2016 16:59:39 +0200 (CEST) Received: from [IPv6:2001:638:208:fd4e::1033] ([IPv6:2001:638:208:fd4e::1033]) by mailgw1.uni-kl.de (8.14.4/8.14.4/Debian-8) with ESMTP id u72ExbBj003678 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 2 Aug 2016 16:59:37 +0200 Message-ID: <1470150313.4786.48.camel@physik.uni-kl.de> From: Thomas =?ISO-8859-1?Q?Niederpr=FCm?= To: linux-sunxi@googlegroups.com, alsa-devel@alsa-project.org Date: Tue, 02 Aug 2016 17:05:13 +0200 Organization: TU Kaiserslautern X-Mailer: Evolution 3.20.3 Mime-Version: 1.0 Subject: [alsa-devel] ASoC: sun4i-i2s: Restricting the MCLK X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: niederp@physik.uni-kl.de 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 I am using the new sun4i-i2s driver in linux-next to run a sta326 codec via the pin header on a cubietruck (this involves some soldering as described in [1]). The codec can only be configured as slave and needs a master clock for its internal PLL. It is therefore great that, unlike many other SOCs, the a20 provides a MCLK that can be used to sync the codec. However, in my case there is a restriction imposed on the MCLK by the codec. As stated in the datasheet [2], the master clock should be at maximum 12.288 MHz/11.2896 MHz or otherwise the codec will not work (confirmed by experiment!). Since the mod clock of the a20's dai block is running at twice this frequency, I need to assure that the MLCK divider is at least 2. Actually it is rather straight forward to achieve this by changing the breaking condition in the divider calculation, as shown by the following one-line patch: Of course, this is just a hack to fix my use case and I am wondering what would be the best way to handle my corner case more generally? I see one option in introducing a DT property mlck_mindiv, or similar, that defaults to 1 and can be overwritten at the board level. I'm willing to prepare a proper patch to tackle this problem but right now I'm wondering if there a major objections to this approach or whether there is any better solution to the problem. Best regards, Thomas [1] https://hifiduino.wordpress.com/2014/03/07/cubieboard-for-audio/ [2] www.st.com/resource/en/datasheet/sta326.pdf diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 687a8f8..8920844 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -206,7 +206,7 @@ static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s,     clk_rate,     rate);   - if ((bclk_div >= 0) && (mclk_div >= 0)) + if ((bclk_div >= 0) && (mclk_div >= 1))   break;   }