Commit 33ea42f6 authored by Kurt Van Dijck's avatar Kurt Van Dijck Committed by Marc Kleine-Budde

can: mcp25xxfd: add listen-only mode

This commit enables listen-only mode, which works internally like CANFD mode.
Signed-off-by: default avatarKurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/r/20200918172536.2074504-5-mkl@pengutronix.de
parent 55e5b97f
......@@ -392,7 +392,8 @@ static int mcp25xxfd_ring_alloc(struct mcp25xxfd_priv *priv)
int ram_free, i;
tef_obj_size = sizeof(struct mcp25xxfd_hw_tef_obj);
if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
/* listen-only mode works like FD mode */
if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_FD)) {
tx_obj_num = MCP25XXFD_TX_OBJ_NUM_CANFD;
tx_obj_size = sizeof(struct mcp25xxfd_hw_tx_obj_canfd);
rx_obj_size = sizeof(struct mcp25xxfd_hw_rx_obj_canfd);
......@@ -807,7 +808,7 @@ mcp25xxfd_chip_rx_fifo_init_one(const struct mcp25xxfd_priv *priv,
MCP25XXFD_REG_FIFOCON_RXOVIE |
MCP25XXFD_REG_FIFOCON_TFNRFNIE;
if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_FD))
fifo_con |= FIELD_PREP(MCP25XXFD_REG_FIFOCON_PLSIZE_MASK,
MCP25XXFD_REG_FIFOCON_PLSIZE_64);
else
......@@ -857,7 +858,7 @@ static int mcp25xxfd_chip_fifo_init(const struct mcp25xxfd_priv *priv)
MCP25XXFD_REG_FIFOCON_TXEN |
MCP25XXFD_REG_FIFOCON_TXATIE;
if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_FD))
val |= FIELD_PREP(MCP25XXFD_REG_FIFOCON_PLSIZE_MASK,
MCP25XXFD_REG_FIFOCON_PLSIZE_64);
else
......@@ -930,7 +931,9 @@ static u8 mcp25xxfd_get_normal_mode(const struct mcp25xxfd_priv *priv)
{
u8 mode;
if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
mode = MCP25XXFD_REG_CON_MODE_LISTENONLY;
else if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
mode = MCP25XXFD_REG_CON_MODE_MIXED;
else
mode = MCP25XXFD_REG_CON_MODE_CAN2_0;
......@@ -2792,8 +2795,9 @@ static int mcp25xxfd_probe(struct spi_device *spi)
priv->can.do_get_berr_counter = mcp25xxfd_get_berr_counter;
priv->can.bittiming_const = &mcp25xxfd_bittiming_const;
priv->can.data_bittiming_const = &mcp25xxfd_data_bittiming_const;
priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING |
CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO;
priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_FD |
CAN_CTRLMODE_FD_NON_ISO;
priv->ndev = ndev;
priv->spi = spi;
priv->rx_int = rx_int;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment