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(+)
--
2.43.0
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.
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
---
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index f9ffb963d6b1..33f1688ca208 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -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
--
2.43.0
Pins 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.
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
---
.../devicetree/bindings/net/can/bosch,m_can.yaml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 33f1688ca208..7c6fa7367c37 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -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
--
2.43.0
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 <[email protected]>
---
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);
+
+ 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
*/
--
2.43.0
am62 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.
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
---
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(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 80964e403a5e..c5585dc68f2f 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -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;
}
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index 3a9edc292593..bdfbba67b336 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -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);
--
2.43.0
mcu_mcan0 and mcu_mcan1 can be wakeup sources for the SoC. Mark them
accordingly in the devicetree.
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
---
arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi b/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi
index e66d486ef1f2..56a40b641667 100644
--- a/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi
@@ -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";
};
};
--
2.43.0
mcu_mcan0 and mcu_mcan1 can be wakeup sources for the SoC. Mark them
accordingly in the devicetree.
Signed-off-by: Markus Schneider-Pargmann <[email protected]>
---
arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi b/arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi
index 8c36e56f4138..f0f6b7650233 100644
--- a/arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62a-mcu.dtsi
@@ -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";
};
};
--
2.43.0
From: 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.
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(+)
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
On 09:53-20240523, Markus Schneider-Pargmann wrote:
> From: 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.
>
> 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(+)
>
> 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?
--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
On Thu, May 23, 2024 at 09:53:41AM +0200, Markus Schneider-Pargmann wrote:
> 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.
>
> Signed-off-by: Markus Schneider-Pargmann <[email protected]>
> ---
> Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
> index f9ffb963d6b1..33f1688ca208 100644
> --- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
> +++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
> @@ -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?