Skip to content

Commit dd3bd23

Browse files
rshanmumarckleinebudde
authored andcommitted
can: rcar_canfd: Add Renesas R-Car CAN FD driver
This patch adds support for the CAN FD controller found in Renesas R-Car SoCs. The controller operates in CAN FD only mode by default. CAN FD mode supports both Classical CAN & CAN FD frame formats. The controller supports ISO 11898-1:2015 CAN FD format only. This controller supports two channels and the driver can enable either or both of the channels. Driver uses Rx FIFOs (one per channel) for reception & Common FIFOs (one per channel) for transmission. Rx filter rules are configured to the minimum (one per channel) and it accepts Standard, Extended, Data & Remote Frame combinations. Note: There are few documentation errors in R-Car Gen3 Hardware User Manual v0.5E with respect to CAN FD controller. They are listed below: 1. CAN FD interrupt numbers 29 & 30 are listed as per channel interrupts. However, they are common to both channels (i.e.) they are global and channel interrupts respectively. 2. CANFD clock is derived from PLL1. This is not documented. 3. CANFD clock is further divided by (1/2) within the CAN FD controller. This is not documented. 4. The minimum value of NTSEG1 in RSCFDnCFDCmNCFG register is 2 Tq. It is specified 4 Tq in the manual. 5. The maximum number of message RAM area the controller can use is 3584 bytes. It is specified 10752 bytes in the manual. Signed-off-by: Ramesh Shanmugasundaram <[email protected]> Acked-by: Rob Herring <[email protected]> Reviewed-by: Ulrich Hecht <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 9be05c7 commit dd3bd23

File tree

6 files changed

+1802
-0
lines changed

6 files changed

+1802
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Renesas R-Car CAN FD controller Device Tree Bindings
2+
----------------------------------------------------
3+
4+
Required properties:
5+
- compatible: Must contain one or more of the following:
6+
- "renesas,rcar-gen3-canfd" for R-Car Gen3 compatible controller.
7+
- "renesas,r8a7795-canfd" for R8A7795 (R-Car H3) compatible controller.
8+
9+
When compatible with the generic version, nodes must list the
10+
SoC-specific version corresponding to the platform first, followed by the
11+
family-specific and/or generic versions.
12+
13+
- reg: physical base address and size of the R-Car CAN FD register map.
14+
- interrupts: interrupt specifier for the Global & Channel interrupts
15+
- clocks: phandles and clock specifiers for 3 clock inputs.
16+
- clock-names: 3 clock input name strings: "fck", "canfd", "can_clk".
17+
- pinctrl-0: pin control group to be used for this controller.
18+
- pinctrl-names: must be "default".
19+
20+
Required child nodes:
21+
The controller supports two channels and each is represented as a child node.
22+
The name of the child nodes are "channel0" and "channel1" respectively. Each
23+
child node supports the "status" property only, which is used to
24+
enable/disable the respective channel.
25+
26+
Required properties for "renesas,r8a7795-canfd" compatible:
27+
In R8A7795 SoC, canfd clock is a div6 clock and can be used by both CAN
28+
and CAN FD controller at the same time. It needs to be scaled to maximum
29+
frequency if any of these controllers use it. This is done using the
30+
below properties.
31+
32+
- assigned-clocks: phandle of canfd clock.
33+
- assigned-clock-rates: maximum frequency of this clock.
34+
35+
Example
36+
-------
37+
38+
SoC common .dtsi file:
39+
40+
canfd: can@e66c0000 {
41+
compatible = "renesas,r8a7795-canfd",
42+
"renesas,rcar-gen3-canfd";
43+
reg = <0 0xe66c0000 0 0x8000>;
44+
interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
45+
<GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
46+
clocks = <&cpg CPG_MOD 914>,
47+
<&cpg CPG_CORE R8A7795_CLK_CANFD>,
48+
<&can_clk>;
49+
clock-names = "fck", "canfd", "can_clk";
50+
assigned-clocks = <&cpg CPG_CORE R8A7795_CLK_CANFD>;
51+
assigned-clock-rates = <40000000>;
52+
power-domains = <&cpg>;
53+
status = "disabled";
54+
55+
channel0 {
56+
status = "disabled";
57+
};
58+
59+
channel1 {
60+
status = "disabled";
61+
};
62+
};
63+
64+
Board specific .dts file:
65+
66+
E.g. below enables Channel 1 alone in the board.
67+
68+
&canfd {
69+
pinctrl-0 = <&canfd1_pins>;
70+
pinctrl-names = "default";
71+
status = "okay";
72+
73+
channel1 {
74+
status = "okay";
75+
};
76+
};
77+
78+
E.g. below enables Channel 0 alone in the board using External clock
79+
as fCAN clock.
80+
81+
&canfd {
82+
pinctrl-0 = <&canfd0_pins &can_clk_pins>;
83+
pinctrl-names = "default";
84+
status = "okay";
85+
86+
channel0 {
87+
status = "okay";
88+
};
89+
};

drivers/net/can/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ source "drivers/net/can/cc770/Kconfig"
152152
source "drivers/net/can/ifi_canfd/Kconfig"
153153
source "drivers/net/can/m_can/Kconfig"
154154
source "drivers/net/can/mscan/Kconfig"
155+
source "drivers/net/can/rcar/Kconfig"
155156
source "drivers/net/can/sja1000/Kconfig"
156157
source "drivers/net/can/softing/Kconfig"
157158
source "drivers/net/can/spi/Kconfig"

drivers/net/can/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ can-dev-y := dev.o
1010

1111
can-dev-$(CONFIG_CAN_LEDS) += led.o
1212

13+
obj-y += rcar/
1314
obj-y += spi/
1415
obj-y += usb/
1516
obj-y += softing/

drivers/net/can/rcar/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
config CAN_RCAR_CANFD
2+
tristate "Renesas R-Car CAN FD controller"
3+
depends on ARCH_RENESAS || ARM
4+
---help---
5+
Say Y here if you want to use CAN FD controller found on
6+
Renesas R-Car SoCs. The driver puts the controller in CAN FD only
7+
mode, which can interoperate with CAN2.0 nodes but does not support
8+
dedicated CAN 2.0 mode.
9+
10+
To compile this driver as a module, choose M here: the module will
11+
be called rcar_canfd.

drivers/net/can/rcar/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#
2+
# Makefile for the Renesas R-Car CAN FD controller driver
3+
#
4+
5+
obj-$(CONFIG_CAN_RCAR_CANFD) += rcar_canfd.o

0 commit comments

Comments
 (0)