drivers: can: add kconfig CAN_MAX_MB
Each CAN instance of S32K344 has different maximum number of message buffers, depends on payload. Add kconfig that defines maximum number of message buffers for concurrent active instances and update driver to compatible support S32k344. Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
This commit is contained in:
parent
c044b2e916
commit
a3fb2dcc2f
2 changed files with 18 additions and 4 deletions
|
@ -21,12 +21,21 @@ config CAN_MCUX_FLEXCAN_FD
|
|||
help
|
||||
Enable support for CAN-FD capable NXP FlexCAN devices.
|
||||
|
||||
config CAN_MAX_MB
|
||||
int "Maximum number of message buffers for concurrent active instances"
|
||||
default 16
|
||||
depends on SOC_SERIES_S32K3_M7
|
||||
range 1 96
|
||||
help
|
||||
Defines maximum number of message buffers for concurrent active instances.
|
||||
|
||||
config CAN_MAX_FILTER
|
||||
int "Maximum number of concurrent active RX filters"
|
||||
default 5
|
||||
range 1 15 if SOC_SERIES_KINETIS_KE1XF || SOC_SERIES_KINETIS_K6X
|
||||
range 1 13 if SOC_SERIES_IMX_RT && CAN_MCUX_FLEXCAN_FD
|
||||
range 1 63 if SOC_SERIES_IMX_RT
|
||||
range 1 96 if SOC_SERIES_S32K3_M7
|
||||
help
|
||||
Defines maximum number of concurrent active RX filters
|
||||
|
||||
|
|
|
@ -49,14 +49,19 @@ LOG_MODULE_REGISTER(can_mcux_flexcan, CONFIG_CAN_LOG_LEVEL);
|
|||
#define RX_START_IDX 0
|
||||
#endif
|
||||
|
||||
/* The maximum number of message buffers for concurrent active instances */
|
||||
#ifdef CONFIG_CAN_MAX_MB
|
||||
#define MCUX_FLEXCAN_MAX_MB CONFIG_CAN_MAX_MB
|
||||
#else
|
||||
#define MCUX_FLEXCAN_MAX_MB FSL_FEATURE_FLEXCAN_HAS_MESSAGE_BUFFER_MAX_NUMBERn(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* RX message buffers (filters) will take up the first N message
|
||||
* buffers. The rest are available for TX use.
|
||||
*/
|
||||
#define MCUX_FLEXCAN_MAX_RX (CONFIG_CAN_MAX_FILTER + RX_START_IDX)
|
||||
#define MCUX_FLEXCAN_MAX_TX \
|
||||
(FSL_FEATURE_FLEXCAN_HAS_MESSAGE_BUFFER_MAX_NUMBERn(0) \
|
||||
- MCUX_FLEXCAN_MAX_RX)
|
||||
#define MCUX_FLEXCAN_MAX_TX (MCUX_FLEXCAN_MAX_MB - MCUX_FLEXCAN_MAX_RX)
|
||||
|
||||
/*
|
||||
* Convert from RX message buffer index to allocated filter ID and
|
||||
|
@ -1246,7 +1251,7 @@ static int mcux_flexcan_init(const struct device *dev)
|
|||
data->dev = dev;
|
||||
|
||||
FLEXCAN_GetDefaultConfig(&flexcan_config);
|
||||
flexcan_config.maxMbNum = FSL_FEATURE_FLEXCAN_HAS_MESSAGE_BUFFER_MAX_NUMBERn(0);
|
||||
flexcan_config.maxMbNum = MCUX_FLEXCAN_MAX_MB;
|
||||
flexcan_config.clkSrc = config->clk_source;
|
||||
flexcan_config.baudRate = clock_freq /
|
||||
(1U + data->timing.prop_seg + data->timing.phase_seg1 +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue