can: m_can: Add am62 wakeup support
Subsystems (6)
Markus Schneider-Pargmann
maintainercover can: m_can: Add am62 wakeup support
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(+)
Signature · 1 line
2.43.0
Markus Schneider-Pargmann
maintainerPATCH 1/7 dt-bindings: can: m_can: Add wakeup-source property
m_can can be a wakeup source on some devices. Especially on some of the am62* SoCs pins, connected to m_can in the mcu, can be used to wakeup the SoC.
This property defines on which devices m_can can be used for wakeup.
--- Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +4 -0
@@ -118,6 +118,10 @@ properties: phys: maxItems: 1 + wakeup-source: + $ref: /schemas/types.yaml#/definitions/flag + description: This device is capable to wakeup the SoC. + required: - compatible - reg
Signature · 1 line
2.43.0
Markus Schneider-Pargmann
maintainerPATCH 2/7 dt-bindings: can: m_can: Add wakeup pinctrl state
In reply to Markus Schneider-PargmannPins associated with m_can can be the source of a wakeup in deep sleep states. To be able to wakeup these pins have to be configured in a special way. To support this configuration add the default and wakeup pinctrl states.
--- .../devicetree/bindings/net/can/bosch,m_can.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +16 -0
@@ -106,6 +106,22 @@ properties: maximum: 32 minItems: 1 + pinctrl-0: + description: Default pinctrl state + + pinctrl-1: + description: Wakeup pinctrl state + + pinctrl-names: + description: + When present should contain at least "default" describing the default pin + states. The second state called "wakeup" describes the pins in their + wakeup configuration required to exit sleep states. + minItems: 1 + items: + - const: default + - const: wakeup + power-domains: description: Power domain provider node and an args specifier containing
Signature · 1 line
2.43.0
Markus Schneider-Pargmann
maintainerPATCH 3/7 can: m_can: Map WoL to device_set_wakeup_enable
In reply to Markus Schneider-PargmannIn 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.
--- drivers/net/can/m_can/m_can.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/net/can/m_can/m_can.c +25 -0
@@ -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 ); + +return 0 ; +} +static const struct ethtool_ops m_can_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ |
@@ -2142,6 +2162,8 @@ static const struct ethtool_ops m_can_ethtool_ops = {static const struct ethtool_ops m_can_ethtool_ops_polling = { .get_ts_info = ethtool_op_get_ts_info, + .get_wol = m_can_get_wol, + .set_wol = m_can_set_wol, };static int register_m_can_dev (struct net_device *dev)
@@ -2266,6 +2288,9 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, goto out; } +if (dev->of_node &&of_property_read_bool (dev->of_node,"wakeup-source" )) +device_set_wakeup_capable (dev, true); +/* Get TX FIFO size * Defines the total amount of echo buffers for loopback */
Signature · 1 line
2.43.0
Markus Schneider-Pargmann
maintainerPATCH 4/7 can: m_can: Support pinctrl wakeup state
In reply to Markus Schneider-Pargmannam62 requires a wakeup flag being set in pinctrl when mcan pins acts as a wakeup source. Add support to select the wakeup state if WOL is enabled.
--- drivers/net/can/m_can/m_can.c | 20 +++++++++++++++++++- drivers/net/can/m_can/m_can.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/net/can/m_can/m_can.c +19 -1
@@ -2140,11 +2140,21 @@ static void m_can_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)static int m_can_set_wol (struct net_device *dev,struct ethtool_wolinfo *wol) {struct m_can_classdev *cdev =netdev_priv (dev); +struct pinctrl_state *new_pinctrl_state =NULL ; +bool wol_enable = !!wol->wolopts &WAKE_PHY ;if ((wol->wolopts &WAKE_PHY ) != wol->wolopts)return -EINVAL ; -device_set_wakeup_enable (cdev->dev, !!wol->wolopts &WAKE_PHY ); +if (wol_enable) + new_pinctrl_state = cdev->pinctrl_state_wakeup; +else + new_pinctrl_state = cdev->pinctrl_state_default; + +if (!IS_ERR_OR_NULL (new_pinctrl_state)) +pinctrl_select_state (cdev->pinctrl, new_pinctrl_state); + +device_set_wakeup_enable (cdev->dev, wol_enable);return 0 ; }
@@ -2309,6 +2319,14 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,SET_NETDEV_DEV (net_dev, dev);m_can_of_parse_mram (class_dev, mram_config_vals); + + class_dev->pinctrl =devm_pinctrl_get (dev); +if (!IS_ERR_OR_NULL (class_dev->pinctrl)) { + class_dev->pinctrl_state_default = +pinctrl_lookup_state (class_dev->pinctrl,"default" ); + class_dev->pinctrl_state_wakeup = +pinctrl_lookup_state (class_dev->pinctrl,"wakeup" ); + } out:return class_dev; }
drivers/net/can/m_can/m_can.h +4 -0
@@ -126,6 +126,10 @@ struct m_can_classdev {struct mram_cfg mcfg[MRAM_CFG_NUM ];struct hrtimer hrtimer; + +struct pinctrl *pinctrl; +struct pinctrl_state *pinctrl_state_default; +struct pinctrl_state *pinctrl_state_wakeup; };struct m_can_classdev *m_can_class_allocate_dev (struct device *dev,int sizeof_priv);
Signature · 1 line
2.43.0
Markus Schneider-Pargmann
maintainerPATCH 5/7 arm64: dts: ti: k3-am62: Mark mcu_mcan0/1 as wakeup-source
In reply to Markus Schneider-Pargmannmcu_mcan0 and mcu_mcan1 can be wakeup sources for the SoC. Mark them accordingly in the devicetree.
--- arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi +2 -0
@@ -159,6 +159,7 @@ mcu_mcan0: can@4e08000 { clocks = <&k3_clks 188 6>, <&k3_clks 188 1>; clock-names = "hclk", "cclk"; bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + wakeup-source; status = "disabled"; };
@@ -171,6 +172,7 @@ mcu_mcan1: can@4e18000 { clocks = <&k3_clks 189 6>, <&k3_clks 189 1>; clock-names = "hclk", "cclk"; bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + wakeup-source; status = "disabled"; }; };
Signature · 1 line
2.43.0
Markus Schneider-Pargmann
maintainerPATCH 6/7 arm64: dts: ti: k3-am62a-mcu: Mark mcu_mcan0/1 as wakeup-source
In reply to Markus Schneider-Pargmannmcu_mcan0 and mcu_mcan1 can be wakeup sources for the SoC. Mark them accordingly in the devicetree.
--- arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi +2 -0
@@ -153,6 +153,7 @@ mcu_mcan0: can@4e08000 { clocks = <&k3_clks 188 6>, <&k3_clks 188 1>; clock-names = "hclk", "cclk"; bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + wakeup-source; status = "disabled"; };
@@ -165,6 +166,7 @@ mcu_mcan1: can@4e18000 { clocks = <&k3_clks 189 6>, <&k3_clks 189 1>; clock-names = "hclk", "cclk"; bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + wakeup-source; status = "disabled"; }; };
Signature · 1 line
2.43.0
Markus Schneider-Pargmann
maintainerPATCH 7/7 arm64: dts: ti: k3-am62p-mcu: Mark mcu_mcan0/1 as wakeup-source
In reply to Markus Schneider-PargmannFrom: Vibhore Vardhan <[email protected]>
mcu_mcan0 and mcu_mcan1 can be wakeup sources for the SoC. Mark them accordingly in the devicetree. Based on the patch for AM62a.
--- arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi +2 -0
@@ -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"; };
Signature · 1 line
2.43.0
Nishanth Menon
maintainerRe: [PATCH 7/7] arm64: dts: ti: k3-am62p-mcu: Mark mcu_mcan0/1 as wakeup-source
Quoted 34 lines · Markus Schneider-Pargmann
From: Vibhore Vardhan <[email protected]>
mcu_mcan0andmcu_mcan1can be wakeup sources for the SoC. Mark them accordingly in the devicetree. Based on the patch for AM62a.Signed-off-by Vibhore Vardhan <[email protected]>Signed-off-by Markus Schneider-Pargmann <[email protected]>--- arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/boot/dts/ti/k3-am62p-mcu.dtsi +2
-0@@ -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"; };Signature · 1 line
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?
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Re: [PATCH 1/7] dt-bindings: can: m_can: Add wakeup-source property
In reply to Markus Schneider-PargmannQuoted 16 lines · Markus Schneider-Pargmann
m_cancan be a wakeup source on some devices. Especially on some of the am62* SoCs pins, connected tom_canin the mcu, can be used to wakeup the SoC.This property defines on which devices
m_cancan be used for wakeup.Signed-off-by Markus Schneider-Pargmann <[email protected]>--- Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +0
-0
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml properties: · line 123
Quoted 6 lines
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +3
-0@@ -118,6 +118,10 @@ properties: phys: maxItems: 1 + wakeup-source: + $ref: /schemas/types.yaml#/definitions/flag + description: This device is capable to wakeup the SoC.
It seems to me like patch 1 & 2 should be squashed, with "wakeup-source" depending on the correct pinctrl setup?
Marc Kleine-Budde
maintainerRe: [PATCH 3/7] can: m_can: Map WoL to device_set_wakeup_enable
In reply to Markus Schneider-PargmannQuoted 28 lines · Markus Schneider-Pargmann
In some devices the pins of the
m_canmodule can act as a wakeup source. This patch helps do that by connecting thePHY_WAKEWoL option todevice_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 <[email protected]>--- drivers/net/can/m_can/m_can.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/net/can/m_can/m_can.c +6
-0@@ -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 ;
drivers/net/can/m_can/m_can.c static int m_can_set_coalesce(struct net_device *dev, · line 2147
Quoted 10 lines
drivers/net/can/m_can/m_can.c +10
-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
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |