* [PATCH v10 0/4] can: m_can: Add am62 wakeup support
@ 2025-10-01 14:30 Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties Markus Schneider-Pargmann (TI.com)
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2025-10-01 14:30 UTC (permalink / raw)
To: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Vincent Mailhol
Cc: Vishal Mahaveer, Kevin Hilman, Dhruva Gole, Sebin Francis,
Kendall Willis, Akashdeep Kaur, Simon Horman, linux-can,
devicetree, linux-kernel, Markus Schneider-Pargmann (TI.com),
Vincent Mailhol
Hi,
This series adds support for wakeup capabilities to the m_can driver,
which is necessary for enabling Partial-IO functionality on am62, am62a,
and am62p SoCs. It implements the wake-on-lan interface for m_can
devices and handles the pinctrl states needed for wakeup functionality.
am62, am62a and am62p support Partial-IO, a low power system state in
which nearly everything is turned off except the pins of the CANUART
group. This group contains mcu_mcan0, mcu_mcan1, wkup_uart0 and
mcu_uart0 devices.
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.
Partial-IO Overview
------------------
Partial-IO is a low power system state in which nearly everything is
turned off except the pins of the CANUART group (mcu_mcan0, mcu_mcan1,
wkup_uart0 and mcu_uart0). These devices can trigger a wakeup of the
system on pin activity. Note that this does not resume the system as the
DDR is off as well. So this state can be considered a power-off state
with wakeup capabilities.
A documentation can also be found in section 6.2.4 in the TRM:
https://www.ti.com/lit/pdf/spruiv7
Implementation Details
----------------------
The complete Partial-IO feature requires three coordinated series, each
handling a different aspect of the implementation:
1. This series (m_can driver): Implements device-specific wakeup
functionality for m_can devices, allowing them to be set as wakeup
sources.
2. Devicetree series: Defines system states and wakeup sources in the
devicetree for am62, am62a and am62p.
https://gitlab.baylibre.com/msp8/linux/-/tree/topic/am62-dt-partialio/v6.17?ref_type=heads
3. TI-SCI firmware series: Implements the firmware interface to enter
Partial-IO mode when appropriate wakeup sources are enabled.
https://gitlab.baylibre.com/msp8/linux/-/tree/topic/tisci-partialio/v6.17?ref_type=heads
Devicetree Bindings
-------------------
The wakeup-source property is used with references to
system-idle-states. This depends on the dt-schema pull request that adds
bindings for system-idle-states and updates the binding for
wakeup-source:
https://github.com/devicetree-org/dt-schema/pull/150
This is merged now and upstream in dt-schema.
Testing
-------
A test branch is available here that includes all patches required to
test Partial-IO:
https://gitlab.baylibre.com/msp8/linux/-/tree/integration/am62-partialio/v6.17?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
Previous versions:
v1: https://lore.kernel.org/lkml/20240523075347.1282395-1-msp@baylibre.com/
v2: https://lore.kernel.org/lkml/20240729074135.3850634-1-msp@baylibre.com/
v3: https://lore.kernel.org/lkml/20241011-topic-mcan-wakeup-source-v6-12-v3-0-9752c714ad12@baylibre.com
v4: https://lore.kernel.org/r/20241015-topic-mcan-wakeup-source-v6-12-v4-0-fdac1d1e7aa6@baylibre.com
v5: https://lore.kernel.org/r/20241028-topic-mcan-wakeup-source-v6-12-v5-0-33edc0aba629@baylibre.com
v6: https://lore.kernel.org/r/20241219-topic-mcan-wakeup-source-v6-12-v6-0-1356c7f7cfda@baylibre.com
v7: https://lore.kernel.org/r/20250421-topic-mcan-wakeup-source-v6-12-v7-0-1b7b916c9832@baylibre.com
v8: https://lore.kernel.org/r/20250812-topic-mcan-wakeup-source-v6-12-v8-0-6972a810d63b@baylibre.com
v9: https://lore.kernel.org/r/20250820-topic-mcan-wakeup-source-v6-12-v9-0-0ac13f2ddd67@baylibre.com
Changes in v10:
- Change dt-binding to be able to set pinctrl-names = "default", "wakeup";
- Fix wording in the dt-binging
- Fix mcan commit message to have correct naming of the SoC
- Change function name from m_can_class_setup_optional_pinctrl() to
m_can_class_parse_pinctrl()
Changes in v9:
- Update the binding to accept the sleep pinctrl state which is
already in use by other devicetrees
- Modify suspend/resume to not set the sleep state if wakeup is enabled
and a wakeup pinctrl state is present. If wakeup pinctrl is active
this should be kept enabled even after suspend
- Modify m_can_set_wol() to use pinctrl_pm_select_default_state() to
get rid of the manually managed default pinctrl.
Changes in v8:
- Rebase to v6.17-rc1
Changes in v7:
- Separate this series from "firmware: ti_sci: Partial-IO support"
again as was requested internally
- All DT changes are now in their own series to avoid conflicts
- wakeup-source definition in the m_can binding is now only an
extension to the dt-schema binding and a pull request was created
Changes in v6:
- Rebased to v6.13-rc1
- After feedback of the other Partial-IO series, I updated this series
and removed all use of regulator-related patches.
- wakeup-source is now not only a boolean property but can also be a
list of power states in which the device is wakeup capable.
Changes in v5:
- Make the check of wol options nicer to read
Changes in v4:
- Remove leftover testing code that always returned -EIO in a specific
- Redesign pincontrol setup to be easier understandable and less nested
- Fix missing parantheses around wol_enable expression
- Remove | from binding description
Changes in v3:
- Rebase to v6.12-rc1
- Change 'wakeup-source' to only 'true'
- Simplify m_can_set_wol by returning early on error
- Add vio-suuply binding and handling of this optional property.
vio-supply is used to reflect the SoC architecture and which power
line powers the m_can unit. This is important as some units are
powered in special low power modes.
Changes in v2:
- Rebase to v6.11-rc1
- Squash these two patches for the binding into one:
dt-bindings: can: m_can: Add wakeup-source property
dt-bindings: can: m_can: Add wakeup pinctrl state
- Add error handling to multiple patches of the m_can driver
- Add error handling in m_can_class_allocate_dev(). This also required
to add a new patch to return error pointers from
m_can_class_allocate_dev().
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
Markus Schneider-Pargmann (TI.com) (4):
dt-bindings: can: m_can: Add wakeup properties
can: m_can: Map WoL to device_set_wakeup_enable
can: m_can: Return ERR_PTR on error in allocation
can: m_can: Support pinctrl wakeup state
.../devicetree/bindings/net/can/bosch,m_can.yaml | 25 +++++
drivers/net/can/m_can/m_can.c | 112 ++++++++++++++++++++-
drivers/net/can/m_can/m_can.h | 3 +
drivers/net/can/m_can/m_can_pci.c | 4 +-
drivers/net/can/m_can/m_can_platform.c | 4 +-
drivers/net/can/m_can/tcan4x5x-core.c | 4 +-
6 files changed, 141 insertions(+), 11 deletions(-)
---
base-commit: 24c4d4041c2ec11c47baf6ea54f9379cf88809fc
change-id: 20241009-topic-mcan-wakeup-source-v6-12-8c1d69931bd8
Best regards,
--
Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties
2025-10-01 14:30 [PATCH v10 0/4] can: m_can: Add am62 wakeup support Markus Schneider-Pargmann (TI.com)
@ 2025-10-01 14:30 ` Markus Schneider-Pargmann (TI.com)
2025-10-08 15:06 ` Rob Herring (Arm)
2025-10-09 8:21 ` Dhruva Gole
2025-10-01 14:30 ` [PATCH v10 2/4] can: m_can: Map WoL to device_set_wakeup_enable Markus Schneider-Pargmann (TI.com)
` (3 subsequent siblings)
4 siblings, 2 replies; 8+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2025-10-01 14:30 UTC (permalink / raw)
To: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Vincent Mailhol
Cc: Vishal Mahaveer, Kevin Hilman, Dhruva Gole, Sebin Francis,
Kendall Willis, Akashdeep Kaur, Simon Horman, linux-can,
devicetree, linux-kernel, Markus Schneider-Pargmann (TI.com),
Vincent Mailhol
The pins associated with m_can have to have a special configuration to
be able to wakeup the SoC from some system states. This configuration is
described in the wakeup pinctrl state while the default state describes
the default configuration. Also add the sleep state which is already in
use by some devicetrees.
Also m_can can be a wakeup-source if capable of wakeup.
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
.../devicetree/bindings/net/can/bosch,m_can.yaml | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 61ef60d8f1c78c40a6c8458ed30b940b1121d83f..2c9d37975bedd652b3060ab11ba75c37565edaad 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -109,6 +109,26 @@ properties:
maximum: 32
minItems: 1
+ pinctrl-0:
+ description: Default pinctrl state
+
+ pinctrl-1:
+ description: Can be "sleep" or "wakeup" pinctrl state
+
+ pinctrl-2:
+ description: Can be "sleep" or "wakeup" pinctrl state
+
+ pinctrl-names:
+ description:
+ When present should contain at least "default" describing the default pin
+ states. Other states are "sleep" which describes the pinstate when
+ sleeping and "wakeup" describing the pins if wakeup is enabled.
+ minItems: 1
+ items:
+ - const: default
+ - enum: [ sleep, wakeup ]
+ - const: wakeup
+
power-domains:
description:
Power domain provider node and an args specifier containing
@@ -125,6 +145,11 @@ properties:
minItems: 1
maxItems: 2
+ wakeup-source:
+ $ref: /schemas/types.yaml#/definitions/phandle-array
+ description:
+ List of phandles to system idle states in which mcan can wakeup the system.
+
required:
- compatible
- reg
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v10 2/4] can: m_can: Map WoL to device_set_wakeup_enable
2025-10-01 14:30 [PATCH v10 0/4] can: m_can: Add am62 wakeup support Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties Markus Schneider-Pargmann (TI.com)
@ 2025-10-01 14:30 ` Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 3/4] can: m_can: Return ERR_PTR on error in allocation Markus Schneider-Pargmann (TI.com)
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2025-10-01 14:30 UTC (permalink / raw)
To: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Vincent Mailhol
Cc: Vishal Mahaveer, Kevin Hilman, Dhruva Gole, Sebin Francis,
Kendall Willis, Akashdeep Kaur, Simon Horman, linux-can,
devicetree, linux-kernel, Markus Schneider-Pargmann (TI.com),
Vincent Mailhol
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.
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Kendall Willis <k-willis@ti.com>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
drivers/net/can/m_can/m_can.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index e1d725979685ff90bff9957bcf6193265bfbcb55..e5588e2205797be03090a7317e9d3518bc09b054 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -2220,6 +2220,36 @@ 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);
+ bool wol_enable = !!(wol->wolopts & WAKE_PHY);
+ int ret;
+
+ if (wol->wolopts & ~WAKE_PHY)
+ return -EINVAL;
+
+ if (wol_enable == device_may_wakeup(cdev->dev))
+ return 0;
+
+ ret = device_set_wakeup_enable(cdev->dev, wol_enable);
+ if (ret) {
+ netdev_err(cdev->net, "Failed to set wakeup enable %pE\n",
+ ERR_PTR(ret));
+ return ret;
+ }
+
+ return 0;
+}
+
static const struct ethtool_ops m_can_ethtool_ops_coalescing = {
.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ |
ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ |
@@ -2229,10 +2259,14 @@ static const struct ethtool_ops m_can_ethtool_ops_coalescing = {
.get_ts_info = ethtool_op_get_ts_info,
.get_coalesce = m_can_get_coalesce,
.set_coalesce = m_can_set_coalesce,
+ .get_wol = m_can_get_wol,
+ .set_wol = m_can_set_wol,
};
static const struct ethtool_ops m_can_ethtool_ops = {
.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 m_can_classdev *cdev)
@@ -2359,6 +2393,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.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v10 3/4] can: m_can: Return ERR_PTR on error in allocation
2025-10-01 14:30 [PATCH v10 0/4] can: m_can: Add am62 wakeup support Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 2/4] can: m_can: Map WoL to device_set_wakeup_enable Markus Schneider-Pargmann (TI.com)
@ 2025-10-01 14:30 ` Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 4/4] can: m_can: Support pinctrl wakeup state Markus Schneider-Pargmann (TI.com)
2025-10-17 10:15 ` [PATCH v10 0/4] can: m_can: Add am62 wakeup support Marc Kleine-Budde
4 siblings, 0 replies; 8+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2025-10-01 14:30 UTC (permalink / raw)
To: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Vincent Mailhol
Cc: Vishal Mahaveer, Kevin Hilman, Dhruva Gole, Sebin Francis,
Kendall Willis, Akashdeep Kaur, Simon Horman, linux-can,
devicetree, linux-kernel, Markus Schneider-Pargmann (TI.com),
Vincent Mailhol
We have more detailed error values available, return them in the core
driver and the calling drivers to return proper errors to callers.
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Reviewed-by: Kendall Willis <k-willis@ti.com>
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
drivers/net/can/m_can/m_can.c | 6 +++---
drivers/net/can/m_can/m_can_pci.c | 4 ++--
drivers/net/can/m_can/m_can_platform.c | 4 ++--
drivers/net/can/m_can/tcan4x5x-core.c | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index e5588e2205797be03090a7317e9d3518bc09b054..835b03db1003db6ffa21044ac756676fb193f64d 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -2390,7 +2390,7 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
sizeof(mram_config_vals) / 4);
if (ret) {
dev_err(dev, "Could not get Message RAM configuration.");
- goto out;
+ return ERR_PTR(ret);
}
if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source"))
@@ -2405,7 +2405,7 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
net_dev = alloc_candev(sizeof_priv, tx_fifo_size);
if (!net_dev) {
dev_err(dev, "Failed to allocate CAN device");
- goto out;
+ return ERR_PTR(-ENOMEM);
}
class_dev = netdev_priv(net_dev);
@@ -2415,7 +2415,7 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
m_can_of_parse_mram(class_dev, mram_config_vals);
spin_lock_init(&class_dev->tx_handling_spinlock);
-out:
+
return class_dev;
}
EXPORT_SYMBOL_GPL(m_can_class_allocate_dev);
diff --git a/drivers/net/can/m_can/m_can_pci.c b/drivers/net/can/m_can/m_can_pci.c
index 9ad7419f88f83016e93667f4847fe536eca39ad1..eb31ed1f964491ab41c7811be317706a09951390 100644
--- a/drivers/net/can/m_can/m_can_pci.c
+++ b/drivers/net/can/m_can/m_can_pci.c
@@ -111,8 +111,8 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
mcan_class = m_can_class_allocate_dev(&pci->dev,
sizeof(struct m_can_pci_priv));
- if (!mcan_class)
- return -ENOMEM;
+ if (IS_ERR(mcan_class))
+ return PTR_ERR(mcan_class);
priv = cdev_to_priv(mcan_class);
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b832566efda042929486578fad1879c7ad4a0cff..40bd10f71f0e2fab847c40c5bd5f7d85d3d46712 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -87,8 +87,8 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class = m_can_class_allocate_dev(&pdev->dev,
sizeof(struct m_can_plat_priv));
- if (!mcan_class)
- return -ENOMEM;
+ if (IS_ERR(mcan_class))
+ return PTR_ERR(mcan_class);
priv = cdev_to_priv(mcan_class);
diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index 39b0b5277b11f5cf86137528e7ebea93a6d29c80..31cc9d0abd45360de8700d0a0270af8d3e42967d 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -416,8 +416,8 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
mcan_class = m_can_class_allocate_dev(&spi->dev,
sizeof(struct tcan4x5x_priv));
- if (!mcan_class)
- return -ENOMEM;
+ if (IS_ERR(mcan_class))
+ return PTR_ERR(mcan_class);
ret = m_can_check_mram_cfg(mcan_class, TCAN4X5X_MRAM_SIZE);
if (ret)
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v10 4/4] can: m_can: Support pinctrl wakeup state
2025-10-01 14:30 [PATCH v10 0/4] can: m_can: Add am62 wakeup support Markus Schneider-Pargmann (TI.com)
` (2 preceding siblings ...)
2025-10-01 14:30 ` [PATCH v10 3/4] can: m_can: Return ERR_PTR on error in allocation Markus Schneider-Pargmann (TI.com)
@ 2025-10-01 14:30 ` Markus Schneider-Pargmann (TI.com)
2025-10-17 10:15 ` [PATCH v10 0/4] can: m_can: Add am62 wakeup support Marc Kleine-Budde
4 siblings, 0 replies; 8+ messages in thread
From: Markus Schneider-Pargmann (TI.com) @ 2025-10-01 14:30 UTC (permalink / raw)
To: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Vincent Mailhol
Cc: Vishal Mahaveer, Kevin Hilman, Dhruva Gole, Sebin Francis,
Kendall Willis, Akashdeep Kaur, Simon Horman, linux-can,
devicetree, linux-kernel, Markus Schneider-Pargmann (TI.com),
Vincent Mailhol
TI AM62x SoC requires a wakeup flag being set in pinctrl when mcan pins
act as a wakeup source. Add support to select the wakeup state if WOL
is enabled.
Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
---
drivers/net/can/m_can/m_can.c | 69 +++++++++++++++++++++++++++++++++++++++++--
drivers/net/can/m_can/m_can.h | 3 ++
2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 835b03db1003db6ffa21044ac756676fb193f64d..beb79403611b61d0643da960dfe5301e9dba579b 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -2247,7 +2247,26 @@ static int m_can_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
return ret;
}
+ if (!IS_ERR_OR_NULL(cdev->pinctrl_state_wakeup)) {
+ if (wol_enable)
+ ret = pinctrl_select_state(cdev->pinctrl, cdev->pinctrl_state_wakeup);
+ else
+ ret = pinctrl_pm_select_default_state(cdev->dev);
+
+ if (ret) {
+ netdev_err(cdev->net, "Failed to select pinctrl state %pE\n",
+ ERR_PTR(ret));
+ goto err_wakeup_enable;
+ }
+ }
+
return 0;
+
+err_wakeup_enable:
+ /* Revert wakeup enable */
+ device_set_wakeup_enable(cdev->dev, !wol_enable);
+
+ return ret;
}
static const struct ethtool_ops m_can_ethtool_ops_coalescing = {
@@ -2375,6 +2394,42 @@ int m_can_class_get_clocks(struct m_can_classdev *cdev)
}
EXPORT_SYMBOL_GPL(m_can_class_get_clocks);
+static bool m_can_class_wakeup_pinctrl_enabled(struct m_can_classdev *class_dev)
+{
+ return device_may_wakeup(class_dev->dev) && class_dev->pinctrl_state_wakeup;
+}
+
+static int m_can_class_parse_pinctrl(struct m_can_classdev *class_dev)
+{
+ struct device *dev = class_dev->dev;
+ int ret;
+
+ class_dev->pinctrl = devm_pinctrl_get(dev);
+ if (IS_ERR(class_dev->pinctrl)) {
+ ret = PTR_ERR(class_dev->pinctrl);
+ class_dev->pinctrl = NULL;
+
+ if (ret == -ENODEV)
+ return 0;
+
+ return dev_err_probe(dev, ret, "Failed to get pinctrl\n");
+ }
+
+ class_dev->pinctrl_state_wakeup =
+ pinctrl_lookup_state(class_dev->pinctrl, "wakeup");
+ if (IS_ERR(class_dev->pinctrl_state_wakeup)) {
+ ret = PTR_ERR(class_dev->pinctrl_state_wakeup);
+ class_dev->pinctrl_state_wakeup = NULL;
+
+ if (ret == -ENODEV)
+ return 0;
+
+ return dev_err_probe(dev, ret, "Failed to lookup pinctrl wakeup state\n");
+ }
+
+ return 0;
+}
+
struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
int sizeof_priv)
{
@@ -2416,7 +2471,15 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev,
m_can_of_parse_mram(class_dev, mram_config_vals);
spin_lock_init(&class_dev->tx_handling_spinlock);
+ ret = m_can_class_parse_pinctrl(class_dev);
+ if (ret)
+ goto err_free_candev;
+
return class_dev;
+
+err_free_candev:
+ free_candev(net_dev);
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(m_can_class_allocate_dev);
@@ -2531,7 +2594,8 @@ int m_can_class_suspend(struct device *dev)
m_can_clk_stop(cdev);
}
- pinctrl_pm_select_sleep_state(dev);
+ if (!m_can_class_wakeup_pinctrl_enabled(cdev))
+ pinctrl_pm_select_sleep_state(dev);
cdev->can.state = CAN_STATE_SLEEPING;
@@ -2545,7 +2609,8 @@ int m_can_class_resume(struct device *dev)
struct net_device *ndev = cdev->net;
int ret = 0;
- pinctrl_pm_select_default_state(dev);
+ if (!m_can_class_wakeup_pinctrl_enabled(cdev))
+ pinctrl_pm_select_default_state(dev);
cdev->can.state = CAN_STATE_ERROR_ACTIVE;
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index bd4746c63af3f0a032910644dfd48a9ebb3a6168..583c7f1d005d61b3fc8587697388522993ff11a8 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -128,6 +128,9 @@ struct m_can_classdev {
struct mram_cfg mcfg[MRAM_CFG_NUM];
struct hrtimer hrtimer;
+
+ struct pinctrl *pinctrl;
+ struct pinctrl_state *pinctrl_state_wakeup;
};
struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, int sizeof_priv);
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties
2025-10-01 14:30 ` [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties Markus Schneider-Pargmann (TI.com)
@ 2025-10-08 15:06 ` Rob Herring (Arm)
2025-10-09 8:21 ` Dhruva Gole
1 sibling, 0 replies; 8+ messages in thread
From: Rob Herring (Arm) @ 2025-10-08 15:06 UTC (permalink / raw)
To: Markus Schneider-Pargmann (TI.com)
Cc: Dhruva Gole, Vincent Mailhol, Simon Horman, Akashdeep Kaur,
linux-kernel, linux-can, Vishal Mahaveer, Marc Kleine-Budde,
Conor Dooley, Sebin Francis, Chandrasekar Ramakrishnan,
devicetree, Krzysztof Kozlowski, Kevin Hilman, Kendall Willis
On Wed, 01 Oct 2025 16:30:19 +0200, Markus Schneider-Pargmann (TI.com) wrote:
> The pins associated with m_can have to have a special configuration to
> be able to wakeup the SoC from some system states. This configuration is
> described in the wakeup pinctrl state while the default state describes
> the default configuration. Also add the sleep state which is already in
> use by some devicetrees.
>
> Also m_can can be a wakeup-source if capable of wakeup.
>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
> .../devicetree/bindings/net/can/bosch,m_can.yaml | 25 ++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties
2025-10-01 14:30 ` [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties Markus Schneider-Pargmann (TI.com)
2025-10-08 15:06 ` Rob Herring (Arm)
@ 2025-10-09 8:21 ` Dhruva Gole
1 sibling, 0 replies; 8+ messages in thread
From: Dhruva Gole @ 2025-10-09 8:21 UTC (permalink / raw)
To: Markus Schneider-Pargmann (TI.com)
Cc: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Vincent Mailhol,
Vishal Mahaveer, Kevin Hilman, Sebin Francis, Kendall Willis,
Akashdeep Kaur, Simon Horman, linux-can, devicetree, linux-kernel
On Oct 01, 2025 at 16:30:19 +0200, Markus Schneider-Pargmann (TI.com) wrote:
> The pins associated with m_can have to have a special configuration to
> be able to wakeup the SoC from some system states. This configuration is
> described in the wakeup pinctrl state while the default state describes
> the default configuration. Also add the sleep state which is already in
> use by some devicetrees.
>
> Also m_can can be a wakeup-source if capable of wakeup.
>
> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
> ---
Reviewed-by: Dhruva Gole <d-gole@ti.com>
--
Best regards,
Dhruva Gole
Texas Instruments Incorporated
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v10 0/4] can: m_can: Add am62 wakeup support
2025-10-01 14:30 [PATCH v10 0/4] can: m_can: Add am62 wakeup support Markus Schneider-Pargmann (TI.com)
` (3 preceding siblings ...)
2025-10-01 14:30 ` [PATCH v10 4/4] can: m_can: Support pinctrl wakeup state Markus Schneider-Pargmann (TI.com)
@ 2025-10-17 10:15 ` Marc Kleine-Budde
4 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2025-10-17 10:15 UTC (permalink / raw)
To: Markus Schneider-Pargmann (TI.com)
Cc: Chandrasekar Ramakrishnan, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Vincent Mailhol, Vishal Mahaveer, Kevin Hilman,
Dhruva Gole, Sebin Francis, Kendall Willis, Akashdeep Kaur,
Simon Horman, linux-can, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 673 bytes --]
On 01.10.2025 16:30:18, Markus Schneider-Pargmann (TI.com) wrote:
> This series adds support for wakeup capabilities to the m_can driver,
> which is necessary for enabling Partial-IO functionality on am62, am62a,
> and am62p SoCs. It implements the wake-on-lan interface for m_can
> devices and handles the pinctrl states needed for wakeup functionality.
Added to linux-can-next.
Thanks,
Marc
--
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 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-10-17 10:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-01 14:30 [PATCH v10 0/4] can: m_can: Add am62 wakeup support Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 1/4] dt-bindings: can: m_can: Add wakeup properties Markus Schneider-Pargmann (TI.com)
2025-10-08 15:06 ` Rob Herring (Arm)
2025-10-09 8:21 ` Dhruva Gole
2025-10-01 14:30 ` [PATCH v10 2/4] can: m_can: Map WoL to device_set_wakeup_enable Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 3/4] can: m_can: Return ERR_PTR on error in allocation Markus Schneider-Pargmann (TI.com)
2025-10-01 14:30 ` [PATCH v10 4/4] can: m_can: Support pinctrl wakeup state Markus Schneider-Pargmann (TI.com)
2025-10-17 10:15 ` [PATCH v10 0/4] can: m_can: Add am62 wakeup support Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).