Skip to content

Commit add9e60

Browse files
michal-smolacfriedt
authored andcommitted
drivers: i2c: mcux_lpi2c: Support split role interrupts
Some NXP SoCs have dedicated interrupts for controller and target roles. The i2c_mcux_lpi2c driver connects only one interrupt. Add connection of the second interrupt, if enabled, to support SoCs with split role interrupts. Signed-off-by: Michal Smola <[email protected]>
1 parent 98db4d9 commit add9e60

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

drivers/i2c/i2c_mcux_lpi2c.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -559,18 +559,14 @@ static DEVICE_API(i2c, mcux_lpi2c_driver_api) = {
559559
#define I2C_MCUX_LPI2C_SDA_INIT(n)
560560
#endif /* CONFIG_I2C_MCUX_LPI2C_BUS_RECOVERY */
561561

562-
#define I2C_MCUX_LPI2C_MODULE_IRQ_CONNECT(n) \
563-
do { \
564-
IRQ_CONNECT(DT_INST_IRQN(n), \
565-
DT_INST_IRQ(n, priority), \
566-
mcux_lpi2c_isr, \
567-
DEVICE_DT_INST_GET(n), 0); \
568-
irq_enable(DT_INST_IRQN(n)); \
569-
} while (false)
570-
571-
#define I2C_MCUX_LPI2C_MODULE_IRQ(n) \
572-
IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), \
573-
(I2C_MCUX_LPI2C_MODULE_IRQ_CONNECT(n)))
562+
#define I2C_MCUX_LPI2C_CONFIGURE_IRQ(idx, inst) \
563+
IF_ENABLED(DT_INST_IRQ_HAS_IDX(inst, idx), ( \
564+
IRQ_CONNECT(DT_INST_IRQ_BY_IDX(inst, idx, irq), \
565+
DT_INST_IRQ_BY_IDX(inst, idx, priority), \
566+
mcux_lpi2c_isr, \
567+
DEVICE_DT_INST_GET(inst), 0); \
568+
irq_enable(DT_INST_IRQ_BY_IDX(inst, idx, irq)); \
569+
))
574570

575571
/* When using LP Flexcomm driver, register the interrupt handler
576572
* so we receive notification from the LP Flexcomm interrupt handler.
@@ -585,7 +581,8 @@ static DEVICE_API(i2c, mcux_lpi2c_driver_api) = {
585581
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_INST_PARENT(n), \
586582
nxp_lp_flexcomm), \
587583
(I2C_MCUX_LPI2C_LPFLEXCOMM_IRQ_FUNC(n)), \
588-
(I2C_MCUX_LPI2C_MODULE_IRQ(n))) \
584+
(LISTIFY(DT_NUM_IRQS(DT_DRV_INST(n)), \
585+
I2C_MCUX_LPI2C_CONFIGURE_IRQ, (), n)))
589586

590587
#define I2C_MCUX_LPI2C_INIT(n) \
591588
PINCTRL_DT_INST_DEFINE(n); \

0 commit comments

Comments
 (0)