Skip to content

power: supply: macsmc-power: optionally wake from s2idle on charger plug/unplug (opt-in) - #456

Open
WilliamJohnDavisIII wants to merge 1 commit into
omacom:integration/aurorafrom
WilliamJohnDavisIII:macsmc-power-wake-on-charger
Open

WilliamJohnDavisIII wants to merge 1 commit into
omacom:integration/aurorafrom
WilliamJohnDavisIII:macsmc-power-wake-on-charger

Conversation

@WilliamJohnDavisIII

@WilliamJohnDavisIII WilliamJohnDavisIII commented Nov 11, 2026 •

Copy link
Copy Markdown

What

macOS wakes briefly when a charger is connected while the lid is closed and the Mac is asleep, so it can play the power chime. On Aurora the charger change is only noticed when the lid is next opened, so anything in userspace that reacts to AC changes (a sound, a notification) fires late.

The SMC keeps delivering notifications while the AP is in s2idle (the lid open event 0x72030001 already wakes the system this way through macsmc-input). This patch has macsmc-power treat connector insert/remove events (0x7113xxxx) received while suspended as a wakeup event.

It is opt-in: the driver marks the device wakeup-capable but leaves wakeup disabled, so nothing changes unless userspace enables it:

echo enabled > /sys/devices/platform/soc/*.smc/macsmc-power/power/wakeup

or with a udev rule:

ACTION=="bind", SUBSYSTEM=="platform", DRIVER=="macsmc-power", ATTR{power/wakeup}="enabled"

Events seen while suspended are logged with dev_dbg.

Event codes seen while suspended (j313)

Action Events (in order)
Plug in 70200000 71130103 71060100 71060000 71010101 71060100 71060000 71130104 71130103 71130103 71060100
Unplug 71020000 71010100 71060000 71060100 71130102 70200000 71130103 7113ff04
Lid open 72030001 (plus sometimes 71020000)

Only 0x7113xxxx triggers the wake. 71010101/71010100 look like "charger attached/detached" and could be used to wake on plug-in only, but waking on both matches what userspace sees while awake.

Testing

  • Apple MacBook Air (M1, 2020), apple,j313 / apple,t8103
  • linux-aurora 7.2.11.aurora14-1, OS firmware 13.5
  • Built as an out-of-tree module against the package headers.
  • With wakeup enabled, lid closed and suspended for 1–15 minutes:
    • plugging in wakes the system immediately, and the AC online change reaches userspace;
    • unplugging does the same;
    • with the lid still closed, logind suspends again after its holdoff (~30 s), so the machine doesn't stay awake in a bag.
  • With wakeup disabled (the default), behaviour is unchanged.
  • checkpatch.pl --strict: no errors or warnings.

Battery charging during s2idle was already working before this patch; the SMC handles it on its own. This only affects when the AP finds out.

Disclosure

This patch was written with the help of an AI coding assistant, and tested on my own hardware as described above.

macOS wakes briefly when a charger is connected while the system is
asleep, so it can play the power chime. On Linux the AC state change is
only noticed once something else wakes the system, so userspace that
reacts to it (a sound, a notification) fires late.

The SMC keeps delivering notifications while the AP is in s2idle; the
lid open event already wakes the system this way via macsmc-input.
Track when the device is between PM prepare and complete, and treat
connector insert/remove events (0x7113xxxx) received in that window as
a wakeup event.

The device is only marked wakeup-capable, so this is opt-in through
power/wakeup and the default behaviour is unchanged. Events seen while
suspended are logged at debug level.

Tested on a MacBook Air (M1, 2020, j313): with wakeup enabled, plugging
in or removing the charger with the lid closed wakes the system, and
logind suspends it again after its holdoff timeout.

Signed-off-by: William John Davis III <58375683+WilliamJohnDavisIII@users.noreply.github.com>
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.

1 participant