-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MCXN947 sai module support #77534
Changes from all commits
9c8fa33
55ffc95
aebbd9f
a2a3d70
a959efd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,3 +233,10 @@ zephyr_udc0: &usb1 { | |
&sc_timer { | ||
status = "okay"; | ||
}; | ||
|
||
&sai1 { | ||
status = "okay"; | ||
}; | ||
&sai0 { | ||
status = "okay"; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ supported: | |
- flash | ||
- gpio | ||
- i2c | ||
- i2s | ||
- i3c | ||
- pwm | ||
- regulator | ||
|
mcuxted marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,7 @@ struct i2s_mcux_config { | |
uint32_t pll_pd; | ||
uint32_t pll_num; | ||
uint32_t pll_den; | ||
uint32_t *mclk_control_base; | ||
uint32_t mclk_control_base; | ||
uint32_t mclk_pin_mask; | ||
uint32_t mclk_pin_offset; | ||
uint32_t tx_channel; | ||
|
@@ -400,9 +400,10 @@ static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg, uint32_ | |
static void enable_mclk_direction(const struct device *dev, bool dir) | ||
{ | ||
const struct i2s_mcux_config *dev_cfg = dev->config; | ||
uint32_t control_base = dev_cfg->mclk_control_base; | ||
uint32_t offset = dev_cfg->mclk_pin_offset; | ||
uint32_t mask = dev_cfg->mclk_pin_mask; | ||
uint32_t *base = (uint32_t *)(dev_cfg->mclk_control_base + offset); | ||
uint32_t *base = (uint32_t *)(control_base + offset); | ||
|
||
if (dir) { | ||
*base |= mask; | ||
|
@@ -1030,6 +1031,7 @@ static void i2s_mcux_isr(void *arg) | |
|
||
static void audio_clock_settings(const struct device *dev) | ||
{ | ||
#ifdef CONFIG_I2S_HAS_PLL_SETTING | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also agree that the PLL configuration should be moved out of the i2s driver and configured using other methods,This may also cause the pll configuration to be overwritten. |
||
clock_audio_pll_config_t audioPllConfig; | ||
const struct i2s_mcux_config *dev_cfg = dev->config; | ||
uint32_t clock_name = (uint32_t)dev_cfg->clk_sub_sys; | ||
|
@@ -1055,6 +1057,7 @@ static void audio_clock_settings(const struct device *dev) | |
#endif /* CONFIG_SOC_SERIES */ | ||
|
||
CLOCK_InitAudioPll(&audioPllConfig); | ||
#endif | ||
} | ||
|
||
static int i2s_mcux_initialize(const struct device *dev) | ||
|
@@ -1113,7 +1116,8 @@ static int i2s_mcux_initialize(const struct device *dev) | |
/* master clock configurations */ | ||
#if (defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)) || \ | ||
(defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)) | ||
#if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) | ||
#if ((defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)) || \ | ||
(defined(FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV) && (FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV))) | ||
mclkConfig.mclkHz = mclk; | ||
mclkConfig.mclkSourceClkHz = mclk; | ||
#endif | ||
|
@@ -1140,16 +1144,15 @@ static DEVICE_API(i2s, i2s_mcux_driver_api) = { | |
\ | ||
static const struct i2s_mcux_config i2s_##i2s_id##_config = { \ | ||
.base = (I2S_Type *)DT_INST_REG_ADDR(i2s_id), \ | ||
.clk_src = DT_INST_PROP(i2s_id, clock_mux), \ | ||
.clk_pre_div = DT_INST_PROP(i2s_id, pre_div), \ | ||
.clk_src_div = DT_INST_PROP(i2s_id, podf), \ | ||
.pll_src = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, src, value), \ | ||
.pll_lp = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, lp, value), \ | ||
.pll_pd = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, pd, value), \ | ||
.pll_num = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, num, value), \ | ||
.pll_den = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, den, value), \ | ||
.mclk_control_base = \ | ||
(uint32_t *)DT_REG_ADDR(DT_PHANDLE(DT_DRV_INST(i2s_id), pinmuxes)), \ | ||
.clk_src = DT_INST_PROP_OR(i2s_id, clock_mux, 0), \ | ||
.clk_pre_div = DT_INST_PROP_OR(i2s_id, pre_div, 0), \ | ||
.clk_src_div = DT_INST_PROP_OR(i2s_id, podf, 0), \ | ||
.pll_src = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, src, value, 0), \ | ||
.pll_lp = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, lp, value, 0), \ | ||
.pll_pd = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, pd, value, 0), \ | ||
.pll_num = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, num, value, 0), \ | ||
.pll_den = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, den, value, 0), \ | ||
.mclk_control_base = DT_REG_ADDR(DT_PHANDLE(DT_DRV_INST(i2s_id), pinmuxes)), \ | ||
.mclk_pin_mask = DT_PHA_BY_IDX(DT_DRV_INST(i2s_id), pinmuxes, 0, function), \ | ||
.mclk_pin_offset = DT_PHA_BY_IDX(DT_DRV_INST(i2s_id), pinmuxes, 0, pin), \ | ||
.clk_sub_sys = \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Copyright (c) 2024, NXP | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# SAI peripheral does not have loopback mode. Use 2 SAI peripherals connected | ||
# together externally. | ||
CONFIG_I2S_TEST_SEPARATE_DEVICES=y | ||
|
||
# CONFIG_DMA_TCD_QUEUE_SIZE sets size of queue used to chain DMA blocks (TCDs) | ||
# together, and should be sized as needed by the application. If not large | ||
# enough, the DMA may starve. Symptoms of this issue include transmit blocks | ||
# repeated, or RX blocks skipped. For I2S driver, queue size must be at least 3. | ||
CONFIG_DMA_TCD_QUEUE_SIZE=4 | ||
|
||
# Repeat test continually to help find intermittent issues | ||
CONFIG_ZTEST_RETEST_IF_PASSED=y | ||
|
||
# I2S and DMA logging can occur in interrupt context, and interfere with I2S | ||
# stream timing. If using either logging, set logging to deferred | ||
# CONFIG_LOG_MODE_DEFERRED=y | ||
|
||
CONFIG_DMA_LOG_LEVEL_OFF=y | ||
CONFIG_I2S_LOG_LEVEL_OFF=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* i2s_speed with CONFIG_I2S_TEST_SEPARATE_DEVICES=y uses two I2S peripherals: | ||
* i2s-node0 is the receiver | ||
* i2s-node1 is the transmitter | ||
*/ | ||
|
||
/ { | ||
aliases { | ||
i2s-node0 = &sai1; | ||
i2s-node1 = &sai0; | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the FlexCAN clock setup deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clock source of flexcan has been switched to kFRO_HF_to_FLEXCAN0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However I don't see
flexcan
in this list?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original clk source of flexcan is pll1. Due to the conflict with sai mclk clock source, the clock source of flexcan is switched from kPLL1_CLK0_to_FLEXCAN0 to kFRO_HF_to_FLEXCAN0 to ensure the use of flexcan(CLOCK_AttachClk(kFRO_HF_to_FLEXCAN0);).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcuxted , can you please look at this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hakehuang , can we confirm that this change does not break
Flexcan
support on this board.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmahadevan108 good point. looks OK for all timings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @hakehuang . Can you please approve this PR if it looks good to you per your testing.