23
23
#define PORT_Type void
24
24
#endif
25
25
26
+ #if (defined(FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT ) && \
27
+ FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT )
28
+ #define GPIO_MCUX_HAS_INTERRUPT_CHANNEL_SELECT
29
+ #endif
30
+
31
+ #if (defined(FSL_FEATURE_PORT_HAS_NO_INTERRUPT ) && FSL_FEATURE_PORT_HAS_NO_INTERRUPT )
32
+ #define PORT_HAS_NO_INTERRUPT
33
+ #endif
34
+
26
35
struct gpio_mcux_config {
27
36
/* gpio_driver_config needs to be first */
28
37
struct gpio_driver_config common ;
@@ -255,7 +264,7 @@ static int gpio_mcux_port_toggle_bits(const struct device *dev, uint32_t mask)
255
264
}
256
265
257
266
#if !(defined(CONFIG_PINCTRL_NXP_IOCON ))
258
- #if !(defined(FSL_FEATURE_PORT_HAS_NO_INTERRUPT ) && FSL_FEATURE_PORT_HAS_NO_INTERRUPT )
267
+ #if !(defined(PORT_HAS_NO_INTERRUPT ) )
259
268
static uint32_t get_port_pcr_irqc_value_from_flags (const struct device * dev , uint32_t pin ,
260
269
enum gpio_int_mode mode , enum gpio_int_trig trig )
261
270
{
@@ -289,11 +298,10 @@ static uint32_t get_port_pcr_irqc_value_from_flags(const struct device *dev, uin
289
298
290
299
return PORT_PCR_IRQC (port_interrupt );
291
300
}
292
- #endif /* !defined(FSL_FEATURE_PORT_HAS_NO_INTERRUPT) && FSL_FEATURE_PORT_HAS_NO_INTERRUPT */
301
+ #endif /* !( defined(PORT_HAS_NO_INTERRUPT)) */
293
302
#endif /* !(defined(CONFIG_PINCTRL_NXP_IOCON)) */
294
303
295
- #if (defined(FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT ) && \
296
- FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT )
304
+ #if (defined(GPIO_MCUX_HAS_INTERRUPT_CHANNEL_SELECT ) || defined(PORT_HAS_NO_INTERRUPT ))
297
305
298
306
#define GPIO_MCUX_INTERRUPT_DISABLED 0
299
307
#define GPIO_MCUX_INTERRUPT_LOGIC_0 0x8
@@ -335,7 +343,7 @@ static uint32_t get_gpio_icr_irqc_value_from_flags(const struct device *dev, uin
335
343
336
344
return GPIO_ICR_IRQC (gpio_interrupt );
337
345
}
338
- #endif /* (defined(FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT ) */
346
+ #endif /* (defined(GPIO_MCUX_HAS_INTERRUPT_CHANNEL_SELECT ) */
339
347
340
348
static int gpio_mcux_pin_interrupt_configure (const struct device * dev , gpio_pin_t pin ,
341
349
enum gpio_int_mode mode , enum gpio_int_trig trig )
@@ -361,16 +369,15 @@ static int gpio_mcux_pin_interrupt_configure(const struct device *dev, gpio_pin_
361
369
return - ENOTSUP ;
362
370
}
363
371
364
- #if (defined(FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT ) && \
365
- FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT )
372
+ #if (defined(GPIO_MCUX_HAS_INTERRUPT_CHANNEL_SELECT ) || defined(PORT_HAS_NO_INTERRUPT ))
366
373
uint32_t icr = get_gpio_icr_irqc_value_from_flags (dev , pin , mode , trig );
367
374
368
375
gpio_base -> ICR [pin ] = (gpio_base -> ICR [pin ] & ~GPIO_ICR_IRQC_MASK ) | icr ;
369
- #elif !(defined(FSL_FEATURE_PORT_HAS_NO_INTERRUPT ) && FSL_FEATURE_PORT_HAS_NO_INTERRUPT )
376
+ #elif !(defined(PORT_HAS_NO_INTERRUPT ) )
370
377
uint32_t pcr = get_port_pcr_irqc_value_from_flags (dev , pin , mode , trig );
371
378
372
379
port_base -> PCR [pin ] = (port_base -> PCR [pin ] & ~PORT_PCR_IRQC_MASK ) | pcr ;
373
- #endif /* !( defined(FSL_FEATURE_PORT_HAS_NO_INTERRUPT ) */
380
+ #endif /* defined(GPIO_MCUX_HAS_INTERRUPT_CHANNEL_SELECT) || defined(PORT_HAS_NO_INTERRUPT ) */
374
381
375
382
return 0 ;
376
383
}
@@ -389,21 +396,20 @@ static void gpio_mcux_port_isr(const struct device *dev)
389
396
struct gpio_mcux_data * data = dev -> data ;
390
397
uint32_t int_status ;
391
398
392
- #if (defined(FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT ) && \
393
- FSL_FEATURE_GPIO_HAS_INTERRUPT_CHANNEL_SELECT )
399
+ #if (defined(GPIO_MCUX_HAS_INTERRUPT_CHANNEL_SELECT ) || defined(PORT_HAS_NO_INTERRUPT ))
394
400
int_status = config -> gpio_base -> ISFR [0 ];
395
401
396
402
/* Clear the gpio interrupts */
397
403
config -> gpio_base -> ISFR [0 ] = int_status ;
398
- #elif !(defined(FSL_FEATURE_PORT_HAS_NO_INTERRUPT ) && FSL_FEATURE_PORT_HAS_NO_INTERRUPT )
404
+ #elif !(defined(PORT_HAS_NO_INTERRUPT ) )
399
405
int_status = config -> port_base -> ISFR ;
400
406
401
407
/* Clear the port interrupts */
402
408
config -> port_base -> ISFR = int_status ;
403
409
#else
404
410
int_status = 0U ;
405
411
ARG_UNUSED (config );
406
- #endif /* !( defined(FSL_FEATURE_PORT_HAS_NO_INTERRUPT ) */
412
+ #endif /* defined(GPIO_MCUX_HAS_INTERRUPT_CHANNEL_SELECT) || defined(PORT_HAS_NO_INTERRUPT ) */
407
413
408
414
gpio_fire_callbacks (& data -> callbacks , dev , int_status );
409
415
}
0 commit comments