Repository navigation
iio: apple: AOP fused motion (devmotion6) and board temperature (als-temp) on the M4 Pro - #1247
Conversation
The J616s AOP announces two sensor services Linux left unclaimed: devmotion6, the always-on processor's six-axis fusion output, and als-temp, a board temperature sensor next to the light sensor. Claim them in the AOP core and expose them through IIO: the fused orientation as a quaternion (W/X/Y/Z, signed Q30, 50 Hz) and the board temperature in millidegrees Celsius (1 Hz). Stop both streams across system sleep and restart them on resume. Optional temperature calibration comes from bootloader-filled DT properties; without it the sensor runs on its own defaults. Add the T604x AOP child nodes and their bindings. The wakehint and cma services stay unclaimed: wakehint is a single vendor byte with no established meaning, and cma is a CoreMotion command and history transport rather than a sensor. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Select the AOP firmware's built-in calibration state before enabling the devmotion6 interval. AppleSPUHIDDriver performs this generic state write even though the fused service has no calibration blob; an interval alone is accepted but leaves the service silent. Keep the state across sleep and restore only the interval on resume, matching the macOS power path. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
On the J616s the devmotion6 service answers the calibration-state write with the 'unsupported' status the other AOP sensor services use when they already hold their calibration from an earlier start in the same AOP session. Treat it the same way instead of failing the probe. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
devmotion6 does not stream over fake-HID reports. Its reports arrive in a per-service shared-memory fast path that the AP must open before the report interval does anything. Read the payload size from property 81, allocate a coherent two-slot ping-pong buffer, open the client with EPIC command 25, then set the interval. Poll the published slot for new reports. On sleep and unbind, clear the interval and close the client with command 26; on resume, open a new client before restoring the interval. If an open or close outcome is unknown, keep the DMA mapping, since the firmware may still hold it. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
The firmware answers the client-open (25) and client-close (26) commands with reply subtypes 0x99 and 0x9a: the request subtype with bit 7 set, like the existing 0x84 and 0x8a replies. The core only matched the older subtypes, so it dropped these replies and the caller timed out. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
The firmware writes the fast-path ring, so the ring has to be mapped through the AOP core's own DART stream. The service device has no DMA setup, and the allocation on it failed with -ENOMEM. Allocate on the parent AOP device instead. The payload-size property also answers with 32 bits on the M4 Pro, not 64, which failed the probe with a silent -EIO. Accept either width, and log the reply length when it is too short. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
The M4 Pro firmware sends 52-byte type 3 reports, while the decoder only took type 3 and 4 reports of exactly 60 bytes. It treated every report as a state report and the device never produced a sample. The length varies with the firmware, so require only that the quaternion fits. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
The interval in property 0 does not pace the fast-path buffer. The firmware stores whatever is written there, but it refreshes the shared slots at the fusion engine's own rate, every 5 ms on the M4 Pro, for every value from 20 us to 20 s and even for zero, until the client is closed. The driver opened the client at probe and polled the buffer every 5 ms for the rest of the boot, with or without a reader. Open the client only while samples are consumed: when the IIO buffer is enabled, and briefly for a direct read, which waits up to 100 ms for the first sample and closes the client again. Poll at the requested rate, exposed as sampling_frequency (default 50 Hz, 1 to 200 Hz), and still write the matching interval for the firmware's record. Suspend now closes and resume reopens only a client that was open, and a stopped client's last sample is never returned to a later reader. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
When the AOP starts the fusion engine, the service publishes the exact identity quaternion until its filter has a first estimate, about 140 ms (23 reports) on the M4 Pro. Since the client is now opened on demand, a direct read right after a cold start returned that placeholder as the orientation. Do not report a bit-exact identity quaternion, which a measured attitude never is, and let a direct read wait up to 500 ms for a real estimate. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Picks up the tools/aurora-sep source-check fix (c60537c) and the current release branch, so CI runs against today's base. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
The T6040-only AOP children moved from t604x.dtsi to t6040.dtsi (c5fd88e). Put devmotion6 and als-temp next to accel and gyro in the t6040.dtsi &aop block, so the J614s and J616s keep them and the J616c tree does not gain unqualified nodes. Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
Hardware receipts (J616s, 11-09 03:41-03:52)Setup: one-shot kernel
Still not verified: attitude change under real motion. Nobody was at the machine, so this needs a tilt/lid test by hand; at rest the attitude is stable and the norm stays at 1. DT delivery: the J616s boots the DTB inside Stage 2. These nodes reach users with the next J616s Stage 2 DTB refresh (DT lane), which composes from the integration DTB after this merges. Until then the drivers stay unbound, which is harmless. |
Supersedes #1054 (same commits,
surp/aop-servicesat7949de52). #1054 conflicted with integration/aurora, so this branch merges integration in (no rebase, no force push):1f392cd2merges integration1fadde6a(the fleet37 base). The only conflict: c5fd88e moved the T6040-only AOP children (accel, gyro) fromt604x.dtsitot6040.dtsi.devmotion6andals-tempnow sit next to them in thet6040.dtsi&aopblock, so the J614s and J616s get them and the J616c tree gains nothing.7918e6cemerges integration9c607045(clean).What
Two AOP sensor services on the M4 Pro (J616s) that Linux left unclaimed:
als-temp: a board temperature sensor next to the ambient light sensor, exposed as an IIO temperature channel (in_temp_input, millidegrees Celsius, 1 Hz, buffered with timestamp). Optional calibration comes from bootloader-filled DT properties; without it the sensor runs on its own defaults (debug message only).devmotion6: the always-on processor's six-axis fusion output, exposed as an IIO quaternion (in_rot_quaternion_raw, W/X/Y/Z signed Q30, buffered with timestamp).devmotion6does not use fake-HID reports. Its reports arrive in a per-service shared-memory fast path that the host opens:The firmware stores property 0 but refreshes the slots at the fusion engine's fixed rate (every 5 ms on the M4 Pro) until the client is closed, whatever the interval says. So the host paces itself:
sampling_frequency(default 50 Hz, 1 to 200 Hz) sets the poll period, and the client is open only while samples are consumed. Enabling the IIO buffer opens it and disabling it closes it (interval 0, then command 26). A direct read without a buffer opens the client, waits for the first estimate and closes it again. Sleep closes an open client and resume reopens it; unbind closes it for good. If an open or close outcome is unknown, the buffer stays mapped. The AOP core now routes the 0x99/0x9a replies to commands 25/26, which it used to drop. The AOP core claims just these two names;wakehint(one opaque vendor byte) andcma(a command and history transport, not a sensor) stay unclaimed on purpose. T604x AOP child nodes and bindings included.Testing (J616s, 11-07)
Setup: one-shot trial Stage 2 (the live DTB plus the two child nodes) and a one-shot kernel,
7.3.0-aurora-aop2b= fleet17 source + this branch at3b980a29, fleet17 config. fleet17 stayed the default; the machine went back to fleet17 and the production Stage 2 afterwards.devmotion6streams from boot. A buffered capture gave 150 samples with |q|² = 1.000000 and monotonic timestamps. Example report (52-byte type 3, laptop flat, lid at 86°): W +0.99983, X -0.01851, Y +0.00024, Z +0.00000.rtcwake -m freeze). The close and reopen are acknowledged, with no AOP or driver messages, and samples resume after each wake. The attitude re-converges to slightly different values each time.als-temp: 21.4 °C, steady, survives s2idle.aop_devmotion.rs,aop_temp.rsoraop.rs. rustfmt is clean on those files. Binding checks passed earlier.The hardware run found three bugs, now fixed on this branch:
A fourth fix was needed after that: the decoder required 60-byte type 3 reports, but the M4 Pro sends 52-byte ones.
Rate and on-demand client (11-07,
091f105d+5a685b33)091f105d: no consumer means no poll work at all (it used to be every 5 ms for the whole boot). Direct reads take 8-19 ms. The buffer runs at 47.6 / 166 / 9.6 Hz for 50 / 200 / 10 Hz requested (jiffy rounding; the firmware caps it at 200). Disabling the buffer stops the polling. Three s2idle cycles (rtcwake -d rtc1), with the buffer on and with it off, all resumed cleanly.5a685b33skips that placeholder and lets a direct read wait up to 500 ms. Retest (12:51-12:58): the first read after boot returns a real estimate in 157 ms and later ones take 7-8 ms. Rates, s2idle and boot log are unchanged from the run above.Still open
🤖 Generated with Claude Code