Skip to content

Commit 3973c52

Browse files
Roger Quadrosmarckleinebudde
authored andcommitted
can: c_can: Disable pins when CAN interface is down
DRA7 CAN IP suffers from a problem which causes it to be prevented from fully turning OFF (i.e. stuck in transition) if the module was disabled while there was traffic on the CAN_RX line. To work around this issue we select the SLEEP pin state by default on probe and use the DEFAULT pin state on CAN up and back to the SLEEP pin state on CAN down. Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 0741bfb commit 3973c52

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/net/can/c_can/c_can.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/list.h>
3636
#include <linux/io.h>
3737
#include <linux/pm_runtime.h>
38+
#include <linux/pinctrl/consumer.h>
3839

3940
#include <linux/can.h>
4041
#include <linux/can/dev.h>
@@ -603,6 +604,8 @@ static int c_can_start(struct net_device *dev)
603604

604605
priv->can.state = CAN_STATE_ERROR_ACTIVE;
605606

607+
/* activate pins */
608+
pinctrl_pm_select_default_state(dev->dev.parent);
606609
return 0;
607610
}
608611

@@ -611,6 +614,9 @@ static void c_can_stop(struct net_device *dev)
611614
struct c_can_priv *priv = netdev_priv(dev);
612615

613616
c_can_irq_control(priv, false);
617+
618+
/* deactivate pins */
619+
pinctrl_pm_select_sleep_state(dev->dev.parent);
614620
priv->can.state = CAN_STATE_STOPPED;
615621
}
616622

@@ -1244,6 +1250,13 @@ int register_c_can_dev(struct net_device *dev)
12441250
struct c_can_priv *priv = netdev_priv(dev);
12451251
int err;
12461252

1253+
/* Deactivate pins to prevent DRA7 DCAN IP from being
1254+
* stuck in transition when module is disabled.
1255+
* Pins are activated in c_can_start() and deactivated
1256+
* in c_can_stop()
1257+
*/
1258+
pinctrl_pm_select_sleep_state(dev->dev.parent);
1259+
12471260
c_can_pm_runtime_enable(priv);
12481261

12491262
dev->flags |= IFF_ECHO; /* we support local echo */

0 commit comments

Comments
 (0)