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>; 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)