Repository navigation
Conversation
|
Thanks a lot for this, @danlovaj. The commits are well split, the Aria event controller and the 24-byte calibration table are useful on their own, and the test table with the Anker and the computer port is exactly what we need to review a charger change. Our direction for charging on every Lightning board is adaptive charging: the input limit follows what the source on the other end says it can supply, through the same shared code on every board. Since this PR reuses What adaptive covers, and where it already is on main
Every grant is capped at the board maximum and ramps the way iOS does, inside the battery window. So the PR is not a hard-coded 1.5 A: 1.5 A is the ceiling the DT gives, and 500 mA from your computer is the USB 2.0 rule working as intended. What we need changed: 1. Board maximum from the ADT: 2.4 A, not 1.5 AI checked the iOS 16.7.16 device trees (20H392, On your reviewer question about the VBUS window: the 1.5 A and VBUS guard on 2. Back off a source that cannot deliver what it advertisesA cheap brick or a tired power bank can advertise 2.4 A and then sag. Your Anker attempt that dropped out after about 6 s and stayed off might be one. An adaptive charger lowers its limit and keeps the lower value until unplug. It doesn't trip to off or hold a limit the source can't give. Main does this in two other drivers, but not yet in the Tristar policy:
Since J127/J128 have no VBUS ADC in the ADT, the signal has to come from the D2355 itself: a status bit or one of the events the charger already subscribes to (40, 42, 53), or the D2355 lowering its own limit. Could you look in the J128 kernelcache for what 3. The ID-bus request: on every attach, for every board, not as a retry on a bad frameYou're right that the cable has to be asked for its ID. iOS asks on every attach, before it touches the data lines, and then samples only the route the ID selects (see the header comment of
The way we'd like it built: split the accessory code into the ID read, which every Lightning board needs for charging and which the charger runs once per attach before identification (it builds with the charger, as your Makefile change already does), and the host-mode policy, which stays behind the role switch. Identification then starts from the digital ID on every board, and the capability frame is read after it. That replaces the retry, and J71b/J71t keep their current behaviour because their policy already does exactly this. 4. The Aria event controller in
|
|
Data point from iPad Pro (10.5-inch, Wi-Fi) ( Cherry-picking
(Paired with #164 for |
…of faulting at 4.75 V The Orion Bellatrix VBUS ADC measures Lightning VBUS at the iPad's connector, after USB cable and adapter IR drop. On real 5 V USB-A bricks and cables, drawing 1.0-1.5 A routinely drops connector VBUS below 4.75 V (the host-port minimum before cable drop): on J207 we measured 4736 mV at 1.48 A on an Anker Zolo 50 W USB-A brick (BrickID 5) and 4688 mV at 1.48 A (4736 mV at 1.28 A) on an Apple MacBook Air brick through a USB-A adapter (BC1.2 DCP). Previously, any single sample below 4750 mV latched TRISTAR_FAULT and withdrew input current to the 80 mA fallback until unplug. Separate hard VBUS faults from normal cable droop: - Keep immediate TRISTAR_FAULT withdrawal to fallback on IIO read error, overvoltage (> 5500 mV, protecting low-voltage range 0 against high-voltage USB-PD rails), or severe brownout (< 4350 mV, below the USB 2.0 4.40 V device-side minimum), checked whenever input is above fallback or targeting > 1 A. - On droop below 4500 mV, step back by one ramp step (100 mA), cap vbus_limit_ma for the current attachment, and hold steady instead of collapsing to 80 mA. Reset vbus_limit_ma on disconnect/new attachment. Tested on J207 (combined with #136's GetID retry): - Computer USB-A (SDP): ramps cleanly to 500 mA (VBUS 5040 -> 4880 mV) - Anker Zolo 50 W USB-A (BrickID 5): ramps to 1500 mA, VBUS 4736 mV, +725 mA net into battery - Apple MacBook Air USB-C brick + USB-C-to-Lightning (3.0 A CC): ramps to 1500 mA, VBUS 4832 mV, +749 mA net into battery - Apple brick + USB-A adapter + USB-A-to-Lightning (BC1.2 DCP): ramps to 1500 mA, VBUS 4688 mV, +688 mA net into battery Ref: OrchardLinux/orchard#552 Assisted-by: LLM Signed-off-by: Grier Johnson <grier@scooterfarm.com>
The Dialog D2257 (Aria) is the PMIC of the A9X iPad Pros. It has 22 GPIOs, whose input levels are read as on the D2365, and latches 248 PMU events. Assisted-by: LLM Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The D2257 of the A9X iPad Pros has 31 event bytes at 0x140 (status) and 0x1c0 (mask), with GPIO line N being event 0x30 + N. Its 22 GPIOs are inputs for now, as the boot firmware set them up. The Lightning charger needs the events: the PMIC's ADC reports a finished conversion as event 184. Assisted-by: LLM Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bration The 9.7-inch iPad Pro has the same D2355 charger as the iPad Pro 2, but its ADT carries a 24-byte low-voltage calibration table in place of the 84-byte one, and the ADC is in the Aria PMIC. Assisted-by: LLM Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 9.7-inch iPad Pro's ADT has a 24-byte usb-input-limit-calibration table: five Q16.16 points for range 0 and a selector word. Use it when the 84-byte high-voltage table of the iPad Pro 2 is absent. Assisted-by: LLM Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iOS asks the cable for its digital ID over the ID bus on every attach before touching the USB data lines, and then reads the capability frame from the Tristar response window. Until now, only boards with apple,usb-role-switch ran GetID through the accessory policy; on other CBTL1610 rev 0x8a boards (such as J128 and J207), 0x20..0x27 stayed 75 00 00 00 00 00 00 00 and wall chargers fell back to 80 mA. Build apple_tristar_idbus.o unconditionally with apple-tristar-charger (keeping the host-mode accessory policy behind CONFIG_APPLE_TRISTAR_ACCESSORY) and run tristar_idbus_identify() once per attachment in tristar_run_identification() before tristar_identify() on boards without chg->acc. Boards with chg->acc keep their existing accessory-policy flow, non-0x8a Tristars return -ENODEV without register writes, and session-time tristar_reconfirm() continues reading only the capability frame. Assisted-by: LLM
On J127/J128 there is no VBUS ADC in the ADT, so input sag has to come from the D2355 itself. In iOS 16.7.16 (AppleD2355PMUPowerSource:: handleInterrupt), when a verified grant >= 200 mA (raw >= 0x14) collapses a weak source, the D2355 drops control_base + 0xb (0x44e) to 0x0a (100 mA) while status[1] (0x81) bit 7 stays set, and AppleARMPMUCharger backs the input current limit off by 100 mA. Wire tristar_d2355_input_sag() into tristar_chip_info.input_sag: - Keep tristar_vbus_sag() first for boards that carry a VBUS ADC. - Otherwise report TRISTAR_SAG_DROOP when the D2355 has dropped control_base + 0xb to 0x0a while online. - Because D2355's line/source IRQ handlers withdraw to the fallback before tristar_poll() runs, also check for that collapse right before tristar_d2355_write_limit() overwrites 0x44e on withdrawal and pass the collapsing current through input_sag() so the shared sag backoff caps the attachment 100 mA below it instead of looping back into collapse. - Keep the faster poll interval while awaiting sag confirmation. Assisted-by: LLM
…Pad Pro Describe the Aria PMIC's event controller and the CBTL1610 Tristar in s8001-pro.dtsi (matching the J98a/J99a and J127/J128 ADTs), and the D2355 charger of J127 and J128 in s8001-j127-j128.dtsi with the ADT's 2.4 A board maximum (usb-input-limit-max = 2400). J98a and J99a have a D2231 instead, which has no driver yet. Assisted-by: LLM
aa503c0 to
990d8f4
Compare
|
Thanks for the detailed review @henrikklee, and great to hear the ID-bus read also helped Rebased onto 1. Board max raised to 2.4 A
2. D2355 input-collapse check wired into
|
| Source | Kernel identification | usb_type |
current_max |
input_current_limit |
Gauge current / V |
|---|---|---|---|---|---|
| PC USB-A port (idle, 95% SOC) | USB enumeration (500 mA) |
SDP |
500 mA |
500 mA (steady) |
+70 mA / 4.17 V |
| Anker PowerPort 4 (A2142) (under 1-core load) | Apple USB-A charger, BrickID 5 (2.4 A) |
BrickID |
2400 mA |
2400 mA (held 32 s) |
+374 mA / 4.17→4.20 V |
| Apple 10 W USB-A (95% SOC) | Apple USB-A charger, BrickID 4 (2.1 A) |
BrickID |
2100 mA |
880 mA* |
+328 mA / 4.23 V |
Oculus 15 W USB-C (C→Lightning, 95% SOC) |
USB-C 3.0 A (CC 1692 mV) |
C |
2400 mA |
880 mA* |
+315 mA / 4.23 V |
| Samsung 10 W USB-A (under 1-core load) | USB charging port (DCP, BC1.2 667/667 mV) |
DCP |
1500 mA |
1500 mA (held 48 s) |
-222 mA / 4.12→4.15 V |
USB-A-to-C adapter (C→Lightning, 95% SOC) |
USB-C 3.0 A (CC 1645 mV) |
C |
2400 mA |
880 mA* |
+309 mA / 4.23 V |
PC USB-C port (C→Lightning, under load) |
USB-C 3.0 A (CC 1697 mV) + USB 500 mA |
C |
2400 mA |
2080 mA (event 53 at 2080 mA; see #2) |
-171 mA / 4.16 V |
| Brick → PC USB-A swap | Disconnect → 80 mA → SDP (500 mA) |
SDP |
500 mA |
500 mA (zero carryover) |
-1315 mA / 4.05 V |
*At 95% SOC (4.16 V resting), ramping past 880 mA raised pack voltage above the conservative 4.20 V limit (4.21–4.23 V), tripping the pack window guard cleanly. Under a 1-core system load (keeping pack voltage below 4.20 V), Anker held steady at 2400 mA and Samsung DCP held steady at 1500 mA.
Note on Signed-off-by (regarding your requests here and on #118/#133):
To be transparent, I am steering an AI coding assistant and performing the live DFU and hardware testing on my J128 — I did not write or audit all of the C/DTS code myself, so I am not comfortable certifying a Signed-off-by DCO for code I did not personally author/review, though I am happy to provide Tested-by: for the hardware verification. Let me know how you would prefer to handle that for these PRs.
Adds Lightning charging to the 9.7-inch iPad Pro (J127, J128). It charges at up to 1.5 A from a USB-A charger and 500 mA from a computer.
Based on
main; it does not need #118 or #134. Charging needs the m1n1 pull request that copies the 24-byte calibration table (OrchardLinux/m1n1#23). With an older m1n1 the charger does not start, and USB connects through dwc2's fallback.Changes
gpio-apple-d2365. The charger needs its ADC-done event.Affects other boards: the GetID also runs on other Tristar boards without
apple,usb-role-switch, but only when their cable frame is invalid, and only on CBTL1610 revision 0x8a.Tested on J128
Tested on this branch, booted on J128. One Anker attempt dropped out about 6 s after it was plugged in and stayed off; the cable was probably not fully seated. The repeat held 1.5 A for about 60 s, until unplugged.
Not tested
For reviewers
tristar_accept()leaves USB data on for BrickID chargers, so this is existing behaviour.Assisted-by: LLM
🤖 Generated with Claude Code