Skip to content

Commit

Permalink
drivers: can: nxp_s32_canxl: calculate and set the TDCO
Browse files Browse the repository at this point in the history
Calculate and set the Transceiver Delay Compensation Offset (TDCO).

Fixes #73824

(cherry picked from commit 0781caf)

Original-Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
GitOrigin-RevId: 0781caf
Change-Id: I83d73fc1abb0c9735445693858d4f6a5b9eefdf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5621388
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
  • Loading branch information
congnguyenhuu authored and Chromeos LUCI committed Jun 11, 2024
1 parent a319f3b commit 5510aaf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/can/can_nxp_s32_canxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#define CAN_NXP_S32_MAX_BITRATE 8000000
#define CAN_NXP_S32_DATA_LENGTH 64

#define CAN_NXP_S32_TDCO_MAX FIELD_GET(CANXL_SIC_BTDCC_FTDCOFF_MASK, CANXL_SIC_BTDCC_FTDCOFF_MASK)

#ifdef CONFIG_CAN_NXP_S32_RX_FIFO
/* RX FIFO depth is fixed to the maximum value */
#define CAN_NXP_S32_RX_FIFO_DEPTH 32
Expand Down Expand Up @@ -706,6 +708,9 @@ static int can_nxp_s32_set_timing_data(const struct device *dev,
/* Set timing for CAN FD instance*/
CanXL_SetFDBaudRate(config->base_sic, &can_fd_time_segment);

Canexcel_Ip_SetTDCOffsetFD(config->instance, true, false,
CAN_CALC_TDCO((timing_data), 0U, CAN_NXP_S32_TDCO_MAX));

return 0;
}
#endif
Expand Down Expand Up @@ -964,6 +969,11 @@ static int can_nxp_s32_init(const struct device *dev)
/* Initialize CAN structure */
Canexcel_Ip_Init(config->instance, config->can_cfg, data->can_state);

#ifdef CAN_NXP_S32_FD_MODE
Canexcel_Ip_SetTDCOffsetFD(config->instance, true, false,
CAN_CALC_TDCO((&data->timing_data), 0U, CAN_NXP_S32_TDCO_MAX));
#endif

/* Configure time stamp */
#ifdef CONFIG_CAN_RX_TIMESTAMP
Canexcel_Ip_ConfigTimeStamp(config->instance, &time_stamp);
Expand Down

0 comments on commit 5510aaf

Please sign in to comment.