From patchwork Tue Dec 19 17:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10123785 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 B6031603B5 for ; Tue, 19 Dec 2017 17:02:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93CAB290EB for ; Tue, 19 Dec 2017 17:02:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86D6D29120; Tue, 19 Dec 2017 17:02:15 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 9A7D1290EB for ; Tue, 19 Dec 2017 17:02:14 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9438F2676EF; Tue, 19 Dec 2017 18:01:18 +0100 (CET) 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 DD9252676D5; Tue, 19 Dec 2017 18:01:13 +0100 (CET) Received: from mail-pl0-f68.google.com (mail-pl0-f68.google.com [209.85.160.68]) by alsa0.perex.cz (Postfix) with ESMTP id 33165266D09 for ; Tue, 19 Dec 2017 18:01:11 +0100 (CET) Received: by mail-pl0-f68.google.com with SMTP id z5so7324156plo.10 for ; Tue, 19 Dec 2017 09:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BRV6Im+a8QsCIkK0dtmS6d1vop0sBVr+Nosqu+d55g4=; b=L+f/RJK8Fd9p5ZgG1CUucgJVdGKHlVjHZwQu5mJL9rQX7FZqHaq/B99BXTqVnjAy3T +2htJu+4sg3b5f5DrbF/LhOJdGXNf8E1SgYsEf+Go//PdpPQTVS/tMw5uyM5olWiPveC eQqFQQ59Cm5+XNGH4MZSF2hv8PscMj+EsGGMKcl4hl2+D0erZgL7eLdTu6WWFwDhlKus qS7cyniLElC/VRXy3U6cyvMVpw2ugBqcUx/W7e8q1KYfr40nq077fbjhqBAeI0g5hSBP LyK38QTGGtEXNqbQrIveIV4YQVAqxF1ljFZHPRtgTI72kjlnFU6HiXmieOG492zHW8Mz g36g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BRV6Im+a8QsCIkK0dtmS6d1vop0sBVr+Nosqu+d55g4=; b=kmNLnPzjNsn7XydzwvCrek/Ikf7MkU42B2v8rBszUe6Qj/lOSwRBjfVwECWqsWSoMe rTsLpmDEGuetZ1Fpon1gyMXWdJsCiiyxG+fxPA2aIgkQ8r1/LYt+mNG7OjnUxxPa9CyV QTJIIoHIHCuVDi6Og9Qzv9GHyfk4O2XYK3IdNNsDe8oaKpke+j5IjLLlULaRw6HrYY9c /+mGLqE0XDo3WKt/2rBBsMuzzLztV1kbOpqEfZF7oJ/WXz5Ncj42RvO28V8/3armehpq OavBdOWwaYunqo8i19jGRGIa1LOTjrertU5H1YkzvUdGQFLICpTi1lqnSjC+lchuHAE7 ykpg== X-Gm-Message-State: AKGB3mJVLRXBLgkD/NS9LIxj3ElpeFDD65lnhPDkJaydQICFE4HpZuTF e/mZVuTklv+9kF5TH7TtrND+9w== X-Google-Smtp-Source: ACJfBounDBE+1U7EYSZhrt21EDxP0JSVgZwz0nlvhSI7oBKV1dYDJYldVKEDWy/5nR1ARXp0cUEMoA== X-Received: by 10.84.143.129 with SMTP id 1mr3990843plz.126.1513702870519; Tue, 19 Dec 2017 09:01:10 -0800 (PST) Received: from Asurada-CZ80.localdomain (c-73-231-2-134.hsd1.ca.comcast.net. [73.231.2.134]) by smtp.gmail.com with ESMTPSA id q9sm34490181pfl.116.2017.12.19.09.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Dec 2017 09:01:09 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org Date: Tue, 19 Dec 2017 09:00:08 -0800 Message-Id: <1513702819-42310-5-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513702819-42310-1-git-send-email-nicoleotsuka@gmail.com> References: <1513702819-42310-1-git-send-email-nicoleotsuka@gmail.com> Cc: mail@maciej.szmigiero.name, kernel@pengutronix.de, lgirdwood@gmail.com, alsa-devel@alsa-project.org, caleb@crome.org, linux-kernel@vger.kernel.org, arnaud.mouiche@invoxia.com, lukma@denx.de, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH v1 04/15] ASoC: fsl_ssi: Clear FIFO directly in fsl_ssi_config() 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 The FIFO clear helper function is just one line of code now. So it could be cleaned up by removing it and calling regmap directly. Meanwhile, FIFO clear could be applied to all use cases, not confined to AC97. So this patch also moves FIFO clear in the trigger() to fsl_ssi_config() and removes the AC97 check. Note that SOR register is safe from offline_config HW limit. Signed-off-by: Nicolin Chen --- sound/soc/fsl/fsl_ssi.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 6dda2e0..0f09caf 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -406,17 +406,6 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable) } /** - * Clear remaining data in the FIFO to avoid dirty data or channel slipping - */ -static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) -{ - bool tx = !is_rx; - - regmap_update_bits(ssi->regs, REG_SSI_SOR, - SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); -} - -/** * Exclude bits that are used by the opposite stream * * When both streams are active, disabling some bits for the current stream @@ -484,7 +473,9 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, /* Online configure single direction while SSI is running */ if (enable) { - fsl_ssi_fifo_clear(ssi, vals->scr & SSI_SCR_RE); + /* Clear FIFO to prevent dirty data or channel slipping */ + regmap_update_bits(ssi->regs, REG_SSI_SOR, + SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); regmap_update_bits(regs, REG_SSI_SRCR, vals->srcr, vals->srcr); regmap_update_bits(regs, REG_SSI_STCR, vals->stcr, vals->stcr); @@ -506,6 +497,10 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, regmap_update_bits(regs, REG_SSI_SRCR, srcr, 0); regmap_update_bits(regs, REG_SSI_STCR, stcr, 0); regmap_update_bits(regs, REG_SSI_SIER, sier, 0); + + /* Clear FIFO to prevent dirty data or channel slipping */ + regmap_update_bits(ssi->regs, REG_SSI_SOR, + SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); } config_done: @@ -1086,7 +1081,6 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai); - struct regmap *regs = ssi->regs; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -1111,14 +1105,6 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, return -EINVAL; } - /* Clear corresponding FIFO */ - if (fsl_ssi_is_ac97(ssi)) { - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - regmap_write(regs, REG_SSI_SOR, SSI_SOR_TX_CLR); - else - regmap_write(regs, REG_SSI_SOR, SSI_SOR_RX_CLR); - } - return 0; }