Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH] net: can: ifi: Configure transmitter delay
@ 2016-09-19 19:34 Marek Vasut
  2016-09-21  8:36 ` Marc Kleine-Budde
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2016-09-19 19:34 UTC (permalink / raw)
  To: linux-can
  Cc: Marek Vasut, Marc Kleine-Budde, Mark Rutland, Oliver Hartkopp,
	Wolfgang Grandegger

Configure the transmitter delay register at +0x1c to correctly handle
the CAN FD bitrate switch (BRS). This moves the SSP (secondary sample
point) to a proper offset, so that the TDC mechanism works and won't
generate error frames on the CAN link.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Wolfgang Grandegger <wg@grandegger.com>
---
 drivers/net/can/ifi_canfd/ifi_canfd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 2d1d22e..368bb07 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -81,6 +81,10 @@
 #define IFI_CANFD_TIME_SET_TIMEA_4_12_6_6	BIT(15)
 
 #define IFI_CANFD_TDELAY			0x1c
+#define IFI_CANFD_TDELAY_DEFAULT		0xb
+#define IFI_CANFD_TDELAY_MASK			0x3fff
+#define IFI_CANFD_TDELAY_ABS			BIT(14)
+#define IFI_CANFD_TDELAY_EN			BIT(15)
 
 #define IFI_CANFD_ERROR				0x20
 #define IFI_CANFD_ERROR_TX_OFFSET		0
@@ -641,7 +645,7 @@ static void ifi_canfd_set_bittiming(struct net_device *ndev)
 	struct ifi_canfd_priv *priv = netdev_priv(ndev);
 	const struct can_bittiming *bt = &priv->can.bittiming;
 	const struct can_bittiming *dbt = &priv->can.data_bittiming;
-	u16 brp, sjw, tseg1, tseg2;
+	u16 brp, sjw, tseg1, tseg2, tdc;
 
 	/* Configure bit timing */
 	brp = bt->brp - 2;
@@ -664,6 +668,11 @@ static void ifi_canfd_set_bittiming(struct net_device *ndev)
 	       (brp << IFI_CANFD_TIME_PRESCALE_OFF) |
 	       (sjw << IFI_CANFD_TIME_SJW_OFF_7_9_8_8),
 	       priv->base + IFI_CANFD_FTIME);
+
+	/* Configure transmitter delay */
+	tdc = (dbt->brp * (dbt->phase_seg1 + 1)) & IFI_CANFD_TDELAY_MASK;
+	writel(IFI_CANFD_TDELAY_EN | IFI_CANFD_TDELAY_ABS | tdc,
+	       priv->base + IFI_CANFD_TDELAY);
 }
 
 static void ifi_canfd_set_filter(struct net_device *ndev, const u32 id,
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* pull-request: can 2016-09-21
@ 2016-09-21  8:43 Marc Kleine-Budde
  2016-09-21  8:43 ` [PATCH] net: can: ifi: Configure transmitter delay Marc Kleine-Budde
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2016-09-21  8:43 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel

Hello David,

this is another pull request of one patch for the upcoming linux-4.8 release.

Marek Vasut fixes the CAN-FD bit rate switch in the ifi driver by configuring
the transmitter delay.

regards,
Marc

---

The following changes since commit b5036cd4ed3173ab8cdbc85e2ba74acf46bafb51:

  ipmr, ip6mr: return lastuse relative to now (2016-09-21 00:58:23 -0400)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-4.8-20160921

for you to fetch changes up to 8d58790b832e13d6006d842037732304af357c3c:

  net: can: ifi: Configure transmitter delay (2016-09-21 10:32:24 +0200)

----------------------------------------------------------------
linux-can-fixes-for-4.8-20160921

----------------------------------------------------------------
Marek Vasut (1):
      net: can: ifi: Configure transmitter delay

 drivers/net/can/ifi_canfd/ifi_canfd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-21  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19 19:34 [PATCH] net: can: ifi: Configure transmitter delay Marek Vasut
2016-09-21  8:36 ` Marc Kleine-Budde
  -- strict thread matches above, loose matches on Subject: below --
2016-09-21  8:43 pull-request: can 2016-09-21 Marc Kleine-Budde
2016-09-21  8:43 ` [PATCH] net: can: ifi: Configure transmitter delay Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox