Skip to content

Commit e8d28bf

Browse files
LaurentiuM1234carlescufi
authored andcommitted
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 <[email protected]>
1 parent 48b98a9 commit e8d28bf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/dai/nxp/sai/sai.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ static int sai_trigger_stop(const struct device *dev,
620620
SAI_TX_RX_ENABLE_DISABLE_IRQ(dir, data->regmap,
621621
kSAI_FIFOErrorInterruptEnable, false);
622622

623+
irq_disable(cfg->irq);
624+
623625
return 0;
624626
}
625627

@@ -723,6 +725,8 @@ static int sai_trigger_start(const struct device *dev,
723725

724726
sai_tx_rx_sw_reset(data, cfg, dir);
725727

728+
irq_enable(cfg->irq);
729+
726730
/* enable error interrupt */
727731
SAI_TX_RX_ENABLE_DISABLE_IRQ(dir, data->regmap,
728732
kSAI_FIFOErrorInterruptEnable, true);
@@ -842,7 +846,7 @@ static int sai_init(const struct device *dev)
842846
data->tx_state = DAI_STATE_NOT_READY;
843847
data->rx_state = DAI_STATE_NOT_READY;
844848

845-
/* register ISR and enable IRQ */
849+
/* register ISR */
846850
cfg->irq_config();
847851

848852
return 0;
@@ -902,12 +906,12 @@ void irq_config_##inst(void) \
902906
sai_isr, \
903907
DEVICE_DT_INST_GET(inst), \
904908
0); \
905-
irq_enable(DT_INST_IRQN(inst)); \
906909
} \
907910
\
908911
static struct sai_config sai_config_##inst = { \
909912
.regmap_phys = DT_INST_REG_ADDR(inst), \
910913
.regmap_size = DT_INST_REG_SIZE(inst), \
914+
.irq = DT_INST_IRQN(inst), \
911915
.clk_data = SAI_CLOCK_DATA_DECLARE(inst), \
912916
.rx_fifo_watermark = SAI_RX_FIFO_WATERMARK(inst), \
913917
.tx_fifo_watermark = SAI_TX_FIFO_WATERMARK(inst), \

drivers/dai/nxp/sai/sai.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ struct sai_data {
259259
struct sai_config {
260260
uint32_t regmap_phys;
261261
uint32_t regmap_size;
262+
uint32_t irq;
262263
struct sai_clock_data clk_data;
263264
bool mclk_is_output;
264265
/* if the tx/rx-fifo-watermark properties are not specified, it's going

0 commit comments

Comments
 (0)