diff --git a/Documentation/devicetree/bindings/soc/apple/apple,rtk-helper-asc4.yaml b/Documentation/devicetree/bindings/soc/apple/apple,rtk-helper-asc4.yaml index 874f667ce3f61..3a40d2b009ac0 100644 --- a/Documentation/devicetree/bindings/soc/apple/apple,rtk-helper-asc4.yaml +++ b/Documentation/devicetree/bindings/soc/apple/apple,rtk-helper-asc4.yaml @@ -76,6 +76,15 @@ properties: bypass. The host continues servicing system endpoints without restarting the coprocessor or taking it to QUIESCED. + apple,rtkit-keep-running: + type: boolean + description: | + The helper's firmware cannot be restarted once it has been taken to + QUIESCED, so a boot stage that starts it hands its first RTKit epoch to + the OS running, with apple,rtkit-handoff, instead of stopping it. Set by + the board device tree for the firmware it describes. The OS does not + read it. + apple,rtkit-buffers: oneOf: - type: boolean diff --git a/arch/arm64/boot/dts/apple/Makefile b/arch/arm64/boot/dts/apple/Makefile index 6258ce085349d..25b14626c655b 100644 --- a/arch/arm64/boot/dts/apple/Makefile +++ b/arch/arm64/boot/dts/apple/Makefile @@ -113,6 +113,7 @@ dtb-$(CONFIG_ARCH_APPLE) += t6050-k114s.dtb dtb-$(CONFIG_ARCH_APPLE) += t6050-k116c.dtb dtb-$(CONFIG_ARCH_APPLE) += t6050-k116s.dtb dtb-$(CONFIG_ARCH_APPLE) += t8112-j413.dtb +dtb-$(CONFIG_ARCH_APPLE) += t8112-j413-fw27.dtb dtb-$(CONFIG_ARCH_APPLE) += t8112-j415.dtb dtb-$(CONFIG_ARCH_APPLE) += t8112-j473.dtb dtb-$(CONFIG_ARCH_APPLE) += t8112-j493.dtb diff --git a/arch/arm64/boot/dts/apple/t8112-j413-fw27.dts b/arch/arm64/boot/dts/apple/t8112-j413-fw27.dts new file mode 100644 index 0000000000000..ae41133aa6785 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t8112-j413-fw27.dts @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* J413 with macOS 27 system firmware (27.2 stub). */ +#include "t8112-j413.dts" + +/* + * The 27.x MTP firmware cannot be restarted once quiesced: a boot stage that + * starts it hands it over running (apple,rtkit-handoff). + */ +&mtp { + apple,rtkit-keep-running; +}; + +/* The 27.x trackpad firmware answers only the two-stage power command. */ +&mtp_hid { + multi-touch { + apple,power-method = <2>; + }; +}; diff --git a/arch/arm64/boot/dts/apple/t8122-j613.dts b/arch/arm64/boot/dts/apple/t8122-j613.dts index 1c503729a3101..7f1b54c9e1c0e 100644 --- a/arch/arm64/boot/dts/apple/t8122-j613.dts +++ b/arch/arm64/boot/dts/apple/t8122-j613.dts @@ -432,3 +432,8 @@ /* Per-device factory data from this Mac's own iBoot system container. */ firmware-name = "apple/mesacal-j613.bin"; }; + +/* The J613 MTP firmware cannot be restarted once quiesced: hand it over running. */ +&mtp { + apple,rtkit-keep-running; +}; diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 4bb6491eedb8c..60fe4828c7f0e 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -5833,9 +5833,12 @@ static int apple_dart_probe(struct platform_device *pdev) ret = -EINVAL; goto err_clk_disable; } - if (stream && (!of_machine_is_compatible("apple,j613") || - !of_device_is_compatible(dev->of_node, "apple,t8122-dart") || - res->start != 0x2fa808000ULL || !dart->supports_bypass || + /* + * Inherit the stream only if this DART can bypass and the boot + * stage really left that stream in bypass: the TCR read back is + * the hardware's own statement of the handoff, on any board. + */ + if (stream && (!dart->supports_bypass || stream != 1 || stream >= dart->num_streams || apple_dart_readl(dart, DART_TCR(dart, stream)) != dart->hw->tcr_bypass)) { ret = -EINVAL; diff --git a/drivers/soc/apple/rtkit-helper.c b/drivers/soc/apple/rtkit-helper.c index 6db0dfcdd6251..4db46fe2970db 100644 --- a/drivers/soc/apple/rtkit-helper.c +++ b/drivers/soc/apple/rtkit-helper.c @@ -543,7 +543,11 @@ static int __maybe_unused apple_rtkit_helper_suspend(struct device *dev) if (helper->adopted && pm_suspend_target_state != PM_SUSPEND_TO_IDLE) return -EBUSY; - if (!helper->adopted || !of_machine_is_compatible("apple,j613")) + /* + * An adopted session (apple,rtkit-handoff) was handed over running + * because it cannot be restarted, whatever the board. + */ + if (!helper->adopted) return 0; if (!(readl(helper->asc_base + APPLE_ASC_CPU_CONTROL) & APPLE_ASC_CPU_CONTROL_RUN)) return -EHOSTDOWN; @@ -559,7 +563,7 @@ static int __maybe_unused apple_rtkit_helper_resume(struct device *dev) /* After a firmware-driven suspend's idle notice; nothing otherwise. */ apple_rtkit_helper_ap_on(helper); - if (!helper->adopted || !of_machine_is_compatible("apple,j613")) + if (!helper->adopted) return 0; if (!(readl(helper->asc_base + APPLE_ASC_CPU_CONTROL) & APPLE_ASC_CPU_CONTROL_RUN)) { dev_err(dev, "adopted MTP lost ASC RUN; refusing firmware restart\n"); diff --git a/scripts/dtc/apple-dt-check.sh b/scripts/dtc/apple-dt-check.sh index 820d8dc2daf41..3942cd776c974 100755 --- a/scripts/dtc/apple-dt-check.sh +++ b/scripts/dtc/apple-dt-check.sh @@ -4,7 +4,9 @@ # and fail when HEAD has a warning BASE does not. Also runs dt_binding_check on every binding HEAD # changes. Phandle values in the messages are masked, so renumbering is not a new warning, and so # is the pattern list of a "does not match any of the regexes" message, which grows with every -# vendor prefix the bindings add. +# vendor prefix the bindings add. A firmware-profile variant (a .dts that includes another board's +# .dts, such as t8122-j613-25g83) is reported under its base board's name, so the base's existing +# warnings are not new warnings of the variant; anything the variant adds still is. # Needs dtschema (dt-validate), clang/lld (LLVM=1), flex, bison. Prints a summary. set -u BASE=$1 HEAD=$2 W=$3 @@ -17,8 +19,13 @@ warnings() { # rev tag local dtbs; dtbs=$(cd "$t/arch/arm64/boot/dts" && ls apple/*.dts | sed 's/dts$/dtb/') make -C "$t" O="$o" -j"$(nproc)" CHECK_DTBS=y $dtbs > "$W/$2.log" 2>&1 local rc=$? + local variants; variants=$(cd "$t/arch/arm64/boot/dts" && + grep -l '^#include "[^"]*\.dts"' apple/*.dts 2>/dev/null | while read -r v; do + sed -nE 's#^\#include "([^"]*)\.dts".*#s|^'"${v%.dts}"'\\.dtb: |apple/\1.dtb: |;#p' "$v" | head -1 + done) grep -E '\.dtb: |[Ww]arning|rror' "$W/$2.log" | grep -v '^ ' | sed -E "s#$t/##g; s#$o/##g" | + sed -E "s#arch/arm64/boot/dts/##; $variants" | sed -E 's#^apple/#arch/arm64/boot/dts/apple/#' | perl -pe 's{(\[\[[^:]*?\]\])}{(my $x = $1) =~ s/\d+/N/g; $x}ge; s{b\x27(?:\\.|[^\x27])*\x27}{b\x27N\x27}g; s{( not match any of the regexes): .*}{$1: ...}' | sort -u > "$W/$2.warn" echo "$2: make rc=$rc, $(wc -l < "$W/$2.warn") warning lines, $(echo $dtbs | wc -w) DTBs" diff --git a/tools/asahi/j613-mtp-s2idle-tests.py b/tools/asahi/j613-mtp-s2idle-tests.py index 21d673862dac6..fbf39ce280e26 100644 --- a/tools/asahi/j613-mtp-s2idle-tests.py +++ b/tools/asahi/j613-mtp-s2idle-tests.py @@ -30,7 +30,6 @@ def fn(s,n): static unsigned forced_suspend,forced_resume; static int pm_runtime_force_suspend(struct device *d){forced_suspend++;return 7;} static int pm_runtime_force_resume(struct device *d){forced_resume++;return 8;} -static bool of_machine_is_compatible(const char *s){return true;} static unsigned readl(void *p){return *(unsigned *)p;} /* #1445: only a firmware-driven (T8140 S2R) sleep takes the noirq or AP-idle paths. */ static bool pm_suspend_via_firmware(void){return false;}