Repository navigation
Conversation
…OS 12 The A7 iPads' Lightning charger now does two things iOS 12 AppleD2089PMUPowerSource does on the D2089: - with every input-limit write, bit 2 of PMIC register 0x10 is set below 75 mA and cleared otherwise (setInputCurrentLimit); the driver never writes less than 75 mA, so it clears the bit, logging the first time it found it set; - when the charger state 0x62 reports an expired charge timer (bit 4) while a source is attached and the battery is below 90 %, the timer is restarted through 0x4c8 (the value with only bit 3, then the value), at most every 300 s. The binding gains an "input" register range for 0x10, required on the D2089; the iPad Air's and iPad mini 2's shared files give it and extend the control range to 0x4c8. The D2207, D2365 and D2355 are unchanged. An iPad Air at 1 % kept discharging on a charger while one at 7 % charged; this series has not run on an iPad yet. Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Closing this: the register dumps show it isn't the cause. I caught the failure twice more on the J71 today, at 1–2 % (about 3.65 V, screen on). Once it was on a Mac CDP, once on an Apple USB-C charger, and both times the battery discharged at -270 to -540 mA. A read-only dump in the failing state was identical to the charging state:
iOS's restart sequence didn't help either: 0x10 bit 2 set, then cleared, then 0x4c0 rewritten. At 3.70 V the same kernel charged at +845 to +948 mA from the same sources. So this looks like low-battery behaviour of the D2089 (precharge, or a system-load priority below some VBAT), not the input suspend or the charge timer. Powered off on a charger, it recovers. I'll look into what iOS does at low VBAT and open a new PR if that finds the cause. |
An iPad Air (J71) on main's charger code did not charge from a near-empty
battery. At 1 % it was plugged into a Mac's USB-C port (identified as a CDP)
and into a 30 W USB-C charger. Both times the driver identified the source and
set the D2089's input limit (0x4c0) to 1500 mA, but the battery kept
discharging at -224 to -565 mA and went from 1 % to 0 %. After iBoot had
charged it to 7 % while powered off, the same kernel charged it at +823 mA
on the CDP.
I don't know the root cause. No register dump was taken while it failed at
1 %. The only read-only dump is from the charging state at 7 %: 0x10 = 00,
0x4c0..0x4cf = 72 02 c2 72 0e d4 3f 3f f7 3f 0e 00 e1 2d 3f 07,
0x60..0x6c = 0d 03 42 20 3e 00 00 00 00 00 00 00 03. So this PR does what iOS
12 does on the D2089 in two places where main's driver does nothing, and
it logs when either case happens so the next failing run shows which one it was.
What iOS 12 does (AppleD2089PMUPowerSource, J85 12.5.8 kernelcache, static analysis)
setInputCurrentLimitwrites 0x4c0 = (mA - 75) / 12.5. Before each write,a helper read-modify-writes bit 2 of PMIC register 0x10: set for a limit
below 75 mA, cleared otherwise.
charge timer (bit 4) and the battery is below 90 %, at most every 300 s,
it reads 0x4c8, writes back only its bit 3, then writes the value it read.
Changes
apple_tristar_charger): three new fields instruct tristar_pmic(
input_suspend,timeoutandcharge_timer), set only for the D2089.write_limit, including the unlockedwithdrawal from the event handler), bit 2 of the "input" register is set
or cleared as iOS does it. The driver never writes less than 75 mA, so in
practice this clears the bit. The first time the bit is found set it
logs a
dev_info("charger input was suspended ... resuming it").battery reads below 90 %, the charge timer is pulsed through 0x4c8 as
above. This happens at most every 300 s per attachment and logs a
dev_infoeach time. If the battery charge can't be read, the timer isleft alone.
input, required forapple,d2089-tristar-chargerand not allowed for the other compatibles.s5l8960x-air1.dtsi,s5l8960x-mini2.dtsi):<0x10 0x01>asinput, and the control range grows from<0x4c0 0x01>to<0x4c0 0x09>so it reaches 0x4c8.registers on them.
devices/j71/device.toml: the charging note records the J71 results above.It stays
untested. CHANGELOG entry under Unreleased.The charge current register 0x4c6 (0x3f from iBoot) is left alone.
Testing
1-2 % and look for the two new log lines and the battery current.
orchard build examples/minimal-boot --device j85,--device j71,--device j81: built. The J71 and J85 DTBs have the new range. The driveralso compiles cleanly with W=1.
kernel/audit-patches.py --devicej85, j81, j71b, j71t, j71: PASS.tools/catalog/generate matrix --check: clean.(test_cascadia_loader, test_ram CLI tests); nothing new.
🤖 Generated with Claude Code