[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240523075347.1282395-5-msp@baylibre.com>
Date: Thu, 23 May 2024 09:53:44 +0200
From: Markus Schneider-Pargmann <msp@...libre.com>
To: Chandrasekar Ramakrishnan <rcsekar@...sung.com>,
Marc Kleine-Budde <mkl@...gutronix.de>,
Vincent Mailhol <mailhol.vincent@...adoo.fr>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Nishanth Menon <nm@...com>,
Vignesh Raghavendra <vigneshr@...com>,
Tero Kristo <kristo@...nel.org>
Cc: Vibhore Vardhan <vibhore@...com>,
Kevin Hilman <khilman@...libre.com>,
Dhruva Gole <d-gole@...com>,
Martin Hundebøll <martin@...nix.com>,
Simon Horman <horms@...nel.org>,
linux-can@...r.kernel.org,
netdev@...r.kernel.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Markus Schneider-Pargmann <msp@...libre.com>
Subject: [PATCH 4/7] can: m_can: Support pinctrl wakeup state
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 <msp@...libre.com>
---
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
Powered by blists - more mailing lists