Skip to content

Commit cbb6c28

Browse files
mcuxtedkartben
authored andcommitted
drivers: drivers/i2s: fix sai issue for support frdm_mcxn497
i2s driver have not suooprt frdm_mcxn947 pll clk set. so add macro CONFIG_I2S_HAS_PLL_SETTING to control pll init. Signed-off-by: Qiang Zhang <[email protected]>
1 parent 436f3dc commit cbb6c28

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

drivers/i2s/Kconfig.mcux

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MCUX I2S driver configuration options
22

3-
# Copyright (c) 2021, NXP
3+
# Copyright 2021,2024 NXP
44
# SPDX-License-Identifier: Apache-2.0
55

66
menuconfig I2S_MCUX_SAI
@@ -28,4 +28,8 @@ config I2S_EDMA_BURST_SIZE
2828
help
2929
I2S EDMA burst size in bytes.
3030

31+
config I2S_HAS_PLL_SETTING
32+
bool "I2S will setting pll in driver"
33+
default y
34+
3135
endif # I2S_MCUX_SAI

drivers/i2s/i2s_mcux_sai.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct i2s_mcux_config {
9494
uint32_t pll_pd;
9595
uint32_t pll_num;
9696
uint32_t pll_den;
97-
uint32_t *mclk_control_base;
97+
uint32_t mclk_control_base;
9898
uint32_t mclk_pin_mask;
9999
uint32_t mclk_pin_offset;
100100
uint32_t tx_channel;
@@ -400,9 +400,10 @@ static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg, uint32_
400400
static void enable_mclk_direction(const struct device *dev, bool dir)
401401
{
402402
const struct i2s_mcux_config *dev_cfg = dev->config;
403+
uint32_t control_base = dev_cfg->mclk_control_base;
403404
uint32_t offset = dev_cfg->mclk_pin_offset;
404405
uint32_t mask = dev_cfg->mclk_pin_mask;
405-
uint32_t *base = (uint32_t *)(dev_cfg->mclk_control_base + offset);
406+
uint32_t *base = (uint32_t *)(control_base + offset);
406407

407408
if (dir) {
408409
*base |= mask;
@@ -1030,6 +1031,7 @@ static void i2s_mcux_isr(void *arg)
10301031

10311032
static void audio_clock_settings(const struct device *dev)
10321033
{
1034+
#ifdef CONFIG_I2S_HAS_PLL_SETTING
10331035
clock_audio_pll_config_t audioPllConfig;
10341036
const struct i2s_mcux_config *dev_cfg = dev->config;
10351037
uint32_t clock_name = (uint32_t)dev_cfg->clk_sub_sys;
@@ -1055,6 +1057,7 @@ static void audio_clock_settings(const struct device *dev)
10551057
#endif /* CONFIG_SOC_SERIES */
10561058

10571059
CLOCK_InitAudioPll(&audioPllConfig);
1060+
#endif
10581061
}
10591062

10601063
static int i2s_mcux_initialize(const struct device *dev)
@@ -1113,7 +1116,8 @@ static int i2s_mcux_initialize(const struct device *dev)
11131116
/* master clock configurations */
11141117
#if (defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR)) || \
11151118
(defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER))
1116-
#if defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)
1119+
#if ((defined(FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER) && (FSL_FEATURE_SAI_HAS_MCLKDIV_REGISTER)) || \
1120+
(defined(FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV) && (FSL_FEATURE_SAI_HAS_MCR_MCLK_POST_DIV)))
11171121
mclkConfig.mclkHz = mclk;
11181122
mclkConfig.mclkSourceClkHz = mclk;
11191123
#endif
@@ -1140,16 +1144,15 @@ static DEVICE_API(i2s, i2s_mcux_driver_api) = {
11401144
\
11411145
static const struct i2s_mcux_config i2s_##i2s_id##_config = { \
11421146
.base = (I2S_Type *)DT_INST_REG_ADDR(i2s_id), \
1143-
.clk_src = DT_INST_PROP(i2s_id, clock_mux), \
1144-
.clk_pre_div = DT_INST_PROP(i2s_id, pre_div), \
1145-
.clk_src_div = DT_INST_PROP(i2s_id, podf), \
1146-
.pll_src = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, src, value), \
1147-
.pll_lp = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, lp, value), \
1148-
.pll_pd = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, pd, value), \
1149-
.pll_num = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, num, value), \
1150-
.pll_den = DT_PHA_BY_NAME(DT_DRV_INST(i2s_id), pll_clocks, den, value), \
1151-
.mclk_control_base = \
1152-
(uint32_t *)DT_REG_ADDR(DT_PHANDLE(DT_DRV_INST(i2s_id), pinmuxes)), \
1147+
.clk_src = DT_INST_PROP_OR(i2s_id, clock_mux, 0), \
1148+
.clk_pre_div = DT_INST_PROP_OR(i2s_id, pre_div, 0), \
1149+
.clk_src_div = DT_INST_PROP_OR(i2s_id, podf, 0), \
1150+
.pll_src = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, src, value, 0), \
1151+
.pll_lp = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, lp, value, 0), \
1152+
.pll_pd = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, pd, value, 0), \
1153+
.pll_num = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, num, value, 0), \
1154+
.pll_den = DT_PHA_BY_NAME_OR(DT_DRV_INST(i2s_id), pll_clocks, den, value, 0), \
1155+
.mclk_control_base = DT_REG_ADDR(DT_PHANDLE(DT_DRV_INST(i2s_id), pinmuxes)), \
11531156
.mclk_pin_mask = DT_PHA_BY_IDX(DT_DRV_INST(i2s_id), pinmuxes, 0, function), \
11541157
.mclk_pin_offset = DT_PHA_BY_IDX(DT_DRV_INST(i2s_id), pinmuxes, 0, pin), \
11551158
.clk_sub_sys = \

dts/bindings/i2s/nxp,mcux-i2s.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,5 @@ properties:
6262
description: tx channel the maximum number is SOC dependent
6363

6464
clock-mux:
65-
required: true
6665
type: int
6766
description: Clock mux source for SAI root clock

0 commit comments

Comments
 (0)