[PATCH 0/3] Add support for Renesas CAN-FD Bus-Off recovery mode selection

Biju posted 3 patches 2 months, 1 week ago
.../bindings/net/can/renesas,rcar-canfd.yaml  | 11 ++++++++++
drivers/net/can/rcar/rcar_canfd.c             | 20 +++++++++++++------
2 files changed, 25 insertions(+), 6 deletions(-)
[PATCH 0/3] Add support for Renesas CAN-FD Bus-Off recovery mode selection
Posted by Biju 2 months, 1 week ago
From: Biju Das <biju.das.jz@bp.renesas.com>

The CAN-FD IP supports the below Bus-Off recovery modes:
1) ISO11898-1 compliant
2) Entry to Channel Halt mode automatically at bus-off entry
3) Entry to Channel Halt mode automatically at bus-off end
4) Entry to Channel Halt mode (in bus-off state) by program request

Add support for Bus-Off recovery mode selection via the
renesas,bus-off-recovery-mode device tree property. If the property is
absent, it defaults to RCANFD_CCTR_BOM_BENTRY (entry to Channel Halt mode
automatically at bus-off entry) for backward compatibility.

Testing:
CANBUS-OFF trigger on RZ/G3E SMARC EVK:-

Enable
CONFIG_EXPERT=y
CONFIG_GPIO_SYSFS=y

echo 556 > /sys/class/gpio/export
echo 557 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio556/direction
echo out > /sys/class/gpio/gpio557/direction
echo 1 > /sys/class/gpio/gpio556/value
echo 1 > /sys/class/gpio/gpio557/value

ip link set can0 down
ip link set can1 down
ip link set can0 up type can bitrate 1000000 dbitrate 4000000 fd on restart-ms 100
ip link set can1 up type can bitrate 1000000 dbitrate 4000000 fd on restart-ms 100

Set the switches SW_GPIO8_CAN0_STB and SW_GPIO9_CAN1_STB to STANDBY mode

candump can0 &
cansend can1 123#1122334455667788

This will trigger BUS-OFF as CAN is in STANDBY mode

Then, Set the switches SW_GPIO8_CAN0_STB and  SW_GPIO9_CAN1_STB to
NORMAL mode, the messages started receiving after bus-off errors.

With BOM=0, after bus recovery, Bus-Off recovery interrupt is triggered
by CAN-FD IP.

Biju Das (3):
  dt-bindings: can: renesas,rcar-canfd: Document
    renesas,bus-off-recovery-mode property
  can: rcar_canfd: Add support for Bus-Off recovery mode selection
  can: rcar_canfd: Handle Bus-Off recovery interrupt

 .../bindings/net/can/renesas,rcar-canfd.yaml  | 11 ++++++++++
 drivers/net/can/rcar/rcar_canfd.c             | 20 +++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

-- 
2.43.0
Re: [PATCH 0/3] Add support for Renesas CAN-FD Bus-Off recovery mode selection
Posted by Marc Kleine-Budde 2 months, 1 week ago
On 03.04.2026 10:49:57, Biju wrote:
> From: Biju Das <biju.das.jz@bp.renesas.com>
>
> The CAN-FD IP supports the below Bus-Off recovery modes:
> 1) ISO11898-1 compliant
> 2) Entry to Channel Halt mode automatically at bus-off entry
> 3) Entry to Channel Halt mode automatically at bus-off end
> 4) Entry to Channel Halt mode (in bus-off state) by program request
>
> Add support for Bus-Off recovery mode selection via the
> renesas,bus-off-recovery-mode device tree property. If the property is
> absent, it defaults to RCANFD_CCTR_BOM_BENTRY (entry to Channel Halt mode
> automatically at bus-off entry) for backward compatibility.

Using DT properties for configuration is not the best way to go. I think
we first have to get the CAN error state handling fixed, before you add
new features.

Can you explain a bit more what the controller does in the different
modes?

In the current driver when the bus off IRQ (RCANFD_CERFL_BOEF) fires,
the driver calls can_bus_off(), which triggers the configured bus off
handling.

What the Linux driver should do is once the HW is in bus off mode,
switch off the HW and let the .do_set_mode(CAN_MODE_START) callback
restart the hardware.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |