From b6d2a9b7f8660d7428525cf2d4a674adcbbaf6a0 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 22:35:34 +1100 Subject: [PATCH 1/2] soc: apple: sep: take the Touch ID sensor's lines from the device tree only The sensor shim had a board fallback: on a machine compatible with apple,j414s whose sensor node carried no power GPIO, it took line 122 of /soc/pinctrl@39b028000 for power, and on one with no node interrupt it took line 121 of the same controller for data-ready. Every other board had to describe both lines in its sensor node. The tree now describes them on J414s too: t602x-j414-j416.dtsi gives the J414s, J414c, J416s and J416c sensor enable-gpios = <&pinctrl_ap 122> and interrupts = <121 IRQ_TYPE_EDGE_RISING> on pinctrl_ap, which is pinctrl@39b028000. Those are the same two lines, so the fallback never runs on an in-tree J414s DTB. Every M1 and M2 laptop DT (J293, J313, J314s/c, J316s/c, J413, J415, J493, J414s/c, J416s/c) describes the power line in its node. Drop the board check and the fixed lines. Power comes from enable-gpios (or the J700 SMC rails), data-ready from the node's interrupt via spi->irq, on every board alike. Drop the chip-line power source from sensor.rs, which only that path produced. Fixes: f9fc10a8b34c ("soc: apple: restrict the fixed power-GPIO fallback to j414s") Fixes: bece4b11f28f ("soc: apple: sep: optional interrupt-driven fingerprint capture") Suggested-by: Diljit Singh Signed-off-by: Ryan Murray Co-Authored-By: Claude Opus 5.5 --- drivers/soc/apple/sensor.rs | 3 - drivers/soc/apple/sensor_shim.c | 135 +++----------------------------- 2 files changed, 12 insertions(+), 126 deletions(-) diff --git a/drivers/soc/apple/sensor.rs b/drivers/soc/apple/sensor.rs index 5e6a96afb43ec..b884a90259bba 100644 --- a/drivers/soc/apple/sensor.rs +++ b/drivers/soc/apple/sensor.rs @@ -91,7 +91,6 @@ impl CsTiming { pub(crate) enum PowerSource { None, NodeProperty, - ChipLine, /// Rails switched by the SMC on J700. SmcRails, } @@ -100,7 +99,6 @@ impl PowerSource { fn from_wire(v: c_int) -> PowerSource { match v { 1 => PowerSource::NodeProperty, - 2 => PowerSource::ChipLine, 3 => PowerSource::SmcRails, _ => PowerSource::None, } @@ -110,7 +108,6 @@ impl PowerSource { match self { PowerSource::None => c"none — no power line was taken", PowerSource::NodeProperty => c"the sensor node's own gpios property", - PowerSource::ChipLine => c"/soc/pinctrl@39b028000 line 122, taken by device-tree node", PowerSource::SmcRails => c"the sensor node's SMC-switched rails (apple,smc-power-key)", } } diff --git a/drivers/soc/apple/sensor_shim.c b/drivers/soc/apple/sensor_shim.c index ffe3979c02840..7564e08971c39 100644 --- a/drivers/soc/apple/sensor_shim.c +++ b/drivers/soc/apple/sensor_shim.c @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include #include #include @@ -78,16 +76,9 @@ static struct spi_device *sep_spi; static struct gpio_desc *sep_power; static bool sep_registered; -/* - * Power line resolved by DT node path, not gpiochip index: registration order - * shifts, so an index would silently pick the wrong chip. - */ -#define SEP_SENSOR_GPIO_NODE "/soc/pinctrl@39b028000" -#define SEP_SENSOR_GPIO_LINE 122 - +/* Wire values shared with sensor.rs (PowerSource::from_wire). */ #define SEP_POWER_NONE 0 #define SEP_POWER_NODE_PROPERTY 1 -#define SEP_POWER_CHIP_LINE 2 #define SEP_POWER_SMC_RAILS 3 static int sep_power_source; @@ -102,12 +93,9 @@ static u32 sep_smc_rails[SEP_SMC_MAX_RAILS]; static int sep_smc_nrails; /* - * Data-ready line for interrupt-driven capture. On j414s it is the pin adjacent - * to the power line (122) on the same controller; other boards describe it as - * the SPI node's interrupt, which the SPI core resolves into spi->irq. + * Data-ready line for interrupt-driven capture: the SPI node's interrupt, which + * the SPI core resolves into spi->irq. */ -#define SEP_SENSOR_DRDY_LINE 121 -static struct gpio_desc *sep_drdy; /* set only when we own the gpiochip line (j414s) */ static int sep_drdy_irq = -1; static DECLARE_COMPLETION(sep_drdy_done); @@ -244,10 +232,6 @@ static int sep_acquire_smc_power(struct spi_device *spi) */ static int sep_acquire_power(struct spi_device *spi) { - struct device_node *np; - struct gpio_device *gdev; - struct gpio_chip *gc; - if (spi->dev.of_node && of_property_present(spi->dev.of_node, "apple,smc-power-key")) return sep_acquire_smc_power(spi); @@ -269,58 +253,9 @@ static int sep_acquire_power(struct spi_device *spi) } sep_power = NULL; - /* - * The fallback below is the j414s power line; a sibling board's sensor sits - * on a different pin, so only j414s may use it. Every other machine must - * describe enable-gpios in its device node. - */ - if (!of_machine_is_compatible("apple,j414s")) { - dev_warn(&spi->dev, - "sep sensor: no power GPIO in the device node; describe enable-gpios in DT\n"); - return -ENODEV; - } - - np = of_find_node_by_path(SEP_SENSOR_GPIO_NODE); - if (!np) { - dev_warn(&spi->dev, - "sep sensor: no DT node at %s, no power line\n", - SEP_SENSOR_GPIO_NODE); - return -ENODEV; - } - - gdev = gpio_device_find_by_fwnode(of_fwnode_handle(np)); - of_node_put(np); - if (!gdev) { - dev_warn(&spi->dev, - "sep sensor: %s has no registered GPIO device\n", - SEP_SENSOR_GPIO_NODE); - return -EPROBE_DEFER; - } - - gc = gpio_device_get_chip(gdev); - if (gc) - sep_power = gpiochip_request_own_desc(gc, - SEP_SENSOR_GPIO_LINE, - "apple-mesa-power", - GPIO_LOOKUP_FLAGS_DEFAULT, - GPIOD_OUT_LOW); - if (!gc || IS_ERR(sep_power)) { - sep_power = NULL; - dev_warn(&spi->dev, - "sep sensor: could not take line %d on %s (%s)\n", - SEP_SENSOR_GPIO_LINE, SEP_SENSOR_GPIO_NODE, - gpio_device_get_label(gdev)); - gpio_device_put(gdev); - return -ENODEV; - } - - sep_power_source = SEP_POWER_CHIP_LINE; - dev_info(&spi->dev, - "sep sensor: power line %s line %d (%s), driven low\n", - SEP_SENSOR_GPIO_NODE, SEP_SENSOR_GPIO_LINE, - gpio_device_get_label(gdev)); - gpio_device_put(gdev); - return 0; + dev_warn(&spi->dev, + "sep sensor: no power GPIO in the device node; describe enable-gpios in DT\n"); + return -ENODEV; } static void sep_release_power(void) @@ -335,10 +270,7 @@ static void sep_release_power(void) if (!sep_power) return; gpiod_set_value_cansleep(sep_power, 0); - if (sep_power_source == SEP_POWER_CHIP_LINE) - gpiochip_free_own_desc(sep_power); - else - gpiod_put(sep_power); + gpiod_put(sep_power); sep_power = NULL; sep_power_source = SEP_POWER_NONE; } @@ -633,7 +565,7 @@ static int sep_sensor_power_cycle_locked(struct sep_sensor_lifetime *sensor) return 0; } -/* How the power line was obtained: none, the node's property, or chip+line. */ +/* How the power line was obtained: none, the node's property, or SMC rails. */ static int sep_sensor_power_source_locked(void) { return sep_power_source; @@ -699,9 +631,6 @@ static irqreturn_t sep_drdy_isr(int irq, void *dev_id) */ static int sep_sensor_irq_setup_locked(void) { - struct device_node *np; - struct gpio_device *gdev; - struct gpio_chip *gc; int irq, rc; if (!sep_spi) @@ -709,41 +638,10 @@ static int sep_sensor_irq_setup_locked(void) if (sep_drdy_irq >= 0) return 0; - if (sep_spi->irq > 0) { - /* A board that describes the data-ready line as the SPI node's - * interrupt gets it resolved by the SPI core. */ - irq = sep_spi->irq; - } else if (of_machine_is_compatible("apple,j414s")) { - np = of_find_node_by_path(SEP_SENSOR_GPIO_NODE); - if (!np) - return -ENODEV; - gdev = gpio_device_find_by_fwnode(of_fwnode_handle(np)); - of_node_put(np); - if (!gdev) - return -ENODEV; - gc = gpio_device_get_chip(gdev); - if (!gc) { - gpio_device_put(gdev); - return -ENODEV; - } - sep_drdy = gpiochip_request_own_desc(gc, SEP_SENSOR_DRDY_LINE, - "apple-mesa-drdy", - GPIO_LOOKUP_FLAGS_DEFAULT, - GPIOD_IN); - gpio_device_put(gdev); - if (IS_ERR(sep_drdy)) { - sep_drdy = NULL; - return -ENODEV; - } - irq = gpiod_to_irq(sep_drdy); - if (irq < 0) { - gpiochip_free_own_desc(sep_drdy); - sep_drdy = NULL; - return irq; - } - } else { + /* The board describes the data-ready line as the SPI node's interrupt. */ + if (sep_spi->irq <= 0) return -ENODEV; - } + irq = sep_spi->irq; init_completion(&sep_drdy_done); /* @@ -756,13 +654,8 @@ static int sep_sensor_irq_setup_locked(void) rc = request_threaded_irq(irq, NULL, sep_drdy_isr, IRQF_ONESHOT | IRQF_TRIGGER_RISING, "apple-mesa-drdy", sep_spi); - if (rc) { - if (sep_drdy) { - gpiochip_free_own_desc(sep_drdy); - sep_drdy = NULL; - } + if (rc) return rc; - } sep_drdy_irq = irq; dev_info(&sep_spi->dev, "sep sensor: data-ready IRQ %d configured for interrupt capture\n", @@ -776,10 +669,6 @@ static void sep_sensor_irq_teardown_locked(void) free_irq(sep_drdy_irq, sep_spi); sep_drdy_irq = -1; } - if (sep_drdy) { - gpiochip_free_own_desc(sep_drdy); - sep_drdy = NULL; - } } static int sep_sensor_irq_available_locked(void) From 3191f94636b566181dfc245c2fc34b5996c0985e Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 22:35:36 +1100 Subject: [PATCH 2/2] arm64: dts: apple: t8112, t602x: alias the SEP on the M2 desktops The SEP node is disabled in t8112.dtsi and t602x-die0.dtsi on every board, laptops included. That is the warm-attach contract of apple_sep: on these SoCs the SEP is already running when Linux starts, and the driver enables the SEP node and sep_dart with a changeset at module load, after it has picked the SoC's profile and before the DART probes. The running M2 Air (J413) shows it: "SEP DART changeset applied", "SEP node enabled", then "ready ... 12 endpoints". Say so at the node, so the disabled status does not read as a missing enable. What a board must provide is the sep alias: m1n1 finds the SEP through it to add the sepfw region and the local-policy and iBoot manifests, and the warm registration refuses to attach without the manifests. The M2 laptops have it; the Mac mini (J473, J474s) and the Mac Studio M2 Max (J475c) have a SEP and a profile (T8112, T6020/T6021) but no alias, so the driver could never attach there (key store, Magic Keyboard Touch ID). Add it. These boards have no built-in sensor and leave the mesa node disabled. The M2 Ultra boards (J475d, J180d) get no alias: the driver has no T6022 profile, so it would only reserve memory for nothing. Signed-off-by: Ryan Murray Co-Authored-By: Claude Opus 5.5 --- arch/arm64/boot/dts/apple/t6020-j474s.dts | 4 ++++ arch/arm64/boot/dts/apple/t6021-j475c.dts | 4 ++++ arch/arm64/boot/dts/apple/t602x-die0.dtsi | 9 +++++++++ arch/arm64/boot/dts/apple/t8112-j473.dts | 1 + arch/arm64/boot/dts/apple/t8112.dtsi | 9 +++++++++ 5 files changed, 27 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6020-j474s.dts b/arch/arm64/boot/dts/apple/t6020-j474s.dts index 3d2b4c3e0211b..7b80e06270ab5 100644 --- a/arch/arm64/boot/dts/apple/t6020-j474s.dts +++ b/arch/arm64/boot/dts/apple/t6020-j474s.dts @@ -21,6 +21,10 @@ / { compatible = "apple,j474s", "apple,t6020", "apple,arm-platform"; model = "Apple Mac mini (M2 Pro, 2023)"; + + aliases { + sep = &sep; + }; }; /* PCIe devices */ diff --git a/arch/arm64/boot/dts/apple/t6021-j475c.dts b/arch/arm64/boot/dts/apple/t6021-j475c.dts index c3fce206ab662..fa6ee51e9cf4b 100644 --- a/arch/arm64/boot/dts/apple/t6021-j475c.dts +++ b/arch/arm64/boot/dts/apple/t6021-j475c.dts @@ -15,6 +15,10 @@ / { compatible = "apple,j475c", "apple,t6021", "apple,arm-platform"; model = "Apple Mac Studio (M2 Max, 2023)"; + + aliases { + sep = &sep; + }; }; &wifi0 { diff --git a/arch/arm64/boot/dts/apple/t602x-die0.dtsi b/arch/arm64/boot/dts/apple/t602x-die0.dtsi index 828f6ac65c4a8..488afa4e9e574 100644 --- a/arch/arm64/boot/dts/apple/t602x-die0.dtsi +++ b/arch/arm64/boot/dts/apple/t602x-die0.dtsi @@ -722,6 +722,15 @@ status = "disabled"; }; + /* + * Disabled here on every board by design. The SEP is already + * running when Linux starts (warm attach: one shared-memory + * registration, no cold boot), so apple_sep enables this node + * and sep_dart with a changeset at module load, once it has + * picked this SoC's profile and before the DART probes. A + * board with the enclave only needs the sep alias, which m1n1 + * uses to add the sepfw region and the boot manifests. + */ sep: sep@396400000 { compatible = "apple,sep"; reg = <0x3 0x96400000 0x0 0x6C000>; diff --git a/arch/arm64/boot/dts/apple/t8112-j473.dts b/arch/arm64/boot/dts/apple/t8112-j473.dts index 84ecd65613567..eeda54799f63f 100644 --- a/arch/arm64/boot/dts/apple/t8112-j473.dts +++ b/arch/arm64/boot/dts/apple/t8112-j473.dts @@ -24,6 +24,7 @@ ethernet0 = ðernet0; rtc0 = &smc_rtc; rtc1 = &pmu_rtc; + sep = &sep; wifi0 = &wifi0; }; }; diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/apple/t8112.dtsi index 882965a8db382..f15f86793c829 100644 --- a/arch/arm64/boot/dts/apple/t8112.dtsi +++ b/arch/arm64/boot/dts/apple/t8112.dtsi @@ -1847,6 +1847,15 @@ status = "disabled"; }; + /* + * Disabled here on every board by design. The SEP is already + * running when Linux starts (warm attach: one shared-memory + * registration, no cold boot), so apple_sep enables this node + * and sep_dart with a changeset at module load, once it has + * picked this SoC's profile and before the DART probes. A + * board with the enclave only needs the sep alias, which m1n1 + * uses to add the sepfw region and the boot manifests. + */ sep: sep@25e400000 { compatible = "apple,sep"; reg = <0x2 0x5e400000 0x0 0x6C000>;