From: Biju Das biju.das.jz@bp.renesas.com
The commit 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") applies to all SoCs except the RZ/G2L family of SoCs. As per RZ/G2L hardware manual "Figure 28.16 CAN Setting Procedure after the MCU is Reset" CAN mode needs to be set before channel reset. Add the mode_before_ch_rst variable to struct rcar_canfd_hw_info to handle this difference.
The above commit also breaks CANFD functionality on RZ/G3E. Adapt this change to RZ/G3E, as well as it works ok by following the initialisation sequence of RZ/G2L.
Fixes: 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") Cc: stable@vger.kernel.org Signed-off-by: Biju Das biju.das.jz@bp.renesas.com --- drivers/net/can/rcar/rcar_canfd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 49ab65274b51..1724fa5dace6 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -444,6 +444,7 @@ struct rcar_canfd_hw_info { unsigned ch_interface_mode:1; /* Has channel interface mode */ unsigned shared_can_regs:1; /* Has shared classical can registers */ unsigned external_clk:1; /* Has external clock */ + unsigned mode_before_ch_rst:1; /* Has set mode before channel reset */ };
/* Channel priv data */ @@ -615,6 +616,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .ch_interface_mode = 0, .shared_can_regs = 0, .external_clk = 1, + .mode_before_ch_rst = 0, };
static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { @@ -632,6 +634,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .ch_interface_mode = 1, .shared_can_regs = 1, .external_clk = 1, + .mode_before_ch_rst = 0, };
static const struct rcar_canfd_hw_info rzg2l_hw_info = { @@ -649,6 +652,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { .ch_interface_mode = 0, .shared_can_regs = 0, .external_clk = 1, + .mode_before_ch_rst = 1, };
static const struct rcar_canfd_hw_info r9a09g047_hw_info = { @@ -666,6 +670,7 @@ static const struct rcar_canfd_hw_info r9a09g047_hw_info = { .ch_interface_mode = 1, .shared_can_regs = 1, .external_clk = 0, + .mode_before_ch_rst = 1, };
/* Helper functions */ @@ -806,6 +811,10 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv) /* Reset Global error flags */ rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0x0);
+ /* RZ/G2L SoC needs setting the mode before channel reset */ + if (gpriv->info->mode_before_ch_rst) + rcar_canfd_set_mode(gpriv); + /* Transition all Channels to reset mode */ for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { rcar_canfd_clear_bit(gpriv->base, @@ -826,7 +835,8 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv) }
/* Set the controller into appropriate mode */ - rcar_canfd_set_mode(gpriv); + if (!gpriv->info->mode_before_ch_rst) + rcar_canfd_set_mode(gpriv);
return 0; }
On 30.10.2025 12:05:04, Biju wrote:
From: Biju Das biju.das.jz@bp.renesas.com
The commit 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") applies to all SoCs except the RZ/G2L family of SoCs. As per RZ/G2L hardware manual "Figure 28.16 CAN Setting Procedure after the MCU is Reset" CAN mode needs to be set before channel reset. Add the mode_before_ch_rst variable to struct rcar_canfd_hw_info to handle this difference.
The above commit also breaks CANFD functionality on RZ/G3E. Adapt this change to RZ/G3E, as well as it works ok by following the initialisation sequence of RZ/G2L.
Fixes: 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") Cc: stable@vger.kernel.org Signed-off-by: Biju Das biju.das.jz@bp.renesas.com
Applied to linux-can.
Thanks, Marc
Hi Marc, Geert,
-----Original Message----- From: Marc Kleine-Budde mkl@pengutronix.de Sent: 12 November 2025 08:47 Subject: Re: [PATCH] can: rcar_canfd: Fix controller mode setting for RZ/G2L SoCs
On 30.10.2025 12:05:04, Biju wrote:
From: Biju Das biju.das.jz@bp.renesas.com
The commit 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") applies to all SoCs except the RZ/G2L family of SoCs. As per RZ/G2L hardware manual "Figure 28.16 CAN Setting Procedure after the MCU is Reset" CAN mode needs to be set before channel reset. Add the mode_before_ch_rst variable to struct rcar_canfd_hw_info to handle this difference.
The above commit also breaks CANFD functionality on RZ/G3E. Adapt this change to RZ/G3E, as well as it works ok by following the initialisation sequence of RZ/G2L.
Fixes: 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") Cc: stable@vger.kernel.org Signed-off-by: Biju Das biju.das.jz@bp.renesas.com
Applied to linux-can.
There are 3 modes for CANFD on RZ/G3E
1) CAN-FD mode 2) FD only mode 3) Classical CAN only mode
In the "FD only mode", the FDOE bit enables the reception and transmission of CAN-FD-only frames. If enabled, communication in the Classical CAN frame format is disabled. On RZ/G2L, currently, CAN-FD mode is enabled by default and On RZ/G3E and R-Car Gen4, currently FD-only mode is the default.
Prior to commit 5cff263606a1010 ("can: rcar_canfd: Fix controller mode setting) RZ/G3E and R-Car Gen4 are using incorrect code for setting CAN-FD mode. But fortunately, it sets the mode as CAN-FD node, as the channel reset was executed after setting the mode, that resets the registers to CAN-FD mode.(Global reset, set mode, channel reset)
The commit 5cff263606a1010 makes (Global reset, channel reset, set mode), now align with the flow mentioned in the hardware manual for all SoCs except RZ/G2L. But because of the earlier wrong code, it sets to FD-only mode instead of CAN-FD mode.
Is it okay to drop this patch so I can send another patch to make CAN-FD mode as the default for RZ/G3E and R-Car Gen4?
As an enhancement, we need to define a device tree property to support FD-only mode for RZ/G2L, RZ/G3E and R-Car Gen4. Please share your thoughts on this.
Cheers, Biju
Hi All,
-----Original Message----- From: Biju Das Sent: 15 November 2025 13:57 Subject: RE: [PATCH] can: rcar_canfd: Fix controller mode setting for RZ/G2L SoCs
Hi Marc, Geert,
-----Original Message----- From: Marc Kleine-Budde mkl@pengutronix.de Sent: 12 November 2025 08:47 Subject: Re: [PATCH] can: rcar_canfd: Fix controller mode setting for RZ/G2L SoCs
On 30.10.2025 12:05:04, Biju wrote:
From: Biju Das biju.das.jz@bp.renesas.com
The commit 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") applies to all SoCs except the RZ/G2L family of SoCs. As per RZ/G2L hardware manual "Figure 28.16 CAN Setting Procedure after the MCU is Reset" CAN mode needs to be set before channel reset. Add the mode_before_ch_rst variable to struct rcar_canfd_hw_info to handle this difference.
The above commit also breaks CANFD functionality on RZ/G3E. Adapt this change to RZ/G3E, as well as it works ok by following the initialisation sequence of RZ/G2L.
Fixes: 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") Cc: stable@vger.kernel.org Signed-off-by: Biju Das biju.das.jz@bp.renesas.com
Applied to linux-can.
There are 3 modes for CANFD on RZ/G3E
- CAN-FD mode
- FD only mode
- Classical CAN only mode
In the "FD only mode", the FDOE bit enables the reception and transmission of CAN-FD-only frames. If enabled, communication in the Classical CAN frame format is disabled.
On RZ/G2L, currently, CAN-FD mode is enabled by default and On RZ/G3E and R-Car Gen4, currently FD- only mode is the default.
Prior to commit 5cff263606a1010 ("can: rcar_canfd: Fix controller mode setting) RZ/G3E and R-Car Gen4 are using incorrect code for setting CAN-FD mode. But fortunately, it sets the mode as CAN-FD node, as the channel reset was executed after setting the mode, that resets the registers to CAN-FD mode.(Global reset, set mode, channel reset)
The commit 5cff263606a1010 makes (Global reset, channel reset, set mode), now align with the flow mentioned in the hardware manual for all SoCs except RZ/G2L. But because of the earlier wrong code, it sets to FD-only mode instead of CAN-FD mode.
Is it okay to drop this patch so I can send another patch to make CAN-FD mode as the default for RZ/G3E and R-Car Gen4?
As an enhancement, we need to define a device tree property to support FD-only mode for RZ/G2L, RZ/G3E and R-Car Gen4. Please share your thoughts on this.
Just to add,
The patch I posted "can: rcar_canfd: Fix controller mode setting for RZ/G2L SoCs" and commit 5cff263606a1010 ("can: rcar_canfd: Fix controller mode setting) is wrong for R-Car Gen3.
R-Car Gen3 has only 2 modes: CAN-FD and Classical CAN (there is no FD-only mode). All other SoCs has 3 modes, CAN-FD, Classical CAN and FD-only mode
R-Can Gen3, RZ/G2L (CAN-FD and Classical modes): Modify the RSCFDnCFDGRMCFG register only in global reset mode. (Here the flow is global reset, set mode, channel reset)
Selection of FD-only mode for RZ/G2L: Modify the FDOE bit in RSCFDnCFDCmFDCFG only in channel reset
RZ/G3E and R-Car Gen4: Modify the FDOE/CLOE bit in CFDCnFDCFG only in channel reset (Here flow is global reset, set mode, channel reset)
Cheers, Biju
Hi Biju,
On Sun, 16 Nov 2025 at 11:31, Biju Das biju.das.jz@bp.renesas.com wrote:
From: Biju Das
Sent: 12 November 2025 08:47 On 30.10.2025 12:05:04, Biju wrote:
The commit 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") applies to all SoCs except the RZ/G2L family of SoCs. As per RZ/G2L hardware manual "Figure 28.16 CAN Setting Procedure after the MCU is Reset" CAN mode needs to be set before channel reset. Add the mode_before_ch_rst variable to struct rcar_canfd_hw_info to handle this difference.
The above commit also breaks CANFD functionality on RZ/G3E. Adapt this change to RZ/G3E, as well as it works ok by following the initialisation sequence of RZ/G2L.
Fixes: 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") Cc: stable@vger.kernel.org Signed-off-by: Biju Das biju.das.jz@bp.renesas.com
Applied to linux-can.
There are 3 modes for CANFD on RZ/G3E
- CAN-FD mode
- FD only mode
- Classical CAN only mode
In the "FD only mode", the FDOE bit enables the reception and transmission of CAN-FD-only frames. If enabled, communication in the Classical CAN frame format is disabled.
On RZ/G2L, currently, CAN-FD mode is enabled by default and On RZ/G3E and R-Car Gen4, currently FD- only mode is the default.
Prior to commit 5cff263606a1010 ("can: rcar_canfd: Fix controller mode setting) RZ/G3E and R-Car Gen4 are using incorrect code for setting CAN-FD mode. But fortunately, it sets the mode as CAN-FD node, as the channel reset was executed after setting the mode, that resets the registers to CAN-FD mode.(Global reset, set mode, channel reset)
The commit 5cff263606a1010 makes (Global reset, channel reset, set mode), now align with the flow mentioned in the hardware manual for all SoCs except RZ/G2L. But because of the earlier wrong code, it sets to FD-only mode instead of CAN-FD mode.
Is it okay to drop this patch so I can send another patch to make CAN-FD mode as the default for RZ/G3E and R-Car Gen4?
As an enhancement, we need to define a device tree property to support FD-only mode for RZ/G2L, RZ/G3E and R-Car Gen4. Please share your thoughts on this.
Hmm, Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml:
renesas,no-can-fd: $ref: /schemas/types.yaml#/definitions/flag description: The controller can operate in either CAN FD only mode (default) or Classical CAN only mode. The mode is global to all channels. Specify this property to put the controller in Classical CAN only mode.
The patch I posted "can: rcar_canfd: Fix controller mode setting for RZ/G2L SoCs" and commit 5cff263606a1010 ("can: rcar_canfd: Fix controller mode setting) is wrong for R-Car Gen3.
R-Car Gen3 has only 2 modes: CAN-FD and Classical CAN (there is no FD-only mode). All other SoCs has 3 modes, CAN-FD, Classical CAN and FD-only mode
R-Can Gen3, RZ/G2L (CAN-FD and Classical modes): Modify the RSCFDnCFDGRMCFG register only in global reset mode. (Here the flow is global reset, set mode, channel reset)
Selection of FD-only mode for RZ/G2L: Modify the FDOE bit in RSCFDnCFDCmFDCFG only in channel reset
RZ/G3E and R-Car Gen4: Modify the FDOE/CLOE bit in CFDCnFDCFG only in channel reset (Here flow is global reset, set mode, channel reset)
Gr{oetje,eeting}s,
Geert
Hi Geert,
Thanks for the feedback.
-----Original Message----- From: Geert Uytterhoeven geert@linux-m68k.org Sent: 17 November 2025 10:13 Subject: Re: [PATCH] can: rcar_canfd: Fix controller mode setting for RZ/G2L SoCs
Hi Biju,
On Sun, 16 Nov 2025 at 11:31, Biju Das biju.das.jz@bp.renesas.com wrote:
From: Biju Das
Sent: 12 November 2025 08:47 On 30.10.2025 12:05:04, Biju wrote:
The commit 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") applies to all SoCs except the RZ/G2L family of SoCs. As per RZ/G2L hardware manual "Figure 28.16 CAN Setting Procedure after the MCU is Reset" CAN mode needs to be set before channel reset. Add the mode_before_ch_rst variable to struct rcar_canfd_hw_info to handle this difference.
The above commit also breaks CANFD functionality on RZ/G3E. Adapt this change to RZ/G3E, as well as it works ok by following the initialisation sequence of RZ/G2L.
Fixes: 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") Cc: stable@vger.kernel.org Signed-off-by: Biju Das biju.das.jz@bp.renesas.com
Applied to linux-can.
There are 3 modes for CANFD on RZ/G3E
- CAN-FD mode
- FD only mode
- Classical CAN only mode
In the "FD only mode", the FDOE bit enables the reception and transmission of CAN-FD-only frames. If enabled, communication in the Classical CAN frame format is disabled.
On RZ/G2L, currently, CAN-FD mode is enabled by default and On RZ/G3E and R-Car Gen4, currently FD- only mode is the default.
Prior to commit 5cff263606a1010 ("can: rcar_canfd: Fix controller mode setting) RZ/G3E and R-Car Gen4 are using incorrect code for setting CAN-FD mode. But fortunately, it sets the mode as CAN-FD node, as the channel reset was executed after setting the mode, that resets the registers to CAN-FD mode.(Global reset, set mode, channel reset)
The commit 5cff263606a1010 makes (Global reset, channel reset, set mode), now align with the flow mentioned in the hardware manual for all SoCs except RZ/G2L. But because of the earlier wrong code, it sets to FD-only mode instead of CAN-FD mode.
Is it okay to drop this patch so I can send another patch to make CAN-FD mode as the default for RZ/G3E and R-Car Gen4?
As an enhancement, we need to define a device tree property to support FD-only mode for RZ/G2L, RZ/G3E and R-Car Gen4. Please share your thoughts on this.
Hmm, Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml:
renesas,no-can-fd: $ref: /schemas/types.yaml#/definitions/flag description: The controller can operate in either CAN FD only mode (default) or Classical CAN only mode. The mode is global to all channels. Specify this property to put the controller in Classical CAN only mode.
Maybe we need to remove the "only" word from bindings to avoid confusion. This is coming from R-Car Gen3, which has 2 modes. As per the bit definition of RCMC
0: Classical CAN mode 1: CAN FD mode
As per 48.1.2 Interface Mode od RZ/G2{H,M,N,E} manual RS-CANFD has the following two interface modes.
• Classical CAN mode: Only classical CAN frames are handled. • CAN FD mode: both the classical CAN frames and CAN FD frames are handled.
But RZ/G2L, RZ/G3E and R-Car Gen4, has additional mode called FD-only mode for CAN-FD. In this mode, rx/tx transfer using the canfdtest tool won't work. But cansend/candump works[1].
To summarise, we need the following setting in rcar_canfd_reset_controller():
R-Car Gen3 and RZ/G2L: On Global reset mode set RCMC for CAN-FD or Classical CAN RZ/G2L: On channel reset mode, set FD-only mode or CAN-FD mode. RZ/G3E and R-Car Gen4: On channel reset mode, set CAN-FD mode or FD-only mode or Classical CAN mode
I think there will be 2 patches: 1) Fixes patches to set CAN-FD mode as the default for all SoCs 2) Binding + Driver changes for supporting FD-Only mode for RZ/G2L, R/G3E and R-Car Gen4.
[1] root@smarc-rzg3e:~# candump can1 & [1] 399 root@smarc-rzg3e:~# [ 232.698723] can: controller area network core [ 232.703202] NET: Registered PF_CAN protocol family [ 232.770075] can: raw protocol root@smarc-rzg3e:~# cansend can0 123##0.0011223344556677 can1 123 [08] 00 11 22 33 44 55 66 77 root@smarc-rzg3e:~#
Please share your thoughts.
Cheers, Biju
On 15.11.2025 13:57:13, Biju Das wrote:
Hi Marc, Geert,
-----Original Message----- From: Marc Kleine-Budde mkl@pengutronix.de Sent: 12 November 2025 08:47 Subject: Re: [PATCH] can: rcar_canfd: Fix controller mode setting for RZ/G2L SoCs
On 30.10.2025 12:05:04, Biju wrote:
From: Biju Das biju.das.jz@bp.renesas.com
The commit 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") applies to all SoCs except the RZ/G2L family of SoCs. As per RZ/G2L hardware manual "Figure 28.16 CAN Setting Procedure after the MCU is Reset" CAN mode needs to be set before channel reset. Add the mode_before_ch_rst variable to struct rcar_canfd_hw_info to handle this difference.
The above commit also breaks CANFD functionality on RZ/G3E. Adapt this change to RZ/G3E, as well as it works ok by following the initialisation sequence of RZ/G2L.
Fixes: 5cff263606a1 ("can: rcar_canfd: Fix controller mode setting") Cc: stable@vger.kernel.org Signed-off-by: Biju Das biju.das.jz@bp.renesas.com
Applied to linux-can.
There are 3 modes for CANFD on RZ/G3E
- CAN-FD mode
- FD only mode
- Classical CAN only mode
In the "FD only mode", the FDOE bit enables the reception and transmission of CAN-FD-only frames. If enabled, communication in the Classical CAN frame format is disabled.
On RZ/G2L, currently, CAN-FD mode is enabled by default and On RZ/G3E and R-Car Gen4, currently FD-only mode is the default.
Prior to commit 5cff263606a1010 ("can: rcar_canfd: Fix controller mode setting) RZ/G3E and R-Car Gen4 are using incorrect code for setting CAN-FD mode. But fortunately, it sets the mode as CAN-FD node, as the channel reset was executed after setting the mode, that resets the registers to CAN-FD mode.(Global reset, set mode, channel reset)
The commit 5cff263606a1010 makes (Global reset, channel reset, set mode), now align with the flow mentioned in the hardware manual for all SoCs except RZ/G2L. But because of the earlier wrong code, it sets to FD-only mode instead of CAN-FD mode.
Is it okay to drop this patch so I can send another patch to make CAN-FD mode as the default for RZ/G3E and R-Car Gen4?
Yes. I'll drop this patch now.
As an enhancement, we need to define a device tree property to support FD-only mode for RZ/G2L, RZ/G3E and R-Car Gen4. Please share your thoughts on this.
regards, Marc
linux-stable-mirror@lists.linaro.org