drivers: dai: sai: Introduce the rx_sync_mode/tx_sync_mode properties

In preparation for supporting all synchronization modes, this
commit introduces the rx_sync_mode/tx_sync_mode DTS properties.
Using these, the user will be able to specify which synchronization
mode the SAI should use.

At the moment, the driver does nothing with the values from
said properties but still checks if their values are sane
(i.e: it checks if the directions are both in SYNC mode which
is forbidden). By default, if "rx_sync_mode" or "tx_sync_mode"
is not specified, the direction will be set to ASYNC mode.
As such, below one may find a couple of valid examples
depicting this idea:

	tx_sync_mode = <0>;
	rx_sync_mode = <0>;

is the same as not specifying any of the properties,

	tx_sync_mode = <1>;
	rx_sync_mode = <0>;

is the same as:

	tx_sync_mode = <1>;

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This commit is contained in:
Laurentiu Mihalcea 2023-12-21 14:36:46 +02:00 committed by Carles Cufí
commit 6127535b1d
3 changed files with 48 additions and 0 deletions

View file

@ -711,6 +711,10 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_SAI_HAS_MCLK_CONFIG_OPTION) || \
!DT_INST_PROP(inst, mclk_is_output), \
"SAI doesn't support MCLK config but mclk_is_output is specified");\
\
BUILD_ASSERT(SAI_TX_SYNC_MODE(inst) != SAI_RX_SYNC_MODE(inst) || \
SAI_TX_SYNC_MODE(inst) != kSAI_ModeSync, \
"transmitter and receiver can't be both SYNC with each other"); \
\
static const struct dai_properties sai_tx_props_##inst = { \
.fifo_address = SAI_TX_FIFO_BASE(inst), \
.fifo_depth = SAI_FIFO_DEPTH(inst) * CONFIG_SAI_FIFO_WORD_SIZE, \
@ -743,6 +747,8 @@ static struct sai_config sai_config_##inst = { \
.tx_props = &sai_tx_props_##inst, \
.rx_props = &sai_rx_props_##inst, \
.irq_config = irq_config_##inst, \
.tx_sync_mode = SAI_TX_SYNC_MODE(inst), \
.rx_sync_mode = SAI_RX_SYNC_MODE(inst), \
}; \
\
static struct sai_data sai_data_##inst = { \

View file

@ -125,6 +125,18 @@ LOG_MODULE_REGISTER(nxp_dai_sai);
#define SAI_RX_DMA_MUX(inst)\
FSL_FEATURE_SAI_RX_DMA_MUXn(UINT_TO_I2S(DT_INST_REG_ADDR(inst)))
/* used to retrieve the synchronization mode of the transmitter. If this
* property is not specified, ASYNC mode will be used.
*/
#define SAI_TX_SYNC_MODE(inst)\
DT_INST_PROP_OR(inst, tx_sync_mode, kSAI_ModeAsync)
/* used to retrieve the synchronization mode of the receiver. If this property
* is not specified, ASYNC mode will be used.
*/
#define SAI_RX_SYNC_MODE(inst)\
DT_INST_PROP_OR(inst, rx_sync_mode, kSAI_ModeAsync)
/* utility macros */
/* invert a clock's polarity. This works because a clock's polarity is expressed
@ -211,6 +223,10 @@ struct sai_config {
const struct dai_properties *tx_props;
const struct dai_properties *rx_props;
uint32_t dai_index;
/* RX synchronization mode - may be SYNC or ASYNC */
sai_sync_mode_t rx_sync_mode;
/* TX synchronization mode - may be SYNC or ASYNC */
sai_sync_mode_t tx_sync_mode;
void (*irq_config)(void);
};

View file

@ -58,3 +58,29 @@ properties:
associated with the DAI whose index Linux passes to SOF
through an IPC. If this property is not specified, the DAI
index will be considered 0.
tx-sync-mode:
type: int
enum:
- 0
- 1
description: |
Use this property to specify which synchronization mode to use
for the transmitter. At the moment, the only supported modes are:
1) The transmitter is ASYNC (0)
2) The transmitter is in SYNC with the receiver (1)
If this property is not specified, the transmitter will be set to ASYNC.
If one side is SYNC then the other MUST be ASYNC. Failing to meet this
condition will result in a failed BUILD_ASSERT().
rx-sync-mode:
type: int
enum:
- 0
- 1
description: |
Use this property to specify which synchronization mode to use
for the receiver. At the moment, the only supported modes are:
1) The receiver is ASYNC (0)
2) The receiver is in SYNC with the transmitter (1)
If this property is not specified, the receiver will be set to ASYNC.
If one side is SYNC then the other MUST be ASYNC. Failing to meet this
condition will result in a failed BUILD_ASSERT().