All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Mouiche <arnaud.mouiche@invoxia.com>
To: Timur Tabi <timur@tabi.org>,
	Nicolin Chen <nicoleotsuka@gmail.com>,
	Xiubo Li <Xiubo.Lee@gmail.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org, festevam@gmail.com, caleb@crome.org
Cc: Arnaud Mouiche <arnaud.mouiche@invoxia.com>
Subject: [PATCH v4 2/6] ASoC: fsl_ssi: The IPG/5 limitation concerns the bitclk, not the sysclk.
Date: Tue,  3 May 2016 14:13:56 +0200	[thread overview]
Message-ID: <1462277640-20052-3-git-send-email-arnaud.mouiche@invoxia.com> (raw)
In-Reply-To: <1462277640-20052-1-git-send-email-arnaud.mouiche@invoxia.com>

im6sl reference manual 47.7.4:
"
Bit clock - Used to serially clock the data bits in and out of the SSI port.
This clock is either generated internally (from SSI's sys clock) or taken
from external clock source (through the Tx/Rx clock ports).
[...]
Care should be taken to ensure that the bit clock frequency (either
internally generated by dividing the SSI's sys clock or sourced from
external device through Tx/Rx clock ports) is never greater than 1/5
of the ipg_clk (from CCM) frequency.
"

Since, in master mode, the sysclk is a multiple of bitclk, we can
easily reach a high sysclk value, whereas keeping a reasonable bitclk.

ex: 8ch x 16bit x 48kHz = 6144000, requires a 24576000 sysclk (PM=1)
    yet ipg_clk/5 = 66Mhz/5 = 13.2

Signed-off-by: Arnaud Mouiche <arnaud.mouiche@invoxia.com>
---
 sound/soc/fsl/fsl_ssi.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 472141f..1a9d0ad 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -671,6 +671,15 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
 	if (IS_ERR(ssi_private->baudclk))
 		return -EINVAL;
 
+	/*
+	 * Hardware limitation: The bclk rate must be
+	 * never greater than 1/5 IPG clock rate
+	 */
+	if (freq * 5 > clk_get_rate(ssi_private->clk)) {
+		dev_err(cpu_dai->dev, "bitclk > ipgclk/5\n");
+		return -EINVAL;
+	}
+
 	baudclk_is_used = ssi_private->baudclk_streams & ~(BIT(substream->stream));
 
 	/* It should be already enough to divide clock by setting pm alone */
@@ -687,13 +696,6 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
 		else
 			clkrate = clk_round_rate(ssi_private->baudclk, tmprate);
 
-		/*
-		 * Hardware limitation: The bclk rate must be
-		 * never greater than 1/5 IPG clock rate
-		 */
-		if (clkrate * 5 > clk_get_rate(ssi_private->clk))
-			continue;
-
 		clkrate /= factor;
 		afreq = clkrate / (i + 1);
 
-- 
1.9.1

  parent reply	other threads:[~2016-05-03 12:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 12:13 [PATCH v4 0/6] ASoC: fsl_ssi: Fixing various channel slips and bad samples insertions Arnaud Mouiche
2016-05-03 12:13 ` [PATCH v4 1/6] ASoC: fsl_ssi: Real hardware channels max number is 32 Arnaud Mouiche
2016-05-03 12:23   ` Fabio Estevam
2016-05-10 16:32     ` Caleb Crome
2016-05-03 12:13 ` Arnaud Mouiche [this message]
2016-05-03 12:23   ` [PATCH v4 2/6] ASoC: fsl_ssi: The IPG/5 limitation concerns the bitclk, not the sysclk Fabio Estevam
2016-05-10 16:33     ` Caleb Crome
2016-05-03 12:13 ` [PATCH v4 3/6] ASoC: fsl_ssi: Save a dev reference for dev_err() purpose Arnaud Mouiche
2016-05-03 12:17   ` Timur Tabi
2016-05-07 22:54     ` Fabio Estevam
2016-05-10 16:34   ` Caleb Crome
2016-05-03 12:13 ` [PATCH v4 4/6] ASoC: fsl_ssi: Fix samples being dropped at Playback startup Arnaud Mouiche
2016-05-03 12:24   ` Fabio Estevam
2016-05-10 16:34     ` Caleb Crome
2016-05-03 12:13 ` [PATCH v4 5/6] ASoC: fsl_ssi: Fix channel slipping in Playback at startup Arnaud Mouiche
2016-05-03 12:24   ` Fabio Estevam
2016-05-10 16:34     ` Caleb Crome
2016-05-03 12:14 ` [PATCH v4 6/6] ASoC: fsl_ssi: Fix channel slipping on capture (or playback) restart in full duplex Arnaud Mouiche
2016-05-03 12:24   ` Fabio Estevam
2016-05-10 16:34     ` Caleb Crome
2016-05-13 12:25   ` Applied "ASoC: fsl_ssi: Fix channel slipping on capture (or playback) restart in full duplex." to the asoc tree Mark Brown
2016-05-07 22:56 ` [PATCH v4 0/6] ASoC: fsl_ssi: Fixing various channel slips and bad samples insertions Fabio Estevam
2016-05-07 23:16   ` Nicolin Chen
2016-05-10 16:32     ` Caleb Crome

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=1462277640-20052-3-git-send-email-arnaud.mouiche@invoxia.com \
    --to=arnaud.mouiche@invoxia.com \
    --cc=Xiubo.Lee@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=caleb@crome.org \
    --cc=festevam@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=nicoleotsuka@gmail.com \
    --cc=perex@perex.cz \
    --cc=timur@tabi.org \
    --cc=tiwai@suse.com \
    /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 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.