Skip to content

iio: aop: AOP accelerometer and gyroscope (J616s, ready for J713) - #680

Merged
RyanTheTide merged 4 commits into
aurora-wipfrom
feat/aop-motion-20261031
Oct 31, 2026
Merged

RyanTheTide merged 4 commits into
aurora-wipfrom
feat/aop-motion-20261031

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

This adds the AOP accelerometer and gyroscope as IIO devices, one shared driver for every machine whose AOP announces the accel and gyro services. It is based on Eryk Wieliczko's J713 work (dirtyroom-linux 63e6467), which first got both sensors reporting at 50 Hz on the M4 MacBook Air. The driver is written fresh against the current aurora-wip AOP API.

@erykwieliczko, please review. You're welcome to add your own Signed-off-by.

What it does

  • AOP core: creates service devices for accel and gyro. It also hands report subtypes 0xc1 and 0xc2 (what the T8132 firmware uses for motion) to the fake-HID listeners, like 0xc4.
  • Driver (iio_aop_motion): at probe it sends the three calibration packets (properties 75, 76, 77, each the location 0 entry of its container), then a 20000 us report interval. Reports are 22 bytes with signed LE i32 X/Y/Z at byte 6, in Q16 g or Q16 deg/s.
  • IIO: aop-sensors-accel and aop-sensors-gyro, each with raw X/Y/Z, a shared scale (m/s^2 and rad/s) and sampling_frequency. Samples are stored under a lock, so a read never mixes two reports.
  • Buffered capture: a kfifo buffer takes X, Y and Z together, with an optional timestamp taken when the report arrives.
  • Suspend/resume: a PM notifier sets the interval to 0 before sleep, so the AOP doesn't wake the AP 50 times a second. It resends the calibration and interval on wake.
  • Calibration from the machine, not the DT source: the packets come from the Apple device tree, and m1n1 copies them into the node at boot (companion PR kboot: Pass the AOP motion sensor calibration to the OS m1n1#61). No DT source carries calibration bytes. Without them the driver stays off and says so once.
  • DT: accel and gyro children on the T6040 AOP. J616s labels the accelerometer accel-base (it's on the logic board), so desktops don't rotate the screen when the laptop tilts.
  • Binding: new iio/imu/apple,aop-motion.yaml, with T6041 and T8132 compatibles. It is referenced from the T6041 AOP binding.

The Neo gets no nodes, because its ADT has no motion services.

J713 gets no nodes yet either. Its AOP node isn't on aurora-wip, and the driver and binding already carry the T8132 compatibles for when it lands.

Testing

  • W=1 build of drivers/iio/common/aop_sensors/ and drivers/soc/apple/aop.o (defconfig + asahi.config, LLVM, rustc 1.97.1): no warnings.
  • CLIPPY=1 on aop_motion.o: nothing from the driver.
  • rustfmt clean.
  • checkpatch --strict per commit: 0 errors, 0 checks. The one warning is the usual "does MAINTAINERS need updating" on the driver commit; the files sit under the existing drivers/iio/common/aop_sensors/ entry.
  • dt_binding_check on both schemas: clean.
  • CHECK_DTBS on t6040-j616s.dtb: clean, with the nodes and label in the output. t8132-j713.dtb shows only its existing warnings.
  • Host tests: tools/testing/selftests/drivers/apple/aop-motion.py runs the production decoder and calibration selector against synthetic reports and containers (4/4 pass). aop-las.py still passes.

Not tested on hardware yet. It needs a kernel with this series and an m1n1 stage 2 with the companion change. On the J616s:

dmesg | grep -iE "aop|accel|gyro"            # expect no "sensor left off"
for d in /sys/bus/iio/devices/iio:device*; do echo $d $(cat $d/name); done
cat /sys/bus/iio/devices/iio:deviceN/in_accel_{x,y,z}_raw   # flat: about 65536 on one axis
cat /sys/bus/iio/devices/iio:deviceN/in_anglvel_{x,y,z}_raw # still: near 0, tracks rotation

Rollback: modprobe -r iio_aop_motion stops the reports (interval 0). Or boot the previous kernel.

Open

  • Axis mapping: the axes are the sensor's. A mount matrix needs six static orientations on the J616s.
  • Scale accuracy: the scale is the Q16 convention (9.80665/65536 m/s^2, pi/(180*65536) rad/s), unverified against a reference.
  • J713: depends on its AOP node. Whether its firmware also wants the nCal boot argument set to 1 is open.
  • devmotion6 (fused) and als-temp are not covered.

🤖 Generated with Claude Code

The Always-On Processor of Apple laptops reads the machine's inertial
sensor and reports acceleration and angular rate as two services. Describe
their child nodes, and allow them under the T6041 AOP.

A service starts reporting only once it has been sent the machine's three
calibration packets. They are machine data from the Apple device tree, so
the bootloader fills them in at every boot and the device tree sources
carry none.

Based on Eryk Wieliczko's J713 work (dirtyroom-linux 63e6467).

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Create service devices for the "accel" and "gyro" services the AOP
firmware announces, so that their driver can bind to the matching device
tree children.

The T8132 firmware sends its motion samples with report subtypes 0xc1
(gyroscope) and 0xc2 (accelerometer) besides the fake-HID 0xc4, all with
the same payload, so hand those to the fake-HID listeners too.

Based on Eryk Wieliczko's J713 work (dirtyroom-linux 63e6467), which
found both the services and the report subtypes.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Add one driver for the AOP accelerometer and gyroscope, matched by the
generic apple,aop-accel and apple,aop-gyro compatibles, so every machine
with the services shares it.

At probe the driver sends the three calibration packets the bootloader
copied from the Apple device tree (properties 75, 76 and 77, each the
location 0 entry of its container), then a 20000 us report interval. A
sample report is 22 bytes with X, Y and Z as signed little-endian 32-bit
values at byte 6, in 1/65536 g or 1/65536 degree per second. Without the
calibration the driver leaves the sensor off and does not bind.

Each sensor is an IIO device with raw X, Y and Z channels, a fixed scale
in m/s^2 or rad/s and its sampling frequency. Samples are stored under a
lock so a read never mixes two reports. A kfifo buffer takes X, Y and Z
together with a timestamp taken when the report arrives, which is what
iio-sensor-proxy and other buffer users read.

Around system sleep the driver sets the interval to zero, so the AOP does
not wake the application processor 50 times a second, and resends the
calibration and interval on wake.

Host tests run the production decoder and calibration selector against
synthetic reports and containers.

Based on Eryk Wieliczko's J713 driver (dirtyroom-linux 63e6467), which
first got both sensors reporting at 50 Hz on the M4 MacBook Air.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Add the accel and gyro children of the T6040 AOP. The bootloader adds
their calibration from the Apple device tree. On the J616s the sensor is
on the logic board, so label the accelerometer accel-base, which keeps
desktops from rotating the screen when the laptop tilts.

Enable the driver in asahi.config.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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