From 6cb4c3ec3e8b8086fc45222736a1828cbcf4cbef Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:48:33 +1100 Subject: [PATCH 1/3] drm/apple, phy: apple: atc: select the T6030 display fabric by its IP compatibles The T6030 display paths were selected by the root compatible (of_machine_is_compatible("apple,t6030")): - dcp-fabric.c: the tunnel pixel clock sources a route may use (dcp_route_tunnel_clock_blocked(), dcp_route_clock_rate(), dcp_tunnel_set_rate()) and the explicit crossbar link-up of a direct output (dcp_direct_crossbar_link()); - atc.c: the T8122-generation tunnel clock (apple_atc_tunnel_t8122_clock()) and the matching stop before a mode change (atcphy_configure()). What these follow is hardware: the T6030 display crossbars, where a selected output is only routed until its link is brought up and only external sources 0 and 2 reach the ATC PHY's tunnel pixel clocks, and the T6030 ATC PHY, which clocks both DP IN outputs from its own AUSPLL tunnel clock. Every display processor behind those crossbars is an apple,t6030-dcp or apple,t6030-dcpext, and every such PHY an apple,t6030-atcphy. Select them by those compatibles, through match data: a t6030_fabric flag for the two T6030 processors, read by dcp_is_t6030_fabric(), and a t8122_tunnel_clock flag for the PHY, set in a new apple,t6030-atcphy entry (the T8122 PHY data plus the flag) and in the T8132 PHY data. The PHY's mode change reads the same flag; a T8132 PHY never reaches that path (atcphy_configure_t8132()), so it is the condition it had. No functional change on any in-tree device tree: the T6030 machines (J514s, J516s) carry exactly these compatibles, and no other SoC does (T6031/T6034 use apple,t6031-*, T8122 apple,t8122-*). Whether the T8122 and T6031 PHYs, of the same generation, want the same tunnel clock sequence is not known and is not changed here. The host fixtures that replay these functions model the match data the way they modelled the machine check, and the ATC USB3 host test now resolves the new apple,t6030-atcphy entry. Fixes: 6a6ee2a94084 ("thunderbolt, phy, soc: apple: T6030 USB4/Thunderbolt, Type-C and DP tunnel support") Fixes: 9e03c19f921d ("drm/apple: reserve the T6030 HDMI processor with source-aware tunnel clocks") Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/dcp-fabric.c | 21 +++++++-- drivers/gpu/drm/apple/dcp-fabric.h | 1 + drivers/gpu/drm/apple/dcp-internal.h | 7 +++ drivers/gpu/drm/apple/dcp.c | 2 + drivers/phy/apple/atc.c | 45 ++++++++++++++++---- tools/asahi/atc-usb3-tests.py | 2 +- tools/asahi/dcpext26-crossbar-union-tests.py | 9 ++-- tools/asahi/t6030-clock/fixture.c | 11 ++++- tools/asahi/tunnel-route/fixture.c | 4 +- 9 files changed, 82 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-fabric.c b/drivers/gpu/drm/apple/dcp-fabric.c index 150cd163924f..cec30688690a 100644 --- a/drivers/gpu/drm/apple/dcp-fabric.c +++ b/drivers/gpu/drm/apple/dcp-fabric.c @@ -244,6 +244,19 @@ bool dcp_is_t8132_ext(const struct apple_dcp *dcp) return of_device_is_compatible(dcp->dev->of_node, "apple,t8132-dcpext"); } +/* + * A T6030 display processor, from its compatible's match data. Its outputs go + * through the T6030 display crossbars (apple,t6030-display-crossbar): there a + * selected output is only routed until its link is brought up, which starts + * its clocks, and only external sources 0 and 2 feed the ATC tunnel pixel + * clocks (dcp_fabric_t6030_pclk()). The T6031 and T6034 processors have + * their own compatibles and keep the default flow. + */ +bool dcp_is_t6030_fabric(const struct apple_dcp *dcp) +{ + return dcp->hw.t6030_fabric; +} + /* * DP IN outputs (bits 0/1) whose tunnel pixel clock source @route cannot be: * T6030 even sources only, T8132 its dcpexts (2 and 4), others any. @@ -253,7 +266,7 @@ static u8 dcp_route_tunnel_clock_blocked(const struct apple_dcp_typec_route *rou if (dcp_is_t8132_ext(route->dcp)) return (apple_dp_tunnel_t8132_pclk(route->mux_index, 0) < 0 ? BIT(0) : 0) | (apple_dp_tunnel_t8132_pclk(route->mux_index, 1) < 0 ? BIT(1) : 0); - return dcp_fabric_tunnel_clock_blocked(of_machine_is_compatible("apple,t6030"), + return dcp_fabric_tunnel_clock_blocked(dcp_is_t6030_fabric(route->dcp), route->mux_index); } @@ -481,7 +494,7 @@ static int dcp_route_clock_rate(struct apple_dcp_typec_route *route, } /* A T8132 dcpext names its source (2 or 4), as T6030 does. */ - if (of_machine_is_compatible("apple,t6030") || t8132) { + if (dcp_is_t6030_fabric(route->dcp) || t8132) { typeof(apple_atc_dp_tunnel_rate_source) *fn; if (t8132 ? apple_dp_tunnel_t8132_pclk(route->mux_index, dpin) < 0 : @@ -2619,7 +2632,7 @@ int dcp_direct_crossbar_link(struct apple_dcp *dcp, bool up) * On T6030, a T8132 dcpext and the selected native26 pipeline, * selecting a crossbar output only routes it; link-up enables clocks. */ - if (!of_machine_is_compatible("apple,t6030") && + if (!dcp_is_t6030_fabric(dcp) && !dcp_is_t8132_ext(dcp) && !dcp_is_ext26(dcp)) return 0; guard(mutex)(&dcp->tb_lock); @@ -2697,7 +2710,7 @@ int dcp_tunnel_set_rate(struct apple_dcp *dcp, struct phy *phy, u32 unit, } return ret; } - if (of_machine_is_compatible("apple,t6030") && + if (dcp_is_t6030_fabric(dcp) && (unit || dcp->dptx_dfp_port != 1 + route->tunnel_dpin || apple_dp_tunnel_t6030_pclk(route->mux_index, route->tunnel_dpin) < 0)) diff --git a/drivers/gpu/drm/apple/dcp-fabric.h b/drivers/gpu/drm/apple/dcp-fabric.h index bef215c12fd7..7ec0e0841ba3 100644 --- a/drivers/gpu/drm/apple/dcp-fabric.h +++ b/drivers/gpu/drm/apple/dcp-fabric.h @@ -117,6 +117,7 @@ int dcp_tunnel_dpin_activate(struct apple_dcp *dcp, u32 unit, bool active); /* An adopted T8132 dcpext. */ bool dcp_is_t8132_ext(const struct apple_dcp *dcp); +bool dcp_is_t6030_fabric(const struct apple_dcp *dcp); /* DCP probe, resume and endpoint teardown hooks. */ int dcp_register_typec_routes(struct apple_dcp *dcp); diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index ea38c3fd64de..b3e258632488 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -285,6 +285,13 @@ struct apple_dcp_hw_data { u32 firmware_request; /* M2 Pro/Max laptop T6020 Thunderbolt flow, from the match data */ bool t6020_tunnel_flow; + /* + * A T6030 display processor (apple,t6030-dcp, apple,t6030-dcpext), + * behind the T6030 display crossbars: selecting an output only routes + * it and linking it up starts its clocks, and only the even external + * sources reach the ATC tunnel pixel clocks, see dcp_is_t6030_fabric(). + */ + bool t6030_fabric; /* * A processor Linux starts itself on 14.7 firmware through the IOMFB * template whose AFK, DPTX and DPAV endpoints speak the 14.7 protocol diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 7cde46e00909..17e0025a0fb8 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -9662,6 +9662,7 @@ static const struct apple_dcp_hw_data apple_dcp_hw_dcp = { static const struct apple_dcp_hw_data apple_dcp_hw_t6030 = { .num_dptx_ports = 1, + .t6030_fabric = true, }; static const struct apple_dcp_hw_data apple_dcp_hw_t8122 = { @@ -9675,6 +9676,7 @@ static const struct apple_dcp_hw_data apple_dcp_hw_t6031 = { static const struct apple_dcp_hw_data apple_dcp_hw_t6030_dcpext = { .num_dptx_ports = 1, + .t6030_fabric = true, }; static const struct apple_dcp_hw_data apple_dcp_hw_t8122_dcpext = { diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index 34d3aa12b8f4..fa8607f96586 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -704,6 +704,9 @@ struct apple_atcphy; * can also drop while the system runs, see atcphy_rpm_get(). * Only for PHYs without DisplayPort, whose phy ops and tunnel * calls take no runtime PM reference + * @t8122_tunnel_clock: The DP IN outputs are clocked from the PHY's AUSPLL + * tunnel clock, see apple_atc_tunnel_t8122_clock(): the + * T6030 and T8132 PHYs */ struct atcphy_hw { void (*configure_post_tunable)(struct apple_atcphy *, enum atcphy_mode); @@ -725,6 +728,7 @@ struct atcphy_hw { bool clear_boot_hold; bool restore_after_pd_off; bool idle_power_off; + bool t8122_tunnel_clock; }; enum atcphy_t8132_bank { @@ -3576,15 +3580,17 @@ static int atc_tunnel_set_t602x(struct apple_atcphy *atcphy, unsigned int dpin, } /* - * T6030 (M3 Pro) uses T8122-generation PHYs for both DP IN clock outputs. - * The T8132 (M4) PHY has the same tunnel clock: AUSPLL descriptor, APB - * handshake, lock bit and TX_DP_CTRL0 selects are at the same offsets. + * The T6030 (M3 Pro) PHY (apple,t6030-atcphy, a T8122-generation PHY) clocks + * both DP IN outputs from its own AUSPLL tunnel clock. The T8132 (M4) PHY has + * the same tunnel clock: AUSPLL descriptor, APB handshake, lock bit and + * TX_DP_CTRL0 selects are at the same offsets. The match data of the PHY's + * compatible says which it is. The T8122 and T6031 PHYs share the T6030 one's + * generation but have their own compatibles and keep the T8103/T602X tunnel + * clock sequence. */ static bool apple_atc_tunnel_t8122_clock(struct apple_atcphy *atcphy) { - return (of_machine_is_compatible("apple,t6030") && - atcphy->hw->gen == ATCPHY_GENERATION_T8122) || - atcphy->hw->gen == ATCPHY_GENERATION_T8132; + return atcphy->hw->t8122_tunnel_clock; } /* Which pixel clock (0: PCLK1, 1: PCLK2) source @source uses for DP IN @dpin. */ @@ -4203,9 +4209,12 @@ static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode) } /* Keep failed transitions retryable even when the requested mode is unchanged. */ atcphy->mode_dirty = true; - /* the mode change below may power the PHY down: stop the tunnel clock first */ - if (of_machine_is_compatible("apple,t6030") && - atcphy->hw->gen == ATCPHY_GENERATION_T8122) { + /* + * The mode change below may power the PHY down: stop the tunnel clock + * first, by the sequence that started it. A T8132 PHY never gets here + * (atcphy_configure_t8132()). + */ + if (atcphy->hw->t8122_tunnel_clock) { ret = atc_t8122_tunnel_stop(atcphy); if (ret) return ret; @@ -7944,6 +7953,22 @@ static const struct atcphy_hw atcphy_hw_t8122 = { .restore_after_pd_off = true, }; +/* The T6030 PHY: the T8122 PHY, with the DP IN clocks on its tunnel clock. */ +static const struct atcphy_hw atcphy_hw_t6030 = { + .gen = ATCPHY_GENERATION_T8122, + .aciophy_lane_mode = ACIOPHY_LANE_MODE_T8122, + .aciophy_crossbar = ACIOPHY_CROSSBAR_T8122, + .configure_post_tunable = atcphy_configure_post_tunable_t8122, + .pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8103, + .pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103, + .has_usb4 = true, + .dp_t8122 = true, + .park_pipe_unlocked = true, + .park_dummy_phy = true, + .restore_after_pd_off = true, + .t8122_tunnel_clock = true, +}; + static const struct atcphy_hw atcphy_hw_t8132 = { .gen = ATCPHY_GENERATION_T8132, .usb2_only = true, @@ -7952,6 +7977,7 @@ static const struct atcphy_hw atcphy_hw_t8132 = { .pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103, .restore_after_pd_off = true, .idle_power_off = true, + .t8122_tunnel_clock = true, }; static const struct atcphy_hw atcphy_hw_t8140 = { @@ -7985,6 +8011,7 @@ static const struct atcphy_hw atcphy_hw_t8142 = { static const struct of_device_id atcphy_match[] = { { .compatible = "apple,t8103-atcphy", .data = &atcphy_hw_t8103 }, + { .compatible = "apple,t6030-atcphy", .data = &atcphy_hw_t6030 }, { .compatible = "apple,t8122-atcphy", .data = &atcphy_hw_t8122 }, { .compatible = "apple,t8132-atcphy", .data = &atcphy_hw_t8132 }, { .compatible = "apple,t8142-atcphy", .data = &atcphy_hw_t8142 }, diff --git a/tools/asahi/atc-usb3-tests.py b/tools/asahi/atc-usb3-tests.py index 3a7955197c9f..8f909ab8f0aa 100644 --- a/tools/asahi/atc-usb3-tests.py +++ b/tools/asahi/atc-usb3-tests.py @@ -624,7 +624,7 @@ def block(source, marker): def generation_scope(source, root): """Resolve real DT fallback compatibles through the driver's actual match table.""" tables = {} - for name in ("t8103", "t8122", "t8140", "t8142"): + for name in ("t8103", "t8122", "t6030", "t8140", "t8142"): text = block(source, "static const struct atcphy_hw atcphy_hw_" + name + " =") tables["atcphy_hw_" + name] = re.search(r"\.gen\s*=\s*(ATCPHY_GENERATION_\w+)", text).group(1) matches = dict(re.findall(r'\.compatible\s*=\s*"([^"]+)"\s*,\s*\.data\s*=\s*&([a-zA-Z0-9_]+)', source)) diff --git a/tools/asahi/dcpext26-crossbar-union-tests.py b/tools/asahi/dcpext26-crossbar-union-tests.py index 2edbcc37a448..13ae4440c101 100644 --- a/tools/asahi/dcpext26-crossbar-union-tests.py +++ b/tools/asahi/dcpext26-crossbar-union-tests.py @@ -52,7 +52,7 @@ def function(text, name): bool tunnel, selected; }; struct apple_dcp { - struct { int iomfb_method_profile; } hw; + struct { int iomfb_method_profile; bool t6030_fabric; } hw; int fw_compat, tb_lock; struct device *dev; struct apple_dcp_typec_route *active_typec_route; @@ -64,7 +64,7 @@ def function(text, name): static struct mux_control *last; static bool last_up; static int fault; -static bool of_machine_is_compatible(const char *name) { return !strcmp(machine, name); } +/* The gate reads the processor's match data, not the machine. */ static bool of_device_is_compatible(const struct device_node *n, const char *name) { return !strcmp(n->compatible, name); } @@ -90,6 +90,8 @@ def function(text, name): node.compatible = profile == 1 ? "apple,t8132-dcpext" : "apple,other-dcp"; struct apple_dcp d = { .dev = &dev, .active_typec_route = &route }; d.hw.iomfb_method_profile = profile == 2 ? DCP_IOMFB_METHODS_J613_EXT26 : 0; + /* A T6030 processor's match data, on the T6030 machine only. */ + d.hw.t6030_fabric = !strcmp(machine, "apple,t6030"); reset(); assert(dcp_direct_crossbar_link(&d, true) == 0); assert(links == 1 && locks == 1 && last == &a && last_up && d.direct_xbar_up == &a); @@ -134,7 +136,8 @@ def function(text, name): } ''' unit = pre + function(header, 'dcp_is_ext26') + '\n' -unit += function(source, 'dcp_is_t8132_ext') + '\n' + link + '\n' + cases +unit += function(source, 'dcp_is_t8132_ext') + '\n' +unit += function(source, 'dcp_is_t6030_fabric') + '\n' + link + '\n' + cases with tempfile.TemporaryDirectory() as tmp: c = Path(tmp) / 'crossbar.c' binary = Path(tmp) / 'crossbar' diff --git a/tools/asahi/t6030-clock/fixture.c b/tools/asahi/t6030-clock/fixture.c index 3efdc838fe8d..f258b25c1fb3 100644 --- a/tools/asahi/t6030-clock/fixture.c +++ b/tools/asahi/t6030-clock/fixture.c @@ -30,6 +30,7 @@ typedef uint64_t u64; /* REGISTER_DEFINES */ struct atcphy_hw { enum atcphy_generation gen; + bool t8122_tunnel_clock; }; struct apple_atcphy { const struct atcphy_hw *hw; @@ -86,6 +87,11 @@ static bool of_machine_is_compatible(const char *s) { return !strcmp(s, machine); } +/* The display processors of the modeled machine have its compatible. */ +static bool dcp_is_t6030_fabric(const struct apple_dcp *dcp) +{ + return !strcmp(machine, "apple,t6030"); +} static void atcphy_restore_after_pd_off(struct apple_atcphy *p) { } @@ -249,7 +255,8 @@ int main(int argc, char **argv) apple_dp_tunnel_t6030_pclk(source, dpin)); u8 regs[0x10000] = { 0 }; registers = regs; - struct atcphy_hw hw = { .gen = ATCPHY_GENERATION_T8122 }; + /* The T6030 PHY's match data (apple,t6030-atcphy). */ + struct atcphy_hw hw = { .gen = ATCPHY_GENERATION_T8122, .t8122_tunnel_clock = true }; struct apple_atcphy d = { .hw = &hw, .regs.core = regs, .mode = APPLE_ATCPHY_MODE_USB4 }; @@ -276,7 +283,9 @@ int main(int argc, char **argv) return 0; } if (!strcmp(name, "wrong-generation")) { + /* Another PHY's match data: no T8122 tunnel clock. */ hw.gen = ATCPHY_GENERATION_T8103; + hw.t8122_tunnel_clock = false; assert(clock_call(&phy, 0, 0, 0x14) == -EOPNOTSUPP && !writes); return 0; } diff --git a/tools/asahi/tunnel-route/fixture.c b/tools/asahi/tunnel-route/fixture.c index 2bcb8e713e5b..81063ec9e7cf 100644 --- a/tools/asahi/tunnel-route/fixture.c +++ b/tools/asahi/tunnel-route/fixture.c @@ -62,9 +62,9 @@ struct apple_dcp_typec_port { bool dp_wanted, dp_hpd, typec_yielded; }; static bool t6030, t8132_ext; -static bool of_machine_is_compatible(const char *compatible) +/* Production: the T6030 processor's match data (dcp->hw.t6030_fabric). */ +static bool dcp_is_t6030_fabric(const struct apple_dcp *dcp) { - assert(!strcmp(compatible, "apple,t6030")); return t6030; } /* Production: of_device_is_compatible(dcp->dev->of_node, "apple,t8132-dcpext"). */ From 76da970002daae0c7b5ce4c1df65928481d040e7 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:56:16 +1100 Subject: [PATCH 2/3] selftests: apple-dcp: keep the PHY fixtures' machine mock when it goes unused The PHY host fixtures in phy.py define of_machine_is_compatible() for the ATC functions they extract. Since the T6030 tunnel clock stop in atcphy_configure() reads the PHY's match data instead of the machine, no extracted function calls the mock any more, and the units fail to build under -Werror=unused-function. Mark the two mocks unused, as the fixtures do for other optional stubs. Fixes: 6cb4c3ec3e8b ("drm/apple, phy: apple: atc: select the T6030 display fabric by its IP compatibles") Signed-off-by: Ryan Murray --- tools/testing/selftests/drivers/gpu/apple-dcp/phy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py b/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py index 26c0f62dabb2..c68c5a2d6475 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py @@ -149,7 +149,7 @@ def function(source, name): static int atcphy_dp_link_stop_t8122(struct apple_atcphy *p) { assert(!p->dp_t8122.pll && !p->dp_t8122.pairs); return 0; } #define __iomem -static bool of_machine_is_compatible(const char *name) { (void)name; return false; } +static bool __attribute__((unused)) of_machine_is_compatible(const char *name) { (void)name; return false; } #ifndef READ_ONCE #define READ_ONCE(x) (x) #endif @@ -2414,7 +2414,7 @@ def function(source, name): { assert(!p->dp_t8122.aux && !p->dp_t8122.pll); } static void atcphy_dp_aux_on_t8122(struct apple_atcphy *p) { assert(!p->hw->dp_t8122); } -static bool of_machine_is_compatible(const char *name) { (void)name; return false; } +static bool __attribute__((unused)) of_machine_is_compatible(const char *name) { (void)name; return false; } #ifndef READ_ONCE #define READ_ONCE(x) (x) #endif From e583b4eb58734a5980f91b3bc1c98e7bda7313d5 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 01:12:46 +1100 Subject: [PATCH 3/3] phy: apple: atc: select the T8103 and T600x tunnel clocks by PHY compatible The DP tunnel pixel clock sequence of a T8103-generation PHY was picked by the root compatible: apple_atc_tunnel_is_t600x() (apple,t6000 or apple,t6001) and apple_atc_tunnel_is_t8103_style() (apple,t8103, apple,t8112 or T600x). A T8103-style PHY feeds both DP IN adapters from one AUSPLL pixel clock; a T600x one also runs PCLK2 and the DPRX clock and is opened before the first rate request; every other PHY took the per-DP IN T602x sequence. Which of these a PHY needs is a property of the PHY: the T8103 and T8112 PHYs ("apple,t8103-atcphy", the T8112 one through its fallback), the T600x PHY ("apple,t6000-atcphy") and the T602x PHY ("apple,t6020-atcphy") all share the T8103 register generation and match data today. Give the T600x and T602x PHYs their own match entries (the T8103 data, which they get now through the fallback) and say in the match data which tunnel clock they have: tunnel_t8103_clock for the T8103 entry and T600x, tunnel_dprx_clock for T600x only. apple_atc_dp_tunnel_open() now answers -EOPNOTSUPP for a PHY of another driver before it looks at the match data, as it did on every machine but T6000/T6001. No functional change on T8103, T8112, T6000, T6001 and T602x. T6002 (M1 Ultra), whose PHYs are the same apple,t6000-atcphy blocks (t600x-dieX.dtsi) but whose root compatible was not in the list, now gets the T600x sequence instead of the T602x one; there the T602x path refused every rate with -EOPNOTSUPP, as T6002 has no T602x tunnel wiring (apple_atc_t602x_qualified()). The ATC USB3 host test resolves the two new entries. Fixes: 49fa0659212f ("phy: apple: atc: run the t8103 tunnel clock sequence on t600x") Signed-off-by: Ryan Murray --- drivers/phy/apple/atc.c | 79 +++++++++++++++++++++++++---------- tools/asahi/atc-usb3-tests.py | 2 +- 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index fa8607f96586..8eb960aa99ad 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -680,6 +680,15 @@ struct apple_atcphy; * @aciophy_lane_mode: Lane mode register offset * @aciophy_crossbar: Crossbar register offset * @has_usb4: A USB4/Thunderbolt controller sits behind the PHY + * @tunnel_t8103_clock: DP tunnels are clocked by the T8103 sequence: one + * AUSPLL pixel clock (PCLK1) feeds both DP IN adapters, + * see atc_tunnel_start_t8103(); the T8103, T8112 and T600x + * PHYs. Without it, and without @t8122_tunnel_clock, each + * DP IN has its own clock (atc_tunnel_set_t602x()) + * @tunnel_dprx_clock: With @tunnel_t8103_clock, the tunnel also runs PCLK2 and + * the DP IN (DPRX) clock at the same rate, and the clock + * path is woken before the first rate request + * (apple_atc_dp_tunnel_open()): the T600x PHY * @usb2_only: Uses the USB2 subset unless its banked SuperSpeed resources exist * @usb2phy_sig_host: Host role field mask, or zero for the original layout * @pipe_mux_clk: PIPE clock selection field mask @@ -714,6 +723,8 @@ struct atcphy_hw { int aciophy_lane_mode; int aciophy_crossbar; bool has_usb4; + bool tunnel_t8103_clock; + bool tunnel_dprx_clock; bool usb2_only; u32 usb2phy_sig_host; u32 pipe_mux_clk; @@ -2901,13 +2912,6 @@ static void atcphy_configure_post_tunable_all_modes(struct apple_atcphy *atcphy, * without touching the lane mux. Based on Oliver Lukschander's t6020 tunnel * clock patch (asahi-j416s-display). */ -/* t600x (M1 Pro/Max) has the t8103 generation ATC. */ -static bool apple_atc_tunnel_is_t600x(void) -{ - return of_machine_is_compatible("apple,t6000") || - of_machine_is_compatible("apple,t6001"); -} - /* * Stop the tunnel pixel clock: switch the AUSPLL output drivers off and send * APB command 3. TX_DP_CTRL0, the sleep overrides and the @@ -3139,7 +3143,7 @@ static void atc_tunnel_pclk_t8103(struct apple_atcphy *atcphy, u32 selector) { core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTXPHY_PMA_LANE_RESET_N); core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTXPHY_PMA_LANE_RESET_N_OV); - if (apple_atc_tunnel_is_t600x()) { + if (atcphy->hw->tunnel_dprx_clock) { core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPRX_PCLK_ENABLE); core_set32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPTX_PCLK2_ENABLE); core_mask32(atcphy, ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0, DPRX_PCLK_SELECT, @@ -5002,13 +5006,13 @@ static const struct phy_ops apple_atc_dp_phy_ops = { * Thunderbolt DP IN adapter @dpin (rate is the DP link rate code, 0 = stop). */ /* - * t600x (M1 Pro/Max) and t8112 (M2, whose ATC PHY is t8103-compatible) run - * the t8103 tunnel clock sequence unchanged. + * The T8103-generation PHYs of T8103, T8112 (M2) and T600x (M1 Pro/Max/Ultra) + * run the T8103 tunnel clock sequence; the T6020 PHY, of the same generation, + * has a clock per DP IN. The PHY's match data says which (tunnel_t8103_clock). */ -static bool apple_atc_tunnel_is_t8103_style(void) +static bool apple_atc_tunnel_is_t8103_style(const struct apple_atcphy *atcphy) { - return of_machine_is_compatible("apple,t8103") || - of_machine_is_compatible("apple,t8112") || apple_atc_tunnel_is_t600x(); + return atcphy->hw->tunnel_t8103_clock; } int apple_atc_dp_tunnel_rate_source(struct phy *phy, unsigned int source, @@ -5125,7 +5129,7 @@ int apple_atc_dp_tunnel_rate(struct phy *phy, unsigned int dpin, u8 rate) */ if (apple_atc_tunnel_t8122_clock(atcphy)) return apple_atc_dp_tunnel_rate_source(phy, 0, dpin, rate); - if (!apple_atc_tunnel_is_t8103_style()) { + if (!apple_atc_tunnel_is_t8103_style(atcphy)) { bool valid_core = apple_atc_t602x_core_valid(atcphy->np, atcphy->res.core->start, resource_size(atcphy->res.core)); @@ -5136,7 +5140,7 @@ int apple_atc_dp_tunnel_rate(struct phy *phy, unsigned int dpin, u8 rate) } guard(mutex)(&atcphy->lock); if (!rate) { - if (apple_atc_tunnel_is_t8103_style()) { + if (apple_atc_tunnel_is_t8103_style(atcphy)) { /* * One pixel clock feeds both DP IN adapters: a stream * that ends must not stop the other one's clock. @@ -5151,7 +5155,7 @@ int apple_atc_dp_tunnel_rate(struct phy *phy, unsigned int dpin, u8 rate) } if (atcphy->mode != APPLE_ATCPHY_MODE_USB4 && atcphy->mode != APPLE_ATCPHY_MODE_TBT) return -EBUSY; - if (apple_atc_tunnel_is_t8103_style()) { + if (apple_atc_tunnel_is_t8103_style(atcphy)) { ret = atc_tunnel_start_t8103(atcphy, rate); if (!ret) atcphy->tunnel_users |= BIT(dpin); @@ -5173,15 +5177,16 @@ int apple_atc_dp_tunnel_open(struct phy *phy) if (!phy) return -EINVAL; /* - * Everything but t600x has nothing to open, whichever driver provides - * the PHY: T6050's tunnel clocks belong to atc-t6050-dp.c, whose PHY - * this driver does not know, and start from the link rate alone. + * Only a PHY with the DPRX tunnel clock (T600x) has something to open. + * Others, whichever driver provides them, start from the link rate + * alone: T6050's tunnel clocks belong to atc-t6050-dp.c, whose PHY this + * driver does not know. */ - if (!apple_atc_tunnel_is_t600x()) - return -EOPNOTSUPP; if (phy->ops != &apple_atc_dp_phy_ops) - return -EINVAL; + return -EOPNOTSUPP; atcphy = phy_get_drvdata(phy); + if (!atcphy->hw->tunnel_dprx_clock) + return -EOPNOTSUPP; guard(mutex)(&atcphy->lock); if (atcphy->mode != APPLE_ATCPHY_MODE_USB4 && atcphy->mode != APPLE_ATCPHY_MODE_TBT) return -EBUSY; @@ -7928,7 +7933,35 @@ static const struct dev_pm_ops atcphy_pm_ops = { NOIRQ_SYSTEM_SLEEP_PM_OPS(atcphy_suspend_noirq, atcphy_resume_noirq) }; +/* T8103, and T8112 through its fallback compatible. */ static const struct atcphy_hw atcphy_hw_t8103 = { + .gen = ATCPHY_GENERATION_T8103, + .aciophy_lane_mode = ACIOPHY_LANE_MODE_T8103, + .aciophy_crossbar = ACIOPHY_CROSSBAR_T8103, + .configure_post_tunable = atcphy_configure_post_tunable_t8103, + .pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8103, + .pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103, + .has_usb4 = true, + .tunnel_t8103_clock = true, + .park_pipe_unlocked = true, +}; + +/* T600x: the T8103 PHY, whose tunnels also run PCLK2 and the DPRX clock. */ +static const struct atcphy_hw atcphy_hw_t6000 = { + .gen = ATCPHY_GENERATION_T8103, + .aciophy_lane_mode = ACIOPHY_LANE_MODE_T8103, + .aciophy_crossbar = ACIOPHY_CROSSBAR_T8103, + .configure_post_tunable = atcphy_configure_post_tunable_t8103, + .pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8103, + .pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8103, + .has_usb4 = true, + .tunnel_t8103_clock = true, + .tunnel_dprx_clock = true, + .park_pipe_unlocked = true, +}; + +/* T602x: the T8103 PHY, with a tunnel clock per DP IN. */ +static const struct atcphy_hw atcphy_hw_t6020 = { .gen = ATCPHY_GENERATION_T8103, .aciophy_lane_mode = ACIOPHY_LANE_MODE_T8103, .aciophy_crossbar = ACIOPHY_CROSSBAR_T8103, @@ -8011,6 +8044,8 @@ static const struct atcphy_hw atcphy_hw_t8142 = { static const struct of_device_id atcphy_match[] = { { .compatible = "apple,t8103-atcphy", .data = &atcphy_hw_t8103 }, + { .compatible = "apple,t6000-atcphy", .data = &atcphy_hw_t6000 }, + { .compatible = "apple,t6020-atcphy", .data = &atcphy_hw_t6020 }, { .compatible = "apple,t6030-atcphy", .data = &atcphy_hw_t6030 }, { .compatible = "apple,t8122-atcphy", .data = &atcphy_hw_t8122 }, { .compatible = "apple,t8132-atcphy", .data = &atcphy_hw_t8132 }, diff --git a/tools/asahi/atc-usb3-tests.py b/tools/asahi/atc-usb3-tests.py index 8f909ab8f0aa..2e69dca5b5fd 100644 --- a/tools/asahi/atc-usb3-tests.py +++ b/tools/asahi/atc-usb3-tests.py @@ -624,7 +624,7 @@ def block(source, marker): def generation_scope(source, root): """Resolve real DT fallback compatibles through the driver's actual match table.""" tables = {} - for name in ("t8103", "t8122", "t6030", "t8140", "t8142"): + for name in ("t8103", "t6000", "t6020", "t8122", "t6030", "t8140", "t8142"): text = block(source, "static const struct atcphy_hw atcphy_hw_" + name + " =") tables["atcphy_hw_" + name] = re.search(r"\.gen\s*=\s*(ATCPHY_GENERATION_\w+)", text).group(1) matches = dict(re.findall(r'\.compatible\s*=\s*"([^"]+)"\s*,\s*\.data\s*=\s*&([a-zA-Z0-9_]+)', source))