From patchwork Mon Jul 22 18:27:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11053273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F86E746 for ; Mon, 22 Jul 2019 18:30:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F347921FAD for ; Mon, 22 Jul 2019 18:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E396126E76; Mon, 22 Jul 2019 18:30:11 +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=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E37021FAD for ; Mon, 22 Jul 2019 18:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:References :In-Reply-To:Message-Id:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I/6chfMjXrpVuKLj+nTIORgYYn3y2lj//mhzO6abHfg=; b=fUbMUawJ3Hn3rB ERyQGfpgTRmz0tknHMu2M3dxLWAZfnxkndQst9aBrqeChebKUV6IbSWGSQZe8JO2LUCiuBz9Imnc1 EFX13zL/G3AyWBepyvBhelHZ91pYEP1TWSYFPEPFAYssqdO/4aZwBvwOlhOuzWR792HVbmlF7TZJP H/st932j+qOSog3GeChRhkEZPItHmBcfyK8cc/S2Qawcaqo/hL2jLthhn3yDJx7DI5jPrXU3plyF2 upRk0vXWyfUOyc0ms8lXn3d+UmgZW9D3wTirUAlS5UzvvUXQaCfXufwJJmK2ZonQKpMj6IhYRkNje lKaZLNXlbDzp/5Mrr0dw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpd4U-0002cD-JK; Mon, 22 Jul 2019 18:30:03 +0000 Received: from rere.qmqm.pl ([91.227.64.183]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hpd27-0001U3-Qe for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2019 18:27:38 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 45sqmq1HX7zPG; Mon, 22 Jul 2019 20:26:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1563819963; bh=RAkdSRMcVQNhW3bmtlHKYOaZmPW+rVTN4yB7nHM+sKc=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=BD9f7v9aHJJwEd1FU5bbFKO0qAU5yjOw/mOe+GgMy2Dhh+BfifJaRF2bKFAd+j78d p3v7FIRbqe7GiMsRPTChLE/FHccaR6b5fiZsUAJ/nTOlFs9MyqUUgjSMWnZIVv+heC Q1lSjgsMvkw859WfNixgWdrcUmjoAT3mo5eKyoUq4oEiR5xv27JwHay88sLbRdXrPt HCE4krRuGQF9cM+u8PqrMuCtVUAE0Jr3a2llVJ89ACBNinoOpAq9l23WMxpykTsM4l v3Wkl6H0+S2p2bgy8gss5VhFzn1x7kQfDS8tZk8Ul+EXg7YN9IgQv2KnWM21/Yi1vE ADEK/3CmMATDw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.3 at mail Date: Mon, 22 Jul 2019 20:27:21 +0200 Message-Id: <107e0cfd11a31ce1558e941612e183100022930d.1563819483.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 5/5] ASoC: atmel_ssc_dai: Enable shared FSYNC source in frame-slave mode MIME-Version: 1.0 To: alsa-devel@alsa-project.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190722_112736_547934_E6A745C2 X-CRM114-Status: GOOD ( 14.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Takashi Iwai , Liam Girdwood , Ludovic Desroches , Mark Brown , Codrin Ciubotariu , Jaroslav Kysela , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP SSC driver allows only synchronous TX and RX. In slave mode for BCLK it uses only one of TK or RK pin, but for LRCLK it configured separate inputs from TF and RF pins. Allow configuration with common FS signal. Signed-off-by: Michał Mirosław --- .../devicetree/bindings/misc/atmel-ssc.txt | 4 ++ drivers/misc/atmel-ssc.c | 2 + include/linux/atmel-ssc.h | 1 + sound/soc/atmel/atmel_ssc_dai.c | 48 ++++++++++++------- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt index f9fb412642fe..89133c5b82cb 100644 --- a/Documentation/devicetree/bindings/misc/atmel-ssc.txt +++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt @@ -24,6 +24,10 @@ Optional properties: this parameter to choose where the clock from. - By default the clock is from TK pin, if the clock from RK pin, this property is needed. + - atmel,shared-fs-pin: bool property. + - When SSC works in slave mode, by default it gets separate LRCLK signals + from RF and TF. This property makes SSC use a single pin for both + RX and TX. TF is used unless atmel,clk-from-rk-pin is also present. - #sound-dai-cells: Should contain <0>. - This property makes the SSC into an automatically registered DAI. diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index ab4144ea1f11..da63eee1cdf5 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -210,6 +210,8 @@ static int ssc_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; ssc->clk_from_rk_pin = of_property_read_bool(np, "atmel,clk-from-rk-pin"); + ssc->shared_fs_pin = + of_property_read_bool(np, "atmel,shared-fs-pin"); } regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/include/linux/atmel-ssc.h b/include/linux/atmel-ssc.h index 6091d2abc1eb..46fdff2dfbb0 100644 --- a/include/linux/atmel-ssc.h +++ b/include/linux/atmel-ssc.h @@ -21,6 +21,7 @@ struct ssc_device { int user; int irq; bool clk_from_rk_pin; + bool shared_fs_pin; bool sound_dai; }; diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index cf2cfc345676..6f595a748618 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -471,7 +471,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, int dir, channels, bits; u32 tfmr, rfmr, tcmr, rcmr; int ret; - int fslen, fslen_ext, fs_osync; + int fslen, fslen_ext, fs_osync, fs_edge; u32 cmr_div; u32 tcmr_period; u32 rcmr_period; @@ -567,24 +567,20 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, case SND_SOC_DAIFMT_LEFT_J: /* left-justified format */ fs_osync = SSC_FSOS_POSITIVE; + fs_edge = SSC_START_RISING_TF; - rcmr = SSC_BF(RCMR_STTDLY, 0) - | SSC_BF(RCMR_START, SSC_START_RISING_RF); - - tcmr = SSC_BF(TCMR_STTDLY, 0) - | SSC_BF(TCMR_START, SSC_START_RISING_TF); + rcmr = SSC_BF(RCMR_STTDLY, 0); + tcmr = SSC_BF(TCMR_STTDLY, 0); break; case SND_SOC_DAIFMT_I2S: /* I2S format = left-justified with start bit and inverted LRCLK */ fs_osync = SSC_FSOS_NEGATIVE; + fs_edge = SSC_START_FALLING_TF; - rcmr = SSC_BF(RCMR_STTDLY, 1) - | SSC_BF(RCMR_START, SSC_START_FALLING_RF); - - tcmr = SSC_BF(TCMR_STTDLY, 1) - | SSC_BF(TCMR_START, SSC_START_FALLING_TF); + rcmr = SSC_BF(RCMR_STTDLY, 1); + tcmr = SSC_BF(TCMR_STTDLY, 1); break; @@ -597,13 +593,11 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, * the left channel data. */ fs_osync = SSC_FSOS_POSITIVE; + fs_edge = SSC_START_RISING_TF; fslen = fslen_ext = 0; - rcmr = SSC_BF(RCMR_STTDLY, 1) - | SSC_BF(RCMR_START, SSC_START_RISING_RF); - - tcmr = SSC_BF(TCMR_STTDLY, 1) - | SSC_BF(TCMR_START, SSC_START_RISING_TF); + rcmr = SSC_BF(RCMR_STTDLY, 1); + tcmr = SSC_BF(TCMR_STTDLY, 1); break; @@ -613,10 +607,30 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - if (!atmel_ssc_cfs(ssc_p)) { + if (atmel_ssc_cfs(ssc_p)) { + /* + * SSC provides LRCLK + * + * Both TF and RF are generated, so use them directly. + */ + rcmr |= SSC_BF(RCMR_START, fs_edge); + tcmr |= SSC_BF(TCMR_START, fs_edge); + } else { fslen = fslen_ext = 0; rcmr_period = tcmr_period = 0; fs_osync = SSC_FSOS_NONE; + if (!ssc->shared_fs_pin) { + rcmr |= SSC_BF(RCMR_START, fs_edge); + tcmr |= SSC_BF(TCMR_START, fs_edge); + } else if (ssc->clk_from_rk_pin) { + /* assume RF is to be used when RK is used as BCLK input */ + /* Note: won't work correctly on SAMA5D2 due to errata */ + rcmr |= SSC_BF(RCMR_START, fs_edge); + tcmr |= SSC_BF(TCMR_START, SSC_START_RECEIVE); + } else { + rcmr |= SSC_BF(RCMR_START, SSC_START_TRANSMIT); + tcmr |= SSC_BF(TCMR_START, fs_edge); + } } if (atmel_ssc_cbs(ssc_p)) {