can: m_can: introduce ti,am62-mcan compatible for out-of-band wakeup
Subsystems (3)
v9 cover can: m_can: introduce ti,am62-mcan compatible for out-of-band wakeup
This series introduces the "ti,am62-mcan" compatible which adds support for out-of-band wakeup capability in m_can devices.
A corresponding DTS series enabling this feature on TI K3 AM62 family of devices has been submitted separately:
"arm64: dts: ti: use ti,am62-mcan compatible for m_can devices" [1]
Testing
-------
Tested suspend/resume with CAN wakeup on AM62P SK EVM.
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v9:
- Rebase to v7.4-rc3.
- Link to v8: https://lore.kernel.org/all/[email protected]/
Changes in v8:
- Remove redundant error check before the logic to set out-of-band wakeup.
- Move m_can_of_data definition from m_can.h to m_can_platform.c since the struct is only used in that file.
- Link to v7: https://lore.kernel.org/r/[email protected]
Changes in v7:
- Rebased on top of "can: m_can: Fix suspend deinit() error path" and 6c507ab36a83 ("can: m_can: Remove comma after sentinel-entry in match-table").
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Fix indentation for items under the compatible property in DT bindings.
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Rename compatible string from "ti,am62-m_can" to "ti,am62-mcan".
- Update dt binding to use "oneOf" with a fallback compatible chain instead of a flat "enum".
- Rename "struct m_can_pdata" to "struct m_can_of_data".
- Read match data at probe time and cache it in "m_can_classdev" instead of fetching it in suspend.
- Add "out_band_wakeup" flag to "struct m_can_classdev".
- Guard wakeup/sleep pinctrl selection in suspend with a return value check.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Remove patch for "out-band-wakeup" property in dt binding.
- Create "ti,am62-m_can" compatible in the dt binding and m_can driver.
- Add "struct m_can_of_data" for compatible-specific data which keeps track of "out_band_wakeup" flag.
- Replace check "out-band-wakeup" dt property in the device driver upon suspend with check for "out_band_wakeup" variable from the "m_can_of_data".
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Remove definition of "out-band-wakeup" property in dt binding.
- Allow "out-band-wakeup" property in dt binding.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Create "out-band-wakeup" property in dt bindings.
- Use "out-band-wakeup" property to set the out_band_wakeup flag upon suspend.
- Rebase to v7.2
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Kendall Willis (2):
dt-bindings: can: m_can: add ti,am62-mcan compatible
can: m_can: add ti,am62-mcan compatible with out-of-band wakeup support
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 6 +++++- drivers/net/can/m_can/m_can.c | 6 +++++- drivers/net/can/m_can/m_can.h | 2 ++ drivers/net/can/m_can/m_can_platform.c | 13 +++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-)
---
base-commit: dec005ae90a2946656a090f37bf1cfbd22f08e57
change-id: 20260819-temp-93299bee27b7
prerequisite-change-id: 20260914-v7-3-topic-mcan-suspend-fix-fix-b943929d8fef:v1
prerequisite-patch-id: d60701b698565843ed0630ce15cda0c46c35cb39
prerequisite-patch-id: 6c507ab36a830f131d17ca74033282e89dec8a3f
Best regards,
Signature · 1 line
Kendall Willis <[email protected]>
PATCH v9 1/2 dt-bindings: can: m_can: add ti,am62-mcan compatible
Add "ti,am62-mcan" device. Device is fully compatible with Bosch. The device supports out-of-band wakeup capability.
--- Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +5 -1
@@ -16,7 +16,11 @@ allOf: properties: compatible: - const: bosch,m_can + oneOf: + - const: bosch,m_can + - items: + - const: ti,am62-mcan + - const: bosch,m_can reg: items:
Signature · 1 line
2.34.1
PATCH v9 2/2 can: m_can: add ti,am62-mcan compatible with out-of-band wakeup support
In reply to Kendall WillisIn TI K3 AM62 SoCs, the M_CAN controllers are in power domains which are OFF in the deepest low power states. However, the m_can pins are able to wakeup the system from states where the power domain is OFF through its out-of-band wakeup functionality.
Introduce the ti,am62-mcan 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.
--- drivers/net/can/m_can/m_can.c | 6 +++++- drivers/net/can/m_can/m_can.h | 2 ++ drivers/net/can/m_can/m_can_platform.c | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-)
drivers/net/can/m_can/m_can.c +5 -1
@@ -2622,8 +2622,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 (cdev->out_band_wakeup) +device_set_out_band_wakeup (dev); + }else {pinctrl_pm_select_sleep_state (dev); + }return ret; }
drivers/net/can/m_can/m_can.h +2 -0
@@ -132,6 +132,8 @@ struct m_can_classdev {struct pinctrl *pinctrl;struct pinctrl_state *pinctrl_state_wakeup; + +bool out_band_wakeup; };struct m_can_classdev *m_can_class_allocate_dev (struct device *dev,int sizeof_priv);
drivers/net/can/m_can/m_can_platform.c +13 -0
@@ -18,6 +18,10 @@ struct m_can_plat_priv {void __iomem *mram_base; }; +struct m_can_of_data { +bool out_band_wakeup; +}; +static inline struct m_can_plat_priv *cdev_to_priv (struct m_can_classdev *cdev) { return container_of(cdev, struct m_can_plat_priv, cdev);
@@ -83,6 +87,7 @@ static int m_can_plat_probe(struct platform_device *pdev)void __iomem *addr;void __iomem *mram_addr;struct phy *transceiver; +const struct m_can_of_data *of_data;int irq =0 , ret =0 ; mcan_class = m_can_class_allocate_dev(&pdev->dev,
@@ -148,6 +153,9 @@ static int m_can_plat_probe(struct platform_device *pdev) mcan_class->is_peripheral = false; + of_data =of_device_get_match_data (&pdev->dev); + mcan_class->out_band_wakeup = of_data && of_data->out_band_wakeup; +platform_set_drvdata (pdev, mcan_class);pm_runtime_enable (mcan_class->dev);
@@ -218,8 +226,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_of_data m_can_plat_am62 = { + .out_band_wakeup = true, +}; +static const struct of_device_id m_can_of_table[] = { { .compatible ="bosch,m_can" , .data =NULL }, + { .compatible ="ti,am62-mcan" , .data = &m_can_plat_am62 }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, m_can_of_table);
Signature · 1 line
2.34.1