Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Documentation/devicetree/bindings/usb/apple,sn201202x.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions arch/arm64/boot/dts/apple/t6041-j575c.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 {
Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/typec/tipd/sn201202x-pm-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 15 additions & 4 deletions drivers/usb/typec/tipd/spmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/typec/tipd/tps6598x.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading