From patchwork Mon Jan 15 23:16:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10165457 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 A5E6F602C2 for ; Mon, 15 Jan 2018 23:19:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 964C127B2F for ; Mon, 15 Jan 2018 23:19:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B0B127BFF; Mon, 15 Jan 2018 23:19:17 +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 DDC1227B2F for ; Mon, 15 Jan 2018 23:19:16 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 555F426765E; Tue, 16 Jan 2018 00:17:42 +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 F3A1626762E; Tue, 16 Jan 2018 00:17:31 +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 DBAD2267621 for ; Tue, 16 Jan 2018 00:17:28 +0100 (CET) Received: by mail-pl0-f68.google.com with SMTP id f4so3336283plr.10 for ; Mon, 15 Jan 2018 15:17:28 -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=tHL0A29BTk4D5dZNmqyYOAydErPe22YUkCcjk6WGjvs=; b=cGXcVu3OC5nafMvEyXXNdxk4dNrbdU5PmvODZI048gaVNYrYNoj1bGhac32FiWUdCW opxjVatxsOIGX7Z1f7Thq68k70ehgLlVTlLU8NUYuExeFPG5jP6mY1bXajnf47okMWYg AH/jDjwEmsBC5Y39x3GRVojw6Fm7mJFVshJa7XTKhj2f94T82/hyjoS40TPd5tlq32bL c560vwTSWRu8ozgJwev//7YOTEcbFw6SDw4W55ARYbPQMf5wlcHd5jkFIrLxY/esYNHB qYqXBWd6nIqxt+HttbRlyAm5sdD+Cn/lOegLSO3ci/1SCl51lMIJChyVc8Qm2M16Eu3p rQjA== 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=tHL0A29BTk4D5dZNmqyYOAydErPe22YUkCcjk6WGjvs=; b=iFOvjCGzeNvTGK1baNOrWqkWgwwPR9TTAuxHhY/wv5pvQI40mkCHqFxQXR6KTtPlKx FDJqLJpC8LiEnABYf82lzMXkKCbcGtkJAN9PKCcESMzEunFOAp7xDLpx9kvj1lr7gdb/ KhaGNHfG3CX3agqspDvasQ7mOqz+Y0ebGcAVkwlFWjsknfra9lpC1Hr6fPN1T9f1Jb04 YN7DtdZgicCx3gs0rYnOHdqjqrJ4CIJfA21AXbG+TpPn8hzBK4pUPB0Jym1RvvzWh1aO pHOk3vSHEvB5xZMQmLZBQr8UOVd2iZktf0vgaKUBuNbVnm0e4MXLuFDxcVn2GZgjhapE f53Q== X-Gm-Message-State: AKGB3mJUf6uHCoPKyoxXS7To12/iQewUzwq9iDavug7tU9/JpE4326VB HHHCfotKfNir7bKC2M+ekfU= X-Google-Smtp-Source: ACJfBosNvbcAubnu9V9wVEmRidDs8cfGPlnnFeZ8LmsHdOO7Roy04G4OS8mrJOCMcTlGnp3mcTzEtQ== X-Received: by 10.84.248.151 with SMTP id q23mr25492613pll.274.1516058248005; Mon, 15 Jan 2018 15:17:28 -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 b6sm776442pfe.85.2018.01.15.15.17.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jan 2018 15:17:27 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org, mail@maciej.szmigiero.name Date: Mon, 15 Jan 2018 15:16:21 -0800 Message-Id: <1516058192-65519-7-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516058192-65519-1-git-send-email-nicoleotsuka@gmail.com> References: <1516058192-65519-1-git-send-email-nicoleotsuka@gmail.com> Cc: alsa-devel@alsa-project.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, caleb@crome.org, lgirdwood@gmail.com, arnaud.mouiche@invoxia.com, lukma@denx.de, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH v4 06/17] 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 Tested-by: Caleb Crome --- Changelog v3 * Replaced "bool dir" with "int dir" and "int adir" v2 * Replaced bool tx with bool dir sound/soc/fsl/fsl_ssi.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index bbeef71..a2ac92f 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -410,17 +410,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 @@ -446,10 +435,11 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, struct fsl_ssi_regvals *vals) { - int adir = (&ssi->regvals[TX] == vals) ? RX : TX; - int dir = (&ssi->regvals[TX] == vals) ? TX : RX; + bool tx = &ssi->regvals[TX] == vals; struct regmap *regs = ssi->regs; struct fsl_ssi_regvals *avals; + int adir = tx ? RX : TX; + int dir = tx ? TX : RX; bool aactive; /* Check if the opposite stream is active */ @@ -489,7 +479,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); @@ -511,6 +503,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: @@ -1091,7 +1087,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: @@ -1116,14 +1111,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; }