diff --git a/arch/arm64/boot/dts/apple/t8132-gpu.dtsi b/arch/arm64/boot/dts/apple/t8132-gpu.dtsi index 44d6157f76137..5e3f933e9cfff 100644 --- a/arch/arm64/boot/dts/apple/t8132-gpu.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-gpu.dtsi @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0+ OR MIT /* * The T8132 G16 GPU, its ASC mailbox and the outer GFX power gate (TVM), - * as on the J713. m1n1 fills the inherited UAT and firmware ranges (reg) - * and enables them; a board enables the GPU once its firmware and board data - * are qualified. + * as on the J713. The GPU depends on the 26.6.2 firmware, not the board: the + * boot loader fills the inherited UAT and firmware ranges (reg), enables + * them and publishes the handoff, or disables the GPU. * * Copyright The Asahi Linux Contributors */ @@ -54,7 +54,6 @@ compatible = "apple,t8132-gfx-tvm"; reg = <0x3 0x80760800 0x0 0x4>; #power-domain-cells = <0>; - status = "disabled"; }; gpu: gpu@302600000 { @@ -72,7 +71,6 @@ <&gpu_shared_l2>, <&gpu_fw_text>, <&gpu_fw_data>; memory-region-names = "ttbs", "pagetables", "handoff", "shared-l2", "fw-text", "fw-data"; - status = "disabled"; }; agx_mbox: mailbox@302608000 { @@ -88,6 +86,17 @@ interrupt-names = "send-empty", "send-not-empty", "recv-empty", "recv-not-empty"; #mbox-cells = <0>; - status = "disabled"; }; }; + +/* The outer TVM gate is the parent of the GFX PMGR domain. */ +&ps_gfx { + power-domains = <&gfx_tvm>; + /* The G16 firmware stays live across suspend-to-idle. */ + apple,sleep-retained; +}; + +/* The existing report provider owns readiness for shared PMP commands. */ +&pmp { + apple,pmp-report = <&pmp_report>; +}; diff --git a/arch/arm64/boot/dts/apple/t8132-j604.dts b/arch/arm64/boot/dts/apple/t8132-j604.dts index 5830d21bee81b..b9d4c870e71cd 100644 --- a/arch/arm64/boot/dts/apple/t8132-j604.dts +++ b/arch/arm64/boot/dts/apple/t8132-j604.dts @@ -312,3 +312,19 @@ #include "hwmon-common.dtsi" #include "hwmon-laptop.dtsi" #include "hwmon-fan-dual.dtsi" + +/* + * The PMGR domains of the USB-C ports this board wires beyond ATC0/ATC1, as + * the M4 firmware path's policy enables ATC0/ATC1's. + */ +&ps_atc3_common { + status = "okay"; +}; + +&ps_atc3_usb_aon { + status = "okay"; +}; + +&ps_atc3_usb { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/apple/t8132-j624.dts b/arch/arm64/boot/dts/apple/t8132-j624.dts index 833f7a2788fe3..042e9a66cbf4e 100644 --- a/arch/arm64/boot/dts/apple/t8132-j624.dts +++ b/arch/arm64/boot/dts/apple/t8132-j624.dts @@ -197,3 +197,31 @@ }; }; }; + +/* + * The PMGR domains of the USB-C ports this board wires beyond ATC0/ATC1, as + * the M4 firmware path's policy enables ATC0/ATC1's. + */ +&ps_atc2_common { + status = "okay"; +}; + +&ps_atc2_usb_aon { + status = "okay"; +}; + +&ps_atc2_usb { + status = "okay"; +}; + +&ps_atc3_common { + status = "okay"; +}; + +&ps_atc3_usb_aon { + status = "okay"; +}; + +&ps_atc3_usb { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/apple/t8132-j713-j715.dtsi b/arch/arm64/boot/dts/apple/t8132-j713-j715.dtsi index ee0fe73467e64..1f54a7cfb0166 100644 --- a/arch/arm64/boot/dts/apple/t8132-j713-j715.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-j713-j715.dtsi @@ -132,31 +132,11 @@ }; }; -/* GPU: the outer TVM gate is the parent of the GFX domain. */ -&gfx_tvm { - status = "okay"; -}; - -&gpu { - status = "okay"; -}; - -&agx_mbox { - status = "okay"; -}; - +/* The GPU itself is described for every M4 Mac in t8132-gpu.dtsi. */ &ps_gfx { - power-domains = <&gfx_tvm>; - /* The G16 firmware stays live across suspend-to-idle. */ - apple,sleep-retained; status = "okay"; }; -/* The report provider owns readiness for shared PMP commands. */ -&pmp { - apple,pmp-report = <&pmp_report>; -}; - /* * Internal display: the loader enables disp0_dart, piodma and the display * subsystem once it has validated the inherited frontend mappings. diff --git a/arch/arm64/boot/dts/apple/t8132-j773g.dts b/arch/arm64/boot/dts/apple/t8132-j773g.dts index c7ae238c04f86..89d2514815914 100644 --- a/arch/arm64/boot/dts/apple/t8132-j773g.dts +++ b/arch/arm64/boot/dts/apple/t8132-j773g.dts @@ -198,3 +198,31 @@ #include "hwmon-common.dtsi" #include "hwmon-mini.dtsi" + +/* + * The PMGR domains of the USB-C ports this board wires beyond ATC0/ATC1, as + * the M4 firmware path's policy enables ATC0/ATC1's. + */ +&ps_atc2_common { + status = "okay"; +}; + +&ps_atc2_usb_aon { + status = "okay"; +}; + +&ps_atc2_usb { + status = "okay"; +}; + +&ps_atc3_common { + status = "okay"; +}; + +&ps_atc3_usb_aon { + status = "okay"; +}; + +&ps_atc3_usb { + status = "okay"; +}; diff --git a/drivers/gpu/drm/apple/t8132_ext_drm.c b/drivers/gpu/drm/apple/t8132_ext_drm.c index e41adac648874..911f011ae400b 100644 --- a/drivers/gpu/drm/apple/t8132_ext_drm.c +++ b/drivers/gpu/drm/apple/t8132_ext_drm.c @@ -1090,7 +1090,7 @@ int t8132_ext_drm_init(struct drm_device *drm) bool mine, reg; int ret = 0; - if (!apple_t8132_air()) + if (!apple_t8132_firmware_path()) return 0; /* Sleep handling for the outputs of one DRM device only. */ mutex_lock(&t8132_ext_reg_lock); diff --git a/drivers/iommu/apple-dart-dcp-format.h b/drivers/iommu/apple-dart-dcp-format.h index b47db0f65e29b..c6e536904b510 100644 --- a/drivers/iommu/apple-dart-dcp-format.h +++ b/drivers/iommu/apple-dart-dcp-format.h @@ -157,9 +157,13 @@ static inline int dcp_adt_value(struct dcp_adt_tables *out, if (kind == 1 && !strcmp(name, "target-type")) { bit = 1; - /* The M4 Airs share the retained display handoff. */ - if (length != 5 || - (memcmp(value, "J713", 5) && memcmp(value, "J715", 5))) + /* Every M4 Mac shares the retained display handoff. */ + if (!(length == 5 && (!memcmp(value, "J713", 5) || + !memcmp(value, "J715", 5) || + !memcmp(value, "J604", 5) || + !memcmp(value, "J623", 5) || + !memcmp(value, "J624", 5))) && + !(length == 6 && !memcmp(value, "J773g", 6))) return -ENODEV; } else if (kind == 3 && !strcmp(name, "compatible")) { bit = 2; diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index d39ee78d9d73c..4acc60c4875e2 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -4112,20 +4112,20 @@ static int apple_dart_probe(struct platform_device *pdev) bool j713_display, j713_dcpext, j713_dispext, j713_radio; /* - * The J713/J715 internal display DARTs are live: DCP firmware (SID23) + * The M4 internal display DARTs are live: DCP firmware (SID23) * and the scanout/PIODMA frontend (SID0/SID16) keep using them. Leave * both untouched until userspace, with its watchdog armed, opts in. */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - j713_display = res && !tunneled && apple_t8132_air() && + j713_display = res && !tunneled && apple_t8132_firmware_path() && of_device_is_compatible(dev->of_node, "apple,t8132-dart") && (res->start == 0x30a300000ULL || res->start == 0x30a340000ULL); /* The external DCP firmware DARTs (SID23) of dcpext0 and dcpext1. */ - j713_dcpext = res && !tunneled && apple_t8132_air() && + j713_dcpext = res && !tunneled && apple_t8132_firmware_path() && of_device_is_compatible(dev->of_node, "apple,t8132-dart") && (res->start == 0x286340000ULL || res->start == 0x48a340000ULL); /* The external display DARTs (SID0/SID16) of dispext0 and dispext1. */ - j713_dispext = res && !tunneled && apple_t8132_air() && + j713_dispext = res && !tunneled && apple_t8132_firmware_path() && of_device_is_compatible(dev->of_node, "apple,t8132-dart") && (res->start == 0x286300000ULL || res->start == 0x48a300000ULL); /* The radio DART's fault interrupt is not described by the loader. */ diff --git a/drivers/pmdomain/apple/pmgr-pwrstate.c b/drivers/pmdomain/apple/pmgr-pwrstate.c index 2367cc8c339d6..b84bfc4432111 100644 --- a/drivers/pmdomain/apple/pmgr-pwrstate.c +++ b/drivers/pmdomain/apple/pmgr-pwrstate.c @@ -532,14 +532,13 @@ static int apple_pmgr_ps_probe(struct platform_device *pdev) t8132 = of_device_is_compatible(node, "apple,t8132-pmgr-pwrstate"); /* - * The original J713 loader tree, which the J715 shares, exposes domains - * Linux cannot access. The early compatibility adapter supplies the - * board's explicit status and ownership before population; fail closed - * if it was not enabled. Other T8132 boards keep their own domain - * descriptions and behaviour. + * On the M4 firmware path some domains are the firmware's, which Linux + * cannot access. The early compatibility adapter supplies the explicit + * status and ownership before population; fail closed if it was not + * enabled. Other firmware keeps the tree's own domain descriptions. */ - if (t8132 && apple_t8132_air() && !of_property_present(node, "status")) - return dev_err_probe(dev, -ENODEV, "missing J713 power-domain policy\n"); + if (t8132 && apple_t8132_firmware_path() && !of_property_present(node, "status")) + return dev_err_probe(dev, -ENODEV, "missing M4 power-domain policy\n"); tvm = of_parse_phandle(node, "power-domains", 0); if (t8132 && tvm) diff --git a/drivers/pmdomain/apple/pmp-report.c b/drivers/pmdomain/apple/pmp-report.c index d3b5350fc50e1..b3dceb84afa5a 100644 --- a/drivers/pmdomain/apple/pmp-report.c +++ b/drivers/pmdomain/apple/pmp-report.c @@ -487,7 +487,7 @@ int apple_pmp_report_wait_supplier_ready(struct device *supplier, unsigned int t struct platform_device *pdev; struct apple_pmp_report *rep; u64 status; - bool t8132 = apple_t8132_air() && + bool t8132 = apple_t8132_firmware_path() && of_device_is_compatible(supplier->of_node, "apple,t8132-pmp-v2"); int ret; diff --git a/drivers/soc/apple/display-gate.c b/drivers/soc/apple/display-gate.c index 94828093b3154..bdb4b6dac2031 100644 --- a/drivers/soc/apple/display-gate.c +++ b/drivers/soc/apple/display-gate.c @@ -3069,7 +3069,7 @@ static void __init gate_t6041_max_run(void) } /* - * J713 and J715: the dcpext Type-C routes are disabled in the device tree, + * M4: the dcpext Type-C routes are disabled in the device tree, * as on J613, because a USB-C port controller waits for the mode switch of * every available route. Enable them only for a dcpext the boot loader handed * over (apple,t8132-dcpext-firmware-ready = 1). A handed-over dcpext that is @@ -3115,7 +3115,7 @@ static int __init apple_display_gate(void) { int i; - if (apple_t8132_air()) { + if (apple_t8132_firmware_path()) { gate_j713_dcpext_routes(); return 0; } diff --git a/drivers/soc/apple/pmp-telemetry.c b/drivers/soc/apple/pmp-telemetry.c index 4ef51355328fe..788a5e3a4fac2 100644 --- a/drivers/soc/apple/pmp-telemetry.c +++ b/drivers/soc/apple/pmp-telemetry.c @@ -19,7 +19,7 @@ bool apple_pmp_telemetry_retained_board(void) { - return apple_t8132_air() && of_machine_is_compatible("apple,t8132"); + return apple_t8132_firmware_path() && of_machine_is_compatible("apple,t8132"); } static LIST_HEAD(apple_pmp_telemetry_list); diff --git a/drivers/soc/apple/rtkit-helper.c b/drivers/soc/apple/rtkit-helper.c index defca6cf9c4f5..9081068869083 100644 --- a/drivers/soc/apple/rtkit-helper.c +++ b/drivers/soc/apple/rtkit-helper.c @@ -283,7 +283,7 @@ static int apple_rtkit_helper_probe(struct platform_device *pdev) helper->preserved = true; } - if (!live && apple_t8132_air() && of_machine_is_compatible("apple,t8132")) { + if (!live && apple_t8132_live_mtp() && of_machine_is_compatible("apple,t8132")) { struct property *prop; u32 inherited; int len; diff --git a/drivers/soc/apple/t8132-platform-handoff.c b/drivers/soc/apple/t8132-platform-handoff.c index 35140c5404506..db33bf95c67bd 100644 --- a/drivers/soc/apple/t8132-platform-handoff.c +++ b/drivers/soc/apple/t8132-platform-handoff.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only OR MIT /* Supply missing platform descriptions for the original J713 loader ABI, - * which the J715 shares. + * which the J715 shares, and the M4 PMGR ownership policy on the qualified + * firmware for every M4 Mac. * Keep the shared m1n1 payload usable by the stable kernel. Hardware control * remains in the ordinary MCC, PMC and CLPC drivers, with one DTS data source. * J713 PMGR ownership/status also comes from its board DTS, before any domain @@ -132,8 +133,14 @@ static int __init t8132_fdt_node_offset(const void *data, return fdt_subnode_offset(data, parent, kbasename(node->full_name)); } -/* Apply only board availability/ownership, never imported register values. */ -static int __init t8132_pmgr_policy(struct of_changeset *cs, unsigned int *changed) +/* + * Apply only availability/ownership, never imported register values. Only the + * original J713 loader tree (the Airs') can mark a domain okay that the policy + * refuses. Other trees state what their board wires, so keep their status, + * except on domains the policy gives the firmware. + */ +static int __init t8132_pmgr_policy(struct of_changeset *cs, unsigned int *changed, + bool legacy) { const void *data = __dtb_t8132_platform_data_begin; const char * const ownership[] = { "apple,firmware-owned", "apple,inherited-on" }; @@ -152,6 +159,7 @@ static int __init t8132_pmgr_policy(struct of_changeset *cs, unsigned int *chang for_each_child_of_node_scoped(pmgr, node) { const char *status, *live; int offset, len; + bool owned; if (!of_device_is_compatible(node, "apple,t8132-pmgr-pwrstate")) continue; @@ -161,12 +169,16 @@ static int __init t8132_pmgr_policy(struct of_changeset *cs, unsigned int *chang /* Unknown legacy domains stay inaccessible, rather than being probed. */ if (!status) status = "disabled"; + owned = offset >= 0 && + (fdt_getprop(data, offset, ownership[0], NULL) || + fdt_getprop(data, offset, ownership[1], NULL)); if (of_property_read_string(node, "status", &live)) { ret = of_changeset_add_prop_string(cs, node, "status", status); if (ret) goto put_pmgr; (*changed)++; - } else if (!strcmp(status, "disabled") && strcmp(live, status)) { + } else if (strcmp(live, status) && + (legacy ? !strcmp(status, "disabled") : owned)) { ret = of_changeset_update_prop_string(cs, node, "status", status); if (ret) goto put_pmgr; @@ -217,7 +229,7 @@ static int __init t8132_platform_handoff(void) unsigned int added = 0, changed = 0; int root, node, ret; - if (!apple_t8132_air() || !of_machine_is_compatible("apple,t8132")) + if (!apple_t8132_firmware_path() || !of_machine_is_compatible("apple,t8132")) return 0; if (fdt_check_header(data)) return -EINVAL; @@ -230,7 +242,7 @@ static int __init t8132_platform_handoff(void) goto out; } of_changeset_init(cs); - ret = t8132_pmgr_policy(cs, &changed); + ret = t8132_pmgr_policy(cs, &changed, apple_t8132_air()); if (ret) goto destroy; diff --git a/drivers/thermal/apple-pmp-thermal.c b/drivers/thermal/apple-pmp-thermal.c index 41ca922045ae2..1f2c8e0e9b965 100644 --- a/drivers/thermal/apple-pmp-thermal.c +++ b/drivers/thermal/apple-pmp-thermal.c @@ -740,8 +740,8 @@ static int apple_pmp_thermal_probe(struct platform_device *pdev) { const struct apple_pmp_sensor_data *sensors = dev_get_platdata(&pdev->dev); - /* Only the M4 Airs' sensor topology and operating policy are qualified. */ - if (!apple_t8132_air()) + /* The M4 PMP sensor records and the Airs' fanless policy are qualified. */ + if (!apple_t8132_firmware_path()) return -ENODEV; if (!sensors || !sensors->read || !sensors->dev) return -EINVAL; diff --git a/include/linux/soc/apple/pmp-display.h b/include/linux/soc/apple/pmp-display.h index 350a3c5f4e1c7..7db16206d4e8a 100644 --- a/include/linux/soc/apple/pmp-display.h +++ b/include/linux/soc/apple/pmp-display.h @@ -6,10 +6,10 @@ #include #include -/* The retained M4 bridge and raw thermal records: J713, and the J715 too. */ +/* The retained M4 bridge and raw thermal records: the M4 firmware path. */ static inline bool apple_pmp_j713_board(void) { - return apple_t8132_air() && of_machine_is_compatible("apple,t8132"); + return apple_t8132_firmware_path() && of_machine_is_compatible("apple,t8132"); } struct device; diff --git a/include/linux/soc/apple/t8132.h b/include/linux/soc/apple/t8132.h index 72b1851550ea9..ec91e8faaa9b5 100644 --- a/include/linux/soc/apple/t8132.h +++ b/include/linux/soc/apple/t8132.h @@ -3,6 +3,7 @@ #define _LINUX_SOC_APPLE_T8132_H #include +#include #include /* @@ -30,6 +31,29 @@ static inline bool apple_t8132_pro_mini_imac(void) of_machine_is_compatible("apple,j773g"); } +/* + * The OS firmware the M4 PMP, PMGR ownership, display and GPU paths are + * qualified on, as the boot loader reports it: macOS 26.6.2 (iBoot + * mBoot-18000.161.10). These paths depend on the firmware, not the board. + */ +static inline bool apple_t8132_qualified_firmware(void) +{ + const char *version; + + return of_machine_is_compatible("apple,t8132") && + !of_property_read_string(of_chosen, "asahi,os-fw-version", &version) && + !strcmp(version, "26.6.2"); +} + +/* + * The firmware-dependent M4 paths: every M4 Mac on the qualified firmware, + * and the Airs on any firmware, as before. + */ +static inline bool apple_t8132_firmware_path(void) +{ + return apple_t8132_air() || apple_t8132_qualified_firmware(); +} + /* * The radio port the Airs have: reg-on on the SMC's gP13 with the same * template, and the radio's two ordinary streams managed on port 0 of the diff --git a/tools/asahi/t6030-pmp-graph-tests.c b/tools/asahi/t6030-pmp-graph-tests.c index f66c94e26fc6e..5f6d0c4d6214b 100644 --- a/tools/asahi/t6030-pmp-graph-tests.c +++ b/tools/asahi/t6030-pmp-graph-tests.c @@ -469,6 +469,11 @@ static inline bool apple_t8132_air(void) return of_machine_is_compatible("apple,j713") || of_machine_is_compatible("apple,j715"); } +/* The qualified-firmware term: these harnesses model no /chosen. */ +static inline bool apple_t8132_firmware_path(void) +{ + return apple_t8132_air(); +} static bool of_property_read_bool(const struct device_node *n, const char *p) { if (!strcmp(p, "apple,always-on")) diff --git a/tools/asahi/t6030-pmp-supplier-tests.c b/tools/asahi/t6030-pmp-supplier-tests.c index 6bbd3b30572e6..69f832bff9cb3 100644 --- a/tools/asahi/t6030-pmp-supplier-tests.c +++ b/tools/asahi/t6030-pmp-supplier-tests.c @@ -165,6 +165,11 @@ static inline bool apple_t8132_air(void) return of_machine_is_compatible("apple,j713") || of_machine_is_compatible("apple,j715"); } +/* The qualified-firmware term: these harnesses model no /chosen. */ +static inline bool apple_t8132_firmware_path(void) +{ + return apple_t8132_air(); +} static struct device_node *of_find_compatible_node(struct device_node *from, const char *type, const char *compat) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/m4-dart-boot-contract-test.py b/tools/testing/selftests/drivers/gpu/apple-dcp/m4-dart-boot-contract-test.py index a5d7ebc5d9015..d00a4c5526b66 100755 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/m4-dart-boot-contract-test.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/m4-dart-boot-contract-test.py @@ -87,6 +87,11 @@ def address(node): !strcmp(s,"apple,j624") || !strcmp(s,"apple,j773g")) return false; assert(!strcmp(s,"apple,t8132")); return soc; } +/* No /chosen: the qualified-firmware term is off and the Air gates decide. */ +static struct device_node *of_chosen; +static int of_property_read_string(const struct device_node *n,const char *p,const char **out) { + (void)n;(void)p;(void)out;return -22; +} AIR_HELPER static bool of_device_is_compatible(const struct device_node *n,const char *s) { for(unsigned int i=0;icount;i++) if(!strcmp(n->compatible[i],s))return true;