From: Dong Aisheng <b29396@freescale.com>
To: linux-can@vger.kernel.org
Cc: netdev@vger.kernel.org, wg@grandegger.com, mkl@pengutronix.de,
devicetree@vger.kernel.org
Subject: [PATCH 3/3] can: m_can: add loopback and monitor mode support
Date: Fri, 27 Jun 2014 18:00:46 +0800 [thread overview]
Message-ID: <1403863246-18822-4-git-send-email-b29396@freescale.com> (raw)
In-Reply-To: <1403863246-18822-1-git-send-email-b29396@freescale.com>
add loopback and monitor mode support.
Signed-off-by: Dong Aisheng <b29396@freescale.com>
---
drivers/net/can/m_can.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/m_can.c b/drivers/net/can/m_can.c
index e4aed71..bbe8a7d 100644
--- a/drivers/net/can/m_can.c
+++ b/drivers/net/can/m_can.c
@@ -94,8 +94,12 @@ enum m_can_lec_type {
LEC_CRC_ERROR,
LEC_UNUSED,
};
+/* Test Register (TEST) */
+#define TEST_LBCK BIT(4)
/* CC Control Register(CCCR) */
+#define CCCR_TEST BIT(7)
+#define CCCR_MON BIT(5)
#define CCCR_CCE BIT(1)
#define CCCR_INIT BIT(0)
@@ -661,13 +665,13 @@ static int m_can_set_bittiming(struct net_device *dev)
* - configure rx fifo
* - accept non-matching frame into fifo 0
* - configure tx buffer
+ * - configure mode
* - setup bittiming
- * - TODO:
- * 1) other working modes support like monitor, loopback...
*/
static void m_can_chip_config(struct net_device *dev)
{
struct m_can_priv *priv = netdev_priv(dev);
+ u32 cccr, test;
m_can_config_endisable(priv, true);
@@ -694,6 +698,22 @@ static void m_can_chip_config(struct net_device *dev)
m_can_write(priv, M_CAN_RXF1C, (priv->rxf1_elems << RXFC_FS_OFF) |
RXFC_FWM_1 | (priv->mram_off + priv->rxf1_off));
+ cccr = m_can_read(priv, M_CAN_CCCR);
+ cccr &= ~(CCCR_TEST | CCCR_MON);
+ test = m_can_read(priv, M_CAN_TEST);
+ test &= ~TEST_LBCK;
+
+ if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
+ cccr |= CCCR_MON;
+
+ if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) {
+ cccr |= CCCR_TEST;
+ test |= TEST_LBCK;
+ }
+
+ m_can_write(priv, M_CAN_CCCR, cccr);
+ m_can_write(priv, M_CAN_TEST, test);
+
/* enable all interrupts */
m_can_write(priv, M_CAN_IR, IR_ALL_INT);
m_can_write(priv, M_CAN_IE, IR_ALL_INT);
--
1.7.8
next prev parent reply other threads:[~2014-06-27 10:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-27 10:00 [PATCH 0/3] can: m_can: add Bosch M_CAN controller support Dong Aisheng
2014-06-27 10:00 ` [PATCH 1/3] " Dong Aisheng
2014-06-27 12:35 ` Mark Rutland
2014-06-30 8:03 ` Dong Aisheng
2014-06-27 18:03 ` Oliver Hartkopp
2014-06-30 8:26 ` Dong Aisheng
2014-07-02 17:54 ` Oliver Hartkopp
2014-07-02 19:13 ` Marc Kleine-Budde
2014-07-03 3:48 ` Dong Aisheng
2014-07-03 7:12 ` Marc Kleine-Budde
2014-07-03 8:48 ` Dong Aisheng
[not found] ` <20140703084803.GA11012-KgLukfWpBlCctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2014-07-03 9:04 ` Marc Kleine-Budde
2014-07-03 9:09 ` Dong Aisheng
2014-07-03 9:20 ` Marc Kleine-Budde
2014-07-03 10:39 ` Dong Aisheng
2014-07-01 10:29 ` Marc Kleine-Budde
2014-07-02 6:20 ` Dong Aisheng
2014-07-02 7:57 ` Marc Kleine-Budde
2014-07-02 6:33 ` Dong Aisheng
2014-07-01 10:33 ` Marc Kleine-Budde
2014-06-27 10:00 ` [PATCH 2/3] can: m_can: add bus error handling Dong Aisheng
2014-07-01 10:37 ` Marc Kleine-Budde
2014-07-02 6:31 ` Dong Aisheng
2014-06-27 10:00 ` Dong Aisheng [this message]
2014-07-01 10:38 ` [PATCH 3/3] can: m_can: add loopback and monitor mode support Marc Kleine-Budde
2014-07-02 6:32 ` Dong Aisheng
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=1403863246-18822-4-git-send-email-b29396@freescale.com \
--to=b29396@freescale.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=wg@grandegger.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).