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

USB: gpio_vbus: wakeup support on GPIO VBUS interrupts

We'd like to see the system waking up from the system-wide suspend
when it gets plugged-in, or the USB cable is pulled out.

Also makes it configurable via platform data 'wakeup'.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Shinya Kuribayashi and committed by
Greg Kroah-Hartman
7cbb062a ec1ac6e1

+35
+33
drivers/usb/otg/gpio_vbus.c
··· 327 327 goto err_otg; 328 328 } 329 329 330 + device_init_wakeup(&pdev->dev, pdata->wakeup); 331 + 330 332 return 0; 331 333 err_otg: 332 334 regulator_put(gpio_vbus->vbus_draw); ··· 350 348 struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data; 351 349 int gpio = pdata->gpio_vbus; 352 350 351 + device_init_wakeup(&pdev->dev, 0); 353 352 cancel_delayed_work_sync(&gpio_vbus->work); 354 353 regulator_put(gpio_vbus->vbus_draw); 355 354 ··· 367 364 return 0; 368 365 } 369 366 367 + #ifdef CONFIG_PM 368 + static int gpio_vbus_pm_suspend(struct device *dev) 369 + { 370 + struct gpio_vbus_data *gpio_vbus = dev_get_drvdata(dev); 371 + 372 + if (device_may_wakeup(dev)) 373 + enable_irq_wake(gpio_vbus->irq); 374 + 375 + return 0; 376 + } 377 + 378 + static int gpio_vbus_pm_resume(struct device *dev) 379 + { 380 + struct gpio_vbus_data *gpio_vbus = dev_get_drvdata(dev); 381 + 382 + if (device_may_wakeup(dev)) 383 + disable_irq_wake(gpio_vbus->irq); 384 + 385 + return 0; 386 + } 387 + 388 + static const struct dev_pm_ops gpio_vbus_dev_pm_ops = { 389 + .suspend = gpio_vbus_pm_suspend, 390 + .resume = gpio_vbus_pm_resume, 391 + }; 392 + #endif 393 + 370 394 /* NOTE: the gpio-vbus device may *NOT* be hotplugged */ 371 395 372 396 MODULE_ALIAS("platform:gpio-vbus"); ··· 402 372 .driver = { 403 373 .name = "gpio-vbus", 404 374 .owner = THIS_MODULE, 375 + #ifdef CONFIG_PM 376 + .pm = &gpio_vbus_dev_pm_ops, 377 + #endif 405 378 }, 406 379 .remove = __exit_p(gpio_vbus_remove), 407 380 };
+2
include/linux/usb/gpio_vbus.h
··· 17 17 * @gpio_pullup: optional D+ or D- pullup GPIO (else negative/invalid) 18 18 * @gpio_vbus_inverted: true if gpio_vbus is active low 19 19 * @gpio_pullup_inverted: true if gpio_pullup is active low 20 + * @wakeup: configure gpio_vbus as a wake-up source 20 21 * 21 22 * The VBUS sensing GPIO should have a pulldown, which will normally be 22 23 * part of a resistor ladder turning a 4.0V-5.25V level on VBUS into a ··· 28 27 int gpio_pullup; 29 28 bool gpio_vbus_inverted; 30 29 bool gpio_pullup_inverted; 30 + bool wakeup; 31 31 };