Skip to content

Commit a50b69d

Browse files
hakehuangnashif
authored andcommitted
drivers: mcux_flexcan driver errata
in NXP flexcan driver we need add ERRATA for ERRATA 5461 and 5829, reproted in #31555 Signed-off-by: Hake Huang <[email protected]>
1 parent 3f1d1f5 commit a50b69d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/can/can_mcux_flexcan.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ LOG_MODULE_REGISTER(can_mcux_flexcan);
3535
#error You must either set a sampling-point or timings (phase-seg* and prop-seg)
3636
#endif
3737

38+
#if ((defined(FSL_FEATURE_FLEXCAN_HAS_ERRATA_5641) && FSL_FEATURE_FLEXCAN_HAS_ERRATA_5641) || \
39+
(defined(FSL_FEATURE_FLEXCAN_HAS_ERRATA_5829) && FSL_FEATURE_FLEXCAN_HAS_ERRATA_5829))
40+
/* the first valid MB should be occupied by ERRATA 5461 or 5829. */
41+
#define RX_START_IDX 1
42+
#else
43+
#define RX_START_IDX 0
44+
#endif
45+
3846
/*
3947
* RX message buffers (filters) will take up the first N message
4048
* buffers. The rest are available for TX use.
@@ -165,6 +173,7 @@ static int mcux_flexcan_set_mode(const struct device *dev, enum can_mode mode)
165173
}
166174

167175
FLEXCAN_GetDefaultConfig(&flexcan_config);
176+
flexcan_config.maxMbNum = FSL_FEATURE_FLEXCAN_HAS_MESSAGE_BUFFER_MAX_NUMBERn(0);
168177
flexcan_config.clkSrc = config->clk_source;
169178
flexcan_config.baudRate = clock_freq /
170179
(1U + data->timing.prop_seg + data->timing.phase_seg1 +
@@ -370,7 +379,7 @@ static int mcux_flexcan_attach_isr(const struct device *dev,
370379
k_mutex_lock(&data->rx_mutex, K_FOREVER);
371380

372381
/* Find and allocate RX message buffer */
373-
for (i = 0; i < MCUX_FLEXCAN_MAX_RX; i++) {
382+
for (i = RX_START_IDX; i < MCUX_FLEXCAN_MAX_RX; i++) {
374383
if (!atomic_test_and_set_bit(data->rx_allocs, i)) {
375384
alloc = i;
376385
break;

0 commit comments

Comments
 (0)