drivers: dai: sai: add pinctrl support

Add support for performing pinctrl operations. For now,
the only supported operation is applying the pinctrl default
state. Pinctrl is left optional to allow for scenarios in which
this is not required (e.g: AMP system in which another
OS configures the pinctrl).

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This commit is contained in:
Laurentiu Mihalcea 2024-03-28 17:44:10 +02:00 committed by Fabio Baltieri
commit f4c73105e5
4 changed files with 15 additions and 1 deletions

View file

@ -5,6 +5,7 @@ config DAI_NXP_SAI
bool "NXP Synchronous Audio Interface (SAI) driver"
default y
depends on DT_HAS_NXP_DAI_SAI_ENABLED
select PINCTRL
help
Select this to enable NXP SAI driver.

View file

@ -831,6 +831,14 @@ static int sai_init(const struct device *dev)
LOG_DBG("clock %s has been ungated", cfg->clk_data.clock_names[i]);
}
/* note: optional operation so -ENOENT is allowed (i.e: we
* allow the default state to not be defined)
*/
ret = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT);
if (ret < 0 && ret != -ENOENT) {
return ret;
}
/* set TX/RX default states */
data->tx_state = DAI_STATE_NOT_READY;
data->rx_state = DAI_STATE_NOT_READY;
@ -843,6 +851,8 @@ static int sai_init(const struct device *dev)
#define SAI_INIT(inst) \
\
PINCTRL_DT_INST_DEFINE(inst); \
\
BUILD_ASSERT(SAI_FIFO_DEPTH(inst) > 0 && \
SAI_FIFO_DEPTH(inst) <= _SAI_FIFO_DEPTH(inst), \
"invalid FIFO depth"); \
@ -910,6 +920,7 @@ static struct sai_config sai_config_##inst = { \
.rx_sync_mode = SAI_RX_SYNC_MODE(inst), \
.tx_dline = SAI_TX_DLINE_INDEX(inst), \
.rx_dline = SAI_RX_DLINE_INDEX(inst), \
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
}; \
\
static struct sai_data sai_data_##inst = { \

View file

@ -7,6 +7,7 @@
#define ZEPHYR_DRIVERS_DAI_NXP_SAI_H_
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/logging/log.h>
#include <fsl_sai.h>
@ -271,6 +272,7 @@ struct sai_config {
void (*irq_config)(void);
uint32_t tx_dline;
uint32_t rx_dline;
const struct pinctrl_dev_config *pincfg;
};
/* this needs to perfectly match SOF's struct sof_ipc_dai_sai_params */

View file

@ -5,7 +5,7 @@ description: NXP Synchronous Audio Interface (SAI) node
compatible: "nxp,dai-sai"
include: base.yaml
include: [base.yaml, pinctrl-device.yaml]
properties:
reg: