boards: nxp: frdm_mcxn947: enable flexcan0

Enable FlexCAN0 on the NXP FRDM-MCXN947 board.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2024-05-08 14:09:22 +00:00 committed by Fabio Baltieri
commit 0c3114cc01
7 changed files with 49 additions and 2 deletions

View file

@ -106,6 +106,25 @@ static int frdm_mcxn947_init(void)
CLOCK_SetupExtClocking(BOARD_XTAL0_CLK_HZ); CLOCK_SetupExtClocking(BOARD_XTAL0_CLK_HZ);
#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcan0), okay)
/* Set up PLL1 for 80 MHz FlexCAN clock */
const pll_setup_t pll1Setup = {
.pllctrl = SCG_SPLLCTRL_SOURCE(1U) | SCG_SPLLCTRL_SELI(27U) |
SCG_SPLLCTRL_SELP(13U),
.pllndiv = SCG_SPLLNDIV_NDIV(3U),
.pllpdiv = SCG_SPLLPDIV_PDIV(1U),
.pllmdiv = SCG_SPLLMDIV_MDIV(10U),
.pllRate = 80000000U
};
/* Configure PLL1 to the desired values */
CLOCK_SetPLL1Freq(&pll1Setup);
/* PLL1 Monitor is disabled */
CLOCK_SetPll1MonitorMode(kSCG_Pll1MonitorDisable);
/* Set PLL1 CLK0 divider to value 1 */
CLOCK_SetClkDiv(kCLOCK_DivPLL1Clk0, 1U);
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcomm1), okay) #if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcomm1), okay)
CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u); CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u);
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1); CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1);
@ -203,6 +222,11 @@ static int frdm_mcxn947_init(void)
CLOCK_AttachClk(kPLL0_to_CTIMER4); CLOCK_AttachClk(kPLL0_to_CTIMER4);
#endif #endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcan0), okay)
CLOCK_SetClkDiv(kCLOCK_DivFlexcan0Clk, 1U);
CLOCK_AttachClk(kPLL1_CLK0_to_FLEXCAN0);
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc0), okay) #if DT_NODE_HAS_STATUS(DT_NODELABEL(usdhc0), okay)
CLOCK_SetClkDiv(kCLOCK_DivUSdhcClk, 1u); CLOCK_SetClkDiv(kCLOCK_DivUSdhcClk, 1u);
CLOCK_AttachClk(kFRO_HF_to_USDHC); CLOCK_AttachClk(kFRO_HF_to_USDHC);

View file

@ -92,6 +92,8 @@ The FRDM-MCXN947 board configuration supports the following hardware features:
+-----------+------------+-------------------------------------+ +-----------+------------+-------------------------------------+
| LPCMP | on-chip | sensor(comparator) | | LPCMP | on-chip | sensor(comparator) |
+-----------+------------+-------------------------------------+ +-----------+------------+-------------------------------------+
| FLEXCAN | on-chip | CAN |
+-----------+------------+-------------------------------------+
Targets available Targets available
================== ==================

View file

@ -166,4 +166,14 @@
bias-pull-up; bias-pull-up;
}; };
}; };
pinmux_flexcan0: pinmux_flexcan0 {
group0 {
pinmux = <CAN0_TXD_PIO1_10>,
<CAN0_RXD_PIO1_11>;
slew-rate = "fast";
drive-strength = "low";
input-enable;
};
};
}; };

View file

@ -196,3 +196,8 @@
pinctrl-0 = <&pinmux_lpcmp0>; pinctrl-0 = <&pinmux_lpcmp0>;
pinctrl-names = "default"; pinctrl-names = "default";
}; };
&flexcan0 {
pinctrl-0 = <&pinmux_flexcan0>;
pinctrl-names = "default";
};

View file

@ -24,6 +24,7 @@
zephyr,code-partition = &slot0_partition; zephyr,code-partition = &slot0_partition;
zephyr,console = &flexcomm4_lpuart4; zephyr,console = &flexcomm4_lpuart4;
zephyr,shell-uart = &flexcomm4_lpuart4; zephyr,shell-uart = &flexcomm4_lpuart4;
zephyr,canbus = &flexcan0;
}; };
aliases{ aliases{
@ -142,6 +143,10 @@
status = "okay"; status = "okay";
}; };
&flexcan0 {
status = "okay";
};
&ctimer0 { &ctimer0 {
status = "okay"; status = "okay";
}; };

View file

@ -15,6 +15,7 @@ toolchain:
- gnuarmemb - gnuarmemb
- xtools - xtools
supported: supported:
- can
- dma - dma
- gpio - gpio
- spi - spi

View file

@ -876,7 +876,7 @@
}; };
flexcan0: can@d4000 { flexcan0: can@d4000 {
compatible = "nxp,flexcan-fd", "nxp,flexcan"; compatible = "nxp,flexcan";
reg = <0xd4000 0x4000>; reg = <0xd4000 0x4000>;
interrupts = <62 0>; interrupts = <62 0>;
interrupt-names = "common"; interrupt-names = "common";
@ -886,7 +886,7 @@
}; };
flexcan1: can@d8000 { flexcan1: can@d8000 {
compatible = "nxp,flexcan-fd", "nxp,flexcan"; compatible = "nxp,flexcan";
reg = <0xd8000 0x4000>; reg = <0xd8000 0x4000>;
interrupts = <63 0>; interrupts = <63 0>;
interrupt-names = "common"; interrupt-names = "common";