Skip to content

Commit

Permalink
drivers: can: mcux: mcan: use bosch m_can timing parameter initializers
Browse files Browse the repository at this point in the history
Some NXP SoC reference manuals contain a bug regarding the minimum values
for nominal phase segments. Valid Bosch M_CAN nominal phase segment
register values are 1 and up. Same goes for the maximum value for data
phase segment 2. Here, valid Bosch M_CAN register values are 0 to 31.

Using the static initializers fixes these.

Fixes: zephyrproject-rtos#58429

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
  • Loading branch information
henrikbrixandersen authored and nashif committed May 31, 2023
1 parent 6b13900 commit 1871fa7
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions drivers/can/can_mcux_mcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,13 @@ static const struct can_driver_api mcux_mcan_driver_api = {
* Note that the values here are the "physical" timing limits, whereas
* the register field limits are physical values minus 1 (which is
* handled by the register assignments in the common MCAN driver code).
*
* Beware that at least some SoC reference manuals contain a bug
* regarding the minimum values for nominal phase segments. Valid
* register values are 1 and up.
*/
.timing_min = {
.sjw = 1,
.prop_seg = 0,
.phase_seg1 = 1,
.phase_seg2 = 1,
.prescaler = 1
},
.timing_max = {
.sjw = 128,
.prop_seg = 0,
.phase_seg1 = 256,
.phase_seg2 = 128,
.prescaler = 512,
},
.timing_min = CAN_MCAN_TIMING_MIN_INITIALIZER,
.timing_max = CAN_MCAN_TIMING_MAX_INITIALIZER,
#ifdef CONFIG_CAN_FD_MODE
.set_timing_data = can_mcan_set_timing_data,
/*
Expand All @@ -172,21 +164,13 @@ static const struct can_driver_api mcux_mcan_driver_api = {
* Note that the values here are the "physical" timing limits, whereas
* the register field limits are physical values minus 1 (which is
* handled by the register assignments in the common MCAN driver code).
*
* Beware that at least some SoC reference manuals contain a bug
* regarding the maximum value for data phase segment 2. Valid register
* values are 0 to 31.
*/
.timing_data_min = {
.sjw = 1,
.prop_seg = 0,
.phase_seg1 = 1,
.phase_seg2 = 1,
.prescaler = 1,
},
.timing_data_max = {
.sjw = 16,
.prop_seg = 0,
.phase_seg1 = 16,
.phase_seg2 = 16,
.prescaler = 32,
}
.timing_data_min = CAN_MCAN_TIMING_DATA_MIN_INITIALIZER,
.timing_data_max = CAN_MCAN_TIMING_DATA_MAX_INITIALIZER,
#endif /* CONFIG_CAN_FD_MODE */
};

Expand Down

0 comments on commit 1871fa7

Please sign in to comment.