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

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: tcpci: add wakeup support

Add wakeup support for tcpci. If the user enables the wakeup file, call
enable_irq_wake() during system suspend and disable_irq_wake() during
system resume. Since this driver supports shared interrupts, mask the
chip interrupt by default when wakeup is disabled to avoid affecting
other IRQ users.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Badhri Jagan Sridharan <badhri@google.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20250910105042.695146-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xu Yang and committed by
Greg Kroah-Hartman
a5d2edb2 6f9871b3

+33
+33
drivers/usb/typec/tcpm/tcpci.c
··· 949 949 if (err < 0) 950 950 goto unregister_port; 951 951 952 + device_set_wakeup_capable(chip->tcpci->dev, true); 953 + 952 954 return 0; 953 955 954 956 unregister_port: ··· 971 969 tcpci_unregister_port(chip->tcpci); 972 970 } 973 971 972 + static int tcpci_suspend(struct device *dev) 973 + { 974 + struct i2c_client *i2c = to_i2c_client(dev); 975 + struct tcpci_chip *chip = i2c_get_clientdata(i2c); 976 + int ret; 977 + 978 + if (device_may_wakeup(dev)) 979 + ret = enable_irq_wake(i2c->irq); 980 + else 981 + ret = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, 0); 982 + 983 + return ret; 984 + } 985 + 986 + static int tcpci_resume(struct device *dev) 987 + { 988 + struct i2c_client *i2c = to_i2c_client(dev); 989 + struct tcpci_chip *chip = i2c_get_clientdata(i2c); 990 + int ret; 991 + 992 + if (device_may_wakeup(dev)) 993 + ret = disable_irq_wake(i2c->irq); 994 + else 995 + ret = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, chip->tcpci->alert_mask); 996 + 997 + return ret; 998 + } 999 + 1000 + DEFINE_SIMPLE_DEV_PM_OPS(tcpci_pm_ops, tcpci_suspend, tcpci_resume); 1001 + 974 1002 static const struct i2c_device_id tcpci_id[] = { 975 1003 { "tcpci" }, 976 1004 { } ··· 1019 987 static struct i2c_driver tcpci_i2c_driver = { 1020 988 .driver = { 1021 989 .name = "tcpci", 990 + .pm = pm_sleep_ptr(&tcpci_pm_ops), 1022 991 .of_match_table = of_match_ptr(tcpci_of_match), 1023 992 }, 1024 993 .probe = tcpci_probe,