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

usb: typec: tipd: Support wakeup

Enable wakeup when pluging or unpluging USB cable. It is up to other
components to hold system in active mode, such as display, so that
user can receive the notification.

Signed-off-by: Jun Nie <jun.nie@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Link: https://lore.kernel.org/r/20230105075058.924680-2-jun.nie@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jun Nie and committed by
Greg Kroah-Hartman
481735d6 26fe7450

+38
+38
drivers/usb/typec/tipd/core.c
··· 95 95 struct power_supply_desc psy_desc; 96 96 enum power_supply_usb_type usb_type; 97 97 98 + int wakeup; 98 99 u16 pwr_status; 99 100 }; 100 101 ··· 847 846 i2c_set_clientdata(client, tps); 848 847 fwnode_handle_put(fwnode); 849 848 849 + tps->wakeup = device_property_read_bool(tps->dev, "wakeup-source"); 850 + if (tps->wakeup) { 851 + device_init_wakeup(&client->dev, true); 852 + enable_irq_wake(client->irq); 853 + } 854 + 850 855 return 0; 851 856 852 857 err_disconnect: ··· 877 870 usb_role_switch_put(tps->role_sw); 878 871 } 879 872 873 + static int __maybe_unused tps6598x_suspend(struct device *dev) 874 + { 875 + struct i2c_client *client = to_i2c_client(dev); 876 + struct tps6598x *tps = i2c_get_clientdata(client); 877 + 878 + if (tps->wakeup) { 879 + disable_irq(client->irq); 880 + enable_irq_wake(client->irq); 881 + } 882 + 883 + return 0; 884 + } 885 + 886 + static int __maybe_unused tps6598x_resume(struct device *dev) 887 + { 888 + struct i2c_client *client = to_i2c_client(dev); 889 + struct tps6598x *tps = i2c_get_clientdata(client); 890 + 891 + if (tps->wakeup) { 892 + disable_irq_wake(client->irq); 893 + enable_irq(client->irq); 894 + } 895 + 896 + return 0; 897 + } 898 + 899 + static const struct dev_pm_ops tps6598x_pm_ops = { 900 + SET_SYSTEM_SLEEP_PM_OPS(tps6598x_suspend, tps6598x_resume) 901 + }; 902 + 880 903 static const struct of_device_id tps6598x_of_match[] = { 881 904 { .compatible = "ti,tps6598x", }, 882 905 { .compatible = "apple,cd321x", }, ··· 923 886 static struct i2c_driver tps6598x_i2c_driver = { 924 887 .driver = { 925 888 .name = "tps6598x", 889 + .pm = &tps6598x_pm_ops, 926 890 .of_match_table = tps6598x_of_match, 927 891 }, 928 892 .probe_new = tps6598x_probe,