162306a36Sopenharmony_ci# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
262306a36Sopenharmony_ci%YAML 1.2
362306a36Sopenharmony_ci---
462306a36Sopenharmony_ci$id: http://devicetree.org/schemas/gpio/nvidia,tegra186-gpio.yaml#
562306a36Sopenharmony_ci$schema: http://devicetree.org/meta-schemas/core.yaml#
662306a36Sopenharmony_ci
762306a36Sopenharmony_cititle: NVIDIA Tegra GPIO Controller (Tegra186 and later)
862306a36Sopenharmony_ci
962306a36Sopenharmony_cimaintainers:
1062306a36Sopenharmony_ci  - Thierry Reding <thierry.reding@gmail.com>
1162306a36Sopenharmony_ci  - Jon Hunter <jonathanh@nvidia.com>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cidescription: |
1462306a36Sopenharmony_ci  Tegra186 contains two GPIO controllers; a main controller and an "AON"
1562306a36Sopenharmony_ci  controller. This binding document applies to both controllers. The register
1662306a36Sopenharmony_ci  layouts for the controllers share many similarities, but also some
1762306a36Sopenharmony_ci  significant differences. Hence, this document describes closely related but
1862306a36Sopenharmony_ci  different bindings and compatible values.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci  The Tegra186 GPIO controller allows software to set the IO direction of,
2162306a36Sopenharmony_ci  and read/write the value of, numerous GPIO signals. Routing of GPIO signals
2262306a36Sopenharmony_ci  to package balls is under the control of a separate pin controller hardware
2362306a36Sopenharmony_ci  block. Two major sets of registers exist:
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci    a) Security registers, which allow configuration of allowed access to the
2662306a36Sopenharmony_ci       GPIO register set. These registers exist in a single contiguous block
2762306a36Sopenharmony_ci       of physical address space. The size of this block, and the security
2862306a36Sopenharmony_ci       features available, varies between the different GPIO controllers.
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci       Access to this set of registers is not necessary in all circumstances.
3162306a36Sopenharmony_ci       Code that wishes to configure access to the GPIO registers needs access
3262306a36Sopenharmony_ci       to these registers to do so. Code which simply wishes to read or write
3362306a36Sopenharmony_ci       GPIO data does not need access to these registers.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci    b) GPIO registers, which allow manipulation of the GPIO signals. In some
3662306a36Sopenharmony_ci       GPIO controllers, these registers are exposed via multiple "physical
3762306a36Sopenharmony_ci       aliases" in address space, each of which access the same underlying
3862306a36Sopenharmony_ci       state. See the hardware documentation for rationale. Any particular
3962306a36Sopenharmony_ci       GPIO client is expected to access just one of these physical aliases.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci    Tegra HW documentation describes a unified naming convention for all GPIOs
4262306a36Sopenharmony_ci    implemented by the SoC. Each GPIO is assigned to a port, and a port may
4362306a36Sopenharmony_ci    control a number of GPIOs. Thus, each GPIO is named according to an
4462306a36Sopenharmony_ci    alphabetical port name and an integer GPIO name within the port. For
4562306a36Sopenharmony_ci    example, GPIO_PA0, GPIO_PN6, or GPIO_PCC3.
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci    The number of ports implemented by each GPIO controller varies. The number
4862306a36Sopenharmony_ci    of implemented GPIOs within each port varies. GPIO registers within a
4962306a36Sopenharmony_ci    controller are grouped and laid out according to the port they affect.
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci    The mapping from port name to the GPIO controller that implements that
5262306a36Sopenharmony_ci    port, and the mapping from port name to register offset within a
5362306a36Sopenharmony_ci    controller, are both extremely non-linear. The header file
5462306a36Sopenharmony_ci    <dt-bindings/gpio/tegra186-gpio.h> describes the port-level mapping. In
5562306a36Sopenharmony_ci    that file, the naming convention for ports matches the HW documentation.
5662306a36Sopenharmony_ci    The values chosen for the names are alphabetically sorted within a
5762306a36Sopenharmony_ci    particular controller. Drivers need to map between the DT GPIO IDs and HW
5862306a36Sopenharmony_ci    register offsets using a lookup table.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci    Each GPIO controller can generate a number of interrupt signals. Each
6162306a36Sopenharmony_ci    signal represents the aggregate status for all GPIOs within a set of
6262306a36Sopenharmony_ci    ports. Thus, the number of interrupt signals generated by a controller
6362306a36Sopenharmony_ci    varies as a rough function of the number of ports it implements. Note
6462306a36Sopenharmony_ci    that the HW documentation refers to both the overall controller HW
6562306a36Sopenharmony_ci    module and the sets-of-ports as "controllers".
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci    Each GPIO controller in fact generates multiple interrupts signals for
6862306a36Sopenharmony_ci    each set of ports. Each GPIO may be configured to feed into a specific
6962306a36Sopenharmony_ci    one of the interrupt signals generated by a set-of-ports. The intent is
7062306a36Sopenharmony_ci    for each generated signal to be routed to a different CPU, thus allowing
7162306a36Sopenharmony_ci    different CPUs to each handle subsets of the interrupts within a port.
7262306a36Sopenharmony_ci    The status of each of these per-port-set signals is reported via a
7362306a36Sopenharmony_ci    separate register. Thus, a driver needs to know which status register to
7462306a36Sopenharmony_ci    observe. This binding currently defines no configuration mechanism for
7562306a36Sopenharmony_ci    this. By default, drivers should use register
7662306a36Sopenharmony_ci    GPIO_${port}_INTERRUPT_STATUS_G1_0. Future revisions to the binding could
7762306a36Sopenharmony_ci    define a property to configure this.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ciproperties:
8062306a36Sopenharmony_ci  compatible:
8162306a36Sopenharmony_ci    enum:
8262306a36Sopenharmony_ci      - nvidia,tegra186-gpio
8362306a36Sopenharmony_ci      - nvidia,tegra186-gpio-aon
8462306a36Sopenharmony_ci      - nvidia,tegra194-gpio
8562306a36Sopenharmony_ci      - nvidia,tegra194-gpio-aon
8662306a36Sopenharmony_ci      - nvidia,tegra234-gpio
8762306a36Sopenharmony_ci      - nvidia,tegra234-gpio-aon
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci  reg-names:
9062306a36Sopenharmony_ci    items:
9162306a36Sopenharmony_ci      - const: security
9262306a36Sopenharmony_ci      - const: gpio
9362306a36Sopenharmony_ci    minItems: 1
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci  reg:
9662306a36Sopenharmony_ci    items:
9762306a36Sopenharmony_ci      - description: Security configuration registers.
9862306a36Sopenharmony_ci      - description: |
9962306a36Sopenharmony_ci          GPIO control registers. This may cover either:
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci            a) The single physical alias that this OS should use.
10262306a36Sopenharmony_ci            b) All physical aliases that exist in the controller. This is
10362306a36Sopenharmony_ci               appropriate when the OS is responsible for managing assignment
10462306a36Sopenharmony_ci               of the physical aliases.
10562306a36Sopenharmony_ci    minItems: 1
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci  interrupts:
10862306a36Sopenharmony_ci    description: The interrupt outputs from the HW block, one per set of
10962306a36Sopenharmony_ci      ports, in the order the HW manual describes them. The number of entries
11062306a36Sopenharmony_ci      required varies depending on compatible value.
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci  gpio-controller: true
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci  "#gpio-cells":
11562306a36Sopenharmony_ci    description: |
11662306a36Sopenharmony_ci      Indicates how many cells are used in a consumer's GPIO specifier. In the
11762306a36Sopenharmony_ci      specifier:
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci        - The first cell is the pin number.
12062306a36Sopenharmony_ci          See <dt-bindings/gpio/tegra186-gpio.h>.
12162306a36Sopenharmony_ci        - The second cell contains flags:
12262306a36Sopenharmony_ci          - Bit 0 specifies polarity
12362306a36Sopenharmony_ci            - 0: Active-high (normal).
12462306a36Sopenharmony_ci            - 1: Active-low (inverted).
12562306a36Sopenharmony_ci    const: 2
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci  interrupt-controller: true
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci  "#interrupt-cells":
13062306a36Sopenharmony_ci    description: |
13162306a36Sopenharmony_ci      Indicates how many cells are used in a consumer's interrupt specifier.
13262306a36Sopenharmony_ci      In the specifier:
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci        - The first cell is the GPIO number.
13562306a36Sopenharmony_ci          See <dt-bindings/gpio/tegra186-gpio.h>.
13662306a36Sopenharmony_ci        - The second cell is contains flags:
13762306a36Sopenharmony_ci          - Bits [3:0] indicate trigger type and level:
13862306a36Sopenharmony_ci            - 1: Low-to-high edge triggered.
13962306a36Sopenharmony_ci            - 2: High-to-low edge triggered.
14062306a36Sopenharmony_ci            - 4: Active high level-sensitive.
14162306a36Sopenharmony_ci            - 8: Active low level-sensitive.
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci            Valid combinations are 1, 2, 3, 4, 8.
14462306a36Sopenharmony_ci    const: 2
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ciallOf:
14762306a36Sopenharmony_ci  - if:
14862306a36Sopenharmony_ci      properties:
14962306a36Sopenharmony_ci        compatible:
15062306a36Sopenharmony_ci          contains:
15162306a36Sopenharmony_ci            enum:
15262306a36Sopenharmony_ci              - nvidia,tegra186-gpio
15362306a36Sopenharmony_ci              - nvidia,tegra194-gpio
15462306a36Sopenharmony_ci              - nvidia,tegra234-gpio
15562306a36Sopenharmony_ci    then:
15662306a36Sopenharmony_ci      properties:
15762306a36Sopenharmony_ci        interrupts:
15862306a36Sopenharmony_ci          minItems: 6
15962306a36Sopenharmony_ci          maxItems: 48
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci  - if:
16262306a36Sopenharmony_ci      properties:
16362306a36Sopenharmony_ci        compatible:
16462306a36Sopenharmony_ci          contains:
16562306a36Sopenharmony_ci            enum:
16662306a36Sopenharmony_ci              - nvidia,tegra186-gpio-aon
16762306a36Sopenharmony_ci              - nvidia,tegra194-gpio-aon
16862306a36Sopenharmony_ci              - nvidia,tegra234-gpio-aon
16962306a36Sopenharmony_ci    then:
17062306a36Sopenharmony_ci      properties:
17162306a36Sopenharmony_ci        interrupts:
17262306a36Sopenharmony_ci          minItems: 1
17362306a36Sopenharmony_ci          maxItems: 4
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_cirequired:
17662306a36Sopenharmony_ci  - compatible
17762306a36Sopenharmony_ci  - reg
17862306a36Sopenharmony_ci  - reg-names
17962306a36Sopenharmony_ci  - interrupts
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ciadditionalProperties: false
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ciexamples:
18462306a36Sopenharmony_ci  - |
18562306a36Sopenharmony_ci    #include <dt-bindings/interrupt-controller/irq.h>
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci    gpio@2200000 {
18862306a36Sopenharmony_ci        compatible = "nvidia,tegra186-gpio";
18962306a36Sopenharmony_ci        reg-names = "security", "gpio";
19062306a36Sopenharmony_ci        reg = <0x2200000 0x10000>,
19162306a36Sopenharmony_ci              <0x2210000 0x10000>;
19262306a36Sopenharmony_ci        interrupts = <0  47 IRQ_TYPE_LEVEL_HIGH>,
19362306a36Sopenharmony_ci                     <0  50 IRQ_TYPE_LEVEL_HIGH>,
19462306a36Sopenharmony_ci                     <0  53 IRQ_TYPE_LEVEL_HIGH>,
19562306a36Sopenharmony_ci                     <0  56 IRQ_TYPE_LEVEL_HIGH>,
19662306a36Sopenharmony_ci                     <0  59 IRQ_TYPE_LEVEL_HIGH>,
19762306a36Sopenharmony_ci                     <0 180 IRQ_TYPE_LEVEL_HIGH>;
19862306a36Sopenharmony_ci        gpio-controller;
19962306a36Sopenharmony_ci        #gpio-cells = <2>;
20062306a36Sopenharmony_ci        interrupt-controller;
20162306a36Sopenharmony_ci        #interrupt-cells = <2>;
20262306a36Sopenharmony_ci    };
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci    gpio@c2f0000 {
20562306a36Sopenharmony_ci        compatible = "nvidia,tegra186-gpio-aon";
20662306a36Sopenharmony_ci        reg-names = "security", "gpio";
20762306a36Sopenharmony_ci        reg = <0xc2f0000 0x1000>,
20862306a36Sopenharmony_ci              <0xc2f1000 0x1000>;
20962306a36Sopenharmony_ci        interrupts = <0 60 IRQ_TYPE_LEVEL_HIGH>;
21062306a36Sopenharmony_ci        gpio-controller;
21162306a36Sopenharmony_ci        #gpio-cells = <2>;
21262306a36Sopenharmony_ci        interrupt-controller;
21362306a36Sopenharmony_ci        #interrupt-cells = <2>;
21462306a36Sopenharmony_ci    };
215