Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to enable I2S Rock64 DAC on a mainline kernel or on the ayufan-rock64 4.4 kernel? #460

Open
mikhailian opened this issue Mar 19, 2021 · 7 comments

Comments

@mikhailian
Copy link

The title says it all.

I guess this requires fiddling with device tree, but I am not knowledgeable enough to figure out what to change. And the documentation on Rock64 wiki seems to be lacking.

@mikhailian mikhailian changed the title Is there a way to enable IS2 Rock64 DAC on a mainline kernel? Is there a way to enable IS2 Rock64 DAC on a mainline kernel or on the ayufan-rock64 4.4 kernel? Mar 19, 2021
@ayufan
Copy link
Member

ayufan commented Mar 22, 2021

@mikhailian Do you talk about enabling spdif on i2s?

@mikhailian
Copy link
Author

Nope, I am trying to get RCA analog output.

I booted mainline Arch Linux kernel 5.11 and did not see the audio hat.

Tried with latest Armbian 5.10-21-rockchip64 and saw no audio hat either.

I can switch the built-in audio in mainline Arch Linux kernel before 5.12 with the following trick:

fdtput -t s /boot/dtbs/rockchip/rk3328-rock64.dtb /analog-sound status okay
reboot

Then, aplay -l shows the following both with and without the DAC hat. I assume this is built-in audio.

**** List of PLAYBACK Hardware Devices ****
card 0: rockchiprk3328 [rockchip,rk3328], device 0: ff000000.i2s-i2s-hifi i2s-hifi-0 [ff000000.i2s-i2s-hifi i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: rockchiprk3328 [rockchip,rk3328], device 1: ff010000.i2s-rk3328-hifi ff410000.codec-1 [ff010000.i2s-rk3328-hifi ff410000.codec-1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: rockchiprk3328 [rockchip,rk3328], device 2: ff030000.spdif-dit-hifi dit-hifi-2 [ff030000.spdif-dit-hifi dit-hifi-2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

This is a ES9023-based DAC, I tried find /usr -name '9023'` but this gives no results.

Don't know where to start exploring from there.

@mikhailian mikhailian changed the title Is there a way to enable IS2 Rock64 DAC on a mainline kernel or on the ayufan-rock64 4.4 kernel? Is there a way to enable I2S Rock64 DAC on a mainline kernel or on the ayufan-rock64 4.4 kernel? Mar 22, 2021
@ayufan
Copy link
Member

ayufan commented Mar 22, 2021

@mikhailian

So, you try to connect to A/C output?

There's a bunch of different outputs on this board:

  • HDMI sound
  • RCA on a HiFi shield
  • Headphone jack on a HiFi shield
  • A/V Jack

I guess, we talk about RCA on a HiFi shield: these two goldplated connectors?

@ayufan
Copy link
Member

ayufan commented Mar 22, 2021

@mikhailian

From what I see the RCA on HiFi shield should be on i2s1, which is ff010000.i2s-rk3328-hifi. Can you try playing through this device? Can you also change J4 from L and H and vice-versa? This impacts a clock source of ES9023.

@mikhailian
Copy link
Author

I tried all combinations of jumpers on the latest Armbian with kernel 5.10, but the only sound output that works is card0, device 1, which is the built-in audio.

Willing to try with the latest Linux mainline kernel, I wrote Arch Linux Arm to the emmc card, booted with it and I now see the following:

uname -a
Linux alarm 5.12.0-rc3-3-ARCH #2 SMP Thu Mar 18 00:37:31 UTC 2021 aarch64 GNU/Linux
[root@alarm alarm]# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Analog
    Analog, ff010000.i2s-rk3328-hifi ff410000.codec-0
    Default Audio Device
sysdefault:CARD=Analog
    Analog, ff010000.i2s-rk3328-hifi ff410000.codec-0
    Default Audio Device
default:CARD=HDMI
    HDMI, ff000000.i2s-i2s-hifi i2s-hifi-0
    Default Audio Device
sysdefault:CARD=HDMI
    HDMI, ff000000.i2s-i2s-hifi i2s-hifi-0
    Default Audio Device

As much as I understand this, i2s bus is not even enabled, so I searched around, found your dtedit script, extracted the current device tree, found

        i2s@ff020000 {
                compatible = "rockchip,rk3328-i2s\0rockchip,rk3066-i2s";
                reg = <0x00 0xff020000 0x00 0x1000>;
                interrupts = <0x00 0x1c 0x04>;
                clocks = <0x02 0x2b 0x02 0x139>;
                clock-names = "i2s_clk\0i2s_hclk";
                dmas = <0x10 0x00 0x10 0x01>;
                dma-names = "tx\0rx";
                #sound-dai-cells = <0x00>;
                status = "disabled";
                phandle = <0x6c>;
        };`

changed the status to okay, created the dtb file and wrote it to /boot/dtbs/rockchip/rk3328-rock64.dtb. Then I checked that is is picked by the kernel by comparing the old device tree to the new.

After all these manipulations aplay -L still shows

[root@alarm ~]# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Analog
    Analog, ff010000.i2s-rk3328-hifi ff410000.codec-0
    Default Audio Device
sysdefault:CARD=Analog
    Analog, ff010000.i2s-rk3328-hifi ff410000.codec-0
    Default Audio Device
default:CARD=HDMI
    HDMI, ff000000.i2s-i2s-hifi i2s-hifi-0
    Default Audio Device
sysdefault:CARD=HDMI
    HDMI, ff000000.i2s-i2s-hifi i2s-hifi-0
    Default Audio Device

dmesg does not seem to complain about i2s

[root@alarm ~]# dmesg -l err
[    2.566197] rockchip-pinctrl pinctrl: pin gpio0-2 already requested by vcc-host-5v-regulator; cannot claim for vcc-host1-5v-regulator
[    2.567342] rockchip-pinctrl pinctrl: pin-2 (vcc-host1-5v-regulator) status -22
[    2.568014] rockchip-pinctrl pinctrl: could not request pin 2 (gpio0-2) from group usb20-host-drv  on device rockchip-pinctrl
[    2.569054] reg-fixed-voltage vcc-host1-5v-regulator: Error applying setting, reverse things back
[    3.534716] gpio-syscon ff100000.syscon:grf-gpio: can't read the data register offset!
[    7.510715] rk_gmac-dwmac ff540000.ethernet: cannot get clock clk_mac_speed

nor does it tell anything about i2s.

[root@alarm ~]# dmesg |grep mclk
[root@alarm ~]# 

@mikhailian
Copy link
Author

Here is the gist with the complete device tree.

@dantheperson
Copy link

Also interested in this. I used to have this working on armbian, but then moved house a few times and it went in a packing box for a while. Trying to resurect it with the latest armbian no luck.

Today i tried volumio instead and bingo DAC shield RCA outputs work.

volumio@volumio:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDMI], device 0: ff000000.i2s-i2s-hifi i2s-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: I2S [I2S], device 0: ff010000.i2s-rk3328-hifi rk3328-hifi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: I2S [I2S], device 1: ff010000.i2s-snd-soc-dummy-dai snd-soc-dummy-dai-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: SPDIF [SPDIF], device 0: ff030000.spdif-dit-hifi dit-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
volumio@volumio:~$ uname -a
Linux volumio 4.4.154 #1 SMP Tue Oct 13 11:37:38 CEST 2020 aarch64 GNU/Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants