Skip to content

Commit

Permalink
can: rockchip_canfd: add support for CAN_CTRLMODE_LOOPBACK
Browse files Browse the repository at this point in the history
Add support for loopback mode.

Tested-by: Alibek Omarov <a1ba.omarov@gmail.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20240904-rockchip-canfd-v5-19-8ae22bcb27cc@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Marc Kleine-Budde committed Sep 4, 2024
1 parent 4e1a18b commit edf1dd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion drivers/net/can/rockchip/rockchip_canfd-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ static void rkcanfd_chip_start(struct rkcanfd_priv *priv)
RKCANFD_REG_MODE_RXSTX_MODE |
RKCANFD_REG_MODE_WORK_MODE;

if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
priv->reg_mode_default |= RKCANFD_REG_MODE_LBACK_MODE |
RKCANFD_REG_MODE_SILENT_MODE |
RKCANFD_REG_MODE_SELF_TEST;

/* mask, i.e. ignore:
* - TIMESTAMP_COUNTER_OVERFLOW_INT - timestamp counter overflow interrupt
* - TX_ARBIT_FAIL_INT - TX arbitration fail interrupt
Expand Down Expand Up @@ -894,7 +899,7 @@ static int rkcanfd_probe(struct platform_device *pdev)
priv->can.clock.freq = clk_get_rate(priv->clks[0].clk);
priv->can.bittiming_const = &rkcanfd_bittiming_const;
priv->can.data_bittiming_const = &rkcanfd_data_bittiming_const;
priv->can.ctrlmode_supported = 0;
priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK;
if (!(priv->devtype_data.quirks & RKCANFD_QUIRK_CANFD_BROKEN))
priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD;
priv->can.do_set_mode = rkcanfd_set_mode;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/rockchip/rockchip_canfd-rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static int rkcanfd_handle_rx_int_one(struct rkcanfd_priv *priv)
err = rkcanfd_rxstx_filter(priv, cfd, header->ts, &tx_done);
if (err)
return err;
if (tx_done)
if (tx_done && !(priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK))
return 0;
}

Expand Down

0 comments on commit edf1dd1

Please sign in to comment.