diff --git a/arch/arm64/boot/dts/apple/t8142-j813.dts b/arch/arm64/boot/dts/apple/t8142-j813.dts index c0b2d42c9dcc3..7af91983df777 100644 --- a/arch/arm64/boot/dts/apple/t8142-j813.dts +++ b/arch/arm64/boot/dts/apple/t8142-j813.dts @@ -397,3 +397,53 @@ "shared-l2", "gfx-data", "gfx1-data", "fw-data", "fw-text"; }; + +/* Touch ID uses SPI2, with power on NUB GPIO 36 and data ready on AP GPIO 200. */ +&pmgr { + ps_spi2: power-controller@440 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x440 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_spi_p>; + label = "spi2"; + }; +}; + +&{/soc} { + spi2: spi@3a5108000 { + compatible = "apple,t8142-spi", "apple,t8103-spi"; + reg = <0x3 0xa5108000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = ; + clocks = <&clkref>; + power-domains = <&ps_spi2>; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + mesa: fingerprint@0 { + compatible = "apple,mesa-fingerprint"; + reg = <0>; + spi-max-frequency = <8000000>; + spi-cpol; + spi-cs-setup-delay-ns = <20>; + spi-cs-hold-delay-ns = <20>; + enable-gpios = <&pinctrl_nub 36 GPIO_ACTIVE_HIGH>; + interrupt-parent = <&pinctrl_ap>; + interrupts = <200 IRQ_TYPE_EDGE_RISING>; + /* Per-device files, built from the Mac's own factory records. */ + firmware-name = "apple/mesacal-j813.bin", "apple/msrk-j813.bin"; + status = "okay"; + }; + }; +}; + +/* Expose the sensor's two pins next to the ones sound uses. */ +&pinctrl_ap { + gpio-reserved-ranges = <0 100>, <101 49>, <152 48>, <201 23>; +}; + +&pinctrl_nub { + gpio-reserved-ranges = <0 18>, <19 17>, <37 3>; +}; diff --git a/drivers/soc/apple/profile.rs b/drivers/soc/apple/profile.rs index 87904639a780f..29e74e2df0c57 100644 --- a/drivers/soc/apple/profile.rs +++ b/drivers/soc/apple/profile.rs @@ -501,17 +501,17 @@ pub(crate) const T8132: PlatformProfile = PlatformProfile { ..T8122 }; -/// MacBook Air 15" M5 (J815). The J815 ADT (macOS 27.0 stub firmware) puts +/// MacBook Air M5 (J813 and J815). Their ADTs (macOS 27.0 stub firmware) put /// the Mesa sensor (`V3`, the J700/J713/J714s generation) on spi2 at /// `0x3a5108000`, 8 MHz, chip select 0, with power on the NUB GPIO controller /// (pin 36) and data-ready on AP GPIO 200. The SEP is a pre-booted /// `iop-sep,ascwrap-v6` (`sepfw-booted`) behind a t8110 DART whose input /// aperture is the BIT(40) alias (`vm-base-0` 0x10000004000, `vm-size-0` /// 0xffff0000): the same SoC side as T8132 and T6050 (J714s, the M5 Pro). -/// So this is T8132's profile with the sensor bus moved. On J815 the SEP -/// attaches with it; the sensor session itself is not tested yet. +/// So this is T8132's profile with the sensor bus moved. J813 was tested +/// with explicit xart_guard=1; the inherited guard policy is unchanged. pub(crate) const T8142: PlatformProfile = PlatformProfile { - name: "T8142/J815", + name: "T8142/J813, J815", sensor: SensorProfile { controller_base: 0x3_a510_8000, ..T8132.sensor @@ -726,6 +726,30 @@ fn select( mod tests { use super::*; + #[test] + fn t8142_sensor_boards_require_the_matching_soc() { + assert_eq!(T8142.xart_guard, 1); + let cases: [(&[u8], &[u8], bool); 8] = [ + (b"apple,t8142", b"apple,j813", true), + (b"apple,t8142", b"apple,j815", true), + (b"apple,t8142", b"apple,j814", false), + (b"apple,t8142", b"apple,j704", false), + (b"apple,t8142", b"", false), + (b"", b"apple,j813", false), + (b"apple,t8132", b"apple,j813", false), + (b"apple,t6050", b"apple,j815", false), + ]; + for (soc, board, admitted) in cases { + let has = |c: &[u8]| c == soc || c == board; + let selected = select(&has, &|| &T6020); + if admitted { + assert!(matches!(selected, Ok(profile) if profile.name == T8142.name)); + } else { + assert!(selected.is_err()); + } + } + } + #[test] fn old_firmware_uses_the_legacy_key_store() { assert!(t6020_uses_sepos13(Some(b"iBoot-13822.79.1\0"))); @@ -813,7 +837,7 @@ mod tests { /// profile naming one of the known Mesa revisions. #[test] fn every_touch_id_mac_gets_a_sensor_the_shared_path_decodes() { - let macs: [&[&[u8]]; 16] = [ + let macs: [&[&[u8]]; 18] = [ &[b"apple,j313", b"apple,t8103"], &[b"apple,j316s", b"apple,t6000"], &[b"apple,j316c", b"apple,t6001"], @@ -830,6 +854,8 @@ mod tests { &[b"apple,j700", b"apple,t8140"], &[b"apple,j714s", b"apple,t6050"], &[b"apple,j716c", b"apple,t6050"], + &[b"apple,j813", b"apple,t8142"], + &[b"apple,j815", b"apple,t8142"], ]; for compatibles in macs { let has = |c: &[u8]| compatibles.iter().any(|x| *x == c); @@ -891,6 +917,7 @@ mod dart_window_tests { &T6041, &T6050, &T8132, + &T8142, ] { assert_eq!(offset(profile.dart_window), 1 << 40); assert_eq!(range(profile.dart_window), (0, 1 << 32));