* [PATCH 0/3] usb: typec: tcpm/tcpci_maxim: irq wake and other updates @ 2025-07-07 10:50 André Draszik 2025-07-07 10:50 ` [PATCH 1/3] usb: typec: tcpm/tcpci_maxim: fix irq wake usage André Draszik ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: André Draszik @ 2025-07-07 10:50 UTC (permalink / raw) To: Heikki Krogerus, Greg Kroah-Hartman Cc: Badhri Jagan Sridharan, Amit Sunil Dhamne, Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team, linux-usb, linux-kernel, André Draszik These patches fix a few small issues with the Maxim TCPCi driver. Most importantly, the driver never calls disable_irq_wake(), and while looking into that, I noticed a few other possible cleanups. Please see the individual patches, they're self-explanatory, I believe. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- André Draszik (3): usb: typec: tcpm/tcpci_maxim: fix irq wake usage usb: typec: tcpm/tcpci_maxim: drop CONFIG_OF usb: typec: tcpm/tcpci_maxim: enable PROBE_PREFER_ASYNCHRONOUS drivers/usb/typec/tcpm/tcpci_maxim_core.c | 51 +++++++++++++++++++------------ 1 file changed, 32 insertions(+), 19 deletions(-) --- base-commit: 50c8770a42faf8b1c7abe93e7c114337f580a97d change-id: 20250707-max77759-irq-wake-1ffda8371c5f Best regards, -- André Draszik <andre.draszik@linaro.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] usb: typec: tcpm/tcpci_maxim: fix irq wake usage 2025-07-07 10:50 [PATCH 0/3] usb: typec: tcpm/tcpci_maxim: irq wake and other updates André Draszik @ 2025-07-07 10:50 ` André Draszik 2025-07-09 22:51 ` Badhri Jagan Sridharan 2025-07-07 10:50 ` [PATCH 2/3] usb: typec: tcpm/tcpci_maxim: drop CONFIG_OF André Draszik 2025-07-07 10:50 ` [PATCH 3/3] usb: typec: tcpm/tcpci_maxim: enable PROBE_PREFER_ASYNCHRONOUS André Draszik 2 siblings, 1 reply; 7+ messages in thread From: André Draszik @ 2025-07-07 10:50 UTC (permalink / raw) To: Heikki Krogerus, Greg Kroah-Hartman Cc: Badhri Jagan Sridharan, Amit Sunil Dhamne, Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team, linux-usb, linux-kernel, André Draszik This driver calls enable_irq_wake() during probe() unconditionally, and never issues the required corresponding disable_irq_wake() to disable hardware interrupt wakeup signals. Additionally, whether or not a device should wake-up the system is meant to be a policy decision based on sysfs (.../power/wakeup) in the first place. Update the driver to use the standard approach to enable/disable IRQ wake during the suspend/resume callbacks. This solves both issues described above. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- drivers/usb/typec/tcpm/tcpci_maxim_core.c | 46 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c index b5a5ed40faea9cfcceef5550263968148646eb44..ff3604be79da73ca5acff7b5b2434c116ed12ef8 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c @@ -421,21 +421,6 @@ static irqreturn_t max_tcpci_isr(int irq, void *dev_id) return IRQ_WAKE_THREAD; } -static int max_tcpci_init_alert(struct max_tcpci_chip *chip, struct i2c_client *client) -{ - int ret; - - ret = devm_request_threaded_irq(chip->dev, client->irq, max_tcpci_isr, max_tcpci_irq, - (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), - chip); - - if (ret < 0) - return ret; - - enable_irq_wake(client->irq); - return 0; -} - static int max_tcpci_start_toggling(struct tcpci *tcpci, struct tcpci_data *tdata, enum typec_cc_status cc) { @@ -532,7 +517,9 @@ static int max_tcpci_probe(struct i2c_client *client) chip->port = tcpci_get_tcpm_port(chip->tcpci); - ret = max_tcpci_init_alert(chip, client); + ret = devm_request_threaded_irq(&client->dev, client->irq, max_tcpci_isr, max_tcpci_irq, + (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), + chip); if (ret < 0) return dev_err_probe(&client->dev, ret, "IRQ initialization failed\n"); @@ -544,6 +531,32 @@ static int max_tcpci_probe(struct i2c_client *client) return 0; } +#ifdef CONFIG_PM_SLEEP +static int max_tcpci_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + int ret = 0; + + if (client->irq && device_may_wakeup(dev)) + ret = disable_irq_wake(client->irq); + + return ret; +} + +static int max_tcpci_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + int ret = 0; + + if (client->irq && device_may_wakeup(dev)) + ret = enable_irq_wake(client->irq); + + return ret; +} +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(max_tcpci_pm_ops, max_tcpci_suspend, max_tcpci_resume); + static const struct i2c_device_id max_tcpci_id[] = { { "maxtcpc" }, { } @@ -562,6 +575,7 @@ static struct i2c_driver max_tcpci_i2c_driver = { .driver = { .name = "maxtcpc", .of_match_table = of_match_ptr(max_tcpci_of_match), + .pm = &max_tcpci_pm_ops, }, .probe = max_tcpci_probe, .id_table = max_tcpci_id, -- 2.50.0.727.gbf7dc18ff4-goog ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] usb: typec: tcpm/tcpci_maxim: fix irq wake usage 2025-07-07 10:50 ` [PATCH 1/3] usb: typec: tcpm/tcpci_maxim: fix irq wake usage André Draszik @ 2025-07-09 22:51 ` Badhri Jagan Sridharan 0 siblings, 0 replies; 7+ messages in thread From: Badhri Jagan Sridharan @ 2025-07-09 22:51 UTC (permalink / raw) To: André Draszik Cc: Heikki Krogerus, Greg Kroah-Hartman, Amit Sunil Dhamne, Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team, linux-usb, linux-kernel On Mon, Jul 7, 2025 at 3:50 AM André Draszik <andre.draszik@linaro.org> wrote: > > This driver calls enable_irq_wake() during probe() unconditionally, and > never issues the required corresponding disable_irq_wake() to disable > hardware interrupt wakeup signals. > > Additionally, whether or not a device should wake-up the system is > meant to be a policy decision based on sysfs (.../power/wakeup) in the > first place. > > Update the driver to use the standard approach to enable/disable IRQ > wake during the suspend/resume callbacks. This solves both issues > described above. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com> > --- > drivers/usb/typec/tcpm/tcpci_maxim_core.c | 46 ++++++++++++++++++++----------- > 1 file changed, 30 insertions(+), 16 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > index b5a5ed40faea9cfcceef5550263968148646eb44..ff3604be79da73ca5acff7b5b2434c116ed12ef8 100644 > --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c > +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > @@ -421,21 +421,6 @@ static irqreturn_t max_tcpci_isr(int irq, void *dev_id) > return IRQ_WAKE_THREAD; > } > > -static int max_tcpci_init_alert(struct max_tcpci_chip *chip, struct i2c_client *client) > -{ > - int ret; > - > - ret = devm_request_threaded_irq(chip->dev, client->irq, max_tcpci_isr, max_tcpci_irq, > - (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), > - chip); > - > - if (ret < 0) > - return ret; > - > - enable_irq_wake(client->irq); > - return 0; > -} > - > static int max_tcpci_start_toggling(struct tcpci *tcpci, struct tcpci_data *tdata, > enum typec_cc_status cc) > { > @@ -532,7 +517,9 @@ static int max_tcpci_probe(struct i2c_client *client) > > chip->port = tcpci_get_tcpm_port(chip->tcpci); > > - ret = max_tcpci_init_alert(chip, client); > + ret = devm_request_threaded_irq(&client->dev, client->irq, max_tcpci_isr, max_tcpci_irq, > + (IRQF_TRIGGER_LOW | IRQF_ONESHOT), dev_name(chip->dev), > + chip); > if (ret < 0) > return dev_err_probe(&client->dev, ret, > "IRQ initialization failed\n"); > @@ -544,6 +531,32 @@ static int max_tcpci_probe(struct i2c_client *client) > return 0; > } > > +#ifdef CONFIG_PM_SLEEP > +static int max_tcpci_resume(struct device *dev) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + int ret = 0; > + > + if (client->irq && device_may_wakeup(dev)) > + ret = disable_irq_wake(client->irq); > + > + return ret; > +} > + > +static int max_tcpci_suspend(struct device *dev) > +{ > + struct i2c_client *client = to_i2c_client(dev); > + int ret = 0; > + > + if (client->irq && device_may_wakeup(dev)) > + ret = enable_irq_wake(client->irq); > + > + return ret; > +} > +#endif /* CONFIG_PM_SLEEP */ > + > +static SIMPLE_DEV_PM_OPS(max_tcpci_pm_ops, max_tcpci_suspend, max_tcpci_resume); > + > static const struct i2c_device_id max_tcpci_id[] = { > { "maxtcpc" }, > { } > @@ -562,6 +575,7 @@ static struct i2c_driver max_tcpci_i2c_driver = { > .driver = { > .name = "maxtcpc", > .of_match_table = of_match_ptr(max_tcpci_of_match), > + .pm = &max_tcpci_pm_ops, > }, > .probe = max_tcpci_probe, > .id_table = max_tcpci_id, > > -- > 2.50.0.727.gbf7dc18ff4-goog > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] usb: typec: tcpm/tcpci_maxim: drop CONFIG_OF 2025-07-07 10:50 [PATCH 0/3] usb: typec: tcpm/tcpci_maxim: irq wake and other updates André Draszik 2025-07-07 10:50 ` [PATCH 1/3] usb: typec: tcpm/tcpci_maxim: fix irq wake usage André Draszik @ 2025-07-07 10:50 ` André Draszik 2025-07-09 23:06 ` Badhri Jagan Sridharan 2025-07-07 10:50 ` [PATCH 3/3] usb: typec: tcpm/tcpci_maxim: enable PROBE_PREFER_ASYNCHRONOUS André Draszik 2 siblings, 1 reply; 7+ messages in thread From: André Draszik @ 2025-07-07 10:50 UTC (permalink / raw) To: Heikki Krogerus, Greg Kroah-Hartman Cc: Badhri Jagan Sridharan, Amit Sunil Dhamne, Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team, linux-usb, linux-kernel, André Draszik The general recommendation is to not use of_match_ptr() or CONFIG_OF ifdef. Drop them. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- drivers/usb/typec/tcpm/tcpci_maxim_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c index ff3604be79da73ca5acff7b5b2434c116ed12ef8..43b0ec2d12ba6d4c1cfccbfd355af3e5d9ce1385 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c @@ -563,18 +563,16 @@ static const struct i2c_device_id max_tcpci_id[] = { }; MODULE_DEVICE_TABLE(i2c, max_tcpci_id); -#ifdef CONFIG_OF static const struct of_device_id max_tcpci_of_match[] = { { .compatible = "maxim,max33359", }, {}, }; MODULE_DEVICE_TABLE(of, max_tcpci_of_match); -#endif static struct i2c_driver max_tcpci_i2c_driver = { .driver = { .name = "maxtcpc", - .of_match_table = of_match_ptr(max_tcpci_of_match), + .of_match_table = max_tcpci_of_match, .pm = &max_tcpci_pm_ops, }, .probe = max_tcpci_probe, -- 2.50.0.727.gbf7dc18ff4-goog ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] usb: typec: tcpm/tcpci_maxim: drop CONFIG_OF 2025-07-07 10:50 ` [PATCH 2/3] usb: typec: tcpm/tcpci_maxim: drop CONFIG_OF André Draszik @ 2025-07-09 23:06 ` Badhri Jagan Sridharan 0 siblings, 0 replies; 7+ messages in thread From: Badhri Jagan Sridharan @ 2025-07-09 23:06 UTC (permalink / raw) To: André Draszik Cc: Heikki Krogerus, Greg Kroah-Hartman, Amit Sunil Dhamne, Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team, linux-usb, linux-kernel On Mon, Jul 7, 2025 at 3:50 AM André Draszik <andre.draszik@linaro.org> wrote: > > The general recommendation is to not use of_match_ptr() or CONFIG_OF > ifdef. > > Drop them. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com> > --- > drivers/usb/typec/tcpm/tcpci_maxim_core.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > index ff3604be79da73ca5acff7b5b2434c116ed12ef8..43b0ec2d12ba6d4c1cfccbfd355af3e5d9ce1385 100644 > --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c > +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > @@ -563,18 +563,16 @@ static const struct i2c_device_id max_tcpci_id[] = { > }; > MODULE_DEVICE_TABLE(i2c, max_tcpci_id); > > -#ifdef CONFIG_OF > static const struct of_device_id max_tcpci_of_match[] = { > { .compatible = "maxim,max33359", }, > {}, > }; > MODULE_DEVICE_TABLE(of, max_tcpci_of_match); > -#endif > > static struct i2c_driver max_tcpci_i2c_driver = { > .driver = { > .name = "maxtcpc", > - .of_match_table = of_match_ptr(max_tcpci_of_match), > + .of_match_table = max_tcpci_of_match, > .pm = &max_tcpci_pm_ops, > }, > .probe = max_tcpci_probe, > > -- > 2.50.0.727.gbf7dc18ff4-goog > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] usb: typec: tcpm/tcpci_maxim: enable PROBE_PREFER_ASYNCHRONOUS 2025-07-07 10:50 [PATCH 0/3] usb: typec: tcpm/tcpci_maxim: irq wake and other updates André Draszik 2025-07-07 10:50 ` [PATCH 1/3] usb: typec: tcpm/tcpci_maxim: fix irq wake usage André Draszik 2025-07-07 10:50 ` [PATCH 2/3] usb: typec: tcpm/tcpci_maxim: drop CONFIG_OF André Draszik @ 2025-07-07 10:50 ` André Draszik 2025-07-09 23:14 ` Badhri Jagan Sridharan 2 siblings, 1 reply; 7+ messages in thread From: André Draszik @ 2025-07-07 10:50 UTC (permalink / raw) To: Heikki Krogerus, Greg Kroah-Hartman Cc: Badhri Jagan Sridharan, Amit Sunil Dhamne, Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team, linux-usb, linux-kernel, André Draszik This driver works fine with asynchronous probe. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- drivers/usb/typec/tcpm/tcpci_maxim_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c index 43b0ec2d12ba6d4c1cfccbfd355af3e5d9ce1385..19f63865079658fb2a446dc390262d141b940e9a 100644 --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c @@ -572,6 +572,7 @@ MODULE_DEVICE_TABLE(of, max_tcpci_of_match); static struct i2c_driver max_tcpci_i2c_driver = { .driver = { .name = "maxtcpc", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, .of_match_table = max_tcpci_of_match, .pm = &max_tcpci_pm_ops, }, -- 2.50.0.727.gbf7dc18ff4-goog ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] usb: typec: tcpm/tcpci_maxim: enable PROBE_PREFER_ASYNCHRONOUS 2025-07-07 10:50 ` [PATCH 3/3] usb: typec: tcpm/tcpci_maxim: enable PROBE_PREFER_ASYNCHRONOUS André Draszik @ 2025-07-09 23:14 ` Badhri Jagan Sridharan 0 siblings, 0 replies; 7+ messages in thread From: Badhri Jagan Sridharan @ 2025-07-09 23:14 UTC (permalink / raw) To: André Draszik Cc: Heikki Krogerus, Greg Kroah-Hartman, Amit Sunil Dhamne, Peter Griffin, Tudor Ambarus, Will McVicker, kernel-team, linux-usb, linux-kernel On Mon, Jul 7, 2025 at 3:50 AM André Draszik <andre.draszik@linaro.org> wrote: > > This driver works fine with asynchronous probe. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> Reviewed-by: Badhri Jagan Sridharan <badhri@google.com> > --- > drivers/usb/typec/tcpm/tcpci_maxim_core.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim_core.c b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > index 43b0ec2d12ba6d4c1cfccbfd355af3e5d9ce1385..19f63865079658fb2a446dc390262d141b940e9a 100644 > --- a/drivers/usb/typec/tcpm/tcpci_maxim_core.c > +++ b/drivers/usb/typec/tcpm/tcpci_maxim_core.c > @@ -572,6 +572,7 @@ MODULE_DEVICE_TABLE(of, max_tcpci_of_match); > static struct i2c_driver max_tcpci_i2c_driver = { > .driver = { > .name = "maxtcpc", > + .probe_type = PROBE_PREFER_ASYNCHRONOUS, > .of_match_table = max_tcpci_of_match, > .pm = &max_tcpci_pm_ops, > }, > > -- > 2.50.0.727.gbf7dc18ff4-goog > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-09 23:15 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-07-07 10:50 [PATCH 0/3] usb: typec: tcpm/tcpci_maxim: irq wake and other updates André Draszik 2025-07-07 10:50 ` [PATCH 1/3] usb: typec: tcpm/tcpci_maxim: fix irq wake usage André Draszik 2025-07-09 22:51 ` Badhri Jagan Sridharan 2025-07-07 10:50 ` [PATCH 2/3] usb: typec: tcpm/tcpci_maxim: drop CONFIG_OF André Draszik 2025-07-09 23:06 ` Badhri Jagan Sridharan 2025-07-07 10:50 ` [PATCH 3/3] usb: typec: tcpm/tcpci_maxim: enable PROBE_PREFER_ASYNCHRONOUS André Draszik 2025-07-09 23:14 ` Badhri Jagan Sridharan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).