diff --git a/boards/nxp/frdm_mcxaxx6/board.c b/boards/nxp/frdm_mcxaxx6/board.c index ef0ff88450e7b..8dec3fcfb1804 100644 --- a/boards/nxp/frdm_mcxaxx6/board.c +++ b/boards/nxp/frdm_mcxaxx6/board.c @@ -297,6 +297,12 @@ void board_early_init_hook(void) CLOCK_SetClockDiv(kCLOCK_DivLPTMR0, 1u); #endif /* DT_PROP(DT_NODELABEL(lptmr0), clk_source) */ +#endif + +#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcan0)) + CLOCK_SetClockDiv(kCLOCK_DivFLEXCAN0, 1U); + CLOCK_SetClockDiv(kCLOCK_DivFRO_HF, 1U); + CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCAN0); #endif /* Set SystemCoreClock variable. */ diff --git a/boards/nxp/frdm_mcxaxx6/board_common.dtsi b/boards/nxp/frdm_mcxaxx6/board_common.dtsi index 9f6bbbc20cfb1..8572dc8a0e104 100644 --- a/boards/nxp/frdm_mcxaxx6/board_common.dtsi +++ b/boards/nxp/frdm_mcxaxx6/board_common.dtsi @@ -26,6 +26,7 @@ zephyr,code-partition = &slot0_partition; zephyr,console = &lpuart2; zephyr,shell-uart = &lpuart2; + zephyr,canbus = &flexcan0; }; leds { @@ -207,3 +208,9 @@ &lptmr0 { status = "okay"; }; + +&flexcan0 { + status = "okay"; + pinctrl-0 = <&pinmux_flexcan0>; + pinctrl-names = "default"; +}; diff --git a/boards/nxp/frdm_mcxaxx6/frdm_mcxa266-pinctrl.dtsi b/boards/nxp/frdm_mcxaxx6/frdm_mcxa266-pinctrl.dtsi index e0aba91b45778..1da18cafa32d0 100644 --- a/boards/nxp/frdm_mcxaxx6/frdm_mcxa266-pinctrl.dtsi +++ b/boards/nxp/frdm_mcxaxx6/frdm_mcxa266-pinctrl.dtsi @@ -126,4 +126,14 @@ slew-rate = "fast"; }; }; + + pinmux_flexcan0: pinmux_flexcan0 { + group0 { + pinmux = , + ; + slew-rate = "fast"; + drive-strength = "low"; + input-enable; + }; + }; }; diff --git a/boards/nxp/frdm_mcxaxx6/frdm_mcxa266.yaml b/boards/nxp/frdm_mcxaxx6/frdm_mcxa266.yaml index 03ada0798d180..1ac20bf75753a 100644 --- a/boards/nxp/frdm_mcxaxx6/frdm_mcxa266.yaml +++ b/boards/nxp/frdm_mcxaxx6/frdm_mcxa266.yaml @@ -24,4 +24,5 @@ supported: - counter - dma - i3c + - can vendor: nxp diff --git a/boards/nxp/frdm_mcxaxx6/frdm_mcxa346-pinctrl.dtsi b/boards/nxp/frdm_mcxaxx6/frdm_mcxa346-pinctrl.dtsi index 8f338d09860a6..87456bdbdbd38 100644 --- a/boards/nxp/frdm_mcxaxx6/frdm_mcxa346-pinctrl.dtsi +++ b/boards/nxp/frdm_mcxaxx6/frdm_mcxa346-pinctrl.dtsi @@ -118,4 +118,14 @@ slew-rate = "fast"; }; }; + + pinmux_flexcan0: pinmux_flexcan0 { + group0 { + pinmux = , + ; + slew-rate = "fast"; + drive-strength = "low"; + input-enable; + }; + }; }; diff --git a/boards/nxp/frdm_mcxaxx6/frdm_mcxa346.yaml b/boards/nxp/frdm_mcxaxx6/frdm_mcxa346.yaml index 24c6ef2d11dac..3214271167e22 100644 --- a/boards/nxp/frdm_mcxaxx6/frdm_mcxa346.yaml +++ b/boards/nxp/frdm_mcxaxx6/frdm_mcxa346.yaml @@ -24,4 +24,5 @@ supported: - counter - dma - opamp + - can vendor: nxp diff --git a/boards/nxp/frdm_mcxaxx6/frdm_mcxa366-pinctrl.dtsi b/boards/nxp/frdm_mcxaxx6/frdm_mcxa366-pinctrl.dtsi index 77bff8ad8f1c3..6ca14bc4bb59c 100644 --- a/boards/nxp/frdm_mcxaxx6/frdm_mcxa366-pinctrl.dtsi +++ b/boards/nxp/frdm_mcxaxx6/frdm_mcxa366-pinctrl.dtsi @@ -136,4 +136,14 @@ slew-rate = "fast"; }; }; + + pinmux_flexcan0: pinmux_flexcan0 { + group0 { + pinmux = , + ; + slew-rate = "fast"; + drive-strength = "low"; + input-enable; + }; + }; }; diff --git a/boards/nxp/frdm_mcxaxx6/frdm_mcxa366.yaml b/boards/nxp/frdm_mcxaxx6/frdm_mcxa366.yaml index 13163cc3b58df..4d0146abe2cf3 100644 --- a/boards/nxp/frdm_mcxaxx6/frdm_mcxa366.yaml +++ b/boards/nxp/frdm_mcxaxx6/frdm_mcxa366.yaml @@ -25,4 +25,5 @@ supported: - dma - i3c - opamp + - can vendor: nxp diff --git a/drivers/clock_control/clock_control_mcux_syscon.c b/drivers/clock_control/clock_control_mcux_syscon.c index 62eb489394562..e312aac13b025 100644 --- a/drivers/clock_control/clock_control_mcux_syscon.c +++ b/drivers/clock_control/clock_control_mcux_syscon.c @@ -98,6 +98,11 @@ static int mcux_lpc_syscon_clock_control_on(const struct device *dev, case MCUX_FLEXCAN0_CLK: CLOCK_EnableClock(kCLOCK_GateFLEXCAN0); break; +#if (defined(FSL_FEATURE_SOC_FLEXCAN_COUNT) && (FSL_FEATURE_SOC_FLEXCAN_COUNT > 1)) + case MCUX_FLEXCAN1_CLK: + CLOCK_EnableClock(kCLOCK_GateFLEXCAN1); + break; +#endif /* defined(FSL_FEATURE_SOC_FLEXCAN_COUNT) */ #else case MCUX_FLEXCAN0_CLK: CLOCK_EnableClock(kCLOCK_Flexcan0); @@ -535,7 +540,8 @@ static int mcux_lpc_syscon_clock_control_get_subsys_rate(const struct device *de #endif /* CONFIG_ADC_MCUX_LPADC */ #if defined(CONFIG_CAN_MCUX_FLEXCAN) -#if defined(CONFIG_SOC_FAMILY_MCXA) +#if (defined(FSL_FEATURE_SOC_FLEXCAN_COUNT) && (FSL_FEATURE_SOC_FLEXCAN_COUNT == 1) && \ + !defined(CONFIG_SOC_MCXA346)) case MCUX_FLEXCAN0_CLK: *rate = CLOCK_GetFlexcanClkFreq(); break; @@ -546,7 +552,7 @@ static int mcux_lpc_syscon_clock_control_get_subsys_rate(const struct device *de case MCUX_FLEXCAN1_CLK: *rate = CLOCK_GetFlexcanClkFreq(1); break; -#endif /* defined(CONFIG_SOC_FAMILY_MCXA) */ +#endif /* defined(FSL_FEATURE_SOC_FLEXCAN_COUNT) */ #endif /* defined(CONFIG_CAN_MCUX_FLEXCAN) */ #if defined(CONFIG_MCUX_FLEXIO) diff --git a/dts/arm/nxp/nxp_mcxa346.dtsi b/dts/arm/nxp/nxp_mcxa346.dtsi index 9f7b75bcec83d..b9fea8a930219 100644 --- a/dts/arm/nxp/nxp_mcxa346.dtsi +++ b/dts/arm/nxp/nxp_mcxa346.dtsi @@ -7,3 +7,4 @@ #include /delete-node/ &i3c0; +/delete-node/ &flexcan1; diff --git a/dts/arm/nxp/nxp_mcxaxx6_common.dtsi b/dts/arm/nxp/nxp_mcxaxx6_common.dtsi index 40e07a20b4068..85f80cf29beee 100644 --- a/dts/arm/nxp/nxp_mcxaxx6_common.dtsi +++ b/dts/arm/nxp/nxp_mcxaxx6_common.dtsi @@ -481,6 +481,26 @@ status = "disabled"; clk-divider = <1>; }; + + flexcan0: can@400cc000 { + compatible = "nxp,flexcan"; + reg = <0x400cc000 0x1000>; + interrupts = <19 0>; + interrupt-names = "common"; + clocks = <&syscon MCUX_FLEXCAN0_CLK>; + clk-source = <0>; + status = "disabled"; + }; + + flexcan1: can@400d0000 { + compatible = "nxp,flexcan"; + reg = <0x400d0000 0x1000>; + interrupts = <20 0>; + interrupt-names = "common"; + clocks = <&syscon MCUX_FLEXCAN1_CLK>; + clk-source = <0>; + status = "disabled"; + }; }; }; diff --git a/tests/drivers/can/timing/boards/frdm_mcxa266.conf b/tests/drivers/can/timing/boards/frdm_mcxa266.conf new file mode 100644 index 0000000000000..7b071f3a54f51 --- /dev/null +++ b/tests/drivers/can/timing/boards/frdm_mcxa266.conf @@ -0,0 +1 @@ +CONFIG_TEST_ALL_BITRATES=y diff --git a/tests/drivers/can/timing/boards/frdm_mcxa346.conf b/tests/drivers/can/timing/boards/frdm_mcxa346.conf new file mode 100644 index 0000000000000..7b071f3a54f51 --- /dev/null +++ b/tests/drivers/can/timing/boards/frdm_mcxa346.conf @@ -0,0 +1 @@ +CONFIG_TEST_ALL_BITRATES=y diff --git a/tests/drivers/can/timing/boards/frdm_mcxa366.conf b/tests/drivers/can/timing/boards/frdm_mcxa366.conf new file mode 100644 index 0000000000000..7b071f3a54f51 --- /dev/null +++ b/tests/drivers/can/timing/boards/frdm_mcxa366.conf @@ -0,0 +1 @@ +CONFIG_TEST_ALL_BITRATES=y