Skip to contentSkip to conversation

dt-bindings: can: rockchip: add rk3588 CAN-FD compatible

PATCH Superseded Cunhao Lu 3 participants 8 messages Jul 3 1 message not in the archive

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Cunhao Lu

author
#1 lore raw

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

In reply to a message not in the archive

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
author
#3 lore raw

PATCH v4 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.

---
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
#6 lore raw

PATCH v4 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 base-board, so enable support for it there.

At least on RK3588-Tiger, the CAN clocks default to 99MHz, limiting usable CAN bitrates without skew. Errata documentation mentions 300MHz as the default frequency on RK3568, so replicate this here to allow more bitrates.

---
 arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts +6 -0
index 873fbeb8daa1..6273e695b039 100644
@@ -155,6 +155,12 @@ vddd_audio_1v6: regulator-vddd-audio-1v6 {
 	};
 };
 
+&can0 {
+	assigned-clocks = <&cru CLK_CAN0>;
+	assigned-clock-rates = <300000000>;
+	status = "okay";
+};
+
 &combphy2_psu {
 	status = "okay";
 };
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v4 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
Reviewed-by on v4 3/4
#4 lore raw

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

In reply to Cunhao Lu

Hi Cunhao,

Quoted 7 lines · Cunhao Lu

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.

Thanks!
Quentin

#7 lore raw

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

In reply to Cunhao Lu

Hi Heiko, Cunhao,

Quoted 21 lines · Cunhao Lu

From: Heiko Stuebner <[email protected]>

CAN0 is piped through the Q7-connector to the CAN-Header on the Haikou base-board, so enable support for it there.

At least on RK3588-Tiger, the CAN clocks default to 99MHz, limiting usable CAN bitrates without skew. Errata documentation mentions 300MHz as the default frequency on RK3568, so replicate this here to allow more bitrates.

---
  arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts | 6 ++++++
  1 file changed, 6 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts +0 -0
index 873fbeb8daa1..6273e695b039 100644

arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts vddd_audio_1v6: regulator-vddd-audio-1v6 { · line 160

Quoted 6 lines
arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts +3 -0
@@ -155,6 +155,12 @@ vddd_audio_1v6: regulator-vddd-audio-1v6 {
  	};
  };
 
+&can0 {
+	assigned-clocks = <&cru CLK_CAN0>;
+	assigned-clock-rates = <300000000>;

Why is this not SoC-specific? We are only routing the signal from the SoC after all.

If it cannot be put into rk3588-base.dtsi for some reason and is product-specific... Why is this in the baseboard DTS and not in the SoM DTSI? I would like to avoid our customers to have to copy things over if they should just work on their baseboard too if they don't do crazy things there.

I'll try to find time to test the three CAN controllers on RK3588 Jaguar with the CAN1-CAN2-UART4 Mezzanine adapter board and will contribute an overlay for that if it goes well. I don't have a CAN-FD adapter though but I hope they reused the exact same IP for the three controllers in the SoC :)

Cheers,
Quentin

maintainer
#8 lore raw

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

Am Freitag, 3. Juli 2026, 16:05:18 Mitteleuropäische Sommerzeit schrieb Quentin Schulz:

Quoted 27 lines

Hi Heiko, Cunhao,

Quoted 24 lines · Cunhao Lu

From: Heiko Stuebner <[email protected]>

CAN0 is piped through the Q7-connector to the CAN-Header on the Haikou base-board, so enable support for it there.

At least on RK3588-Tiger, the CAN clocks default to 99MHz, limiting usable CAN bitrates without skew. Errata documentation mentions 300MHz as the default frequency on RK3568, so replicate this here to allow more bitrates.

---
  arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts | 6 ++++++
  1 file changed, 6 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts +0 -0
index 873fbeb8daa1..6273e695b039 100644
@@ -155,6 +155,12 @@ vddd_audio_1v6: regulator-vddd-audio-1v6 {
  	};
  };
 
Quoted 6 lines

arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts vddd_audio_1v6: regulator-vddd-audio-1v6 { · line 160

Quoted 3 lines
arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts +3 -0
+&can0 {
+	assigned-clocks = <&cru CLK_CAN0>;
+	assigned-clock-rates = <300000000>;

Why is this not SoC-specific? We are only routing the signal from the SoC after all.

My main reason was that I have no clue what a reasonable controller frequency is. The default on Tiger on boot is 99MHz, which causes problems with accurate rates.

Similarly the controller has issues with low clock rates (erratum 5 if I'm not mistaken) and ther Mark wrote that at 300MHz the issue is less visible. So I took that frequency, but have no clue what the "right" frequency is.

Similarly, only Renesas socs seem to set their can frequency in the DT and that to 40MHz.

In the Rockchip vendor-kernel I've seen rates to set to 150MHz, 200MHz (or left alone) on a board-level

rk3568-ok3568c.dts even sets both 150MHZ AND 200MHz depending on the CAN controller (200 for can0+1, 150 for can2) .

This does suggest the usable frequency being specific to the board-design.

Quoted 5 lines

If it cannot be put into rk3588-base.dtsi for some reason and is product-specific... Why is this in the baseboard DTS and not in the SoM DTSI? I would like to avoid our customers to have to copy things over if they should just work on their baseboard too if they don't do crazy things there.

We can of course move the clk-rate to the tiger.dtsi.
(This should not affect the rest of the series, as I'll be applying the dts patches anyway)

Heiko

Quoted 5 lines

I'll try to find time to test the three CAN controllers on RK3588 Jaguar with the CAN1-CAN2-UART4 Mezzanine adapter board and will contribute an overlay for that if it goes well. I don't have a CAN-FD adapter though but I hope they reused the exact same IP for the three controllers in the SoC :)

author
#5 lore raw

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

In reply to Quentin Schulz

Hi Quentin,

Quoted 8 lines

 > 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.

Thanks for the review and for the Reviewed-by tag.

Best regards,
Cunhao