|
16 | 16 | #include <device.h> |
17 | 17 | #include <init.h> |
18 | 18 | #include <drivers/dma.h> |
19 | | - |
20 | 19 | #include <drivers/i2s.h> |
| 20 | +#include <drivers/pinctrl.h> |
21 | 21 | #include <drivers/clock_control.h> |
22 | 22 | #include <dt-bindings/clock/imx_ccm.h> |
23 | 23 | #include <soc.h> |
@@ -78,6 +78,7 @@ struct i2s_mcux_config { |
78 | 78 | uint32_t tx_channel; |
79 | 79 | clock_control_subsys_t clk_sub_sys; |
80 | 80 | const struct device *ccm_dev; |
| 81 | + const struct pinctrl_dev_config *pinctrl; |
81 | 82 | void (*irq_connect)(const struct device *dev); |
82 | 83 | bool rx_sync_mode; |
83 | 84 | bool tx_sync_mode; |
@@ -328,15 +329,24 @@ static void enable_mclk_direction(const struct device *dev, bool dir) |
328 | 329 | const struct i2s_mcux_config *dev_cfg = dev->config; |
329 | 330 | uint32_t offset = dev_cfg->mclk_pin_offset; |
330 | 331 | uint32_t mask = dev_cfg->mclk_pin_mask; |
331 | | - uint32_t value = 0; |
332 | 332 | uint32_t *gpr = (uint32_t *)DT_REG_ADDR(DT_NODELABEL(iomuxcgpr)) + offset; |
333 | 333 |
|
334 | 334 | if (dir) { |
335 | 335 | *gpr |= mask; |
336 | 336 | } else { |
337 | 337 | *gpr &= ~mask; |
338 | 338 | } |
| 339 | +} |
| 340 | + |
| 341 | +static void mcux_rt_sai_pin_init(void) |
| 342 | +{ |
| 343 | + int err; |
339 | 344 |
|
| 345 | + err = pinctrl_apply_state(dev_cfg->pinctrl, PINCTRL_STATE_DEFAULT); |
| 346 | + if (err < 0) { |
| 347 | + LOG_ERR("mclk pinctrl setup failed (%d)", err); |
| 348 | + return err; |
| 349 | + } |
340 | 350 | } |
341 | 351 |
|
342 | 352 | static void get_mclk_rate(const struct device *dev, uint32_t *mclk) |
@@ -989,6 +999,9 @@ static int i2s_mcux_initialize(const struct device *dev) |
989 | 999 | /* register ISR */ |
990 | 1000 | dev_cfg->irq_connect(dev); |
991 | 1001 |
|
| 1002 | + /* pinctrl */ |
| 1003 | + mcux_rt_sai_pin_init(); |
| 1004 | + |
992 | 1005 | /*clock configuration*/ |
993 | 1006 | audio_clock_settings(dev); |
994 | 1007 |
|
@@ -1040,6 +1053,8 @@ static const struct i2s_driver_api i2s_mcux_driver_api = { |
1040 | 1053 | #define I2S_MCUX_INIT(i2s_id) \ |
1041 | 1054 | static void i2s_irq_connect_##i2s_id(const struct device *dev); \ |
1042 | 1055 | \ |
| 1056 | + PINCTRL_DT_INST_DEFINE(i2s_id); \ |
| 1057 | + \ |
1043 | 1058 | static const struct i2s_mcux_config i2s_##i2s_id##_config = { \ |
1044 | 1059 | .base = (I2S_Type *)DT_INST_REG_ADDR(i2s_id), \ |
1045 | 1060 | .clk_src = \ |
@@ -1071,6 +1086,7 @@ static const struct i2s_driver_api i2s_mcux_driver_api = { |
1071 | 1086 | .clk_sub_sys = (clock_control_subsys_t) \ |
1072 | 1087 | DT_INST_CLOCKS_CELL_BY_IDX(i2s_id, 0, name), \ |
1073 | 1088 | .ccm_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(i2s_id)), \ |
| 1089 | + .pinctrl = PINCTRL_DT_INST_DEV_CONFIG_GET(i2s_id), \ |
1074 | 1090 | .irq_connect = i2s_irq_connect_##i2s_id, \ |
1075 | 1091 | .tx_sync_mode = \ |
1076 | 1092 | DT_INST_PROP(i2s_id, nxp_tx_sync_mode), \ |
|
0 commit comments