Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions arch/arm64/boot/dts/apple/t6030-j514s.dts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
compatible = "apple,j514s", "apple,t6030", "apple,arm-platform";
model = "Apple MacBook Pro (14-inch, M3 Pro, Nov 2023)";

aliases {
sep = &sep;
};

chosen {
asahi,t6030-dispext = "1";
};
Expand Down Expand Up @@ -97,3 +101,27 @@
&isp {
apple,platform-id = <16>;
};

/* apple_sep enables the SEP and its DART when it loads. */
&sep_mbox {
status = "okay";
};

/*
* Touch ID sensor (Mesa 0x3352, J514s ADT /arm-io/spi2/mesa): power on
* NUB GPIO 33, active high. As on J613, the data-ready line (AP GPIO 200)
* is left out, so the driver polls until its trigger is confirmed. Native
* chip select only.
*/
&spi2 {
status = "okay";
};

&mesa {
status = "okay";
enable-gpios = <&pinctrl_nub 33 GPIO_ACTIVE_HIGH>;
spi-cs-setup-delay-ns = <20>;
spi-cs-hold-delay-ns = <20>;
/* Per-device factory data from this Mac's own iBoot system container. */
firmware-name = "apple/mesacal-j514s.bin";
};
67 changes: 67 additions & 0 deletions arch/arm64/boot/dts/apple/t6030.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,31 @@
status = "disabled";
};

/*
* Touch ID (J514s ADT /arm-io/spi2). iBoot leaves the pads muxed
* and the controller uses its native chip select, so there is no
* pinctrl here.
*/
spi2: spi@289108000 {
compatible = "apple,t6030-spi", "apple,t8103-spi";
reg = <0x2 0x89108000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 876 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <1>;
#size-cells = <0>;
clocks = <&clk_200m>;
power-domains = <&ps_spi2>;
status = "disabled";

mesa: fingerprint@0 {
compatible = "apple,mesa-fingerprint";
reg = <0>;
spi-max-frequency = <8000000>;
spi-cpha;
status = "disabled";
};
};

sio_dart: iommu@289004000 {
compatible = "apple,t6030-dart", "apple,t8110-dart";
reg = <0x2 0x89004000 0x0 0x4000>;
Expand Down Expand Up @@ -675,6 +700,48 @@
/* child nodes are added in t6030-pmgr.dtsi */
};

/*
* iBoot hands over a running SEP (ADT sepfw-load-at-boot). Keep
* Linux off its DART at boot; apple_sep enables it when the driver
* binds. The SEP only accepts IOVAs in the window iBoot programmed
* (ADT vm-base 0x10000004000, vm-size 0xffff0000), which carries
* the BIT(40) alias the DART translates.
*/
sep_dart: iommu@29cac0000 {
compatible = "apple,t6030-dart", "apple,t8110-dart";
reg = <0x2 0x9cac0000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 372 IRQ_TYPE_LEVEL_HIGH>;
#iommu-cells = <1>;
apple,dma-range = /bits/ 64 <0x10000004000 0xffff0000>;
apple,dma-offset = /bits/ 64 <0x0>;
status = "disabled";
};

sep: sep@29e400000 {
compatible = "apple,sep";
reg = <0x2 0x9e400000 0x0 0x6c000>;
mboxes = <&sep_mbox>;
mbox-names = "mbox";
iommus = <&sep_dart 0>;
power-domains = <&ps_sep>;
status = "disabled";
};

sep_mbox: mbox@29e408000 {
compatible = "apple,t6030-asc-mailbox", "apple,asc-mailbox-v4";
reg = <0x2 0x9e408000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 366 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 367 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 368 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 369 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "send-empty", "send-not-empty",
"recv-empty", "recv-not-empty";
#mbox-cells = <0>;
status = "disabled";
};

isp: isp@2c8000000 {
compatible = "apple,t6030-isp";
iommus = <&isp_dart0 0>, <&isp_dart1 0>, <&isp_dart2 0>;
Expand Down
28 changes: 28 additions & 0 deletions drivers/soc/apple/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,26 @@ pub(crate) const T8122: PlatformProfile = PlatformProfile {
..T8112
};

/// MacBook Pro 14" M3 Pro (J514s). The J514s ADT (system firmware 27.0) records
/// a pre-booted SEP (`sepfw-load-at-boot`), an `iop-sep,ascwrap-v6` SEP and
/// its DART at the same addresses as T8122's, with the same BIT(40) aperture
/// (`vm-base` 0x10000004000, `vm-size` 0xffff0000). The Mesa sensor is the
/// `0x3352` part T8122 carries, on spi2 at `0x289108000`, 8 MHz, chip select
/// 0. Its power is NUB GPIO 33 and its data-ready line AP GPIO 200.
/// `/defaults` carries `cpx-encryption-mode = 2`.
///
/// Otherwise T8122's warm-registration profile. J514s on system firmware 27.0
/// attaches, provisions the keybag, enrols, matches, and still matches after a
/// reboot and after suspend; macOS Touch ID keeps working alongside it.
pub(crate) const T6030: PlatformProfile = PlatformProfile {
name: "T6030/J514s",
sensor: SensorProfile {
controller_base: 0x2_8910_8000,
..T8122.sensor
},
..T8122
};

static_assert!(T8103.shmem_capacity == 0x30000);
static_assert!(T6020.shmem_capacity == 0x40000);
static_assert!(T8140.shmem_capacity == 0x40000);
Expand All @@ -440,6 +460,9 @@ static_assert!(T8112.sensor.controller_base == T8103.sensor.controller_base);
static_assert!(T8122.shmem_capacity == T8112.shmem_capacity);
static_assert!(T8122.sensor.controller_base == 0x2a1108000);
static_assert!(T8122.wide_dma_mask);
static_assert!(T6030.sensor.controller_base == 0x289108000);
static_assert!(T6030.sensor.expected_id == T8122.sensor.expected_id);
static_assert!(T6030.wide_dma_mask);

/// Whether the machine root declares `compatible`.
///
Expand Down Expand Up @@ -586,6 +609,11 @@ pub(crate) fn detect() -> Result<&'static PlatformProfile> {
if machine_has(b"apple,t8122") && (machine_has(b"apple,j613") || machine_has(b"apple,j615")) {
return Ok(&T8122);
}
// Only the board whose ADT was read: J514s. The 16" M3 Pro (J516s)
// shares the SoC but its sensor wiring is unchecked.
if machine_has(b"apple,t6030") && machine_has(b"apple,j514s") {
return Ok(&T6030);
}
Err(ENODEV)
}

Expand Down
1 change: 1 addition & 0 deletions drivers/soc/apple/xart_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ mod tests {
assert_eq!(level(-1, profile::T6020_SEPOS13.xart_guard), Some(1));
assert_eq!(level(-1, profile::T8112.xart_guard), Some(1));
assert_eq!(level(-1, profile::T8122.xart_guard), Some(1));
assert_eq!(level(-1, profile::T6030.xart_guard), Some(1));
// Off on the Neo, whose Linux records predate the list.
assert_eq!(level(-1, profile::T8140.xart_guard), None);
assert_eq!(level(i8::MIN, 1), Some(1));
Expand Down
132 changes: 132 additions & 0 deletions tools/aurora-sep/tests/test_t6030_sep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
"""T6030 (MacBook Pro 14" M3 Pro, J514s) SEP and Mesa sensor device tree and profile.

Set DTC to this kernel's built scripts/dtc/dtc for Apple floating-point cells.
"""

from pathlib import Path
import os
import re
import shutil
import subprocess
import tempfile
import unittest


ROOT = Path(__file__).resolve().parents[3]
DTS = ROOT / "arch/arm64/boot/dts/apple"
DTC = os.environ.get("DTC", "dtc")
PROFILE = (ROOT / "drivers/soc/apple/profile.rs").read_text()

SEP_DART = "/soc/iommu@29cac0000"
SEP = "/soc/sep@29e400000"
BUS = "/soc/spi@289108000"
SENSOR = BUS + "/fingerprint@0"
PINCTRL_NUB = "/soc/pinctrl@3641f0000"
MBOX = "/soc/mbox@29e408000"
# AIC_IRQ cells: <type irq flags>, IRQ_TYPE_LEVEL_HIGH = 4.
LEVEL_HIGH = 4


@unittest.skipUnless(all(shutil.which(tool) for tool in ("cpp", DTC, "fdtget")),
"requires cpp, dtc and fdtget")
class T6030SepTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.temp = tempfile.TemporaryDirectory(prefix="aurora-t6030-sep-")
cls.addClassCleanup(cls.temp.cleanup)
cls.out = Path(cls.temp.name)

def compile_board(self, board):
pp = subprocess.run(["cpp", "-nostdinc", "-undef", "-D__DTS__", "-x",
"assembler-with-cpp", "-I", str(ROOT / "include"),
"-I", str(DTS), str(DTS / f"t6030-{board}.dts")],
check=True, capture_output=True)
output = self.out / f"{board}.dtb"
subprocess.run([DTC, "-q", "-I", "dts", "-O", "dtb", "-o", str(output)],
input=pp.stdout, check=True, capture_output=True)
return output

def prop(self, dtb, node, name, kind="x"):
return subprocess.run(["fdtget", "-t", kind, str(dtb), node, name],
check=True, capture_output=True, text=True).stdout.split()

def props(self, dtb, node):
return subprocess.run(["fdtget", "-p", str(dtb), node],
check=True, capture_output=True, text=True).stdout.split()

def cells(self, dtb, node, name):
return [int(cell, 16) for cell in self.prop(dtb, node, name)]

def irqs(self, dtb, node):
cells = self.cells(dtb, node, "interrupts")
self.assertEqual(len(cells) % 3, 0)
triples = [cells[i:i + 3] for i in range(0, len(cells), 3)]
for kind, _, flags in triples:
self.assertEqual((kind, flags), (0, LEVEL_HIGH))
return [irq for _, irq, _ in triples]

def test_j514s_describes_sep_and_sensor(self):
dtb = self.compile_board("j514s")
# apple_sep enables the SEP and its DART at module load.
self.assertEqual(self.prop(dtb, SEP_DART, "status", "s"), ["disabled"])
self.assertEqual(self.prop(dtb, SEP, "status", "s"), ["disabled"])
self.assertEqual(self.prop(dtb, MBOX, "status", "s"), ["okay"])
# ADT vm-base 0x10000004000, vm-size 0xffff0000, as on t8122.
self.assertEqual(self.cells(dtb, SEP_DART, "apple,dma-range"),
[0x100, 0x4000, 0, 0xffff0000])
self.assertEqual(self.cells(dtb, SEP_DART, "apple,dma-offset"), [0, 0])
self.assertEqual(self.prop(dtb, "/aliases", "sep", "s"), [SEP])

self.assertEqual(self.prop(dtb, BUS, "status", "s"), ["okay"])
self.assertEqual(self.prop(dtb, SENSOR, "status", "s"), ["okay"])
self.assertEqual(self.prop(dtb, SENSOR, "firmware-name", "s"),
["apple/mesacal-j514s.bin"])
nub = int(self.prop(dtb, PINCTRL_NUB, "phandle")[0], 16)
self.assertEqual(self.cells(dtb, SENSOR, "enable-gpios"), [nub, 33, 0])
self.assertEqual(self.prop(dtb, SENSOR, "spi-max-frequency", "u"), ["8000000"])
self.assertEqual(self.prop(dtb, SENSOR, "spi-cs-setup-delay-ns", "u"), ["20"])
self.assertEqual(self.prop(dtb, SENSOR, "spi-cs-hold-delay-ns", "u"), ["20"])
properties = self.props(dtb, SENSOR)
self.assertIn("spi-cpha", properties)
self.assertNotIn("spi-cpol", properties)
self.assertNotIn("interrupts", properties)
self.assertNotIn("cs-gpios", self.props(dtb, BUS))

def test_addresses_and_interrupts_match_the_adt(self):
# The J514s ADT values (system firmware 27.0), /arm-io base 0x210000000 added.
dtb = self.compile_board("j514s")
self.assertEqual(self.cells(dtb, SEP_DART, "reg"), [0x2, 0x9cac0000, 0, 0x4000])
self.assertEqual(self.irqs(dtb, SEP_DART), [372])
self.assertEqual(self.cells(dtb, SEP, "reg"), [0x2, 0x9e400000, 0, 0x6c000])
self.assertEqual(self.cells(dtb, MBOX, "reg"), [0x2, 0x9e408000, 0, 0x4000])
self.assertEqual(self.prop(dtb, MBOX, "interrupt-names", "s"),
["send-empty", "send-not-empty", "recv-empty", "recv-not-empty"])
self.assertEqual(self.irqs(dtb, MBOX), [366, 367, 368, 369])
mbox = int(self.prop(dtb, MBOX, "phandle")[0], 16)
dart = int(self.prop(dtb, SEP_DART, "phandle")[0], 16)
self.assertEqual(self.cells(dtb, SEP, "mboxes"), [mbox])
self.assertEqual(self.cells(dtb, SEP, "iommus"), [dart, 0])
self.assertEqual(self.cells(dtb, BUS, "reg"), [0x2, 0x89108000, 0, 0x4000])
self.assertEqual(self.irqs(dtb, BUS), [876])
self.assertEqual(self.cells(dtb, SENSOR, "reg"), [0])

def test_j516s_leaves_sep_and_sensor_off(self):
dtb = self.compile_board("j516s")
self.assertNotIn("sep", self.props(dtb, "/aliases"))
self.assertEqual(self.prop(dtb, MBOX, "status", "s"), ["disabled"])
self.assertEqual(self.prop(dtb, BUS, "status", "s"), ["disabled"])
self.assertEqual(self.prop(dtb, SENSOR, "status", "s"), ["disabled"])

def test_profile_selected_only_on_j514s(self):
detect = PROFILE.split("pub(crate) fn detect()", 1)[1]
line = next(line for line in detect.splitlines() if 'b"apple,t6030"' in line)
self.assertIn('b"apple,j514s"', line)
profile = re.search(r"const T6030: PlatformProfile = PlatformProfile \{(.*?)\n\};",
PROFILE, re.S).group(1)
self.assertIn("..T8122", profile)
# The diagnostic controller base is spi2's, not T8122's.
self.assertIn("controller_base: 0x2_8910_8000", profile)


if __name__ == "__main__":
unittest.main()