From patchwork Mon Dec 4 20:46:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10091581 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 C984A6035E for ; Mon, 4 Dec 2017 20:50:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB4CA2879A for ; Mon, 4 Dec 2017 20:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B02A028D24; Mon, 4 Dec 2017 20:50:04 +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 CEE952879A for ; Mon, 4 Dec 2017 20:50:03 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 172072676D9; Mon, 4 Dec 2017 21:47:44 +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 184B02676D8; Mon, 4 Dec 2017 21:47:43 +0100 (CET) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by alsa0.perex.cz (Postfix) with ESMTP id 13AF6267660 for ; Mon, 4 Dec 2017 21:47:32 +0100 (CET) Received: by mail-pf0-f195.google.com with SMTP id m26so9426888pfj.11 for ; Mon, 04 Dec 2017 12:47:32 -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=vBDIXwPnN5dM8tUeT3XT5U0iYkgrvA845OcTvPjwmHM=; b=IQVPiyPxIQmLngtRCARQac7kBUL2cQ74LofWWfCYSjVJtALIEZUDGXWDfttmleuifk AMTAAo3sYifOJF6FtFdRsDcQ5NqT0fpy1qhETHvs7N5tTd8HEpQghmYM2wBebgUjPc5X 1dkkQRPPRSlopTqAy3y/nLhN4leCL7IG5AqUdvsEZqsnaGHmV15KfVSnkxsGINSzbMzP 1FK5dyaC4AbCwEt4VSXV018aWV/v2/BJc3Ht6NEyqqL6PPxk23kogep4FWs0EYR5O71/ Y2EMWybNaodrDy6LV5kMER8NveWO9y369aR1u4te9nSUoIElgPolheFLEz96leoaveEN gN7A== 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=vBDIXwPnN5dM8tUeT3XT5U0iYkgrvA845OcTvPjwmHM=; b=oUjSBOmSx6JK6D1dnZ0SXF5qGFnooFedXc71xWGRuSgAUz1wPTeBdzrt1d5FD9rsI9 3HBQObsjSm37tZhreTHr+OqJYx1fHOemhU/qqEBxtJchdgWJWNob1mrnIlIXS3lvC+op D9qhM+/szGuBb0gf0TOl1gBLvqdx5Kla3baqyrIgsXljMerNzZXnHu4Aygp8RNZy0Jmd 6KO+aheIHBdBbEl8LmPo8EchZg4n1eFVaHikHyhQXScKH2Oe9jivbJgCwkR16OCLn3H5 YRY7JXPzksl6TI9DCI1d9XhKO7jZh+nPLL2lk1oKXCQTxp6tTtUDWLx84XrqmgNtiV8s gUAg== X-Gm-Message-State: AJaThX5ZMsOPTh6l7K95yb7fSXgeiOY16NXNOytTXPoeCk758ZghxBWC pFI9cHHZWTJqiVottRXFy/s= X-Google-Smtp-Source: AGs4zMYLOxAk27Gqld1vzpnwmrhBanZ9gnN3g4kE7P2pyiDdd8D9TatR4TbCcNNEcozQ7me3Dluk+A== X-Received: by 10.101.92.138 with SMTP id a10mr14732924pgt.6.1512420451630; Mon, 04 Dec 2017 12:47:31 -0800 (PST) Received: from Asurada-Nvidia.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c11sm22263895pgv.42.2017.12.04.12.47.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 12:47:30 -0800 (PST) From: Nicolin Chen To: broonie@kernel.org Date: Mon, 4 Dec 2017 12:46:43 -0800 Message-Id: <1512420403-10164-11-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1512420403-10164-1-git-send-email-nicoleotsuka@gmail.com> References: <1512420403-10164-1-git-send-email-nicoleotsuka@gmail.com> Cc: mail@maciej.szmigiero.name, timur@tabi.org, lgirdwood@gmail.com, alsa-devel@alsa-project.org, caleb@crome.org, linux-kernel@vger.kernel.org, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH 10/10] ASoC: fsl_ssi: Replace fsl_ssi_rxtx_reg_val with fsl_ssi_regvals 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 name fsl_ssi_rxtx_reg_val is too long to read comfortably. So this patch shortens it by using an array (fsl_ssi_regvals, renamed from fsl_ssi_reg_val). To do that, it also introduces two macros (TX and RX) to replace the wrapper structure. This will also help for further cleanups. Meanwhile, it unifies all local variable with the name "vals" to get rid of the name "reg" -- could be confusing with "regs" in the private struct for regmap. Signed-off-by: Nicolin Chen --- sound/soc/fsl/fsl_ssi.c | 79 +++++++++++++++++++++++-------------------------- sound/soc/fsl/fsl_ssi.h | 3 ++ 2 files changed, 40 insertions(+), 42 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 55f6a1f..50b470d 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -106,18 +106,13 @@ enum fsl_ssi_type { FSL_SSI_MX51, }; -struct fsl_ssi_reg_val { +struct fsl_ssi_regvals { u32 sier; u32 srcr; u32 stcr; u32 scr; }; -struct fsl_ssi_rxtx_reg_val { - struct fsl_ssi_reg_val rx; - struct fsl_ssi_reg_val tx; -}; - static bool fsl_ssi_readable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -213,7 +208,7 @@ struct fsl_ssi_soc_data { * @fifo_depth: Depth of the SSI FIFOs * @slot_width: Width of each DAI slot * @slots: Number of slots - * @rxtx_reg_val: Specific RX/TX register settings + * @regvals: Specific RX/TX register settings * * @clk: Clock source to access register * @baudclk: Clock source to generate bit and frame-sync clocks @@ -257,7 +252,7 @@ struct fsl_ssi { unsigned int fifo_depth; unsigned int slot_width; unsigned int slots; - struct fsl_ssi_rxtx_reg_val rxtx_reg_val; + struct fsl_ssi_regvals regvals[2]; struct clk *clk; struct clk *baudclk; @@ -379,25 +374,25 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable) { struct regmap *regs = ssi->regs; - struct fsl_ssi_rxtx_reg_val *vals = &ssi->rxtx_reg_val; + struct fsl_ssi_regvals *vals = ssi->regvals; if (enable) { regmap_update_bits(regs, REG_SSI_SIER, - vals->rx.sier | vals->tx.sier, - vals->rx.sier | vals->tx.sier); + vals[RX].sier | vals[TX].sier, + vals[RX].sier | vals[TX].sier); regmap_update_bits(regs, REG_SSI_SRCR, - vals->rx.srcr | vals->tx.srcr, - vals->rx.srcr | vals->tx.srcr); + vals[RX].srcr | vals[TX].srcr, + vals[RX].srcr | vals[TX].srcr); regmap_update_bits(regs, REG_SSI_STCR, - vals->rx.stcr | vals->tx.stcr, - vals->rx.stcr | vals->tx.stcr); + vals[RX].stcr | vals[TX].stcr, + vals[RX].stcr | vals[TX].stcr); } else { regmap_update_bits(regs, REG_SSI_SRCR, - vals->rx.srcr | vals->tx.srcr, 0); + vals[RX].srcr | vals[TX].srcr, 0); regmap_update_bits(regs, REG_SSI_STCR, - vals->rx.stcr | vals->tx.stcr, 0); + vals[RX].stcr | vals[TX].stcr, 0); regmap_update_bits(regs, REG_SSI_SIER, - vals->rx.sier | vals->tx.sier, 0); + vals[RX].sier | vals[TX].sier, 0); } } @@ -439,10 +434,10 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) * Enable or disable SSI configuration. */ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, - struct fsl_ssi_reg_val *vals) + struct fsl_ssi_regvals *vals) { struct regmap *regs = ssi->regs; - struct fsl_ssi_reg_val *avals; + struct fsl_ssi_regvals *avals; int nr_active_streams; u32 scr; int keep_active; @@ -457,10 +452,10 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, keep_active = 0; /* Get the opposite direction to keep its values untouched */ - if (&ssi->rxtx_reg_val.rx == vals) - avals = &ssi->rxtx_reg_val.tx; + if (&ssi->regvals[RX] == vals) + avals = &ssi->regvals[TX]; else - avals = &ssi->rxtx_reg_val.rx; + avals = &ssi->regvals[RX]; if (!enable) { /* Exclude necessary bits for the opposite stream */ @@ -537,7 +532,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, static void fsl_ssi_rx_config(struct fsl_ssi *ssi, bool enable) { - fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.rx); + fsl_ssi_config(ssi, enable, &ssi->regvals[RX]); } static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi) @@ -565,38 +560,38 @@ static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable) if (enable && fsl_ssi_is_ac97(ssi)) fsl_ssi_tx_ac97_saccst_setup(ssi); - fsl_ssi_config(ssi, enable, &ssi->rxtx_reg_val.tx); + fsl_ssi_config(ssi, enable, &ssi->regvals[TX]); } /** * Cache register values to later set them at once */ -static void fsl_ssi_setup_reg_vals(struct fsl_ssi *ssi) +static void fsl_ssi_setup_regvals(struct fsl_ssi *ssi) { - struct fsl_ssi_rxtx_reg_val *reg = &ssi->rxtx_reg_val; + struct fsl_ssi_regvals *vals = ssi->regvals; - reg->rx.sier = SSI_SIER_RFF0_EN; - reg->rx.srcr = SSI_SRCR_RFEN0; - reg->rx.scr = 0; - reg->tx.sier = SSI_SIER_TFE0_EN; - reg->tx.stcr = SSI_STCR_TFEN0; - reg->tx.scr = 0; + vals[RX].sier = SSI_SIER_RFF0_EN; + vals[RX].srcr = SSI_SRCR_RFEN0; + vals[RX].scr = 0; + vals[TX].sier = SSI_SIER_TFE0_EN; + vals[TX].stcr = SSI_STCR_TFEN0; + vals[TX].scr = 0; if (!fsl_ssi_is_ac97(ssi)) { - reg->rx.scr = SSI_SCR_SSIEN | SSI_SCR_RE; - reg->tx.scr = SSI_SCR_SSIEN | SSI_SCR_TE; + vals[RX].scr = SSI_SCR_SSIEN | SSI_SCR_RE; + vals[TX].scr = SSI_SCR_SSIEN | SSI_SCR_TE; } if (ssi->use_dma) { - reg->rx.sier |= SSI_SIER_RDMAE; - reg->tx.sier |= SSI_SIER_TDMAE; + vals[RX].sier |= SSI_SIER_RDMAE; + vals[TX].sier |= SSI_SIER_TDMAE; } else { - reg->rx.sier |= SSI_SIER_RIE; - reg->tx.sier |= SSI_SIER_TIE; + vals[RX].sier |= SSI_SIER_RIE; + vals[TX].sier |= SSI_SIER_TIE; } - reg->rx.sier |= FSLSSI_SIER_DBG_RX_FLAGS; - reg->tx.sier |= FSLSSI_SIER_DBG_TX_FLAGS; + vals[RX].sier |= FSLSSI_SIER_DBG_RX_FLAGS; + vals[TX].sier |= FSLSSI_SIER_DBG_TX_FLAGS; } static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi) @@ -862,7 +857,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, return -EINVAL; } - fsl_ssi_setup_reg_vals(ssi); + fsl_ssi_setup_regvals(ssi); regmap_read(regs, REG_SSI_SCR, &scr); scr &= ~(SSI_SCR_SYN | SSI_SCR_I2S_MODE_MASK); diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h index 7bb8a08..71a305c 100644 --- a/sound/soc/fsl/fsl_ssi.h +++ b/sound/soc/fsl/fsl_ssi.h @@ -12,6 +12,9 @@ #ifndef _MPC8610_I2S_H #define _MPC8610_I2S_H +#define RX 0 +#define TX 1 + /* -- SSI Register Map -- */ /* SSI Transmit Data Register 0 */