Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imx9/flexcan: Make self reception disable to be configurable #14373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions arch/arm64/src/imx9/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,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 @@ -1144,6 +1151,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