Skip to contentSkip to conversation

can: rockchip: add RK3588 CAN support

PATCH Applied Cunhao Lu 5 participants 16 messages Jul 30 – Sep 2 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

Cunhao Lu

author
#0 lore raw

v6 cover can: rockchip: add RK3588 CAN support

Add support for the RK3588 CAN controller.

RK3588 integrates three CAN-FD controllers that are closely related to the existing Rockchip CAN-FD IP already supported in the kernel. The RK3588 variant is not fully compatible with RK3568v2 because the RX FIFO count register field has a different layout.

This series therefore:

- extends the existing Rockchip CAN-FD binding with the rockchip,rk3588-canfd compatible
- adds a dedicated RK3588 match entry and devtype in the driver
- describes the three CAN controller nodes in rk3588-base.dtsi
- enables CAN on the RK3588 Tiger Haikou board

RK3588 encodes RX_FIFO_CNT in bits 7:5 instead of 6:4. This difference was found by comparing Rockchip's vendor kernel 6.1 CAN support for RK3568 and RK3588, and was also confirmed by runtime testing.

RK3588 uses the existing erratum 5 empty-FIFO workaround. Based on Heiko's testing, this series also enables the erratum 6 workaround for extended frames being transmitted as standard frames.

CAN-FD is enabled for RK3588. The BRS bus-off issue seen in earlier testing was caused by the transmit delay compensation setting. With RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION programmed to 0 on RK3588, CAN-FD with BRS works in local testing.

Tested on an embedfire,rk3588-lubancat-5io board with can0/can1 directly connected, no other device on the bus, 60 Ohm bus termination, and a 300 MHz CAN clock. The test used 500 kbit/s arbitration bitrate and 1, 3 and 5 Mbit/s data bitrates. The 5 Mbit/s data phase test ran for 15 minutes with:

ip link set can0 type can bitrate 500000 sample-point 0.8 dbitrate 5000000 dsample-point 0.8 fd on berr-reporting on ip link set can1 type can bitrate 500000 sample-point 0.8 dbitrate 5000000 dsample-point 0.8 fd on berr-reporting on cangen can0 -I 2 -Li -Di -p 10 -f -g 1 -c32 -b
cansequence -rv can1 -f

The receiver reported continuous sequence wrap-around messages up to sequence wrap around (37219). Both interfaces reported 9528377 packets and 150667356 bytes, with 0 bus-errors, 0 error-warn, 0 error-pass and 0 bus-off events.

---
v5 -> v6:
- Move the CAN0 assigned clock properties from the Haikou carrier board
DTS to the Tiger SoM DTSI, as suggested by Quentin.
- Collect Quentin's Tested-by tag for the RK3588 CAN controller nodes.
- Link to v5: https://lore.kernel.org/lkml/[email protected]
v4 -> v5:
- collect Quentin's Reviewed-by tag for the RK3588 CAN controller nodes
- Link to v4: https://lore.kernel.org/lkml/[email protected]
v3 -> v4:
- disable TDC on RK3588 by programming
RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION to 0
- drop RKCANFD_QUIRK_CANFD_BROKEN for RK3588 and enable CAN-FD support
- document successful RK3588 CAN-FD/BRS testing at 500 kbit/s
arbitration bitrate and 1, 3 and 5 Mbit/s data bitrates
- collect Krzysztof's Acked-by tag for the binding patch
- Link to v3: https://lore.kernel.org/lkml/[email protected]
v2 -> v3:
- Move the Changelog below ---
- Collect Heiko's Reviewed-by and the driver patch Tested-by tag
- Use Co-developed-by for Heiko's RK3588 contributions and add his Signed-off-by
- Link to v2: https://lore.kernel.org/lkml/[email protected]
v1 -> v2:
- use real author name
- fold the single-compatible entries into an enum, as suggested by Krzysztof
- enable the erratum 6 workaround for RK3588 based on Heiko's testing
- add Heiko's RK3588 Tiger Haikou CAN enablement patch
- keep RKCANFD_QUIRK_CANFD_BROKEN enabled for RK3588 so CAN-FD stays disabled
- document the RK3588 CAN-FD/BRS bus-off failure mode
- Link to v1: https://lore.kernel.org/lkml/[email protected]

To: Marc Kleine-Budde <[email protected]>
To: [email protected]
To: Vincent Mailhol <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Heiko Stuebner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Cunhao Lu (3):
dt-bindings: can: rockchip: add rk3588 CAN-FD compatible
can: rockchip: add RK3588 CAN support
arm64: dts: rockchip: add CAN-FD nodes for RK3588

Heiko Stuebner (1):
arm64: dts: rockchip: Enable CAN controller on RK3588-Tiger-Haikou

 .../bindings/net/can/rockchip,rk3568v2-canfd.yaml  |  4 ++-
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi      | 39 ++++++++++++++++++++++
 .../boot/dts/rockchip/rk3588-tiger-haikou.dts      |  4 +++
 arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi     |  5 +++
 drivers/net/can/rockchip/rockchip_canfd-core.c     | 17 ++++++++++
 drivers/net/can/rockchip/rockchip_canfd-rx.c       |  5 ++-
 drivers/net/can/rockchip/rockchip_canfd.h          | 14 +++++++-
 7 files changed, 85 insertions(+), 3 deletions(-)

---
base-commit: 0ce37745d4bfbc493f718169c3974898ffec8ee7
change-id: 20260702-master-8c52be892a3f

Best regards,

Signature · 1 line
Cunhao Lu <[email protected]>
#1 lore raw
Quoted 7 lines · Cunhao Lu

Add support for the RK3588 CAN controller.

RK3588 integrates three CAN-FD controllers that are closely related to the existing Rockchip CAN-FD IP already supported in the kernel. The RK3588 variant is not fully compatible with RK3568v2 because the RX FIFO count register field has a different layout.

Quoted 5 lines

This series therefore:

- extends the existing Rockchip CAN-FD binding with the rockchip,rk3588-canfd compatible
- adds a dedicated RK3588 match entry and devtype in the driver

I'll take the first 2 patches.

Quoted 2 lines

- describes the three CAN controller nodes in rk3588-base.dtsi
- enables CAN on the RK3588 Tiger Haikou board

The DT changes should probably go via the rockchip tree.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
maintainer
#2 lore raw

Am Montag, 17. August 2026, 18:23:03 Mitteleuropäische Sommerzeit schrieb Marc Kleine-Budde:

Quoted 14 lines · Cunhao Lu
Quoted 7 lines

Add support for the RK3588 CAN controller.

RK3588 integrates three CAN-FD controllers that are closely related to the existing Rockchip CAN-FD IP already supported in the kernel. The RK3588 variant is not fully compatible with RK3568v2 because the RX FIFO count register field has a different layout.

Quoted 5 lines

This series therefore:

- extends the existing Rockchip CAN-FD binding with the rockchip,rk3588-canfd compatible
- adds a dedicated RK3588 match entry and devtype in the driver

Quoted 6 lines

I'll take the first 2 patches.

Quoted 2 lines

- describes the three CAN controller nodes in rk3588-base.dtsi
- enables CAN on the RK3588 Tiger Haikou board

The DT changes should probably go via the rockchip tree.

yep :-) .

I'll pick those up after the merge-window.

Heiko

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#4 lore raw

PATCH v6 1/4 dt-bindings: can: rockchip: add rk3588 CAN-FD compatible

RK3588 integrates a Rockchip CAN-FD controller variant that is not fully compatible with RK3568v2. The RX FIFO count register field is encoded in bits 7:5 on RK3588, while RK3568v2 uses bits 6:4.

Add a dedicated rockchip,rk3588-canfd compatible to describe this variant. Do not use rockchip,rk3568v2-canfd as a fallback, because that would describe a register layout that does not match the hardware.

---
v3 -> v4:
- Collect Krzysztof's Acked-by tag.
v2 -> v3:
- Move the Changelog below ---
- Collect Heiko's Reviewed-by tag
v1 -> v2:
- Use enum for the single-compatible entries, as suggested by Krzysztof.
- Reword the commit message to explain the hardware difference instead of referring to Linux driver match data.

---
 .../devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml          | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml +3 -1
index a077c0330013..81e2b6dfeb02 100644
@@ -16,7 +16,9 @@ allOf:
 properties:
   compatible:
     oneOf:
-      - const: rockchip,rk3568v2-canfd
+      - enum:
+          - rockchip,rk3568v2-canfd
+          - rockchip,rk3588-canfd
       - items:
           - const: rockchip,rk3568v3-canfd
           - const: rockchip,rk3568v2-canfd
Signature · 1 line
2.34.1
maintainer Applied
#5 lore raw

Re: (subset) [PATCH v6 1/4] dt-bindings: can: rockchip: add rk3588 CAN-FD compatible

Quoted 9 lines · Cunhao Lu

RK3588 integrates a Rockchip CAN-FD controller variant that is not fully compatible with RK3568v2. The RX FIFO count register field is encoded in bits 7:5 on RK3588, while RK3568v2 uses bits 6:4.

Add a dedicated rockchip,rk3588-canfd compatible to describe this variant. Do not use rockchip,rk3568v2-canfd as a fallback, because that would describe a register layout that does not match the hardware.

[...]

Applied, thanks!

[3/4] arm64: dts: rockchip: add CAN-FD nodes for RK3588

      commit: 685b81f8c717b0f7ec7219f35ead626758ef3aec
[4/4] arm64: dts: rockchip: Enable CAN controller on RK3588-Tiger-Haikou
      commit: 0fb792388d2d39e35b7b366f491f846a7ebd8630

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>
author
#6 lore raw

PATCH v6 2/4 can: rockchip: add RK3588 CAN support

In reply to a message not in the archive

Add support for the RK3588 CAN controller by introducing a dedicated model ID and OF match entry.

The block is closely related to the existing RK3568 variants, but it cannot reuse their match data unchanged. In particular, RK3588 encodes RX_FIFO_CNT in bits 7:5 instead of 6:4, so the RX path needs SoC-specific handling.

The RX FIFO count bitfield difference was found by comparing Rockchip's vendor kernel 6.1 CAN support for RK3568 and RK3588. Runtime testing on RK3588 also confirms that bits 7:5 are needed.

Enable the existing erratum 5 empty-FIFO workaround for RK3588. Heiko reproduced erratum 6 on RK3588, so enable that workaround as well.

CAN-FD is enabled for RK3588. The BRS bus-off issue seen in earlier testing was caused by the transmit delay compensation setting. With RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION programmed to 0 on RK3588, CAN-FD with BRS works in local testing.

Tested on an embedfire,rk3588-lubancat-5io board with can0/can1 directly connected, no other device on the bus, 60 Ohm bus termination, and a 300 MHz CAN clock. Runtime testing used 500 kbit/s arbitration bitrate and 1, 3 and 5 Mbit/s data bitrates. The 5 Mbit/s data phase test ran for 15 minutes with cangen using BRS and cansequence on the receiver. Both interfaces reported 9528377 packets and 150667356 bytes, with 0 bus-errors, 0 error-warn, 0 error-pass and 0 bus-off events.

---
v3 -> v4:
- Disable TDC on RK3588 by programming RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION to 0.
- Drop RKCANFD_QUIRK_CANFD_BROKEN for RK3588 and enable CAN-FD support.
- Document successful RK3588 CAN-FD/BRS testing.
v2 -> v3:
- Use Co-developed-by for Heiko's RK3588 contributions and add his Signed-off-by
- Collect Heiko's Reviewed-by and Tested-by tags

---
 drivers/net/can/rockchip/rockchip_canfd-core.c | 17 +++++++++++++++++
 drivers/net/can/rockchip/rockchip_canfd-rx.c   |  5 ++++-
 drivers/net/can/rockchip/rockchip_canfd.h      | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)
drivers/net/can/rockchip/rockchip_canfd-core.c +17 -0
index 29de0c01e4ed..37c1c22c40c9 100644
@@ -50,6 +50,12 @@ static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3568v3 = {
 		RKCANFD_QUIRK_CANFD_BROKEN,
 };
 
+static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3588 = {
+	.model = RKCANFD_MODEL_RK3588,
+	.quirks = RKCANFD_QUIRK_RK3568_ERRATUM_5 |
+		RKCANFD_QUIRK_RK3568_ERRATUM_6,
+};
+
 static const char *__rkcanfd_get_model_str(enum rkcanfd_model model)
 {
 	switch (model) {
@@ -57,6 +63,8 @@ static const char *__rkcanfd_get_model_str(enum rkcanfd_model model)
 		return "rk3568v2";
 	case RKCANFD_MODEL_RK3568V3:
 		return "rk3568v3";
+	case RKCANFD_MODEL_RK3588:
+		return "rk3588";
 	}
 
 	return "<unknown>";
@@ -148,6 +156,12 @@ static int rkcanfd_set_bittiming(struct rkcanfd_priv *priv)
 
 	rkcanfd_write(priv, RKCANFD_REG_FD_DATA_BITTIMING, reg_dbt);
 
+	/* RK3588 CAN-FD BRS works with TDC disabled. */
+	if (priv->devtype_data.model == RKCANFD_MODEL_RK3588) {
+		rkcanfd_write(priv, RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION, 0);
+		return 0;
+	}
+
 	tdco = (priv->can.clock.freq / dbt->bitrate) * 2 / 3;
 	tdco = min(tdco, FIELD_MAX(RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION_TDC_OFFSET));
 
@@ -846,6 +860,9 @@ static const struct of_device_id rkcanfd_of_match[] = {
 	}, {
 		.compatible = "rockchip,rk3568v3-canfd",
 		.data = &rkcanfd_devtype_data_rk3568v3,
+	}, {
+		.compatible = "rockchip,rk3588-canfd",
+		.data = &rkcanfd_devtype_data_rk3588,
 	}, {
 		/* sentinel */
 	},
drivers/net/can/rockchip/rockchip_canfd-rx.c +4 -1
index 475c0409e215..24e87daa1df0 100644
@@ -281,7 +281,10 @@ rkcanfd_rx_fifo_get_len(const struct rkcanfd_priv *priv)
 {
 	const u32 reg = rkcanfd_read(priv, RKCANFD_REG_RX_FIFO_CTRL);
 
-	return FIELD_GET(RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_CNT, reg);
+	if (priv->devtype_data.model == RKCANFD_MODEL_RK3588)
+		return FIELD_GET(RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_CNT_RK3588, reg);
+
+	return FIELD_GET(RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_CNT_RK3568, reg);
 }
 
 int rkcanfd_handle_rx_int(struct rkcanfd_priv *priv)
drivers/net/can/rockchip/rockchip_canfd.h +13 -1
index 93131c7d7f54..95bea9bfd8a2 100644
@@ -214,7 +214,8 @@
 #define RKCANFD_REG_TXEVENT_FIFO_CTRL_TXE_FIFO_ENABLE BIT(0)
 
 #define RKCANFD_REG_RX_FIFO_CTRL 0x118
-#define RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_CNT GENMASK(6, 4)
+#define RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_CNT_RK3568 GENMASK(6, 4)
+#define RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_CNT_RK3588 GENMASK(7, 5)
 #define RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_FULL_WATERMARK GENMASK(3, 1)
 #define RKCANFD_REG_RX_FIFO_CTRL_RX_FIFO_ENABLE BIT(0)
 
@@ -331,6 +332,11 @@
  * rarely with the standard clock of 300 MHz, but almost immediately
  * at 80 MHz.
  *
+ * Tests on the rk3588 show the same empty FIFO condition.
+ * In that setup rx_fifo_empty_errors increments when the bus
+ * transitions from idle to high CAN-FD load and stops growing once
+ * the bus reaches a steady state.
+ *
  * To workaround this problem, check for empty FIFO with
  * rkcanfd_fifo_header_empty() in rkcanfd_handle_rx_int_one() and exit
  * early.
@@ -344,6 +350,8 @@
 /* Erratum 6: The CAN controller's transmission of extended frames may
  * intermittently change into standard frames
  *
+ * Tests on the rk3588 show the same problem.
+ *
  * Work around this issue by activating self reception (RXSTX). If we
  * have pending TX CAN frames, check all RX'ed CAN frames in
  * rkcanfd_rxstx_filter().
@@ -424,6 +432,9 @@
  *     cansequence -rv -i 1
  *
  * - TX starvation after repeated Bus-Off
+ *   Tests on the rk3588 show the same problem. In a
+ *   10-cycle Bus-Off recovery test, 9 cycles failed to send after the
+ *   controller restarted.
  *   To reproduce:
  *   host:
  *     sleep 3 && cangen can0 -I2 -Li -Di -p10 -g 0.0
@@ -434,6 +445,7 @@
 enum rkcanfd_model {
 	RKCANFD_MODEL_RK3568V2 = 0x35682,
 	RKCANFD_MODEL_RK3568V3 = 0x35683,
+	RKCANFD_MODEL_RK3588 = 0x3588,
 };
 
 struct rkcanfd_devtype_data {
Signature · 1 line
2.34.1
#7 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The rockchip_canfd driver unconditionally enables CAN-FD mode in the hardware, even if the user only requests Classic CAN mode. However, the data bit timing registers are only initialized if the user explicitly requests CAN-FD. This leaves the hardware configured to process CAN-FD frames but with uninitialized data bit timing, causing it to lose synchronization and transmit error frames, which disrupts valid CAN-FD traffic on the bus. --

--- Patch [2]: [PATCH v6 2/4] can: rockchip: add RK3588 CAN support --- commit c9bd120b397e60634c9f6a44ebe7ae2f872b4274
Author: Cunhao Lu <[email protected]>

can: rockchip: add RK3588 CAN support

Add support for the RK3588 CAN controller by introducing a dedicated model ID and OF match entry. Enable existing erratum 5 and 6 workarounds and enable CAN-FD for RK3588.

Quoted 4 lines
drivers/net/can/rockchip/rockchip_canfd-core.c +0 -0
index 29de0c01e4edc..37c1c22c40c9f 100644

[ ... ]

drivers/net/can/rockchip/rockchip_canfd-core.c static int rkcanfd_set_bittiming(struct rkcanfd_priv *priv) · line 164

Quoted 10 lines
drivers/net/can/rockchip/rockchip_canfd-core.c +6 -0
@@ -148,6 +156,12 @@ static int rkcanfd_set_bittiming(struct rkcanfd_priv *priv)
 
 	rkcanfd_write(priv, RKCANFD_REG_FD_DATA_BITTIMING, reg_dbt);
 
+	/* RK3588 CAN-FD BRS works with TDC disabled. */
+	if (priv->devtype_data.model == RKCANFD_MODEL_RK3588) {
+		rkcanfd_write(priv, RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION, 0);
+		return 0;
+	}
+

[Severity: High]
This isn't a bug introduced by this patch, but it appears there is a pre-existing issue with how CAN-FD is enabled that affects both RK3568 and the newly added RK3588 controllers.

In drivers/net/can/rockchip/rockchip_canfd-core.c:rkcanfd_chip_start(), the hardware is unconditionally configured to enable CAN-FD mode by setting RKCANFD_REG_MODE_CAN_FD_MODE_ENABLE.

However, in rkcanfd_set_bittiming() (just above the changes in this hunk), if the user configures the interface in Classic CAN mode, the initialization of data bit timing registers is skipped:

	if (!(priv->can.ctrlmode & CAN_CTRLMODE_FD))
		return 0;

Does this leave the hardware configured to process CAN-FD frames but with uninitialized data bit timing?

If a valid CAN-FD frame with BRS is sent by another node on the bus, could this controller attempt to switch to the uninitialized data bit timing, fail, and actively transmit an error frame, disrupting valid CAN-FD traffic?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#8 lore raw
Quoted 10 lines · On 30.07.2026 14:46:05, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues: - [High] The rockchip_canfd driver unconditionally enables CAN-FD mode in the hardware, even if the user only requests Classic CAN mode. However, the data bit timing registers are only initialized if the user explicitly requests CAN-FD. This leaves the hardware configured to process CAN-FD frames but with uninitialized data bit timing, causing it to lose synchronization and transmit error frames, which disrupts valid CAN-FD traffic on the bus. --

Good point. IIRC in non CAN-FD mode, the controller switches into a much less capable register layout and disables many features. We accept the downsides.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
#9 lore raw
In reply to Cunhao Lu
Quoted 78 lines · Cunhao Lu

Add support for the RK3588 CAN controller by introducing a dedicated model ID and OF match entry.

The block is closely related to the existing RK3568 variants, but it cannot reuse their match data unchanged. In particular, RK3588 encodes RX_FIFO_CNT in bits 7:5 instead of 6:4, so the RX path needs SoC-specific handling.

The RX FIFO count bitfield difference was found by comparing Rockchip's vendor kernel 6.1 CAN support for RK3568 and RK3588. Runtime testing on RK3588 also confirms that bits 7:5 are needed.

Enable the existing erratum 5 empty-FIFO workaround for RK3588. Heiko reproduced erratum 6 on RK3588, so enable that workaround as well.

CAN-FD is enabled for RK3588. The BRS bus-off issue seen in earlier testing was caused by the transmit delay compensation setting. With RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION programmed to 0 on RK3588, CAN-FD with BRS works in local testing.

Tested on an embedfire,rk3588-lubancat-5io board with can0/can1 directly connected, no other device on the bus, 60 Ohm bus termination, and a 300 MHz CAN clock. Runtime testing used 500 kbit/s arbitration bitrate and 1, 3 and 5 Mbit/s data bitrates. The 5 Mbit/s data phase test ran for 15 minutes with cangen using BRS and cansequence on the receiver. Both interfaces reported 9528377 packets and 150667356 bytes, with 0 bus-errors, 0 error-warn, 0 error-pass and 0 bus-off events.

---
v3 -> v4:
- Disable TDC on RK3588 by programming RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION to 0.
- Drop RKCANFD_QUIRK_CANFD_BROKEN for RK3588 and enable CAN-FD support.
- Document successful RK3588 CAN-FD/BRS testing.
v2 -> v3:
- Use Co-developed-by for Heiko's RK3588 contributions and add his Signed-off-by
- Collect Heiko's Reviewed-by and Tested-by tags

---
 drivers/net/can/rockchip/rockchip_canfd-core.c | 17 +++++++++++++++++
 drivers/net/can/rockchip/rockchip_canfd-rx.c   |  5 ++++-
 drivers/net/can/rockchip/rockchip_canfd.h      | 14 +++++++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)
drivers/net/can/rockchip/rockchip_canfd-core.c +8 -0
index 29de0c01e4ed..37c1c22c40c9 100644
@@ -50,6 +50,12 @@ static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3568v3 = {
 		RKCANFD_QUIRK_CANFD_BROKEN,
 };
 
+static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3588 = {
+	.model = RKCANFD_MODEL_RK3588,
+	.quirks = RKCANFD_QUIRK_RK3568_ERRATUM_5 |
+		RKCANFD_QUIRK_RK3568_ERRATUM_6,
+};
+
 static const char *__rkcanfd_get_model_str(enum rkcanfd_model model)
 {
 	switch (model) {
@@ -57,6 +63,8 @@ static const char *__rkcanfd_get_model_str(enum rkcanfd_model model)
 		return "rk3568v2";
 	case RKCANFD_MODEL_RK3568V3:
 		return "rk3568v3";
+	case RKCANFD_MODEL_RK3588:
+		return "rk3588";
 	}
 
 	return "<unknown>";

drivers/net/can/rockchip/rockchip_canfd-core.c static int rkcanfd_set_bittiming(struct rkcanfd_priv *priv) · line 164

Quoted 9 lines
drivers/net/can/rockchip/rockchip_canfd-core.c +6 -0
@@ -148,6 +156,12 @@ static int rkcanfd_set_bittiming(struct rkcanfd_priv *priv)
 
 	rkcanfd_write(priv, RKCANFD_REG_FD_DATA_BITTIMING, reg_dbt);
 
+	/* RK3588 CAN-FD BRS works with TDC disabled. */
+	if (priv->devtype_data.model == RKCANFD_MODEL_RK3588) {
+		rkcanfd_write(priv, RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION, 0);
+		return 0;
+	}
+

Can you attach the TDC to the CAN framework? See commit 5e1663810e11 ("can: mcp251xfd: fix TDC setting for low data bit rates"). And check if CAN-FD works on the rk3588 works?

Marc

drivers/net/can/rockchip/rockchip_canfd-core.c static int rkcanfd_set_bittiming(struct rkcanfd_priv *priv) · line 166

Quoted 2 lines
drivers/net/can/rockchip/rockchip_canfd-core.c +0 -0
 	tdco = (priv->can.clock.freq / dbt->bitrate) * 2 / 3;
 	tdco = min(tdco, FIELD_MAX(RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION_TDC_OFFSET));

--

Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |

Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |

author
#10 lore raw

Hi Marc,

Quoted 3 lines

Can you attach the TDC to the CAN framework? See commit 5e1663810e11 ("can: mcp251xfd: fix TDC setting for low data bit rates"). And check if CAN-FD works on the rk3588 works?

Could we leave the RK3588 TDC support out of this patch series for now?

I will test whether CAN-FD works on RK3588 with TDC integrated with the CAN framework and report the test result. If the testing shows that it works, I will enable it in a separate follow-up patch.

Thanks,
Cunhao

#11 lore raw
Quoted 7 lines · Cunhao Lu

Hi Marc,

Quoted 3 lines

Can you attach the TDC to the CAN framework? See commit 5e1663810e11 ("can: mcp251xfd: fix TDC setting for low data bit rates"). And check if CAN-FD works on the rk3588 works?

Could we leave the RK3588 TDC support out of this patch series for now?

..and mark the rk3588 as RKCANFD_QUIRK_CANFD_BROKEN for now? Fine with me.

Quoted 3 lines

I will test whether CAN-FD works on RK3588 with TDC integrated with the CAN framework and report the test result. If the testing shows that it works, I will enable it in a separate follow-up patch.

Sounds good,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
author
#12 lore raw

Hi Marc,

Quoted 7 lines
Quoted 5 lines

 > Can you attach the TDC to the CAN framework? See commit 5e1663810e11 > ("can: mcp251xfd: fix TDC setting for low data bit rates"). And check if > CAN-FD works on the rk3588 works?

 Could we leave the RK3588 TDC support out of this patch series for now?

..and mark the rk3588 as RKCANFD_QUIRK_CANFD_BROKEN for now? Fine with me.

I have finished testing the CAN-FD TDC integration on RK3588.

Enabling TDC makes the transmitter enter bus-off for every TDCO value tested. This includes the framework value (TDCO=48), TDCO=0, and the non-zero values 1, 8, 16, 24, 32, 40, 48 and 56. With TDCO=63, only one frame was received during a 10 second test, so that setting is not usable.

I checked the register definition against Rockchip RK3588 TRM V1.0-Part1-20220309.pdf. The driver uses CAN_TRANSMIT_DELAY_COMPENSATION at offset 0x108, with tdc_offset in bits 6:1 and tdc_enable in bit 0, which matches the TRM. Thus, the failure is not explained by an incorrect register address or field definition.

The test setup was:

  Board:             embedfire,rk3588-lubancat-5io
  CAN clock:         300 MHz
  Nominal bitrate:   500 kbit/s
  Data bitrate:      5 Mbit/s
  Sample points:     80% nominal, 80% data
  Bus:               can0 and can1 directly connected, 60 Ohm termination

With TDC disabled, about 29,775 frames were received in three seconds with no bus errors. With TDC enabled, can0 typically reached bus-off after about 15-31 bus errors.

This is a preliminary indication of a problem in the RK3588 CAN IP TDC path, although it is not sufficient to prove a silicon defect. In particular, the hardware-measured transmitter delay (TDCV) is not observable through the registers described by the TRM, so the TDC offset semantics still need to be verified independently.

TDC is not a mandatory feature for a CAN-FD implementation. It compensates the TX-to-RX loop delay when that delay would otherwise consume the timing margin before the normal sample point. Whether it must be enabled depends on the complete hardware path, including the controller, transceiver, PCB and bus. It is therefore not required solely because CAN-FD or a particular data bitrate is used.

On the board used for this test, CAN-FD runs reliably at 5 Mbit/s with TDC disabled and no lost frames. This demonstrates that RK3588 supports CAN-FD, while the maximum usable data bitrate still depends on the board design and its TX-to-RX delay. Boards with a longer delay may need a lower data bitrate, just as different CAN transceivers have different maximum data-rate specifications (for example, 8 Mbit/s for some devices and 5 Mbit/s for others).

In my opinion, enabling CAN-FD support on RK3588 is independent of TDC. TDC is an optimization for hardware paths that need additional TX-to-RX delay compensation, rather than a prerequisite for CAN-FD operation. I would therefore still like to enable CAN-FD support for RK3588 in this series while keeping TDC disabled. TDC support can be investigated separately in a follow-up patch once its behavior has been understood.

Best regards,
Cunhao

author
#13 lore raw
In reply to Marc Kleine-Budde

Hi Marc,

I would like to follow up on my previous email regarding RK3588 CAN-FD and TDC.

As reported previously:

Quoted 4 lines

Enabling TDC makes the transmitter enter bus-off for every TDCO value tested. This includes the framework value (TDCO=48), TDCO=0, and the non-zero values 1, 8, 16, 24, 32, 40, 48 and 56. With TDCO=63, only one frame was received during a 10 second test, so that setting is not usable.

I have now also completed a 20-hour CAN-FD test with TDC disabled, using the same setup as described in my previous email:

  Board:             embedfire,rk3588-lubancat-5io
  CAN clock:         300 MHz
  Nominal bitrate:   500 kbit/s
  Data bitrate:      5 Mbit/s
  Sample points:     80% nominal, 80% data
  Bus:               can0 and can1 directly connected, 60 Ohm termination

The 5 Mbit/s data bitrate is the maximum supported by the CAN transceivers on this board.

No frames were lost during the 20-hour test, and no CAN errors were reported in the kernel log. The final ifconfig statistics were:

can0 RX: 607939922 packets, 9613049987 bytes (9.6 GB) can0 TX: 607939922 packets, 9613049987 bytes (9.6 GB) can1 RX: 607939922 packets, 9613049987 bytes (9.6 GB)

The error, dropped, and overrun counters were all zero. The kernel log contained fewer than ten TXE_FIFO_FULL_INT informational messages during the entire test, with no corresponding frame loss, bus error, or bus-off event.

These results show that, on this hardware setup, RK3588 CAN-FD operates reliably at 5 Mbit/s when TDC is disabled, while enabling TDC prevents normal CAN communication.

Would it therefore be acceptable to drop RKCANFD_QUIRK_CANFD_BROKEN for RK3588 and enable CAN-FD support while explicitly keeping TDC disabled?

Alternatively, should I follow your earlier suggestion and add RKCANFD_QUIRK_CANFD_BROKEN back for RK3588 in this series?

Best regards,
Cunhao

author
#14 lore raw

PATCH v6 3/4 arm64: dts: rockchip: add CAN-FD nodes for RK3588

In reply to a message not in the archive

Describe the three CAN-FD controllers integrated in RK3588 in the base SoC .dtsi.

Add CAN0, CAN1 and CAN2 nodes with their register ranges, interrupts, clocks and resets, and keep them disabled by default so board DTS files can enable them as needed.

---
v5 -> v6:
- Collect Quentin's Tested-by tag
v4 -> v5:
- Collect Quentin's Reviewed-by tag
v2 -> v3:
- Use Co-developed-by for Heiko's RK3588 contributions and add his Signed-off-by

---
 arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 39 +++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +39 -0
index fc1fdbfd3162..b340973775c5 100644
@@ -2648,6 +2648,45 @@ dmac1: dma-controller@fea30000 {
 		#dma-cells = <1>;
 	};
 
+	can0: can@fea50000 {
+		compatible = "rockchip,rk3588-canfd";
+		reg = <0x0 0xfea50000 0x0 0x1000>;
+		interrupts = <GIC_SPI 341 IRQ_TYPE_LEVEL_HIGH 0>;
+		clocks = <&cru CLK_CAN0>, <&cru PCLK_CAN0>;
+		clock-names = "baud", "pclk";
+		resets = <&cru SRST_CAN0>, <&cru SRST_P_CAN0>;
+		reset-names = "core", "apb";
+		pinctrl-names = "default";
+		pinctrl-0 = <&can0m0_pins>;
+		status = "disabled";
+	};
+
+	can1: can@fea60000 {
+		compatible = "rockchip,rk3588-canfd";
+		reg = <0x0 0xfea60000 0x0 0x1000>;
+		interrupts = <GIC_SPI 342 IRQ_TYPE_LEVEL_HIGH 0>;
+		clocks = <&cru CLK_CAN1>, <&cru PCLK_CAN1>;
+		clock-names = "baud", "pclk";
+		resets = <&cru SRST_CAN1>, <&cru SRST_P_CAN1>;
+		reset-names = "core", "apb";
+		pinctrl-names = "default";
+		pinctrl-0 = <&can1m0_pins>;
+		status = "disabled";
+	};
+
+	can2: can@fea70000 {
+		compatible = "rockchip,rk3588-canfd";
+		reg = <0x0 0xfea70000 0x0 0x1000>;
+		interrupts = <GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH 0>;
+		clocks = <&cru CLK_CAN2>, <&cru PCLK_CAN2>;
+		clock-names = "baud", "pclk";
+		resets = <&cru SRST_CAN2>, <&cru SRST_P_CAN2>;
+		reset-names = "core", "apb";
+		pinctrl-names = "default";
+		pinctrl-0 = <&can2m0_pins>;
+		status = "disabled";
+	};
+
 	i2c1: i2c@fea90000 {
 		compatible = "rockchip,rk3588-i2c", "rockchip,rk3399-i2c";
 		reg = <0x0 0xfea90000 0x0 0x1000>;
Signature · 1 line
2.34.1
author
#15 lore raw

PATCH v6 4/4 arm64: dts: rockchip: Enable CAN controller on RK3588-Tiger-Haikou

In reply to a message not in the archive

From: Heiko Stuebner <[email protected]>

CAN0 is piped through the Q7 connector to the CAN header on the Haikou baseboard, so enable support for it there.

At least on RK3588 Tiger, the CAN clocks default to 99 MHz, limiting usable CAN bitrates without skew. The RK3568 errata documentation mentions 300 MHz as the default frequency, so request the same rate to allow more bitrates.

The CAN clock setup is common to the Tiger SoM regardless of which carrier board exposes CAN0, so place it in rk3588-tiger.dtsi. Keep CAN0 disabled by default and enable it in rk3588-tiger-haikou.dts, where the carrier board routes it to a transceiver.

---
 arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts | 4 ++++
 arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi       | 5 +++++
 2 files changed, 9 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts +4 -0
index 873fbeb8daa1..6c57c9f54a30 100644
@@ -155,6 +155,10 @@ vddd_audio_1v6: regulator-vddd-audio-1v6 {
 	};
 };
 
+&can0 {
+	status = "okay";
+};
+
 &combphy2_psu {
 	status = "okay";
 };
arch/arm64/boot/dts/rockchip/rk3588-tiger.dtsi +5 -0
index 139f70e7bbd9..161c89c62bcd 100644
@@ -90,6 +90,11 @@ vcc5v0_sys: regulator-vcc5v0-sys {
 	};
 };
 
+&can0 {
+	assigned-clocks = <&cru CLK_CAN0>;
+	assigned-clock-rates = <300000000>;
+};
+
 &cpu_b0 {
 	cpu-supply = <&vdd_cpu_big0_s0>;
 };
Signature · 1 line
2.34.1
Reviewed-by on v6 4/4
#16 lore raw

Re: [PATCH v6 4/4] arm64: dts: rockchip: Enable CAN controller on RK3588-Tiger-Haikou

Hi Cunhao,

Quoted 10 lines · Cunhao Lu

From: Heiko Stuebner <[email protected]>

CAN0 is piped through the Q7 connector to the CAN header on the Haikou baseboard, so enable support for it there.

At least on RK3588 Tiger, the CAN clocks default to 99 MHz, limiting usable CAN bitrates without skew. The RK3568 errata documentation mentions 300 MHz as the default frequency, so request the same rate to allow more bitrates.

Quoted 5 lines

The CAN clock setup is common to the Tiger SoM regardless of which carrier board exposes CAN0, so place it in rk3588-tiger.dtsi. Keep CAN0 disabled by default and enable it in rk3588-tiger-haikou.dts, where the carrier board routes it to a transceiver.

Thanks!
Quentin