drivers: sai: add pinctrl support in mcux sai
enable i2s pinctrl Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
This commit is contained in:
parent
40f3ab9f72
commit
8c5a4fc3b0
1 changed files with 28 additions and 2 deletions
|
@ -16,8 +16,10 @@
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <drivers/dma.h>
|
#include <drivers/dma.h>
|
||||||
|
|
||||||
#include <drivers/i2s.h>
|
#include <drivers/i2s.h>
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
#include <drivers/pinctrl.h>
|
||||||
|
#endif
|
||||||
#include <drivers/clock_control.h>
|
#include <drivers/clock_control.h>
|
||||||
#include <dt-bindings/clock/imx_ccm.h>
|
#include <dt-bindings/clock/imx_ccm.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
@ -78,6 +80,9 @@ struct i2s_mcux_config {
|
||||||
uint32_t tx_channel;
|
uint32_t tx_channel;
|
||||||
clock_control_subsys_t clk_sub_sys;
|
clock_control_subsys_t clk_sub_sys;
|
||||||
const struct device *ccm_dev;
|
const struct device *ccm_dev;
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
const struct pinctrl_dev_config *pinctrl;
|
||||||
|
#endif
|
||||||
void (*irq_connect)(const struct device *dev);
|
void (*irq_connect)(const struct device *dev);
|
||||||
bool rx_sync_mode;
|
bool rx_sync_mode;
|
||||||
bool tx_sync_mode;
|
bool tx_sync_mode;
|
||||||
|
@ -335,7 +340,6 @@ static void enable_mclk_direction(const struct device *dev, bool dir)
|
||||||
} else {
|
} else {
|
||||||
*gpr &= ~mask;
|
*gpr &= ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_mclk_rate(const struct device *dev, uint32_t *mclk)
|
static void get_mclk_rate(const struct device *dev, uint32_t *mclk)
|
||||||
|
@ -969,6 +973,9 @@ static int i2s_mcux_initialize(const struct device *dev)
|
||||||
I2S_Type *base = (I2S_Type *)dev_cfg->base;
|
I2S_Type *base = (I2S_Type *)dev_cfg->base;
|
||||||
struct i2s_dev_data *dev_data = dev->data;
|
struct i2s_dev_data *dev_data = dev->data;
|
||||||
uint32_t mclk;
|
uint32_t mclk;
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
int err;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!dev_data->dev_dma) {
|
if (!dev_data->dev_dma) {
|
||||||
LOG_ERR("DMA device not found");
|
LOG_ERR("DMA device not found");
|
||||||
|
@ -987,6 +994,14 @@ static int i2s_mcux_initialize(const struct device *dev)
|
||||||
|
|
||||||
/* register ISR */
|
/* register ISR */
|
||||||
dev_cfg->irq_connect(dev);
|
dev_cfg->irq_connect(dev);
|
||||||
|
/* pinctrl */
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
err = pinctrl_apply_state(dev_cfg->pinctrl, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (err) {
|
||||||
|
LOG_ERR("mclk pinctrl setup failed (%d)", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*clock configuration*/
|
/*clock configuration*/
|
||||||
audio_clock_settings(dev);
|
audio_clock_settings(dev);
|
||||||
|
@ -1036,9 +1051,19 @@ static const struct i2s_driver_api i2s_mcux_driver_api = {
|
||||||
.trigger = i2s_mcux_trigger,
|
.trigger = i2s_mcux_trigger,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_PINCTRL
|
||||||
|
#define PINCTRL_DEFINE(i2s_id) PINCTRL_DT_INST_DEFINE(i2s_id);
|
||||||
|
#define PINCTRL_INIT(i2s_id) .pinctrl = PINCTRL_DT_INST_DEV_CONFIG_GET(i2s_id),
|
||||||
|
#else
|
||||||
|
#define PINCTRL_DEFINE(i2s_id)
|
||||||
|
#define PINCTRL_INIT(i2s_id)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define I2S_MCUX_INIT(i2s_id) \
|
#define I2S_MCUX_INIT(i2s_id) \
|
||||||
static void i2s_irq_connect_##i2s_id(const struct device *dev); \
|
static void i2s_irq_connect_##i2s_id(const struct device *dev); \
|
||||||
\
|
\
|
||||||
|
PINCTRL_DEFINE(i2s_id) \
|
||||||
|
\
|
||||||
static const struct i2s_mcux_config i2s_##i2s_id##_config = { \
|
static const struct i2s_mcux_config i2s_##i2s_id##_config = { \
|
||||||
.base = (I2S_Type *)DT_INST_REG_ADDR(i2s_id), \
|
.base = (I2S_Type *)DT_INST_REG_ADDR(i2s_id), \
|
||||||
.clk_src = \
|
.clk_src = \
|
||||||
|
@ -1071,6 +1096,7 @@ static const struct i2s_driver_api i2s_mcux_driver_api = {
|
||||||
DT_INST_CLOCKS_CELL_BY_IDX(i2s_id, 0, name), \
|
DT_INST_CLOCKS_CELL_BY_IDX(i2s_id, 0, name), \
|
||||||
.ccm_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(i2s_id)), \
|
.ccm_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(i2s_id)), \
|
||||||
.irq_connect = i2s_irq_connect_##i2s_id, \
|
.irq_connect = i2s_irq_connect_##i2s_id, \
|
||||||
|
PINCTRL_INIT(i2s_id) \
|
||||||
.tx_sync_mode = \
|
.tx_sync_mode = \
|
||||||
DT_INST_PROP(i2s_id, nxp_tx_sync_mode), \
|
DT_INST_PROP(i2s_id, nxp_tx_sync_mode), \
|
||||||
.rx_sync_mode = \
|
.rx_sync_mode = \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue