mbox series

[0/7] can: m_can: Add am62 wakeup support

Message ID 20240523075347.1282395-1-msp@baylibre.com
Headers show
Series can: m_can: Add am62 wakeup support | expand

Message

Markus Schneider-Pargmann May 23, 2024, 7:53 a.m. UTC
Hi,

am62, am62a and am62p support Partial-IO, a poweroff SoC state with a
few pin groups being active for wakeup.

To support mcu_mcan0 and mcu_mcan1 wakeup for the mentioned SoCs, the
series introduces a notion of wake-on-lan for m_can. If the user decides
to enable wake-on-lan for a m_can device, the device is set to wakeup
enabled. A 'wakeup' pinctrl state is selected to enable wakeup flags for
the relevant pins. If wake-on-lan is disabled the default pinctrl is
selected.

It is based on v6.9-rc1.

This series is part of a bigger topic to support Partial-IO on am62,
am62a and am62p. Partial-IO is a poweroff state in which some pins are
able to wakeup the SoC. In detail MCU m_can and two serial port pins can
trigger the wakeup.

These two other series are relevant for the support of Partial-IO:

 - firmware: ti_sci: Partial-IO support
 - serial: 8250: omap: Add am62 wakeup support

A test branch is available here that includes all patches required to
test Partial-IO:

https://gitlab.baylibre.com/msp8/linux/-/tree/integration/am62-lp-sk-partialio/v6.9?ref_type=heads

After enabling Wake-on-LAN the system can be powered off and will enter
the Partial-IO state in which it can be woken up by activity on the
specific pins:
    ethtool -s can0 wol p
    ethtool -s can1 wol p
    poweroff

I tested these patches on am62-lp-sk.

Best,
Markus

Markus Schneider-Pargmann (6):
  dt-bindings: can: m_can: Add wakeup-source property
  dt-bindings: can: m_can: Add wakeup pinctrl state
  can: m_can: Map WoL to device_set_wakeup_enable
  can: m_can: Support pinctrl wakeup state
  arm64: dts: ti: k3-am62: Mark mcu_mcan0/1 as wakeup-source
  arm64: dts: ti: k3-am62a-mcu: Mark mcu_mcan0/1 as wakeup-source

Vibhore Vardhan (1):
  arm64: dts: ti: k3-am62p-mcu: Mark mcu_mcan0/1 as wakeup-source

 .../bindings/net/can/bosch,m_can.yaml         | 20 +++++++++
 arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi       |  2 +
 arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi      |  2 +
 arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi      |  2 +
 drivers/net/can/m_can/m_can.c                 | 43 +++++++++++++++++++
 drivers/net/can/m_can/m_can.h                 |  4 ++
 6 files changed, 73 insertions(+)

Comments

Nishanth Menon May 24, 2024, 5:48 a.m. UTC | #1
On 09:53-20240523, Markus Schneider-Pargmann wrote:
> From: Vibhore Vardhan <vibhore@ti.com>
> 
> mcu_mcan0 and mcu_mcan1 can be wakeup sources for the SoC. Mark them
> accordingly in the devicetree. Based on the patch for AM62a.
> 
> Signed-off-by: Vibhore Vardhan <vibhore@ti.com>
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
> ---
>  arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi b/arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi
> index b973b550eb9d..e434b258e90c 100644
> --- a/arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi
> +++ b/arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi
> @@ -162,6 +162,7 @@ mcu_mcan0: can@4e08000 {
>  		interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>,
>  			     <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>;
>  		interrupt-names = "int0", "int1";
> +		wakeup-source;
>  		status = "disabled";
>  	};
>  
> @@ -177,6 +178,7 @@ mcu_mcan1: can@4e18000 {
>  		interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>,
>  			     <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
>  		interrupt-names = "int0", "int1";
> +		wakeup-source;
>  		status = "disabled";
>  	};
>  
> -- 
> 2.43.0
> 

Curious:
https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/lpm.html#supported-low-power-modes
Does not seem to call out am62p. Is that an documentation oversight?

what happens to j722s?
Marc Kleine-Budde June 20, 2024, 12:26 p.m. UTC | #2
On 23.05.2024 09:53:43, Markus Schneider-Pargmann wrote:
> In some devices the pins of the m_can module can act as a wakeup source.
> This patch helps do that by connecting the PHY_WAKE WoL option to
> device_set_wakeup_enable. By marking this device as being wakeup
> enabled, this setting can be used by platform code to decide which
> sleep or poweroff mode to use.
> 
> Also this prepares the driver for the next patch in which the pinctrl
> settings are changed depending on the desired wakeup source.
> 
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
> ---
>  drivers/net/can/m_can/m_can.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 14b231c4d7ec..80964e403a5e 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -2129,6 +2129,26 @@ static int m_can_set_coalesce(struct net_device *dev,
>  	return 0;
>  }
>  
> +static void m_can_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
> +{
> +	struct m_can_classdev *cdev = netdev_priv(dev);
> +
> +	wol->supported = device_can_wakeup(cdev->dev) ? WAKE_PHY : 0;
> +	wol->wolopts = device_may_wakeup(cdev->dev) ? WAKE_PHY : 0;
> +}
> +
> +static int m_can_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
> +{
> +	struct m_can_classdev *cdev = netdev_priv(dev);
> +
> +	if ((wol->wolopts & WAKE_PHY) != wol->wolopts)
> +		return -EINVAL;
> +
> +	device_set_wakeup_enable(cdev->dev, !!wol->wolopts & WAKE_PHY);

Can you please add error handling here? Same for the modifications in
the next patch.

regards,
Marc