Repository navigation
iio: aop: AOP accelerometer and gyroscope (J616s, ready for J713) - #680
Merged
Merged
Conversation
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>
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.
This adds the AOP accelerometer and gyroscope as IIO devices, one shared driver for every machine whose AOP announces the
accelandgyroservices. 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
accelandgyro. It also hands report subtypes 0xc1 and 0xc2 (what the T8132 firmware uses for motion) to the fake-HID listeners, like 0xc4.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.aop-sensors-accelandaop-sensors-gyro, each with raw X/Y/Z, a shared scale (m/s^2 and rad/s) andsampling_frequency. Samples are stored under a lock, so a read never mixes two reports.accelandgyrochildren on the T6040 AOP. J616s labels the accelerometeraccel-base(it's on the logic board), so desktops don't rotate the screen when the laptop tilts.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=1build ofdrivers/iio/common/aop_sensors/anddrivers/soc/apple/aop.o(defconfig + asahi.config, LLVM, rustc 1.97.1): no warnings.CLIPPY=1onaop_motion.o: nothing from the driver.checkpatch --strictper commit: 0 errors, 0 checks. The one warning is the usual "does MAINTAINERS need updating" on the driver commit; the files sit under the existingdrivers/iio/common/aop_sensors/entry.dt_binding_checkon both schemas: clean.CHECK_DTBSont6040-j616s.dtb: clean, with the nodes and label in the output.t8132-j713.dtbshows only its existing warnings.tools/testing/selftests/drivers/apple/aop-motion.pyruns the production decoder and calibration selector against synthetic reports and containers (4/4 pass).aop-las.pystill 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:
Rollback:
modprobe -r iio_aop_motionstops the reports (interval 0). Or boot the previous kernel.Open
nCalboot argument set to 1 is open.🤖 Generated with Claude Code