@@ -43,9 +43,6 @@ LOG_MODULE_REGISTER(mcux_lpi2c);
43
43
44
44
struct mcux_lpi2c_config {
45
45
DEVICE_MMIO_NAMED_ROM (reg_base );
46
- #ifdef CONFIG_NXP_LP_FLEXCOMM
47
- const struct device * parent_dev ;
48
- #endif
49
46
const struct device * clock_dev ;
50
47
clock_control_subsys_t clock_subsys ;
51
48
void (* irq_config_func )(const struct device * dev );
@@ -335,15 +332,7 @@ static int mcux_lpi2c_init(const struct device *dev)
335
332
return error ;
336
333
}
337
334
338
- #if CONFIG_NXP_LP_FLEXCOMM
339
- /* When using LP Flexcomm driver, register the interrupt handler
340
- * so we receive notification from the LP Flexcomm interrupt handler.
341
- */
342
- nxp_lp_flexcomm_setirqhandler (config -> parent_dev , dev ,
343
- LP_FLEXCOMM_PERIPH_LPI2C , mcux_lpi2c_isr );
344
- #else
345
335
config -> irq_config_func (dev );
346
- #endif
347
336
348
337
i2c_rtio_init (data -> ctx , dev );
349
338
@@ -377,21 +366,31 @@ static DEVICE_API(i2c, mcux_lpi2c_driver_api) = {
377
366
IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), \
378
367
(I2C_MCUX_LPI2C_MODULE_IRQ_CONNECT(n)))
379
368
380
- #ifdef CONFIG_NXP_LP_FLEXCOMM
381
- #define PARENT_DEV (n ) \
382
- .parent_dev = DEVICE_DT_GET(DT_INST_PARENT(n)),
383
- #else
384
- #define PARENT_DEV (n )
385
- #endif /* CONFIG_NXP_LP_FLEXCOMM */
369
+ /* When using LP Flexcomm driver, register the interrupt handler
370
+ * so we receive notification from the LP Flexcomm interrupt handler.
371
+ */
372
+ #define I2C_MCUX_LPI2C_LPFLEXCOMM_IRQ_FUNC (n ) \
373
+ nxp_lp_flexcomm_setirqhandler(DEVICE_DT_GET(DT_INST_PARENT(n)), \
374
+ DEVICE_DT_INST_GET(n), \
375
+ LP_FLEXCOMM_PERIPH_LPI2C, \
376
+ mcux_lpi2c_isr)
377
+
378
+ #define I2C_MCUX_LPI2C_IRQ_SETUP_FUNC (n ) \
379
+ COND_CODE_1(DT_NODE_HAS_COMPAT(DT_INST_PARENT(n), \
380
+ nxp_lp_flexcomm), \
381
+ (I2C_MCUX_LPI2C_LPFLEXCOMM_IRQ_FUNC(n)), \
382
+ (I2C_MCUX_LPI2C_MODULE_IRQ(n)))
386
383
387
384
#define I2C_MCUX_LPI2C_INIT (n ) \
388
385
PINCTRL_DT_INST_DEFINE(n); \
389
386
\
390
- static void mcux_lpi2c_config_func_##n(const struct device *dev); \
387
+ static void mcux_lpi2c_config_func_##n(const struct device *dev)\
388
+ { \
389
+ I2C_MCUX_LPI2C_IRQ_SETUP_FUNC(n); \
390
+ } \
391
391
\
392
392
static const struct mcux_lpi2c_config mcux_lpi2c_config_##n = { \
393
393
DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)), \
394
- PARENT_DEV(n) \
395
394
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
396
395
.clock_subsys = \
397
396
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
@@ -417,11 +416,6 @@ static DEVICE_API(i2c, mcux_lpi2c_driver_api) = {
417
416
&mcux_lpi2c_data_##n, \
418
417
&mcux_lpi2c_config_##n, POST_KERNEL, \
419
418
CONFIG_I2C_INIT_PRIORITY, \
420
- &mcux_lpi2c_driver_api); \
421
- \
422
- static void mcux_lpi2c_config_func_##n(const struct device *dev)\
423
- { \
424
- I2C_MCUX_LPI2C_MODULE_IRQ(n); \
425
- }
419
+ &mcux_lpi2c_driver_api);
426
420
427
421
DT_INST_FOREACH_STATUS_OKAY (I2C_MCUX_LPI2C_INIT )
0 commit comments