Skip to content

Commit 3a15017

Browse files
mcuxtedkartben
authored andcommitted
boards: nxp/frdm_mcxn947: Support sai for NXP frdm_mcxn947
Support sai for NXP frdm_mcxn947. Signed-off-by: Qiang Zhang <[email protected]>
1 parent 85aff83 commit 3a15017

File tree

7 files changed

+73
-14
lines changed

7 files changed

+73
-14
lines changed

boards/nxp/frdm_mcxn947/board.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,18 @@ static int frdm_mcxn947_init(void)
131131

132132
CLOCK_SetupExtClocking(BOARD_XTAL0_CLK_HZ);
133133

134-
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcan0))
135-
/* Set up PLL1 for 80 MHz FlexCAN clock */
136-
const pll_setup_t pll1Setup = {
137-
.pllctrl = SCG_SPLLCTRL_SOURCE(1U) | SCG_SPLLCTRL_SELI(27U) |
138-
SCG_SPLLCTRL_SELP(13U),
139-
.pllndiv = SCG_SPLLNDIV_NDIV(3U),
140-
.pllpdiv = SCG_SPLLPDIV_PDIV(1U),
141-
.pllmdiv = SCG_SPLLMDIV_MDIV(10U),
142-
.pllRate = 80000000U
143-
};
134+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(sai0)) || DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(sai1))
135+
/* < Set up PLL1 */
136+
const pll_setup_t pll1_Setup = {
137+
.pllctrl = SCG_SPLLCTRL_SOURCE(1U) | SCG_SPLLCTRL_SELI(3U) |
138+
SCG_SPLLCTRL_SELP(1U),
139+
.pllndiv = SCG_SPLLNDIV_NDIV(25U),
140+
.pllpdiv = SCG_SPLLPDIV_PDIV(10U),
141+
.pllmdiv = SCG_SPLLMDIV_MDIV(256U),
142+
.pllRate = 24576000U};
144143

145144
/* Configure PLL1 to the desired values */
146-
CLOCK_SetPLL1Freq(&pll1Setup);
147-
/* PLL1 Monitor is disabled */
148-
CLOCK_SetPll1MonitorMode(kSCG_Pll1MonitorDisable);
145+
CLOCK_SetPLL1Freq(&pll1_Setup);
149146
/* Set PLL1 CLK0 divider to value 1 */
150147
CLOCK_SetClkDiv(kCLOCK_DivPLL1Clk0, 1U);
151148
#endif
@@ -250,7 +247,7 @@ static int frdm_mcxn947_init(void)
250247

251248
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcan0))
252249
CLOCK_SetClkDiv(kCLOCK_DivFlexcan0Clk, 1U);
253-
CLOCK_AttachClk(kPLL1_CLK0_to_FLEXCAN0);
250+
CLOCK_AttachClk(kFRO_HF_to_FLEXCAN0);
254251
#endif
255252

256253
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usdhc0))
@@ -383,6 +380,18 @@ static int frdm_mcxn947_init(void)
383380
CLOCK_AttachClk(kFRO_HF_to_SCT);
384381
#endif
385382

383+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(sai0))
384+
CLOCK_SetClkDiv(kCLOCK_DivSai0Clk, 1u);
385+
CLOCK_AttachClk(kPLL1_CLK0_to_SAI0);
386+
CLOCK_EnableClock(kCLOCK_Sai0);
387+
#endif
388+
389+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(sai1))
390+
CLOCK_SetClkDiv(kCLOCK_DivSai1Clk, 1u);
391+
CLOCK_AttachClk(kPLL1_CLK0_to_SAI1);
392+
CLOCK_EnableClock(kCLOCK_Sai1);
393+
#endif
394+
386395
/* Set SystemCoreClock variable. */
387396
SystemCoreClock = CLOCK_INIT_CORE_CLOCK;
388397

boards/nxp/frdm_mcxn947/doc/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ The FRDM-MCXN947 board configuration supports the following hardware features:
9797
+-----------+------------+-------------------------------------+
9898
| FLEXIO | on-chip | flexio |
9999
+-----------+------------+-------------------------------------+
100+
| SAI | on-chip | i2s |
101+
+-----------+------------+-------------------------------------+
100102
| DISPLAY | on-chip | flexio; MIPI-DBI. Tested with |
101103
| | | :ref:`lcd_par_s035` |
102104
+-----------+------------+-------------------------------------+

boards/nxp/frdm_mcxn947/frdm_mcxn947-pinctrl.dtsi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@
9292
};
9393
};
9494

95+
pinmux_sai1: pinmux_sai1 {
96+
group0 {
97+
pinmux = <SAI1_TX_BCLK_PIO3_16>,
98+
<SAI1_TX_FS_PIO3_17>,
99+
<SAI1_TXD0_PIO3_20>,
100+
<SAI1_RX_FS_PIO3_19>,
101+
<SAI1_RX_BCLK_PIO3_18>,
102+
<SAI1_RXD0_PIO3_21>;
103+
drive-strength = "high";
104+
slew-rate = "fast";
105+
input-enable;
106+
};
107+
};
108+
109+
pinmux_sai0: pinmux_sai0 {
110+
group0 {
111+
pinmux = <SAI0_TXD0_PIO2_2>,
112+
<SAI0_TX_BCLK_PIO2_6>,
113+
<SAI0_TX_FS_PIO2_7>;
114+
drive-strength = "high";
115+
slew-rate = "fast";
116+
input-enable;
117+
};
118+
};
119+
95120
pinmux_enet_qos: pinmux_enet_qos {
96121
mdio_group {
97122
pinmux = <ENET0_MDC_PIO1_20>,

boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ nxp_8080_touch_panel_i2c: &flexcomm2_lpi2c2 {
206206
pinctrl-names = "default";
207207
};
208208

209+
&sai1 {
210+
pinctrl-0 = <&pinmux_sai1>;
211+
pinctrl-names = "default";
212+
};
213+
214+
&sai0 {
215+
pinctrl-0 = <&pinmux_sai0>;
216+
pinctrl-names = "default";
217+
};
218+
209219
&enet {
210220
pinctrl-0 = <&pinmux_enet_qos>;
211221
pinctrl-names = "default";

boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,10 @@ zephyr_udc0: &usb1 {
233233
&sc_timer {
234234
status = "okay";
235235
};
236+
237+
&sai1 {
238+
status = "okay";
239+
};
240+
&sai0 {
241+
status = "okay";
242+
};

boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ supported:
2323
- flash
2424
- gpio
2525
- i2c
26+
- i2s
2627
- i3c
2728
- pwm
2829
- regulator

soc/nxp/mcx/mcxn/Kconfig.defconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC
2727
config FLASH_FILL_BUFFER_SIZE
2828
default 128
2929

30+
# The existing SAI diver cannot initialize the PLL on the board,
31+
# so the PLL settings will not be performed in the driver.
32+
config I2S_HAS_PLL_SETTING
33+
default n
34+
3035
endif # SOC_SERIES_MCXN

0 commit comments

Comments
 (0)