Skip to content

Commit

Permalink
imx9/flexcan: Make self reception disable to be configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Oct 16, 2024
1 parent 43a6b1f commit 2281715
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
14 changes: 14 additions & 0 deletions arch/arm64/src/imx9/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,13 @@ config IMX9_FLEXCAN1_DATA_SAMPLEP
depends on NET_CAN_CANFD
default 75

config IMX9_FLEXCAN1_SRXDIS
bool "CAN1 Self reception disable"
default n
---help---
Configure this y if you want that CAN1 doesn't receive the
frames which it sent itself

endmenu # IMX9_FLEXCAN1

menu "FLEXCAN2 Configuration"
Expand Down Expand Up @@ -1152,6 +1159,13 @@ config IMX9_FLEXCAN2_DATA_SAMPLEP
depends on NET_CAN_CANFD
default 75

config IMX9_FLEXCAN2_SRXDIS
bool "CAN2 Self reception disable"
default n
---help---
Configure this y if you want that CAN2 doesn't receive the
frames which it sent itself

endmenu # IMX9_FLEXCAN2

endmenu # iMX Peripheral Selection
Expand Down
18 changes: 16 additions & 2 deletions arch/arm64/src/imx9/imx9_flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ struct imx9_driver_s
const bool canfd_capable;
const uint32_t *txdesc; /* A pointer to the list of TX descriptor */
const uint32_t *rxdesc; /* A pointer to the list of RX descriptors */
const bool srxdis; /* Self reception disable */

uint32_t clk_freq; /* Peripheral clock frequency */
bool bifup; /* true:ifup false:ifdown */
Expand Down Expand Up @@ -223,6 +224,10 @@ static struct imx9_driver_s g_flexcan1 =

.txdesc = g_tx_pool_can1,
.rxdesc = g_rx_pool_can1,

# if defined(CONFIG_IMX9_FLEXCAN1_SRXDIS)
.srxdis = true,
# endif
};
#endif

Expand Down Expand Up @@ -264,6 +269,10 @@ static struct imx9_driver_s g_flexcan2 =

.txdesc = g_tx_pool_can2,
.rxdesc = g_rx_pool_can2,

# if defined(CONFIG_IMX9_FLEXCAN2_SRXDIS)
.srxdis = true,
# endif
};
#endif

Expand Down Expand Up @@ -1778,11 +1787,16 @@ static int imx9_initialize(struct imx9_driver_s *priv)
/* Configure MCR */

modifyreg32(priv->base + IMX9_CAN_MCR_OFFSET, CAN_MCR_MAXMB_MASK,
CAN_MCR_SLFWAK | CAN_MCR_WRNEN | CAN_MCR_SRXDIS |
CAN_MCR_WAKSRC | CAN_MCR_IRMQ | CAN_MCR_LPRIOEN | CAN_MCR_AEN |
CAN_MCR_SLFWAK | CAN_MCR_WRNEN | CAN_MCR_WAKSRC |
CAN_MCR_IRMQ | CAN_MCR_LPRIOEN | CAN_MCR_AEN |
(((TOTALMBCOUNT - 1) << CAN_MCR_MAXMB_SHIFT) &
CAN_MCR_MAXMB_MASK));

if (priv->srxdis)
{
modifyreg32(priv->base + IMX9_CAN_MCR_OFFSET, 0, CAN_MCR_SRXDIS);
}

if (!priv->canfd_capable)
{
modifyreg32(priv->base + IMX9_CAN_CTRL1_OFFSET,
Expand Down

0 comments on commit 2281715

Please sign in to comment.