From 3191b7934459de72c70d4bdfebe35368cbde1436 Mon Sep 17 00:00:00 2001 From: William Wu Date: Fri, 7 Jun 2024 09:13:13 +0800 Subject: [PATCH] usb: typec: tcpci_husb311: Support to enable wakeup irq via dts The husb311 driver disable irq wakeup if vbus is on (e.g connect with an U Disk), it aimed to avoid wakeup system from deep sleep immediately by husb311 irq if the vbus was powered off during deep sleep. However, some platforms can keep vbus on during deep sleep, and it may want to support the husb311 irq to wakeup system from deep sleep, so this patch adds an option property "wakeup-source" for this scenario. Fixes: a6a4762e0c46 ("usb: typec: tcpci_husb311: Refactor irq wakeup") Signed-off-by: William Wu Change-Id: I3a862b3b3e99fe12c4dbb87e09a0910b4602b92a --- drivers/usb/typec/tcpm/tcpci_husb311.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci_husb311.c b/drivers/usb/typec/tcpm/tcpci_husb311.c index 574588e419f5..74f45f581ca6 100644 --- a/drivers/usb/typec/tcpm/tcpci_husb311.c +++ b/drivers/usb/typec/tcpm/tcpci_husb311.c @@ -36,6 +36,7 @@ struct husb311_chip { bool vbus_on; bool charge_on; bool suspended; + bool wakeup; }; static int husb311_read8(struct husb311_chip *chip, unsigned int reg, u8 *val) @@ -295,6 +296,7 @@ static int husb311_probe(struct i2c_client *client, return ret; } + chip->wakeup = device_property_read_bool(chip->dev, "wakeup-source"); device_init_wakeup(chip->dev, true); return 0; @@ -324,7 +326,7 @@ static int husb311_pm_suspend(struct device *dev) struct husb311_chip *chip = dev->driver_data; struct i2c_client *client = to_i2c_client(dev); - if (device_may_wakeup(dev) && !chip->vbus_on) + if (device_may_wakeup(dev) && (!chip->vbus_on || chip->wakeup)) enable_irq_wake(client->irq); else disable_irq(client->irq); @@ -344,7 +346,7 @@ static int husb311_pm_resume(struct device *dev) int ret = 0; u8 filter; - if (device_may_wakeup(dev) && !chip->vbus_on) + if (device_may_wakeup(dev) && (!chip->vbus_on || chip->wakeup)) disable_irq_wake(client->irq); else enable_irq(client->irq);