[Letux-kernel] jz4730 sound

H. Nikolaus Schaller hns at goldelico.com
Tue Jan 26 11:37:27 CET 2021


> Am 24.01.2021 um 19:37 schrieb Paul Boddie <paul at boddie.org.uk>:
> 
> On Saturday, 23 January 2021 18:22:46 CET H. Nikolaus Schaller wrote:
>> Hi Paul,
>> I have found some issues in the device tree and
>> the i2s node wasn't complete at all.
> 
> Sorry not to reply to this earlier! To look into this a bit more, I reviewed 
> the clock definitions and found that we were missing a "bitclk" for AIC/I2S, 
> and the gating wasn't being done for the existing I2S clock. So, there's a 
> patch to add a new clock and to update the existing one.
> 
>> Hence I have checked with jz4740 and the i2s controllers
>> are quite similar. On a first scan of the documentation
>> there are only minor differences in 24 bit capabilites.
>> And some status registers may have additional bits.
> 
> It will probably need checking just to make sure.
> 
>> So it is likely to get it run.
>> 
>> But it needs DMA...
>> And I2C to access the external sound chip...
> 
> I hadn't looked into interacting with the sound chip over I2C, not really 
> knowing where to start, but we will obviously need reliable I2C support to 
> have a chance of setting it up.
> 
>> Maybe it is also easier to test DMA for this subsystem
>> than for MMC which is necessary for boot.
> 
> Yes, I would imagine so.
> 
>> Anyways, attached is a proposal where I think the compatible,
>> the ref and the interrupt and dma channel numbers are correct.
>> 
>> What do you think how to correctly set up the jz4730 clocks?
> 
> The patch should fix the clocks to make them available. About the node 
> itself...
> 
>> 	i2s: i2s at 10020000 {
>> 		compatible = "ingenic,jz4730-i2s";
> 
> I guess we will only need JZ4730-specific identification if there are some 
> differences, but you probably know more about this than me at the moment. :-)

Well, there is a difference in the 24 bit mode and it seems that there
are small diffs in some config registers. But as usual not much.

> 
>> 		reg = <0x10020000 0x38>;
>> 
>> 		#sound-dai-cells = <0>;
>> 
>> 		interrupt-parent = <&intc>;
>> 		interrupts = <20>;
>> 
>> /* FIXME:
>> 		clocks = <&cgu JZ4740_CLK_AIC>,
>> 			 <&cgu JZ4740_CLK_I2S>,
>> 			 <&cgu JZ4740_CLK_EXT>,
>> 			 <&cgu JZ4740_CLK_PLL_HALF>;
>> 		clock-names = "aic", "i2s", "ext", "pll half";
>> */
> 
> This looks OK. I add the missing AIC clock in the patch, which is the 
> "bitclk".

Compiles fine with JZ4740_CLK_* -> JZ4730_CLK_*


>> 		dmas = <&dmac 25 0xffffffff>, <&dmac 24 0xffffffff>;
>> 		dma-names = "rx", "tx";
>> 	};
> 
> I hope this is OK, too!
> 
> Paul<0001-Added-missing-AIC-clock-and-gating-for-I2S-clock.patch>

Also added...

Now with the blacklisting I can easily boot and:

root at letux:~# modprobe snd_soc_jz4740_i2s
[  246.975343] jz4780_of_dma_xlate
[  246.976619] jz4780_of_dma_xlate 1
[  246.980282] jz4780_of_dma_xlate 4
[  246.984290] jz4780_of_dma_xlate
[  246.985191] jz4780_of_dma_xlate 1
[  246.987619] jz4780_of_dma_xlate 4
root at letux:~# ls -l /sys/devices/platform/10020000.i2s
total 0
lrwxrwxrwx 1 root root    0 Jan  1 00:04 dma:rx -> ../13020000.dma/dma/dma0chan3
lrwxrwxrwx 1 root root    0 Jan  1 00:04 dma:tx -> ../13020000.dma/dma/dma0chan2
lrwxrwxrwx 1 root root    0 Jan  1 00:04 driver -> ../../../bus/platform/drivers/jz4740-i2s
-rw-r--r-- 1 root root 4096 Jan  1 00:04 driver_override
-r--r--r-- 1 root root 4096 Jan  1  1970 modalias
lrwxrwxrwx 1 root root    0 Jan  1  1970 of_node -> ../../../firmware/devicetree/base/i2s at 10020000
drwxr-xr-x 2 root root    0 Jan  1 00:04 power
lrwxrwxrwx 1 root root    0 Jan  1 00:04 subsystem -> ../../../bus/platform
-rw-r--r-- 1 root root 4096 Jan  1 00:04 uevent
root at letux:~# 

So there are no complaints or obvious issues by the driver.
(It failed with a -2 error before).

Loading the sound chip driver is also promising:

root at letux:~# modprobe snd_soc_ak4642
root at letux:~# [  339.619230] jz4730_i2c_xfer count=1
[  339.626073] jz4730_i2c_xfer wait_time=5
[  339.628326] jz4730_i2c_irq: state 0 msg=0 pos=0 len=2 CR=0x13 SR=0x0c
[  339.630378] jz4730_i2c_irq msg=83929a18 flags=0x0 len=2
[  339.631133] jz4730_i2c_irq: state 1 msg=0 pos=0 len=2 CR=0x11 SR=0x0c
[  339.632959] jz4730_i2c_irq: state 3 msg=0 pos=0 len=2 CR=0x11 SR=0x08
[  339.634144] jz4730_i2c_irq: state 3 msg=0 pos=1 len=2 CR=0x11 SR=0x08
[  339.634773] jz4730_i2c_irq: state 3 msg=0 pos=2 len=2 CR=0x11 SR=0x08
[  339.634895] jz4730_i2c_irq: state 4 msg=0 pos=2 len=2 CR=0x11 SR=0x0c
[  339.652134] jz4730_i2c_irq done STO
[  339.648355] jz4730_i2c_irq: state 0 msg=1 pos=2 len=52736 CR=0x11 SR=0x1c
[  339.665828] jz4730_i2c_irq: complete
[  339.661659] i2c i2c-0: spurious interrupt during state 0 CR=0x11 SR=0x1c
[  339.675589] jz4730_i2c_xfer done
[  339.672049] jz4730_i2c_xfer count=1
[  339.688105] jz4730_i2c_xfer wait_time=5
[  339.703582] jz4730_i2c_irq: state 0 msg=0 pos=2 len=2 CR=0x11 SR=0x04
[  339.701662] jz4730_i2c_irq msg=83929a90 flags=0x0 len=2
[  339.716090] jz4730_i2c_irq: state 1 msg=0 pos=0 len=2 CR=0x11 SR=0x0c
[  339.731876] jz4730_i2c_irq: state 3 msg=0 pos=0 len=2 CR=0x11 SR=0x08
[  339.747224] jz4730_i2c_irq: state 3 msg=0 pos=1 len=2 CR=0x11 SR=0x08
[  339.762249] jz4730_i2c_irq: state 3 msg=0 pos=2 len=2 CR=0x11 SR=0x08
[  339.777139] jz4730_i2c_irq: state 4 msg=0 pos=2 len=2 CR=0x11 SR=0x0c
[  339.791424] jz4730_i2c_irq done STO
[  339.785038] jz4730_i2c_irq: state 0 msg=1 pos=2 len=52736 CR=0x11 SR=0x1c
[  339.800034] jz4730_i2c_irq: complete
[  339.793988] i2c i2c-0: spurious interrupt during state 0 CR=0x11 SR=0x1c
[  339.797078] jz4730_i2c_xfer done
[  339.809774] jz4730_i2c_xfer count=1
[  339.825167] jz4730_i2c_xfer wait_time=5
[  339.840555] jz4730_i2c_irq: state 0 msg=0 pos=2 len=2 CR=0x11 SR=0x04
[  339.839011] jz4730_i2c_irq msg=83929a90 flags=0x0 len=2
[  339.854198] jz4730_i2c_irq: state 1 msg=0 pos=0 len=2 CR=0x11 SR=0x0c
[  339.870705] jz4730_i2c_irq: state 3 msg=0 pos=0 len=2 CR=0x11 SR=0x08
[  339.886895] jz4730_i2c_irq: state 3 msg=0 pos=1 len=2 CR=0x11 SR=0x08
[  339.903081] jz4730_i2c_irq: state 3 msg=0 pos=2 len=2 CR=0x11 SR=0x08
[  339.919279] jz4730_i2c_irq: state 4 msg=0 pos=2 len=2 CR=0x11 SR=0x0c
[  339.935161] jz4730_i2c_irq done STO
[  339.930576] jz4730_i2c_irq: state 0 msg=1 pos=2 len=52736 CR=0x11 SR=0x1c
[  339.947207] jz4730_i2c_irq: complete
[  339.942431] i2c i2c-0: spurious interrupt during state 0 CR=0x11 SR=0x1c
[  339.941542] jz4730_i2c_xfer done
[  339.954913] asoc-simple-card sound: ASoC: no source widget found for DAI0 Playback
[  339.955173] asoc-simple-card sound: ASoC: Failed to add route DAI0 Playback -> direct -> ak4642 Playback
[  339.967969] asoc-simple-card sound: ASoC: no sink widget found for DAI0 Capture
[  339.969171] asoc-simple-card sound: ASoC: Failed to add route ak4642 Capture -> direct -> DAI0 Capture
root at letux:~# aplay -l
aplay: device_list:268: no soundcards found...
root at letux:~# 

But then we are missing some widgets/DAI links. This is not driver or clock related.

Seems to be an issue with the routing table in:

	sound: sound {
		compatible = "simple-scu-audio-card";

		simple-audio-card,name = "sound";
		simple-audio-card,format = "left_j";
		simple-audio-card,bitclock-master = <&sndcodec>;
		simple-audio-card,frame-master = <&sndcodec>;

		simple-audio-card,convert-rate = <48000>;

		simple-audio-card,prefix = "ak4642";
		simple-audio-card,routing = "ak4642 Playback", "DAI0 Playback",
				"DAI0 Capture", "ak4642 Capture";

		sndcpu: simple-audio-card,cpu {
			sound-dai = <&i2s>;
		};

		sndcodec: simple-audio-card,codec {
			sound-dai = <&ak4642>;
			system-clock-frequency = <11289600>;
		};
	};

Maybe someone has an idea...

BR,
Nikolaus



More information about the Letux-kernel mailing list