Skip to content

j81: charging — the Lightning charger on the iPad Air 2's D2207 - #197

Merged
henrikklee merged 6 commits into
OrchardLinux:mainfrom
ricktav:j81/charging
Nov 22, 2026
Merged

henrikklee merged 6 commits into
OrchardLinux:mainfrom
ricktav:j81/charging

Conversation

@ricktav

@ricktav ricktav commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The iPad Air 2 (J81) drained on a cable: iBoot leaves the D2207 PMIC's input-current limit at 100 mA, and nothing raised it. This PR teaches the existing Lightning charger driver (apple_tristar_charger) the D2207, and describes the Tristar and the charger in the J81 device tree. A computer's charging port or an Apple adapter now gets up to 1.5 A.

Changes

  • Driver (drivers/power 0041):
    • Per-PMIC match data. apple,tristar-charger keeps the D2365 layout unchanged.

    • apple,d2207-tristar-charger uses the D2207's addresses, from iOS 15.8's AppleD2207PMU:

      function D2365 (bank + offset) D2207
      connection state status + 0x09 0x60
      "new connection" bit bit 1 bit 3
      charger state status + 0x0a 0x62
      input-current limit control + 0x03 0x4c0
      ADC start adc + 0, value 1 0x500, 0x80 | channel 6
      ADC result adc + 1 0x502

      The limit encoding (mA = code × 12.5 + 75) and the ADC result format are the same. After a D2207 conversion, the driver clears the start bit and the latch in 0x501, as iOS does.

    • A node may now have no source events. The driver's 100 ms poll of the connection state then sees plugging in and unplugging.

  • Binding (drivers/power 0040):
    • The D2207 compatibles.
    • The interrupts need at least 2 entries (the PMU line and ADC done) instead of 3.
  • Device tree (devices/t7001 0012):
    • The Tristar (CBTL1610) at i2c0 0x1a.
    • The charger on the PMIC, with the PMU line (112) and ADC done (89).
    • A 2400 mA board maximum: the ADT's usb-input-limit-max is 0x960.
    • The USB role link, and usb-psy-name on the device controller.
  • J81: charging and charging_control are working. Includes the regenerated matrix and a CHANGELOG line.

No plug event on the J81

iOS's charger also subscribes event 0 (plug) and event 21. With the plug event subscribed, it stays unmasked when the iPad is reset into DFU from a running Linux, because that reset skips iBoot, which would mask it. The cable replugs of the next boot then latch it.

Over these tests, RAM boots after a DFU from a Linux with the charger active got through 0 of 5 times with the plug event subscribed. With the charger unbound first, 2 of 2 got through. Without the plug event, 3 of 4 got through.

This is not the whole story. RAM boots after a DFU from Linux also freeze sometimes without any of this PR: 3 of 6 base main probes, with and without Wi-Fi loaded, froze after such a DFU. After a freeze, the next boot freezes too, until Recovery → DFU from a powered-off iPad. Installed Omarchy (orchard launch) did not freeze in any test, including after a DFU from Linux with the charger active. I'll file the RAM-boot freeze separately.

The poll sees a plug within 100 ms, so leaving the plug event out costs nothing measurable.

Testing

iPad Air 2 Wi-Fi (J81, iPad5,3). Host: a MacBook Air M2 under Asahi Linux, USB-C port.

  • Registers first, read-only:
    • With the cable in, 0x60 reads 0x0f and 0x62 reads 0x42.
    • With the cable out, 0x60 reads 0x06 and 0x62 reads 0x00.
    • 0x4c0 stays at 0x02 (100 mA) in both cases.
    • Writing 0x22 (500 mA) to 0x4c0 by hand moved the battery current by +426 mA.
  • RAM boots (orchard run, this branch's kernel):
    • The Mac's USB-C port is identified as a BC1.2 charging port: CDP, BC1.2 D- 623 mV, D+ 39 mV: up to 1500 mA.
    • An Apple USB-C power adapter on a USB-C to Lightning cable is identified by its 1.5 A advertisement (CC 878 mV).
    • Both get 1500 mA. The battery goes from about −0.7 A to +0.9 A with the screen on.
    • Unplugging withdraws the grant and holds USB data off. The next plug identifies the source again (3 cycles, with the event and with the poll).
    • USB data comes back each time, and SSH stays up.
  • Installed Omarchy:
    • The kernel combines this branch with j81: speakers — SmartIO, MCA v1 and MAX98721 on the iPad Air 2 #192 (speakers) and j81: run Bluetooth at 3 Mbit/s #195 (Bluetooth at 3 Mbit/s). I installed the platform layer with boot-entries sync.
    • The charger identifies the port at boot and gets 1500 mA.
    • The speakers play, and Bluetooth runs at 3 Mbit/s.
    • Unplugging and plugging in work.
    • An 83 s s2idle sleep with the cable in, woken by Power: the grant comes back after resume.
      • Afterwards omarchy-powerd logs suspend did not happen; the sleep did happen. The USB reconnect after resume probably hides the end of the suspend unit from it. Not looked into further.
    • A DFU entered from Omarchy, then orchard launch: it boots, charging included.
  • Checks:
    • kernel/audit-patches.py passes for j81, j71b and j71t.
    • tools/catalog/generate matrix --check passes.
    • python -m unittest discover -s tests: everything passes except the 5 that also fail on unmodified main on this host.

Not included

  • The D2207's 0x10 bit 2 (possibly "input disable"). iOS sets it below 75 mA; this PR never goes that low.
  • Event 21: its meaning is unknown.
  • Lightning accessories over the ID bus. CONFIG_APPLE_TRISTAR_ACCESSORY is not built on apple-4k.
  • An Apple USB-A wall adapter (BrickID path), which I didn't test.

#192 and #195 also add devices/t7001 patches and CHANGELOG lines, so whichever merges later gets its patch renumbered.

🤖 Generated with Claude Code

The iPad Air 2 drained on a cable: iBoot leaves the D2207 PMIC's input
current limit at 100 mA and nothing raised it. The Lightning charger
driver now supports the D2207 (its charger registers, ADC and plug state,
as iOS 15.8 uses them), and the J81 device tree describes the Tristar and
the charger. A computer's charging port or an Apple adapter gets up to
1.5 A.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ricktav and others added 5 commits November 23, 2026 01:54
SmartIO on the A8/A8X (AppleA7IOP version 1), MCA version 1 in the S8000 MCA driver, the MAX98721 speaker amplifier driver, the T7001 NCO, the device tree and a UCM profile; both speakers play in stereo. The headphone jack and the microphones are not part of it. Squashed from ricktav's j81/audio (17aa5eb); patch files renumbered to follow main.
The Lightning charger driver learns the iPad Air 2's D2207 PMIC, so a charging port or an Apple adapter gets up to 1.5 A instead of iBoot's 100 mA. From ricktav's j81/charging (2bbdaa3); patch files renumbered to follow main.
Patch numbers follow main's, and the changelog, compatibility table and
driver catalog are combined with the other J81 changes. ricktav's patches
are unchanged.
@henrikklee
henrikklee marked this pull request as ready for review November 22, 2026 18:08
@henrikklee
henrikklee merged commit ac23038 into OrchardLinux:main Nov 22, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants