Skip to contentSkip to conversation

*arm64: Add CAN-FD support for R-Car V4M and Gray Hawk Single

PATCH Superseded Geert Uytterhoeven 3 participants 10 messages May 17, 2024 – May 21, 2024

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

cover *arm64: Add CAN-FD support for R-Car V4M and Gray Hawk Single

Hi all,

This patch series aims to add support for CAN-FD on the R-Car V4M SoC and the Gray Hawk Single development board.

Unfortunately it does not work: bringing up any CAN interface fails with:

rcar_canfd e6660000.can can0: channel 0 communication state failed RTNETLINK answers: Connection timed out

This error means that instructing the internal MCU to switch the CAN-FD channel to operational mode timed out, and the channel is still in reset mode.

The CAN-FD module on R-Car V4M is very similar to the one on R-Car V4H, but differ in some hardware parameters, as reflected by the Parameter Status Information part of the Global IP Version Register. However, none of this parameterization should have any impact on the driver, as the driver does not access any register that is impacted by the parameterization (except for the number of channels).

Channels 0 and 1 work fine on R-Car V4H. I have compared all register writes between V4H and V4M, and dumped and compared the full register block after a sucessful and failed bring-up of a channel, but there is no other failure indication in e.g. a status or error flag register...

Thanks for your comments!

Cong Dang (1):
clk: renesas: r8a779h0: Add CANFD clock

Duy Nguyen (2):
dt-bindings: can: renesas,rcar-canfd: Document R-Car V4M support
arm64: dts: renesas: r8a779h0: Add CAN-FD node

Geert Uytterhoeven (1):
arm64: dts: renesas: gray-hawk-single: Add CAN-FD support

 .../bindings/net/can/renesas,rcar-canfd.yaml  | 22 +++++++---
 .../dts/renesas/r8a779h0-gray-hawk-single.dts | 40 ++++++++++++++++++
 arch/arm64/boot/dts/renesas/r8a779h0.dtsi     | 41 +++++++++++++++++++
 drivers/clk/renesas/r8a779h0-cpg-mssr.c       |  1 +
 4 files changed, 98 insertions(+), 6 deletions(-)
Signature · 12 lines
2.34.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
author maintainer
#1 lore raw

PATCH 1/4 clk: renesas: r8a779h0: Add CANFD clock

From: Cong Dang <[email protected]>

Add the CANFD module clock on the Renesas R-Car V4M (R8A779H0) SoC.

---
Changes compared to the BSP:
- Change clock name from can-fd to canfd0,
- Change parent clock from CANFD to SASYNCPERD2.

---
 drivers/clk/renesas/r8a779h0-cpg-mssr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/renesas/r8a779h0-cpg-mssr.c +1 -0
index 079b55b30b23bd50..4b237bb2ca69dc2c 100644
@@ -176,6 +176,7 @@ static const struct mssr_mod_clk r8a779h0_mod_clks[] = {
 	DEF_MOD("avb0:rgmii0",	211,	R8A779H0_CLK_S0D8_HSC),
 	DEF_MOD("avb1:rgmii1",	212,	R8A779H0_CLK_S0D8_HSC),
 	DEF_MOD("avb2:rgmii2",	213,	R8A779H0_CLK_S0D8_HSC),
+	DEF_MOD("canfd0",	328,	R8A779H0_CLK_SASYNCPERD2),
 	DEF_MOD("hscif0",	514,	R8A779H0_CLK_SASYNCPERD1),
 	DEF_MOD("hscif1",	515,	R8A779H0_CLK_SASYNCPERD1),
 	DEF_MOD("hscif2",	516,	R8A779H0_CLK_SASYNCPERD1),
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH 2/4 dt-bindings: can: renesas,rcar-canfd: Document R-Car V4M support

In reply to Geert Uytterhoeven

From: Duy Nguyen <[email protected]>

Document support for the CAN-FD Interface on the Renesas R-Car V4M (R8A779H0) SoC, which supports up to four channels.

---
Changes compared to the BSP:
- Restrict number of channels to four.

---
 .../bindings/net/can/renesas,rcar-canfd.yaml  | 22 ++++++++++++++-----
 1 file changed, 16 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml +16 -6
index d3f45d29fa0a550a..7c5ac5d2e880bbb8 100644
@@ -32,6 +32,7 @@ properties:
           - enum:
               - renesas,r8a779a0-canfd     # R-Car V3U
               - renesas,r8a779g0-canfd     # R-Car V4H
+              - renesas,r8a779h0-canfd     # R-Car V4M
           - const: renesas,rcar-gen4-canfd # R-Car Gen4
 
       - items:
@@ -163,14 +164,23 @@ allOf:
           maxItems: 1
 
   - if:
-      not:
-        properties:
-          compatible:
-            contains:
-              const: renesas,rcar-gen4-canfd
+      properties:
+        compatible:
+          contains:
+            const: renesas,r8a779h0-canfd
     then:
       patternProperties:
-        "^channel[2-7]$": false
+        "^channel[5-7]$": false
+    else:
+      if:
+        not:
+          properties:
+            compatible:
+              contains:
+                const: renesas,rcar-gen4-canfd
+      then:
+        patternProperties:
+          "^channel[2-7]$": false
 
 unevaluatedProperties: false
 
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH 3/4 arm64: dts: renesas: r8a779h0: Add CAN-FD node

In reply to Geert Uytterhoeven

From: Duy Nguyen <[email protected]>

Add device nodes for the CAN-FD interface and the related external CAN clock on the Renesas R-Car V4M (R8A779H0) SoC.

---
Changes compared to the BSP:
- Add can_clk comment,
- Add "-clk" suffix to clock node name.

---
 arch/arm64/boot/dts/renesas/r8a779h0.dtsi | 41 +++++++++++++++++++++++
 1 file changed, 41 insertions(+)
arch/arm64/boot/dts/renesas/r8a779h0.dtsi +41 -0
index ea3d2b2de10b2999..3766652623fd8e5e 100644
@@ -14,6 +14,13 @@ / {
 	#address-cells = <2>;
 	#size-cells = <2>;
 
+	/* External CAN clock - to be overridden by boards that provide it */
+	can_clk: can-clk {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <0>;
+	};
+
 	cluster0_opp: opp-table-0 {
 		compatible = "operating-points-v2";
 		opp-shared;
@@ -635,6 +642,40 @@ hscif3: serial@e66a0000 {
 			status = "disabled";
 		};
 
+		canfd: can@e6660000 {
+			compatible = "renesas,r8a779h0-canfd",
+				     "renesas,rcar-gen4-canfd";
+			reg = <0 0xe6660000 0 0x8500>;
+			interrupts = <GIC_SPI 412 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 413 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "ch_int", "g_int";
+			clocks = <&cpg CPG_MOD 328>,
+				 <&cpg CPG_CORE R8A779H0_CLK_CANFD>,
+				 <&can_clk>;
+			clock-names = "fck", "canfd", "can_clk";
+			assigned-clocks = <&cpg CPG_CORE R8A779H0_CLK_CANFD>;
+			assigned-clock-rates = <80000000>;
+			power-domains = <&sysc R8A779H0_PD_ALWAYS_ON>;
+			resets = <&cpg 328>;
+			status = "disabled";
+
+			channel0 {
+				status = "disabled";
+			};
+
+			channel1 {
+				status = "disabled";
+			};
+
+			channel2 {
+				status = "disabled";
+			};
+
+			channel3 {
+				status = "disabled";
+			};
+		};
+
 		avb0: ethernet@e6800000 {
 			compatible = "renesas,etheravb-r8a779h0",
 				     "renesas,etheravb-rcar-gen4";
Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH 4/4 arm64: dts: renesas: gray-hawk-single: Add CAN-FD support

In reply to Geert Uytterhoeven

Enable CAN-FD channels 0 and 1 on the Gray Hawk Single development board:
- Channel 0 uses an NXP TJR1443AT CAN transceiver, which must be enabled through a GPIO,
- Channel 1 uses a Microchip MCP2558FD-H/SN CAN transceiver, which does not need explicit description.

Inspired by a patch for Gray Hawk in the BSP by Duy Nguyen.

---
Changes compared to the BSP:
- Add can_clk,
- Add missing can_transceiver0,
- Keep channels 2 and 3 disabled,
- Preserve sort order.

---
 .../dts/renesas/r8a779h0-gray-hawk-single.dts | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
arch/arm64/boot/dts/renesas/r8a779h0-gray-hawk-single.dts +40 -0
index cfbe8c8680cd8947..294ed2d5a17cbfd5 100644
@@ -22,6 +22,13 @@ aliases {
 		ethernet0 = &avb0;
 	};
 
+	can_transceiver0: can-phy0 {
+		compatible = "nxp,tjr1443";
+		#phy-cells = <0>;
+		enable-gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
+		max-bitrate = <5000000>;
+	};
+
 	chosen {
 		bootargs = "ignore_loglevel rw root=/dev/nfs ip=on";
 		stdout-path = "serial0:921600n8";
@@ -75,6 +82,24 @@ phy0: ethernet-phy@0 {
 	};
 };
 
+&can_clk {
+	clock-frequency = <40000000>;
+};
+
+&canfd {
+	pinctrl-0 = <&canfd0_pins>, <&canfd1_pins>, <&can_clk_pins>;
+	status = "okay";
+
+	channel0 {
+		status = "okay";
+		phys = <&can_transceiver0>;
+	};
+
+	channel1 {
+		status = "okay";
+	};
+};
+
 &extal_clk {
 	clock-frequency = <16666666>;
 };
@@ -174,6 +199,21 @@ pins_mii {
 		};
 	};
 
+	can_clk_pins: can-clk {
+		groups = "can_clk";
+		function = "can_clk";
+	};
+
+	canfd0_pins: canfd0 {
+		groups = "canfd0_data";
+		function = "canfd0";
+	};
+
+	canfd1_pins: canfd1 {
+		groups = "canfd1_data";
+		function = "canfd1";
+	};
+
 	hscif0_pins: hscif0 {
 		groups = "hscif0_data", "hscif0_ctrl";
 		function = "hscif0";
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH/RFC 4/4] arm64: dts: renesas: gray-hawk-single: Add CAN-FD support

Quoted 21 lines · Geert Uytterhoeven

Enable CAN-FD channels 0 and 1 on the Gray Hawk Single development board:
- Channel 0 uses an NXP TJR1443AT CAN transceiver, which must be enabled through a GPIO,
- Channel 1 uses a Microchip MCP2558FD-H/SN CAN transceiver, which does not need explicit description.

Inspired by a patch for Gray Hawk in the BSP by Duy Nguyen.

---
Changes compared to the BSP:
- Add can_clk,
- Add missing can_transceiver0,
- Keep channels 2 and 3 disabled,
- Preserve sort order.

arch/arm64/boot/dts/renesas/r8a779h0-gray-hawk-single.dts phy0: ethernet-phy@0 { · line 90

Quoted 9 lines
arch/arm64/boot/dts/renesas/r8a779h0-gray-hawk-single.dts +6 -0
@@ -75,6 +82,24 @@ phy0: ethernet-phy@0 {
        };
 };
 
+&can_clk {
+       clock-frequency = <40000000>;
+};
+
+&canfd {
+       pinctrl-0 = <&canfd0_pins>, <&canfd1_pins>, <&can_clk_pins>;

This lacks

    pinctrl-names = "default";

(the BSP did have that, but it was badly indented, and accidentally
removed while disabling channels 2 and 3).

Unfortunately adding the missing line doesn't help:

    ( sleep 1; cansend can1 '5A1#11.2233.44556677.88') & candump can0

doesn't do anything.

( sleep 1; cansend can0 '5A1#11.2233.44556677.88') & candump can1

triggers:

    rcar_canfd e6660000.can can0: bus-off

arch/arm64/boot/dts/renesas/r8a779h0-gray-hawk-single.dts phy0: ethernet-phy@0 { · line 101

Quoted 11 lines
arch/arm64/boot/dts/renesas/r8a779h0-gray-hawk-single.dts +11 -0
+       status = "okay";
+
+       channel0 {
+               status = "okay";
+               phys = <&can_transceiver0>;
+       };
+
+       channel1 {
+               status = "okay";
+       };
+};

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#6 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 6 lines

The CAN-FD module on R-Car V4M is very similar to the one on R-Car V4H, but differ in some hardware parameters, as reflected by the Parameter Status Information part of the Global IP Version Register. However, none of this parameterization should have any impact on the driver, as the driver does not access any register that is impacted by the parameterization (except for the number of channels).

Does the BSP work?

Happy hacking,

Wolfram

#7 lore raw

Hi Wolfram,

Quoted 8 lines · Wolfram Sang
Quoted 6 lines

The CAN-FD module on R-Car V4M is very similar to the one on R-Car V4H, but differ in some hardware parameters, as reflected by the Parameter Status Information part of the Global IP Version Register. However, none of this parameterization should have any impact on the driver, as the driver does not access any register that is impacted by the parameterization (except for the number of channels).

Does the BSP work?

I haven't tried the BSP in-se (it does not support Gray Hawk Single), but a forward port of rcar_canfd from the BSP exhibits the same behavior.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#8 lore raw

Hi Wolfram,

Quoted 9 lines · Geert Uytterhoeven
Quoted 7 lines · Wolfram Sang
Quoted 6 lines

The CAN-FD module on R-Car V4M is very similar to the one on R-Car V4H, but differ in some hardware parameters, as reflected by the Parameter Status Information part of the Global IP Version Register. However, none of this parameterization should have any impact on the driver, as the driver does not access any register that is impacted by the parameterization (except for the number of channels).

Quoted 4 lines
Quoted 1 line

Does the BSP work?

I haven't tried the BSP in-se (it does not support Gray Hawk Single), but a forward port of rcar_canfd from the BSP exhibits the same behavior.

I just booted the BSP's kernel and its Gray Hawk DTS on Gray Hawk Single, and I no longer get an error message when bringing up the CAN devices. However, that does not make CAN work, as v5.10 (and the BSP rcar-canfd driver) lack CAN transceiver support. Backporting that didn't help, but now I have something more to investigate next week ;-)

Thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#9 lore raw
Quoted 3 lines

rcar-canfd driver) lack CAN transceiver support. Backporting that didn't help, but now I have something more to investigate next week ;-)

Yay, at least something!