Repository navigation
max77705: S9 charger guard for iOS 16.5 (max77705_chg=, off by default): Samsung's 5 V limits, temperature bands, SIOP - #421
Conversation
…default): Samsung's 5 V limits, temperature bands, SIOP The iOS 16.5 kernel's MAX77705 driver only read the charger (and kicked its watchdog with max77705_wdt=1), so the S9 charged at whatever S-Boot left. With max77705_chg=2 the driver now applies the rules of hakios.max77705_charge.h (the same rules as the iOS 27 guard, Samsung's numbers for the S9 from exynos9810-starlte_eur_open_26.dts): - CNFG_09 [6:0] input limit and CNFG_02 [5:0] charge current to Samsung's S9 values for the BC 1.2 type, at 5 V: SDP 475/550, CDP 1500/1500, DCP 1800/2100, unknown 500/500 mA; 700 mA charge at 15.0 C and down; - CNFG_00 bit 0: charging off at 41.0 C (on at 39.0), 5.0 C (on at 10.0), without a thermistor reading, when full (recharge at 4280 mV / 98 %), after the session time; latched off at 45 C, on a chip fault, a float above 4350 mV or a read-back that differs; only while the mode is 4 or 5; - CNFG_06 WDTCLR kicked every poll. Each written only when different, only its bits, read back; nothing while CHGPROT is locked, without VBUS or after a failed read. Never written: the float, the timers, CHGPROT, the MUIC (no AFC), the gauge, anything non-volatile. max77705_chg=1 only says what it would write. On top, only lowering: SIOP, Samsung's in-use limit (siop_input_limit_current 1200, siop_charging_limit_current 1000 of the S9's DTS) while the panel is lit or its level unknown (max77705_siop=0 turns it off); and a computer on the USB link (hakios_usb_gadget_host(), the gadget configured) holds the CDP's 1500/1500 mA and never asks 9 V. Both ideas come from Jesvi-iOS (jesvi-eulah, iOS 16.5 on the Galaxy S20): SIOP from docs/devices/x1slte/charging-samsung.md (fc07d1b), the computer-port cap and no 9 V with a host from redwood_max77705.c's charging commits 3a4db07, fb882cf and a57b321. No code is copied; the values are the S9's. Credited in NOTICE. S9 only (refused on the S9+ and the Note9). Not yet run on a phone; host tests extended (tools/max77705-charge-test.sh: the caps only ever lower). docs/devices/starlte-charging.md: registers, values, sources, test plan.
…om the device repository)
|
CI: GitHub Actions is disabled on this repository, so I ran this repo's own workflows (
|
|
Phone regression of current main, phone 2 (Galaxy S9, iOS 27.2.1), 28 Nov 2026 — PASS. Built: scion-kernel main
Home screen drawn on both (icons, widgets, dock, Wi-Fi + charging). Crash set = the earlier baselines' (locationd, chronod); no new crash loop. The S9's charger guard as before ( #421 ( |
What
The iOS 16.5 kernel's MAX77705 driver only read the S9's charger (plus the watchdog kick with
max77705_wdt=1), so the phone charged at whatever S-Boot left. This adds a charger guard, off by default:max77705_chg=1: read only. Logs what it would write.max77705_chg=2: writes Samsung's own S9 limits at 5 V, with the temperature rules.max77705_siop=0: turns off the in-use limit. It is on by default when the guard is on.The rules are the existing
hakios.max77705_charge.h, the same rules the iOS 27 guard uses (#415). This PR adds the iOS 16.5 caller (hakios.max77705_guard.h) and two caps that only lower the limits. AFC (9 V) is not in this PR. It will come later as its own off-by-default boot-arg.Registers written (
max77705_chg=2), charger at I2C 0x69exynos9810-starlte_eur_open_26.dts)cable-infocurrent groups;siop_input_limit_currentswelling_low_temp_current;siop_charging_limit_currentswelling_*,recharge_condition_*,*_charging_total_timemax77705_chg_set_wdtmr_kick()Each register is written only when its value differs, only the named bits change, and every write is read back. Nothing is written when CHGPROT is locked, without VBUS, or after a failed read. Never written: the float voltage, the timers, CHGPROT, the MUIC (no AFC, the D+/D- switch untouched), the gauge, and anything non-volatile. It runs on the S9 only; on star2lte and crownlte it says it is for the S9 and does nothing.
Taken from Jesvi-iOS (jesvi-eulah, with the owner's approval)
Ideas only, no code copied. The values are the S9's own, not the S20's.
docs/devices/x1slte/charging-samsung.md(fc07d1b).ask_9vis cleared.Jesvi-iOS is credited in NOTICE and in
docs/devices/starlte-charging.md.Other changes
hakios_panel_level()inhakios.backlight.cpp(the panel's last level, -1 if unknown).hakios_usb_gadget_host()inhakios.dwc3.c, with a stub that returns false when the gadget isn't built.tools/max77705-charge-test.shnow also checks that the caps only ever lower, across every input/charge value (871 213 checks, 0 failures).tools/arch-size.allow:hakios.max77705.cgoes 1125→1130 (+5: the guard's hooks; the guard itself is split out intohakios.max77705_guard.h), andhakios.dwc3.cgoes 2298→2302 (+4: the new accessor).The checks run locally all pass: hakios-config-test, boot-args-test/--check, drivers-check, arch-check, hakios-device check, docs-gen --check, docs-check, max77705-charge-test, provenance. The guard logic was also compiled and run on the host against a fake register file under ASan/UBSan, and clang reported no warnings with
-Wconversion -Wshorten-64-to-32. The kernel build itself is left to CI (xnu-linux, starlte_defconfig).Test plan (S9, iOS 16.5 image from this branch)
Full plan:
docs/devices/starlte-charging.md.max77705_chg=1. Look formax77705: chg: the charger guard, read only…, then lines likemax77705: chg: a wall charger at 5 V (DCP); charging allowed; on, input … mA …; battery NN.N C. The battery temperature must be plausible, neverNOT READ, and the type must match the charger.max77705_chg=2on a Samsung wall charger:input limit (CNFG_09): … -> 0x47, read back 0x47andcharge current (CNFG_02): … -> 0x2a, read back 0x2a;Every 5 min the summary should read
… 0 failed, 0 read back differently, 0 refused.a computer on the link, and the limits never go above 1500/1500.DIFFERS,FAILED,45 C or more,a fault, or a hot phone.Revert: drop
max77705_chg=(or set it to 0). Every register written is volatile: S-Boot sets its own again on the next boot.Unverified: none of this has run on a phone yet. Two things in particular are untested: whether iOS sets the panel to level 0 when the screen locks (if it does not, SIOP stays on, which only means slower charging), and what S-Boot sets on a DCP.
Not merging: the owner merges after a phone test.
🤖 Generated with Claude Code