Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions arch/arm64/boot/dts/apple/t8142-j813.dts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@
aliases {
wifi0 = &n1_alpha;
bluetooth0 = &n1_beta;
/*
* The loader finds the SEP through this alias: it reserves SEPFW
* and copies the boot's local-policy and iBoot manifests onto
* the node.
*/
sep = &sep;
};
};

Expand Down Expand Up @@ -183,3 +189,94 @@
};

/* Unexposed chassis port instances remain described and disabled. */

/*
* Secure Enclave and the Touch ID sensor. All values are from the J813 ADT
* (macOS 27.0) and are the same as J815's:
* - sep: iop-sep,ascwrap-v6 at 0x30a600000 (0x88000), sepfw-booted, so
* apple_sep warm-attaches; ASC mailbox at +0x8000, AIC 445-448.
* - dart-sep: t8110 at 0x308b80000, irq 455; vm-base-0 0x10000004000,
* vm-size-0 0xffff0000.
* - spi2 at 0x3a5108000, irq 1241; PMGR device SPI2 at +0x440, parent SPI_P.
* - mesa: "biosensor,mesa", sensor-id 0x3356, 8 MHz, CS0; power
* function-mesa_pwr = NUB GPIO pin 36; data-ready interrupt on AP GPIO
* pin 200.
* The SEP and its DART stay disabled here: apple_sep enables them at module
* init (drivers/soc/apple/dt.rs).
*/
&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} {
sep: sep@30a600000 {
compatible = "apple,sep";
reg = <0x3 0x0a600000 0x0 0x88000>;
mboxes = <&sep_mbox>;
mbox-names = "mbox";
iommus = <&sep_dart 0>;
status = "disabled";
};

sep_mbox: mbox@30a608000 {
compatible = "apple,t8142-asc-mailbox", "apple,asc-mailbox-v4";
reg = <0x3 0x0a608000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 445 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 446 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 447 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 448 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "send-empty", "send-not-empty",
"recv-empty", "recv-not-empty";
#mbox-cells = <0>;
status = "okay";
};

spi2: spi@3a5108000 {
compatible = "apple,t8142-spi", "apple,t8103-spi";
reg = <0x3 0xa5108000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 1241 IRQ_TYPE_LEVEL_HIGH>;
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";
};
};
};

&sep_dart {
apple,dma-range = /bits/ 64 <0x10000004000 0xffff0000>;
apple,dma-offset = /bits/ 64 <0x0>;
};

/* 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>;
};
42 changes: 35 additions & 7 deletions drivers/soc/apple/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,17 +500,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
Expand Down Expand Up @@ -710,8 +710,9 @@ fn select(
if has(b"apple,t8132") && (has(b"apple,j713") || has(b"apple,j715")) {
return Ok(&T8132);
}
// Only the J815, whose ADT was read; the J813's sensor bus is unchecked.
if has(b"apple,t8142") && has(b"apple,j815") {
// The J815 and the J813, whose ADTs were read (macOS 27.0 stub firmware):
// the J813's SEP, its DART, spi2 and the Mesa node carry the J815's values.
if has(b"apple,t8142") && (has(b"apple,j815") || has(b"apple,j813")) {
return Ok(&T8142);
}
Err(ENODEV)
Expand All @@ -722,6 +723,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")));
Expand Down Expand Up @@ -806,7 +831,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]]; 15] = [
let macs: [&[&[u8]]; 17] = [
&[b"apple,j313", b"apple,t8103"],
&[b"apple,j316s", b"apple,t6000"],
&[b"apple,j316c", b"apple,t6001"],
Expand All @@ -822,6 +847,8 @@ mod tests {
&[b"apple,j713", b"apple,t8132"],
&[b"apple,j700", b"apple,t8140"],
&[b"apple,j714s", 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);
Expand Down Expand Up @@ -883,6 +910,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));
Expand Down
Loading