|
7 | 7 | #include <linux/module.h> |
8 | 8 | #include <linux/mutex.h> |
9 | 9 | #include <linux/of_device.h> |
| 10 | +#include <linux/pm_wakeup.h> |
10 | 11 | #include <linux/property.h> |
11 | 12 | #include <linux/soc/qcom/pdr.h> |
12 | 13 | #include <linux/usb/typec_mux.h> |
13 | 14 | #include <linux/gpio/consumer.h> |
14 | 15 | #include <linux/soc/qcom/pmic_glink.h> |
15 | 16 | #include "ucsi.h" |
16 | 17 |
|
| 18 | +/* |
| 19 | + * Wakeup timeout covering two async hops: |
| 20 | + * 1. pmic_glink_ucsi_notify() work runs ucsi_notify_common() |
| 21 | + * 2. ucsi_handle_connector_change() work runs and notifies USB |
| 22 | + * ucsi_handle_connector_change() involves GLINK round-trips with up to 5s |
| 23 | + * timeouts, so 10s gives sufficient margin for the full chain to complete. |
| 24 | + */ |
| 25 | +#define UCSI_GLINK_WAKEUP_TIMEOUT_MS 200 |
| 26 | + |
17 | 27 | #define PMIC_GLINK_MAX_PORTS 3 |
18 | 28 |
|
19 | 29 | #define UCSI_BUF_V1_SIZE (UCSI_MESSAGE_OUT + (UCSI_MESSAGE_OUT - UCSI_MESSAGE_IN)) |
@@ -342,6 +352,7 @@ static void pmic_glink_ucsi_callback(const void *data, size_t len, void *priv) |
342 | 352 | pmic_glink_ucsi_write_ack(ucsi, data, len); |
343 | 353 | break; |
344 | 354 | case UC_UCSI_USBC_NOTIFY_IND: |
| 355 | + pm_wakeup_event(ucsi->dev, UCSI_GLINK_WAKEUP_TIMEOUT_MS); |
345 | 356 | schedule_work(&ucsi->notify_work); |
346 | 357 | break; |
347 | 358 | } |
@@ -401,6 +412,8 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev, |
401 | 412 | ucsi->dev = dev; |
402 | 413 | dev_set_drvdata(dev, ucsi); |
403 | 414 |
|
| 415 | + device_init_wakeup(dev, true); |
| 416 | + |
404 | 417 | INIT_WORK(&ucsi->notify_work, pmic_glink_ucsi_notify); |
405 | 418 | INIT_WORK(&ucsi->register_work, pmic_glink_ucsi_register); |
406 | 419 | init_completion(&ucsi->read_ack); |
|
0 commit comments