From patchwork Sat Jul 29 14:17:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 9869993 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 AD9216038F for ; Sat, 29 Jul 2017 14:20:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86D8D28925 for ; Sat, 29 Jul 2017 14:20:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8325F288F1; Sat, 29 Jul 2017 14:20: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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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 B2D74288B5 for ; Sat, 29 Jul 2017 14:20:11 +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=pPts0vlwChpGBePt75UxKKzfcjLo+7cyIufZuqUF1Mk=; b=GxVVqqoSCP5WP34RR4jpUkVyp5 +HRT1uB5zBtEAt+IhlR5aHzSskx9IyKKSug0hshm2DDRKhRKGM3b/NAGVJYHNqFzvSWj2GhGh54NN 5az4Sr4J0CDBh2UtJutcAfkwCuK3nBJ659M2r9/rn+ZW7KHOLfxpkIfzpcaVoSkSuOmNVnWEEkJIh aiUErL8n7mSkOuDvugvE8+l03E4U9X8rF9NMVOWgmbJWTH1rC1TNcuAG4uFd48apHr2o2l2l6geIq YdR6HmF4o3CFog3eWEACax9UI40/b7ydSfKPZSuiUf9NMij2j3RbBmeAS0Upw0PNeQ22ffI+3H8O8 4s+xfgJA==; 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 1dbSab-0001mw-6y; Sat, 29 Jul 2017 14:19:33 +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 1dbSZT-000169-7h for linux-arm-kernel@lists.infradead.org; Sat, 29 Jul 2017 14:18:29 +0000 Received: by mail-lf0-x243.google.com with SMTP id y15so12124882lfd.5 for ; Sat, 29 Jul 2017 07:18:06 -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=gocecsd0OxAvf7RPQMgL8L0AaQSdLNe/wf03QgcOG0U=; b=FaYx6jLhp6aA08PNYrCPmLeKuEh06osQKsTsOqPKwTocsNXIFd4Lpp9ZE4AM72dm6h 0eLxzMFYZyJOw1ciwkhYVsXxbmeichHE4GUJBUzYkSbvyntRULjzMS/AJSr6DgB1pLkd NNniHgyRpXhaiqXauzDreTzUkJLikH9N0fC9IKwi8bm6hAw0NtL179+f2lSK+pNZsLHy 59XWLJJzUOGu+M+q/QK448eSSAKwy6zlfrKJTMDxs71EXZtYGp+IgaaJNPbBGRd3yiom dAvOTsd2mx3yCbj1nI+2dCihdaog/Lin23TIWhiSYmNLZNol8Wov8zI2jwzx3J4GNr71 VD4A== 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=gocecsd0OxAvf7RPQMgL8L0AaQSdLNe/wf03QgcOG0U=; b=gAYnAXsQ5V5GXAnTs2oyOyJWg+NSHyByxVpAOqbVf1QI+Q67x2KP6HxW6IYkd2iEKY FlRfIPOTgvF6ihCxocpItIci4zraITNqCMzlr2xTiFVoAcRNpFGN7eot+bjajRuGyaGz zm8M7OxwRqYBlP4GkxdU30zqVgSU3puRpxxYLfRpZrzw7kXKj6uKqzPmKqJs9Nu1rTfC SmsrvB3EF+qcCH0JCY9w5jD7w4hgRiflLhcXMhts4IntbbHcoPA1c3pDk3rzbRbNbp19 oVK1hM2aVa1yvjTW9um/OG0/WzuKQXRu8/Q27seoLT+QEhBIf16mJJrB/Fi77FbOWksr 2iag== X-Gm-Message-State: AIVw1137lyY3ZxkVt3rkUmD6uBG9WQ+k3SsBYDnPIUVZ4xOKOcJl8C+w /KwGzstrX7mPhA== X-Received: by 10.25.80.84 with SMTP id z20mr3579839lfj.157.1501337884771; Sat, 29 Jul 2017 07:18:04 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Jul 2017 07:18:04 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Subject: [PATCH v3 07/12] ASoC: sun4i-i2s: bclk and lrclk polarity tidyup Date: Sat, 29 Jul 2017 16:17:48 +0200 Message-Id: <20170729141753.20174-8-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170729_071823_665149_798C1CEB X-CRM114-Status: GOOD ( 14.45 ) 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 On newer SoCs the bit fields for the blck and lrclk polarity are in a different locations. Use regmap fields to set the polarity bits as intended. Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun4i-i2s.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 171df99a267e..90daa974bd27 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -50,6 +50,8 @@ #define SUN4I_I2S_FMT0_FMT_RIGHT_J (2 << 0) #define SUN4I_I2S_FMT0_FMT_LEFT_J (1 << 0) #define SUN4I_I2S_FMT0_FMT_I2S (0 << 0) +#define SUN4I_I2S_FMT0_POLARITY_INVERTED (1) +#define SUN4I_I2S_FMT0_POLARITY_NORMAL (0) #define SUN4I_I2S_FMT1_REG 0x08 #define SUN4I_I2S_FIFO_TX_REG 0x0c @@ -101,6 +103,8 @@ * @fmt_offset: Value by which wss and sr needs to be adjusted. * @field_fmt_set_wss: regmap field to set word select size. * @field_fmt_set_sr: regmap field to set sample resolution. + * @field_fmt_set_bclk_polarity: regmap field to set clk polarity. + * @field_fmt_set_lrclk_polarity: regmap field to set frame polarity. * @field_txchanmap: location of the tx channel mapping register. * @field_rxchanmap: location of the rx channel mapping register. * @field_txchansel: location of the tx channel select bit fields. @@ -117,6 +121,8 @@ struct sun4i_i2s_quirks { /* Register fields for i2s */ struct reg_field field_fmt_set_wss; struct reg_field field_fmt_set_sr; + struct reg_field field_fmt_set_bclk_polarity; + struct reg_field field_fmt_set_lrclk_polarity; struct reg_field field_txchanmap; struct reg_field field_rxchanmap; struct reg_field field_txchansel; @@ -137,6 +143,8 @@ struct sun4i_i2s { /* Register fields for i2s */ struct regmap_field *field_fmt_set_wss; struct regmap_field *field_fmt_set_sr; + struct regmap_field *field_fmt_set_bclk_polarity; + struct regmap_field *field_fmt_set_lrclk_polarity; struct regmap_field *field_txchanmap; struct regmap_field *field_rxchanmap; struct regmap_field *field_txchansel; @@ -332,6 +340,8 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); u32 val; + u32 bclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL; + u32 lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL; /* DAI Mode */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -356,32 +366,25 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_IB_IF: /* Invert both clocks */ - val = SUN4I_I2S_FMT0_BCLK_POLARITY_INVERTED | - SUN4I_I2S_FMT0_LRCLK_POLARITY_INVERTED; + bclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; + lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; break; case SND_SOC_DAIFMT_IB_NF: /* Invert bit clock */ - val = SUN4I_I2S_FMT0_BCLK_POLARITY_INVERTED | - SUN4I_I2S_FMT0_LRCLK_POLARITY_NORMAL; + bclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; break; case SND_SOC_DAIFMT_NB_IF: /* Invert frame clock */ - val = SUN4I_I2S_FMT0_LRCLK_POLARITY_INVERTED | - SUN4I_I2S_FMT0_BCLK_POLARITY_NORMAL; + lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; break; case SND_SOC_DAIFMT_NB_NF: - /* Nothing to do for both normal cases */ - val = SUN4I_I2S_FMT0_BCLK_POLARITY_NORMAL | - SUN4I_I2S_FMT0_LRCLK_POLARITY_NORMAL; break; default: return -EINVAL; } - regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG, - SUN4I_I2S_FMT0_BCLK_POLARITY_MASK | - SUN4I_I2S_FMT0_LRCLK_POLARITY_MASK, - val); + 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) { @@ -709,6 +712,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, .field_fmt_set_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), .field_fmt_set_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), + .field_fmt_set_bclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), + .field_fmt_set_lrclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -721,6 +726,8 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, .field_fmt_set_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), .field_fmt_set_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), + .field_fmt_set_bclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), + .field_fmt_set_lrclk_polarity = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -741,6 +748,18 @@ static int sun4i_i2s_init_regmap_fields(struct device *dev, struct sun4i_i2s *i2 if (IS_ERR(i2s->field_fmt_set_sr)) return PTR_ERR(i2s->field_fmt_set_sr); + i2s->field_fmt_set_bclk_polarity = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_set_bclk_polarity); + if (IS_ERR(i2s->field_fmt_set_bclk_polarity)) + return PTR_ERR(i2s->field_fmt_set_bclk_polarity); + + i2s->field_fmt_set_lrclk_polarity = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_set_lrclk_polarity); + if (IS_ERR(i2s->field_fmt_set_lrclk_polarity)) + return PTR_ERR(i2s->field_fmt_set_lrclk_polarity); + i2s->field_txchanmap = devm_regmap_field_alloc(dev, i2s->regmap, i2s->variant->field_txchanmap);