Skip to content

Commit c7a0024

Browse files
ubiedakartben
authored andcommitted
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 <mahesh.mahadevan@nxp.com> Signed-off-by: Luis Ubieda <luisf@croxel.com>
1 parent 797772f commit c7a0024

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/i2c/i2c_mcux_lpi2c_rtio.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include <zephyr/kernel.h>
1717
#include <zephyr/irq.h>
1818
#include <fsl_lpi2c.h>
19+
#if CONFIG_NXP_LP_FLEXCOMM
20+
#include <zephyr/drivers/mfd/nxp_lp_flexcomm.h>
21+
#endif
1922

2023
#include <zephyr/drivers/pinctrl.h>
2124

@@ -40,6 +43,9 @@ LOG_MODULE_REGISTER(mcux_lpi2c);
4043

4144
struct mcux_lpi2c_config {
4245
DEVICE_MMIO_NAMED_ROM(reg_base);
46+
#ifdef CONFIG_NXP_LP_FLEXCOMM
47+
const struct device *parent_dev;
48+
#endif
4349
const struct device *clock_dev;
4450
clock_control_subsys_t clock_subsys;
4551
void (*irq_config_func)(const struct device *dev);
@@ -329,7 +335,15 @@ static int mcux_lpi2c_init(const struct device *dev)
329335
return error;
330336
}
331337

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
332345
config->irq_config_func(dev);
346+
#endif
333347

334348
i2c_rtio_init(data->ctx, dev);
335349

@@ -363,13 +377,21 @@ static DEVICE_API(i2c, mcux_lpi2c_driver_api) = {
363377
IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), \
364378
(I2C_MCUX_LPI2C_MODULE_IRQ_CONNECT(n)))
365379

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 */
386+
366387
#define I2C_MCUX_LPI2C_INIT(n) \
367388
PINCTRL_DT_INST_DEFINE(n); \
368389
\
369390
static void mcux_lpi2c_config_func_##n(const struct device *dev); \
370391
\
371392
static const struct mcux_lpi2c_config mcux_lpi2c_config_##n = { \
372393
DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)), \
394+
PARENT_DEV(n) \
373395
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
374396
.clock_subsys = \
375397
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\

0 commit comments

Comments
 (0)