diff options
author | Nikita Edward Baruzdin <nebaruzdin@gmail.com> | 2014-07-11 16:13:20 +0400 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2014-07-15 09:34:23 +0200 |
commit | dcf9e152670ea74dec24ec9ad57c495e631edba9 (patch) | |
tree | 268d40c8d30383c0c2230bd176ccae533e906297 /drivers/net/can | |
parent | 4b9e1bab12c9b6de965268c2fbe6ebbb35dddd89 (diff) |
can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
This adds support for hardware loopback in SJA1000 by utilising its self
reception request (SRR) feature. Upon SRR the message is transmitted and
received simultaneously, meaning you can't have hardware loopback
without actually sending a message to the CAN bus in case of SJA1000.
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.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index f31499a32d7..45400d9aeed 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c @@ -278,6 +278,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb, uint8_t dlc; canid_t id; uint8_t dreg; + u8 cmd_reg_val = 0x00; int i; if (can_dropped_invalid_skb(dev, skb)) @@ -312,9 +313,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb, can_put_echo_skb(skb, dev, 0); if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) - sja1000_write_cmdreg(priv, CMD_TR | CMD_AT); + cmd_reg_val |= CMD_AT; + + if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) + cmd_reg_val |= CMD_SRR; else - sja1000_write_cmdreg(priv, CMD_TR); + cmd_reg_val |= CMD_TR; + + sja1000_write_cmdreg(priv, cmd_reg_val); return NETDEV_TX_OK; } @@ -622,9 +628,11 @@ struct net_device *alloc_sja1000dev(int sizeof_priv) priv->can.do_set_bittiming = sja1000_set_bittiming; priv->can.do_set_mode = sja1000_set_mode; priv->can.do_get_berr_counter = sja1000_get_berr_counter; - priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | - CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LISTENONLY | - CAN_CTRLMODE_ONE_SHOT; + priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | + CAN_CTRLMODE_LISTENONLY | + CAN_CTRLMODE_3_SAMPLES | + CAN_CTRLMODE_ONE_SHOT | + CAN_CTRLMODE_BERR_REPORTING; spin_lock_init(&priv->cmdreg_lock); |