summaryrefslogtreecommitdiff
path: root/drivers/net/can
diff options
context:
space:
mode:
authorNikita Edward Baruzdin <nebaruzdin@gmail.com>2014-07-11 16:13:23 +0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-07-15 09:34:27 +0200
commit5b853ec3494e34eb4882f65ebbcd04b495ff3c85 (patch)
treefe4a2a3badfbaadaf8422ea5e0f6f9d3b7f47ce8 /drivers/net/can
parentdcf9e152670ea74dec24ec9ad57c495e631edba9 (diff)
downloadlinux-5b853ec3494e34eb4882f65ebbcd04b495ff3c85.tar.gz
can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK
SJA1000 has a self test mode (STM) which does not require acknowledgement for the successful message transmission. In this mode a node test is possible without any other active node on the bus. This patch adds a possibility to set STM for SJA1000 controller through specifying the corresponding CAN_CTRLMODE_PRESUME_ACK netlink flag. Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/sja1000/sja1000.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 45400d9aeedb..d1692154ed1b 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -141,6 +141,7 @@ static void set_normal_mode(struct net_device *dev)
{
struct sja1000_priv *priv = netdev_priv(dev);
unsigned char status = priv->read_reg(priv, SJA1000_MOD);
+ u8 mod_reg_val = 0x00;
int i;
for (i = 0; i < 100; i++) {
@@ -158,9 +159,10 @@ static void set_normal_mode(struct net_device *dev)
/* set chip to normal mode */
if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
- priv->write_reg(priv, SJA1000_MOD, MOD_LOM);
- else
- priv->write_reg(priv, SJA1000_MOD, 0x00);
+ mod_reg_val |= MOD_LOM;
+ if (priv->can.ctrlmode & CAN_CTRLMODE_PRESUME_ACK)
+ mod_reg_val |= MOD_STM;
+ priv->write_reg(priv, SJA1000_MOD, mod_reg_val);
udelay(10);
@@ -632,7 +634,8 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_3_SAMPLES |
CAN_CTRLMODE_ONE_SHOT |
- CAN_CTRLMODE_BERR_REPORTING;
+ CAN_CTRLMODE_BERR_REPORTING |
+ CAN_CTRLMODE_PRESUME_ACK;
spin_lock_init(&priv->cmdreg_lock);