Identity
| Part | Rockchip RK817 |
| Role | System PMIC: DCDC/LDO regulators, RTC, 5 V charger path, fuel gauge, audio codec, boost/OTG switch |
| Bus / address | i2c0 addr 0x20 |
| GPIO / IRQ | GPIO0_A3, level-low PMIC interrupt |
| PineTab2 battery node | simple-battery, 6000 mAh design capacity, 4.3 V constant-charge voltage |
| Linux reference | drivers/power/supply/rk817_charger.c |
| Register map reference | include/linux/mfd/rk808.h |
| DTS reference | rk3566-pinetab2.dtsi |
Status — ◐ partial
The FreeBSD RK8xx PMIC core already knows the RK817 family and regulator
layout. This repo now adds a PineTab2-safe battery/charger monitor:
src/sys/dev/iicbus/pmic/rockchip/rk817_battery.c attaches from the RK8xx
PMIC core when the charger child exists, reads the gas-gauge and charger
registers, and exposes dev.rk8xx.N.rk817_* sysctls.
This is intentionally read-only. It does not program PMIC_CHRG_OUT,
PMIC_CHRG_IN, GG_CON, relax thresholds, coulomb-counter initial state,
or NVRAM. Linux does all of that during probe, but on an unbenched tablet
the first FreeBSD pass should answer “what did firmware leave us?” before
it starts changing charge limits.
Driver Surface
| Sysctl | Meaning |
|---|---|
rk817_present | PMIC_CHRG_STS.BAT_EXS |
rk817_online | SYS_STS.PLUG_IN_STS |
rk817_status | Decoded charger state string |
rk817_capacity_pct | Q_PRES / Q_MAX, falling back to the DT design capacity |
rk817_voltage_uv / rk817_current_ua | Battery voltage/current using Linux’s RK817 calibration math |
rk817_usb_voltage_uv / rk817_sys_voltage_uv | Input and system rail voltage readouts |
rk817_chrg_out, rk817_chrg_in, rk817_chrg_term, rk817_chrg_sts | Raw charger control/status registers |
rk817_adc_config0, rk817_adc_config1, rk817_gg_con, rk817_gg_sts | Raw gas-gauge configuration/status |
rk817_dbg_reg / rk817_peek | Read-only register peek for bench hypotheses |
rk817_dump | Write non-zero to emit one decoded dmesg line |
The patch into FreeBSD’s RK8xx core is deliberately small:
patches/sys/dev/iicbus/pmic/rockchip/rk8xx.c.patch includes
rk817_battery.h and calls rk817_battery_attach(sc->dev) only when
sc->type == RK817. patches/sys/conf/files.arm64.patch builds the new
file whenever rk8xx is in the kernel.
First Bench Predicate
After the tablet boots:
dmesg | grep -i rk817
sysctl dev.rk8xx.0 | grep rk817
sysctl dev.rk8xx.0.rk817_dump=1
The useful first proof is not “charging works”; it is:
rk817_id_msb/rk817_id_lsbread as a plausible RK817 ID.rk817_present=1.rk817_voltage_uvis in the single-cell Li-ion range.rk817_res_div=1, matching the PineTab2 DTS10000micro-ohm sense resistor.rk817_chrg_stsandrk817_sys_stsmove when USB-C power is connected or removed.
Only after those are boring should the driver grow write-side support for ADC enables, charger limits, fuel-gauge initialization, and Type-C role handoff.
Open Work
- Compile-test in a full
PINETAB2kernel once Coppice or honor is stable. - Decide whether to keep the read-only monitor as a separate file or fold RK817 into a more general RK8xx battery/charger layer.
- Add controlled write-side initialization from Linux: ADC enables,
GG_CON, relax thresholds,PMIC_CHRG_OUT,PMIC_CHRG_IN, andQ_INIT. - Wire the PMIC interrupt instead of polling.
- Keep the RK817 codec/audio path separate; the charger monitor should not become a general PMIC kitchen sink.