From db766b2c13bd8d603c5ddf61922b7a55f7ec67a6 Mon Sep 17 00:00:00 2001 From: Grier Johnson Date: Fri, 4 Dec 2026 10:58:15 -0700 Subject: [PATCH 1/3] arm64: dts: apple: t8011-pro2: Wire USB host current budget to the Lightning charger Every other Tristar iPad sets usb-psy-name = "lightning" on its dwc2 device node so vbus_draw reports the configured USB host budget (500 mA) to apple-tristar-charger. t8011-pro2.dtsi omitted it, leaving iPad Pro 2 boards (J120, J121, J207, J208) at the 80 mA fallback (CURRENT_MAX=0) when attached to a computer USB port. Add usb-psy-name = "lightning" to &usb2dev and update the VBUS window comment on charger@80. Tested on J207 (iPad Pro 10.5-inch, Wi-Fi): attached to a Linux host USB port, dwc2 reports 500 mA and apple-tristar-charger ramps cleanly from 80 mA to 500 mA. Ref: OrchardLinux/orchard#552 Assisted-by: LLM Signed-off-by: Grier Johnson --- arch/arm64/boot/dts/apple/t8011-pro2.dtsi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8011-pro2.dtsi b/arch/arm64/boot/dts/apple/t8011-pro2.dtsi index ec80bc47c7de7f..02a98541fec1b4 100644 --- a/arch/arm64/boot/dts/apple/t8011-pro2.dtsi +++ b/arch/arm64/boot/dts/apple/t8011-pro2.dtsi @@ -231,7 +231,7 @@ /* The boot loader adds this unit's ADT calibration table. */ /* A conservative window, not Apple's production limits. */ apple,pack-limits = <150 350 3400000 4200000 (-2000000) 2000000>; - /* 1.5 A only while the Lightning VBUS reads 4.75-5.5 V. */ + /* Up to 1.5 A while Lightning VBUS stays in the 5 V window. */ input-current-limit-microamp = <1500000>; io-channels = <&orion_vbus 0>; io-channel-names = "vbus"; @@ -504,8 +504,9 @@ }; }; -/* The Lightning charger sets the data role once the source is known. */ +/* The Lightning charger sets the data role and receives the USB host budget. */ &usb2dev { + usb-psy-name = "lightning"; usb-role-switch; port { From c928c72a933006ad4db657be2957f9fcbc037919 Mon Sep 17 00:00:00 2001 From: Grier Johnson Date: Fri, 4 Dec 2026 10:58:15 -0700 Subject: [PATCH 2/3] power: supply: apple_tristar_charger: Back off on VBUS droop instead 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 --- drivers/power/supply/apple_tristar_charger.c | 56 +++++++++++++++----- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/apple_tristar_charger.c b/drivers/power/supply/apple_tristar_charger.c index ee47ca1619b933..f2dc58d8d19c7d 100644 --- a/drivers/power/supply/apple_tristar_charger.c +++ b/drivers/power/supply/apple_tristar_charger.c @@ -209,6 +209,15 @@ static const struct tristar_pmic tristar_d2355 = { #define TRISTAR_EVENT_DEBOUNCE_MS 50 /* More source events than this per second means something is stuck. */ #define TRISTAR_IRQ_STORM 200 +/* + * Lightning VBUS telemetry bounds (mV) for low-voltage (5 V) charging: + * overvoltage (> 5.5 V, e.g. high-voltage PD) and severe brownout (< 4.35 V) + * fault to the fallback; normal cable/adapter droop below 4.5 V caps the + * input current by backing off a step instead of terminating charging. + */ +#define TRISTAR_VBUS_MAX_MV 5500 +#define TRISTAR_VBUS_DROOP_MV 4500 +#define TRISTAR_VBUS_FAULT_MV 4350 enum tristar_phase { TRISTAR_EMPTY, @@ -251,6 +260,7 @@ struct tristar_charger { u32 adc_base; unsigned int max_ma; struct iio_channel *vbus; + unsigned int vbus_limit_ma; bool vbus_fault; /* Serializes policy state and PMIC/Tristar sequences. */ @@ -884,14 +894,16 @@ static void tristar_set_usb(struct tristar_charger *chg, bool on) } } -/* The highest grant the source allows, up to the board maximum. */ +/* The highest grant the source allows, up to the board and VBUS maximums. */ static unsigned int tristar_target_code(struct tristar_charger *chg) { unsigned int ma = max(chg->source_ma, tristar_usb_ma(chg)); + unsigned int cap = chg->vbus_limit_ma ? + min(chg->max_ma, chg->vbus_limit_ma) : chg->max_ma; if (ma <= tristar_code_ma(chg, chg->chip->fallback_code)) return chg->chip->fallback_code; - return tristar_ma_code(chg, min(ma, chg->max_ma)); + return tristar_ma_code(chg, min(ma, cap)); } /* Follow a changed allowance once the source is identified. Caller holds lock. */ @@ -924,6 +936,7 @@ static void tristar_new_attachment(struct tristar_charger *chg, u64 now) /* Before anything else: a host must not start a session yet. */ tristar_set_usb(chg, false); chg->present = true; + chg->vbus_limit_ma = 0; chg->vbus_fault = false; chg->phase = TRISTAR_SETTLING; chg->attach_ns = now; @@ -1300,6 +1313,7 @@ static void tristar_poll(struct work_struct *work) chg->phase = TRISTAR_EMPTY; chg->source[0] = '\0'; chg->source_ma = 0; + chg->vbus_limit_ma = 0; chg->usb_ma = 0; chg->usb_type = POWER_SUPPLY_USB_TYPE_UNKNOWN; if (tristar_set_code(chg, chg->chip->handoff_code)) @@ -1320,16 +1334,34 @@ static void tristar_poll(struct work_struct *work) goto again; } if (IS_REACHABLE(CONFIG_IIO) && chg->vbus && !chg->vbus_fault && - (chg->phase == TRISTAR_RAMPING || chg->phase == TRISTAR_CHARGING) && - tristar_code_ma(chg, chg->target_code) > 1000) { - int mv, ret; - - ret = iio_read_channel_processed(chg->vbus, &mv); - if (ret || mv < 4750 || mv > 5500) { - chg->vbus_fault = true; - chg->phase = TRISTAR_FAULT; - dev_warn(chg->dev, "VBUS guard tripped (sample %d mV, error %d)\n", - ret ? 0 : mv, ret); + (chg->phase == TRISTAR_RAMPING || chg->phase == TRISTAR_CHARGING)) { + unsigned int cur_ma = tristar_code_ma(chg, chg->code); + unsigned int target_ma = tristar_code_ma(chg, chg->target_code); + unsigned int fallback_ma = tristar_code_ma(chg, chg->chip->fallback_code); + + if (cur_ma > fallback_ma || target_ma > 1000) { + int mv, ret; + + ret = iio_read_channel_processed(chg->vbus, &mv); + if (!ret && chg->phase == TRISTAR_RAMPING) + dev_dbg(chg->dev, "VBUS %d mV at %u mA (target %u mA)\n", + mv, cur_ma, target_ma); + if (ret || mv < TRISTAR_VBUS_FAULT_MV || mv > TRISTAR_VBUS_MAX_MV) { + chg->vbus_fault = true; + chg->phase = TRISTAR_FAULT; + dev_warn(chg->dev, "VBUS guard tripped (sample %d mV, error %d)\n", + ret ? 0 : mv, ret); + } else if (mv < TRISTAR_VBUS_DROOP_MV) { + unsigned int limit_ma = cur_ma > fallback_ma + TRISTAR_RAMP_STEP_MA ? + cur_ma - TRISTAR_RAMP_STEP_MA : fallback_ma; + + chg->vbus_limit_ma = limit_ma; + chg->target_code = tristar_target_code(chg); + tristar_withdraw(chg, chg->target_code); + chg->phase = TRISTAR_CHARGING; + dev_info(chg->dev, "VBUS droop (%d mV at %u mA); capping input to %u mA\n", + mv, cur_ma, tristar_code_ma(chg, chg->target_code)); + } } } if (chg->vbus_fault) From 53943ab91b8e9d9e779df21583ef7ed2f1342491 Mon Sep 17 00:00:00 2001 From: Grier Johnson Date: Fri, 4 Dec 2026 14:09:25 -0700 Subject: [PATCH 3/3] power: supply: apple_tristar_charger: Retry transient VBUS ADC read errors With the VBUS guard active at 500 mA USB input as well as > 1 A, a single transient I2C NACK (-ENXIO) or -EBUSY from the Orion Bellatrix VBUS ADC permanently latched TRISTAR_FAULT and collapsed input current to the 80 mA fallback for the rest of the attachment. Observed live on J207 at t = 2.48s right after ramping to 500 mA USB SDP: i2c-apple 20a111000.i2c: NACK, status 0x10210110 apple-tristar-charger ...: VBUS guard tripped (sample 0 mV, error -6) Require three consecutive VBUS ADC read errors before latching TRISTAR_FAULT, holding the current ramp step (without advancing) while retrying and resetting the error counter on any successful read or attachment change. Measured overvoltage (> 5500 mV) and severe brownout (< 4350 mV) still trip TRISTAR_FAULT immediately. Ref: OrchardLinux/orchard#552 Assisted-by: LLM Signed-off-by: Grier Johnson --- drivers/power/supply/apple_tristar_charger.c | 62 +++++++++++++------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/drivers/power/supply/apple_tristar_charger.c b/drivers/power/supply/apple_tristar_charger.c index f2dc58d8d19c7d..54fe3a01e77626 100644 --- a/drivers/power/supply/apple_tristar_charger.c +++ b/drivers/power/supply/apple_tristar_charger.c @@ -218,6 +218,7 @@ static const struct tristar_pmic tristar_d2355 = { #define TRISTAR_VBUS_MAX_MV 5500 #define TRISTAR_VBUS_DROOP_MV 4500 #define TRISTAR_VBUS_FAULT_MV 4350 +#define TRISTAR_VBUS_READ_RETRIES 3 enum tristar_phase { TRISTAR_EMPTY, @@ -261,6 +262,7 @@ struct tristar_charger { unsigned int max_ma; struct iio_channel *vbus; unsigned int vbus_limit_ma; + unsigned int vbus_read_errors; bool vbus_fault; /* Serializes policy state and PMIC/Tristar sequences. */ @@ -937,6 +939,7 @@ static void tristar_new_attachment(struct tristar_charger *chg, u64 now) tristar_set_usb(chg, false); chg->present = true; chg->vbus_limit_ma = 0; + chg->vbus_read_errors = 0; chg->vbus_fault = false; chg->phase = TRISTAR_SETTLING; chg->attach_ns = now; @@ -1288,7 +1291,7 @@ static void tristar_poll(struct work_struct *work) struct tristar_charger *chg = container_of(to_delayed_work(work), struct tristar_charger, poll_work); unsigned int status, old_code; - bool old_online, old_present, old_usb_on; + bool old_online, old_present, old_usb_on, vbus_hold = false; u64 now = ktime_get_ns(), line_ns; mutex_lock(&chg->lock); @@ -1314,6 +1317,7 @@ static void tristar_poll(struct work_struct *work) chg->source[0] = '\0'; chg->source_ma = 0; chg->vbus_limit_ma = 0; + chg->vbus_read_errors = 0; chg->usb_ma = 0; chg->usb_type = POWER_SUPPLY_USB_TYPE_UNKNOWN; if (tristar_set_code(chg, chg->chip->handoff_code)) @@ -1343,24 +1347,41 @@ static void tristar_poll(struct work_struct *work) int mv, ret; ret = iio_read_channel_processed(chg->vbus, &mv); - if (!ret && chg->phase == TRISTAR_RAMPING) - dev_dbg(chg->dev, "VBUS %d mV at %u mA (target %u mA)\n", - mv, cur_ma, target_ma); - if (ret || mv < TRISTAR_VBUS_FAULT_MV || mv > TRISTAR_VBUS_MAX_MV) { - chg->vbus_fault = true; - chg->phase = TRISTAR_FAULT; - dev_warn(chg->dev, "VBUS guard tripped (sample %d mV, error %d)\n", - ret ? 0 : mv, ret); - } else if (mv < TRISTAR_VBUS_DROOP_MV) { - unsigned int limit_ma = cur_ma > fallback_ma + TRISTAR_RAMP_STEP_MA ? - cur_ma - TRISTAR_RAMP_STEP_MA : fallback_ma; - - chg->vbus_limit_ma = limit_ma; - chg->target_code = tristar_target_code(chg); - tristar_withdraw(chg, chg->target_code); - chg->phase = TRISTAR_CHARGING; - dev_info(chg->dev, "VBUS droop (%d mV at %u mA); capping input to %u mA\n", - mv, cur_ma, tristar_code_ma(chg, chg->target_code)); + if (ret) { + if (++chg->vbus_read_errors >= TRISTAR_VBUS_READ_RETRIES) { + chg->vbus_fault = true; + chg->phase = TRISTAR_FAULT; + dev_warn(chg->dev, + "VBUS guard tripped (sample 0 mV, error %d after %u attempts)\n", + ret, chg->vbus_read_errors); + } else { + dev_dbg(chg->dev, + "VBUS read error %d (%u/%u), holding step\n", + ret, chg->vbus_read_errors, + TRISTAR_VBUS_READ_RETRIES); + vbus_hold = true; + } + } else { + chg->vbus_read_errors = 0; + if (chg->phase == TRISTAR_RAMPING) + dev_dbg(chg->dev, "VBUS %d mV at %u mA (target %u mA)\n", + mv, cur_ma, target_ma); + if (mv < TRISTAR_VBUS_FAULT_MV || mv > TRISTAR_VBUS_MAX_MV) { + chg->vbus_fault = true; + chg->phase = TRISTAR_FAULT; + dev_warn(chg->dev, "VBUS guard tripped (sample %d mV, error 0)\n", + mv); + } else if (mv < TRISTAR_VBUS_DROOP_MV) { + unsigned int limit_ma = cur_ma > fallback_ma + TRISTAR_RAMP_STEP_MA ? + cur_ma - TRISTAR_RAMP_STEP_MA : fallback_ma; + + chg->vbus_limit_ma = limit_ma; + chg->target_code = tristar_target_code(chg); + tristar_withdraw(chg, chg->target_code); + chg->phase = TRISTAR_CHARGING; + dev_info(chg->dev, "VBUS droop (%d mV at %u mA); capping input to %u mA\n", + mv, cur_ma, tristar_code_ma(chg, chg->target_code)); + } } } } @@ -1397,7 +1418,8 @@ static void tristar_poll(struct work_struct *work) tristar_run_identification(chg, now); break; case TRISTAR_RAMPING: - tristar_ramp_step(chg, now); + if (!vbus_hold) + tristar_ramp_step(chg, now); break; case TRISTAR_CHARGING: tristar_guard(chg, now);