drivers: dai: sai: disable IRQs when not needed

IRQs are currently only enabled during the driver
initialization function (i.e: sai_init()). As such,
even though they're not needed (i.e: after a TRIGGER_STOP
operation) they remain enabled. Fix this by enabling IRQs
after during the TRIGGER_START operation and disabling them
during the TRIGGER_STOP operation.

This change is required by irq chips (i.e: irqsteer) which
perform PM operations during irq_enable()/irq_disable(). If
interrupts are left enabled all the time that means the irq
chip's PM resources might also remain enabled.

To make this change possible, the irq will have to be stored
inside the SAI's configuration structure.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This commit is contained in:
Laurentiu Mihalcea 2024-09-30 13:27:39 +03:00 committed by Carles Cufí
parent 48b98a9284
commit e8d28bfdfd
2 changed files with 7 additions and 2 deletions

View file

@ -620,6 +620,8 @@ out_dmareq_disable:
SAI_TX_RX_ENABLE_DISABLE_IRQ(dir, data->regmap,
kSAI_FIFOErrorInterruptEnable, false);
irq_disable(cfg->irq);
return 0;
}
@ -723,6 +725,8 @@ static int sai_trigger_start(const struct device *dev,
sai_tx_rx_sw_reset(data, cfg, dir);
irq_enable(cfg->irq);
/* enable error interrupt */
SAI_TX_RX_ENABLE_DISABLE_IRQ(dir, data->regmap,
kSAI_FIFOErrorInterruptEnable, true);
@ -842,7 +846,7 @@ static int sai_init(const struct device *dev)
data->tx_state = DAI_STATE_NOT_READY;
data->rx_state = DAI_STATE_NOT_READY;
/* register ISR and enable IRQ */
/* register ISR */
cfg->irq_config();
return 0;
@ -902,12 +906,12 @@ void irq_config_##inst(void) \
sai_isr, \
DEVICE_DT_INST_GET(inst), \
0); \
irq_enable(DT_INST_IRQN(inst)); \
} \
\
static struct sai_config sai_config_##inst = { \
.regmap_phys = DT_INST_REG_ADDR(inst), \
.regmap_size = DT_INST_REG_SIZE(inst), \
.irq = DT_INST_IRQN(inst), \
.clk_data = SAI_CLOCK_DATA_DECLARE(inst), \
.rx_fifo_watermark = SAI_RX_FIFO_WATERMARK(inst), \
.tx_fifo_watermark = SAI_TX_FIFO_WATERMARK(inst), \

View file

@ -259,6 +259,7 @@ struct sai_data {
struct sai_config {
uint32_t regmap_phys;
uint32_t regmap_size;
uint32_t irq;
struct sai_clock_data clk_data;
bool mclk_is_output;
/* if the tx/rx-fifo-watermark properties are not specified, it's going