Skip to content

Add board: Anbernic RG Vita Pro (RK3576 gaming handheld)#10128

Open
crackerjacques wants to merge 5 commits into
armbian:mainfrom
crackerjacques:board-anbernic-rg-vita-pro
Open

Add board: Anbernic RG Vita Pro (RK3576 gaming handheld)#10128
crackerjacques wants to merge 5 commits into
armbian:mainfrom
crackerjacques:board-anbernic-rg-vita-pro

Conversation

@crackerjacques

@crackerjacques crackerjacques commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What is this

The Anbernic RG Vita Pro is a gaming handheld built around the Rockchip
RK3576 (4x Cortex-A72 + 4x Cortex-A53, Mali-G52 MC3):

  • 5.5" 1080x1920 portrait-mounted TDDI touch LCD (MIPI-DSI, Synaptics touch
    in the same IC as the display driver)
  • SPI-MCU gamepad (two analog sticks, RGB LEDs) plus GPIO/ADC buttons
  • es8388 codec with aw87391 speaker amplifiers and a headphone jack
  • RTL8852BE WiFi/BT (PCIe/UART), eMMC + microSD
  • USB-C: USB3 Gen1 dual-role, DisplayPort alt-mode, PD charging (HUSB311
    TCPC, SGM41542 charger, CW2217 fuel gauge)
  • Mini HDMI output

The case is glued shut, so there is no accessible UART; bring-up was done
over WiFi/ssh. Everything below is verified on real hardware, running both
console images and GNOME/KDE Wayland desktops.

What works

Subsystem Status
Boot (SD and eMMC), mainline U-Boot v2026.04 works
Display (DSI panel + fbcon + Wayland/X11) works
Touchscreen works
Analog sticks, all buttons works
Audio: speakers, headphone jack (auto-switch) works
WiFi / Bluetooth works
Battery gauge + charger works
USB-C: host (USB3), gadget, PD charging works
HDMI output works
USB-C DisplayPort alt-mode video works
GPU (panfrost) works

Boot specifics

  • generic-rk3576_defconfig mainline U-Boot; the family boot_merger injects
    the rk3576 SD boost blob (same pattern as nanopi-r76s).
  • DDR blob pinned to v1.09: the family default v1.08 does not initialize this
    board's RAM (the vendor image ships v1.09).
  • SD is first in the boot order so a flashed card takes precedence over the
    vendor OS in eMMC.

Kernel patches (rockchip64/edge)

Generic RK3576 fixes, affecting all boards of this SoC (I intend to send
these upstream):

  • board-anbernic-rg-vita-vop2-rk3576-gamma-writemask.patch — on RK3576 the
    VOP2 LUT_PORT_SEL register is write-masked (unlike RK3588); mainline's
    plain write is silently ignored, so the gamma LUT lands in VP0's table
    while another VP enables its never-initialized LUT. Any userspace that
    programs legacy gamma (Xorg does at startup) gets wildly corrupted colors.
  • board-anbernic-rg-vita-vop2-rk3576-vp2-primary-plane.patch — VP2 (the DP
    video port) has no primary plane, so enabling DP fails the whole VOP2 bind.
    Promotes Esmart0 to primary (from ROCKNIX, reduced to match mainline's
    DUAL-pixel DP configuration).
  • board-anbernic-rg-vita-dp-usbdp-hpd-replay.patch — replay HPD state on DP
    PHY init so DP alt-mode displays connected at boot are detected (based on
    ROCKNIX).

Device enablement, ported from the ROCKNIX project (thanks to the ROCKNIX
developers and Chris Morgan for the excellent groundwork; HUSB311 based on a
patch by Alexey Charkov):

  • board-anbernic-rg-vita-panel-generic-dsi.patchrocknix,generic-dsi
    panel driver (timings/init sequence from DT)
  • board-anbernic-rg-vita-joypad-1x-*.patch (4) — SPI-MCU gamepad driver
  • board-anbernic-rg-vita-pwm-01-mfpwm.patch, -02-pwmv4.patch — RK3576
    PWM (backlight)
  • board-anbernic-rg-vita-touch-rmi4-reset-gpio.patch — the LCD is a TDDI
    module; rmi4's chip-wide soft reset at probe kills the display half. With
    a dedicated reset GPIO in DT the driver hard-resets only the touch block.
  • board-anbernic-rg-vita-battery-01-cw221x.patch, -02-sgm41542.patch
    fuel gauge and charger drivers
  • board-anbernic-rg-vita-typec-husb311.patch — HUSB311 IDs for the rt1711h
    TCPC driver (register-compatible, mainline no longer checks VID/PID)

Board DTS (dt/rk3576-anbernic-rg-vita-pro.dts) comes from ROCKNIX, adapted
to the current kernel.

Kernel config additions: JOYSTICK_SPI_MCU_JOYPAD, LEDS_CLASS_MULTICOLOR,
DRM_PANEL_GENERIC_DSI, MFD_ROCKCHIP_MFPWM, PWM_ROCKCHIP_V4,
BATTERY_CW221X, CHARGER_SGM41542.

BSP helpers (config/optional, board bsp package)

  • vita-jack-switch — mutes the internal speakers while headphones are
    plugged (jack detection via the panel's input device)
  • vita-pad2key + toggle — gamepad-to-keyboard remap for desktop navigation
    (D-pad = arrows, A = Enter, B = Esc, ...), toggleable per the RG DS pattern
  • vita-screen — X11-only default rotation + touch mapping (Wayland handles
    the portrait panel natively via the DRM panel-orientation property)
  • SDDM is configured to use its Wayland greeter (the X11 greeter cannot
    rotate); GDM works as-is, lightdm (X11-only) is not usable on this panel
  • udev rule reclassifying the ABS-only stick device from "accelerometer" to
    joystick (stops desktops from auto-rotating the screen on stick movement)
  • Default ALSA state with speakers and headphone jack enabled
  • vita-offcharge — Android-style off-charge mode: the RK806 powers the
    device on whenever a charger is plugged (hardware behavior), so a plug-in
    boot (detected via the PMIC's ON_SOURCE register) shows a battery screen
    instead of booting to the desktop; unplugging powers back off, pressing
    the power button continues the normal boot

Known limitations

  • The RK806 PMIC treats charger plug-in as a power-on event (hardware
    behavior), so the device cannot stay off while a powered USB-C device is
    attached; the vita-offcharge helper turns this into an Android-style
    charging screen that powers back off on unplug.
  • There is intentionally no USB-gadget serial console: a getty holding
    /dev/ttyGS0 open blocks dwc3's device->host role switch (worker deadlocks
    in dwc3_gadget_exit), which would break USB host hotplug. I plan to report
    this u_serial/dwc3 behavior upstream.
  • Minimal images: if you install a desktop manually on Ubuntu, note that
    Ubuntu's wireplumber needs snapd present to expose audio devices (not
    board-specific).

The board page image is submitted as armbian/armbian.github.io#351.

Summary by CodeRabbit

  • New Features
    • Added full Anbernic RG Vita Pro support, including board-specific boot configuration, display (generic DSI), audio/codec state, and hardware DT enablement.
    • Added new joystick, multicolor LED, battery (CW221X), charger (SGM41542), PWMv4, touch reset handling, and input reclassification.
    • Added system services and launchers for pad-to-key remapping, jack-based audio routing, screen rotation, and off-charge/charging behavior.
  • Bug Fixes
    • Improved DP link HPD event handling and corrected VOP2 seamless gamma programming for RK3576.

crackerjacques added 4 commits July 5, 2026 17:20
Three SoC-generic RK3576 display fixes (affect all rk3576 boards, intended
for upstream):

- vop2 gamma LUT port select is write-masked on rk3576 (unlike rk3588);
  mainline's plain write is dropped, corrupting colors in any userspace
  that programs legacy gamma (e.g. Xorg at startup).
- vop2 VP2 (the DP video port) has no primary plane, so enabling DP fails
  the whole VOP2 bind; promote Esmart0 to primary (reduced from ROCKNIX to
  match mainline's DUAL-pixel DP configuration).
- usbdp phy: replay saved HPD state on DP PHY init so DP alt-mode displays
  connected at boot are detected (based on ROCKNIX).

Signed-off-by: crackerjacques <jack@supremeoverlordjabs.co>
Kernel drivers needed by the RG Vita Pro (RK3576), ported from the ROCKNIX
project (thanks to the ROCKNIX developers and Chris Morgan; HUSB311 based
on a patch by Alexey Charkov, generic-dsi panel by Danil Zagoskin):

- drm/panel: rocknix,generic-dsi panel driver (timings/init from DT)
- input/joystick: spi-mcu-joypad (analog sticks + RGB LED rings)
- mfd/pwm: rockchip mfpwm + PWMv4 (RK3576 backlight PWM)
- Input/rmi4: hard-reset via reset GPIO instead of the chip-wide SW reset
  (the LCD is a TDDI module; the SW reset kills the display half)
- power/supply: CW221x fuel gauge + SGM41542 charger
- usb/typec: HUSB311 IDs for the register-compatible rt1711h TCPC driver

Signed-off-by: crackerjacques <jack@supremeoverlordjabs.co>
Add the board config, device tree and kernel config options for the
Anbernic RG Vita Pro, an RK3576 gaming handheld (5.5" 1080x1920 portrait
TDDI touch LCD, SPI-MCU gamepad, es8388 + aw87391 audio, RTL8852BE,
USB-C USB3/DP-altmode/PD, mini HDMI).

- generic-rk3576 mainline U-Boot; the family boot_merger injects the
  rk3576 SD boost blob (nanopi-r76s pattern)
- DDR blob pinned to v1.09 (family default v1.08 does not init this RAM)
- SD first in the boot order
- kernel config: JOYSTICK_SPI_MCU_JOYPAD, LEDS_CLASS_MULTICOLOR,
  DRM_PANEL_GENERIC_DSI, MFD_ROCKCHIP_MFPWM, PWM_ROCKCHIP_V4,
  BATTERY_CW221X, CHARGER_SGM41542

Device tree adapted from ROCKNIX.

Signed-off-by: crackerjacques <jack@supremeoverlordjabs.co>
Board bsp package and default ALSA state:

- vita-jack-switch: mute internal speakers while headphones are plugged
- vita-pad2key + toggle: gamepad-to-keyboard remap for desktop navigation
- vita-screen: X11-only rotation + touch mapping (Wayland uses the DRM
  panel-orientation property natively)
- vita-offcharge: Android-style off-charge screen (the RK806 powers on when
  a charger is plugged, a hardware behavior; a plug-in boot shows a battery
  screen that powers off on unplug and continues to boot on power press)
- SDDM configured for its Wayland greeter; udev rule reclassifying the
  ABS-only stick device from accelerometer to joystick
- default asound.state with speakers and headphone jack enabled

Signed-off-by: crackerjacques <jack@supremeoverlordjabs.co>
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3906ccdb-9a7f-4b5e-a781-7f2b5763aae6

📥 Commits

Reviewing files that changed from the base of the PR and between be1dbad and 80c3282.

📒 Files selected for processing (2)
  • config/boards/anbernic-rg-vita-pro.csc
  • config/kernel/linux-rockchip64-edge.config
🚧 Files skipped from review as they are similar to previous changes (2)
  • config/kernel/linux-rockchip64-edge.config
  • config/boards/anbernic-rg-vita-pro.csc

📝 Walkthrough

Walkthrough

This PR adds complete board support for the Anbernic RG Vita Pro (RK3576): board configuration, kernel enablement, userspace power/audio/input/display helpers, an ALSA state blob, new kernel drivers, supporting kernel patches, and the board device tree.

Changes

Anbernic RG Vita Pro board bring-up

Layer / File(s) Summary
Board config script and kernel config flags
config/boards/anbernic-rg-vita-pro.csc, config/kernel/linux-rockchip64-edge.config
Adds board metadata, U-Boot helpers, systemd tweak/boot-order functions, and enables kernel options for the new joypad, battery, charger, MFD, panel, LED, and PWM drivers.
Off-charge power screen subsystem
config/optional/.../etc/default/vita-offcharge, .../etc/systemd/system/vita-offcharge*.service, .../usr/bin/vita-offcharge
Adds config defaults, systemd units, and a Python script that reads the RK806 PMIC power-on source, renders a charging screen, and handles power-key long/short press behavior.
Jack-switch, pad2key, and screen rotation helpers
.../vita-jack-switch*, .../vita-pad2key*, .../vita-screen*, polkit/udev/desktop/sddm configs
Adds services and scripts for headphone jack audio switching, gamepad-to-keyboard remapping with toggle notification, DSI screen rotation/touch mapping, plus supporting polkit rule, udev classification, autostart entry, and Wayland SDDM config.
ALSA default mixer state
packages/blobs/asound.state/asound.state.anbernic-rg-vita-pro
Adds default HDMI and rockchipes8388c codec mixer control state.
CW221x battery fuel gauge driver
patch/.../board-anbernic-rg-vita-battery-01-cw221x.patch
Adds a new I2C power-supply driver reporting SOC, voltage, current, temperature, cycle count, and SOH with profile programming.
SGM41542 charger driver
patch/.../board-anbernic-rg-vita-battery-02-sgm41542.patch
Adds a new I2C charger driver with power_supply integration, IRQ handling, OTG VBUS regulator, and watchdog management.
SPI MCU joypad driver
patch/.../board-anbernic-rg-vita-joypad-1{0,1,2,3}-*.patch
Adds SPI transport/protocol core, calibrated axis input reporting, and multicolor LED ring control for the MCU-based joypad.
Generic DSI panel driver
patch/.../board-anbernic-rg-vita-panel-generic-dsi.patch
Adds a DRM MIPI-DSI panel driver that loads timings and init sequences from DT or firmware description.
Rockchip MFPWM/PWMv4 drivers
patch/.../board-anbernic-rg-vita-pwm-01-mfpwm.patch, ...-pwm-02-pwmv4.patch
Adds an MFD core exposing acquire/release ownership and a PWMv4 pwm_chip driver built on it.
Supporting kernel patches
patch/.../board-anbernic-rg-vita-dp-usbdp-hpd-replay.patch, ...-touch-rmi4-reset-gpio.patch, ...-typec-husb311.patch, ...-vop2-rk3576-gamma-writemask.patch, ...-vop2-rk3576-vp2-primary-plane.patch
Adds DP HPD replay, touch reset-GPIO handling, HUSB311 TCPM matching, and VOP2 gamma/primary-plane fixes.
Board device tree
patch/.../dt/rk3576-anbernic-rg-vita-pro.dts
Adds the full device tree wiring for display, PMIC/regulators, audio, charger/battery, USB-C, PCIe, storage, and pinctrl for the board.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant systemd
  participant vita-offcharge
  participant RK806PMIC as RK806 PMIC
  participant tty1 as /dev/tty1

  systemd->>vita-offcharge: start before display-manager
  vita-offcharge->>RK806PMIC: read ON_SOURCE via I2C
  RK806PMIC-->>vita-offcharge: on_source value
  alt power-button boot
    vita-offcharge-->>systemd: exit 0 (continue normal boot)
  else plug-in boot
    vita-offcharge->>tty1: draw battery/charging screen
    vita-offcharge->>vita-offcharge: monitor POWER key
    vita-offcharge-->>systemd: exit 0 on long-press or poweroff on charger removal
  end
Loading
sequenceDiagram
  participant PWMv4 as pwm-rockchip-v4
  participant MFPWM as rockchip-mfpwm

  PWMv4->>MFPWM: mfpwm_acquire(pwmf)
  MFPWM-->>PWMv4: ownership granted or busy
  PWMv4->>MFPWM: write enable/period/duty/offset registers
  PWMv4->>MFPWM: mfpwm_release(pwmf)
Loading

Possibly related PRs

  • armbian/build#9535: Introduces related RK3576 board support using the same mainline U-Boot approach and shared Rockchip PWM/MFPWM kernel options.

Suggested labels: Ready to merge, 08, Needs review, size/large, Hardware, Patches, BSP

Suggested reviewers: ColorfulRhino, HeyMeco, JohnTheCoolingFan, SuperKali, TheSnowfield, ahoneybun, amazingfate, brentr, catalinii, chainsx, efectn, iav, igorpecovnik, joekhoobyar, krachlatte, lanefu, paolosabatino, prahal, pyavitz, rpardini, schwar3kat

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding board support for the Anbernic RG Vita Pro.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size/large PR with 250 lines or more 08 Milestone: Third quarter release Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... BSP Board Support Packages labels Jul 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (2)
config/kernel/linux-rockchip64-edge.config (1)

1151-1151: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Consider board-scoping the Vita-Pro-only driver options.

These new symbols (CONFIG_JOYSTICK_SPI_MCU_JOYPAD, CONFIG_BATTERY_CW221X, CONFIG_CHARGER_SGM41542, CONFIG_MFD_ROCKCHIP_MFPWM, CONFIG_DRM_PANEL_GENERIC_DSI, CONFIG_PWM_ROCKCHIP_V4) are specific to the RG Vita Pro but are being enabled in the shared rockchip64-edge family config, so every rockchip64-edge board inherits them. The =y ones in particular add unconditional bloat to all those kernels. Consider moving them into a board-scoped custom_kernel_config__anbernic_rg_vita_pro() in the .csc unless the family intends to share these drivers across boards.

Based on learnings: keep kernel config options that are truly board-specific at board scope; only promote to family scope if all boards in that family use the same driver.

Also applies to: 1434-1434, 1455-1455, 1679-1679, 2019-2019, 3081-3081

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/kernel/linux-rockchip64-edge.config` at line 1151, Move the
Vita-Pro-only kernel symbols out of the shared rockchip64-edge family config and
into the board-specific custom_kernel_config__anbernic_rg_vita_pro() in the
.csc; CONFIG_JOYSTICK_SPI_MCU_JOYPAD, CONFIG_BATTERY_CW221X,
CONFIG_CHARGER_SGM41542, CONFIG_MFD_ROCKCHIP_MFPWM,
CONFIG_DRM_PANEL_GENERIC_DSI, and CONFIG_PWM_ROCKCHIP_V4 should not be enabled
globally for every rockchip64-edge board. Keep only genuinely shared drivers in
the family config and scope the rest to the RG Vita Pro board config.

Source: Learnings

patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts (1)

286-297: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

pwm2_8ch_7 is enabled but has no consumer, and mixes spaces with tabs.

Only pwm1_6ch_3 is referenced (by backlight); pwm2_8ch_7 is set status = "okay" with no phandle consumer in this DTS. Confirm it's actually needed (e.g. rumble/second backlight) — otherwise it needlessly claims the pwm2m2_ch7 pins. The node body also uses 4-space indentation unlike the rest of the file.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts`
around lines 286 - 297, The pwm2_8ch_7 node is enabled without any consumer in
this DTS, so either remove or disable it unless it is intentionally needed for a
feature like rumble or another backlight; check the pwm2_8ch_7 definition and
only keep status = "okay" if a real phandle consumer exists. Also normalize the
indentation in that node to match the rest of the file by using consistent
tabs/spaces, especially around the clocks and clock-names properties.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-offcharge`:
- Around line 8-10: The header comment in vita-offcharge still shows the old
PWRON_MASK example, so update the documented default to match the shipped
/etc/default/vita-offcharge value used by vita-offcharge. Make the comment
consistent with the actual power-button mask seen in the config and keep the
guidance aligned with the existing DISABLE setting so future edits don’t copy
the stale value.
- Around line 209-210: The `vita-offcharge` config parsing for `SCREEN_TIMEOUT`
and `BOOT_HOLD` can crash on malformed values because the `float(...)`
conversions are unchecked. Update the parsing logic around these settings to
safely handle invalid input in the script’s config-loading path, using the
existing `conf.get(...)` values but falling back to the defaults when conversion
fails. Keep the fix localized to the config read section so the charge-screen
flow continues even if `/etc/default/vita-offcharge` contains non-numeric
values.

In
`@config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-pad2key-toggle`:
- Around line 7-11: The vita-pad2key-toggle script has a silent failure path if
systemctl stop/start vita-pad2key fails, leaving msg unset and the user with no
useful output. Update the toggle logic around the systemctl calls so each branch
handles failure explicitly, setting a fallback error message when the command
does not succeed and preserving the existing success messages otherwise. Make
sure the terminal echo/notification path always has a message to display, using
the script’s msg variable and the systemctl-based state switch.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-01-cw221x.patch`:
- Around line 600-612: The battery-profile handling in the cw221x probe path
should return immediately when device_property_count_u8() reports that
"cellwise,battery-profile" is missing, because the current flow still reaches
devm_kzalloc() with a negative length and fails instead of using the
flash-contents fallback. Update the logic around the cw_bat->bat_profile
allocation so the missing-profile branch exits early after the dev_warn, while
keeping the SIZE_OF_PROFILE validation for the present-profile case.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-02-sgm41542.patch`:
- Around line 1382-1384: alloc_ordered_workqueue() can return NULL here, which
leaves sgm->sgm_monitor_wq invalid for later queue_delayed_work() and
destroy_workqueue() usage. Update the initialization path around sgm_monitor_wq
in the sgm charger setup to check the return value immediately after
alloc_ordered_workqueue(), and if it fails, jump to error_out and return
-ENOMEM; keep INIT_DELAYED_WORK only on the success path.
- Around line 1369-1380: The OTG initialization failure paths currently return
directly after register_pm_notifier(), which skips cleanup and leaves the
notifier registered on probe failure. Update the error handling in the SGM4154x
probe/init flow around the sgm4154x_set_otg_voltage and sgm4154x_set_otg_current
calls to jump to error_out instead of returning immediately, so the existing
cleanup path can unregister the PM notifier.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch`:
- Around line 199-200: The allocations in load_mode and load_init_seq are used
immediately without checking for failure, so add NULL handling right after
devm_kzalloc for both mode and item before any dereference or get_option usage.
Update the load_mode and load_init_seq paths to fail gracefully if devm_kzalloc
returns NULL, using the existing symbols load_mode, load_init_seq, mode, and
item to keep the panel probe from faulting on allocation failure.
- Around line 573-578: The failure path after drm_mode_duplicate() in the mode
setup logic is using drm_mode_vrefresh(mode) even when mode is NULL, which can
crash while logging the error. Update the error handling in this branch to avoid
dereferencing mode on failure, and log using the available fallback data from
mode_tmp or a generic message in the same code path where drm_mode_duplicate()
is checked.

In `@patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts`:
- Line 125: The simple-battery property factory-internal-resistance-micro-ohms
in rk3576-anbernic-rg-vita-pro.dts appears to be missing zeros and is
inconsistent with the other battery definitions in this tree. Verify the correct
internal resistance from the battery datasheet, then update the value in the
battery node so it matches the intended micro-ohms scale.

---

Nitpick comments:
In `@config/kernel/linux-rockchip64-edge.config`:
- Line 1151: Move the Vita-Pro-only kernel symbols out of the shared
rockchip64-edge family config and into the board-specific
custom_kernel_config__anbernic_rg_vita_pro() in the .csc;
CONFIG_JOYSTICK_SPI_MCU_JOYPAD, CONFIG_BATTERY_CW221X, CONFIG_CHARGER_SGM41542,
CONFIG_MFD_ROCKCHIP_MFPWM, CONFIG_DRM_PANEL_GENERIC_DSI, and
CONFIG_PWM_ROCKCHIP_V4 should not be enabled globally for every rockchip64-edge
board. Keep only genuinely shared drivers in the family config and scope the
rest to the RG Vita Pro board config.

In `@patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts`:
- Around line 286-297: The pwm2_8ch_7 node is enabled without any consumer in
this DTS, so either remove or disable it unless it is intentionally needed for a
feature like rumble or another backlight; check the pwm2_8ch_7 definition and
only keep status = "okay" if a real phandle consumer exists. Also normalize the
indentation in that node to match the rest of the file by using consistent
tabs/spaces, especially around the clocks and clock-names properties.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dc7ab04e-dd98-4d74-937b-88374dae7706

📥 Commits

Reviewing files that changed from the base of the PR and between e1f2e37 and be1dbad.

📒 Files selected for processing (33)
  • config/boards/anbernic-rg-vita-pro.csc
  • config/kernel/linux-rockchip64-edge.config
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/default/vita-offcharge
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/polkit-1/rules.d/49-vita-pad2key.rules
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/sddm.conf.d/10-vita-wayland.conf
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/systemd/system/vita-jack-switch.service
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/systemd/system/vita-offcharge-reboot-marker.service
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/systemd/system/vita-offcharge.service
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/systemd/system/vita-pad2key.service
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/udev/rules.d/60-vita-joypad-not-accel.rules
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/etc/xdg/autostart/vita-screen.desktop
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-jack-switch
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-offcharge
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-pad2key
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-pad2key-toggle
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-screen
  • config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/share/applications/vita-pad2key-toggle.desktop
  • packages/blobs/asound.state/asound.state.anbernic-rg-vita-pro
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-01-cw221x.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-02-sgm41542.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-dp-usbdp-hpd-replay.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-joypad-10-options.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-joypad-11-core.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-joypad-12-input.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-joypad-13-leds.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-pwm-01-mfpwm.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-pwm-02-pwmv4.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-touch-rmi4-reset-gpio.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-typec-husb311.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-vop2-rk3576-gamma-writemask.patch
  • patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-vop2-rk3576-vp2-primary-plane.patch
  • patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts

Comment on lines +8 to +10
# Config in /etc/default/vita-offcharge:
# PWRON_MASK=0x01 bit(s) set in ON_SOURCE when the power button caused boot
# DISABLE=1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Stale example value in header comment.

Header documents PWRON_MASK=0x01, but the shipped /etc/default/vita-offcharge sets PWRON_MASK=0x80 (matching the measured-on-hardware comment there: 0x80 = power button). A future edit based on this stale docstring could reintroduce a broken mask.

📝 Proposed fix
-#   PWRON_MASK=0x01   bit(s) set in ON_SOURCE when the power button caused boot
+#   PWRON_MASK=0x80   bit(s) set in ON_SOURCE when the power button caused boot
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Config in /etc/default/vita-offcharge:
# PWRON_MASK=0x01 bit(s) set in ON_SOURCE when the power button caused boot
# DISABLE=1
# Config in /etc/default/vita-offcharge:
# PWRON_MASK=0x80 bit(s) set in ON_SOURCE when the power button caused boot
# DISABLE=1
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-offcharge`
around lines 8 - 10, The header comment in vita-offcharge still shows the old
PWRON_MASK example, so update the documented default to match the shipped
/etc/default/vita-offcharge value used by vita-offcharge. Make the comment
consistent with the actual power-button mask seen in the config and keep the
guidance aligned with the existing DISABLE setting so future edits don’t copy
the stale value.

Comment on lines +209 to +210
screen_timeout = float(conf.get('SCREEN_TIMEOUT', '10'))
boot_hold = float(conf.get('BOOT_HOLD', '2'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Malformed config values crash the script.

float(conf.get('SCREEN_TIMEOUT', '10')) / float(conf.get('BOOT_HOLD', '2')) raise an uncaught ValueError if a user edits /etc/default/vita-offcharge with a non-numeric value, killing the charge-screen logic (silently, since the service isn't Required by boot targets).

🛡️ Proposed fix
-    screen_timeout = float(conf.get('SCREEN_TIMEOUT', '10'))
-    boot_hold = float(conf.get('BOOT_HOLD', '2'))
+    try:
+        screen_timeout = float(conf.get('SCREEN_TIMEOUT', '10'))
+    except ValueError:
+        screen_timeout = 10.0
+    try:
+        boot_hold = float(conf.get('BOOT_HOLD', '2'))
+    except ValueError:
+        boot_hold = 2.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
screen_timeout = float(conf.get('SCREEN_TIMEOUT', '10'))
boot_hold = float(conf.get('BOOT_HOLD', '2'))
try:
screen_timeout = float(conf.get('SCREEN_TIMEOUT', '10'))
except ValueError:
screen_timeout = 10.0
try:
boot_hold = float(conf.get('BOOT_HOLD', '2'))
except ValueError:
boot_hold = 2.0
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-offcharge`
around lines 209 - 210, The `vita-offcharge` config parsing for `SCREEN_TIMEOUT`
and `BOOT_HOLD` can crash on malformed values because the `float(...)`
conversions are unchecked. Update the parsing logic around these settings to
safely handle invalid input in the script’s config-loading path, using the
existing `conf.get(...)` values but falling back to the defaults when conversion
fails. Keep the fix localized to the config read section so the charge-screen
flow continues even if `/etc/default/vita-offcharge` contains non-numeric
values.

Comment on lines +7 to +11
if systemctl is-active --quiet vita-pad2key; then
systemctl stop vita-pad2key && msg="Pad-as-keyboard OFF — raw gamepad (for games)"
else
systemctl start vita-pad2key && msg="Pad-as-keyboard ON — D-pad drives the desktop"
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Silent failure path when systemctl fails.

If systemctl stop/start vita-pad2key fails (e.g., permission denied without the polkit rule applied), msg stays unset and the terminal echo / notification silently shows nothing useful.

🛠️ Proposed fix
 if systemctl is-active --quiet vita-pad2key; then
-	systemctl stop vita-pad2key && msg="Pad-as-keyboard OFF — raw gamepad (for games)"
+	systemctl stop vita-pad2key && msg="Pad-as-keyboard OFF — raw gamepad (for games)" || msg="Failed to disable pad-as-keyboard"
 else
-	systemctl start vita-pad2key && msg="Pad-as-keyboard ON — D-pad drives the desktop"
+	systemctl start vita-pad2key && msg="Pad-as-keyboard ON — D-pad drives the desktop" || msg="Failed to enable pad-as-keyboard"
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if systemctl is-active --quiet vita-pad2key; then
systemctl stop vita-pad2key && msg="Pad-as-keyboard OFF — raw gamepad (for games)"
else
systemctl start vita-pad2key && msg="Pad-as-keyboard ON — D-pad drives the desktop"
fi
if systemctl is-active --quiet vita-pad2key; then
systemctl stop vita-pad2key && msg="Pad-as-keyboard OFF — raw gamepad (for games)" || msg="Failed to disable pad-as-keyboard"
else
systemctl start vita-pad2key && msg="Pad-as-keyboard ON — D-pad drives the desktop" || msg="Failed to enable pad-as-keyboard"
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@config/optional/boards/anbernic-rg-vita-pro/_packages/bsp-cli/usr/bin/vita-pad2key-toggle`
around lines 7 - 11, The vita-pad2key-toggle script has a silent failure path if
systemctl stop/start vita-pad2key fails, leaving msg unset and the user with no
useful output. Update the toggle logic around the systemctl calls so each branch
handles failure explicitly, setting a fallback error message when the command
does not succeed and preserving the existing success messages otherwise. Make
sure the terminal echo/notification path always has a message to display, using
the script’s msg variable and the systemctl-based state switch.

Comment on lines +600 to +612
+ length = device_property_count_u8(dev, "cellwise,battery-profile");
+ if (length < 0) {
+ dev_warn(cw_bat->dev,
+ "No battery-profile found, using current flash contents\n");
+ } else if (length != SIZE_OF_PROFILE) {
+ dev_err(cw_bat->dev, "battery-profile must be %d bytes\n",
+ SIZE_OF_PROFILE);
+ return -EINVAL;
+ }
+
+ cw_bat->bat_profile = devm_kzalloc(dev, length, GFP_KERNEL);
+ if (!cw_bat->bat_profile)
+ return -ENOMEM;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Guard the missing-profile case before allocating

device_property_count_u8() returns a negative error when cellwise,battery-profile is absent. Passing that straight to devm_kzalloc() turns it into a huge size_t, so this path ends in -ENOMEM instead of using the flash-contents fallback the warning suggests. Return early before the allocation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-01-cw221x.patch`
around lines 600 - 612, The battery-profile handling in the cw221x probe path
should return immediately when device_property_count_u8() reports that
"cellwise,battery-profile" is missing, because the current flow still reaches
devm_kzalloc() with a negative length and fails instead of using the
flash-contents fallback. Update the logic around the cw_bat->bat_profile
allocation so the missing-profile branch exits early after the dev_warn, while
keeping the SIZE_OF_PROFILE validation for the present-profile case.

Comment on lines +1369 to +1380
+ /* OTG setting 5V/1.2A */
+ ret = sgm4154x_set_otg_voltage(sgm, 5000000);
+ if (ret) {
+ dev_err(sgm->dev, "set OTG voltage error!\n");
+ return ret;
+ }
+
+ ret = sgm4154x_set_otg_current(sgm, 1200000);
+ if (ret) {
+ dev_err(sgm->dev, "set OTG current error!\n");
+ return ret;
+ }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file='patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-02-sgm41542.patch'

echo "== context around the cited lines =="
sed -n '1325,1405p' "$file" | cat -n

echo
echo "== locations of register_pm_notifier / error_out / OTG handling in this patch =="
rg -n "register_pm_notifier|error_out:|set_otg_voltage|set_otg_current|unregister_pm_notifier|pm_nb" "$file"

echo
echo "== broader context for error paths =="
sed -n '1280,1435p' "$file" | cat -n

Repository: armbian/build

Length of output: 8359


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# If the patch references the underlying driver file name, inspect it too.
rg -n "sgm4154x_set_otg_voltage|sgm4154x_set_otg_current|register_pm_notifier|error_out:" -S .

Repository: armbian/build

Length of output: 2305


Route the OTG init failures through error_out

register_pm_notifier(&sgm->pm_nb) runs before these calls, but both OTG error branches return directly and skip unregister_pm_notifier(). That leaves the notifier registered after probe failure. Use goto error_out here too.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-02-sgm41542.patch`
around lines 1369 - 1380, The OTG initialization failure paths currently return
directly after register_pm_notifier(), which skips cleanup and leaves the
notifier registered on probe failure. Update the error handling in the SGM4154x
probe/init flow around the sgm4154x_set_otg_voltage and sgm4154x_set_otg_current
calls to jump to error_out instead of returning immediately, so the existing
cleanup path can unregister the PM notifier.

Comment on lines +1382 to +1384
+ sgm->sgm_monitor_wq = alloc_ordered_workqueue("%s",
+ WQ_MEM_RECLAIM | WQ_FREEZABLE, "sgm-monitor-wq");
+ INIT_DELAYED_WORK(&sgm->sgm_delay_work, sgm_charger_work);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the patch and inspect the surrounding context.
file='patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-02-sgm41542.patch'
wc -l "$file"
sed -n '1360,1425p' "$file"

# Find the relevant symbols in the patch.
rg -n "alloc_ordered_workqueue|sgm_monitor_wq|queue_delayed_work|destroy_workqueue|error_out" "$file"

# If the patch references an upstream source file, list nearby paths to inspect next.
git ls-files | rg 'sgm4154x|rg-vita|battery|charger|sgm41542'

Repository: armbian/build

Length of output: 12722


Handle alloc_ordered_workqueue() failure. A NULL return leaves sgm->sgm_monitor_wq unusable, so later queue_delayed_work() and destroy_workqueue() calls are unsafe. Return -ENOMEM via error_out here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-battery-02-sgm41542.patch`
around lines 1382 - 1384, alloc_ordered_workqueue() can return NULL here, which
leaves sgm->sgm_monitor_wq invalid for later queue_delayed_work() and
destroy_workqueue() usage. Update the initialization path around sgm_monitor_wq
in the sgm charger setup to check the return value immediately after
alloc_ordered_workqueue(), and if it fails, jump to error_out and return
-ENOMEM; keep INIT_DELAYED_WORK only on the success path.

Comment on lines +199 to +200
+ mode = devm_kzalloc(dev, sizeof(*mode), GFP_KERNEL);
+

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Unchecked devm_kzalloc in load_mode/load_init_seq.

Both allocate mode/item and immediately dereference them without a NULL check (item->dcs = -1;, mode->clock via get_option). An allocation failure here faults during panel probe.

Also applies to: 233-237

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch`
around lines 199 - 200, The allocations in load_mode and load_init_seq are used
immediately without checking for failure, so add NULL handling right after
devm_kzalloc for both mode and item before any dereference or get_option usage.
Update the load_mode and load_init_seq paths to fail gracefully if devm_kzalloc
returns NULL, using the existing symbols load_mode, load_init_seq, mode, and
item to keep the panel probe from faulting on allocation failure.

Comment on lines +573 to +578
+ mode = drm_mode_duplicate(connector->dev, &mode_tmp);
+ if (!mode) {
+ dev_err(ctx->dev, "Failed to add mode %u\n",
+ drm_mode_vrefresh(mode));
+ return -ENOMEM;
+ }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the patch and inspect the relevant section
git ls-files 'patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch'
wc -l patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch
sed -n '540,610p' patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch

# Search for the exact error path and the helper used in the log
rg -n "drm_mode_duplicate|drm_mode_vrefresh|Failed to add mode|Failed to duplicate mode" patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch

Repository: armbian/build

Length of output: 3169


Avoid logging drm_mode_vrefresh(mode) after drm_mode_duplicate() fails
That branch passes a null mode into drm_mode_vrefresh(), so the OOM path can dereference NULL while reporting the error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@patch/kernel/archive/rockchip64-7.1/board-anbernic-rg-vita-panel-generic-dsi.patch`
around lines 573 - 578, The failure path after drm_mode_duplicate() in the mode
setup logic is using drm_mode_vrefresh(mode) even when mode is NULL, which can
crash while logging the error. Update the error handling in this branch to avoid
dereferencing mode on failure, and log using the available fallback data from
mode_tmp or a generic message in the same code path where drm_mode_duplicate()
is checked.

charge-term-current-microamp = <300000>;
constant-charge-current-max-microamp = <3780000>;
constant-charge-voltage-max-microvolt = <4350000>;
factory-internal-resistance-micro-ohms = <80>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the DTS and related battery binding/docs.
git ls-files 'patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts' \
  'Documentation/devicetree/bindings/power/supply/*.yaml' \
  'Documentation/devicetree/bindings/power/supply/*.txt' \
  'Documentation/devicetree/bindings/*battery*' \
  | sed 's#^`#FILE` #'

echo
echo '--- DTS excerpt around the reported line ---'
cat -n patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts | sed -n '110,135p'

echo
echo '--- Search for factory-internal-resistance-micro-ohms usage ---'
rg -n "factory-internal-resistance-micro-ohms|simple-battery|internal-resistance" \
  patch/kernel/archive/rockchip64-7.1/dt \
  Documentation/devicetree/bindings/power/supply \
  2>/dev/null | sed -n '1,200p'

Repository: armbian/build

Length of output: 1727


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
print("requesting repository evidence")
PY

Repository: armbian/build

Length of output: 182


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check the exact binding definition for the property.
rg -n "factory-internal-resistance-micro-ohms|internal-resistance-micro-ohms" \
  Documentation/devicetree/bindings/power/supply -g '*.yaml' -g '*.txt' \
  -A 6 -B 6

Repository: armbian/build

Length of output: 238


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the binding file for simple-battery and inspect the property definition.
fd -a 'simple-battery*.yaml' Documentation . 2>/dev/null || true
fd -a '*battery*.yaml' Documentation . 2>/dev/null | sed -n '1,80p'

echo
echo '--- simple-battery binding excerpts ---'
for f in $(fd -a 'simple-battery*.yaml' Documentation . 2>/dev/null); do
  echo "FILE $f"
  rg -n "factory-internal-resistance-micro-ohms|internal-resistance-micro-ohms|simple-battery|enum|minimum|maximum|unit" "$f" -A 4 -B 4
done

Repository: armbian/build

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Broaden the search to any devicetree binding mentioning the property.
rg -n "factory-internal-resistance-micro-ohms|internal-resistance-micro-ohms|simple-battery" \
  Documentation patch/kernel/archive/rockchip64-7.1/dt \
  -g '*.yaml' -g '*.yml' -g '*.txt' -g '*.dts' -g '*.dtsi' \
  -A 5 -B 5 | sed -n '1,240p'

Repository: armbian/build

Length of output: 1930


🌐 Web query:

simple-battery devicetree binding factory-internal-resistance-micro-ohms typical value micro-ohms

💡 Result:

The devicetree property factory-internal-resistance-micro-ohms is used in the simple-battery binding to represent the battery's internal resistance in micro-ohms (µΩ) [1][2]. There is no single "typical" value for this property, as the value is specific to the physical characteristics of the battery being described [2]. In practice, values are determined by the manufacturer's datasheet for the specific battery cell. Examples from existing device tree files in the Linux kernel and hardware documentation show a range of values depending on the device: - 117,000 µΩ (e.g., Quartz64 device configurations) [3][4][5] - 150,000 µΩ (e.g., PinePhone Pro) [6] - 250,000 µΩ (e.g., example provided in the official kernel documentation) [7][2][8] This property was introduced to allow the system to use a constant internal resistance value to estimate battery capacity, acknowledging that actual resistance varies over the battery's lifecycle due to aging, temperature, and other factors [2][9]. If the property is not specified in the device tree, the value is typically treated as unknown or handled by the specific power supply driver implementation [10].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search the repo for battery bindings and any documentation copies.
git ls-files | rg '/(simple-battery|battery).*\.ya?ml$|/.*battery.*\.txt$|/.*battery.*\.rst$|/.*battery.*\.md$' || true

echo
echo '--- search for the property in all tracked files ---'
rg -n "factory-internal-resistance-micro-ohms|internal-resistance-micro-ohms" . -g '!**/.git/**' | sed -n '1,200p'

Repository: armbian/build

Length of output: 2005


factory-internal-resistance-micro-ohms looks too small.
80 µΩ is far below the other simple-battery values in this tree (typically ~120000–150000 µΩ), so this looks like a missing-zeros typo. Please check the battery datasheet and update the value if needed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@patch/kernel/archive/rockchip64-7.1/dt/rk3576-anbernic-rg-vita-pro.dts` at
line 125, The simple-battery property factory-internal-resistance-micro-ohms in
rk3576-anbernic-rg-vita-pro.dts appears to be missing zeros and is inconsistent
with the other battery definitions in this tree. Verify the correct internal
resistance from the battery datasheet, then update the value in the battery node
so it matches the intended micro-ohms scale.

Source: Learnings

Comment thread config/boards/anbernic-rg-vita-pro.csc Outdated
Comment thread config/boards/anbernic-rg-vita-pro.csc Outdated
CONFIG_KEYBOARD_IQS62X=m
CONFIG_KEYBOARD_CYPRESS_SF=m
CONFIG_INPUT_JOYSTICK=y
CONFIG_JOYSTICK_SPI_MCU_JOYPAD=y

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can be a module?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes — changed CONFIG_JOYSTICK_SPI_MCU_JOYPAD to =m. Verified on hardware after a rebuild: it autoloads via its OF/SPI device table and registers the input device (lsmod shows spi_mcu_joypad, evtest sees "MCU Joypad", sticks work).

The battery and charger drivers are already =m as well. I deliberately kept the display/backlight path built-in (MFD_ROCKCHIP_MFPWM, PWM_ROCKCHIP_V4 =y): the case is glued shut so there is no serial console — the panel is the only local console — and I wanted the backlight/PWM up at the earliest point in boot. Happy to modularize those too if you prefer; I would just re-verify the panel still lights on a module build.

- csc: single-line hardware description (match other board configs)
- csc: drop "Anbernic" from BOARD_NAME (already in BOARD_VENDOR)
- kernel config: build the SPI-MCU joypad as a module instead of built-in
  (board-specific driver; autoloads via its OF/SPI device table)

Signed-off-by: crackerjacques <jack@supremeoverlordjabs.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

08 Milestone: Third quarter release BSP Board Support Packages Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review Patches Patches related to kernel, U-Boot, ... size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

2 participants