From patchwork Sat Jul 29 14:17:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 9870005 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 C329B60382 for ; Sat, 29 Jul 2017 14:20:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE6ED2889B for ; Sat, 29 Jul 2017 14:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2E04288E2; Sat, 29 Jul 2017 14:20:54 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM, 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 053AC28881 for ; Sat, 29 Jul 2017 14:20:53 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E5FB92677F0; Sat, 29 Jul 2017 16:18:20 +0200 (CEST) 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 026472677E8; Sat, 29 Jul 2017 16:18:16 +0200 (CEST) Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by alsa0.perex.cz (Postfix) with ESMTP id 817A12677BC for ; Sat, 29 Jul 2017 16:18:09 +0200 (CEST) Received: by mail-lf0-f66.google.com with SMTP id y15so12125026lfd.5 for ; Sat, 29 Jul 2017 07:18:09 -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=b3kWmv3+rFT8RRkwmUWRzacPXdFmR4O4GNN96u4MTwk=; b=gET6fMSThPC+9Zi1yTnBG/+60dgFbo70OHNdaLBzrLQUuYany6/bAr3UojQMj9/3xv r+6jUSDMsZutXFYOu1yP9XcuxNWsSNjjYqAMkwV2mZ3YG8nD9mEZZ35LU2z3ccVU7aOH pgpnH0ZqTfCkyTEbiBULcuqktUXQ/QR0jvtdQdv7yTc5ZFoZOjn6XsCLJnIHo3bEX1Cb 860nmeWD4jZDJ80R+A+Lb/m1GbReP4FqqRsy5sKPChOqxEZc61356Mq1LvlOYIW90h2H ZgUlY+F1pvN7bpr/eJzoHKg6hBmvhONmxkvo8riUZ9URHEXzCB5camJkqFDXwATGIJbt Hx7w== 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=b3kWmv3+rFT8RRkwmUWRzacPXdFmR4O4GNN96u4MTwk=; b=LlgsSwXxLxny88oN/jVzaRgB8AUoFIA6kBznhxRRxdz5itlC1hNKfl7nvSr8KXIrQg D1WihtfzEqTnBbbtDNrEUWkI8xqGi039KMb7cGcWv4zkL1ZFfH9tSlDp5qnYt7N+3vlH a1HmQqE1NQWMx+GP980FACiD6HnqPcfPyeKh/ZRNQa3b3G57WPen2HKApVdJEBDXJcR2 A9U2pnC9YVq6S0oOhDfkbjE1xA4rVyYnpzhPf9cr+Lt4GRO4+TS3BQIhIz/sHI9w9KwW tytj8VUqpMZ5GsFTTNff8hpAp0HqCCVHMAZi2/opNTKuJvwf1GGdok827pHUKN7qVtW6 Z0kA== X-Gm-Message-State: AIVw113M7A6TXHddhGKECz2770MTe1B/ZhbG6jMCP29QvDFATOy9YsWk 3PdzzwoEmq6GOA== X-Received: by 10.25.219.89 with SMTP id s86mr3092153lfg.110.1501337889010; Sat, 29 Jul 2017 07:18:09 -0700 (PDT) Received: from localhost.localdomain (c80-217-9-219.bredband.comhem.se. [80.217.9.219]) by smtp.gmail.com with ESMTPSA id s189sm4581958lja.77.2017.07.29.07.18.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Jul 2017 07:18:08 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Date: Sat, 29 Jul 2017 16:17:51 +0200 Message-Id: <20170729141753.20174-11-codekipper@gmail.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170729141753.20174-1-codekipper@gmail.com> References: <20170729141753.20174-1-codekipper@gmail.com> 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 Subject: [alsa-devel] [PATCH v3 10/12] ASoC: sun4i-i2s: Check for slave select bit 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 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 | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 9e060d1b73d5..1c4d763e3a8e 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; @@ -391,30 +393,32 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) regmap_field_write(i2s->field_fmt_set_bclk_polarity, bclk_polarity); regmap_field_write(i2s->field_fmt_set_lrclk_polarity, 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 | SUN4I_I2S_FIFO_CTRL_RX_MODE_MASK, SUN4I_I2S_FIFO_CTRL_TX_MODE(1) | SUN4I_I2S_FIFO_CTRL_RX_MODE(1)); + return 0; } @@ -715,6 +719,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .has_reset = false, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, .field_clkdiv_mclk_en = REG_FIELD(SUN4I_I2S_CLK_DIV_REG, SUN4I_I2S_CLK_DIV_MCLK_EN, SUN4I_I2S_CLK_DIV_MCLK_EN), @@ -733,6 +738,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .has_reset = true, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .has_slave_select_bit = true, .field_clkdiv_mclk_en = REG_FIELD(SUN4I_I2S_CLK_DIV_REG, SUN4I_I2S_CLK_DIV_MCLK_EN, SUN4I_I2S_CLK_DIV_MCLK_EN),