Skip to content

AOP: make the T6040 accelerometer and gyroscope report - #745

Merged
RyanTheTide merged 2 commits into
aurora-wipfrom
fix/aop-t6040-ncal
Nov 1, 2026
Merged

RyanTheTide merged 2 commits into
aurora-wipfrom
fix/aop-t6040-ncal

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

This series makes the M4 Pro (J616s, T6040) accelerometer and gyroscope report on Linux.

Root cause

drivers/soc/apple/aop.rs patches the AOP firmware's boot arguments with nCal 0 on every SoC. The T6040 firmware (aopfw-mac16jaop, macOS 27.0 26A428) ships a boot argument table in its _rtk_patchbay section, and its own value there is nCal 1, a 1-byte field. With 0, the accel and gyro services:

  • accept the calibration (props 75/76/77) and the report interval (prop 0),
  • configure the BMI286: gyro prop 0x16 goes 0 -> 20000, the ODR prop goes 0 -> 1250 us,
  • but never send an EPIC report.

So aop-sensors-accel and aop-sensors-gyro bind and read ENODATA forever. Eryk's working J713 dirty-room driver sets ncal: 1 for T8132 and nothing else that differs.

Changes

  1. soc: apple: aop: nCal becomes per-SoC data. T6040 writes the firmware's default, 1; T8103/T8112/T6000/T6020 keep 0, and T8140 doesn't patch boot arguments. The docs get a troubleshooting note.
  2. iio: aop: motion: on a second start in the same AOP boot (rebind, or resume through the PM notifier), the firmware answers props 75/76 with kIOReturnUnsupported (0xe00002c7), accepts 77, and keeps its calibration.
    • Before: the driver failed probe with EIO and never restarted the reports after resume.
    • Now: that status counts as "held". The driver logs one info line and starts the reports. Any other non-zero status still fails.
    • The status decision is covered in aop-motion.py.

Hardware (J616s, 7.3.0-aurora-tt3 with the patched aop.ko and aop_motion.ko)

  • Accel at rest (291 samples): |a| = 9.64 m/s^2 (9.62 to 9.65), raw about (36, 2429, -64316).
  • Gyro: static bias about 0.4 deg/s, in 4000-count steps (0.061 deg/s, the BMI's LSB at +-2000 deg/s).
  • Rebind:
    • Stock driver: property 75 refused: status 0xe00002c7, probe -5 on both devices.
    • Patched driver: both devices bind and report fresh samples.
  • Unchanged: ALS (423 lux), lid angle (98 deg), all three DCPs with eDP plus two DP, audio cards probe (no playback). journalctl -b -p 3 is empty.
  • Long run at rest, 10:49 to 11:08, final aop_motion.ko (10804 samples at 10 Hz): |a| mean 9.638 m/s^2 (9.62 to 9.74), gyro mean (0.40, -0.05, 0.08) deg/s. The samples stay live and noisy throughout.
  • Not done yet, follow-ups: a physical tilt/rotation test, and the mapping from sensor axes to chassis axes. Ryan is away from the machine today. These sensors exist only on T6040 (t6040.dtsi is the only DT with apple,aop-accel/gyro), so nothing else is affected.

Tests

  • tools/testing/selftests/drivers/apple/aop-motion.py: 5/5 pass, including the new calibration_status.
  • Both modules build with W=1 against the tt3 tree, and rustfmt --check is clean.
  • aop-las.py already fails on aurora-wip 5caa4ea (ValueError: substring not found in its source extraction). That is unrelated to this series and left alone.
  • Other SoCs: patch 1 leaves their boot arguments byte-identical. Patch 2 only changes behaviour when the firmware returns 0xe00002c7, which used to fail the probe.

🤖 Generated with Claude Code

The AOP core writes nCal 0 into the firmware's boot arguments on every
SoC whose arguments it patches. The T6040 firmware's own default for it,
in the boot argument table it ships with, is 1. With 0, its
accelerometer and gyroscope services accept the calibration and the
report interval, and the sensor starts sampling, but no report ever
reaches the application processor, so both IIO devices read ENODATA.

Make nCal part of the per-SoC data and write the firmware's default, 1,
on the T6040. The other SoCs keep 0. The T6040 comment claimed macOS
writes the same arguments as on the T6020; that is not established for
nCal, so drop it. Note the symptom in the AOP sensor documentation.

On J616s (7.3.0-aurora-tt3), both devices report with this change.
The accelerometer at rest reads |a| = 9.64 m/s^2 (291 samples, 9.62
to 9.65), and the gyroscope shows a static bias of about 0.4 deg/s.
ALS, lid angle, the three DCPs and the audio cards are unchanged, and
the boot logs no errors.

Fixes: e82a608 ("soc: apple: aop: Add T6040 support")
Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T6040 firmware takes a service's calibration once per AOP boot.
When it is sent again, after a rebind or on resume, the firmware
answers the range-intrinsic and nominal-extrinsic writes with
kIOReturnUnsupported (0xe00002c7), accepts the range-extrinsic one and
keeps the calibration it holds. The driver treated that status as a
failure. A rebind then failed with EIO, and after resume the reports
were not restarted.

Treat that status on a calibration write as "already held", log how
many packets were kept, and go on to the report interval. Any other
non-zero status still stops the start. Cover the status decision in
the host selftest. This has been measured on the T6040 only.

On J616s, rebinding the stock driver fails with "property 75 refused:
status 0xe00002c7" on both devices. With this change both devices bind
again and report fresh samples.

Fixes: d2da58e ("iio: aop: Add the accelerometer and gyroscope driver")
Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide merged commit 3412c75 into aurora-wip Nov 1, 2026
@RyanTheTide
RyanTheTide deleted the fix/aop-t6040-ncal branch November 1, 2026 00:10
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Motion test result: Ryan ran it on J616s at 11:09, on battery and Wi-Fi with the machine on his lap. 401 samples at about 10 Hz were logged on the machine with this series' aop.ko and aop_motion.ko.

  • Accel, tilt from gravity:
    • x/z swung -85 to +72 deg for a left/right tilt of about 90 deg.
    • y/z swung -53 to +44 deg for a front lift.
    • |a| ranged 7.5 to 12.8 m/s^2 during motion and was 9.6 m/s^2 at rest.
  • Gyro ranges, deg/s:
    • x: -94 to +123
    • y: -155 to +167
    • z: -30 to +100
  • Integrating gyro z over the run gives 92 deg for his quarter-turn spin, so the Q16 deg/s scale is right.
  • Sensor-frame axes as observed: x = roll (left/right), y = pitch (front/back), z = yaw (up). Mapping these to the chassis frame (mount matrix) is still a follow-up.

🤖 Generated with Claude Code

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