From patchwork Sat Aug 12 11:00:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 9897013 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 55B6860351 for ; Sat, 12 Aug 2017 11:04:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46A6728614 for ; Sat, 12 Aug 2017 11:04:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B69628B67; Sat, 12 Aug 2017 11:04:33 +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=-2.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 C089428614 for ; Sat, 12 Aug 2017 11:04:32 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Abo3lHZp+arOdq6sfYzipqci45Uwo2pcol/nSqYVVvw=; b=ODqDlbrssn4skme7IHDyjnE0MS GpzblMCkmW75VGJ64OGqTVTXxg7Th4PVqi5twG+6nmt8EE2W294wpvAA+9Hd0CiOV6zipmg3S4O41 x3LMxtmsnUEEsIrp2apu1evFA8sE4BwgKJRx2upiAO9CUd4OGWD+kRTaMH3bR6uZT4Jl7wyfgLohA 7fPcFyV8fwQH6vOUPuK4CpDNZTPhoYc8nODTgLmraRg2ESRaeP93hxHjXvJuN6gwyasbcd/5sWZp7 hOPlyg3yPl7o/kSnoG2sH/EZ3PuYhFzXZoJp1ODak2d/uz3pYJw8nFnunnGyxzToOMslvjspy1BqF rqAl02KQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dgUDT-0001nw-DG; Sat, 12 Aug 2017 11:04:27 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dgUAl-00087f-3t for linux-arm-kernel@lists.infradead.org; Sat, 12 Aug 2017 11:01:49 +0000 Received: by mail-lf0-x243.google.com with SMTP id w199so3710683lff.2 for ; Sat, 12 Aug 2017 04:01:20 -0700 (PDT) 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=yAm32XvjZ/mLLfkGX6S4HJ/9yCQhrlnB18PdZKTNtQU=; b=iAhS7KJmnVmx+4XRApH0G11yoxdJ+ubSOPCSR3sOjf7joySZqA2n//jiHD8Q7z0t2c yiZ1c4TCwfE+7OEcxDu6OX7dTNsaj5CybNB82uBfM+ToglcL7lRt48mgB+sO2FGUCDdc co2hjmOhfZGWn4WPZutDcGUkE9Mbz7dWgIiqaOQYGbrU4NoWrn4LpjYYdvyhG/tXeNEO SeHeDY9GNc54FrcjAxrAqbkJFWhg0wZZV5X0skwtYMuedf3562+pgjdRXSdhAm+QE5kV R9lB3C9jF6RY170koLNLAGBzKbG9dUh7sXVws5HDHkF9xjaUQc3N3nIjJ05UxfnG7dzc R2Uw== 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=yAm32XvjZ/mLLfkGX6S4HJ/9yCQhrlnB18PdZKTNtQU=; b=QcjeLOgvT8ZDRmjkdyuBClsfiOT3RKKyI+DcoD92URCKljYkzLfhWTSWvjTfXGTiHg VlZ//tU6L93bSKv7W+7VIY+oiyxfZkOfFqgCGPN0Lm3KMpG1cNI/PQ2/Uin2MOWD+nyg Q7SrirmrF/ti1qlMT5f7HbXqox/Cm83Cfpp88RLItDW6KCOkCSS3NQJKU9uqYTCljklF xB3Nfi5POP9iCqMSmn+PtxL9c/9XAZzbfCISzyIniFOODyIwPoFoaDJVQ9PAl/lllbql k+0GjNPR9CJXd5mrC7pDjxxud+aF9Kfbno9GlqWqkmtDNaLl8x7Wj4kLMVp0Ch2vAyvq rsKg== X-Gm-Message-State: AHYfb5hWtcu81kXtJLBmSlnwlISQHMxZ1GSRmduKAnaT9fRh38Bw62yF XVjeHBJdm1/0vA== X-Received: by 10.46.7.67 with SMTP id i3mr5537169ljd.90.1502535678642; Sat, 12 Aug 2017 04:01:18 -0700 (PDT) Received: from localhost.localdomain (c80-217-9-219.bredband.comhem.se. [80.217.9.219]) by smtp.gmail.com with ESMTPSA id h22sm432402ljb.41.2017.08.12.04.01.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Aug 2017 04:01:17 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Subject: [PATCH v3 09/11] ASoC: sun4i-i2s: Check for slave select bit Date: Sat, 12 Aug 2017 13:00:57 +0200 Message-Id: <20170812110059.5115-10-codekipper@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170812110059.5115-1-codekipper@gmail.com> References: <20170812110059.5115-1-codekipper@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170812_040140_049909_973E70A3 X-CRM114-Status: GOOD ( 13.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, Marcus Cooper , lgirdwood@gmail.com, linux-kernel@vger.kernel.org, be17068@iperbole.bo.it, linux-sunxi@googlegroups.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 From: Marcus Cooper The newer SoCs do not have this setting. Instead they set the pin direction. Add a check to see if the bit is valid and if so set it accordingly. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai --- sound/soc/sunxi/sun4i-i2s.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index b61ef87d0049..475572e1c586 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -96,6 +96,7 @@ * struct sun4i_i2s_quirks - Differences between SoC variants. * * @has_reset: SoC needs reset deasserted. + * @has_slave_select_bit: SoC has a bit to enable slave mode. * @reg_offset_txdata: offset of the tx fifo. * @sun4i_i2s_regmap: regmap config to use. * @mclk_offset: Value by which mclkdiv needs to be adjusted. @@ -114,6 +115,7 @@ */ struct sun4i_i2s_quirks { bool has_reset; + bool has_slave_select_bit; unsigned int reg_offset_txdata; /* TX FIFO */ const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; @@ -394,24 +396,25 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) regmap_field_write(i2s->field_fmt_bclk, bclk_polarity); regmap_field_write(i2s->field_fmt_lrclk, lrclk_polarity); - /* DAI clock master masks */ - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - /* BCLK and LRCLK master */ - val = SUN4I_I2S_CTRL_MODE_MASTER; - break; - case SND_SOC_DAIFMT_CBM_CFM: - /* BCLK and LRCLK slave */ - val = SUN4I_I2S_CTRL_MODE_SLAVE; - break; - default: - return -EINVAL; + if (i2s->variant->has_slave_select_bit) { + /* DAI clock master masks */ + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + /* BCLK and LRCLK master */ + val = SUN4I_I2S_CTRL_MODE_MASTER; + break; + case SND_SOC_DAIFMT_CBM_CFM: + /* BCLK and LRCLK slave */ + val = SUN4I_I2S_CTRL_MODE_SLAVE; + break; + default: + return -EINVAL; + } + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_MODE_MASK, + val); } - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_MODE_MASK, - val); - /* Set significant bits in our FIFOs */ regmap_update_bits(i2s->regmap, SUN4I_I2S_FIFO_CTRL_REG, SUN4I_I2S_FIFO_CTRL_TX_MODE_MASK | @@ -723,6 +726,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), + .has_slave_select_bit = true, .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), @@ -739,6 +743,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), + .has_slave_select_bit = true, .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),