From bed961c8f1c9f07c534f69bac4376cd7ee1db275 Mon Sep 17 00:00:00 2001 From: Sean Dolbec Date: Thu, 19 Nov 2026 07:41:47 -0500 Subject: [PATCH 1/3] kboot: offer the T8132 AOP handoff on what the ADT and tree provide dt_set_t8132_aop() began with a list of boards (J713, J604), so no other T8132 tree could get the handoff. Its conditions are already checked one by one: the tree asks for it, the AOP is halted, the ADT's segments and DAPF windows reserve, and the DAPF programs from the ADT. Drop the board list. Make the tree edits a transaction and program the DAPF, the only hardware write, after them: a failed step leaves no reservation behind and no DAPF slice changed, and disables the AOP. A tree that does not ask for the handoff is left as it is. The host test runs the production function on six board trees, fails each step in turn and checks the order of the hardware write. Assisted-by: LLM Signed-off-by: Sean Dolbec --- src/kboot.c | 59 +++++++------ tests/python/test_t8132_aop_gate.py | 125 ++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 24 deletions(-) create mode 100644 tests/python/test_t8132_aop_gate.py diff --git a/src/kboot.c b/src/kboot.c index 91f39a93..168f7d49 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -9013,30 +9013,46 @@ static int dt_reserve_t8132_aop_windows(const char *path) return 0; } +/* dt_display_transaction has an integer-only callback; the handoff is single-threaded. */ +static const char *t8132_aop_path; + /* - * J713 and J604: iBoot leaves the AOP halted, its DART's DAPF empty, its + * Every FDT edit of the AOP handoff, then the one hardware write, last: the DAPF is programmed + * only once the segments and windows are reserved, and dapf_init_t8132_halted() puts every + * slice back if its own read-back fails. Run as a transaction, so a failure at any step leaves + * neither the tree nor the DAPF half done. + */ +static int dt_set_t8132_aop_one(unsigned int unused) +{ + UNUSED(unused); + if (dt_reserve_asc_segments("/arm-io/aop/iop-aop-nub", NULL, t8132_aop_path, true, 0, true)) + bail("FDT: %s: AOP firmware segments are not reserved\n", t8132_aop_path); + if (dt_reserve_t8132_aop_windows(t8132_aop_path)) + bail("FDT: %s: AOP DAPF windows are not reserved\n", t8132_aop_path); + if (dapf_init_t8132_halted("/arm-io/dart-aop", 1)) + bail("FDT: %s: AOP DAPF is not programmed\n", t8132_aop_path); + return 0; +} + +/* + * T8132: iBoot leaves the AOP halted, its DART's DAPF empty, its * external code (__ETEXT) in DRAM at a fixed address and its log (__OS_LOG) at - * a new one every boot. When the OS asks for the AOP's handoff, program the - * DAPF, then reserve both segments at the IOVAs the firmware uses (their remap - * addresses: EC0p for __ETEXT, the physical address for __OS_LOG) and the - * DAPF windows. Without all of it the firmware cannot run, so on any failure - * the AOP is disabled. + * a new one every boot. When the OS asks for the AOP's handoff, reserve both + * segments at the IOVAs the firmware uses (their remap addresses: EC0p for + * __ETEXT, the physical address for __OS_LOG) and the DAPF windows, then + * program the DAPF. Without all of it the firmware cannot run, so on any + * failure the AOP is disabled. Nothing here depends on the board. A tree that + * does not ask for the handoff is left as it is. */ static int dt_set_t8132_aop(const char *path) { const char *why; int node; - if (fdt_node_check_compatible(dt, 0, "apple,j713") && - fdt_node_check_compatible(dt, 0, "apple,j604")) - return 0; /* No other M4 board's AOP handoff is qualified. */ - int chosen = fdt_path_offset(dt, "/chosen"); if (chosen < 0 || - fdt_stringlist_search(dt, chosen, "linux-enablement-mac,dapf-handoff", "/arm-io/aop") < 0) { - why = "its handoff was not requested"; - goto disable; - } + fdt_stringlist_search(dt, chosen, "linux-enablement-mac,dapf-handoff", "/arm-io/aop") < 0) + return 0; asc_dev_t *asc = asc_init("/arm-io/aop"); if (!asc) { @@ -9050,16 +9066,11 @@ static int dt_set_t8132_aop(const char *path) goto disable; } - if (dapf_init_t8132_halted("/arm-io/dart-aop", 1)) { - why = "its DAPF is not programmed"; - goto disable; - } - if (dt_reserve_asc_segments("/arm-io/aop/iop-aop-nub", NULL, path, true, 0, true)) { - why = "its firmware segments are not reserved"; - goto disable; - } - if (dt_reserve_t8132_aop_windows(path)) { - why = "its DAPF windows are not reserved"; + t8132_aop_path = path; + int ret = dt_display_transaction(dt_set_t8132_aop_one, 0); + t8132_aop_path = NULL; + if (ret) { + why = "its handoff is incomplete"; goto disable; } diff --git a/tests/python/test_t8132_aop_gate.py b/tests/python/test_t8132_aop_gate.py new file mode 100644 index 00000000..9edb18e1 --- /dev/null +++ b/tests/python/test_t8132_aop_gate.py @@ -0,0 +1,125 @@ +# SPDX-License-Identifier: GPL-2.0-only +"""Run the production T8132 AOP handoff on trees of several boards: none is treated specially.""" +from pathlib import Path + +from test_j713_dapf_instance import block +from test_siliconforest_handoff import run_c + +ROOT = Path(__file__).resolve().parents[2] + +# What can go wrong: the handoff depends on the board again; a tree that does not ask for the +# handoff is changed; the DAPF (the only hardware write) is programmed before the tree edits are +# known to succeed; a failed step leaves reservations in the tree or the AOP enabled. +HARNESS = r''' +#include +#include +#include +#include +#include +#include +#include "libfdt.h" +typedef uint32_t u32; +typedef unsigned long u64; +typedef struct { int unused; } asc_dev_t; +#define bail(...) do { printf(__VA_ARGS__); return -1; } while (0) +#define UNUSED(x) (void)(x) +static void *dt; +static asc_dev_t the_asc; +static int touched, fail; +static bool running; +static asc_dev_t *asc_init(const char *path) +{ assert(!strcmp(path, "/arm-io/aop")); touched++; return fail == 1 ? NULL : &the_asc; } +static bool asc_cpu_running(asc_dev_t *asc) { return running; } +static void asc_free(asc_dev_t *asc) {} +/* The one hardware write. It must come after both reservations were made in the tree. */ +static int dapf_writes, reserved; +static int dapf_init_t8132_halted(const char *path, int index) +{ assert(!strcmp(path, "/arm-io/dart-aop") && index == 1 && reserved == 2); touched++; + if (fail == 4) return -1; + dapf_writes++; return 0; } +static int reserve(const char *name) +{ + int node = fdt_add_subnode(dt, fdt_path_offset(dt, "/reserved-memory"), name); + assert(node >= 0); + reserved++; + return 0; +} +static int dt_reserve_asc_segments(const char *adt_path, const char *alt, const char *path, + bool remap, u64 base, bool dram_only) +{ assert(!strcmp(adt_path, "/arm-io/aop/iop-aop-nub") && remap && dram_only && !dapf_writes); + touched++; return fail == 2 ? -1 : reserve("asc-firmware@1"); } +static int dt_reserve_t8132_aop_windows(const char *path) +{ assert(!dapf_writes); touched++; return fail == 3 ? -1 : reserve("asc-mmio@2"); } +''' + +MAIN = r''' +static unsigned char blob[4096]; +static void tree(const char *board, bool requested) +{ + char compatible[64]; + int len = snprintf(compatible, sizeof(compatible), "%s%c%s", board, 0, "apple,t8132") + 1; + dt = blob; + assert(!fdt_create_empty_tree(dt, sizeof(blob))); + assert(!fdt_setprop(dt, 0, "compatible", compatible, len)); + assert(fdt_add_subnode(dt, 0, "reserved-memory") >= 0); + int chosen = fdt_add_subnode(dt, 0, "chosen"); + if (requested) + assert(!fdt_setprop(dt, chosen, "linux-enablement-mac,dapf-handoff", + "/arm-io/aop\0/arm-io/pmp", sizeof("/arm-io/aop\0/arm-io/pmp"))); + int aop = fdt_add_subnode(dt, 0, "aop@390600000"); + assert(aop >= 0 && !fdt_setprop_string(dt, aop, "compatible", "apple,t8132-aop")); + assert(!fdt_setprop_string(dt, aop, "status", "okay")); + touched = fail = dapf_writes = reserved = 0; + running = false; +} +static const char *status(void) +{ + return fdt_getprop(dt, fdt_path_offset(dt, "/aop@390600000"), "status", NULL); +} +int main(void) +{ + /* Any T8132 tree: a requested, halted AOP is handed over; any failed step disables it. */ + static const char *const boards[] = {"apple,j713", "apple,j604", "apple,j623", + "apple,j624", "apple,j715", "apple,j773g"}; + static unsigned char before[sizeof(blob)]; + for (unsigned i = 0; i < sizeof(boards) / sizeof(*boards); i++) { + tree(boards[i], true); + assert(!dt_set_t8132_aop("/aop@390600000") && !strcmp(status(), "okay")); + assert(touched == 4 && dapf_writes == 1 && reserved == 2); + assert(fdt_path_offset(dt, "/reserved-memory/asc-firmware@1") >= 0); + assert(fdt_path_offset(dt, "/reserved-memory/asc-mmio@2") >= 0); + /* 1: no ASC. 2: segments. 3: windows. 4: the DAPF write itself, which comes last. */ + for (int f = 1; f <= 4; f++) { + tree(boards[i], true); + fail = f; + assert(!dt_set_t8132_aop("/aop@390600000") && !strcmp(status(), "disabled")); + assert(touched == f && !dapf_writes); + /* No reservation of a refused handoff stays in the tree. */ + assert(fdt_path_offset(dt, "/reserved-memory/asc-firmware@1") < 0); + assert(fdt_path_offset(dt, "/reserved-memory/asc-mmio@2") < 0); + } + tree(boards[i], true); + running = true; + assert(!dt_set_t8132_aop("/aop@390600000") && !strcmp(status(), "disabled") && touched == 1); + /* Not requested: the tree is byte for byte as it was and no hardware is touched. */ + tree(boards[i], false); + memcpy(before, blob, sizeof(blob)); + assert(!dt_set_t8132_aop("/aop@390600000") && !touched); + assert(!memcmp(before, blob, sizeof(blob)) && !strcmp(status(), "okay")); + } + return 0; +} +''' + + +def production(): + kboot = (ROOT / "src/kboot.c").read_text() + return (block(kboot, "static int dt_display_transaction(") + "\n" + + "static const char *t8132_aop_path;\n" + + block(kboot, "static int dt_set_t8132_aop_one(") + "\n" + + block(kboot, "static int dt_set_t8132_aop(") + "\n") + + +def test_t8132_aop_gate(tmp_path): + run_c(tmp_path, "t8132-aop-gate", + HARNESS + production() + MAIN) From 75b2bd126c2d7bce6e1f8b98399b578e94b5599f Mon Sep 17 00:00:00 2001 From: Sean Dolbec Date: Thu, 19 Nov 2026 07:42:02 -0500 Subject: [PATCH 2/3] kboot: keep the T8132 ISP disabled on a Mac whose ADT has no camera A T8132 Mac without a camera has no isp or isp0 node in its ADT, but nothing stopped a tree from enabling the ISP there: the OS would probe a camera and ISP power domains that do not exist. dt_set_isp() disables only the node the isp alias names, and not its DARTs. When the ADT has neither node, disable every enabled apple,t8132-isp node and the DARTs in its iommus list that no other node uses, before dt_set_isp() runs. The rule follows the ADT and the tree only; it lives in kboot_t8132.c, out of Stage 1's full .init slot. If it cannot write the tree it says so and the boot goes on. The host tests cover an enabled and a disabled ISP, a shared DART, a malformed iommus list, a full tree and an ADT with isp or isp0, and run the rule with the real dt_set_isp() in kboot_prepare_dt()'s order. Assisted-by: LLM Signed-off-by: Sean Dolbec --- Makefile | 2 +- src/kboot.c | 6 + src/kboot.h | 3 + src/kboot_t8132.c | 74 +++++++++++ tests/python/test_t8132_isp_absent.py | 183 ++++++++++++++++++++++++++ 5 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 src/kboot_t8132.c create mode 100644 tests/python/test_t8132_isp_absent.py diff --git a/Makefile b/Makefile index 2bd9bdfb..36d13abf 100644 --- a/Makefile +++ b/Makefile @@ -258,7 +258,7 @@ OBJECTS := \ isp.o \ j873.o \ kboot.o kboot_atc.o kboot_audio.o kboot_mte.o kboot_gpu_t8122.o kboot_gpu_t8122_power.o kboot_pmp_t8122.o \ - kboot_t6020_compat.o \ + kboot_t6020_compat.o kboot_t8132.o \ kboot_display_handoff.o kboot_display_facts.o kboot_gpu26.o kboot_gpu_t6031.o kboot_t6031.o \ main.o boot_options.o \ mitigations.o \ diff --git a/src/kboot.c b/src/kboot.c index 168f7d49..1467849e 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -11626,6 +11626,12 @@ int kboot_prepare_dt(void *fdt) return -1; if (dt_set_aop_firmware()) return -1; + /* + * Before dt_set_isp(): on a Mac with no ISP in its ADT that disables the ISP but not its + * DARTs, and this rule leaves an ISP that is already disabled as it is. + */ + if (dt_disable_t8132_absent_isp(dt)) + printf("FDT: T8132 absent-ISP rule failed; the ISP nodes stay as the tree has them\n"); if (dt_set_isp()) return -1; dt_set_j713_isp(); diff --git a/src/kboot.h b/src/kboot.h index f9a1d46a..a440972e 100644 --- a/src/kboot.h +++ b/src/kboot.h @@ -35,6 +35,9 @@ int kboot_boot(void *kernel); /* Reserve the DMA a USB controller that could not be stopped keeps (main.c, after USB shutdown). */ int kboot_reserve_usb_dma(void); +/* Disable the ISP and the DARTs only it uses on a T8132 Mac whose ADT has no camera. */ +int dt_disable_t8132_absent_isp(void *dt); + /* Boot-args RAM range and boot framebuffer base, for the kboot_* SoC helpers */ u64 kboot_ram_base(void); u64 kboot_ram_size(void); diff --git a/src/kboot_t8132.c b/src/kboot_t8132.c new file mode 100644 index 00000000..29d47708 --- /dev/null +++ b/src/kboot_t8132.c @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: MIT */ +/* + * T8132 (M4) rules. They live here, not in kboot.c: kboot.c's code is linked into Stage 1's + * .init slot (aura-raw.ld), which has almost no room left. + */ + +#include "kboot.h" +#include "adt.h" +#include "utils.h" + +#include "libfdt/libfdt.h" + +#define bail(...) \ + do { \ + printf(__VA_ARGS__); \ + return -1; \ + } while (0) + +/* Whether a node other than skip names the IOMMU phandle in its iommus list. */ +static bool dt_iommu_shared(const void *dt, u32 phandle, int skip) +{ + int node; + + for (node = fdt_next_node(dt, -1, NULL); node >= 0; node = fdt_next_node(dt, node, NULL)) { + int len; + const fdt32_t *iommus = node == skip ? NULL : fdt_getprop(dt, node, "iommus", &len); + + for (int i = 0; iommus && i + 1 < len / (int)sizeof(*iommus); i += 2) + if (fdt32_ld(&iommus[i]) == phandle) + return true; + } + return false; +} + +/* + * A T8132 Mac without a camera (the J773g) has no isp or isp0 in its ADT. A tree that enables + * the ISP there would have the OS probe a camera and power domains that do not exist: disable + * the ISP and the DARTs that only it uses. A tree that leaves it disabled is not changed. + */ +int dt_disable_t8132_absent_isp(void *dt) +{ + if (adt_path_offset(adt, "/arm-io/isp") >= 0 || adt_path_offset(adt, "/arm-io/isp0") >= 0) + return 0; + + int isp = -1; + while ((isp = fdt_node_offset_by_compatible(dt, isp, "apple,t8132-isp")) >= 0) { + const char *status = fdt_getprop(dt, isp, "status", NULL); + if (status && !strcmp(status, "disabled")) + continue; + + /* One cell of stream ID per DART, as in t8132.dtsi. Decide before any write. */ + u32 darts[8]; + bool own[8]; + int len, count = 0; + const fdt32_t *iommus = fdt_getprop(dt, isp, "iommus", &len); + int cells = iommus && len > 0 && !(len % sizeof(*iommus)) ? len / sizeof(*iommus) : 0; + if (!(cells % 2) && cells / 2 <= (int)ARRAY_SIZE(darts)) + for (; count < cells / 2; count++) { + darts[count] = fdt32_ld(&iommus[2 * count]); + own[count] = !dt_iommu_shared(dt, darts[count], isp); + } + + if (fdt_setprop_string(dt, isp, "status", "disabled")) + bail("FDT: cannot disable the T8132 ISP\n"); + for (int i = 0; i < count; i++) { + int dart = own[i] ? fdt_node_offset_by_phandle(dt, darts[i]) : -1; + if (dart >= 0 && fdt_setprop_string(dt, dart, "status", "disabled")) + bail("FDT: cannot disable a T8132 ISP DART\n"); + } + printf("FDT: no ISP in the ADT; T8132 ISP disabled with the DARTs only it uses\n"); + isp = -1; /* Offsets moved; start over. Disabled nodes are skipped. */ + } + return 0; +} diff --git a/tests/python/test_t8132_isp_absent.py b/tests/python/test_t8132_isp_absent.py new file mode 100644 index 00000000..b9909bd2 --- /dev/null +++ b/tests/python/test_t8132_isp_absent.py @@ -0,0 +1,183 @@ +# SPDX-License-Identifier: GPL-2.0-only +"""Run the production T8132 rule for a machine whose ADT has no camera (the J773g).""" +from pathlib import Path + +from test_j713_dapf_instance import block +from test_siliconforest_handoff import run_c + +ROOT = Path(__file__).resolve().parents[2] + +# What can go wrong: a tree that enables the T8132 ISP or its DARTs on a Mac with no ISP in +# its ADT (the J773g has none) makes the OS probe a camera and power domains that are not +# there; the rule touches a machine that does have an ISP, or another SoC; it disables a +# DART that another device shares; a malformed iommus list stops the boot; an earlier +# handoff step disables the ISP first, so the rule skips it and leaves its DARTs enabled. +TREE = r''' +static unsigned char blob[4096]; +static void tree(bool enabled, bool shared) +{ + dt = blob; + assert(!fdt_create_empty_tree(dt, sizeof(blob))); + int aliases = fdt_add_subnode(dt, 0, "aliases"); + assert(aliases >= 0 && !fdt_setprop_string(dt, aliases, "isp", "/isp@48c000000")); + static const char *const names[] = {"iommu@48e8c0000", "iommu@48e8e0000", "iommu@48e900000"}; + for (int i = 0; i < 3; i++) { + int dart = fdt_add_subnode(dt, 0, names[i]); + assert(dart >= 0 && !fdt_setprop_u32(dt, dart, "phandle", 10 + i)); + assert(!fdt_setprop_u32(dt, dart, "#iommu-cells", 1)); + } + int isp = fdt_add_subnode(dt, 0, "isp@48c000000"); + assert(isp >= 0 && !fdt_setprop(dt, isp, "compatible", "apple,t8132-isp\0apple,isp", + sizeof("apple,t8132-isp\0apple,isp"))); + fdt32_t iommus[] = {cpu_to_fdt32(10), 0, cpu_to_fdt32(11), 0, cpu_to_fdt32(12), 0}; + assert(!fdt_setprop(dt, isp, "iommus", iommus, sizeof(iommus))); + if (!enabled) + assert(!fdt_setprop_string(dt, isp, "status", "disabled")); + int other = fdt_add_subnode(dt, 0, "other@0"); + assert(other >= 0); + if (shared) { + fdt32_t ref[] = {cpu_to_fdt32(12), cpu_to_fdt32(1)}; + assert(!fdt_setprop(dt, other, "iommus", ref, sizeof(ref))); + } +} +static const char *status(const char *path) +{ + const char *s = fdt_getprop(dt, fdt_path_offset(dt, path), "status", NULL); + return s ? s : "okay"; +} +static bool off(const char *path) { return !strcmp(status(path), "disabled"); } +''' + +MAIN = TREE + r''' +int main(void) +{ + /* No ISP in the ADT: the ISP and its three DARTs end disabled. */ + tree(true, false); + assert(!dt_disable_t8132_absent_isp(dt)); + assert(off("/isp@48c000000") && off("/iommu@48e8c0000") && off("/iommu@48e8e0000") && + off("/iommu@48e900000") && !off("/other@0")); + /* A tree that already leaves it disabled is left exactly as it is. */ + tree(false, false); + unsigned char before[sizeof(blob)]; + memcpy(before, blob, sizeof(blob)); + assert(!dt_disable_t8132_absent_isp(dt) && !memcmp(before, blob, sizeof(blob))); + /* A DART another device also uses stays as it is. */ + tree(true, true); + assert(!dt_disable_t8132_absent_isp(dt)); + assert(off("/isp@48c000000") && off("/iommu@48e8c0000") && off("/iommu@48e8e0000") && + !off("/iommu@48e900000")); + /* A broken iommus list still leaves the ISP disabled. */ + tree(true, false); + assert(!fdt_setprop(dt, fdt_path_offset(dt, "/isp@48c000000"), "iommus", "\0\0\0\x63\0", 5)); + assert(!dt_disable_t8132_absent_isp(dt) && off("/isp@48c000000")); + assert(!off("/iommu@48e8c0000")); + /* No room left in the tree: the rule reports the failure and does not crash. */ + tree(true, false); + assert(!fdt_pack(dt)); + assert(dt_disable_t8132_absent_isp(dt) == -1); + /* A machine with an ISP in its ADT (the J713) is not touched. The rule follows the ADT and + * the tree's apple,t8132-isp node only: there is no chip or board test to get wrong. */ + for (int c = 0; c < 2; c++) { + tree(true, false); + memcpy(before, blob, sizeof(blob)); + adt_isp = c == 0; adt_isp0 = c == 1; + assert(!dt_disable_t8132_absent_isp(dt) && !memcmp(before, blob, sizeof(blob))); + adt_isp = adt_isp0 = false; + } + return 0; +} +''' + + +HEADER = r''' +#include +#include +#include +#include +#include +#include "libfdt.h" +typedef uint32_t u32; +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define bail(...) do { printf(__VA_ARGS__); return -1; } while (0) +static void *dt, *adt; +static bool adt_isp, adt_isp0; +static int adt_path_offset(const void *tree, const char *path) +{ + if (!strcmp(path, "/arm-io/isp")) return adt_isp ? 1 : -1; + if (!strcmp(path, "/arm-io/isp0")) return adt_isp0 ? 2 : -1; + return -1; +} +''' + + +def rule(): + kboot = (ROOT / "src/kboot_t8132.c").read_text() + return (block(kboot, "static bool dt_iommu_shared(") + "\n" + + block(kboot, "int dt_disable_t8132_absent_isp(") + "\n") + + +def test_t8132_isp_absent(tmp_path): + run_c(tmp_path, "t8132-isp-absent", HEADER + rule() + MAIN) + + +# kboot_prepare_dt() runs the generic dt_set_isp() too. On a Mac with no ISP in its ADT it +# cannot reserve the ISP firmware and disables the node the isp alias names. Run the real +# dt_set_isp() and the real call sequence: the rule must still disable the DARTs only the +# ISP uses, and a machine with an ISP must still reach the generic step. +ORDER = r''' +#define T8132 0x8132 +#define T6040 0x6040 +#define T6050 0x6050 +#define T8140 0x8140 +#define T8142 0x8142 +typedef unsigned long u64; +static u32 chip_id = T8132, board_id; +static int generic_ran; +static bool adt_is_compatible(const void *tree, int node, const char *c) { return false; } +static int dt_t6050_isp_transaction(void) { return -1; } +static int isp_get_heap(u64 *phys, u64 *iova, u64 *size) { return -1; } +static u64 isp_iova_base(void) { return 0; } +static int dt_set_isp_fwdata(void) { return 0; } +/* As dt_reserve_asc_segments_at(): no ADT node, no reservation. */ +static int dt_reserve_asc_firmware(const char *adt_path, const char *adt_path_alt, + const char *fdt_path, bool remap, u64 base) +{ + generic_ran++; + return adt_path_offset(adt, adt_path) < 0 && adt_path_offset(adt, adt_path_alt) < 0 ? -1 : 0; +} +static void dt_set_j713_isp(void) {} +''' + + +def test_t8132_isp_absent_in_handoff_order(tmp_path): + kboot = (ROOT / "src/kboot.c").read_text() + prepare = block(kboot, "int kboot_prepare_dt(") + start = prepare.index(" if (dt_set_aop_firmware())\n return -1;\n") + start = prepare.index("\n", prepare.index("return -1;", start)) + 1 + steps = prepare[start:prepare.index(" if (dt_set_pmgr())", start)] + assert "dt_set_isp()" in steps and "dt_disable_t8132_absent_isp(dt)" in steps + # A failed rule must not abort the boot: kboot_prepare_dt() logs it and goes on. + assert " if (dt_disable_t8132_absent_isp(dt))\n printf(" in steps + run_c(tmp_path, "t8132-isp-absent-order", HEADER + rule() + ORDER + + block(kboot, "static int dt_set_isp(void)") + TREE + + "static int handoff(void)\n{\n" + steps + " return 0;\n}\n" + r''' +int main(void) +{ + /* No ISP in the ADT: whichever step disables the ISP, its DARTs end disabled. */ + tree(true, false); + assert(!handoff() && generic_ran == 1); + assert(off("/isp@48c000000") && off("/iommu@48e8c0000") && off("/iommu@48e8e0000") && + off("/iommu@48e900000") && !off("/other@0")); + /* A DART another device also uses stays as it is. */ + tree(true, true); + assert(!handoff()); + assert(off("/iommu@48e8c0000") && off("/iommu@48e8e0000") && !off("/iommu@48e900000")); + /* With an ISP in the ADT the rule does nothing and the generic step reserves it. */ + adt_isp = true; + tree(true, false); + generic_ran = 0; + assert(!handoff() && generic_ran == 1); + assert(!off("/isp@48c000000") && !off("/iommu@48e8c0000")); + return 0; +} +''') From 53be8212bea9143c806eca8fa96b548bf26769bf Mon Sep 17 00:00:00 2001 From: Sean Dolbec Date: Thu, 19 Nov 2026 07:42:27 -0500 Subject: [PATCH 3/3] kboot_atc: copy the T8132 USB3 calibration on any PHY whose ADT has it dt_copy_atc_tunables() gave an apple,t8132-atcphy node the T8132 USB3 bundle only under a J713 or J604 tree. The copy itself already decides per PHY from the ADT: every required group must be present and well formed, or nothing of the bundle is published and the PHY keeps its USB2 fallback. Drop the board list and the chip id test. The bundle goes to any tree node that is apple,t8132-atcphy whose ADT node is atc-phy,t8132. The host test runs the production copy on the four PHYs of a J773g ADT under five board trees; hides one required group on one PHY; and tries an ADT PHY of another type and a tree node of another type. Assisted-by: LLM Signed-off-by: Sean Dolbec --- src/kboot_atc.c | 9 +- tests/data/j773g-atc-usb3.json | 183 ++++++++++++++ tests/python/test_t8132_atc_usb3_any_board.py | 227 ++++++++++++++++++ 3 files changed, 415 insertions(+), 4 deletions(-) create mode 100644 tests/data/j773g-atc-usb3.json create mode 100644 tests/python/test_t8132_atc_usb3_any_board.py diff --git a/src/kboot_atc.c b/src/kboot_atc.c index a8ab9d94..957b0aaf 100644 --- a/src/kboot_atc.c +++ b/src/kboot_atc.c @@ -872,10 +872,11 @@ static void dt_copy_atc_tunables(void *dt, const char *adt_path, const char *dt_ if (adt_node < 0) return; - if (chip_id == T8132 && - (!fdt_node_check_compatible(dt, 0, "apple,j713") || - !fdt_node_check_compatible(dt, 0, "apple,j604")) && - !fdt_node_check_compatible(dt, fdt_node, "apple,t8132-atcphy") && + /* + * Any T8132 PHY, whatever the board: a PHY whose ADT node has the whole USB3 bundle gets + * it, one that lacks a group keeps its USB2 fallback. + */ + if (!fdt_node_check_compatible(dt, fdt_node, "apple,t8132-atcphy") && adt_is_compatible_at(adt, adt_node, "atc-phy,t8132", 0)) { dt_copy_t8132_usb3_tunables(dt, adt_node, fdt_node); return; diff --git a/tests/data/j773g-atc-usb3.json b/tests/data/j773g-atc-usb3.json new file mode 100644 index 00000000..ca564632 --- /dev/null +++ b/tests/data/j773g-atc-usb3.json @@ -0,0 +1,183 @@ +{ + "SPDX-License-Identifier": "GPL-2.0-only OR MIT", + "description": "J773g (Mac mini, M4) on the macOS 27.2 (26B123) stub: the USB3 calibration groups of /arm-io/atc-phy0..3 as iBoot filled them in, and the properties the loader must publish from them. Nothing else of the ADT is included.", + "source_adt_sha256": "e0487b2be078c7e8e098ab4432b92b0c3d99ebf852ba8e29fa35fc983468f3b8", + "ports": [ + { + "adt_node": "/arm-io/atc-phy0", + "properties": { + "tunable_ATCAXI2AF": "00000020ff0000801b00008004000020ff00ff800f000f8008000020ff00ff8003001b800c000020ff00ff800f000f8010000020ff00ff800f000f8014000020ff00ff800f000f8018000020ff00ff80030001801c000020ff00ff800300018020000020ff0000801000008024000020ff0000802c00008028000020ff00ff80080020802c000020ff00ff801000188030000020ff00ff800800208034000020ff00ff800800208038000020ff00ff8004000c803c000020ff00ff800800088040000020ff0000801800008044000020ff0000800e00008048000020ff0000800e00008000010020ff000000ff000000040100200000ff0000000100080100200600ffff000004000403002000003f3f000008081403002000000080000000801c03002000000080000000802403002000000080000000802c030020000000800000008050030020ffffffffffff000054030020ffffffffffff0000080400202000ffff20000f0048090020ff07ff0700002800480a0020ff07ff0740004000480b0020ff07ff0750006200480c0020ff07ff074a004a00000f0020ffffffffffffff7f040f002000010000000100000840002001000000010000000c40002001000000000000001440002001000000010000001840002001000000000000001c4000200100000001000000204000200000ffff00000000244000200000ffff00000000284000200000ffff000000002c4000200000ffff00000000304000200000ffff00000000344000200000ffff00000000384000200000ffff000000003c4000200000ffff00000000", + "tunable_ATCAXI2AF_WR_DIS": "f81100200100000001000000f81200200100000001000000f81300200100000001000000f81400200100000001000000f81500200100000001000000", + "tunable_ATCAXI2AF_LOCK_LOCK": "fc1100200100000001000000fc1200200100000001000000fc1300200100000001000000fc1400200100000001000000fc1500200100000001000000", + "tunable_ATCAXI2AF_LIOA_IOA": "280000202ffe0000000000002c0000200700000000000000300000207f0000000000000034000020ff00000000000000580000200b01000000000000", + "tunable_ATC_FABRIC": "040000203f003f00200020000c000020f1000000a1000000100000201f80000004000000180000203f003f002000200020000020f1000000a1000000240000201f800000040000002c0000207f007f004100410034000020f1000000710000003800002001000000010000003c0000200100000001000000400000201f80000004000000480000201f00000010000000500000201f80000004000000580000207f007f004500450060000020f100000051000000640000201f800000040000006c0000203f00000020000000740000201f800000040000007c0000200100000001000000800000201f80000004000000880000201f001f00100010008c000020f100000011000000900000200100000001000000940000200100000001000000980000201f80000004000000a00000201f001f0010001000a4000020f100000011000000a80000201f80000004000000b0000020ff000000a0000000b40000201f80000004000000bc0000203f00000020000000c40000201f80000004000000cc0000203f00000020000000d40000201f80000004000000dc0000201f001f0010001000e40000200100000001000000e80000200100000001000000ec0000201f80000004000000f40000200f00000008000000f80000201f80000004000000000100200100000001000000040100200100000001000000080100201f80000004000000100100200100000001000000140100200100000001000000180100201f80000004000000200100200100000001000000240100200100000001000000280100201f80000004000000300100200100000001000000340100200100000001000000380100201f8000000400000040010020ffffffff01010101440100201f800000040000004c0100201f8000000400000054010020ffffffff0101010158010020ffff0000010100005c010020ffffffff01010101600100201f80000004000000680100201f80000004000000700100201f800000040000007801002001000000010000007c0100200100000001000000800100201f8000000400000088010020ffffffff010101018c010020ffff000001010000900100201f800000040000009801002001000000010000009c0100200100000001000000a00100201f80000004000000a80100201f80000004000000", + "tunable_ATC_COMMON_CFG": "080000200100000001000000", + "tunable_AUSCMN_DIG": "0000002000003f0000002300", + "tunable_AUSPLL_CORE": "24000020000c000000080000300000201f0000000f000000400000207f00180049000000b00000200000700800003000e80000200100060001000400380100200000800f00008007", + "tunable_CIO3PLL_CORE": "0000002088080000880800000800002000001f000000030024000020000c00000008000028000020000f0000000b0000300000201f0000000f0000004c00002000fe7f00003c6300b00000200000700000003000e8000020000006000000020000010020ff0f0000d8000000", + "tunable_CIO3PLL_TOP": "940000200001000000010000a0000020ff01000014010000", + "tunable_ACIOPHY_LANE_USBC0": "040000200000007c00000044", + "tunable_ACIOPHY_PLL_TOP": "300000200080000000800000", + "tunable_ACIOPHY_TOP": "0c0100200000040000000000", + "tunable_AUSCMN_SHM": "040000207c00000038000000", + "tunable_CLKMON_CFG": "0c000020ff03000000020000", + "tunable_LN0_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN0_RX_TOP_USB_EQA": "", + "tunable_LN0_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN0_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN0_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN0_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_LN1_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN1_RX_TOP_USB_EQA": "", + "tunable_LN1_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN1_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN1_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN1_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_AUX_TOP": "0800002038000000080000000c0000201f00000000000000" + }, + "expected_be_hex": { + "apple,tunable-usb3-axi2af": "00000000800000ff8000001b0000000480ff00ff800f000f0000000880ff00ff801b00030000000c80ff00ff800f000f0000001080ff00ff800f000f0000001480ff00ff800f000f0000001880ff00ff800100030000001c80ff00ff8001000300000020800000ff8000001000000024800000ff8000002c0000002880ff00ff802000080000002c80ff00ff801800100000003080ff00ff802000080000003480ff00ff802000080000003880ff00ff800c00040000003c80ff00ff8008000800000040800000ff8000001800000044800000ff8000000e00000048800000ff8000000e00000100000000ff000000ff0000010400ff00000001000000000108ffff000600040000000003043f3f0000080800000000031480000000800000000000031c80000000800000000000032480000000800000000000032c800000008000000000000350ffffffff0000ffff00000354ffffffff0000ffff00000408ffff0020000f00200000094807ff07ff0028000000000a4807ff07ff0040004000000b4807ff07ff0062005000000c4807ff07ff004a004a00000f00ffffffff7fffffff00000f0400000100000001000000400800000001000000010000400c00000001000000000000401400000001000000010000401800000001000000000000401c000000010000000100004020ffff00000000000000004024ffff00000000000000004028ffff0000000000000000402cffff00000000000000004030ffff00000000000000004034ffff00000000000000004038ffff0000000000000000403cffff000000000000000011f80000000100000001000012f80000000100000001000013f80000000100000001000014f80000000100000001000015f80000000100000001000011fc0000000100000001000012fc0000000100000001000013fc0000000100000001000014fc0000000100000001000015fc0000000100000001", + "apple,tunable-usb3-lioa": "000000280000fe2f000000000000002c0000000700000000000000300000007f0000000000000034000000ff00000000000000580000010b00000000", + "apple,tunable-usb3-fabric": "00000004003f003f002000200000000c000000f1000000a1000000100000801f0000000400000018003f003f0020002000000020000000f1000000a1000000240000801f000000040000002c007f007f0041004100000034000000f1000000710000003800000001000000010000003c0000000100000001000000400000801f00000004000000480000001f00000010000000500000801f0000000400000058007f007f0045004500000060000000f100000051000000640000801f000000040000006c0000003f00000020000000740000801f000000040000007c0000000100000001000000800000801f0000000400000088001f001f001000100000008c000000f100000011000000900000000100000001000000940000000100000001000000980000801f00000004000000a0001f001f00100010000000a4000000f100000011000000a80000801f00000004000000b0000000ff000000a0000000b40000801f00000004000000bc0000003f00000020000000c40000801f00000004000000cc0000003f00000020000000d40000801f00000004000000dc001f001f00100010000000e40000000100000001000000e80000000100000001000000ec0000801f00000004000000f40000000f00000008000000f80000801f00000004000001000000000100000001000001040000000100000001000001080000801f00000004000001100000000100000001000001140000000100000001000001180000801f00000004000001200000000100000001000001240000000100000001000001280000801f00000004000001300000000100000001000001340000000100000001000001380000801f0000000400000140ffffffff01010101000001440000801f000000040000014c0000801f0000000400000154ffffffff01010101000001580000ffff000001010000015cffffffff01010101000001600000801f00000004000001680000801f00000004000001700000801f000000040000017800000001000000010000017c0000000100000001000001800000801f0000000400000188ffffffff010101010000018c0000ffff00000101000001900000801f000000040000019800000001000000010000019c0000000100000001000001a00000801f00000004000001a80000801f00000004", + "apple,tunable-usb3-config": "000000080000000100000001", + "apple,tunable-usb3-common": "00000800003f0000002300000000222400000c0000000800000022300000001f0000000f000022400018007f00000049000022b00870000000300000000022e80006000100040001000023380f8000000780000000002a00000008880000088800002a08001f00000003000000002a2400000c000000080000002a2800000f0000000b0000002a300000001f0000000f00002a4c007ffe0000633c0000002ab0007000000030000000002ae8000600000002000000002b0000000fff000000d8000028940000010000000100000028a0000001ff00000114000050047c000000440000000000103000008000000080000000010c0004000000000000", + "apple,tunable-usb3-efuse": "00000a040000007c000000380000260c000003ff00000200", + "apple,tunable-lane0-usb": "0000900040000000000000000000918c00ffffff0028c4a30000928803300033022000330000a0000000000f000000090000a0040000000f0000000a0000a0080000000f000000090000a00c0000000f000000090000a0100000000f000000090000a0140000000f000000090000a0380000ffff000001380000a084ffffffff1f47a1200000a08800000fff00000fff0000a09c0f000000050000000000a0c40000ffff000077770000a0e018000000080000000000a10c3fffffff0007a1200000a11000008001000080010000a0b8ff03e000aa03e0000000a0bc04060fff04040faa0000a0c000f80000005000000000a0e8001ff000000020000000a1b0ffffffff000000240000a1b40003ff00000002000000a1b8ffffffff000098240000a1bc0003ff0000000b000000a1d000000001000000010000b02c001f0000001800000000b03000000007000000070000b07000000030000000200000c01c000000e0000000a00000c0a001f80000003800000000c0ec00000001000000000000d04403003fc003003b00", + "apple,tunable-lane1-usb": "0001000040000000000000000001018c00ffffff0028c4a3000102880330003302200033000110000000000f00000009000110040000000f0000000a000110080000000f000000090001100c0000000f00000009000110100000000f00000009000110140000000f00000009000110380000ffff0000013800011084ffffffff1f47a1200001108800000fff00000fff0001109c0f00000005000000000110c40000ffff00007777000110e018000000080000000001110c3fffffff0007a120000111100000800100008001000110b8ff03e000aa03e000000110bc04060fff04040faa000110c000f8000000500000000110e8001ff00000002000000111b0ffffffff00000024000111b40003ff0000000200000111b8ffffffff00009824000111bc0003ff0000000b00000111d000000001000000010001202c001f0000001800000001203000000007000000070001207000000030000000200001301c000000e0000000a0000130a001f8000000380000000130ec00000001000000000001404403003fc003003b00", + "apple,tunable-usb3-dp": "0001600800000038000000080001600c0000001f00000000" + } + }, + { + "adt_node": "/arm-io/atc-phy1", + "properties": { + "tunable_ATCAXI2AF": "00000020ff0000801b00008004000020ff00ff800f000f8008000020ff00ff8003001b800c000020ff00ff800f000f8010000020ff00ff800f000f8014000020ff00ff800f000f8018000020ff00ff80030001801c000020ff00ff800300018020000020ff0000801000008024000020ff0000802c00008028000020ff00ff80080020802c000020ff00ff801000188030000020ff00ff800800208034000020ff00ff800800208038000020ff00ff8004000c803c000020ff00ff800800088040000020ff0000801800008044000020ff0000800e00008048000020ff0000800e00008000010020ff000000ff000000040100200000ff0000000100080100200600ffff000004000403002000003f3f000008081403002000000080000000801c03002000000080000000802403002000000080000000802c030020000000800000008050030020ffffffffffff000054030020ffffffffffff0000080400202000ffff20000f0048090020ff07ff0700002800480a0020ff07ff0740004000480b0020ff07ff0750006200480c0020ff07ff074a004a00000f0020ffffffffffffff7f040f002000010000000100000840002001000000010000000c40002001000000000000001440002001000000010000001840002001000000000000001c4000200100000001000000204000200000ffff00000000244000200000ffff00000000284000200000ffff000000002c4000200000ffff00000000304000200000ffff00000000344000200000ffff00000000384000200000ffff000000003c4000200000ffff00000000", + "tunable_ATCAXI2AF_WR_DIS": "f81100200100000001000000f81200200100000001000000f81300200100000001000000f81400200100000001000000f81500200100000001000000", + "tunable_ATCAXI2AF_LOCK_LOCK": "fc1100200100000001000000fc1200200100000001000000fc1300200100000001000000fc1400200100000001000000fc1500200100000001000000", + "tunable_ATCAXI2AF_LIOA_IOA": "280000202ffe0000000000002c0000200700000000000000300000207f0000000000000034000020ff00000000000000580000200b01000000000000", + "tunable_ATC_FABRIC": "040000203f003f00200020000c000020f1000000a1000000100000201f80000004000000180000203f003f002000200020000020f1000000a1000000240000201f800000040000002c0000207f007f004100410034000020f1000000710000003800002001000000010000003c0000200100000001000000400000201f80000004000000480000201f00000010000000500000201f80000004000000580000207f007f004500450060000020f100000051000000640000201f800000040000006c0000203f00000020000000740000201f800000040000007c0000200100000001000000800000201f80000004000000880000201f001f00100010008c000020f100000011000000900000200100000001000000940000200100000001000000980000201f80000004000000a00000201f001f0010001000a4000020f100000011000000a80000201f80000004000000b0000020ff000000a0000000b40000201f80000004000000bc0000203f00000020000000c40000201f80000004000000cc0000203f00000020000000d40000201f80000004000000dc0000201f001f0010001000e40000200100000001000000e80000200100000001000000ec0000201f80000004000000f40000200f00000008000000f80000201f80000004000000000100200100000001000000040100200100000001000000080100201f80000004000000100100200100000001000000140100200100000001000000180100201f80000004000000200100200100000001000000240100200100000001000000280100201f80000004000000300100200100000001000000340100200100000001000000380100201f8000000400000040010020ffffffff01010101440100201f800000040000004c0100201f8000000400000054010020ffffffff0101010158010020ffff0000010100005c010020ffffffff01010101600100201f80000004000000680100201f80000004000000700100201f800000040000007801002001000000010000007c0100200100000001000000800100201f8000000400000088010020ffffffff010101018c010020ffff000001010000900100201f800000040000009801002001000000010000009c0100200100000001000000a00100201f80000004000000a80100201f80000004000000", + "tunable_ATC_COMMON_CFG": "080000200100000001000000", + "tunable_AUSCMN_DIG": "0000002000003f0000002300", + "tunable_AUSPLL_CORE": "24000020000c000000080000300000201f0000000f000000400000207f00180059000000b00000200000700800003000e80000200100060001000400380100200000800f00008007", + "tunable_CIO3PLL_CORE": "0000002088080000880800000800002000001f000000030024000020000c00000008000028000020000f0000000b0000300000201f0000000f0000004c00002000fe7f0000ba3300b00000200000700000003000e8000020000006000000020000010020ff0f0000d8000000", + "tunable_CIO3PLL_TOP": "940000200001000000010000a0000020ff01000014010000", + "tunable_ACIOPHY_LANE_USBC0": "040000200000007c00000044", + "tunable_ACIOPHY_PLL_TOP": "300000200080000000800000", + "tunable_ACIOPHY_TOP": "0c0100200000040000000000", + "tunable_AUSCMN_SHM": "040000207c00000048000000", + "tunable_CLKMON_CFG": "0c000020ff03000000020000", + "tunable_LN0_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN0_RX_TOP_USB_EQA": "", + "tunable_LN0_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN0_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN0_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN0_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_LN1_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN1_RX_TOP_USB_EQA": "", + "tunable_LN1_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN1_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN1_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN1_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_AUX_TOP": "0800002038000000080000000c0000201f00000000000000" + }, + "expected_be_hex": { + "apple,tunable-usb3-axi2af": "00000000800000ff8000001b0000000480ff00ff800f000f0000000880ff00ff801b00030000000c80ff00ff800f000f0000001080ff00ff800f000f0000001480ff00ff800f000f0000001880ff00ff800100030000001c80ff00ff8001000300000020800000ff8000001000000024800000ff8000002c0000002880ff00ff802000080000002c80ff00ff801800100000003080ff00ff802000080000003480ff00ff802000080000003880ff00ff800c00040000003c80ff00ff8008000800000040800000ff8000001800000044800000ff8000000e00000048800000ff8000000e00000100000000ff000000ff0000010400ff00000001000000000108ffff000600040000000003043f3f0000080800000000031480000000800000000000031c80000000800000000000032480000000800000000000032c800000008000000000000350ffffffff0000ffff00000354ffffffff0000ffff00000408ffff0020000f00200000094807ff07ff0028000000000a4807ff07ff0040004000000b4807ff07ff0062005000000c4807ff07ff004a004a00000f00ffffffff7fffffff00000f0400000100000001000000400800000001000000010000400c00000001000000000000401400000001000000010000401800000001000000000000401c000000010000000100004020ffff00000000000000004024ffff00000000000000004028ffff0000000000000000402cffff00000000000000004030ffff00000000000000004034ffff00000000000000004038ffff0000000000000000403cffff000000000000000011f80000000100000001000012f80000000100000001000013f80000000100000001000014f80000000100000001000015f80000000100000001000011fc0000000100000001000012fc0000000100000001000013fc0000000100000001000014fc0000000100000001000015fc0000000100000001", + "apple,tunable-usb3-lioa": "000000280000fe2f000000000000002c0000000700000000000000300000007f0000000000000034000000ff00000000000000580000010b00000000", + "apple,tunable-usb3-fabric": "00000004003f003f002000200000000c000000f1000000a1000000100000801f0000000400000018003f003f0020002000000020000000f1000000a1000000240000801f000000040000002c007f007f0041004100000034000000f1000000710000003800000001000000010000003c0000000100000001000000400000801f00000004000000480000001f00000010000000500000801f0000000400000058007f007f0045004500000060000000f100000051000000640000801f000000040000006c0000003f00000020000000740000801f000000040000007c0000000100000001000000800000801f0000000400000088001f001f001000100000008c000000f100000011000000900000000100000001000000940000000100000001000000980000801f00000004000000a0001f001f00100010000000a4000000f100000011000000a80000801f00000004000000b0000000ff000000a0000000b40000801f00000004000000bc0000003f00000020000000c40000801f00000004000000cc0000003f00000020000000d40000801f00000004000000dc001f001f00100010000000e40000000100000001000000e80000000100000001000000ec0000801f00000004000000f40000000f00000008000000f80000801f00000004000001000000000100000001000001040000000100000001000001080000801f00000004000001100000000100000001000001140000000100000001000001180000801f00000004000001200000000100000001000001240000000100000001000001280000801f00000004000001300000000100000001000001340000000100000001000001380000801f0000000400000140ffffffff01010101000001440000801f000000040000014c0000801f0000000400000154ffffffff01010101000001580000ffff000001010000015cffffffff01010101000001600000801f00000004000001680000801f00000004000001700000801f000000040000017800000001000000010000017c0000000100000001000001800000801f0000000400000188ffffffff010101010000018c0000ffff00000101000001900000801f000000040000019800000001000000010000019c0000000100000001000001a00000801f00000004000001a80000801f00000004", + "apple,tunable-usb3-config": "000000080000000100000001", + "apple,tunable-usb3-common": "00000800003f0000002300000000222400000c0000000800000022300000001f0000000f000022400018007f00000059000022b00870000000300000000022e80006000100040001000023380f8000000780000000002a00000008880000088800002a08001f00000003000000002a2400000c000000080000002a2800000f0000000b0000002a300000001f0000000f00002a4c007ffe000033ba0000002ab0007000000030000000002ae8000600000002000000002b0000000fff000000d8000028940000010000000100000028a0000001ff00000114000050047c000000440000000000103000008000000080000000010c0004000000000000", + "apple,tunable-usb3-efuse": "00000a040000007c000000480000260c000003ff00000200", + "apple,tunable-lane0-usb": "0000900040000000000000000000918c00ffffff0028c4a30000928803300033022000330000a0000000000f000000090000a0040000000f0000000a0000a0080000000f000000090000a00c0000000f000000090000a0100000000f000000090000a0140000000f000000090000a0380000ffff000001380000a084ffffffff1f47a1200000a08800000fff00000fff0000a09c0f000000050000000000a0c40000ffff000077770000a0e018000000080000000000a10c3fffffff0007a1200000a11000008001000080010000a0b8ff03e000aa03e0000000a0bc04060fff04040faa0000a0c000f80000005000000000a0e8001ff000000020000000a1b0ffffffff000000240000a1b40003ff00000002000000a1b8ffffffff000098240000a1bc0003ff0000000b000000a1d000000001000000010000b02c001f0000001800000000b03000000007000000070000b07000000030000000200000c01c000000e0000000a00000c0a001f80000003800000000c0ec00000001000000000000d04403003fc003003b00", + "apple,tunable-lane1-usb": "0001000040000000000000000001018c00ffffff0028c4a3000102880330003302200033000110000000000f00000009000110040000000f0000000a000110080000000f000000090001100c0000000f00000009000110100000000f00000009000110140000000f00000009000110380000ffff0000013800011084ffffffff1f47a1200001108800000fff00000fff0001109c0f00000005000000000110c40000ffff00007777000110e018000000080000000001110c3fffffff0007a120000111100000800100008001000110b8ff03e000aa03e000000110bc04060fff04040faa000110c000f8000000500000000110e8001ff00000002000000111b0ffffffff00000024000111b40003ff0000000200000111b8ffffffff00009824000111bc0003ff0000000b00000111d000000001000000010001202c001f0000001800000001203000000007000000070001207000000030000000200001301c000000e0000000a0000130a001f8000000380000000130ec00000001000000000001404403003fc003003b00", + "apple,tunable-usb3-dp": "0001600800000038000000080001600c0000001f00000000" + } + }, + { + "adt_node": "/arm-io/atc-phy2", + "properties": { + "tunable_ATCAXI2AF": "00000020ff0000801b00008004000020ff00ff800f000f8008000020ff00ff8003001b800c000020ff00ff800f000f8010000020ff00ff800f000f8014000020ff00ff800f000f8018000020ff00ff80030001801c000020ff00ff800300018020000020ff0000801000008024000020ff0000802c00008028000020ff00ff80080020802c000020ff00ff801000188030000020ff00ff800800208034000020ff00ff800800208038000020ff00ff8004000c803c000020ff00ff800800088040000020ff0000801800008044000020ff0000800e00008048000020ff0000800e00008000010020ff000000ff000000040100200000ff0000000100080100200600ffff000004000403002000003f3f000008081403002000000080000000801c03002000000080000000802403002000000080000000802c030020000000800000008050030020ffffffffffff000054030020ffffffffffff0000080400202000ffff20000f0048090020ff07ff0700002800480a0020ff07ff0740004000480b0020ff07ff0750006200480c0020ff07ff074a004a00000f0020ffffffffffffff7f040f002000010000000100000840002001000000010000000c40002001000000000000001440002001000000010000001840002001000000000000001c4000200100000001000000204000200000ffff00000000244000200000ffff00000000284000200000ffff000000002c4000200000ffff00000000304000200000ffff00000000344000200000ffff00000000384000200000ffff000000003c4000200000ffff00000000", + "tunable_ATCAXI2AF_WR_DIS": "f81100200100000001000000f81200200100000001000000f81300200100000001000000f81400200100000001000000f81500200100000001000000", + "tunable_ATCAXI2AF_LOCK_LOCK": "fc1100200100000001000000fc1200200100000001000000fc1300200100000001000000fc1400200100000001000000fc1500200100000001000000", + "tunable_ATCAXI2AF_LIOA_IOA": "280000202ffe0000000000002c0000200700000000000000300000207f0000000000000034000020ff00000000000000580000200b01000000000000", + "tunable_ATC_FABRIC": "040000203f003f00200020000c000020f1000000a1000000100000201f80000004000000180000203f003f002000200020000020f1000000a1000000240000201f800000040000002c0000207f007f004100410034000020f1000000710000003800002001000000010000003c0000200100000001000000400000201f80000004000000480000201f00000010000000500000201f80000004000000580000207f007f004500450060000020f100000051000000640000201f800000040000006c0000203f00000020000000740000201f800000040000007c0000200100000001000000800000201f80000004000000880000201f001f00100010008c000020f100000011000000900000200100000001000000940000200100000001000000980000201f80000004000000a00000201f001f0010001000a4000020f100000011000000a80000201f80000004000000b0000020ff000000a0000000b40000201f80000004000000bc0000203f00000020000000c40000201f80000004000000cc0000203f00000020000000d40000201f80000004000000dc0000201f001f0010001000e40000200100000001000000e80000200100000001000000ec0000201f80000004000000f40000200f00000008000000f80000201f80000004000000000100200100000001000000040100200100000001000000080100201f80000004000000100100200100000001000000140100200100000001000000180100201f80000004000000200100200100000001000000240100200100000001000000280100201f80000004000000300100200100000001000000340100200100000001000000380100201f8000000400000040010020ffffffff01010101440100201f800000040000004c0100201f8000000400000054010020ffffffff0101010158010020ffff0000010100005c010020ffffffff01010101600100201f80000004000000680100201f80000004000000700100201f800000040000007801002001000000010000007c0100200100000001000000800100201f8000000400000088010020ffffffff010101018c010020ffff000001010000900100201f800000040000009801002001000000010000009c0100200100000001000000a00100201f80000004000000a80100201f80000004000000", + "tunable_ATC_COMMON_CFG": "080000200100000001000000", + "tunable_AUSCMN_DIG": "0000002000003f0000002300", + "tunable_AUSPLL_CORE": "24000020000c000000080000300000201f0000000f000000400000207f00180049000000b00000200000700800003000e80000200100060001000400380100200000800f00008007", + "tunable_CIO3PLL_CORE": "0000002088080000880800000800002000001f000000030024000020000c00000008000028000020000f0000000b0000300000201f0000000f0000004c00002000fe7f0000ba6300b00000200000700000003000e8000020000006000000020000010020ff0f0000d8000000", + "tunable_CIO3PLL_TOP": "940000200001000000010000a0000020ff01000014010000", + "tunable_ACIOPHY_LANE_USBC0": "040000200000007c00000044", + "tunable_ACIOPHY_PLL_TOP": "300000200080000000800000", + "tunable_ACIOPHY_TOP": "0c0100200000040000000000", + "tunable_AUSCMN_SHM": "040000207c00000048000000", + "tunable_CLKMON_CFG": "0c000020ff03000000020000", + "tunable_LN0_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN0_RX_TOP_USB_EQA": "", + "tunable_LN0_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN0_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN0_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN0_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_LN1_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN1_RX_TOP_USB_EQA": "", + "tunable_LN1_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN1_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN1_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN1_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_AUX_TOP": "0800002038000000080000000c0000201f00000000000000" + }, + "expected_be_hex": { + "apple,tunable-usb3-axi2af": "00000000800000ff8000001b0000000480ff00ff800f000f0000000880ff00ff801b00030000000c80ff00ff800f000f0000001080ff00ff800f000f0000001480ff00ff800f000f0000001880ff00ff800100030000001c80ff00ff8001000300000020800000ff8000001000000024800000ff8000002c0000002880ff00ff802000080000002c80ff00ff801800100000003080ff00ff802000080000003480ff00ff802000080000003880ff00ff800c00040000003c80ff00ff8008000800000040800000ff8000001800000044800000ff8000000e00000048800000ff8000000e00000100000000ff000000ff0000010400ff00000001000000000108ffff000600040000000003043f3f0000080800000000031480000000800000000000031c80000000800000000000032480000000800000000000032c800000008000000000000350ffffffff0000ffff00000354ffffffff0000ffff00000408ffff0020000f00200000094807ff07ff0028000000000a4807ff07ff0040004000000b4807ff07ff0062005000000c4807ff07ff004a004a00000f00ffffffff7fffffff00000f0400000100000001000000400800000001000000010000400c00000001000000000000401400000001000000010000401800000001000000000000401c000000010000000100004020ffff00000000000000004024ffff00000000000000004028ffff0000000000000000402cffff00000000000000004030ffff00000000000000004034ffff00000000000000004038ffff0000000000000000403cffff000000000000000011f80000000100000001000012f80000000100000001000013f80000000100000001000014f80000000100000001000015f80000000100000001000011fc0000000100000001000012fc0000000100000001000013fc0000000100000001000014fc0000000100000001000015fc0000000100000001", + "apple,tunable-usb3-lioa": "000000280000fe2f000000000000002c0000000700000000000000300000007f0000000000000034000000ff00000000000000580000010b00000000", + "apple,tunable-usb3-fabric": "00000004003f003f002000200000000c000000f1000000a1000000100000801f0000000400000018003f003f0020002000000020000000f1000000a1000000240000801f000000040000002c007f007f0041004100000034000000f1000000710000003800000001000000010000003c0000000100000001000000400000801f00000004000000480000001f00000010000000500000801f0000000400000058007f007f0045004500000060000000f100000051000000640000801f000000040000006c0000003f00000020000000740000801f000000040000007c0000000100000001000000800000801f0000000400000088001f001f001000100000008c000000f100000011000000900000000100000001000000940000000100000001000000980000801f00000004000000a0001f001f00100010000000a4000000f100000011000000a80000801f00000004000000b0000000ff000000a0000000b40000801f00000004000000bc0000003f00000020000000c40000801f00000004000000cc0000003f00000020000000d40000801f00000004000000dc001f001f00100010000000e40000000100000001000000e80000000100000001000000ec0000801f00000004000000f40000000f00000008000000f80000801f00000004000001000000000100000001000001040000000100000001000001080000801f00000004000001100000000100000001000001140000000100000001000001180000801f00000004000001200000000100000001000001240000000100000001000001280000801f00000004000001300000000100000001000001340000000100000001000001380000801f0000000400000140ffffffff01010101000001440000801f000000040000014c0000801f0000000400000154ffffffff01010101000001580000ffff000001010000015cffffffff01010101000001600000801f00000004000001680000801f00000004000001700000801f000000040000017800000001000000010000017c0000000100000001000001800000801f0000000400000188ffffffff010101010000018c0000ffff00000101000001900000801f000000040000019800000001000000010000019c0000000100000001000001a00000801f00000004000001a80000801f00000004", + "apple,tunable-usb3-config": "000000080000000100000001", + "apple,tunable-usb3-common": "00000800003f0000002300000000222400000c0000000800000022300000001f0000000f000022400018007f00000049000022b00870000000300000000022e80006000100040001000023380f8000000780000000002a00000008880000088800002a08001f00000003000000002a2400000c000000080000002a2800000f0000000b0000002a300000001f0000000f00002a4c007ffe000063ba0000002ab0007000000030000000002ae8000600000002000000002b0000000fff000000d8000028940000010000000100000028a0000001ff00000114000050047c000000440000000000103000008000000080000000010c0004000000000000", + "apple,tunable-usb3-efuse": "00000a040000007c000000480000260c000003ff00000200", + "apple,tunable-lane0-usb": "0000900040000000000000000000918c00ffffff0028c4a30000928803300033022000330000a0000000000f000000090000a0040000000f0000000a0000a0080000000f000000090000a00c0000000f000000090000a0100000000f000000090000a0140000000f000000090000a0380000ffff000001380000a084ffffffff1f47a1200000a08800000fff00000fff0000a09c0f000000050000000000a0c40000ffff000077770000a0e018000000080000000000a10c3fffffff0007a1200000a11000008001000080010000a0b8ff03e000aa03e0000000a0bc04060fff04040faa0000a0c000f80000005000000000a0e8001ff000000020000000a1b0ffffffff000000240000a1b40003ff00000002000000a1b8ffffffff000098240000a1bc0003ff0000000b000000a1d000000001000000010000b02c001f0000001800000000b03000000007000000070000b07000000030000000200000c01c000000e0000000a00000c0a001f80000003800000000c0ec00000001000000000000d04403003fc003003b00", + "apple,tunable-lane1-usb": "0001000040000000000000000001018c00ffffff0028c4a3000102880330003302200033000110000000000f00000009000110040000000f0000000a000110080000000f000000090001100c0000000f00000009000110100000000f00000009000110140000000f00000009000110380000ffff0000013800011084ffffffff1f47a1200001108800000fff00000fff0001109c0f00000005000000000110c40000ffff00007777000110e018000000080000000001110c3fffffff0007a120000111100000800100008001000110b8ff03e000aa03e000000110bc04060fff04040faa000110c000f8000000500000000110e8001ff00000002000000111b0ffffffff00000024000111b40003ff0000000200000111b8ffffffff00009824000111bc0003ff0000000b00000111d000000001000000010001202c001f0000001800000001203000000007000000070001207000000030000000200001301c000000e0000000a0000130a001f8000000380000000130ec00000001000000000001404403003fc003003b00", + "apple,tunable-usb3-dp": "0001600800000038000000080001600c0000001f00000000" + } + }, + { + "adt_node": "/arm-io/atc-phy3", + "properties": { + "tunable_ATCAXI2AF": "00000020ff0000801b00008004000020ff00ff800f000f8008000020ff00ff8003001b800c000020ff00ff800f000f8010000020ff00ff800f000f8014000020ff00ff800f000f8018000020ff00ff80030001801c000020ff00ff800300018020000020ff0000801000008024000020ff0000802c00008028000020ff00ff80080020802c000020ff00ff801000188030000020ff00ff800800208034000020ff00ff800800208038000020ff00ff8004000c803c000020ff00ff800800088040000020ff0000801800008044000020ff0000800e00008048000020ff0000800e00008000010020ff000000ff000000040100200000ff0000000100080100200600ffff000004000403002000003f3f000008081403002000000080000000801c03002000000080000000802403002000000080000000802c030020000000800000008050030020ffffffffffff000054030020ffffffffffff0000080400202000ffff20000f0048090020ff07ff0700002800480a0020ff07ff0740004000480b0020ff07ff0750006200480c0020ff07ff074a004a00000f0020ffffffffffffff7f040f002000010000000100000840002001000000010000000c40002001000000000000001440002001000000010000001840002001000000000000001c4000200100000001000000204000200000ffff00000000244000200000ffff00000000284000200000ffff000000002c4000200000ffff00000000304000200000ffff00000000344000200000ffff00000000384000200000ffff000000003c4000200000ffff00000000", + "tunable_ATCAXI2AF_WR_DIS": "f81100200100000001000000f81200200100000001000000f81300200100000001000000f81400200100000001000000f81500200100000001000000", + "tunable_ATCAXI2AF_LOCK_LOCK": "fc1100200100000001000000fc1200200100000001000000fc1300200100000001000000fc1400200100000001000000fc1500200100000001000000", + "tunable_ATCAXI2AF_LIOA_IOA": "280000202ffe0000000000002c0000200700000000000000300000207f0000000000000034000020ff00000000000000580000200b01000000000000", + "tunable_ATC_FABRIC": "040000203f003f00200020000c000020f1000000a1000000100000201f80000004000000180000203f003f002000200020000020f1000000a1000000240000201f800000040000002c0000207f007f004100410034000020f1000000710000003800002001000000010000003c0000200100000001000000400000201f80000004000000480000201f00000010000000500000201f80000004000000580000207f007f004500450060000020f100000051000000640000201f800000040000006c0000203f00000020000000740000201f800000040000007c0000200100000001000000800000201f80000004000000880000201f001f00100010008c000020f100000011000000900000200100000001000000940000200100000001000000980000201f80000004000000a00000201f001f0010001000a4000020f100000011000000a80000201f80000004000000b0000020ff000000a0000000b40000201f80000004000000bc0000203f00000020000000c40000201f80000004000000cc0000203f00000020000000d40000201f80000004000000dc0000201f001f0010001000e40000200100000001000000e80000200100000001000000ec0000201f80000004000000f40000200f00000008000000f80000201f80000004000000000100200100000001000000040100200100000001000000080100201f80000004000000100100200100000001000000140100200100000001000000180100201f80000004000000200100200100000001000000240100200100000001000000280100201f80000004000000300100200100000001000000340100200100000001000000380100201f8000000400000040010020ffffffff01010101440100201f800000040000004c0100201f8000000400000054010020ffffffff0101010158010020ffff0000010100005c010020ffffffff01010101600100201f80000004000000680100201f80000004000000700100201f800000040000007801002001000000010000007c0100200100000001000000800100201f8000000400000088010020ffffffff010101018c010020ffff000001010000900100201f800000040000009801002001000000010000009c0100200100000001000000a00100201f80000004000000a80100201f80000004000000", + "tunable_ATC_COMMON_CFG": "080000200100000001000000", + "tunable_AUSCMN_DIG": "0000002000003f0000002300", + "tunable_AUSPLL_CORE": "24000020000c000000080000300000201f0000000f000000400000207f00180049000000b00000200000700800003000e80000200100060001000400380100200000800f00008007", + "tunable_CIO3PLL_CORE": "0000002088080000880800000800002000001f000000030024000020000c00000008000028000020000f0000000b0000300000201f0000000f0000004c00002000fe7f0000ba6300b00000200000700000003000e8000020000006000000020000010020ff0f0000d8000000", + "tunable_CIO3PLL_TOP": "940000200001000000010000a0000020ff01000014010000", + "tunable_ACIOPHY_LANE_USBC0": "040000200000007c00000044", + "tunable_ACIOPHY_PLL_TOP": "300000200080000000800000", + "tunable_ACIOPHY_TOP": "0c0100200000040000000000", + "tunable_AUSCMN_SHM": "040000207c00000040000000", + "tunable_CLKMON_CFG": "0c000020ff03000000020000", + "tunable_LN0_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN0_RX_TOP_USB_EQA": "", + "tunable_LN0_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN0_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN0_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN0_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_LN1_RX_TOP_USB_DFLT": "0000002000000040000000008c010020ffffff00a3c42800880200203300300333002002", + "tunable_LN1_RX_TOP_USB_EQA": "", + "tunable_LN1_RX_EQ_USB_EQA": "000000200f00000009000000040000200f0000000a000000080000200f000000090000000c0000200f00000009000000100000200f00000009000000140000200f0000000900000038000020ffff00003801000084000020ffffffff20a1471f88000020ff0f0000ff0f00009c0000200000000f00000005c4000020ffff000077770000e000002000000018000000080c010020ffffff3f20a10700100100200180000001800000b800002000e003ff00e003aabc000020ff0f0604aa0f0404c00000200000f80000005000e800002000f01f0000200000b0010020ffffffff24000000b401002000ff030000020000b8010020ffffffff24980000bc01002000ff0300000b0000d00100200100000001000000", + "tunable_LN1_RX_SHM_USB_DFLT": "2c00002000001f0000001800300000200700000007000000700000203000000020000000", + "tunable_LN1_TX_TOP_USB_DFLT": "1c000020e0000000a0000000a00000200000f80100003800ec0000200100000000000000", + "tunable_LN1_TX_SHM_USB_DFLT": "44000020c03f0003003b0003", + "tunable_AUX_TOP": "0800002038000000080000000c0000201f00000000000000" + }, + "expected_be_hex": { + "apple,tunable-usb3-axi2af": "00000000800000ff8000001b0000000480ff00ff800f000f0000000880ff00ff801b00030000000c80ff00ff800f000f0000001080ff00ff800f000f0000001480ff00ff800f000f0000001880ff00ff800100030000001c80ff00ff8001000300000020800000ff8000001000000024800000ff8000002c0000002880ff00ff802000080000002c80ff00ff801800100000003080ff00ff802000080000003480ff00ff802000080000003880ff00ff800c00040000003c80ff00ff8008000800000040800000ff8000001800000044800000ff8000000e00000048800000ff8000000e00000100000000ff000000ff0000010400ff00000001000000000108ffff000600040000000003043f3f0000080800000000031480000000800000000000031c80000000800000000000032480000000800000000000032c800000008000000000000350ffffffff0000ffff00000354ffffffff0000ffff00000408ffff0020000f00200000094807ff07ff0028000000000a4807ff07ff0040004000000b4807ff07ff0062005000000c4807ff07ff004a004a00000f00ffffffff7fffffff00000f0400000100000001000000400800000001000000010000400c00000001000000000000401400000001000000010000401800000001000000000000401c000000010000000100004020ffff00000000000000004024ffff00000000000000004028ffff0000000000000000402cffff00000000000000004030ffff00000000000000004034ffff00000000000000004038ffff0000000000000000403cffff000000000000000011f80000000100000001000012f80000000100000001000013f80000000100000001000014f80000000100000001000015f80000000100000001000011fc0000000100000001000012fc0000000100000001000013fc0000000100000001000014fc0000000100000001000015fc0000000100000001", + "apple,tunable-usb3-lioa": "000000280000fe2f000000000000002c0000000700000000000000300000007f0000000000000034000000ff00000000000000580000010b00000000", + "apple,tunable-usb3-fabric": "00000004003f003f002000200000000c000000f1000000a1000000100000801f0000000400000018003f003f0020002000000020000000f1000000a1000000240000801f000000040000002c007f007f0041004100000034000000f1000000710000003800000001000000010000003c0000000100000001000000400000801f00000004000000480000001f00000010000000500000801f0000000400000058007f007f0045004500000060000000f100000051000000640000801f000000040000006c0000003f00000020000000740000801f000000040000007c0000000100000001000000800000801f0000000400000088001f001f001000100000008c000000f100000011000000900000000100000001000000940000000100000001000000980000801f00000004000000a0001f001f00100010000000a4000000f100000011000000a80000801f00000004000000b0000000ff000000a0000000b40000801f00000004000000bc0000003f00000020000000c40000801f00000004000000cc0000003f00000020000000d40000801f00000004000000dc001f001f00100010000000e40000000100000001000000e80000000100000001000000ec0000801f00000004000000f40000000f00000008000000f80000801f00000004000001000000000100000001000001040000000100000001000001080000801f00000004000001100000000100000001000001140000000100000001000001180000801f00000004000001200000000100000001000001240000000100000001000001280000801f00000004000001300000000100000001000001340000000100000001000001380000801f0000000400000140ffffffff01010101000001440000801f000000040000014c0000801f0000000400000154ffffffff01010101000001580000ffff000001010000015cffffffff01010101000001600000801f00000004000001680000801f00000004000001700000801f000000040000017800000001000000010000017c0000000100000001000001800000801f0000000400000188ffffffff010101010000018c0000ffff00000101000001900000801f000000040000019800000001000000010000019c0000000100000001000001a00000801f00000004000001a80000801f00000004", + "apple,tunable-usb3-config": "000000080000000100000001", + "apple,tunable-usb3-common": "00000800003f0000002300000000222400000c0000000800000022300000001f0000000f000022400018007f00000049000022b00870000000300000000022e80006000100040001000023380f8000000780000000002a00000008880000088800002a08001f00000003000000002a2400000c000000080000002a2800000f0000000b0000002a300000001f0000000f00002a4c007ffe000063ba0000002ab0007000000030000000002ae8000600000002000000002b0000000fff000000d8000028940000010000000100000028a0000001ff00000114000050047c000000440000000000103000008000000080000000010c0004000000000000", + "apple,tunable-usb3-efuse": "00000a040000007c000000400000260c000003ff00000200", + "apple,tunable-lane0-usb": "0000900040000000000000000000918c00ffffff0028c4a30000928803300033022000330000a0000000000f000000090000a0040000000f0000000a0000a0080000000f000000090000a00c0000000f000000090000a0100000000f000000090000a0140000000f000000090000a0380000ffff000001380000a084ffffffff1f47a1200000a08800000fff00000fff0000a09c0f000000050000000000a0c40000ffff000077770000a0e018000000080000000000a10c3fffffff0007a1200000a11000008001000080010000a0b8ff03e000aa03e0000000a0bc04060fff04040faa0000a0c000f80000005000000000a0e8001ff000000020000000a1b0ffffffff000000240000a1b40003ff00000002000000a1b8ffffffff000098240000a1bc0003ff0000000b000000a1d000000001000000010000b02c001f0000001800000000b03000000007000000070000b07000000030000000200000c01c000000e0000000a00000c0a001f80000003800000000c0ec00000001000000000000d04403003fc003003b00", + "apple,tunable-lane1-usb": "0001000040000000000000000001018c00ffffff0028c4a3000102880330003302200033000110000000000f00000009000110040000000f0000000a000110080000000f000000090001100c0000000f00000009000110100000000f00000009000110140000000f00000009000110380000ffff0000013800011084ffffffff1f47a1200001108800000fff00000fff0001109c0f00000005000000000110c40000ffff00007777000110e018000000080000000001110c3fffffff0007a120000111100000800100008001000110b8ff03e000aa03e000000110bc04060fff04040faa000110c000f8000000500000000110e8001ff00000002000000111b0ffffffff00000024000111b40003ff0000000200000111b8ffffffff00009824000111bc0003ff0000000b00000111d000000001000000010001202c001f0000001800000001203000000007000000070001207000000030000000200001301c000000e0000000a0000130a001f8000000380000000130ec00000001000000000001404403003fc003003b00", + "apple,tunable-usb3-dp": "0001600800000038000000080001600c0000001f00000000" + } + } + ] +} diff --git a/tests/python/test_t8132_atc_usb3_any_board.py b/tests/python/test_t8132_atc_usb3_any_board.py new file mode 100644 index 00000000..9ec78d0e --- /dev/null +++ b/tests/python/test_t8132_atc_usb3_any_board.py @@ -0,0 +1,227 @@ +# SPDX-License-Identifier: GPL-2.0-only OR MIT +"""Run production dt_copy_atc_tunables() on four atc-phy,t8132 PHYs under several board trees. + +The calibration groups are those of /arm-io/atc-phy0..3 in a J773g ADT on the macOS 27.2 +(26B123) stub (tests/data/j773g-atc-usb3.json). What this can catch: + +- the copy depending on the board, the chip id or the OS firmware again: no + apple,tunable-usb3-* on a tree it should serve; +- a PHY whose ADT lacks one group still getting part of the bundle, or costing the other PHYs + theirs; +- the bundle published for an ADT PHY that is not atc-phy,t8132, or under a tree PHY node + that is not apple,t8132-atcphy; +- a group the copy rejects (width, alignment, window), or published values other than the ADT's. +""" +import json +from pathlib import Path +import subprocess + + +def test_t8132_usb3_calibration_follows_the_adt_bundle(tmp_path): + repo = Path(__file__).resolve().parents[2] + source = (repo / "src/kboot_atc.c").read_text() + # Everything dt_copy_atc_tunables() is built from, as it stands in the tree. + production = source[source.index("#define MAX_ATC_DEVS"): + source.index("/* T6040 uses separate register resources")] + fixture = json.loads((repo / "tests/data/j773g-atc-usb3.json").read_text()) + assert len(fixture["ports"]) == 4 + + declarations, tables, checks = [], [], [] + for port, entry in enumerate(fixture["ports"]): + rows = [] + for i, (name, raw) in enumerate(entry["properties"].items()): + data = bytes.fromhex(raw) + body = ",".join(str(x) for x in data) or "0" + declarations.append(f"static const u8 in{port}_{i}[] = {{{body}}};") + rows.append(f'{{"{name}", in{port}_{i}, {len(data)}}}') + tables.append(f"static const struct property props{port}[] = {{{','.join(rows)}}};") + for i, (name, raw) in enumerate(entry["expected_be_hex"].items()): + data = bytes.fromhex(raw) + declarations.append( + f'static const u8 out{port}_{i}[] = {{{",".join(str(x) for x in data)}}};') + checks.append(f' if (port == {port}) expect(node, "{name}", out{port}_{i}, ' + f'sizeof(out{port}_{i}));') + harness = r''' +#include +#include +#include +#include +#include +#include +#include +typedef uint8_t u8; +typedef uint32_t u32; +typedef int32_t s32; +/* Match aura's aarch64 target, not the host libc's uint64_t alias. */ +typedef unsigned long u64; +_Static_assert(sizeof(u64) == 8, "the aura host fixture requires an LP64 host"); +#define static_assert _Static_assert +#define PACKED __attribute__((packed)) +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define BIT(x) (1UL << (x)) +#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (63 - (h)))) +#define FIELD_PREP(mask, val) (((u64)(val) << __builtin_ctzl(mask)) & (mask)) +#define T6030 0x6030 +#define T8132 0x8132 +#define T8140 0x8140 +static u32 chip_id; +static const char *adt_phy = "atc-phy,t8132"; +static const char *tree_phy = "apple,t8132-atcphy"; +static int hide_port = -1; +static bool other_node; +static const char *hide_name; +static char adt_blob; +static void *adt = &adt_blob; +static u32 read32(u64 addr) { (void)addr; abort(); } /* T8132 PHYs take no fuses from here */ +struct property { const char *name; const u8 *data; u32 len; }; +''' + "\n".join(declarations) + "\n" + "\n".join(tables) + r''' +static const struct { const struct property *props; size_t count; } phys[] = { + {props0, ARRAY_SIZE(props0)}, {props1, ARRAY_SIZE(props1)}, + {props2, ARRAY_SIZE(props2)}, {props3, ARRAY_SIZE(props3)}, +}; +/* The ADT: /arm-io/atc-phyN is node N + 1, compatible atc-phy,t8132. */ +static int adt_path_offset(const void *tree, const char *path) +{ + static const char prefix[] = "/arm-io/atc-phy"; + assert(tree == adt); + if (strncmp(path, prefix, sizeof(prefix) - 1) || strlen(path) != sizeof(prefix)) + return -1; + int port = path[sizeof(prefix) - 1] - '0'; + return port >= 0 && port < (int)ARRAY_SIZE(phys) ? port + 1 : -1; +} +static int adt_path_offset_trace(const void *tree, const char *path, int *trace) +{ + (void)trace; + return adt_path_offset(tree, path); +} +static int adt_get_reg(const void *tree, int *path, const char *prop, int idx, u64 *a, u64 *s) +{ + return -1; +} +static bool adt_is_compatible_at(const void *tree, int node, const char *compatible, int index) +{ + return tree == adt && node >= 1 && !index && !strcmp(compatible, adt_phy); +} +static const void *adt_getprop(const void *tree, int node, const char *name, u32 *len) +{ + assert(tree == adt && node >= 1 && node <= (int)ARRAY_SIZE(phys)); + if (node - 1 == hide_port && !strcmp(name, hide_name)) + return NULL; + for (size_t i = 0; i < phys[node - 1].count; i++) + if (!strcmp(phys[node - 1].props[i].name, name)) { + if (len) *len = phys[node - 1].props[i].len; + return phys[node - 1].props[i].data; + } + return NULL; +} +''' + production + r''' +static char dt[1 << 18]; +static const char *const phy_path[] = {"/soc/phy@402a90000", "/soc/phy@40aa90000", + "/soc/phy@412a90000", "/soc/phy@41aa90000"}; +static void world(u32 chip, const char *board) +{ + chip_id = chip; adt_phy = "atc-phy,t8132"; hide_port = -1; hide_name = NULL; + tree_phy = other_node ? "apple,t6030-atcphy-dp" : "apple,t8132-atcphy"; + assert(!fdt_create_empty_tree(dt, sizeof(dt))); + char compat[64]; + int n = snprintf(compat, sizeof(compat), "%s%capple,t8132%capple,arm-platform", board, 0, 0); + assert(!fdt_setprop(dt, 0, "compatible", compat, n + 1)); + assert(fdt_add_subnode(dt, 0, "soc") >= 0); + int aliases = fdt_add_subnode(dt, 0, "aliases"); + assert(aliases >= 0); + for (size_t port = 0; port < ARRAY_SIZE(phy_path); port++) { + char alias[16]; + int node = fdt_add_subnode(dt, fdt_path_offset(dt, "/soc"), phy_path[port] + 5); + assert(node >= 0 && !fdt_setprop_string(dt, node, "compatible", tree_phy)); + snprintf(alias, sizeof(alias), "atcphy%zu", port); + assert(!fdt_setprop_string(dt, fdt_path_offset(dt, "/aliases"), alias, phy_path[port])); + } +} +static void copy_all(void) +{ + for (size_t port = 0; port < ARRAY_SIZE(phy_path); port++) { + char adt_path[32], alias[16]; + snprintf(adt_path, sizeof(adt_path), "/arm-io/atc-phy%zu", port); + snprintf(alias, sizeof(alias), "atcphy%zu", port); + dt_copy_atc_tunables(dt, adt_path, alias, port); + } +} +/* The apple,tunable-usb3-* properties of one PHY: what the hardware check counts (seven). */ +static int usb3_properties(int node) +{ + int prop, count = 0; + fdt_for_each_property_offset(prop, dt, node) { + const char *name; + assert(fdt_getprop_by_offset(dt, prop, &name, NULL)); + count += !strncmp(name, "apple,tunable-usb3-", 19); + } + return count; +} +static void expect(int node, const char *name, const u8 *want, int count) +{ + int len; + const void *data = fdt_getprop(dt, node, name, &len); + assert(data && len == count && !memcmp(data, want, count)); +} +static void check(int except) +{ + copy_all(); + for (size_t port = 0; port < ARRAY_SIZE(phy_path); port++) { + int node = fdt_path_offset(dt, phy_path[port]); + if ((int)port == except || except == -2) { + assert(!usb3_properties(node)); + assert(!fdt_getprop(dt, node, "apple,tunable-lane0-usb", NULL)); + assert(!fdt_getprop(dt, node, "apple,tunable-lane1-usb", NULL)); + continue; + } + assert(usb3_properties(node) == 7); +''' + "\n".join(" " + c for c in checks) + r''' + /* The T8132 bundle replaces the t8122-style lists, which this PHY's driver ignores. */ + assert(!fdt_getprop(dt, node, "apple,tunable-common-b", NULL)); + } +} +int main(void) +{ + /* No board, chip id or firmware is asked: the ADT PHY and the tree's PHY node decide. */ + static const char *const boards[] = {"apple,j773g", "apple,j713", "apple,j604", + "apple,j623", "apple,j715"}; + for (size_t i = 0; i < ARRAY_SIZE(boards); i++) { + world(i & 1 ? 0 : T8132, boards[i]); puts("@all"); check(-1); + } + /* One PHY whose ADT lacks one required group keeps USB2; the other three are served. */ + static const char *const groups[] = {"tunable_ATCAXI2AF", "tunable_ATC_FABRIC", + "tunable_ACIOPHY_TOP", "tunable_LN1_TX_SHM_USB_DFLT"}; + for (size_t i = 0; i < ARRAY_SIZE(groups); i++) { + world(T8132, "apple,j773g"); hide_port = i; hide_name = groups[i]; + puts("@one-missing"); check(i); + } + /* An ADT PHY that is not atc-phy,t8132 gets none of this bundle. */ + world(T8132, "apple,j773g"); adt_phy = "atc-phy,t8140"; puts("@other-phy"); check(-2); + /* An atc-phy,t8132 ADT PHY under a tree node that is not apple,t8132-atcphy: none either. */ + other_node = true; + world(T8132, "apple,j773g"); puts("@other-node"); check(-2); + return 0; +} +''' + cfile = tmp_path / "t8132-atc.c" + binary = tmp_path / "t8132-atc" + cfile.write_text(harness) + libfdt = repo / "src/libfdt" + sources = [str(libfdt / name) for name in ( + "fdt.c", "fdt_ro.c", "fdt_rw.c", "fdt_sw.c", "fdt_wip.c", "fdt_empty_tree.c", + "fdt_strerror.c", + )] + subprocess.run(["cc", "-std=gnu11", "-D_GNU_SOURCE", "-Wall", "-Werror", "-Wno-unused-function", + "-Wno-unused-parameter", "-I", str(libfdt), str(cfile), *sources, "-o", + str(binary)], check=True) + result = subprocess.run([str(binary)], capture_output=True, text=True) + assert result.returncode == 0, result.stdout + result.stderr + # The lines the hardware boots are judged by, once per PHY. + copied = "FDT: Copied T8132 USB3 calibration" + refused = "FDT: T8132 USB3 calibration incomplete; preserving USB2 fallback" + stages = result.stdout.split("@")[1:] + assert len(stages) == 11 + for stage in stages: + name = stage.split("\n", 1)[0] + want = {"all": (4, 0), "one-missing": (3, 1), "other-phy": (0, 0), "other-node": (0, 0)}[name] + assert (stage.count(copied), stage.count(refused)) == want, stage