All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
To: linux-can@vger.kernel.org
Subject: [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK
Date: Wed,  9 Jul 2014 23:31:10 +0400	[thread overview]
Message-ID: <1404934273-19233-1-git-send-email-nebaruzdin@gmail.com> (raw)

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>
---
 drivers/net/can/sja1000/sja1000.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index f31499a..c480bce 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);
 
-- 
2.0.1


             reply	other threads:[~2014-07-09 19:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 19:31 Nikita Edward Baruzdin [this message]
2014-07-09 19:31 ` [PATCH 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
2014-07-09 19:31 ` [PATCH 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
2014-07-10 14:06   ` Oliver Hartkopp
2014-07-10 14:12     ` Marc Kleine-Budde
2014-07-11 13:18       ` Oliver Hartkopp
2014-07-11 14:42         ` Nikita Edward Baruzdin
2014-07-14 12:21     ` Marc Kleine-Budde
2014-07-15  1:32       ` Oliver Hartkopp
2014-07-09 19:31 ` [PATCH 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
2014-07-10 14:25 ` [PATCH 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
2014-07-11 12:13   ` [PATCH v2 " Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 2/4] can: netlink: Remove space before tab Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 3/4] can: netlink: Add CAN_CTRLMODE_PRESUME_ACK flag Nikita Edward Baruzdin
2014-07-11 12:13     ` [PATCH v2 4/4] can: sja1000: Add support for CAN_CTRLMODE_PRESUME_ACK Nikita Edward Baruzdin
2014-07-15  7:35     ` [PATCH v2 1/4] can: sja1000: Add support for CAN_CTRLMODE_LOOPBACK Marc Kleine-Budde
2014-07-15  8:44       ` Nikita Edward Baruzdin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1404934273-19233-1-git-send-email-nebaruzdin@gmail.com \
    --to=nebaruzdin@gmail.com \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.