devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sugar Zhang <sugar.zhang@rock-chips.com>
To: broonie@kernel.org, heiko@sntech.de
Cc: linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
	alsa-devel@alsa-project.org,
	Sugar Zhang <sugar.zhang@rock-chips.com>
Subject: [PATCH v2 06/15] ASoC: rockchip: i2s: Reset the controller if soft reset failed
Date: Tue, 24 Aug 2021 17:17:53 +0800	[thread overview]
Message-ID: <1629796682-4170-1-git-send-email-sugar.zhang@rock-chips.com> (raw)
In-Reply-To: <1629796561-4025-1-git-send-email-sugar.zhang@rock-chips.com>

This patch brings i2s back to normal by resetting i2s m/h
when the soft reset failed.

Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
---

Changes in v2: None

 sound/soc/rockchip/rockchip_i2s.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index 0ba728f..78321ee 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -15,6 +15,7 @@
 #include <linux/clk.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
+#include <linux/reset.h>
 #include <linux/spinlock.h>
 #include <sound/pcm_params.h>
 #include <sound/dmaengine_pcm.h>
@@ -40,6 +41,8 @@ struct rk_i2s_dev {
 
 	struct regmap *regmap;
 	struct regmap *grf;
+	struct reset_control *reset_m;
+	struct reset_control *reset_h;
 
 /*
  * Used to indicate the tx/rx status.
@@ -92,6 +95,20 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai)
 	return snd_soc_dai_get_drvdata(dai);
 }
 
+static void rockchip_i2s_reset(struct rk_i2s_dev *i2s)
+{
+	dev_warn(i2s->dev, "Reset controller.\n");
+
+	reset_control_assert(i2s->reset_m);
+	reset_control_assert(i2s->reset_h);
+	udelay(1);
+	reset_control_deassert(i2s->reset_m);
+	reset_control_deassert(i2s->reset_h);
+
+	regcache_mark_dirty(i2s->regmap);
+	regcache_sync(i2s->regmap);
+}
+
 static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
 {
 	unsigned int val = 0;
@@ -132,7 +149,7 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
 				regmap_read(i2s->regmap, I2S_CLR, &val);
 				retry--;
 				if (!retry) {
-					dev_warn(i2s->dev, "fail to clear\n");
+					rockchip_i2s_reset(i2s);
 					break;
 				}
 			}
@@ -181,7 +198,7 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
 				regmap_read(i2s->regmap, I2S_CLR, &val);
 				retry--;
 				if (!retry) {
-					dev_warn(i2s->dev, "fail to clear\n");
+					rockchip_i2s_reset(i2s);
 					break;
 				}
 			}
@@ -629,6 +646,14 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
 		i2s->pins = of_id->data;
 	}
 
+	i2s->reset_m = devm_reset_control_get_optional(&pdev->dev, "reset-m");
+	if (IS_ERR(i2s->reset_m))
+		return PTR_ERR(i2s->reset_m);
+
+	i2s->reset_h = devm_reset_control_get_optional(&pdev->dev, "reset-h");
+	if (IS_ERR(i2s->reset_h))
+		return PTR_ERR(i2s->reset_h);
+
 	/* try to prepare related clocks */
 	i2s->hclk = devm_clk_get(&pdev->dev, "i2s_hclk");
 	if (IS_ERR(i2s->hclk)) {
-- 
2.7.4




  parent reply	other threads:[~2021-08-24  9:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24  9:16 [PATCH v2 0/15] Patches to update for rockchip i2s Sugar Zhang
2021-08-24  9:17 ` [PATCH v2 01/15] ASoC: rockchip: i2s: Add support for set bclk ratio Sugar Zhang
2021-08-24  9:17 ` [PATCH v2 02/15] ASoC: rockchip: i2s: Fixup clk div error Sugar Zhang
2021-08-24  9:17 ` [PATCH v2 03/15] ASoC: rockchip: i2s: Improve dma data transfer efficiency Sugar Zhang
2021-08-24  9:17 ` [PATCH v2 04/15] ASoC: rockchip: i2s: Fix regmap_ops hang Sugar Zhang
2021-08-24  9:17 ` [PATCH v2 05/15] ASoC: rockchip: i2s: Fix concurrency between tx/rx Sugar Zhang
2021-08-24  9:17 ` Sugar Zhang [this message]
2021-08-24  9:17 ` [PATCH v2 07/15] ASoC: dt-bindings: rockchip: Document reset property for i2s Sugar Zhang
2021-08-24 17:01   ` Rob Herring
2021-08-24  9:17 ` [PATCH v2 08/15] ASoC: rockchip: i2s: Fixup config for DAIFMT_DSP_A/B Sugar Zhang
2021-08-24  9:17 ` [PATCH v2 09/15] ASoC: rockchip: i2s: Add property to specify play/cap capability Sugar Zhang
2021-08-24  9:17 ` [PATCH v2 10/15] ASoC: dt-bindings: rockchip: i2s: Document property for playback/capture Sugar Zhang
2021-08-24 17:06   ` Rob Herring
2021-08-25  9:30     ` [PATCH v2 10/15] ASoC: dt-bindings: rockchip: i2s: Document property for playback/capture【请注意,邮件由robherring2@gmail.com代发】 sugar zhang
2021-08-24  9:18 ` [PATCH v2 11/15] ASoC: rockchip: i2s: Add compatible for more SoCs Sugar Zhang
2021-08-24  9:18 ` [PATCH v2 12/15] ASoC: dt-bindings: rockchip: Add compatible strings " Sugar Zhang
2021-08-24 17:07   ` Rob Herring
2021-08-24  9:18 ` [PATCH v2 13/15] ASoC: rockchip: i2s: Add support for frame inversion Sugar Zhang
2021-08-24  9:18 ` [PATCH v2 14/15] ASoC: rockchip: i2s: Add support for TRCM property Sugar Zhang
2021-08-24  9:18 ` [PATCH v2 15/15] ASoC: dt-bindings: rockchip: i2s: Document property TRCM Sugar Zhang
2021-08-24 17:08   ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1629796682-4170-1-git-send-email-sugar.zhang@rock-chips.com \
    --to=sugar.zhang@rock-chips.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=linux-rockchip@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).