Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: common: usb-conn-gpio: Allow wakeup from system suspend

Currently the VBUS/ID detection interrupts are disabled during system
suspend. So the USB cable connect/disconnect event can't wakeup the
system from low power mode. To allow this, we keep these interrupts
enabled and configure them as wakeup capable. This behavior can be
controlled through device wakeup source policy by the user space.

Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
Link: https://lore.kernel.org/r/1653634146-12215-1-git-send-email-quic_prashk@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Prashanth K and committed by
Greg Kroah-Hartman
7afe69ad 62e4efe3

+17
+17
drivers/usb/common/usb-conn-gpio.c
··· 257 257 } 258 258 259 259 platform_set_drvdata(pdev, info); 260 + device_set_wakeup_capable(&pdev->dev, true); 260 261 261 262 /* Perform initial detection */ 262 263 usb_conn_queue_dwork(info, 0); ··· 287 286 { 288 287 struct usb_conn_info *info = dev_get_drvdata(dev); 289 288 289 + if (device_may_wakeup(dev)) { 290 + if (info->id_gpiod) 291 + enable_irq_wake(info->id_irq); 292 + if (info->vbus_gpiod) 293 + enable_irq_wake(info->vbus_irq); 294 + return 0; 295 + } 296 + 290 297 if (info->id_gpiod) 291 298 disable_irq(info->id_irq); 292 299 if (info->vbus_gpiod) ··· 308 299 static int __maybe_unused usb_conn_resume(struct device *dev) 309 300 { 310 301 struct usb_conn_info *info = dev_get_drvdata(dev); 302 + 303 + if (device_may_wakeup(dev)) { 304 + if (info->id_gpiod) 305 + disable_irq_wake(info->id_irq); 306 + if (info->vbus_gpiod) 307 + disable_irq_wake(info->vbus_irq); 308 + return 0; 309 + } 311 310 312 311 pinctrl_pm_select_default_state(dev); 313 312