All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: fsl_sai: fix no frame clk in master mode
@ 2015-12-10  3:21 Zidan Wang
  2015-12-12  4:47 ` Nicolin Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Zidan Wang @ 2015-12-10  3:21 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, timur, Zidan Wang, lgirdwood, tiwai, nicoleotsuka

After several open/close sai test with ctrl+c, there will be
I/O error. The SAI can't work anymore, can't recover. There
will be no frame clock. With adding the software reset in
trigger stop, the issue can be fixed.

This is a hardware bug/errata and reset is the only option.

According to the reference manual, the software reset doesn't
reset any control register but only internal hardware logics
such as bit clock generator, status flags, and FIFO pointers.
(Our purpose is just to reset the clock generator while the
software reset is the only way to do that.)

Since slave mode doesn't use the clock generator, only apply
the reset procedure to the master mode.

For asynchronous mode, TX will not be reset when RX is still
running. In this case, i can't reproduce this issue.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
---

v1->v2:
1) refine the commit log and comments
2) Since slave mode doesn't use the clock generator, only apply
   the reset procedure to the master mode.

 sound/soc/fsl/fsl_sai.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 8832901..a55a7de 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -564,6 +564,17 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
 					   FSL_SAI_CSR_FR, FSL_SAI_CSR_FR);
 			regmap_update_bits(sai->regmap, FSL_SAI_RCSR,
 					   FSL_SAI_CSR_FR, FSL_SAI_CSR_FR);
+
+			if (!sai->is_slave_mode) {
+				/* Software Reset for both Tx and Rx */
+				regmap_write(sai->regmap,
+					     FSL_SAI_TCSR, FSL_SAI_CSR_SR);
+				regmap_write(sai->regmap,
+					     FSL_SAI_RCSR, FSL_SAI_CSR_SR);
+				/* Clear SR bit to finish the reset */
+				regmap_write(sai->regmap, FSL_SAI_TCSR, 0);
+				regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
+			}
 		}
 		break;
 	default:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ASoC: fsl_sai: fix no frame clk in master mode
  2015-12-10  3:21 [PATCH v2] ASoC: fsl_sai: fix no frame clk in master mode Zidan Wang
@ 2015-12-12  4:47 ` Nicolin Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolin Chen @ 2015-12-12  4:47 UTC (permalink / raw)
  To: Zidan Wang; +Cc: alsa-devel, timur, lgirdwood, tiwai, broonie

On Thu, Dec 10, 2015 at 11:21:25AM +0800, Zidan Wang wrote:

> diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
> index 8832901..a55a7de 100644
> --- a/sound/soc/fsl/fsl_sai.c
> +++ b/sound/soc/fsl/fsl_sai.c
> @@ -564,6 +564,17 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
>  					   FSL_SAI_CSR_FR, FSL_SAI_CSR_FR);
>  			regmap_update_bits(sai->regmap, FSL_SAI_RCSR,
>  					   FSL_SAI_CSR_FR, FSL_SAI_CSR_FR);
> +
> +			if (!sai->is_slave_mode) {

It'd be nicer to add a simple comment to describe the errata here.
Users may have no idea about this abrupt reset as we do.

You may add my ack to your next version:
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>

> +				/* Software Reset for both Tx and Rx */
> +				regmap_write(sai->regmap,
> +					     FSL_SAI_TCSR, FSL_SAI_CSR_SR);
> +				regmap_write(sai->regmap,
> +					     FSL_SAI_RCSR, FSL_SAI_CSR_SR);
> +				/* Clear SR bit to finish the reset */
> +				regmap_write(sai->regmap, FSL_SAI_TCSR, 0);
> +				regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
> +			}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-12  4:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10  3:21 [PATCH v2] ASoC: fsl_sai: fix no frame clk in master mode Zidan Wang
2015-12-12  4:47 ` Nicolin Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.