Skip to content

DTB Elements

southoz edited this page Apr 17, 2026 · 2 revisions

The charger

The bat_low_gpio

The bat_low_gpio property in this RK817 charger node (for RK3326-based devices) specifies the GPIO line that the RK817 PMIC uses to signal a low-battery condition to the SoC.

Purpose

  • The RK817 PMIC monitors battery voltage internally.
  • When the voltage drops below a configured low-battery threshold (usually set via bat-low-threshold in the companion rk817,battery node, e.g. <0x1e> = 30 in some units), the PMIC asserts this GPIO.
  • This GPIO acts as a hardware interrupt/signal to the Linux kernel’s rk817_charger driver (in drivers/power/supply/rk817_charger.c).
  • The kernel then uses it to trigger low-battery events: on-screen warnings, notifications, power-saving actions, or a safe shutdown to protect the battery and prevent data loss/crashes.

How it’s defined

The value <0x66 0x0d 0x00> follows the standard Rockchip GPIO binding format:

  • 0x66 → phandle to the GPIO controller (usually the SoC’s GPIO bank).
  • 0x0d → pin number within that bank.
  • 0x00 → flags (active-high/low, etc.).

It is wired (or configured via the PMIC) to the RK817’s low-battery output pin, similar to how dc_det_gpio detects DC/charger plug-in.

Where you’ll also see it

In most RK3326 + RK817 device trees (e.g. R36S/RG351 handhelds, Quartz64, etc.), it appears either in the charger node (as in your snippet) or the battery sub-node under the RK817 PMIC. It works together with the OCV table (ocv_table) and other battery properties to give accurate fuel-gauge and low-battery behavior.

In short: it’s the hardware low-battery alert pin — essential for proper battery management and user notifications on these devices. If it’s missing or points to the wrong pin, you often get incorrect battery reporting or no low-battery warnings.

The otg_switch-supply

What is otg_switch-supply?

otg_switch-supply is a Device Tree property that belongs inside the charger sub-node of the RK817 PMIC.

It tells the Linux kernel driver (rk817-charger) which regulator is responsible for controlling the USB OTG boost converter.

On these RK3326 handhelds, the RK817 PMIC has a built-in boost regulator (usually called boost) that can generate 5 V from the main 3.3 V / 3.8 V rail. This 5 V is needed when the device acts as a USB host (OTG mode) to power external devices (controllers, keyboards, etc.).

Why is this property required?

The rk817-charger driver always tries to enable/disable the OTG boost regulator at boot and during USB events.

  • If the driver cannot find the regulator via otg_switch-supply, it falls back to a dummy path.
  • It still calls regulator_disable() internally.
  • The kernel’s regulator core sees a disable without a matching enable → “unbalanced disables for otg_switch” warning.

This is exactly the warning you see in your dmesg:

rk817-charger rk817-charger: Looking up otg_switch-supply property ... failed
unbalanced disables for otg_switch
WARNING: at ... (regulator core)

Exact fix (using phandles from your darkosre DTB)

**Phandle are dependent on the BOOST node.

  • BOOST regulator → phandle <0x67>

Add this single line inside the charger node:

charger {
    compatible = "rk817,charger";
    ...
    dc_det_gpio = <0x68 0x05 0x00>;
    extcon = <0x69>;

    /* === ADD THIS LINE === */
    otg_switch-supply = <0x67>;     // points to the BOOST regulator in your DTB
};

Full corrected charger block (copy-paste ready):

charger {
    compatible = "rk817,charger";
    min_input_voltage = <0x1194>;
    max_input_current = <0x1f4>;
    max_chrg_current = <0x1f4>;
    max_chrg_voltage = <0x1068>;
    chrg_term_mode = <0x00>;
    chrg_finish_cur = <0x12c>;
    virtual_power = <0x00>;
    sample_res = <0x0a>;
    dc_det_gpio = <0x68 0x05 0x00>;
    extcon = <0x69>;
    otg_switch-supply = <0x67>;        // ← required for OTG/boost control
};

After adding the line, recompile the DTB and replace it:

dtc -I dts -O dtb -o fixed.dtb current.dts
cp fixed.dtb /boot/dtbs/rockchip/rk3326-r36s-linux.dtb
reboot

Home

Guides

Help

Arcade Systems

Console Systems

Handheld Systems

Ports and Recompilations

Advanced

In development

The guides below are for ArkOS-G80CA; once they are above this marker, they are relevant.

Clone this wiki locally