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: 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"; 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 ddd28b8d94e46..a1cab94dac5ee 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); @@ -806,6 +806,17 @@ static int sn201202x_probe(struct spmi_device *device) */ 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. 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 || + 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); 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;