Repository navigation
ARM: apple: Add s2idle suspend/resume support for 32-bit Apple S5L SoCs - #161
Merged
Merged
Conversation
Add a cpuidle driver for 32-bit Apple S5L894x/S5L895x SoCs so suspend-to-idle (s2idle) reaches cpuidle_enter_s2idle(), freezes the tick and timekeeping, and stops CLOCK_MONOTONIC from advancing during sleep. Delegates to arch_cpu_idle() rather than raw cpu_do_idle() so secondary cores keep entering apple_s5l_idle() (cpu_suspend + L1 clean) instead of plain WFI, which powers off CPU1 and loses its L1 state on S5L894x/S5L895x. Signed-off-by: Alistair Reay <alistair.reay@gmail.com>
Two pieces suspend-to-idle needs from AIC1 on 32-bit Apple S5L SoCs: - aic1_chip has no irq_set_wake, so enable_irq_wake() on its interrupts (and on GPIO interrupts forwarded to it) failed. Set IRQCHIP_SKIP_SET_WAKE: wake interrupts stay enabled through s2idle and wake the CPU. - Register AIC1's 64-bit 24 MHz timebase as the apple-aic1-time clocksource with CLOCK_SOURCE_SUSPEND_NONSTOP, so CLOCK_BOOTTIME advances accurately across long sleeps while CLOCK_MONOTONIC stays frozen. [Orchard: split by subsystem out of "ARM: apple: Support s2idle wake IRQs, nonstop clocksource, and WDT pause" (linux#161)] Signed-off-by: Alistair Reay <alistair.reay@gmail.com>
Implement irq_set_wake by forwarding it to the controller's parent AIC1 interrupt, so GPIO lines marked wakeup-source (gpio-keys buttons) can wake the SoC from suspend-to-idle. [Orchard: split by subsystem out of "ARM: apple: Support s2idle wake IRQs, nonstop clocksource, and WDT pause" (linux#161)] Signed-off-by: Alistair Reay <alistair.reay@gmail.com>
Nothing pets the 60 s hardware reset watchdog while the system is suspended to idle. Stop the watchdog on PM_SUSPEND_PREPARE and re-arm and ping it on PM_POST_SUSPEND, so sleeps longer than the timeout do not reset the device. [Orchard: split by subsystem out of "ARM: apple: Support s2idle wake IRQs, nonstop clocksource, and WDT pause" (linux#161)] Signed-off-by: Alistair Reay <alistair.reay@gmail.com>
Queue the charger's periodic I2C polling, and the immediate re-run a USB host report triggers, on system_freezable_wq, so the work freezes cleanly during suspend instead of touching the PMU while devices are suspended. [Orchard: split by subsystem out of "ARM: apple: Support s2idle wake IRQs, nonstop clocksource, and WDT pause" (linux#161), and applied to all three places the reworked driver from linux#139 queues its work] Signed-off-by: Alistair Reay <alistair.reay@gmail.com>
… cpuidle Enable CONFIG_SUSPEND and CONFIG_ARM_APPLE_S5L_CPUIDLE in orchard_applearmv7_defconfig, for suspend-to-idle on the 32-bit Apple S5L boards. [Orchard: dropped CONFIG_PM_DEBUG, a debugging aid (pm_test and friends) that s2idle does not need] Signed-off-by: Alistair Reay <alistair.reay@gmail.com>
…nd mini Like the iPad 3, let the Home and Hold (power) buttons wake the iPad 2 (K93 family) and the iPad mini 1 (P105) from suspend-to-idle. The GPIO controller forwards wake requests to AIC1, so a press on either button wakes the SoC. The iPhone 5 boards describe no buttons yet. Assisted-by: LLM Signed-off-by: Henrik Klee <henrik@goat-code.com>
henrikklee
force-pushed
the
apple-s5l-s2idle
branch
from
December 4, 2026 21:46
0d40c15 to
b57c373
Compare
|
Thanks a lot, @alistairreay! Merged. With this, the 32-bit boards can suspend to idle: the new cpuidle driver, wake interrupts through AIC1 and the GPIO controller, a clocksource that keeps counting through sleep, and the watchdog paused while asleep. What we changed on your branch:
Nothing was left out. Open follow-up: the watchdog is stopped from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds suspend-to-idle (
s2idle) support for 32-bit Apple S5L894x/S5L895x SoCs, matching Orchard's arm64cpuidle-apple+docs/bring-up/suspend.mdarchitecture.Changes
cpuidle: apple-s5l: Add WFI and s2idle driver for 32-bit Apple S5L SoCsWFI(state 0) andWFI-S2IDLE(state 1, withenter_s2idle) sos2idleenterscpuidle_enter_s2idle(), freezes ticks and timekeeping, and stopsCLOCK_MONOTONICfrom advancing during sleep (preventing systemd watchdog kills after >3 min sleeps).arch_cpu_idle()rather than rawcpu_do_idle()so secondary cores keep takingapple_s5l_idle()(cpu_suspend()+ L1 flush) instead of plain WFI, which causes PMGR to power off CPU1 and lose dirty L1 cache lines.ARM: apple: Support s2idle wake IRQs, nonstop clocksource, and WDT pausedrivers/irqchip/irq-apple-aic1.c: setsIRQCHIP_SKIP_SET_WAKEonaic1_chip, and registers AIC1's 64-bit 24 MHz timebase (apple-aic1-time, rating 360) withCLOCK_SOURCE_SUSPEND_NONSTOPsoCLOCK_BOOTTIMEadvances accurately across arbitrarily long sleeps whileCLOCK_MONOTONICstays frozen.drivers/pinctrl/pinctrl-s5l8940x-gpio.c: implementsirq_set_wakeforwarding to the parent AIC1 IRQ (pctl->irqs[0]) sowakeup-sourceGPIO buttons wake the SoC froms2idle.arch/arm/mach-apple/apple_wdt_clkevt.c: pauses the 60 s hardware reset watchdog onPM_SUSPEND_PREPAREand re-arms/pings it onPM_POST_SUSPENDso sleeps longer than 60 s do not reset the device.drivers/power/supply/apple-pmu-charger.c: queues periodic I2C polling onsystem_freezable_wqso it freezes cleanly across suspend.ARM: configs: orchard_applearmv7: Enable s2idle suspend and Apple S5L cpuidleCONFIG_SUSPEND,CONFIG_PM_DEBUG, andCONFIG_ARM_APPLE_S5L_CPUIDLE.Live hardware verification (64 GB iPad 3 /
iPad3,3/j2a, dual-core A5X SMP)Tested together with
wakeup-source;on Home & Hold in #152:pm_test=devicesandpm_test=platform: PASS (success=2, fail=0).46.05 s): woke cleanly on Home (pm_wakeup_irq=57), sameboot_id.85.4 s, past the 60 s WDT): woke cleanly on Hold/Power (pm_wakeup_irq=58), sameboot_id.294.4 s/ ~4m 54s wall time, dual-core SMP +apple_s5l_cpuidle+apple-aic1-time):boot_id=ed91bf58-896e-42fb-98a1-e08e72950019unchanged,suspend_stats:success=1 fail=0,pm_wakeup_irq=58(Hold/Power).CLOCK_MONOTONICfrozen during sleep (dmesg: suspend[41.636176]→ resume[41.839688], only0.20 selapsed).CLOCK_BOOTTIME(/proc/uptime) advanced accurately:39.91 s→359.76 s.s2idleidle state counters incremented on both cores (cpu0/state1/s2idle/usage=2,cpu1/state1/s2idle/usage=1,apple_smp.powerdowns=3320).apple-wdtcleanly re-armed on wake (ctrl 0x4).1658,bl_power=0), USB gadget re-enumerated and renegotiated2400 mAApple host grant,brcmfmacreloadedBCM4330/4firmware (wlan0up), battery HDQ live (100% Full), NAND/dev/applesftl0p1intact, zero warnings/errors/stalls.