iio: aop_sensors: aop_als: make calibration firmware optional#457
iio: aop_sensors: aop_als: make calibration firmware optional#457juicecultus wants to merge 3 commits intoAsahiLinux:fairydustfrom
Conversation
Implement atcphy_configure_pipehandler_usb4() to enable USB4/Thunderbolt PHY mode on Apple Silicon. Previously this fell back to USB2 with a warning, preventing Thunderbolt displays from working. The USB4 pipehandler follows the same BIST sequence as USB3 but switches the PIPE mux to USB4 (CLK=2, DATA=1 vs USB3 CLK=1, DATA=0). The CIO tunables for USB4 lane configuration are already loaded from the ADT. Derived from clean-room analysis of m1n1 hypervisor traces capturing macOS 13.5 hardware register access on T8112 (M2 MacBook Air). Observed macOS PHY transition sequence: 1. USB2 PHY init in host mode on port 2. DWC3 controller configured as host 3. USB2 PHY teardown (isolation, power down, clock gating) 4. USB4 pipehandler mux + BIST sequence (this patch)
…river skeleton
Add initial driver and DT nodes for the Apple ACIO Thunderbolt/USB4
host controller found in Apple Silicon SoCs.
The ACIO is a platform-based Thunderbolt controller consisting of:
- NHI-like register space for ring buffer DMA
- IOP coprocessor running Thunderbolt firmware via RTKit
- DART (IOMMU) for DMA isolation
- Connection to ATC PHY for USB4 physical layer
This initial commit includes:
- DT nodes for T8112 (M2): acio0/1, dart-acio0/1, acio-cpu0/1
(disabled by default until driver is ready)
- Platform driver skeleton that probes NHI registers and reads caps
- Kconfig/Makefile integration as CONFIG_APPLE_ACIO
- RTKit callback stubs for IOP coprocessor communication
Hardware addresses derived from clean-room analysis of macOS ioreg
device tree dumps on T8112 (M2 MacBook Air 15-inch).
TODO:
- Boot IOP coprocessor via RTKit
- Initialize ring buffers for Thunderbolt control channel
- Bridge to Linux thunderbolt subsystem for tunnel management
- Enable PCIe/DP/USB3 tunneling
The ALS driver currently fails to probe if apple/aop-als-cal.bin is missing. On many Apple Silicon machines (particularly M2 MacBook Air), the calibration data is not available in the Apple Device Tree and must be extracted separately from a macOS ioreg dump. Make the calibration step non-fatal: - If the firmware file is present, send it as before. - If missing, send an empty calibration command and log a warning. - Ignore the AOP's error response to the calibration command (the AOP returns 0xE00002BC even for valid calibration data from macOS). - Always proceed to set the polling interval, which activates the sensor stream. Without this change, the ALS sensor is completely unusable on systems where the calibration file has not yet been provisioned. Tested on MacBook Air 15" M2 (J415) with VD6286 sensor: - Without cal file: sensor activates, reports lux values (uncalibrated) - With cal file extracted from macOS: sensor reports calibrated values Signed-off-by: Justin <justin@juicecultus.dev>
|
We intend to handle the calibration files correctly and not use empty calibrations. AsahiLinux/asahi-installer#406 |
|
Thanks for the pointer to AsahiLinux/asahi-installer#406 — that's clearly the right approach. Happy to close this PR in favour of the installer-based extraction. A couple of data points from our testing that may be useful:
Closing this PR in favour of the installer approach. |
|
btw, there's strong anti ai policy in this project, be aware of that. |
I regret to inform you that it appears that you have re-invented the wheel in this case. KDE Plasma already supports ambient light sensors natively, by going into "display & monitor" settings and enabling "Automatically adapt to environment". If you do not see that option - install "iio-sensor-proxy", then log out and log back in. |
Summary
Make the ALS (Ambient Light Sensor) calibration step non-fatal so the
aop_alsdriver can probe successfully even whenapple/aop-als-cal.binis not present.Problem
The ALS driver currently fails to probe if the calibration firmware file is missing. On many Apple Silicon machines (particularly M2 MacBook Air), the calibration data is not embedded in the Apple Device Tree and must be extracted separately from a macOS
ioregdump. This means the ALS sensor is completely unusable out of the box.Changes
0xE00002BCeven for valid calibration data extracted from macOS)Testing
Tested on MacBook Air 15" M2 (J415) with VD6286 sensor, Asahi Fedora 42, kernel 6.18.10-402:
/sys/bus/iio/devices/iio:device1/in_illuminance_inputandiio-sensor-proxyRelated
Calibration extraction tool and auto-brightness userspace daemon: https://github.com/juicecultus/asahi-auto-brightness