From ecbbfa81bfc95bc5534bffc039f1bc4f891e97ae Mon Sep 17 00:00:00 2001 From: Roberto Dantas <7robertodantas@gmail.com> Date: Mon, 23 Nov 2026 08:31:22 -0300 Subject: [PATCH 1/2] arm64: dts: apple: t6041-j575c: give the port controllers their LOCK key The tipd driver renegotiates the connection that a J575c port inherits from the boot chain (apple,reset-inherited-usb2-connection). The DISC command it sends for that needs the controller unlocked by LOCK with the board's key, the board number reversed. The driver keeps that key in a table of machines. Describe it on the three ports that are renegotiated, with the binding's apple,debug-lock-key, so the driver can take it from there instead of its table. The key is the one the driver uses today ("575J"). Elsewhere the driver reads the property for a debug link that a sleep cut (these ports have none), for the boot power state's HChk and USBw (the J575c ports are in S0 already at the probe), and for the post-sleep replug of a T6050 host. None of that runs on these ports. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com> --- arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi | 1 + arch/arm64/boot/dts/apple/t6041-j575c.dts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi b/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi index 3971e75915e90..1fe04fb9e6212 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi @@ -117,6 +117,7 @@ apple,event-irq-in-sleep; /* Retimer set up before Linux keeps SuperSpeed down until replugged. */ apple,reset-inherited-usb2-connection; + apple,debug-lock-key = "575J"; typec3: connector { compatible = "usb-c-connector"; diff --git a/arch/arm64/boot/dts/apple/t6041-j575c.dts b/arch/arm64/boot/dts/apple/t6041-j575c.dts index 06ee0da56448f..91da674fc549a 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c.dts +++ b/arch/arm64/boot/dts/apple/t6041-j575c.dts @@ -1449,6 +1449,7 @@ apple,event-irq-in-sleep; /* Retimer set up before Linux keeps SuperSpeed down until replugged. */ apple,reset-inherited-usb2-connection; + apple,debug-lock-key = "575J"; typec1: connector { compatible = "usb-c-connector"; @@ -1481,6 +1482,7 @@ apple,event-irq-in-sleep; /* Retimer set up before Linux keeps SuperSpeed down until replugged. */ apple,reset-inherited-usb2-connection; + apple,debug-lock-key = "575J"; typec2: connector { compatible = "usb-c-connector"; From 2375501aa80ab09d7439a30585e6c0382346353b Mon Sep 17 00:00:00 2001 From: Roberto Dantas <7robertodantas@gmail.com> Date: Mon, 23 Nov 2026 08:31:51 -0300 Subject: [PATCH 2/2] usb: typec: tipd: take the J575c's renegotiation key from the DT The renegotiation of an inherited connection took its LOCK key, and whether a failure fails the probe, from a table of machines (cd321x_inherited_boards[]). The J575c ports now carry their key in apple,debug-lock-key, which the partner replug already reads. Take the key from there when the port has one, and drop the J575c row. A port with its key in the DT is left as it was when the renegotiation fails, as the J575c row asked. The J716c keeps its row and its behaviour: its DT has no key yet, and a failure still fails its probe. A port with the property but no key either way keeps its connection as it is, with a warning, so a J575c booted with an older DT comes up as before the renegotiation instead of failing. Signed-off-by: Roberto Dantas <7robertodantas@gmail.com> --- drivers/usb/typec/tipd/core.c | 73 +++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index b13054a905e03..d9ece372d36a4 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -3581,25 +3581,38 @@ static int cd321x_remove(struct tps6598x *tps) } /* - * Boards whose inherited boot connection must be renegotiated. The port - * controller key is the reversed target identifier. + * An SN201202x takes "DISC" unlocked with the key its DT gives it (apple,debug-lock-key, the board + * number reversed). + */ +static int tipd_replug_key(struct tps6598x *tps, u8 key[4]) +{ + const char *s; + + if (!device_is_compatible(tps->dev, "apple,sn201202x") || + device_property_read_string(tps->dev, "apple,debug-lock-key", &s) || strlen(s) != 4) + return -EOPNOTSUPP; + memcpy(key, s, 4); + return 0; +} + +/* + * A connection that was up before Linux keeps state from the boot chain: a USB2 repeater + * connection on the J716c boot port, or on the J575c a Type-C retimer set up before the host PHY + * ran, so SuperSpeed stays in RxDetect until the partner is replugged. The controller reports + * nothing that tells such a connection apart from one that trains, so every one is renegotiated. * - * J716c: the boot port keeps a USB2 repeater connection. - * J575c: a connection that was up before Linux keeps its Type-C retimer set up - * from before the host PHY ran, so SuperSpeed stays in RxDetect until the - * partner is replugged. Every such connection is renegotiated: the controller - * reports nothing that tells it apart from one whose SuperSpeed side trains. - * A failure leaves the port as it was (USB2 only) instead of failing the probe. + * The renegotiation's DISC takes the controller unlocked with the board's LOCK key, the board + * number reversed. A port whose DT gives it (apple,debug-lock-key) is left as it was if the + * renegotiation fails. The J716c's DT does not give it yet: its key is here, and a failure there + * fails the probe. */ struct cd321x_inherited_board { const char *compatible; u8 key[4]; - bool best_effort; }; static const struct cd321x_inherited_board cd321x_inherited_boards[] = { { .compatible = "apple,j716c", .key = { '6', '1', '7', 'J' } }, - { .compatible = "apple,j575c", .key = { '5', '7', '5', 'J' }, .best_effort = true }, }; static const struct cd321x_inherited_board *cd321x_inherited_board(void) @@ -3612,8 +3625,7 @@ static const struct cd321x_inherited_board *cd321x_inherited_board(void) return NULL; } -static int __cd321x_reset_inherited_connection(struct tps6598x *tps, - const struct cd321x_inherited_board *board, +static int __cd321x_reset_inherited_connection(struct tps6598x *tps, const u8 key[4], u32 *status) { static const u8 locked[4]; @@ -3626,8 +3638,7 @@ static int __cd321x_reset_inherited_connection(struct tps6598x *tps, return 0; /* All suppliers are available, but no USB or router session has started. */ - ret = tps6598x_exec_cmd(tps, "LOCK", sizeof(board->key), board->key, sizeof(result), - &result); + ret = tps6598x_exec_cmd(tps, "LOCK", 4, key, sizeof(result), &result); if (ret) return ret; if (result) { @@ -3670,6 +3681,8 @@ static int __cd321x_reset_inherited_connection(struct tps6598x *tps, static int cd321x_reset_inherited_connection(struct tps6598x *tps, u32 *status) { const struct cd321x_inherited_board *board; + bool best_effort = true; + u8 key[4]; int ret; if (!device_property_read_bool(tps->dev, "apple,reset-inherited-usb2-connection") || @@ -3677,12 +3690,19 @@ static int cd321x_reset_inherited_connection(struct tps6598x *tps, u32 *status) tps->dbma_at_probe || !(*status & TPS_STATUS_PLUG_PRESENT) || !TPS_STATUS_TO_TYPEC_DATAROLE(*status)) return 0; - board = cd321x_inherited_board(); - if (!board) - return 0; + if (tipd_replug_key(tps, key)) { + board = cd321x_inherited_board(); + if (!board) { + dev_warn(tps->dev, + "inherited connection not reinitialized: no apple,debug-lock-key\n"); + return 0; + } + memcpy(key, board->key, sizeof(key)); + best_effort = false; + } - ret = __cd321x_reset_inherited_connection(tps, board, status); - if (!ret || !board->best_effort) + ret = __cd321x_reset_inherited_connection(tps, key, status); + if (!ret || !best_effort) return ret; dev_warn(tps->dev, "inherited connection not reinitialized: %d\n", ret); @@ -3719,21 +3739,6 @@ static void tipd_port_list_del(struct tps6598x *tps) cancel_work_sync(&tps->replug_work); } -/* - * An SN201202x takes "DISC" unlocked with the key its DT gives it (apple,debug-lock-key, the board - * number reversed). - */ -static int tipd_replug_key(struct tps6598x *tps, u8 key[4]) -{ - const char *s; - - if (!device_is_compatible(tps->dev, "apple,sn201202x") || - device_property_read_string(tps->dev, "apple,debug-lock-key", &s) || strlen(s) != 4) - return -EOPNOTSUPP; - memcpy(key, s, 4); - return 0; -} - bool tipd_replug_supported(struct tps6598x *tps) { u8 key[4];