Devicetree
 help / color / mirror / Atom feed
From: "Markus Schneider-Pargmann" <msp@baylibre.com>
To: "Kendall Willis" <k-willis@ti.com>,
	"Markus Schneider-Pargmann" <msp@baylibre.com>,
	"Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Vincent Mailhol" <mailhol@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Chandrasekar Ramakrishnan" <rcsekar@samsung.com>
Cc: <s-kochidanadu@ti.com>, <a-kaur@ti.com>, <s-tripathi1@ti.com>,
	<vishalm@ti.com>, <linux-can@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] can: m_can: add ti,am62-m_can compatible with out-of-band wakeup support
Date: Thu, 03 Sep 2026 10:55:27 +0200	[thread overview]
Message-ID: <DL5K0CZS9PDB.1HD8YBEQOUABU@baylibre.com> (raw)
In-Reply-To: <20260902-temp-v4-2-3896f7d16ce8@ti.com>

[-- Attachment #1: Type: text/plain, Size: 3745 bytes --]

On Wed Sep 2, 2026 at 11:03 PM CEST, Kendall Willis wrote:
> In TI AM62X, AM62A, and AM62P SoCs, the M_CAN controller is a part of
> the MCU power domain which is OFF in the deepest low power states.
> However, the m_can pins are able to wakeup the system from states where
> the MCU domain is OFF through its out-of-band wakeup functionality.

There are m_can devices in the main domain as well. Does this apply to
these as well?

>
> Introduce the ti,am62-m_can compatible with match data to identify the
> out-of-band wakeup capability for TI AM62 SoCs. During suspend, set the
> out-of-band wakeup flag when the device is configured as a wakeup
> source, the "wakeup" pinctrl state is present, and the match data
> indicates out-of-band wakeup support.
>
> Signed-off-by: Kendall Willis <k-willis@ti.com>
> ---
>  drivers/net/can/m_can/m_can.c          | 7 ++++++-
>  drivers/net/can/m_can/m_can.h          | 4 ++++
>  drivers/net/can/m_can/m_can_platform.c | 5 +++++
>  3 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 16f80607e150e2ca2950616ff2c39b7aa13710b4..0788816d881ef8ba84ad5a84a6d2d3e60517ea7a 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -2598,6 +2598,7 @@ int m_can_class_suspend(struct device *dev)
>  {
>  	struct m_can_classdev *cdev = dev_get_drvdata(dev);
>  	struct net_device *ndev = cdev->net;
> +	const struct m_can_pdata *pdata = of_device_get_match_data(dev);

The core m_can driver works for all m_can forms, tcan, platform and pci.
I think it would be cleaner if you parse this in the platform driver and
set it in m_can_classdev instead. Otherwise of_match_data has to be the
same for all drivers which is not obvious when you are editing tcan for
example.

>  	int ret = 0;
>  
>  	if (netif_running(ndev)) {
> @@ -2622,8 +2623,12 @@ int m_can_class_suspend(struct device *dev)
>  		cdev->can.state = CAN_STATE_SLEEPING;
>  	}
>  
> -	if (!m_can_class_wakeup_pinctrl_enabled(cdev))
> +	if (m_can_class_wakeup_pinctrl_enabled(cdev)) {
> +		if (pdata && pdata->out_band_wakeup)
> +			device_set_out_band_wakeup(dev);
> +	} else {
>  		pinctrl_pm_select_sleep_state(dev);
> +	}

I just noticed these are called even if ret is not 0, so suspend failed.
This shouldn't happen, but not a problem of your patch. But you could
add a fix for that.

>  
>  	return ret;
>  }
> diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
> index 4743342b2fba3823819b9e2bc5b085cc0fe6d1e2..486d808bc677482acf446b1450c3a9b6b7405178 100644
> --- a/drivers/net/can/m_can/m_can.h
> +++ b/drivers/net/can/m_can/m_can.h
> @@ -134,6 +134,10 @@ struct m_can_classdev {
>  	struct pinctrl_state *pinctrl_state_wakeup;
>  };
>  
> +struct m_can_pdata {
> +	bool out_band_wakeup;
> +};
> +
>  struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, int sizeof_priv);
>  void m_can_class_free_dev(struct net_device *net);
>  int m_can_class_register(struct m_can_classdev *cdev);
> diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
> index 56da411878af0185ff9cc512e325137428a68255..ae2d89b65fe8da65b1ca73cbf80cd8ee8483e2e8 100644
> --- a/drivers/net/can/m_can/m_can_platform.c
> +++ b/drivers/net/can/m_can/m_can_platform.c
> @@ -218,8 +218,13 @@ static const struct dev_pm_ops m_can_pmops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(m_can_suspend, m_can_resume)
>  };
>  
> +static const struct m_can_pdata m_can_plat_am62 = {

I don't like the pdata name here, this suggests to be platform data, but
this is of match data instead. Maybe of_data?

Best
Markus

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 289 bytes --]

  reply	other threads:[~2026-09-03  8:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 21:03 [PATCH v4 0/2] can: m_can: introduce ti,am62-m_can compatible for out-of-band wakeup Kendall Willis
2026-09-02 21:03 ` [PATCH v4 1/2] dt-bindings: can: m_can: add ti,am62-m_can compatible Kendall Willis
2026-09-03  8:28   ` Markus Schneider-Pargmann
2026-09-03 19:04     ` Kendall Willis
2026-09-03 13:45   ` Krzysztof Kozlowski
2026-09-03 20:00     ` Kendall Willis
2026-09-02 21:03 ` [PATCH v4 2/2] can: m_can: add ti,am62-m_can compatible with out-of-band wakeup support Kendall Willis
2026-09-03  8:55   ` Markus Schneider-Pargmann [this message]
2026-09-03 19:22     ` Kendall Willis
2026-09-03 13:46   ` Krzysztof Kozlowski
2026-09-03 21:47     ` Kendall Willis

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=DL5K0CZS9PDB.1HD8YBEQOUABU@baylibre.com \
    --to=msp@baylibre.com \
    --cc=a-kaur@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=k-willis@ti.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=rcsekar@samsung.com \
    --cc=robh@kernel.org \
    --cc=s-kochidanadu@ti.com \
    --cc=s-tripathi1@ti.com \
    --cc=vishalm@ti.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