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

rockchip64: revert rk3308 analog codec to vendor code #7598

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

paolosabatino
Copy link
Contributor

Description

Due to kernel 6.12 becoming "current" for rockchip64 with #7566, restore the rk3308 sound codec driver from vendor code because mainline driver does not support ACODEC_VERSION_B variant found in rk3308b SoCs.

Nothing else is affected, only rk3308 boards.

For the attention of @brentr

How Has This Been Tested?

  • Kernel deb packages compiled and tested on a Rock Pi S on a live installation
  • analog audio output tested and working

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • Any dependent changes have been merged and published in downstream modules

@paolosabatino paolosabatino requested a review from a team December 21, 2024 16:59
@github-actions github-actions bot added size/large PR with 250 lines or more Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Dec 21, 2024
@paolosabatino paolosabatino requested a review from brentr December 21, 2024 16:59
@JohnTheCoolingFan
Copy link
Contributor

JohnTheCoolingFan commented Dec 21, 2024

Sorry, misclicked while trying to do something else. No idea why GitHub didn't add a confirmation for that action on mobile.

@rpardini rpardini force-pushed the rk3308-revert-acodec branch from fe85ebb to d2a3e5d Compare December 22, 2024 10:36
@brentr
Copy link
Collaborator

brentr commented Dec 22, 2024

@paolosabatino
This is not working on my RockPI-S...
Here's the relevant section of the kernel log:

Dec 22 11:22:18 rockpi-s kernel: rk3308-acodec ff560000.codec: Don't need hp-ctl gpio
Dec 22 11:22:18 rockpi-s kernel: rk3308-acodec ff560000.codec: Don't need spk-ctl gpio
Dec 22 11:22:18 rockpi-s kernel: rk3308-acodec ff560000.codec: Don't need pa-drv gpio
Dec 22 11:22:18 rockpi-s kernel: rk3308-acodec ff560000.codec: De-pop as much as possible
Dec 22 11:22:18 rockpi-s kernel: rk3308-acodec ff560000.codec: Can't get acodec pclk
Dec 22 11:22:18 rockpi-s kernel: rk3308-acodec ff560000.codec: probe with driver rk3308-acodec failed with error -2

@brentr
Copy link
Collaborator

brentr commented Dec 22, 2024

Another oddness after applying this patch, near the end of poweroff:

[  OK  ] Reached target poweroff.target - System Power Off.
[  116.816749] ------------[ cut here ]------------
[  116.817221] kobject: '(null)' (000000004be43312): is not initialized, yet kobject_get() is being called.
[  116.818291] WARNING: CPU: 1 PID: 1 at lib/kobject.c:640 kobject_get+0x84/0xbc
[  116.818981] Modules linked in: sunrpc 8723ds crct10dif_ce hci_uart cfg80211 btqca btrtl snd_soc_simple_card snd_soc_rk3308 snd_soc_rockchip_i2s_tdm snd_soc_simple_card_utils btintel snd_soc_core btbcm snd_compress bluetooth snd_pcm_dmaengine snd_pcm snd_timer rfkill snd soundcore nvmem_rockchip_otp cpufreq_dt zram binfmt_misc drm dm_mod drm_panel_orientation_quirks ip_tables x_tables autofs4 realtek dwmac_rk stmmac_platform stmmac pcs_xpcs
[  116.822906] CPU: 1 UID: 0 PID: 1 Comm: systemd-shutdow Not tainted 6.12.6-edge-rockchip64 #11
[  116.823692] Hardware name: Radxa ROCK Pi S (DT)
[  116.824116] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  116.824767] pc : kobject_get+0x84/0xbc
[  116.825136] lr : kobject_get+0x84/0xbc
[  116.825501] sp : ffff80008003bc30
[  116.825814] x29: ffff80008003bc30 x28: ffff2b61805a8000 x27: 0000000000000000
[  116.826513] x26: ffffbb0e935c0838 x25: 0000000000000001 x24: ffffbb0e93eba048
[  116.827208] x23: ffff2b61873f3090 x22: ffffbb0e93f57550 x21: ffff2b61852696e8
[  116.827901] x20: ffff2b619c2b5088 x19: ffff2b619c2b5088 x18: ffffffffffffffff
[  116.828594] x17: 6f6b20746579202c x16: 64657a696c616974 x15: 696e6920746f6e20
[  116.829287] x14: 00000000ffffffea x13: ffff80008003b9d8 x12: ffffbb0e93ce0d70
[  116.829982] x11: 0000000000000001 x10: 0000000000000001 x9 : 000000000002ffe8
[  116.830673] x8 : c0000000ffffdfff x7 : ffffbb0e93c30cf0 x6 : 00000000000affa8
[  116.831366] x5 : ffffbb0e93ce0d18 x4 : 0000000000000000 x3 : 0000000000000000
[  116.832057] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff2b61805a8000
[  116.832753] Call trace:
[  116.832992]  kobject_get+0x84/0xbc
[  116.833334]  device_shutdown+0xc4/0x25c
[  116.833725]  kernel_power_off+0x38/0x80
[  116.834109]  __do_sys_reboot+0x22c/0x26c
[  116.834494]  __arm64_sys_reboot+0x24/0x30
[  116.834892]  invoke_syscall+0x48/0x110
[  116.835269]  el0_svc_common.constprop.0+0x40/0xe0
[  116.835732]  do_el0_svc+0x1c/0x28
[  116.836068]  el0_svc+0x30/0xd0
[  116.836385]  el0t_64_sync_handler+0x100/0x12c
[  116.836815]  el0t_64_sync+0x190/0x194
[  116.837180] ---[ end trace 0000000000000000 ]---
[  116.837798] ------------[ cut here ]------------
[  116.838238] refcount_t: saturated; leaking memory.
[  116.838817] WARNING: CPU: 1 PID: 1 at lib/refcount.c:22 refcount_warn_saturate+0x74/0x144
[  116.839596] Modules linked in: sunrpc 8723ds crct10dif_ce hci_uart cfg80211 btqca btrtl snd_soc_simple_card snd_soc_rk3308 snd_soc_rockchip_i2s_tdm snd_soc_simple_card_utils btintel snd_soc_core btbcm snd_compress bluetooth snd_pcm_dmaengine snd_pcm snd_timer rfkill snd soundcore nvmem_rockchip_otp cpufreq_dt zram binfmt_misc drm dm_mod drm_panel_orientation_quirks ip_tables x_tables autofs4 realtek dwmac_rk stmmac_platform stmmac pcs_xpcs
[  116.843475] CPU: 1 UID: 0 PID: 1 Comm: systemd-shutdow Tainted: G        W          6.12.6-edge-rockchip64 #11
[  116.844398] Tainted: [W]=WARN
[  116.844683] Hardware name: Radxa ROCK Pi S (DT)
[  116.845105] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  116.845754] pc : refcount_warn_saturate+0x74/0x144
[  116.846221] lr : refcount_warn_saturate+0x74/0x144
[  116.846685] sp : ffff80008003bc20
[  116.846999] x29: ffff80008003bc20 x28: ffff2b61805a8000 x27: 0000000000000000
[  116.847699] x26: ffffbb0e935c0838 x25: 0000000000000001 x24: ffffbb0e93eba048
[  116.848392] x23: ffff2b61873f3090 x22: ffffbb0e93f57550 x21: ffff2b61852696e8
[  116.849086] x20: ffff2b619c2b5088 x19: ffff2b619c2b5088 x18: ffffffffffffffff
[  116.849778] x17: 6f6b20746579202c x16: 64657a696c616974 x15: 0000000000000006
[  116.850470] x14: 00000000ffffffea x13: ffff80008003b9c8 x12: ffffbb0e93ce0d70
[  116.851162] x11: 0000000000000001 x10: 0000000000000001 x9 : 000000000002ffe8
[  116.851854] x8 : c0000000ffffdfff x7 : ffffbb0e93c30cf0 x6 : 00000000000affa8
[  116.852548] x5 : ffffbb0e93ce0d18 x4 : 0000000000000000 x3 : 0000000000000000
[  116.853240] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff2b61805a8000
[  116.853932] Call trace:
[  116.854171]  refcount_warn_saturate+0x74/0x144
[  116.854610]  kobject_get+0x9c/0xbc
[  116.854952]  device_shutdown+0xc4/0x25c
[  116.855339]  kernel_power_off+0x38/0x80
[  116.855723]  __do_sys_reboot+0x22c/0x26c
[  116.856108]  __arm64_sys_reboot+0x24/0x30
[  116.856502]  invoke_syscall+0x48/0x110
[  116.856880]  el0_svc_common.constprop.0+0x40/0xe0
[  116.857339]  do_el0_svc+0x1c/0x28
[  116.857675]  el0_svc+0x30/0xd0
[  116.857990]  el0t_64_sync_handler+0x100/0x12c
[  116.858419]  el0t_64_sync+0x190/0x194
[  116.858782] ---[ end trace 0000000000000000 ]---
[  116.859458] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
[  116.860269] Mem abort info:
[  116.860535]   ESR = 0x0000000096000004
[  116.860890]   EC = 0x25: DABT (current EL), IL = 32 bits
[  116.861382]   SET = 0, FnV = 0
[  116.861677]   EA = 0, S1PTW = 0
[  116.861977]   FSC = 0x04: level 0 translation fault
[  116.862432] Data abort info:
[  116.862706]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[  116.863209]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[  116.863678]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[  116.864175] user pgtable: 4k pages, 48-bit VAs, pgdp=00000000089bb000
[  116.864770] [0000000000000010] pgd=0000000000000000, p4d=0000000000000000
[  116.865424] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
[  116.866009] Modules linked in: sunrpc 8723ds crct10dif_ce hci_uart cfg80211 btqca btrtl snd_soc_simple_card snd_soc_rk3308 snd_soc_rockchip_i2s_tdm snd_soc_simple_card_utils btintel snd_soc_core btbcm snd_compress bluetooth snd_pcm_dmaengine snd_pcm snd_timer rfkill snd soundcore nvmem_rockchip_otp cpufreq_dt zram binfmt_misc drm dm_mod drm_panel_orientation_quirks ip_tables x_tables autofs4 realtek dwmac_rk stmmac_platform stmmac pcs_xpcs
[  116.869896] CPU: 1 UID: 0 PID: 1 Comm: systemd-shutdow Tainted: G        W          6.12.6-edge-rockchip64 #11
[  116.870816] Tainted: [W]=WARN
[  116.871101] Hardware name: Radxa ROCK Pi S (DT)
[  116.871522] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  116.872168] pc : hrtimer_active+0x8/0x5c
[  116.872557] lr : hrtimer_try_to_cancel+0x14/0x40
[  116.873000] sp : ffff80008003bbb0
[  116.873313] x29: ffff80008003bbb0 x28: ffff2b61805a8000 x27: 0000000000000000
[  116.874009] x26: ffffbb0e935c0838 x25: 0000000000000001 x24: ffffbb0e93eba048
[  116.874701] x23: ffff2b619c2b5108 x22: 0000000000000000 x21: ffff2b619c2b516c
[  116.875396] x20: ffff2b619c2b5238 x19: ffff2b619c2b5088 x18: ffff2b6184adc220
[  116.876089] x17: 6f6b20746579202c x16: 64657a696c616974 x15: 0000001ba7c768d1
[  116.876784] x14: 000000000000018f x13: ffffbb0e93c09d08 x12: 0000000000000001
[  116.877474] x11: 0000001b355d5217 x10: 0000000000000af0 x9 : ffff80008003baf0
[  116.878165] x8 : ffff2b61805a8b50 x7 : ffff2b619fe54d40 x6 : 00000000058c4216
[  116.878857] x5 : 00ffffffffffffff x4 : ffff2b619c2b51b0 x3 : 0000000000000000
[  116.879550] x2 : 0000000000000010 x1 : ffff2b61805a8000 x0 : ffff2b619c2b51b0
[  116.880244] Call trace:
[  116.880482]  hrtimer_active+0x8/0x5c
[  116.880836]  __pm_runtime_barrier+0xf8/0x13c
[  116.881251]  pm_runtime_barrier+0x54/0x104
[  116.881648]  device_shutdown+0x110/0x25c
[  116.882040]  kernel_power_off+0x38/0x80
[  116.882421]  __do_sys_reboot+0x22c/0x26c
[  116.882805]  __arm64_sys_reboot+0x24/0x30
[  116.883199]  invoke_syscall+0x48/0x110
[  116.883576]  el0_svc_common.constprop.0+0x40/0xe0
[  116.884035]  do_el0_svc+0x1c/0x28
[  116.884371]  el0_svc+0x30/0xd0
[  116.884686]  el0t_64_sync_handler+0x100/0x12c
[  116.885115]  el0t_64_sync+0x190/0x194
[  116.885488] Code: 91000400 17ffffe6 f9401803 91004062 (88dffc41) 
[  116.886051] ---[ end trace 0000000000000000 ]---
[  116.886482] note: systemd-shutdow[1] exited with irqs disabled
[  116.887112] note: systemd-shutdow[1] exited with preempt_count 1
[  116.887690] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[  116.888535] Kernel Offset: 0x3b0e12200000 from 0xffff800080000000
[  116.889098] PHYS_OFFSET: 0xffffd49e80000000
[  116.889489] CPU features: 0x00,00000010,00200000,0200421b
[  116.889995] Memory Limit: none
[  116.890295] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

@brentr
Copy link
Collaborator

brentr commented Dec 22, 2024

It may be that this poweroff bug crept in with the very latest revision to the armbian main branch. I'll test that shortly.

@brentr
Copy link
Collaborator

brentr commented Dec 22, 2024

This poweroff panic bug does not appear with the latest main branch
(git hash 91978d7)
It looks to be somehow related to this PR :-(

@paolosabatino
Copy link
Contributor Author

Something off must be happening in the compilation process, perhaps some caches or whatever, because this line:

Dec 22 11:22:18 rockpi-s kernel: rk3308-acodec ff560000.codec: Can't get acodec pclk

is telling that the compiled dtb has not been refreshed during the compilation process for some reason, but the corrections to the source device tree are indeed in this PR: https://github.com/armbian/build/pull/7598/files#diff-02b30c6cbb556bbeb9b9b78da16231fc0b50e7e5bc2d60d960843a5434fbed73R24

It is something that I experienced as well and it drove me crazy. At the end I deleted cache/sources, cache/git-bare and cache/git-bundles to let the compile script download everything from scratch. After this, the output debs were eventually ok. I don't know, at first I thought it was a fault of mine due to some past tinkering, but since it happened to you as well makes me think more about a bug or so. Also, I always use the ARTIFACT_IGNORE_CACHE=yes to compile locally, since I often do modifications.

Now, after cleaning up and compiling with this command line:

./compile.sh BOARD=rockpi-s BRANCH=current kernel ARTIFACT_IGNORE_CACHE=yes

I go into output/debs directory, use dpkg-deb -x to unpack the latest dtb deb package, and if I decompile the rockpi-s device tree I find the correct acodec string in the clock-names property at the third position. If you get hclk instead (and miss interrupts and rockchip,detect-grf properties), then the device tree has not been refreshed correctly.

 codec@ff560000 {
                compatible = "rockchip,rk3308-codec";
                reg = <0x00 0xff560000 0x00 0x10000>;
                rockchip,grf = <0x3c>;
                rockchip,detect-grf = <0x6f>;
                clock-names = "mclk_tx\0mclk_rx\0acodec";
                clocks = <0x02 0x55 0x02 0x57 0x02 0xc4>;
                interrupts = <0x01 0x72 0x04 0x01 0x73 0x04>;
                reset-names = "acodec-reset";
                resets = <0x02 0x99>;
                #sound-dai-cells = <0x00>;
                status = "okay";
                phandle = <0x7e>;
        };

@amazingfate
Copy link
Contributor

Sometimes ccache can't handle changes in devicetree well. Usually I delete the dtb file at cache/source so that the dtb file is recompiled.

@brentr
Copy link
Collaborator

brentr commented Dec 23, 2024

Yep. The overly optimistic caching system got both of us again.
My preferred fix has been to break the hash calculation in the
lib/functions/artifact-xxx.sh
script.
But, in this case, the trouble was likely with the .dtb file, so I'll try @amazingfate's suggestion of deleting that from the cache/source next time.
Might also try deleting:
output/debs/linux-dtb-$BRANCH-rockchip64__verison-hash.deb
Interestingly, the same hash code is used for all the kernel related stuff:
the image, libc-dev, headers, and the dtb

Copy link
Collaborator

@brentr brentr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RockPI-S audio works again with this reversion.
Please merge the PR.
I earlier said that the mainline mixer's HeadPhone (HPOUT) gain control did nothing.
I now suspect that RockChip's POE/audio hat includes an external headphone amp driven by the DAC LINE out.
So, the only real showstopper for the mainline acodec is that its handling of the "DAC HPMI" control.

@igorpecovnik igorpecovnik added Ready to merge Reviewed, tested and ready for merge 02 Milestone: First quarter release and removed Needs review Seeking for review labels Dec 23, 2024
@igorpecovnik igorpecovnik merged commit 9d7ab82 into armbian:main Dec 23, 2024
@paolosabatino
Copy link
Contributor Author

I earlier said that the mainline mixer's HeadPhone (HPOUT) gain control did nothing.
I now suspect that RockChip's POE/audio hat includes an external headphone amp driven by the DAC LINE out.
So, the only real showstopper for the mainline acodec is that its handling of the "DAC HPMI" control.

I now also got a RockPi-S here (and the Core SoM too), and what I noticed is that the pinout provides only two pins for the DAC Line out. Looking at the RockPi-S pinout, Headphones pins does not exist on the bare RockPi-S, so the Headphones you get on the HAT are probably derived from the Line out. I don't know, though, if it is possible to switch the Line Out pins to Headphone and viceversa via software, but I guess that would be quite dangerous.

@paolosabatino paolosabatino deleted the rk3308-revert-acodec branch December 23, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
02 Milestone: First quarter release Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/large PR with 250 lines or more
Development

Successfully merging this pull request may close these issues.

5 participants