[PATCH v6 2/4] can: rockchip: add RK3588 CAN support

Marc Kleine-Budde mkl at pengutronix.de
Fri Jul 31 00:18:04 PDT 2026


On 30.07.2026 22:34:03, Cunhao Lu wrote:
> Add support for the RK3588 CAN controller by introducing a dedicated
> model ID and OF match entry.
>
> The block is closely related to the existing RK3568 variants, but it
> cannot reuse their match data unchanged. In particular, RK3588
> encodes RX_FIFO_CNT in bits 7:5 instead of 6:4, so the RX path needs
> SoC-specific handling.
>
> The RX FIFO count bitfield difference was found by comparing Rockchip's
> vendor kernel 6.1 CAN support for RK3568 and RK3588. Runtime testing on
> RK3588 also confirms that bits 7:5 are needed.
>
> Enable the existing erratum 5 empty-FIFO workaround for RK3588.
> Heiko reproduced erratum 6 on RK3588, so enable that workaround as
> well.
>
> CAN-FD is enabled for RK3588. The BRS bus-off issue seen in earlier
> testing was caused by the transmit delay compensation setting. With
> RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION programmed to 0 on RK3588,
> CAN-FD with BRS works in local testing.
>
> Tested on an embedfire,rk3588-lubancat-5io board with can0/can1
> directly connected, no other device on the bus, 60 Ohm bus
> termination, and a 300 MHz CAN clock. Runtime testing used 500 kbit/s
> arbitration bitrate and 1, 3 and 5 Mbit/s data bitrates. The 5 Mbit/s
> data phase test ran for 15 minutes with cangen using BRS and
> cansequence on the receiver. Both interfaces reported 9528377 packets
> and 150667356 bytes, with 0 bus-errors, 0 error-warn, 0 error-pass and
> 0 bus-off events.
>
> Co-developed-by: Heiko Stuebner <heiko.stuebner at cherry.de>
> Signed-off-by: Heiko Stuebner <heiko.stuebner at cherry.de>
> Tested-by: Heiko Stuebner <heiko at sntech.de>
> Reviewed-by: Heiko Stuebner <heiko at sntech.de>
> Signed-off-by: Cunhao Lu <1579567540 at qq.com>
> ---
> v3 -> v4:
> - Disable TDC on RK3588 by programming
>   RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION to 0.
> - Drop RKCANFD_QUIRK_CANFD_BROKEN for RK3588 and enable CAN-FD support.
> - Document successful RK3588 CAN-FD/BRS testing.
> v2 -> v3:
> - Use Co-developed-by for Heiko's RK3588 contributions and add his
>   Signed-off-by
> - Collect Heiko's Reviewed-by and Tested-by tags
> ---
>  drivers/net/can/rockchip/rockchip_canfd-core.c | 17 +++++++++++++++++
>  drivers/net/can/rockchip/rockchip_canfd-rx.c   |  5 ++++-
>  drivers/net/can/rockchip/rockchip_canfd.h      | 14 +++++++++++++-
>  3 files changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/can/rockchip/rockchip_canfd-core.c b/drivers/net/can/rockchip/rockchip_canfd-core.c
> index 29de0c01e4ed..37c1c22c40c9 100644
> --- a/drivers/net/can/rockchip/rockchip_canfd-core.c
> +++ b/drivers/net/can/rockchip/rockchip_canfd-core.c
> @@ -50,6 +50,12 @@ static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3568v3 = {
>  		RKCANFD_QUIRK_CANFD_BROKEN,
>  };
>
> +static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3588 = {
> +	.model = RKCANFD_MODEL_RK3588,
> +	.quirks = RKCANFD_QUIRK_RK3568_ERRATUM_5 |
> +		RKCANFD_QUIRK_RK3568_ERRATUM_6,
> +};
> +
>  static const char *__rkcanfd_get_model_str(enum rkcanfd_model model)
>  {
>  	switch (model) {
> @@ -57,6 +63,8 @@ static const char *__rkcanfd_get_model_str(enum rkcanfd_model model)
>  		return "rk3568v2";
>  	case RKCANFD_MODEL_RK3568V3:
>  		return "rk3568v3";
> +	case RKCANFD_MODEL_RK3588:
> +		return "rk3588";
>  	}
>
>  	return "<unknown>";
> @@ -148,6 +156,12 @@ static int rkcanfd_set_bittiming(struct rkcanfd_priv *priv)
>
>  	rkcanfd_write(priv, RKCANFD_REG_FD_DATA_BITTIMING, reg_dbt);
>
> +	/* RK3588 CAN-FD BRS works with TDC disabled. */
> +	if (priv->devtype_data.model == RKCANFD_MODEL_RK3588) {
> +		rkcanfd_write(priv, RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION, 0);
> +		return 0;
> +	}
> +

Can you attach the TDC to the CAN framework? See commit 5e1663810e11
("can: mcp251xfd: fix TDC setting for low data bit rates"). And check if
CAN-FD works on the rk3588 works?

Marc

>  	tdco = (priv->can.clock.freq / dbt->bitrate) * 2 / 3;
>  	tdco = min(tdco, FIELD_MAX(RKCANFD_REG_TRANSMIT_DELAY_COMPENSATION_TDC_OFFSET));

--
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   |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20260731/d24b2401/attachment.sig>


More information about the Linux-rockchip mailing list