@@ -35,6 +35,7 @@ struct mcux_rgpio_config {
3535
3636 const struct pinctrl_soc_pinmux * pin_muxes ;
3737 uint8_t mux_count ;
38+ uint8_t irq_sel ;
3839};
3940
4041struct mcux_rgpio_data {
@@ -144,6 +145,14 @@ static int mcux_rgpio_configure(const struct device *dev,
144145 }
145146#endif
146147
148+ #if defined(CONFIG_SOC_MIMX9596_M7 )
149+ base -> PCNS &= ~BIT (pin );
150+ if (base -> PCNS & BIT (pin )) {
151+ /* We don't have access to this pin */
152+ return - ENOTSUP ;
153+ }
154+ #endif
155+
147156 memcpy (& pin_cfg .pinmux , & config -> pin_muxes [cfg_idx ], sizeof (pin_cfg ));
148157 /* cfg register will be set by pinctrl_configure_pins */
149158 pin_cfg .pin_ctrl_flags = reg ;
@@ -226,12 +235,20 @@ static int mcux_rgpio_pin_interrupt_configure(const struct device *dev,
226235 unsigned int key ;
227236 uint8_t irqs , irqc ;
228237
238+ #if defined(CONFIG_SOC_MIMX9596_M7 )
239+ base -> ICNS &= ~BIT (config -> irq_sel );
240+ if (base -> ICNS & BIT (config -> irq_sel )) {
241+ /* We don't have access to this IRQ */
242+ return - ENOTSUP ;
243+ }
244+ #endif
245+
229246 /* Make sure pin is supported */
230247 if ((config -> common .port_pin_mask & BIT (pin )) == 0 ) {
231248 return - ENOTSUP ;
232249 }
233250
234- irqs = 0 ; /* only irq0 is used for irq */
251+ irqs = config -> irq_sel ;
235252
236253 if (mode == GPIO_INT_MODE_DISABLED ) {
237254 irqc = kRGPIO_InterruptOrDMADisabled ;
@@ -277,9 +294,9 @@ static void mcux_rgpio_port_isr(const struct device *dev)
277294 struct mcux_rgpio_data * data = dev -> data ;
278295 uint32_t int_flags ;
279296
280- int_flags = base -> ISFR [0 ]; /* Notice: only irq0 is used for now */
297+ int_flags = base -> ISFR [config -> irq_sel ];
281298 int_flags &= config -> common .port_pin_mask ; /* don't handle unusable pin */
282- base -> ISFR [0 ] = int_flags ;
299+ base -> ISFR [config -> irq_sel ] = int_flags ;
283300
284301 gpio_fire_callbacks (& data -> callbacks , dev , int_flags );
285302}
@@ -303,7 +320,8 @@ static DEVICE_API(gpio, mcux_rgpio_driver_api) = {
303320 };
304321#define MCUX_RGPIO_PIN_INIT (n ) \
305322 .pin_muxes = mcux_rgpio_pinmux_##n, \
306- .mux_count = DT_PROP_LEN(DT_DRV_INST(n), pinmux),
323+ .mux_count = DT_PROP_LEN(DT_DRV_INST(n), pinmux), \
324+ .irq_sel = DT_INST_PROP(n, irq_output_select) \
307325
308326#define MCUX_RGPIO_IRQ_INIT (n , i ) \
309327 do { \
@@ -317,6 +335,8 @@ static DEVICE_API(gpio, mcux_rgpio_driver_api) = {
317335
318336#define MCUX_RGPIO_INIT (n ) \
319337 MCUX_RGPIO_PIN_DECLARE(n) \
338+ BUILD_ASSERT((DT_INST_PROP(n, irq_output_select) != 1) || DT_INST_IRQ_HAS_IDX(n, 1), \
339+ "irq-output-select=1 but IRQ 1 is not defined"); \
320340 static int mcux_rgpio_##n##_init(const struct device *dev); \
321341 \
322342 static const struct mcux_rgpio_config mcux_rgpio_##n##_config = { \
@@ -343,12 +363,7 @@ static DEVICE_API(gpio, mcux_rgpio_driver_api) = {
343363 { \
344364 DEVICE_MMIO_NAMED_MAP(dev, reg_base, \
345365 K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP); \
346- IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 0), \
347- (MCUX_RGPIO_IRQ_INIT(n, 0);)) \
348- \
349- IF_ENABLED(DT_INST_IRQ_HAS_IDX(n, 1), \
350- (MCUX_RGPIO_IRQ_INIT(n, 1);)) \
351- \
366+ MCUX_RGPIO_IRQ_INIT(n, DT_INST_PROP(n, irq_output_select)); \
352367 return 0; \
353368 }
354369
0 commit comments