Skip to contentSkip to conversation

arm64: dts: renesas: r8a779g0/white-hawk: Add CAN-FD support

PATCH In review Geert Uytterhoeven 2 participants 4 messages Jan 23, 2023 – Jan 24, 2023

Subsystems (2)
lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

cover arm64: dts: renesas: r8a779g0/white-hawk: Add CAN-FD support

Hi all,

This patch series enables support for the CAN-FD interface on the Renesas R-Car V4H (R8A779G0) SoC, and for the first two CAN-FD channels on the Renesas White-Hawk development board.

While R-Car V4H supports 8 CAN-FD channels, and White-Hawk has transceivers mounted for the first 4 channels, my test results are similar to what Ulrich Hecht reported for R-Car V3U on the Falcon development board before, i.e. only channels 0 and 1 work, and thus this series enables support for these channels only. Whether this is a CAN-FD driver issue, a pin control issue, an IP core issue, or an SoC integration issue is still to be seen...

For testing, this series and its dependencies can be found at [1].

Thanks for your comments!

[1] https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/log/?h=topic/r8a779g0-canfd-v1

Geert Uytterhoeven (2):
arm64: dts: renesas: r8a779g0: Add CAN-FD node
arm64: dts: renesas: white-hawk: Add CAN-FD support

 .../boot/dts/renesas/r8a779g0-white-hawk.dts  | 44 ++++++++++++++
 arch/arm64/boot/dts/renesas/r8a779g0.dtsi     | 57 +++++++++++++++++++
 2 files changed, 101 insertions(+)
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/2 arm64: dts: renesas: r8a779g0: Add CAN-FD node

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

Based on a patch in the BSP by Kazuya Mizuguch.

---
Changes compared to the BSP:
- Add family-specific compatible value,
- Correct reg size,
- Add missing interrupt-names.

---
 arch/arm64/boot/dts/renesas/r8a779g0.dtsi | 57 +++++++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/renesas/r8a779g0.dtsi +57 -0
index 83d1666a2ea16de2..d4cc89e49c68d52e 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 {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <0>;
+	};
+
 	cluster0_opp: opp-table-0 {
 		compatible = "operating-points-v2";
 		opp-shared;
@@ -676,6 +683,56 @@ hscif3: serial@e66a0000 {
 			status = "disabled";
 		};
 
+		canfd: can@e6660000 {
+			compatible = "renesas,r8a779g0-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 R8A779G0_CLK_CANFD>,
+				 <&can_clk>;
+			clock-names = "fck", "canfd", "can_clk";
+			assigned-clocks = <&cpg CPG_CORE R8A779G0_CLK_CANFD>;
+			assigned-clock-rates = <80000000>;
+			power-domains = <&sysc R8A779G0_PD_ALWAYS_ON>;
+			resets = <&cpg 328>;
+			status = "disabled";
+
+			channel0 {
+				status = "disabled";
+			};
+
+			channel1 {
+				status = "disabled";
+			};
+
+			channel2 {
+				status = "disabled";
+			};
+
+			channel3 {
+				status = "disabled";
+			};
+
+			channel4 {
+				status = "disabled";
+			};
+
+			channel5 {
+				status = "disabled";
+			};
+
+			channel6 {
+				status = "disabled";
+			};
+
+			channel7 {
+				status = "disabled";
+			};
+		};
+
 		avb0: ethernet@e6800000 {
 			compatible = "renesas,etheravb-r8a779g0",
 				     "renesas,etheravb-rcar-gen4";
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH 2/2 arm64: dts: renesas: white-hawk: Add CAN-FD support

In reply to Geert Uytterhoeven

Enable confirmed-working CAN-FD channels 0 and 1 on the White-Hawk development board:
- Channel 0 uses an NXP TJR1443AT CAN transceiver, which is be enabled through a GPIO,
- Channels 1-7 use Microchip MCP2558FD-H/SN CAN transceivers (not mounted for channels 4-7), which do not need explicit description, but channels 2-3 do not seem to work.

Inspired by a patch in the BSP by Kazuya Mizuguch.

---
This depends on "[PATCH 2/2] phy: phy-can-transceiver: Add support for NXP TJR1443"
https://lore.kernel.org/all/0bfa1e4c43632e49c9512b4e7daa970545545dcf.1674037830.git.geert+renesas@glider.be

Changed compared to the BSP:
- Add can_clk,
- Add missing can_transceiver0,
- Disable channels 2-7.

Tested using cansend, candump, and canfdtest.

- Channel 2 does not work: "bus-off" error message.

- Channel 3 does not work:
- Using cansend on another interface, and candump on can3 shows that nothing is received.
However, my scope does see the data on the bus, and it is not sent repeatedly, hence it must have been acked by the receiver.

- Using canfdtest on can3 gives:

can3: Message ID mismatch!
expected: 0078: [8] 01 02 03 04 05 06 07 08
received: 0077: [8] 00 01 02 03 04 05 06 07

Note that describing a plain gpio-hog instead of can_transceiver0 is not sufficient, as the enable signal must not be asserted before initialization of the CAN-FD controller,

---
 .../boot/dts/renesas/r8a779g0-white-hawk.dts  | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
arch/arm64/boot/dts/renesas/r8a779g0-white-hawk.dts +44 -0
index 04a2b6b83e743f32..eff1ef6e2cc83aba 100644
@@ -13,6 +13,33 @@
 / {
 	model = "Renesas White Hawk CPU and Breakout boards based on r8a779g0";
 	compatible = "renesas,white-hawk-breakout", "renesas,white-hawk-cpu", "renesas,r8a779g0";
+
+	can_transceiver0: can-phy0 {
+		compatible = "nxp,tjr1443";
+		#phy-cells = <0>;
+		enable-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
+		max-bitrate = <5000000>;
+	};
+};
+
+&can_clk {
+	clock-frequency = <40000000>;
+};
+
+&canfd {
+	pinctrl-0 = <&canfd0_pins>, <&canfd1_pins>, <&can_clk_pins>;
+	pinctrl-names = "default";
+
+	status = "okay";
+
+	channel0 {
+		status = "okay";
+		phys = <&can_transceiver0>;
+	};
+
+	channel1 {
+		status = "okay";
+	};
 };
 
 &i2c0 {
@@ -23,3 +50,20 @@ eeprom@51 {
 		pagesize = <8>;
 	};
 };
+
+&pfc {
+	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";
+	};
+};
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 2/2] arm64: dts: renesas: white-hawk: Add CAN-FD support

Hello!

Quoted 3 lines · Geert Uytterhoeven

Enable confirmed-working CAN-FD channels 0 and 1 on the White-Hawk development board:
- Channel 0 uses an NXP TJR1443AT CAN transceiver, which is be enabled

Is be enabled? :-)

Quoted 8 lines

through a GPIO,
- Channels 1-7 use Microchip MCP2558FD-H/SN CAN transceivers (not mounted for channels 4-7), which do not need explicit description, but channels 2-3 do not seem to work.

Inspired by a patch in the BSP by Kazuya Mizuguch.

[...]

MBR, Sergey