Skip to contentSkip to conversation

sound: soc: fsl: Do not set DAI sysclk when it is equal to system freq

PATCH In review Lukasz Majewski 5 participants 28 messages Sep 3, 2017 – Sep 8, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound: soc: fsl: Do not set DAI sysclk when it is equal to system freq

The problem is visible in the following setup (on the imx6q):
"simple-audio-card" -> ssi2 -> I2S + I2C -> codec

The function call log (simple-card probe -> CONFIG_SND_SIMPLE_CARD):

asoc_simple_card_init_dai() @ sound/soc/generic/simple-card-utils.c snd_soc_dai_set_sysclk()
fsl_ssi_set_dai_sysclk() @ sound/soc/fsl/fsl_ssi.c

The last call is changing the bit clock (BCLK) frequency to SSI's IP block clock (ipg = 66 MHz) [1].
This is wrong, since IMX SSI block requires the I2S BCLK to be less than 1/5 of [1].

As a result the driver initialization passes without any errors, but the speaker-test test case breaks.

This commit checks if the fsl_ssi_set_dai_sysclk() frequency passed is not equal to [1].

---
 sound/soc/fsl/fsl_ssi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/fsl/fsl_ssi.c +2 -0
index 173cb84..1186fa9 100644
@@ -809,6 +809,8 @@ static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
 		int clk_id, unsigned int freq, int dir)
 {
 	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+	if (clk_get_rate(ssi_private->clk) == freq)
+		return 0;
 
 	ssi_private->bitclk_freq = freq;
 
Signature · 1 line
2.1.4
#1 lore raw

[Sorry for the top-posting]

The driver currently has:

/*
* 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;
}

Isn't this properly taking care of the clock restriction?

________________________________
From: Lukasz Majewski <[email protected]>
Sent: Sunday, September 3, 2017 8:05:01 AM
To: Timur Tabi; Nicolin Chen; Xiubo Li; Fabio Estevam; Liam Girdwood; Mark Brown; Jaroslav Kysela; Takashi Iwai
Cc: [email protected]; [email protected]; [email protected]; Lukasz Majewski
Subject: [PATCH] sound: soc: fsl: Do not set DAI sysclk when it is equal to system freq

The problem is visible in the following setup (on the imx6q):
"simple-audio-card" -> ssi2 -> I2S + I2C -> codec

The function call log (simple-card probe -> CONFIG_SND_SIMPLE_CARD):

asoc_simple_card_init_dai() @ sound/soc/generic/simple-card-utils.c snd_soc_dai_set_sysclk()
fsl_ssi_set_dai_sysclk() @ sound/soc/fsl/fsl_ssi.c

The last call is changing the bit clock (BCLK) frequency to SSI's IP block clock (ipg = 66 MHz) [1].
This is wrong, since IMX SSI block requires the I2S BCLK to be less than 1/5 of [1].

As a result the driver initialization passes without any errors, but the speaker-test test case breaks.

This commit checks if the fsl_ssi_set_dai_sysclk() frequency passed is not equal to [1].

---
 sound/soc/fsl/fsl_ssi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/fsl/fsl_ssi.c +2 -0
index 173cb84..1186fa9 100644
@@ -809,6 +809,8 @@ static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
                 int clk_id, unsigned int freq, int dir)
 {
         struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+       if (clk_get_rate(ssi_private->clk) == freq)
+               return 0;
 
         ssi_private->bitclk_freq = freq;
 

--
2.1.4

#2 lore raw

Hi Fabio,

Quoted 6 lines

[Sorry for the top-posting]

The driver currently has:

Quoted 9 lines

/*
* 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;
}

Unfortunately not.

This is the part of fsl_ssi_set_bclk() function which is called after fsl_ssi_set_dai_sysclk() (which sets ssi_private->bitclk_freq = freq;).

Before the aforementioned check we do have:

	if (ssi_private->bitclk_freq)
		freq = ssi_private->bitclk_freq;
	else
		freq = params_channels(hw_params) * 32 * 	params_rate(hw_params);

Which assigns freq = bitclk_freq (66 MHz)

And then we break on this particular check:

66MHz * 5 > 66 MHz.

The culprit IMHO is the ssi_private->bitclk_freq = freq; in the fsl_ssi_set_dai_sysclk(), since we _should_ set SSI's IP block clock (ssi_private->clk), not the bit clock (BCLK).

This patch just quits early if it detects change, which don't need to be done.

Quoted 52 lines

Isn't this properly taking care of the clock restriction?

________________________________
From: Lukasz Majewski <[email protected]>
Sent: Sunday, September 3, 2017 8:05:01 AM
To: Timur Tabi; Nicolin Chen; Xiubo Li; Fabio Estevam; Liam Girdwood; Mark Brown; Jaroslav Kysela; Takashi Iwai
Cc: [email protected]; [email protected]; [email protected]; Lukasz Majewski
Subject: [PATCH] sound: soc: fsl: Do not set DAI sysclk when it is equal to system freq

The problem is visible in the following setup (on the imx6q):
"simple-audio-card" -> ssi2 -> I2S + I2C -> codec

The function call log (simple-card probe -> CONFIG_SND_SIMPLE_CARD):

asoc_simple_card_init_dai() @ sound/soc/generic/simple-card-utils.c snd_soc_dai_set_sysclk()
fsl_ssi_set_dai_sysclk() @ sound/soc/fsl/fsl_ssi.c

The last call is changing the bit clock (BCLK) frequency to SSI's IP block clock (ipg = 66 MHz) [1].
This is wrong, since IMX SSI block requires the I2S BCLK to be less than 1/5 of [1].

As a result the driver initialization passes without any errors, but the speaker-test test case breaks.

This commit checks if the fsl_ssi_set_dai_sysclk() frequency passed is not equal to [1].

---
  sound/soc/fsl/fsl_ssi.c | 2 ++
  1 file changed, 2 insertions(+)
sound/soc/fsl/fsl_ssi.c +2 -1
index 173cb84..1186fa9 100644
@@ -809,6 +809,8 @@ static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
                  int clk_id, unsigned int freq, int dir)
  {
          struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+       if (clk_get_rate(ssi_private->clk) == freq)
+               return 0;
 
          ssi_private->bitclk_freq = freq;
 
--

2.1.4

Signature · 9 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
reviewer Reviewed-by
#3 lore raw
Quoted 20 lines · Łukasz Majewski

This is the part of fsl_ssi_set_bclk() function which is called after fsl_ssi_set_dai_sysclk() (which sets ssi_private->bitclk_freq = freq;).

Before the aforementioned check we do have:

        if (ssi_private->bitclk_freq)
                freq = ssi_private->bitclk_freq;
        else
                freq = params_channels(hw_params) * 32 *

params_rate(hw_params);

Which assigns freq = bitclk_freq (66 MHz)

And then we break on this particular check:

66MHz * 5 > 66 MHz.

Quoted 7 lines

The culprit IMHO is the ssi_private->bitclk_freq = freq; in the fsl_ssi_set_dai_sysclk(), since we _should_ set SSI's IP block clock (ssi_private->clk), not the bit clock (BCLK).

This patch just quits early if it detects change, which don't need to be done.

Thanks for the clarification.

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

reviewer
#20 lore raw
In reply to Lukasz Majewski
Quoted 11 lines · Lukasz Majewski

The problem is visible in the following setup (on the imx6q):
"simple-audio-card" -> ssi2 -> I2S + I2C -> codec

The function call log (simple-card probe -> CONFIG_SND_SIMPLE_CARD):

asoc_simple_card_init_dai() @ sound/soc/generic/simple-card-utils.c snd_soc_dai_set_sysclk()
fsl_ssi_set_dai_sysclk() @ sound/soc/fsl/fsl_ssi.c

The last call is changing the bit clock (BCLK) frequency to SSI's IP block clock (ipg = 66 MHz) [1].

I think a bigger question here is why the routine sets BCLK to 66MHz.

Quoted 8 lines

This is wrong, since IMX SSI block requires the I2S BCLK to be less than 1/5 of [1].

As a result the driver initialization passes without any errors, but the speaker-test test case breaks.

This commit checks if the fsl_ssi_set_dai_sysclk() frequency passed is not equal to [1].

I don't feel it's quite comprehensive...what if it's being set to 67MHz.

Thanks
Nicolin

Quoted 21 lines
---
 sound/soc/fsl/fsl_ssi.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/fsl/fsl_ssi.c +2 -0
index 173cb84..1186fa9 100644
@@ -809,6 +809,8 @@ static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
 		int clk_id, unsigned int freq, int dir)
 {
 	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+	if (clk_get_rate(ssi_private->clk) == freq)
+		return 0;
 
 	ssi_private->bitclk_freq = freq;
 
Signature · 1 line
2.1.4
reviewer
#4 lore raw
In reply to Łukasz Majewski
Quoted 25 lines · Łukasz Majewski
Quoted 9 lines

/*
* 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;
}

Unfortunately not.

This is the part of fsl_ssi_set_bclk() function which is called after fsl_ssi_set_dai_sysclk() (which sets ssi_private->bitclk_freq = freq;).

Before the aforementioned check we do have:

	if (ssi_private->bitclk_freq)
		freq = ssi_private->bitclk_freq;
	else
		freq = params_channels(hw_params) * 32 * 	params_rate(hw_params);

Which assigns freq = bitclk_freq (66 MHz)

[...]

Quoted 2 lines

And then we break on this particular check:
66MHz * 5 > 66 MHz.

[...]

Does the check fail and return an error here, or not?

Quoted 3 lines

The culprit IMHO is the ssi_private->bitclk_freq = freq; in the fsl_ssi_set_dai_sysclk(), since we _should_ set SSI's IP block clock (ssi_private->clk), not the bit clock (BCLK).

No. We should not set the IP block clock. That's from IPG bus on certain IMX SoCs. Setting it might change IPG bus clocks which might break the system.

And apparently, we shouldn't set bitclk to 66MHz either. Can you help to find where this 66MHz comes from?

Quoted 2 lines

This patch just quits early if it detects change, which don't need to be done.

I kinda see your point is to error out before hw_params(). So I feel it would be better to have a similar 5-times-check in the set_sysclk() too, if it's really necessary.

Btw, I don't see simple card calling set_sysclk() function in any earlier stage than hw_params(). I am wondering how did you encounter the problem?

Thanks
Nicolin

#21 lore raw
In reply to Nicolin Chen
Quoted 6 lines · Nicolin Chen
Quoted 5 lines · Lukasz Majewski

The problem is visible in the following setup (on the imx6q):
"simple-audio-card" -> ssi2 -> I2S + I2C -> codec

The function call log (simple-card probe -> CONFIG_SND_SIMPLE_CARD):

Quoted 8 lines
Quoted 6 lines

asoc_simple_card_init_dai() @ sound/soc/generic/simple-card-utils.c snd_soc_dai_set_sysclk()
fsl_ssi_set_dai_sysclk() @ sound/soc/fsl/fsl_ssi.c

The last call is changing the bit clock (BCLK) frequency to SSI's IP block clock (ipg = 66 MHz) [1].

I think a bigger question here is why the routine sets BCLK to 66MHz.

Yes, exactly.

In my case the bclk is set to ipg clock, which is the SSI IP block clock (ipg).

Quoted 11 lines
Quoted 9 lines

This is wrong, since IMX SSI block requires the I2S BCLK to be less than 1/5 of [1].

As a result the driver initialization passes without any errors, but the speaker-test test case breaks.

This commit checks if the fsl_ssi_set_dai_sysclk() frequency passed is not equal to [1].

I don't feel it's quite comprehensive...what if it's being set to 67MHz.

I think that this clock is not changing for the SoC. It should be 66 MHz fixed.

Quoted 26 lines

Thanks
Nicolin

Quoted 21 lines
---
  sound/soc/fsl/fsl_ssi.c | 2 ++
  1 file changed, 2 insertions(+)
sound/soc/fsl/fsl_ssi.c +2 -0
index 173cb84..1186fa9 100644
@@ -809,6 +809,8 @@ static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
  		int clk_id, unsigned int freq, int dir)
  {
  	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+	if (clk_get_rate(ssi_private->clk) == freq)
+		return 0;
 
  	ssi_private->bitclk_freq = freq;
 
Signature · 1 line
2.1.4
Signature · 9 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
reviewer
#22 lore raw
Quoted 9 lines · Łukasz Majewski
Quoted 4 lines
Quoted 2 lines

The last call is changing the bit clock (BCLK) frequency to SSI's IP block clock (ipg = 66 MHz) [1].

I think a bigger question here is why the routine sets BCLK to 66MHz.

Yes, exactly.

In my case the bclk is set to ipg clock, which is the SSI IP block clock (ipg).

Can you elaborate why you set ipg clock as bclk? I don't remember SSI could derive bitclock from ipg clock.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

This is wrong, since IMX SSI block requires the I2S BCLK to be less than 1/5 of [1].

As a result the driver initialization passes without any errors, but the speaker-test test case breaks.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

This commit checks if the fsl_ssi_set_dai_sysclk() frequency passed is not equal to [1].

I don't feel it's quite comprehensive...what if it's being set to 67MHz.

I think that this clock is not changing for the SoC. It should be 66 MHz fixed.

What I mean is that we cannot just look at this SoC. Today is 66MHz for this SoC. Tomorrow could be 133MHz for another one. We should put a check that none of these shall pass -- the 1/5 limit.

#23 lore raw
Quoted 7 lines · Nicolin Chen
Quoted 5 lines · Łukasz Majewski
Quoted 4 lines
Quoted 2 lines

The last call is changing the bit clock (BCLK) frequency to SSI's IP block clock (ipg = 66 MHz) [1].

I think a bigger question here is why the routine sets BCLK to 66MHz.

Quoted 7 lines
Quoted 4 lines

Yes, exactly.

In my case the bclk is set to ipg clock, which is the SSI IP block clock (ipg).

Can you elaborate why you set ipg clock as bclk? I don't remember SSI could derive bitclock from ipg clock.

Just to be clear:

What clock shall be set with:

struct snd_soc_dai_ops {

	int (*set_sysclk)(struct snd_soc_dai *dai,
		int clk_id, unsigned int freq, int dir);
}

callback?

The SSI IP block or BCLK ?

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

This is wrong, since IMX SSI block requires the I2S BCLK to be less than 1/5 of [1].

As a result the driver initialization passes without any errors, but the speaker-test test case breaks.

This commit checks if the fsl_ssi_set_dai_sysclk() frequency passed is not equal to [1].

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

I don't feel it's quite comprehensive...what if it's being set to 67MHz.

I think that this clock is not changing for the SoC. It should be 66 MHz fixed.

What I mean is that we cannot just look at this SoC. Today is 66MHz for this SoC. Tomorrow could be 133MHz for another one. We should put a check that none of these shall pass -- the 1/5 limit.

Ok. Good point.

Signature · 13 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#5 lore raw
In reply to Nicolin Chen
Quoted 24 lines · Nicolin Chen
Quoted 23 lines · Łukasz Majewski
Quoted 9 lines

/*
* 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;
}

Unfortunately not.

This is the part of fsl_ssi_set_bclk() function which is called after fsl_ssi_set_dai_sysclk() (which sets ssi_private->bitclk_freq = freq;).

Before the aforementioned check we do have:

	if (ssi_private->bitclk_freq)
		freq = ssi_private->bitclk_freq;
	else
		freq = params_channels(hw_params) * 32 * 	params_rate(hw_params);
Quoted 8 lines
Quoted 2 lines

Which assigns freq = bitclk_freq (66 MHz)

[...]

Quoted 2 lines

And then we break on this particular check:
66MHz * 5 > 66 MHz.

[...]

Does the check fail and return an error here, or not?

Yes, this check fails and return error (-EINVAL).

Quoted 11 lines
Quoted 4 lines

The culprit IMHO is the ssi_private->bitclk_freq = freq; in the fsl_ssi_set_dai_sysclk(), since we _should_ set SSI's IP block clock (ssi_private->clk), not the bit clock (BCLK).

No. We should not set the IP block clock. That's from IPG bus on certain IMX SoCs. Setting it might change IPG bus clocks which might break the system.

And apparently, we shouldn't set bitclk to 66MHz either. Can you help to find where this 66MHz comes from?

OK.

The fsi_ssi.c file defines:

ops->set_sysclk() routine:

.set_sysclk = fsl_ssi_set_dai_sysclk,

This routine is called in:
int snd_soc_dai_set_sysclk() @ soc-core.c

which is called in two places for my setup:

1. asoc_simple_card_hw_params() @ simple-card.c

and

2. int asoc_simple_card_init_dai() @ simple-card-utils.c

In this function (point 2.) the

simple_dai->sysclk is set and:

snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, 0)

which sets frequency to 66 MHz [*].

The asoc_simple_card_init_dai() is called in

asoc_simple_card_dai_init() @ simple-card.c

which is assigned to dai_link->init

dai_link->init = asoc_simple_card_dai_init; @ simple_card.c

And the sysclk itself is defined at:
-------------------------------------

dai_props->codec_dai->sysclk, which is used at:

asoc_simple_card_startup(), asoc_simple_card_shutdown() and others functions at simple-card.c

It is setup at:

asoc_simple_card_parse_clk() @ simple-card-utils.c from macro:
#define asoc_simple_card_parse_clk_cpu()

And the problem is:
-------------------

At the
asoc_simple_card_parse_clk()
we finally go to dts node:

/soc/aips-bus@02100000/i2c@021a0000/tfa9879@6C

which has clock from I2C (66 MHz).

(So the [*] hack may help here, since it is checked before checking the i2c node).

Note:
[*] - I could workaround this problem by setting:

system-clock-frequency = <0> in

			dailink_master: cpu {
			    sound-dai = <&ssi2>;
			};

but this is IMHO even worse hack.... than this patch.

Quoted 15 lines
Quoted 3 lines

This patch just quits early if it detects change, which don't need to be done.

I kinda see your point is to error out before hw_params(). So I feel it would be better to have a similar 5-times-check in the set_sysclk() too, if it's really necessary.

Btw, I don't see simple card calling set_sysclk() function in any earlier stage than hw_params(). I am wondering how did you encounter the problem?

Thanks
Nicolin

Signature · 9 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
maintainer
#24 lore raw
In reply to Łukasz Majewski
Quoted 9 lines · Łukasz Majewski
Quoted 2 lines · Nicolin Chen

Can you elaborate why you set ipg clock as bclk? I don't remember SSI could derive bitclock from ipg clock.

Just to be clear:

What clock shall be set with:

Quoted 8 lines
struct snd_soc_dai_ops {
	int (*set_sysclk)(struct snd_soc_dai *dai,
		int clk_id, unsigned int freq, int dir);
}

callback?

The SSI IP block or BCLK ?

Not the BCLK, probably the IP clock but perhaps nothing. The bclk is usually derived from the sample rate and width, the system clock is the clock rate going into the device. It doesn't *have* to be configured (particuarly if it's discoverable by the IP and managable via the clock API).

reviewer
#25 lore raw
Quoted 11 lines · Mark Brown
Quoted 10 lines

Just to be clear:

What clock shall be set with:

struct snd_soc_dai_ops {
	int (*set_sysclk)(struct snd_soc_dai *dai,
		int clk_id, unsigned int freq, int dir);
}

callback?

Quoted 7 lines
Quoted 1 line

The SSI IP block or BCLK ?

Not the BCLK, probably the IP clock but perhaps nothing. The bclk is usually derived from the sample rate and width, the system clock is the clock rate going into the device. It doesn't *have* to be configured (particuarly if it's discoverable by the IP and managable via the clock API).

Hmm...to clarify the things, some background here:

SSI has mainly two different clock inputs internally (not external pads such as bclk or lrclk): IP block clock (ipg_clk in Reference Manual) and sys clock (ccm_ssi_clk in Reference Manual). According to RM, ccm_ssi_clk: "module/system clock for bit clock generation".

The ipg clock is merely used to access registers, and has nothing (directly) to do with external clock outputs. The driver shall not change the ipg clock as the system ipg clock (its parent clock) might be messed and even system time would get weird -- happened once when the fsl_spdif driver used to call clk_set_rate() on its ipg clock. Although the clock controller should have some kind of protection in my opinion, we just avoid IP clock rate change in all audio drivers as well.

On the other hand, the sys clock (baudclk in the driver) should be configured whenever it's related to external clock outputs. When I implemented this set_sysclk() for fsl_ssi.c, I used it to set this sys clock (baudclk) by a machine driver, in order to set bit clock. Then someone patched the driver by moving all the code to set_bclk() to make machine drivers simpler. Now the set_sysclk() is remained to give machine drivers a chance to override clock configurations in the hw_params(). This could be used in TDM or some other special cases (It could also have a purpose for backwards compatibility).

So here, we should set baudclk (BCLK generator).

reviewer
#6 lore raw
In reply to Łukasz Majewski
Quoted 4 lines · Łukasz Majewski
Quoted 2 lines

And apparently, we shouldn't set bitclk to 66MHz either. Can you help to find where this 66MHz comes from?

2. int asoc_simple_card_init_dai() @ simple-card-utils.c

Oh, I just searched in the simple-card.c but missed this file.

Quoted 5 lines

In this function (point 2.) the simple_dai->sysclk is set and:
snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, 0) which sets frequency to 66 MHz [*].

Quoted 8 lines

The asoc_simple_card_init_dai() is called in
asoc_simple_card_dai_init() @ simple-card.c
which is assigned to dai_link->init
dai_link->init = asoc_simple_card_dai_init; @ simple_card.c

And the sysclk itself is defined at:
-------------------------------------
dai_props->codec_dai->sysclk, which is used at:a

Why codec_dai? Why not dai_props->cpu_dai->sysclk since we are talking about SSI?

Quoted 8 lines

asoc_simple_card_startup(), asoc_simple_card_shutdown() and others functions at simple-card.c
It is setup at:
asoc_simple_card_parse_clk() @ simple-card-utils.c from macro:
#define asoc_simple_card_parse_clk_cpu()
And the problem is:
-------------------

Quoted 4 lines

At the
asoc_simple_card_parse_clk()
we finally go to dts node:
/soc/aips-bus@02100000/i2c@021a0000/tfa9879@6C

This tfa9879 should be the CODEC right?

Quoted 1 line

which has clock from I2C (66 MHz).

You mean I2C scl or I2S sclk?

-----------------------------------------------------------------

But anyway, I feel very confused here as you have 66MHz clock rate (regardless of it purpose) for a codec dai but it's been passed to a cpu dai (SSI).

Quoted 9 lines

[*] - I could workaround this problem by setting:

system-clock-frequency = <0> in

			dailink_master: cpu {
			    sound-dai = <&ssi2>;
			};

but this is IMHO even worse hack.... than this patch.

I haven't used simple-card for a while so I forgot how to define its DT bindings specifically. But you should assign ssi2 as the CPU dai and assign tfa9879 as a CODEC dai.

reviewer
#18 lore raw
In reply to Łukasz Majewski

Hi Lukasz,

Quoted 9 lines · Łukasz Majewski

Note:
[*] - I could workaround this problem by setting:

system-clock-frequency = <0> in

                        dailink_master: cpu {
                            sound-dai = <&ssi2>;
                        };

Which mx6 type are you using? Can you post the complete audio related bindings of your dts?

Still trying to understand why we do not see this error on other imx6 boards.

#7 lore raw
In reply to Nicolin Chen

Hi Nicolin,

Quoted 19 lines · Łukasz Majewski
Quoted 5 lines
Quoted 3 lines

And apparently, we shouldn't set bitclk to 66MHz either. Can you help to find where this 66MHz comes from?

2. int asoc_simple_card_init_dai() @ simple-card-utils.c

Oh, I just searched in the simple-card.c but missed this file.

Quoted 10 lines

In this function (point 2.) the simple_dai->sysclk is set and:
snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, 0) which sets frequency to 66 MHz [*].

The asoc_simple_card_init_dai() is called in
asoc_simple_card_dai_init() @ simple-card.c
which is assigned to dai_link->init
dai_link->init = asoc_simple_card_dai_init; @ simple_card.c

Quoted 6 lines
Quoted 3 lines

And the sysclk itself is defined at:
-------------------------------------
dai_props->codec_dai->sysclk, which is used at:a

Why codec_dai? Why not dai_props->cpu_dai->sysclk since we are talking about SSI?

This is how the simple-card (simple-sound-card) is written.

Quoted 9 lines
Quoted 9 lines

asoc_simple_card_startup(), asoc_simple_card_shutdown() and others functions at simple-card.c
It is setup at:
asoc_simple_card_parse_clk() @ simple-card-utils.c from macro:
#define asoc_simple_card_parse_clk_cpu()
And the problem is:
-------------------

Quoted 6 lines
Quoted 4 lines

At the
asoc_simple_card_parse_clk()
we finally go to dts node:
/soc/aips-bus@02100000/i2c@021a0000/tfa9879@6C

This tfa9879 should be the CODEC right?

Yes. The tfa9879 is a codec (very simple -> I2S + I2C, mono).

They key point here is the asoc_simple_card_parse_clk() function from simple-card-utils.c

Please look how the clock is assigned; It first checks for cpu clock, then for "system-clock-frequency" DTS node and _finally_ looks for another "child" clock [1], which is the codec attached to I2C.

And from there it takes the 66 MHz CLK:
/soc/aips-bus@02100000/i2c@021a0000/tfa9879@6C

Quoted 4 lines
Quoted 2 lines

which has clock from I2C (66 MHz).

You mean I2C scl or I2S sclk?

I2C scl.

Quoted 6 lines

-----------------------------------------------------------------

But anyway, I feel very confused here as you have 66MHz clock rate (regardless of it purpose) for a codec dai but it's been passed to a cpu dai (SSI).

Please look into asoc_simple_card_parse_clk().

My DTS [1] (it is different than other in-tree supported codecs - at least I did not find similar setup in DTSes):

	sound {
		compatible = "simple-audio-card";
		label = "tfa9879-mono";

		simple-audio-card,dai-link {
			/* DAC */
			format = "i2s";
			bitclock-master = <&dailink_master>;
			frame-master = <&dailink_master>;

			dailink_master: cpu {
			    sound-dai = <&ssi2>;
			};
			codec {
			    sound-dai = <&codec>;
			};
		};
	};
&i2c1 {
	clock-frequency = <400000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c1>;
	status = "okay";

	codec: tfa9879@6C {
		#sound-dai-cells = <0>;
		compatible = "tfa9879";
		reg = <0x6C>;
	};
};
&ssi2 {
	fsl,mode = "i2s-master";
	status = "okay";
};

the ssi2 node is defined in imx6qdl.dtsi file (no changes).

The SOC is IMX6Q.

The TFA9879 is a slave for I2S transmission.

Quoted 15 lines
Quoted 10 lines

[*] - I could workaround this problem by setting:

system-clock-frequency = <0> in

			dailink_master: cpu {
			    sound-dai = <&ssi2>;
			};

but this is IMHO even worse hack.... than this patch.

I haven't used simple-card for a while so I forgot how to define its DT bindings specifically. But you should assign ssi2 as the CPU dai and assign tfa9879 as a CODEC dai.

Signature · 13 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#19 lore raw
In reply to Fabio Estevam

Hi Fabio,

Quoted 14 lines

Hi Lukasz,

Quoted 9 lines · Łukasz Majewski

Note:
[*] - I could workaround this problem by setting:

system-clock-frequency = <0> in

                         dailink_master: cpu {
                             sound-dai = <&ssi2>;
                         };
Quoted 5 lines

Which mx6 type are you using? Can you post the complete audio related bindings of your dts?

Still trying to understand why we do not see this error on other imx6 boards.

I've sent my DTS in the other e-mail.

Signature · 9 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
reviewer
#8 lore raw
In reply to Łukasz Majewski
Quoted 7 lines · Łukasz Majewski

They key point here is the asoc_simple_card_parse_clk() function from simple-card-utils.c

Please look how the clock is assigned; It first checks for cpu clock, then for "system-clock-frequency" DTS node and _finally_ looks for another "child" clock [1], which is the codec attached to I2C.

Here is the routine that I understood from the code:
1) asoc_simple_card_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
=> asoc_simple_card_parse_clk(dev, cpu, // cpu node in sound{} [1]

		   		 dai_link->cpu_of_node,     // node ssi2 [2]
				 cpu_dai, dai_link->cpu_dai_name);

==> 1.1) devm_get_clk_from_child(dev, node, NULL); // [1]
==> 1.2) of_property_read_u32(node, "system-clock-frequency", &val)// [1]
==> 1.3) devm_get_clk_from_child(dev, dai_of_node, NULL); // [2]

2) asoc_simple_card_parse_clk_codec(dev, codec, dai_link, codec_dai);
=> asoc_simple_card_parse_clk(dev, codec, // codec node in sound{} [3]

		   		 dai_link->codec_of_node,// node tfa9879 [4]
				 codec_dai, dai_link->codec_dai_name);

==> 2.1) devm_get_clk_from_child(dev, node, NULL); // [3]
==> 2.2) of_property_read_u32(node, "system-clock-frequency", &val)// [3]
==> 2.3) devm_get_clk_from_child(dev, dai_of_node, NULL); // [4]

For the cpu routine, it first checks for clock property under cpu node of simple-card, then for "system-clock-frequency" in the cpu node of simple-card, and finally looks for clock property in ssi2 node.

For codec routine, it first checks for clock property under codec node of simple-card, then for "system-clock-frequency" in codec node of simple-card, and finally looks for clock property in the tfa9879 node.

The cpu and codec are totally separate, aren't they? And I don't think it's right if not.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

which has clock from I2C (66 MHz).

You mean I2C scl or I2S sclk?

I2C scl.

A couple of things here.....
1) I don't think I2C scl can run at 66MHz...The 66MHz is probably the ipg clock of I2C controller.
2) Even if the scl does run at 66MHz, there is no point in passing the clock of I2C scl into an I2S dai-link.

So I feel something must be wrong. I suggest you to add some printk to check the names of those nodes and x_of_node in the simple card driver.

Quoted 13 lines

My DTS [1] (it is different than other in-tree supported codecs - at least I did not find similar setup in DTSes):

	sound {
		compatible = "simple-audio-card";
		label = "tfa9879-mono";

		simple-audio-card,dai-link {
			/* DAC */
			format = "i2s";
			bitclock-master = <&dailink_master>;
			frame-master = <&dailink_master>;
Quoted 7 lines
			dailink_master: cpu {
			    sound-dai = <&ssi2>;
			};
			codec {
			    sound-dai = <&codec>;
			};
		};

I remember there is another style for a single dai-link. Could you please try that one? There is an example in:
Documentation/devicetree/bindings/sound/simple-card.txt
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

reviewer
#16 lore raw
In reply to Łukasz Majewski
Quoted 9 lines · Łukasz Majewski
&i2c1 {
        clock-frequency = <400000>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c1>;
        status = "okay";

        codec: tfa9879@6C {
                #sound-dai-cells = <0>;
                compatible = "tfa9879";

This codec seems to miss device tree support. Don't you need something like this?

sound/soc/codecs/tfa9879.c +6 -0
@@ -312,9 +312,15 @@ static const struct i2c_device_id tfa9879_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, tfa9879_i2c_id);
 
+static const struct of_device_id tfa9879_of_match[] = {
+       { .compatible = "nxp,tfa9879", },
+       { }
+};
+
 static struct i2c_driver tfa9879_i2c_driver = {
        .driver = {
                .name = "tfa9879",
+               .of_match_table = tfa9879_of_match,
        },
        .probe = tfa9879_i2c_probe,
        .remove = tfa9879_i2c_remove,

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#17 lore raw

Hi Fabio,

Quoted 24 lines · Łukasz Majewski
Quoted 10 lines
&i2c1 {
         clock-frequency = <400000>;
         pinctrl-names = "default";
         pinctrl-0 = <&pinctrl_i2c1>;
         status = "okay";

         codec: tfa9879@6C {
                 #sound-dai-cells = <0>;
                 compatible = "tfa9879";

This codec seems to miss device tree support. Don't you need something like this?

sound/soc/codecs/tfa9879.c +2 -0
@@ -312,9 +312,15 @@ static const struct i2c_device_id tfa9879_i2c_id[] = {
  };
  MODULE_DEVICE_TABLE(i2c, tfa9879_i2c_id);
 
+static const struct of_device_id tfa9879_of_match[] = {
+       { .compatible = "nxp,tfa9879", },

sound/soc/codecs/tfa9879.c static const struct i2c_device_id tfa9879_i2c_id[] = { · line 326

Quoted 10 lines
sound/soc/codecs/tfa9879.c +4 -0
+       { }
+};
+
  static struct i2c_driver tfa9879_i2c_driver = {
         .driver = {
                 .name = "tfa9879",
+               .of_match_table = tfa9879_of_match,
         },
         .probe = tfa9879_i2c_probe,
         .remove = tfa9879_i2c_remove,

Maybe it should be added, but the driver is probed via I2C "node" in dts.

I took the codec (tfa9879) driver as-is.

Signature · 9 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
#9 lore raw
In reply to Nicolin Chen

Hi Nicolin,

Quoted 27 lines · Łukasz Majewski
Quoted 8 lines

They key point here is the asoc_simple_card_parse_clk() function from simple-card-utils.c

Please look how the clock is assigned; It first checks for cpu clock, then for "system-clock-frequency" DTS node and _finally_ looks for another "child" clock [1], which is the codec attached to I2C.

Here is the routine that I understood from the code:

1) asoc_simple_card_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
    => asoc_simple_card_parse_clk(dev, cpu,        // cpu node in sound{} [1]
		   		 dai_link->cpu_of_node,     // node ssi2 [2]
				 cpu_dai, dai_link->cpu_dai_name);
    ==> 1.1) devm_get_clk_from_child(dev, node, NULL);                 // [1]
    ==> 1.2) of_property_read_u32(node, "system-clock-frequency", &val)// [1]
    ==> 1.3) devm_get_clk_from_child(dev, dai_of_node, NULL);          // [2]
2) asoc_simple_card_parse_clk_codec(dev, codec, dai_link, codec_dai);
    => asoc_simple_card_parse_clk(dev, codec,    // codec node in sound{} [3]
		   		 dai_link->codec_of_node,// node tfa9879 [4]
				 codec_dai, dai_link->codec_dai_name);
    ==> 2.1) devm_get_clk_from_child(dev, node, NULL);                 // [3]
    ==> 2.2) of_property_read_u32(node, "system-clock-frequency", &val)// [3]
    ==> 2.3) devm_get_clk_from_child(dev, dai_of_node, NULL);          // [4]
Quoted 4 lines

For the cpu routine, it first checks for clock property under cpu node of simple-card, then for "system-clock-frequency" in the cpu node of simple-card, and finally looks for clock property in ssi2 node.

I've double checked this and the
simple_dai->sysclk is assigned in the

asoc_simple_card_parse_clk()

-----> dev: sound
-----> clk node: /soc/aips-bus@02000000/spba-bus@02000000/ssi@0202c000 -----> Clk asignment

And this clock is taken from this node. It looks like ipg clock for ssi...

Quoted 8 lines

For codec routine, it first checks for clock property under codec node of simple-card, then for "system-clock-frequency" in codec node of simple-card, and finally looks for clock property in the tfa9879 node.

The cpu and codec are totally separate, aren't they? And I don't think it's right if not.

Yes, they should be separated.

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

which has clock from I2C (66 MHz).

You mean I2C scl or I2S sclk?

I2C scl.

A couple of things here.....
1) I don't think I2C scl can run at 66MHz...The 66MHz is probably the ipg clock of I2C controller.

I agree. I2C scl runs with 400 kHz (as recommended by I2C high speed spec).

And considering above, the 66 MHz clock seems to be from ssi IP block.

Quoted 2 lines

2) Even if the scl does run at 66MHz, there is no point in passing the clock of I2C scl into an I2S dai-link.

Yes.

Quoted 4 lines

So I feel something must be wrong. I suggest you to add some printk to check the names of those nodes and x_of_node in the simple card driver.

The problem is with the "lack" of clock nodes/properties at

dailink_master: cpu {

 			    sound-dai = <&ssi2>;
			    clock = <&SSSS>;
			    system-clock-frequency = <XXXX>;

};

and as a result we take some "default" clock.

Quoted 22 lines
Quoted 14 lines

My DTS [1] (it is different than other in-tree supported codecs - at least I did not find similar setup in DTSes):

	sound {
		compatible = "simple-audio-card";
		label = "tfa9879-mono";

		simple-audio-card,dai-link {
			/* DAC */
			format = "i2s";
			bitclock-master = <&dailink_master>;
			frame-master = <&dailink_master>;
Quoted 7 lines
			dailink_master: cpu {
			    sound-dai = <&ssi2>;
			};
			codec {
			    sound-dai = <&codec>;
			};
		};
Quoted 3 lines

I remember there is another style for a single dai-link. Could you please try that one? There is an example in:
Documentation/devicetree/bindings/sound/simple-card.txt

Yes, the

simple-audio-card,cpu
simple-audio-card,format,
....

etc.

I've omitted it since in the code it is regarded as "old":
(simple-card.c line 384).

Quoted 1 line

I think that the proper solution would be to add check for:

freq < sysclk/5 in fsl_ssi_set_dai_sysclk() and return -ENOTSUPP to make the simple-audo-card driver happy (and not introducing regressions).

Signature · 13 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
reviewer
#10 lore raw
Quoted 14 lines · Łukasz Majewski
Quoted 9 lines

Here is the routine that I understood from the code:

1) asoc_simple_card_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
   => asoc_simple_card_parse_clk(dev, cpu,        // cpu node in sound{} [1]
		   		 dai_link->cpu_of_node,     // node ssi2 [2]
				 cpu_dai, dai_link->cpu_dai_name);
   ==> 1.1) devm_get_clk_from_child(dev, node, NULL);                 // [1]
   ==> 1.2) of_property_read_u32(node, "system-clock-frequency", &val)// [1]
   ==> 1.3) devm_get_clk_from_child(dev, dai_of_node, NULL);          // [2]
Quoted 4 lines

For the cpu routine, it first checks for clock property under cpu node of simple-card, then for "system-clock-frequency" in the cpu node of simple-card, and finally looks for clock property in ssi2 node.

Quoted 5 lines

-----> dev: sound
-----> clk node: /soc/aips-bus@02000000/spba-bus@02000000/ssi@0202c000 -----> Clk asignment

And this clock is taken from this node. It looks like ipg clock for ssi...

This makes sense now. The devm_get_clk_from_child() in 1.3) fetched the first clock of ssi2 -- ipg clock.

Quoted 7 lines

The problem is with the "lack" of clock nodes/properties at

(quoted diff) +0 -0
 			dailink_master: cpu {
 			    sound-dai = <&ssi2>;
			    clock = <&SSSS>;
			    system-clock-frequency = <XXXX>;

};

This is the right solution based on current simple-card driver. For SSI (having two clocks), you have to specify the baud clock in the cpu node like that. I believe this is what the simple-card designer expected users to do since the cpu node is the first place that the driver tries to look at.

Quoted 5 lines

I think that the proper solution would be to add check for:

freq < sysclk/5 in fsl_ssi_set_dai_sysclk() and return -ENOTSUPP to make the simple-audo-card driver happy (and not introducing regressions).

As I said in the first place, adding another check in set_sysclk() is not that essential but seems to be plausible to me. So I am okay if you really want to have that.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#11 lore raw

Hi Nicolin,

Quoted 16 lines · Łukasz Majewski
Quoted 14 lines
Quoted 14 lines

Here is the routine that I understood from the code:

1) asoc_simple_card_parse_clk_cpu(dev, cpu, dai_link, cpu_dai);
    => asoc_simple_card_parse_clk(dev, cpu,        // cpu node in sound{} [1]
		   		 dai_link->cpu_of_node,     // node ssi2 [2]
				 cpu_dai, dai_link->cpu_dai_name);
    ==> 1.1) devm_get_clk_from_child(dev, node, NULL);                 // [1]
    ==> 1.2) of_property_read_u32(node, "system-clock-frequency", &val)// [1]
    ==> 1.3) devm_get_clk_from_child(dev, dai_of_node, NULL);          // [2]

For the cpu routine, it first checks for clock property under cpu node of simple-card, then for "system-clock-frequency" in the cpu node of simple-card, and finally looks for clock property in ssi2 node.

Quoted 8 lines
Quoted 5 lines

-----> dev: sound
-----> clk node: /soc/aips-bus@02000000/spba-bus@02000000/ssi@0202c000 -----> Clk asignment

And this clock is taken from this node. It looks like ipg clock for ssi...

This makes sense now. The devm_get_clk_from_child() in 1.3) fetched the first clock of ssi2 -- ipg clock.

Yes, exactly (for SSI2) [1]:

	clocks = <&clks IMX6QDL_CLK_SSI2_IPG>,
		 <&clks IMX6QDL_CLK_SSI2>;
	clock-names = "ipg", "baud";
Quoted 6 lines
Quoted 6 lines

The problem is with the "lack" of clock nodes/properties at

dailink_master: cpu {

  			    sound-dai = <&ssi2>;
			    clock = <&SSSS>;

If possible I do prefer a solution, which uses only DTS.

Side question - how to refer to baud clock from [1]?

Quoted 8 lines
Quoted 2 lines
			    system-clock-frequency = <XXXX>;

};

This is the right solution based on current simple-card driver. For SSI (having two clocks), you have to specify the baud clock in the cpu node like that. I believe this is what the simple-card designer expected users to do since the cpu node is the first place that the driver tries to look at.

I will give a shoot the option with adding the ipg clock.

Quoted 11 lines
Quoted 6 lines

I think that the proper solution would be to add check for:

freq < sysclk/5 in fsl_ssi_set_dai_sysclk() and return -ENOTSUPP to make the simple-audo-card driver happy (and not introducing regressions).

As I said in the first place, adding another check in set_sysclk() is not that essential but seems to be plausible to me. So I am okay if you really want to have that.

Thanks for help.

Signature · 9 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
reviewer
#12 lore raw
Quoted 10 lines · Łukasz Majewski
	clocks = <&clks IMX6QDL_CLK_SSI2_IPG>,
		 <&clks IMX6QDL_CLK_SSI2>;
	clock-names = "ipg", "baud";
Quoted 3 lines
Quoted 3 lines
(quoted diff) +0 -0
 			dailink_master: cpu {
 			    sound-dai = <&ssi2>;
			    clock = <&SSSS>;

If possible I do prefer a solution, which uses only DTS.
Side question - how to refer to baud clock from [1]?

Just add a property to this cpu node like:

	clock = <&clks IMX6QDL_CLK_SSI2>;
Quoted 1 line
Quoted 1 line
Quoted 1 line
			    system-clock-frequency = <XXXX>;

This would not be necessary unless you want to specify a clock rate so as to override the clock rate configuration in hw_params().

Quoted 7 lines
Quoted 5 lines

This is the right solution based on current simple-card driver. For SSI (having two clocks), you have to specify the baud clock in the cpu node like that. I believe this is what the simple-card designer expected users to do since the cpu node is the first place that the driver tries to look at.

I will give a shoot the option with adding the ipg clock.

No, not ipg clock. You should use the second clock -- baud clock.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#13 lore raw
Quoted 10 lines · Nicolin Chen
Quoted 8 lines · Łukasz Majewski
	clocks = <&clks IMX6QDL_CLK_SSI2_IPG>,
		 <&clks IMX6QDL_CLK_SSI2>;
	clock-names = "ipg", "baud";
Quoted 3 lines
Quoted 3 lines

dailink_master: cpu {

  			    sound-dai = <&ssi2>;
			    clock = <&SSSS>;
Quoted 5 lines
Quoted 2 lines

If possible I do prefer a solution, which uses only DTS.
Side question - how to refer to baud clock from [1]?

Just add a property to this cpu node like:

	clock = <&clks IMX6QDL_CLK_SSI2>;

Ok.

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
			    system-clock-frequency = <XXXX>;

This would not be necessary unless you want to specify a clock rate so as to override the clock rate configuration in hw_params().

Ok.

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

This is the right solution based on current simple-card driver. For SSI (having two clocks), you have to specify the baud clock in the cpu node like that. I believe this is what the simple-card designer expected users to do since the cpu node is the first place that the driver tries to look at.

I will give a shoot the option with adding the ipg clock.

No, not ipg clock. You should use the second clock -- baud clock.

Yes. Correct - the baud clock.

Quoted 1 line
Signature · 13 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#26 lore raw
In reply to Nicolin Chen
Quoted 8 lines · Nicolin Chen

The ipg clock is merely used to access registers, and has nothing (directly) to do with external clock outputs. The driver shall not change the ipg clock as the system ipg clock (its parent clock) might be messed and even system time would get weird -- happened once when the fsl_spdif driver used to call clk_set_rate() on its ipg clock. Although the clock controller should have some kind of protection in my opinion, we just avoid IP clock rate change in all audio drivers as well.

Yes, the clock API needs constraints code.

Quoted 11 lines

On the other hand, the sys clock (baudclk in the driver) should be configured whenever it's related to external clock outputs. When I implemented this set_sysclk() for fsl_ssi.c, I used it to set this sys clock (baudclk) by a machine driver, in order to set bit clock. Then someone patched the driver by moving all the code to set_bclk() to make machine drivers simpler. Now the set_sysclk() is remained to give machine drivers a chance to override clock configurations in the hw_params(). This could be used in TDM or some other special cases (It could also have a purpose for backwards compatibility).

So here, we should set baudclk (BCLK generator).

No, that's just going to cause confusion - if all the other drivers are using set_sysclk() to set an input clock rate to the IP rather than an output clock but your driver does something else then sooner or later someone will run into trouble with that.

reviewer
#27 lore raw
Quoted 10 lines · Mark Brown
Quoted 9 lines

On the other hand, the sys clock (baudclk in the driver) should be configured whenever it's related to external clock outputs. When I implemented this set_sysclk() for fsl_ssi.c, I used it to set this sys clock (baudclk) by a machine driver, in order to set bit clock. Then someone patched the driver by moving all the code to set_bclk() to make machine drivers simpler. Now the set_sysclk() is remained to give machine drivers a chance to override clock configurations in the hw_params(). This could be used in TDM or some other special cases (It could also have a purpose for backwards compatibility).

Quoted 6 lines
Quoted 1 line

So here, we should set baudclk (BCLK generator).

No, that's just going to cause confusion - if all the other drivers are using set_sysclk() to set an input clock rate to the IP rather than an output clock but your driver does something else then sooner or later someone will run into trouble with that.

I admit I had that concern. Probably I should have deprecated this set_sysclk(). I will try to patch it and hw_params() accordingly.

#14 lore raw
In reply to Nicolin Chen

Hi Nicolin,

Quoted 10 lines · Łukasz Majewski
Quoted 9 lines
  
	clocks = <&clks IMX6QDL_CLK_SSI2_IPG>,
		 <&clks IMX6QDL_CLK_SSI2>;
	clock-names = "ipg", "baud";
Quoted 3 lines
Quoted 3 lines

dailink_master: cpu {

  			    sound-dai = <&ssi2>;
			    clock = <&SSSS>;
Quoted 5 lines
Quoted 2 lines

If possible I do prefer a solution, which uses only DTS.
Side question - how to refer to baud clock from [1]?

Just add a property to this cpu node like:

	clock = <&clks IMX6QDL_CLK_SSI2>;

This doesn't solve the issue:

root@display5:~# speaker-test

speaker-test 1.1.3

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48fsl-ssi-dai 202c000.ssi: bitclk > ipgclk/5 000Hz)
Buffer size range from 64fsl-ssi-dai 202c000.ssi: ASoC: can't set 202c000.ssi hw params: -22
to 65536
Period size range from 32 to 8191
Using max buffer size 65536
Periods = 4
Unable to set hw params for playback: Invalid argument
Setting of hwparams failed: Invalid argument

Quoted 16 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
			    system-clock-frequency = <XXXX>;

This would not be necessary unless you want to specify a clock rate so as to override the clock rate configuration in hw_params().

Quoted 7 lines
Quoted 5 lines

This is the right solution based on current simple-card driver. For SSI (having two clocks), you have to specify the baud clock in the cpu node like that. I believe this is what the simple-card designer expected users to do since the cpu node is the first place that the driver tries to look at.

I will give a shoot the option with adding the ipg clock.

No, not ipg clock. You should use the second clock -- baud clock.

Signature · 13 lines
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
reviewer
#15 lore raw
Quoted 4 lines · Łukasz Majewski
Quoted 2 lines

Just add a property to this cpu node like:

	clock = <&clks IMX6QDL_CLK_SSI2>;

This doesn't solve the issue:

I have a patch locally that should be able to solve your problem. But I need to first verify on my board tonight and will send it later (will put you in the TO/CC list).
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel