Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: badhri@google.com, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org, imx@lists.linux.dev, jun.li@nxp.com
Subject: Re: [PATCH v2] usb: typec: tcpci: add wakeup support
Date: Mon, 15 Sep 2025 15:22:51 +0300	[thread overview]
Message-ID: <aMgFG9WRBqOe5POT@kuha.fi.intel.com> (raw)
In-Reply-To: <20250910105042.695146-1-xu.yang_2@nxp.com>

On Wed, Sep 10, 2025 at 06:50:42PM +0800, Xu Yang wrote:
> 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>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> Changes in v2:
>  - improve commit message
>  - add Rb tag
> ---
>  drivers/usb/typec/tcpm/tcpci.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index a56e31b20c21..2a951c585e92 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -949,6 +949,8 @@ static int tcpci_probe(struct i2c_client *client)
>  	if (err < 0)
>  		goto unregister_port;
>  
> +	device_set_wakeup_capable(chip->tcpci->dev, true);
> +
>  	return 0;
>  
>  unregister_port:
> @@ -969,6 +971,36 @@ static void tcpci_remove(struct i2c_client *client)
>  	tcpci_unregister_port(chip->tcpci);
>  }
>  
> +static int tcpci_suspend(struct device *dev)
> +{
> +	struct i2c_client *i2c = to_i2c_client(dev);
> +	struct tcpci_chip *chip = i2c_get_clientdata(i2c);
> +	int ret;
> +
> +	if (device_may_wakeup(dev))
> +		ret = enable_irq_wake(i2c->irq);
> +	else
> +		ret = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, 0);
> +
> +	return ret;
> +}
> +
> +static int tcpci_resume(struct device *dev)
> +{
> +	struct i2c_client *i2c = to_i2c_client(dev);
> +	struct tcpci_chip *chip = i2c_get_clientdata(i2c);
> +	int ret;
> +
> +	if (device_may_wakeup(dev))
> +		ret = disable_irq_wake(i2c->irq);
> +	else
> +		ret = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, chip->tcpci->alert_mask);
> +
> +	return ret;
> +}
> +
> +DEFINE_SIMPLE_DEV_PM_OPS(tcpci_pm_ops, tcpci_suspend, tcpci_resume);
> +
>  static const struct i2c_device_id tcpci_id[] = {
>  	{ "tcpci" },
>  	{ }
> @@ -987,6 +1019,7 @@ MODULE_DEVICE_TABLE(of, tcpci_of_match);
>  static struct i2c_driver tcpci_i2c_driver = {
>  	.driver = {
>  		.name = "tcpci",
> +		.pm = pm_sleep_ptr(&tcpci_pm_ops),
>  		.of_match_table = of_match_ptr(tcpci_of_match),
>  	},
>  	.probe = tcpci_probe,
> -- 
> 2.34.1

-- 
heikki

      reply	other threads:[~2025-09-15 12:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10 10:50 [PATCH v2] usb: typec: tcpci: add wakeup support Xu Yang
2025-09-15 12:22 ` Heikki Krogerus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aMgFG9WRBqOe5POT@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=xu.yang_2@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox