nanopi-zero2: add USB support for RK3528 (current + edge)#9500
nanopi-zero2: add USB support for RK3528 (current + edge)#9500rubycomm wants to merge 5 commits intoarmbian:mainfrom
Conversation
Enable mainline kernel (current/edge) for the NanoPi Zero2 (RK3528): - Add current,edge to KERNEL_TARGET - Override BOOT_FDT_FILE to rk3528-nanopi-zero2.dtb for mainline branches (vendor kernel uses rk3528-nanopi-rev01.dtb) - Set SERIALCON=ttyS0 and patch boot script for mainline, as RK3528 debug UART is UART0 (ttyS0), not UART2 (ttyS2) like other RK35xx SoCs Tested on hardware with kernel 6.18 (current branch).
Enable the PCIe Gen2x1 controller and combo PHY on the NanoPi Zero2 for the M.2 Key-E 2230 WiFi slot. Signed-off-by: Shlomi Marco <s.marco@rubycomm.com>
These 3 patches are now included in mainline kernels 6.18 and 6.19, causing "Reversed (or previously applied)" failures during patch application: - media-0004: AV1 Fix enable cdef computation - media-0005: AV1 Set IDR flag for intra_only frames - media-0006: AV1 Fix tx mode bit setting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add three kernel patches for USB support on the RK3528 SoC: - phy-rockchip-inno-usb2: Add RK3528 USB2 PHY driver support - rk3528.dtsi: Add xHCI, EHCI, OHCI and USB2 PHY device tree nodes - nanopi-zero2: Enable USB host and OTG ports Tested on hardware: USB storage, PCIe (AX210 WiFi) all working.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds NanoPi Zero2 board support and RK3528 platform updates: expands KERNEL_TARGET, conditions device-tree DTB and serial console for branches, enables PCIe and USB in board DT, adds RK3528 USB2 PHY driver support, and applies several Verisilicon AV1 decoder patches (CDEF enable logic, IDR flag change, TX-mode mapping/removal across kernel versions). Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
config/boards/nanopi-zero2.csc (1)
29-35: Make the boot.cmd rewrite fail fast.
sed -isucceeds even when the expectedconsole=ttyS2,1500000token disappears fromboot.cmd. On a headless board that silently ships current/edge images with the wrong serial console.Suggested hardening
function post_family_tweaks__nanopi_zero2_serial_console() { case "${BRANCH}" in current|edge) display_alert "$BOARD" "Adjusting boot.cmd serial console to ttyS0 for ${BRANCH}" "info" + if ! grep -q 'console=ttyS2,1500000' "${SDCARD}"/boot/boot.cmd; then + display_alert "$BOARD" "boot.cmd no longer contains the ttyS2 console stanza" "err" + return 1 + fi sed -i 's/console=ttyS2,1500000/console=ttyS0,1500000/g' "${SDCARD}"/boot/boot.cmd mkimage -C none -A arm -T script -d "${SDCARD}"/boot/boot.cmd "${SDCARD}"/boot/boot.scr ;; esac }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@config/boards/nanopi-zero2.csc` around lines 29 - 35, The sed replacement in post_family_tweaks__nanopi_zero2_serial_console currently runs silently even when no token is changed; modify the function to verify the presence of the expected token before/after editing (e.g., grep for "console=ttyS2,1500000" or check that the resulting file contains "console=ttyS0,1500000"), and if the replacement did not occur call display_alert "$BOARD" with an error and exit non-zero so the mkimage step is not run; ensure the logic surrounds the sed invocation and mkimage so failure fails fast and is clearly logged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@patch/kernel/archive/rockchip64-6.18/rk3528-10-phy-rockchip-inno-usb2-Add-support-for-RK3528.patch`:
- Around line 182-202: The rk3528_usb2phy_tuning function incorrectly
accumulates regmap_write() return values with bitwise OR; change each call to
check its return and propagate errors immediately: for each
regmap_write(rphy->phy_base, ... ) assign ret = regmap_write(...); if (ret)
return ret; (do this for the writes to offsets 0x30, 0x430, 0x30, 0x430, and
0x94) so the function returns the actual negative errno from the failing
regmap_write instead of a corrupted value.
In
`@patch/kernel/archive/rockchip64-6.18/rk3528-11-arm64-dts-rockchip-rk3528-Add-USB-controller-and-PHY-nodes.patch`:
- Around line 31-52: The DWC3 USB node (usb_host0_xhci / usb@fe500000) and
associated PHY need RK3528 power-domain links so runtime PM/genpd works; add
appropriate power-domains properties: assign the DWC3 controller node
(usb_host0_xhci / usb@fe500000) to the VPU power-domain (the upstream patch uses
RK3528_PD_VPU, typically referenced as &pd_vpu) and ensure EHCI/OHCI and the
u2phy_otg PHY nodes are bound to the VO power-domain (RK3528_PD_VO, typically
&pd_vo); update the usb_host0_xhci node and the u2phy_otg / EHCI/OHCI nodes to
include these power-domains phandles so the blocks participate in
genpd/runtime-PM.
In
`@patch/kernel/archive/rockchip64-6.19/rk3528-11-arm64-dts-rockchip-rk3528-Add-USB-controller-and-PHY-nodes.patch`:
- Around line 31-52: The USB DWC3 node usb_host0_xhci (usb@fe500000) is missing
power-domain links; add a power-domains property referencing the appropriate
RK3528 genpd identifiers so DWC3 is in RK3528_PD_VPU and the companion
EHCI/OHCI/u2phy nodes (e.g., the &u2phy node) are in RK3528_PD_VO as per
upstream; update the usb_host0_xhci node to include the correct phandles/names
for RK3528_PD_VPU and ensure the u2phy/EHCI/OHCI nodes include RK3528_PD_VO in
their power-domains to enable runtime PM/genpd handling.
---
Nitpick comments:
In `@config/boards/nanopi-zero2.csc`:
- Around line 29-35: The sed replacement in
post_family_tweaks__nanopi_zero2_serial_console currently runs silently even
when no token is changed; modify the function to verify the presence of the
expected token before/after editing (e.g., grep for "console=ttyS2,1500000" or
check that the resulting file contains "console=ttyS0,1500000"), and if the
replacement did not occur call display_alert "$BOARD" with an error and exit
non-zero so the mkimage step is not run; ensure the logic surrounds the sed
invocation and mkimage so failure fails fast and is clearly logged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fa4b2774-2ec9-48cf-a1c4-b3b1a360c0d9
📒 Files selected for processing (15)
config/boards/nanopi-zero2.cscpatch/kernel/archive/rockchip64-6.18/board-nanopi-zero2-enable-pcie.patchpatch/kernel/archive/rockchip64-6.18/media-0004-media-verisilicon-AV1-Fix-enable-cdef-computation.patchpatch/kernel/archive/rockchip64-6.18/media-0005-media-verisilicon-AV1-Set-IDR-flag-for-intra_only-fr.patchpatch/kernel/archive/rockchip64-6.18/media-0006-media-verisilicon-AV1-Fix-tx-mode-bit-setting.patchpatch/kernel/archive/rockchip64-6.18/rk3528-10-phy-rockchip-inno-usb2-Add-support-for-RK3528.patchpatch/kernel/archive/rockchip64-6.18/rk3528-11-arm64-dts-rockchip-rk3528-Add-USB-controller-and-PHY-nodes.patchpatch/kernel/archive/rockchip64-6.18/rk3528-12-arm64-dts-rockchip-nanopi-zero2-Enable-USB.patchpatch/kernel/archive/rockchip64-6.19/board-nanopi-zero2-enable-pcie.patchpatch/kernel/archive/rockchip64-6.19/media-0004-media-verisilicon-AV1-Fix-enable-cdef-computation.patchpatch/kernel/archive/rockchip64-6.19/media-0005-media-verisilicon-AV1-Set-IDR-flag-for-intra_only-fr.patchpatch/kernel/archive/rockchip64-6.19/media-0006-media-verisilicon-AV1-Fix-tx-mode-bit-setting.patchpatch/kernel/archive/rockchip64-6.19/rk3528-10-phy-rockchip-inno-usb2-Add-support-for-RK3528.patchpatch/kernel/archive/rockchip64-6.19/rk3528-11-arm64-dts-rockchip-rk3528-Add-USB-controller-and-PHY-nodes.patchpatch/kernel/archive/rockchip64-6.19/rk3528-12-arm64-dts-rockchip-nanopi-zero2-Enable-USB.patch
💤 Files with no reviewable changes (6)
- patch/kernel/archive/rockchip64-6.19/media-0005-media-verisilicon-AV1-Set-IDR-flag-for-intra_only-fr.patch
- patch/kernel/archive/rockchip64-6.18/media-0005-media-verisilicon-AV1-Set-IDR-flag-for-intra_only-fr.patch
- patch/kernel/archive/rockchip64-6.18/media-0004-media-verisilicon-AV1-Fix-enable-cdef-computation.patch
- patch/kernel/archive/rockchip64-6.19/media-0004-media-verisilicon-AV1-Fix-enable-cdef-computation.patch
- patch/kernel/archive/rockchip64-6.18/media-0006-media-verisilicon-AV1-Fix-tx-mode-bit-setting.patch
- patch/kernel/archive/rockchip64-6.19/media-0006-media-verisilicon-AV1-Fix-tx-mode-bit-setting.patch
...kernel/archive/rockchip64-6.18/rk3528-10-phy-rockchip-inno-usb2-Add-support-for-RK3528.patch
Show resolved
Hide resolved
...e/rockchip64-6.18/rk3528-11-arm64-dts-rockchip-rk3528-Add-USB-controller-and-PHY-nodes.patch
Show resolved
Hide resolved
...e/rockchip64-6.19/rk3528-11-arm64-dts-rockchip-rk3528-Add-USB-controller-and-PHY-nodes.patch
Show resolved
Hide resolved
- Fix error handling in USB2 PHY tuning: use individual return checks instead of ret |= pattern (thanks @coderabbitai) - Remove power-domains properties from USB DTS nodes: causes kernel panic (synchronous external abort in rockchip_pmu_set_idle_request) as RK3528 PMU idle request registers are not ready for these domains - Fix patch hunk headers to match updated line counts Tested on hardware: both current (6.18) and edge (6.19) boot successfully with working USB.
|
Note on edge (6.19) kernel support: The USB patches work correctly on both current (6.18) and edge (6.19), this was verified on hardware. Edge remains in KERNEL_TARGET since the patches themselves are correct and removing it would hide the real problem. |
|
Nice @rubycomm , I've tried in the past to pick from Kwiboo ref USB on the E24C, but failed to boot with a panic when I enabled the combphy, something ref the VPU regulator not being really on before it does. Have you encountered or handled something similar? I could try it your take on the E24C if you say it is worth a shot. Also, upstream? Jonas seems busy with other stuff and I don't wanna pester him... |
|
@rpardini Per-board copy-paste isn't ideal. We only have the NanoPi Zero2 (along with a bunch of other non-3528 nanopis) to test with, so I'm not sure which approach would be best for rockchip64_common without risking other boards. Regarding USB: It should definitely be worth trying on the E24C, the PHY driver and SoC-level DTS nodes are shared across all rk3528 boards. You'd just need a board-level patch to enable the USB nodes, similar to our rk3528-12 patch for the Zero2. |
|
Hello, I've made some early work for mainlining rk3528 you can find here. the tvbox I was working on was booting fine and (AFAIR) USB2/USB3 were working pretty well. I used the Jonas patches from patchwork and configured the node in the device tree accordingly. |
|
Nice, thanks for the info. I've cycled my E24C out of it's production-like role, and will pick and rebase this on 7.0-rcX as soon as I have time and test it there. |
A question: does HDMI works on mainline kernel for rk3528? I could not be able to let it work on my tv box, but reading here and there it looks like the HDMI phy driver was surely missing at the time (not to mention the power domains issues...) |
Summary
Add USB support for the FriendlyElec NanoPi Zero2 (RK3528) on mainline kernels (6.18 / 6.19):
phy-rockchip-inno-usb2: standalone PHY at0xffdf0000with separatephy_baseregmap andclkout_ctl_phyfor 480MHz clock controlrk3528.dtsiBased on Jonas Karlman's (Kwiboo) WIP RK3528 USB work.
Tested on hardware
Note on Intel AX210 WiFi firmware
The Armbian firmware package currently ships
iwlwifi-ty-a0-gf-a0-59.ucode(v59), but kernel 6.18'siwlwifidriver requires v89 (iwlwifi-ty-a0-gf-a0-89.ucode). Without the correct firmware, the AX210 will be detected on PCIe but fail to initialize withno suitable firmware found!.Workaround: manually copy
iwlwifi-ty-a0-gf-a0-89.ucodeandiwlwifi-ty-a0-gf-a0.pnvmfrom linux-firmware to/lib/firmware/and reload withmodprobe -r iwlwifi && modprobe iwlwifi.This is not specific to this PR: it affects any board using AX210 with kernel 6.18+.
Summary by CodeRabbit
New Features
Changes
Bug Fixes