aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2014-11-14 10:40:13 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-11-17 06:19:27 -0500
commit3973c526ae9cda5959bf6ef8ed936c46845eb774 (patch)
treeebb282eb389d9b6b0a16a3d8fb517ff3701c2b07
parent0741bfb9395ad176be91f66d2ef3f6f669e27890 (diff)
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>
-rw-r--r--drivers/net/can/c_can/c_can.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 8e78bb48f5a4..f94a9fa60488 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -35,6 +35,7 @@
35#include <linux/list.h> 35#include <linux/list.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/pm_runtime.h> 37#include <linux/pm_runtime.h>
38#include <linux/pinctrl/consumer.h>
38 39
39#include <linux/can.h> 40#include <linux/can.h>
40#include <linux/can/dev.h> 41#include <linux/can/dev.h>
@@ -603,6 +604,8 @@ static int c_can_start(struct net_device *dev)
603 604
604 priv->can.state = CAN_STATE_ERROR_ACTIVE; 605 priv->can.state = CAN_STATE_ERROR_ACTIVE;
605 606
607 /* activate pins */
608 pinctrl_pm_select_default_state(dev->dev.parent);
606 return 0; 609 return 0;
607} 610}
608 611
@@ -611,6 +614,9 @@ static void c_can_stop(struct net_device *dev)
611 struct c_can_priv *priv = netdev_priv(dev); 614 struct c_can_priv *priv = netdev_priv(dev);
612 615
613 c_can_irq_control(priv, false); 616 c_can_irq_control(priv, false);
617
618 /* deactivate pins */
619 pinctrl_pm_select_sleep_state(dev->dev.parent);
614 priv->can.state = CAN_STATE_STOPPED; 620 priv->can.state = CAN_STATE_STOPPED;
615} 621}
616 622
@@ -1244,6 +1250,13 @@ int register_c_can_dev(struct net_device *dev)
1244 struct c_can_priv *priv = netdev_priv(dev); 1250 struct c_can_priv *priv = netdev_priv(dev);
1245 int err; 1251 int err;
1246 1252
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
1247 c_can_pm_runtime_enable(priv); 1260 c_can_pm_runtime_enable(priv);
1248 1261
1249 dev->flags |= IFF_ECHO; /* we support local echo */ 1262 dev->flags |= IFF_ECHO; /* we support local echo */