From 8ca01e3299ce2fad177b3b6f13dd31ffe2fa3d60 Mon Sep 17 00:00:00 2001 From: AxxzyWasTaken Date: Sat, 14 Nov 2026 08:28:58 +0000 Subject: [PATCH 1/5] usb: typec: tipd: sn201202x: sleep while idle on T6041 too Idle sleep (#833) is given only to controllers without a select notification, which are the T8132 ones. The M4 Max (T6041) has four SN201202x controllers with a select interrupt, and they stay awake for as long as the system does. Their event interrupt stays live while they sleep, as on T8132, and register access in that state polls the same way. So give T6041's controllers the same sleep event filter, and with it idle sleep. On a J616c, all four controllers runtime-suspend at idle. Awake against asleep, three rounds each: the SoC rail reads 1.85-1.87 W against 1.74-1.76 W, and the system total about 0.05-0.2 W lower. A USB device plugged in while they slept was detected, and they went back to sleep with it attached. Assisted-by: LLM Signed-off-by: AxxzyWasTaken --- drivers/usb/typec/tipd/spmi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/spmi.c b/drivers/usb/typec/tipd/spmi.c index ddd28b8d94e46..39f724f9915ad 100644 --- a/drivers/usb/typec/tipd/spmi.c +++ b/drivers/usb/typec/tipd/spmi.c @@ -803,8 +803,13 @@ static int sn201202x_probe(struct spmi_device *device) /* * In system sleep only the event interrupt stays live. Register access * then has to poll, which a select notification would not. + * + * T6041 (M4 Max) has a select notification, and its event interrupt + * stays live with the controller asleep as on T8132, so its four + * controllers sleep while idle too. */ - if (!sn->polled && sn->select_polled) + if (!sn->polled && + (sn->select_polled || of_machine_is_compatible("apple,t6041"))) tps->sleep_event = sn201202x_sleep_event; spmi_device_set_drvdata(device, tps); From 78ad8ef03d88a4be782e76669f504656120372bc Mon Sep 17 00:00:00 2001 From: AxxzyWasTaken Date: Sat, 14 Nov 2026 18:27:40 +0000 Subject: [PATCH 2/5] usb: typec: tipd: sn201202x: idle sleep on T6041 without the system-sleep filter Giving T6041 tps->sleep_event also moved it to the system-sleep event filter. That filter reads the controller from an IRQF_NO_SUSPEND event interrupt, and on T6041 register access waits for the select interrupt, which is disabled for the whole system sleep. A plug in suspend-to-idle could then block the IRQ thread instead of waking the system. Decouple the two. A new sn->idle_sleep lets a controller sleep while idle where its event interrupt stays live (T8132 and T6041), and sleep_event, with the system-sleep filter, stays T8132's alone. T6041 keeps its wake IRQ in system sleep, as before; its suspend already wakes a controller asleep from idle through runtime PM first. Assisted-by: LLM Signed-off-by: AxxzyWasTaken --- drivers/usb/typec/tipd/sn201202x-pm-test.c | 1 + drivers/usb/typec/tipd/spmi.c | 23 ++++++++++++---------- drivers/usb/typec/tipd/tps6598x.h | 2 ++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/usb/typec/tipd/sn201202x-pm-test.c b/drivers/usb/typec/tipd/sn201202x-pm-test.c index 7fab562ea81d8..82bd1d8df528a 100644 --- a/drivers/usb/typec/tipd/sn201202x-pm-test.c +++ b/drivers/usb/typec/tipd/sn201202x-pm-test.c @@ -219,6 +219,7 @@ static struct sn201202x_test *__sn201202x_test_port(struct kunit *test, bool idl tps = &t->sn.cd.tps; tps->dev = t->dev; tps->data = tipd_hw_variants[TIPD_VARIANT_SN201202X]; + t->sn.idle_sleep = idle_sleep; if (idle_sleep) tps->sleep_event = sn201202x_test_sleep_event; spmi_device_set_drvdata(t->sn.sdev, tps); diff --git a/drivers/usb/typec/tipd/spmi.c b/drivers/usb/typec/tipd/spmi.c index 39f724f9915ad..ca3dc292eb1e3 100644 --- a/drivers/usb/typec/tipd/spmi.c +++ b/drivers/usb/typec/tipd/spmi.c @@ -622,12 +622,12 @@ EXPORT_SYMBOL_IF_KUNIT(sn201202x_runtime_resume); /* * The SPMI bus holds a runtime PM reference while the driver is bound. * Probe gives it to idle sleep only where the event interrupt stays live - * while the controller sleeps, as the system sleep event filter has it; - * elsewhere the controller stays awake. + * while the controller sleeps (sn->idle_sleep); elsewhere the controller + * stays awake. */ VISIBLE_IF_KUNIT void sn201202x_idle_sleep_start(struct tps6598x *tps) { - if (!tps->sleep_event) + if (!tps_to_sn(tps)->idle_sleep) return; pm_runtime_set_autosuspend_delay(tps->dev, SN201202X_AUTOSUSPEND_MS); pm_runtime_use_autosuspend(tps->dev); @@ -638,7 +638,7 @@ EXPORT_SYMBOL_IF_KUNIT(sn201202x_idle_sleep_start); /* On remove, once the bus has woken it: take back the reference */ VISIBLE_IF_KUNIT void sn201202x_idle_sleep_stop(struct tps6598x *tps) { - if (!tps->sleep_event) + if (!tps_to_sn(tps)->idle_sleep) return; pm_runtime_get_noresume(tps->dev); pm_runtime_dont_use_autosuspend(tps->dev); @@ -803,14 +803,17 @@ static int sn201202x_probe(struct spmi_device *device) /* * In system sleep only the event interrupt stays live. Register access * then has to poll, which a select notification would not. - * - * T6041 (M4 Max) has a select notification, and its event interrupt - * stays live with the controller asleep as on T8132, so its four - * controllers sleep while idle too. */ - if (!sn->polled && - (sn->select_polled || of_machine_is_compatible("apple,t6041"))) + if (!sn->polled && sn->select_polled) tps->sleep_event = sn201202x_sleep_event; + /* + * Idle sleep needs only the event interrupt to stay live while the + * controller sleeps, as it does on T8132 and on T6041 (M4 Max). A + * register access then wakes it through runtime PM, select notification + * or not. T6041 keeps its own system sleep path (a wake IRQ). + */ + sn->idle_sleep = !sn->polled && + (sn->select_polled || of_machine_is_compatible("apple,t6041")); spmi_device_set_drvdata(device, tps); tps->regmap = devm_regmap_init_sn201202x(device, &tps6598x_regmap_config); diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 68d246b7397e1..6982a769464e6 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -493,6 +493,8 @@ struct sn201202x { struct cd321x cd; bool polled; bool select_polled; + /* Sleeps while idle: its event interrupt stays live while it sleeps */ + bool idle_sleep; struct completion select_completion; struct completion sleep_completion; struct completion wake_completion; From d688b642dcfc80c07cfc6d4fdd96d8188bdb36ce Mon Sep 17 00:00:00 2001 From: AxxzyWasTaken Date: Thu, 19 Nov 2026 18:10:18 +0000 Subject: [PATCH 3/5] dt-bindings: usb: apple,sn201202x: the event interrupt in sleep Whether an SN201202x can sleep while its port is idle depends on one thing: its event interrupt stays live while the controller sleeps, so a plug or other port event still reaches the host. Describe that with a boolean on the controller node, so the driver doesn't have to know which SoCs it was seen on. Assisted-by: LLM Signed-off-by: AxxzyWasTaken --- Documentation/devicetree/bindings/usb/apple,sn201202x.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml b/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml index a1f25de21b2e6..a074d56e4c305 100644 --- a/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml +++ b/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml @@ -53,6 +53,13 @@ properties: The four-character key that unlocks the controller's debug mode, for rearming the debug link after a sleep ended it. + apple,event-irq-in-sleep: + type: boolean + description: + The controller's event interrupt stays live while the controller + sleeps, so it can sleep while its port is idle and still report a + port event. A register access wakes it first. + apple,usb-remote-wake: type: boolean description: From 06c496585f3cb36e71e2ab4ea308fd03ac7eb423 Mon Sep 17 00:00:00 2001 From: AxxzyWasTaken Date: Thu, 19 Nov 2026 18:10:37 +0000 Subject: [PATCH 4/5] arm64: dts: apple: t6041: the port controllers' event interrupt in sleep On the J616c all four SN201202x (1-08, 1-0a, 1-0c, 2-0c) runtime-suspend while idle, and a USB device plugged in while all four slept was detected: the event interrupt stays live while they sleep. Mark every SN201202x node of the T6041 boards with apple,event-irq-in-sleep, which is where the driver turns idle sleep on today by the "apple,t6041" machine compatible: the J614c and J616c (shared file) and the J575c's four ports. Only the J616c was measured. The driver reads the property from the next commit on. Assisted-by: LLM Signed-off-by: AxxzyWasTaken --- arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi | 1 + arch/arm64/boot/dts/apple/t6041-j575c.dts | 3 +++ arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi b/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi index 6399e6698293b..3971e75915e90 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi @@ -114,6 +114,7 @@ <95 IRQ_TYPE_EDGE_RISING>, <97 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; /* Retimer set up before Linux keeps SuperSpeed down until replugged. */ apple,reset-inherited-usb2-connection; diff --git a/arch/arm64/boot/dts/apple/t6041-j575c.dts b/arch/arm64/boot/dts/apple/t6041-j575c.dts index edbdefbfc352d..e7bfab3be6730 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c.dts +++ b/arch/arm64/boot/dts/apple/t6041-j575c.dts @@ -1408,6 +1408,7 @@ <17 IRQ_TYPE_EDGE_RISING>, <19 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; typec0: connector { compatible = "usb-c-connector"; @@ -1437,6 +1438,7 @@ <43 IRQ_TYPE_EDGE_RISING>, <45 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; /* Retimer set up before Linux keeps SuperSpeed down until replugged. */ apple,reset-inherited-usb2-connection; @@ -1468,6 +1470,7 @@ <69 IRQ_TYPE_EDGE_RISING>, <71 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; /* Retimer set up before Linux keeps SuperSpeed down until replugged. */ apple,reset-inherited-usb2-connection; diff --git a/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi b/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi index 8e2b49a4567ea..b1789347116b7 100644 --- a/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi @@ -1780,6 +1780,7 @@ <17 IRQ_TYPE_EDGE_RISING>, <19 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; typec0: connector { compatible = "usb-c-connector"; @@ -1817,6 +1818,7 @@ <69 IRQ_TYPE_EDGE_RISING>, <71 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; }; hpm1: usb-pd@a { @@ -1827,6 +1829,7 @@ <43 IRQ_TYPE_EDGE_RISING>, <45 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; typec1: connector { compatible = "usb-c-connector"; @@ -1867,6 +1870,7 @@ <17 IRQ_TYPE_EDGE_RISING>, <19 IRQ_TYPE_EDGE_RISING>; interrupt-names = "irq", "select", "sleep", "wake"; + apple,event-irq-in-sleep; typec2: connector { compatible = "usb-c-connector"; From d8c51f9cd27df52e7190c6b13a037affb5d02939 Mon Sep 17 00:00:00 2001 From: AxxzyWasTaken Date: Thu, 19 Nov 2026 18:10:37 +0000 Subject: [PATCH 5/5] usb: typec: tipd: sn201202x: idle sleep by the DT, not the machine Idle sleep needs only the event interrupt to stay live while the controller sleeps. Key it on the node's apple,event-irq-in-sleep instead of of_machine_is_compatible("apple,t6041"). T8132's select-polled controllers keep it as before, since their system sleep filter already depends on the same thing. The T6041 boards' nodes have the property, so nothing changes on them, and every other board stays awake as before. Another SoC with the same controllers (the M4 Pro, say) gets idle sleep by setting the property once its rows show the interrupt holds. Assisted-by: LLM Signed-off-by: AxxzyWasTaken --- drivers/usb/typec/tipd/spmi.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/spmi.c b/drivers/usb/typec/tipd/spmi.c index ca3dc292eb1e3..a1cab94dac5ee 100644 --- a/drivers/usb/typec/tipd/spmi.c +++ b/drivers/usb/typec/tipd/spmi.c @@ -808,12 +808,15 @@ static int sn201202x_probe(struct spmi_device *device) tps->sleep_event = sn201202x_sleep_event; /* * Idle sleep needs only the event interrupt to stay live while the - * controller sleeps, as it does on T8132 and on T6041 (M4 Max). A - * register access then wakes it through runtime PM, select notification - * or not. T6041 keeps its own system sleep path (a wake IRQ). + * controller sleeps. T8132's select-polled controllers have that, as + * the system sleep filter above relies on; elsewhere the DT says so + * (apple,event-irq-in-sleep). A register access then wakes the + * controller through runtime PM, select notification or not. Those + * controllers keep their own system sleep path (a wake IRQ). */ sn->idle_sleep = !sn->polled && - (sn->select_polled || of_machine_is_compatible("apple,t6041")); + (sn->select_polled || + device_property_read_bool(&device->dev, "apple,event-irq-in-sleep")); spmi_device_set_drvdata(device, tps); tps->regmap = devm_regmap_init_sn201202x(device, &tps6598x_regmap_config);