# Copyright 2022-2023 NXP
# SPDX-License-Identifier: Apache-2.0

description: |
  NXP S32 GPIO controller.

  The GPIO controller provides the option to route external input pad interrupts
  to either the SIUL2 EIRQ interrupt controller or, when available on the SoC,
  the WKPU interrupt controller. By default, GPIO interrupts are routed to the
  SIUL2 EIRQ interrupt controller.

  To route external interrupts to the WKPU interrupt controller, the GPIO
  specifier must be supplied with the flag `NXP_S32_GPIO_INT_WKPU`. For example,
  the following snippet of devicetree source code instructs the GPIO controller
  to route the interrupt from pin 9 of `gpioa` to the WKPU interrupt controller:

    #include <zephyr/dt-bindings/gpio/nxp-s32-gpio.h>

    &device {
        gpios = <&gpioa 9 (NXP_S32_GPIO_INT_WKPU | GPIO_ACTIVE_HIGH)>;
    };

  Explicitly specifying the routing of a GPIO interrupt to a particular
  interrupt controller allows for the allocation of distinct interrupt
  priorities according to application-specific requirements. This is owing to
  the fact that each interrupt controller features its own interrupt vector.
  To illustrate, it is plausible to allocate the board's button interrupts to
  the interrupt controller configured with a lower priority compared to the one
  designated for the data-ready interrupt originating from a sensor. This
  decision is justified by the potentially higher importance of the latter
  interrupt to the overall system operation.

  The `NXP_S32_GPIO_INT_WKPU` flag is intended exclusively for specifying WKPU
  as the interrupt controller for the corresponding GPIO. It's worth noting that
  despite being named WKPU, the flag is not meant to configure GPIOs as wake-up
  sources.

compatible: "nxp,s32-gpio"

include: [gpio-controller.yaml, base.yaml]

properties:
  reg:
    required: true

  reg-names:
    required: true

  interrupts:
    description: |
      For GPIO ports that have pins can be used for processing
      external interrupt signal, this is a list of GPIO pins and
      respective external interrupt lines (<gpio-pin eirq-line>).

  nxp,wkpu:
    type: phandle
    description: |
      NXP WKPU controller associated to this GPIO port.

  nxp,wkpu-interrupts:
    type: array
    description: |
      Map between WKPU external interrupt sources and pins of this GPIO port,
      as in a tuple `<gpio-pin wkpu-interrupt-source>`.

  "#gpio-cells":
    const: 2

gpio-cells:
  - pin
  - flags
