Skip to content

Commit d9a47eb

Browse files
committed
ucsi wakelock
Signed-off-by: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
1 parent ee32a8c commit d9a47eb

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/usb/typec/ucsi/ucsi_glink.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@
77
#include <linux/module.h>
88
#include <linux/mutex.h>
99
#include <linux/of_device.h>
10+
#include <linux/pm_wakeup.h>
1011
#include <linux/property.h>
1112
#include <linux/soc/qcom/pdr.h>
1213
#include <linux/usb/typec_mux.h>
1314
#include <linux/gpio/consumer.h>
1415
#include <linux/soc/qcom/pmic_glink.h>
1516
#include "ucsi.h"
1617

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+
1727
#define PMIC_GLINK_MAX_PORTS 3
1828

1929
#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)
342352
pmic_glink_ucsi_write_ack(ucsi, data, len);
343353
break;
344354
case UC_UCSI_USBC_NOTIFY_IND:
355+
pm_wakeup_event(ucsi->dev, UCSI_GLINK_WAKEUP_TIMEOUT_MS);
345356
schedule_work(&ucsi->notify_work);
346357
break;
347358
}
@@ -401,6 +412,8 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev,
401412
ucsi->dev = dev;
402413
dev_set_drvdata(dev, ucsi);
403414

415+
device_init_wakeup(dev, true);
416+
404417
INIT_WORK(&ucsi->notify_work, pmic_glink_ucsi_notify);
405418
INIT_WORK(&ucsi->register_work, pmic_glink_ucsi_register);
406419
init_completion(&ucsi->read_ack);

0 commit comments

Comments
 (0)