Lines Matching +full:timing +full:- +full:config +full:- +full:mask
2 * Copyright 2022-2024 NXP
4 * SPDX-License-Identifier: Apache-2.0
30 #define RX_MBIDX_TO_ALLOC_IDX(x) (x - CONFIG_CAN_NXP_S32_MAX_TX)
125 struct can_timing timing; member
152 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_config_rx_fifo_filter() local
153 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_config_rx_fifo_filter()
156 (void)config->base_rx_fifo_ctrl->RXFSYSLOCK; in can_nxp_s32_config_rx_fifo_filter()
158 CanXL_ConfigIDFilter(config->base_rx_fifo, in can_nxp_s32_config_rx_fifo_filter()
159 &data->rx_fifo_filter[filter_id], filter_id); in can_nxp_s32_config_rx_fifo_filter()
161 if ((config->base_rx_fifo_ctrl->RXFCSTA & CANXL_RXFIFO_CONTROL_RXFCSTA_SYSLOCK_MASK) in can_nxp_s32_config_rx_fifo_filter()
164 config->base_rx_fifo_ctrl->RXFSYSLOCK = in can_nxp_s32_config_rx_fifo_filter()
172 int alloc = -ENOSPC; in can_nxp_s32_get_rx_fifo_filter()
173 uint32_t mask; in can_nxp_s32_get_rx_fifo_filter() local
176 mask = data->rx_fifo_filter[filter_id].idAddrFilterL; in can_nxp_s32_get_rx_fifo_filter()
178 if (mask == 0) { in can_nxp_s32_get_rx_fifo_filter()
182 if ((data->rx_fifo[queue_idx].Header.Id & mask) == in can_nxp_s32_get_rx_fifo_filter()
183 (data->rx_fifo_filter[filter_id].idAddrFilterH & mask)) { in can_nxp_s32_get_rx_fifo_filter()
195 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_start() local
196 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_start()
199 if (data->common.started) { in can_nxp_s32_start()
200 return -EALREADY; in can_nxp_s32_start()
203 if (config->common.phy != NULL) { in can_nxp_s32_start()
204 err = can_transceiver_enable(config->common.phy, data->common.mode); in can_nxp_s32_start()
213 Canexcel_Ip_ClearErrorStatus(config->instance, CANXL_CLEAR_ALL_ERRORS); in can_nxp_s32_start()
215 data->common.started = true; in can_nxp_s32_start()
222 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_stop() local
223 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_stop()
229 if (!data->common.started) { in can_nxp_s32_stop()
230 return -EALREADY; in can_nxp_s32_stop()
233 data->common.started = false; in can_nxp_s32_stop()
237 function = data->tx_cbs[alloc].function; in can_nxp_s32_stop()
238 arg = data->tx_cbs[alloc].arg; in can_nxp_s32_stop()
240 if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) { in can_nxp_s32_stop()
241 if (Canexcel_Ip_DeactivateMD(config->instance, in can_nxp_s32_stop()
246 function(dev, -ENETDOWN, arg); in can_nxp_s32_stop()
247 k_sem_give(&data->tx_allocs_sem); in can_nxp_s32_stop()
251 if (config->common.phy != NULL) { in can_nxp_s32_stop()
252 err = can_transceiver_disable(config->common.phy); in can_nxp_s32_stop()
266 base->BCFG2 = (base->BCFG2 & ~CANXL_SIC_BCFG2_FDEN_MASK) | in can_nxp_s32_set_fd_mode()
268 base->BCFG1 = (base->BCFG1 & ~CANXL_SIC_BCFG1_FDRSDIS_MASK) | in can_nxp_s32_set_fd_mode()
270 base->BTDCC &= ~(CANXL_SIC_BTDCC_FTDCEN_MASK | in can_nxp_s32_set_fd_mode()
277 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_set_mode() local
278 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_set_mode()
283 if (data->common.started) { in can_nxp_s32_set_mode()
284 return -EBUSY; in can_nxp_s32_set_mode()
297 return -ENOTSUP; in can_nxp_s32_set_mode()
303 "mode listen-only at the same time: 0x%08x", mode); in can_nxp_s32_set_mode()
304 return -ENOTSUP; in can_nxp_s32_set_mode()
316 Canexcel_Ip_EnterFreezeMode(config->instance); in can_nxp_s32_set_mode()
318 can_nxp_s32_set_fd_mode(config->base_sic, canfd, brs); in can_nxp_s32_set_mode()
328 status = CanXL_ConfigCtrlOptions(config->base_sic, options); in can_nxp_s32_set_mode()
330 return -EIO; in can_nxp_s32_set_mode()
334 CanXL_SetOperationMode(config->base_sic, can_nxp_s32_mode); in can_nxp_s32_set_mode()
336 Canexcel_Ip_ExitFreezeMode(config->instance); in can_nxp_s32_set_mode()
338 data->common.mode = mode; in can_nxp_s32_set_mode()
345 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_get_core_clock() local
349 return clock_control_get_rate(config->clock_dev, config->clock_subsys, rate); in can_nxp_s32_get_core_clock()
362 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_get_state() local
363 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_get_state()
367 if (!data->common.started) { in can_nxp_s32_get_state()
370 Canexcel_Ip_GetControllerStatus(config->instance, &bcanxl_status); in can_nxp_s32_get_state()
375 } else if (config->base_sic->SYSS & in can_nxp_s32_get_state()
385 Canexcel_Ip_GetControllerTxErrorCounter(config->instance, &err_cnt->tx_err_cnt); in can_nxp_s32_get_state()
386 Canexcel_Ip_GetControllerRxErrorCounter(config->instance, &err_cnt->rx_err_cnt); in can_nxp_s32_get_state()
396 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_set_state_change_callback()
398 data->common.state_change_cb = callback; in can_nxp_s32_set_state_change_callback()
399 data->common.state_change_cb_user_data = user_data; in can_nxp_s32_set_state_change_callback()
405 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_recover() local
406 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_recover()
411 if (!data->common.started) { in can_nxp_s32_recover()
412 return -ENETDOWN; in can_nxp_s32_recover()
415 if ((data->common.mode & CAN_MODE_MANUAL_RECOVERY) == 0U) { in can_nxp_s32_recover()
416 return -ENOTSUP; in can_nxp_s32_recover()
425 config->base_sic->BCFG1 &= (~CANXL_SIC_BCFG1_ABRDIS_MASK); in can_nxp_s32_recover()
432 k_uptime_ticks() - start_time >= timeout.ticks) { in can_nxp_s32_recover()
433 ret = -EAGAIN; in can_nxp_s32_recover()
440 config->base_sic->BCFG1 |= CANXL_SIC_BCFG1_ABRDIS_MASK; in can_nxp_s32_recover()
448 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_remove_rx_filter() local
449 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_remove_rx_filter()
457 k_mutex_lock(&data->rx_mutex, K_FOREVER); in can_nxp_s32_remove_rx_filter()
459 if (atomic_test_and_clear_bit(data->rx_allocs, filter_id)) { in can_nxp_s32_remove_rx_filter()
461 data->rx_fifo_filter[mb_indx].idAddrFilterL = 0; in can_nxp_s32_remove_rx_filter()
462 data->rx_fifo_filter[mb_indx].idAddrFilterH = 0; in can_nxp_s32_remove_rx_filter()
464 Canexcel_Ip_EnterFreezeMode(config->instance); in can_nxp_s32_remove_rx_filter()
468 Canexcel_Ip_ExitFreezeMode(config->instance); in can_nxp_s32_remove_rx_filter()
470 if (Canexcel_Ip_DeactivateMD(config->instance, mb_indx)) { in can_nxp_s32_remove_rx_filter()
475 data->rx_cbs[filter_id].function = NULL; in can_nxp_s32_remove_rx_filter()
476 data->rx_cbs[filter_id].arg = NULL; in can_nxp_s32_remove_rx_filter()
477 data->rx_cbs[filter_id].filter = (struct can_filter){0}; in can_nxp_s32_remove_rx_filter()
482 k_mutex_unlock(&data->rx_mutex); in can_nxp_s32_remove_rx_filter()
490 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_add_rx_filter() local
491 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_add_rx_filter()
492 int alloc = -ENOSPC; in can_nxp_s32_add_rx_filter()
494 uint32_t mask; in can_nxp_s32_add_rx_filter() local
496 if ((filter->flags & ~(CAN_FILTER_IDE)) != 0) { in can_nxp_s32_add_rx_filter()
497 LOG_ERR("unsupported CAN filter flags 0x%02x", filter->flags); in can_nxp_s32_add_rx_filter()
498 return -ENOTSUP; in can_nxp_s32_add_rx_filter()
501 k_mutex_lock(&data->rx_mutex, K_FOREVER); in can_nxp_s32_add_rx_filter()
505 if (!atomic_test_and_set_bit(data->rx_allocs, i)) { in can_nxp_s32_add_rx_filter()
511 if (alloc == -ENOSPC) { in can_nxp_s32_add_rx_filter()
516 data->rx_cbs[alloc].function = callback; in can_nxp_s32_add_rx_filter()
517 data->rx_cbs[alloc].arg = user_data; in can_nxp_s32_add_rx_filter()
518 data->rx_cbs[alloc].filter = *filter; in can_nxp_s32_add_rx_filter()
520 /* Set Rx Mb individual mask for */ in can_nxp_s32_add_rx_filter()
522 if (!!(filter->flags & CAN_FILTER_IDE)) { in can_nxp_s32_add_rx_filter()
523 mask = filter->mask & CANXL_IP_ID_EXT_MASK; in can_nxp_s32_add_rx_filter()
525 mask = (filter->mask << CANXL_IP_ID_STD_SHIFT) & CANXL_IP_ID_STD_MASK; in can_nxp_s32_add_rx_filter()
529 mask |= CANXL_MSG_DESCRIPTORS_MDFLT1FD_RTRMSK_MASK; in can_nxp_s32_add_rx_filter()
532 Canexcel_Ip_EnterFreezeMode(config->instance); in can_nxp_s32_add_rx_filter()
537 if (!!(filter->flags & CAN_FILTER_IDE)) { in can_nxp_s32_add_rx_filter()
538 filter_id = filter->id & CANXL_IP_ID_EXT_MASK; in can_nxp_s32_add_rx_filter()
540 filter_id = (filter->id << CANXL_IP_ID_STD_SHIFT) & CANXL_IP_ID_STD_MASK; in can_nxp_s32_add_rx_filter()
543 data->rx_fifo_filter[mb_indx].filterType = CANEXCEL_IP_RX_FIFO_MASK_FILTER; in can_nxp_s32_add_rx_filter()
544 data->rx_fifo_filter[mb_indx].idAddrFilterL = mask; in can_nxp_s32_add_rx_filter()
545 data->rx_fifo_filter[mb_indx].idAddrFilterH = filter_id; in can_nxp_s32_add_rx_filter()
549 data->rx_cbs[alloc].rx_info = (Canexcel_Ip_DataInfoType) { in can_nxp_s32_add_rx_filter()
551 .idType = !!(filter->flags & CAN_FILTER_IDE) ? in can_nxp_s32_add_rx_filter()
556 Canexcel_Ip_SetRxIndividualMask(config->instance, mb_indx, in can_nxp_s32_add_rx_filter()
557 data->rx_cbs[alloc].rx_info.frame, mask); in can_nxp_s32_add_rx_filter()
559 Canexcel_Ip_ConfigRx(config->instance, mb_indx, filter->id, in can_nxp_s32_add_rx_filter()
560 &data->rx_cbs[alloc].rx_info); in can_nxp_s32_add_rx_filter()
562 Canexcel_Ip_ReceiveFD(config->instance, mb_indx, &data->rx_msg[alloc], FALSE); in can_nxp_s32_add_rx_filter()
565 Canexcel_Ip_ExitFreezeMode(config->instance); in can_nxp_s32_add_rx_filter()
568 k_mutex_unlock(&data->rx_mutex); in can_nxp_s32_add_rx_filter()
578 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_send() local
579 uint8_t data_length = can_dlc_to_bytes(frame->dlc); in can_nxp_s32_send()
580 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_send()
586 if ((frame->flags & ~(CAN_FRAME_IDE | CAN_FRAME_FDF | CAN_FRAME_BRS)) != 0) { in can_nxp_s32_send()
587 LOG_ERR("unsupported CAN frame flags 0x%02x", frame->flags); in can_nxp_s32_send()
588 return -ENOTSUP; in can_nxp_s32_send()
591 if ((frame->flags & CAN_FRAME_FDF) != 0 && in can_nxp_s32_send()
592 (config->base_sic->BCFG2 & CANXL_SIC_BCFG2_FDEN_MASK) == 0) { in can_nxp_s32_send()
593 LOG_ERR("CAN FD format not supported in non-FD mode"); in can_nxp_s32_send()
594 return -ENOTSUP; in can_nxp_s32_send()
597 if ((frame->flags & CAN_FRAME_BRS) != 0 && in can_nxp_s32_send()
598 ~(config->base_sic->BCFG1 & CANXL_SIC_BCFG1_FDRSDIS_MASK) == 0) { in can_nxp_s32_send()
599 LOG_ERR("CAN FD BRS not supported in non-FD mode"); in can_nxp_s32_send()
600 return -ENOTSUP; in can_nxp_s32_send()
603 if ((frame->flags & ~CAN_FRAME_IDE) != 0) { in can_nxp_s32_send()
604 LOG_ERR("unsupported CAN frame flags 0x%02x", frame->flags); in can_nxp_s32_send()
605 return -ENOTSUP; in can_nxp_s32_send()
609 if (data_length > sizeof(frame->data)) { in can_nxp_s32_send()
611 data_length, sizeof(frame->data)); in can_nxp_s32_send()
612 return -EINVAL; in can_nxp_s32_send()
615 if ((frame->flags & CAN_FRAME_FDF) == 0) { in can_nxp_s32_send()
616 if (frame->dlc > CAN_MAX_DLC) { in can_nxp_s32_send()
617 LOG_ERR("DLC of %d for non-FD format frame", frame->dlc); in can_nxp_s32_send()
618 return -EINVAL; in can_nxp_s32_send()
622 if (frame->dlc > CANFD_MAX_DLC) { in can_nxp_s32_send()
623 LOG_ERR("DLC of %d for CAN FD format frame", frame->dlc); in can_nxp_s32_send()
624 return -EINVAL; in can_nxp_s32_send()
629 if (!data->common.started) { in can_nxp_s32_send()
630 return -ENETDOWN; in can_nxp_s32_send()
635 LOG_ERR("Transmit failed, bus-off"); in can_nxp_s32_send()
636 return -ENETUNREACH; in can_nxp_s32_send()
639 if (k_sem_take(&data->tx_allocs_sem, timeout) != 0) { in can_nxp_s32_send()
640 return -EAGAIN; in can_nxp_s32_send()
644 if (!atomic_test_and_set_bit(data->tx_allocs, alloc)) { in can_nxp_s32_send()
649 data->tx_cbs[alloc].function = callback; in can_nxp_s32_send()
650 data->tx_cbs[alloc].arg = user_data; in can_nxp_s32_send()
652 data->tx_cbs[alloc].tx_info = (Canexcel_Ip_DataInfoType) { in can_nxp_s32_send()
653 .frame = !!(frame->flags & CAN_FRAME_FDF) ? in can_nxp_s32_send()
655 .enable_brs = !!(frame->flags & CAN_FRAME_BRS) ? TRUE : FALSE, in can_nxp_s32_send()
656 .idType = !!(frame->flags & CAN_FRAME_IDE) ? in can_nxp_s32_send()
667 dev->name, data_length, in can_nxp_s32_send()
668 mb_indx, frame->id, in can_nxp_s32_send()
669 !!(frame->flags & CAN_FRAME_IDE) ? in can_nxp_s32_send()
671 !!(frame->flags & CAN_FRAME_RTR) ? "RTR" : "", in can_nxp_s32_send()
672 !!(frame->flags & CAN_FRAME_FDF) ? "FD frame" : "", in can_nxp_s32_send()
673 !!(frame->flags & CAN_FRAME_BRS) ? "BRS" : ""); in can_nxp_s32_send()
675 k_mutex_lock(&data->tx_mutex, K_FOREVER); in can_nxp_s32_send()
677 status = Canexcel_Ip_SendFDMsg(config->instance, mb_indx, &data->tx_cbs[alloc].tx_info, in can_nxp_s32_send()
678 frame->id, (uint8_t *)&frame->data, &data->tx_msg[alloc]); in can_nxp_s32_send()
679 k_mutex_unlock(&data->tx_mutex); in can_nxp_s32_send()
682 return -EIO; in can_nxp_s32_send()
688 static void nxp_s32_zcan_timing_to_canxl_timing(const struct can_timing *timing, in nxp_s32_zcan_timing_to_canxl_timing() argument
692 timing->prop_seg, timing->phase_seg1, timing->phase_seg2, in nxp_s32_zcan_timing_to_canxl_timing()
693 timing->prescaler, timing->sjw); in nxp_s32_zcan_timing_to_canxl_timing()
695 canxl_timing->propSeg = timing->prop_seg - 1U; in nxp_s32_zcan_timing_to_canxl_timing()
696 canxl_timing->phaseSeg1 = timing->phase_seg1 - 1U; in nxp_s32_zcan_timing_to_canxl_timing()
697 canxl_timing->phaseSeg2 = timing->phase_seg2 - 1U; in nxp_s32_zcan_timing_to_canxl_timing()
698 canxl_timing->preDivider = timing->prescaler - 1U; in nxp_s32_zcan_timing_to_canxl_timing()
699 canxl_timing->rJumpwidth = timing->sjw - 1U; in nxp_s32_zcan_timing_to_canxl_timing()
703 const struct can_timing *timing) in can_nxp_s32_set_timing() argument
705 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_set_timing() local
706 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_set_timing()
709 if (data->common.started) { in can_nxp_s32_set_timing()
710 return -EBUSY; in can_nxp_s32_set_timing()
713 nxp_s32_zcan_timing_to_canxl_timing(timing, &can_time_segment); in can_nxp_s32_set_timing()
715 /* Set timing for CAN instance*/ in can_nxp_s32_set_timing()
716 CanXL_SetBaudRate(config->base_sic, &can_time_segment); in can_nxp_s32_set_timing()
725 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_set_timing_data() local
726 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_set_timing_data()
729 if (data->common.started) { in can_nxp_s32_set_timing_data()
730 return -EBUSY; in can_nxp_s32_set_timing_data()
735 /* Set timing for CAN FD instance*/ in can_nxp_s32_set_timing_data()
736 CanXL_SetFDBaudRate(config->base_sic, &can_fd_time_segment); in can_nxp_s32_set_timing_data()
738 Canexcel_Ip_SetTDCOffsetFD(config->instance, true, false, in can_nxp_s32_set_timing_data()
750 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_err_callback() local
751 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_err_callback()
754 void *cb_data = data->common.state_change_cb_user_data; in can_nxp_s32_err_callback()
805 if (data->state != state) { in can_nxp_s32_err_callback()
806 data->state = state; in can_nxp_s32_err_callback()
807 if (data->common.state_change_cb) { in can_nxp_s32_err_callback()
808 data->common.state_change_cb(dev, state, err_cnt, cb_data); in can_nxp_s32_err_callback()
813 /* Abort any pending TX frames in case of bus-off */ in can_nxp_s32_err_callback()
816 function = data->tx_cbs[alloc].function; in can_nxp_s32_err_callback()
817 arg = data->tx_cbs[alloc].arg; in can_nxp_s32_err_callback()
819 if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) { in can_nxp_s32_err_callback()
820 if (Canexcel_Ip_DeactivateMD(config->instance, in can_nxp_s32_err_callback()
825 function(dev, -ENETUNREACH, arg); in can_nxp_s32_err_callback()
826 k_sem_give(&data->tx_allocs_sem); in can_nxp_s32_err_callback()
838 frame->flags |= CAN_FRAME_IDE; in nxp_s32_msg_data_to_zcan_frame()
841 if (!!(frame->flags & CAN_FRAME_IDE)) { in nxp_s32_msg_data_to_zcan_frame()
842 frame->id = (msg_data.Header.Id & CANXL_IP_ID_EXT_MASK); in nxp_s32_msg_data_to_zcan_frame()
844 frame->id = ((msg_data.Header.Id & CANXL_IP_ID_STD_MASK) in nxp_s32_msg_data_to_zcan_frame()
848 frame->dlc = (msg_data.Header.Control & CANXL_TX_HEADER_DLC_MASK) in nxp_s32_msg_data_to_zcan_frame()
852 frame->flags |= CAN_FRAME_FDF; in nxp_s32_msg_data_to_zcan_frame()
856 frame->flags |= CAN_FRAME_BRS; in nxp_s32_msg_data_to_zcan_frame()
860 frame->flags |= CAN_FRAME_RTR; in nxp_s32_msg_data_to_zcan_frame()
862 memcpy(frame->data, msg_data.data, can_dlc_to_bytes(frame->dlc)); in nxp_s32_msg_data_to_zcan_frame()
866 frame->timestamp = msg_data.timeStampL; in nxp_s32_msg_data_to_zcan_frame()
874 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_ctrl_callback() local
875 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_ctrl_callback()
883 tx_func = data->tx_cbs[alloc].function; in can_nxp_s32_ctrl_callback()
884 LOG_DBG("%s: Sent Tx Mb %d", dev->name, buffidx); in can_nxp_s32_ctrl_callback()
885 if (atomic_test_and_clear_bit(data->tx_allocs, alloc)) { in can_nxp_s32_ctrl_callback()
886 tx_func(dev, 0, data->tx_cbs[alloc].arg); in can_nxp_s32_ctrl_callback()
887 k_sem_give(&data->tx_allocs_sem); in can_nxp_s32_ctrl_callback()
891 uint8_t queue_idx = ((config->base_rx_fifo_ctrl->RXFCSTA & in can_nxp_s32_ctrl_callback()
893 CANXL_RXFIFO_CONTROL_RXFCSTA_HWPOINTER_SHIFT) - in can_nxp_s32_ctrl_callback()
898 if (alloc != -ENOSPC) { in can_nxp_s32_ctrl_callback()
899 rx_func = data->rx_cbs[alloc].function; in can_nxp_s32_ctrl_callback()
900 if (atomic_test_bit(data->rx_allocs, alloc)) { in can_nxp_s32_ctrl_callback()
901 nxp_s32_msg_data_to_zcan_frame(data->rx_fifo[queue_idx], &frame); in can_nxp_s32_ctrl_callback()
906 dev->name, can_dlc_to_bytes(frame.dlc), in can_nxp_s32_ctrl_callback()
914 rx_func(dev, &frame, data->rx_cbs[alloc].arg); in can_nxp_s32_ctrl_callback()
919 config->base_rx_fifo_ctrl->RXFSYSPOP = 0; in can_nxp_s32_ctrl_callback()
923 rx_func = data->rx_cbs[alloc].function; in can_nxp_s32_ctrl_callback()
924 if (atomic_test_bit(data->rx_allocs, alloc)) { in can_nxp_s32_ctrl_callback()
925 nxp_s32_msg_data_to_zcan_frame(data->rx_msg[alloc], &frame); in can_nxp_s32_ctrl_callback()
930 dev->name, can_dlc_to_bytes(frame.dlc), in can_nxp_s32_ctrl_callback()
938 rx_func(dev, &frame, data->rx_cbs[alloc].arg); in can_nxp_s32_ctrl_callback()
940 if (Canexcel_Ip_ReceiveFD(config->instance, buffidx, in can_nxp_s32_ctrl_callback()
941 &data->rx_msg[alloc], FALSE) != CANEXCEL_STATUS_SUCCESS) { in can_nxp_s32_ctrl_callback()
951 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_init() local
952 struct can_nxp_s32_data *data = dev->data; in can_nxp_s32_init()
962 if (config->common.phy != NULL) { in can_nxp_s32_init()
963 if (!device_is_ready(config->common.phy)) { in can_nxp_s32_init()
965 return -ENODEV; in can_nxp_s32_init()
969 if (!device_is_ready(config->clock_dev)) { in can_nxp_s32_init()
971 return -ENODEV; in can_nxp_s32_init()
974 err = clock_control_on(config->clock_dev, config->clock_subsys); in can_nxp_s32_init()
980 k_mutex_init(&data->rx_mutex); in can_nxp_s32_init()
981 k_mutex_init(&data->tx_mutex); in can_nxp_s32_init()
982 k_sem_init(&data->tx_allocs_sem, CONFIG_CAN_NXP_S32_MAX_TX, CONFIG_CAN_NXP_S32_MAX_TX); in can_nxp_s32_init()
984 err = pinctrl_apply_state(config->pin_cfg, PINCTRL_STATE_DEFAULT); in can_nxp_s32_init()
990 IP_MC_RGM->PRST_0[0].PRST_0 &= in can_nxp_s32_init()
993 err = can_calc_timing(dev, &data->timing, config->common.bitrate, in can_nxp_s32_init()
994 config->common.sample_point); in can_nxp_s32_init()
995 if (err == -EINVAL) { in can_nxp_s32_init()
996 LOG_ERR("Can't find timing for given param"); in can_nxp_s32_init()
997 return -EIO; in can_nxp_s32_init()
1001 LOG_WRN("Sample-point error : %d", err); in can_nxp_s32_init()
1004 LOG_DBG("Setting CAN bitrate %d:", config->common.bitrate); in can_nxp_s32_init()
1005 nxp_s32_zcan_timing_to_canxl_timing(&data->timing, &config->can_cfg->bitrate); in can_nxp_s32_init()
1008 err = can_calc_timing_data(dev, &data->timing_data, config->common.bitrate_data, in can_nxp_s32_init()
1009 config->common.sample_point_data); in can_nxp_s32_init()
1010 if (err == -EINVAL) { in can_nxp_s32_init()
1011 LOG_ERR("Can't find timing data for given param"); in can_nxp_s32_init()
1012 return -EIO; in can_nxp_s32_init()
1016 LOG_WRN("Sample-point-data err : %d", err); in can_nxp_s32_init()
1019 LOG_DBG("Setting CAN FD bitrate %d:", config->common.bitrate_data); in can_nxp_s32_init()
1020 nxp_s32_zcan_timing_to_canxl_timing(&data->timing_data, &config->can_cfg->Fd_bitrate); in can_nxp_s32_init()
1024 Canexcel_Ip_Init(config->instance, config->can_cfg, data->can_state); in can_nxp_s32_init()
1027 Canexcel_Ip_SetTDCOffsetFD(config->instance, true, false, in can_nxp_s32_init()
1028 CAN_CALC_TDCO((&data->timing_data), 0U, CAN_NXP_S32_TDCO_MAX)); in can_nxp_s32_init()
1033 Canexcel_Ip_ConfigTimeStamp(config->instance, &time_stamp); in can_nxp_s32_init()
1037 Canexcel_Ip_EnableInterrupts(config->instance); in can_nxp_s32_init()
1040 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_RX_WARNING, TRUE); in can_nxp_s32_init()
1041 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_TX_WARNING, TRUE); in can_nxp_s32_init()
1042 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_ERR, TRUE); in can_nxp_s32_init()
1043 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_BUSOFF, TRUE); in can_nxp_s32_init()
1044 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_PASIVE_ERR, TRUE); in can_nxp_s32_init()
1045 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_RXSMB_OVER, TRUE); in can_nxp_s32_init()
1047 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_ERR_FAST, TRUE); in can_nxp_s32_init()
1050 CanXL_SetErrIntCmd(config->base_sic, CANXL_INT_RXFIFO_OVER, TRUE); in can_nxp_s32_init()
1053 config->base_rx_fifo->AFCFG = in can_nxp_s32_init()
1054 CANXL_RXFIFO_AFCFG_ACPTID(CONFIG_CAN_NXP_S32_MAX_RX - 1); in can_nxp_s32_init()
1057 config->irq_config_func(); in can_nxp_s32_init()
1059 can_nxp_s32_get_state(dev, &data->state, NULL); in can_nxp_s32_init()
1066 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_isr_rx_tx_mru() local
1068 Canexcel_Ip_RxTxIRQHandler(config->instance); in can_nxp_s32_isr_rx_tx_mru()
1070 if ((config->base_mru->CHXCONFIG[0u].CH_CFG0 & CANXL_MRU_CH_CFG0_CHE_MASK) in can_nxp_s32_isr_rx_tx_mru()
1072 Canexcel_Ip_MruIRQHandler(config->instance); in can_nxp_s32_isr_rx_tx_mru()
1078 const struct can_nxp_s32_config *config = dev->config; in can_nxp_s32_isr_error() local
1080 Canexcel_Ip_ErrIRQHandler(config->instance); in can_nxp_s32_isr_error()