From c7a00248a668dcac699fc01632bfdabe2c4bb769 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Tue, 8 Apr 2025 14:56:12 -0400 Subject: [PATCH] drivers: i2c_rtio: Use the NXP Flexcomm driver for interrupt handling The Low Power Flexcomm driver manages the interrupt handling and provides an API to register interrupt callbacks. Register the NXP LPI2C interrupt handler. Applying dca6e64c93f26db254089f20225854bb1f8fe9b4 on RTIO-version. Authored-by: Mahesh Mahadevan Signed-off-by: Luis Ubieda --- drivers/i2c/i2c_mcux_lpi2c_rtio.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/i2c/i2c_mcux_lpi2c_rtio.c b/drivers/i2c/i2c_mcux_lpi2c_rtio.c index 07936da06c0..9c2eb106fe7 100644 --- a/drivers/i2c/i2c_mcux_lpi2c_rtio.c +++ b/drivers/i2c/i2c_mcux_lpi2c_rtio.c @@ -16,6 +16,9 @@ #include #include #include +#if CONFIG_NXP_LP_FLEXCOMM +#include +#endif #include @@ -40,6 +43,9 @@ LOG_MODULE_REGISTER(mcux_lpi2c); struct mcux_lpi2c_config { DEVICE_MMIO_NAMED_ROM(reg_base); +#ifdef CONFIG_NXP_LP_FLEXCOMM + const struct device *parent_dev; +#endif const struct device *clock_dev; clock_control_subsys_t clock_subsys; void (*irq_config_func)(const struct device *dev); @@ -329,7 +335,15 @@ static int mcux_lpi2c_init(const struct device *dev) return error; } +#if CONFIG_NXP_LP_FLEXCOMM + /* When using LP Flexcomm driver, register the interrupt handler + * so we receive notification from the LP Flexcomm interrupt handler. + */ + nxp_lp_flexcomm_setirqhandler(config->parent_dev, dev, + LP_FLEXCOMM_PERIPH_LPI2C, mcux_lpi2c_isr); +#else config->irq_config_func(dev); +#endif i2c_rtio_init(data->ctx, dev); @@ -363,6 +377,13 @@ static DEVICE_API(i2c, mcux_lpi2c_driver_api) = { IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), \ (I2C_MCUX_LPI2C_MODULE_IRQ_CONNECT(n))) +#ifdef CONFIG_NXP_LP_FLEXCOMM +#define PARENT_DEV(n) \ + .parent_dev = DEVICE_DT_GET(DT_INST_PARENT(n)), +#else +#define PARENT_DEV(n) +#endif /* CONFIG_NXP_LP_FLEXCOMM */ + #define I2C_MCUX_LPI2C_INIT(n) \ PINCTRL_DT_INST_DEFINE(n); \ \ @@ -370,6 +391,7 @@ static DEVICE_API(i2c, mcux_lpi2c_driver_api) = { \ static const struct mcux_lpi2c_config mcux_lpi2c_config_##n = { \ DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)), \ + PARENT_DEV(n) \ .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = \ (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\