# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/pinctrl/brcm,bcm2835-gpio.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Broadcom BCM2835 GPIO (and pinmux) controller

maintainers:
  - Florian Fainelli <f.fainelli@gmail.com>

description: >
  The BCM2835 GPIO module is a combined GPIO controller, (GPIO) interrupt
  controller, and pinmux/control device.

properties:
  compatible:
    enum:
      - brcm,bcm2835-gpio
      - brcm,bcm2711-gpio
      - brcm,bcm7211-gpio

  reg:
    maxItems: 1

  '#gpio-cells':
    const: 2

  gpio-controller: true
  gpio-ranges: true
  gpio-line-names: true

  interrupts:
    description: >
      Interrupt outputs: one per bank, then the combined “all banks” line.
      BCM7211 may specify up to four per-bank wake-up lines and one combined
      wake-up interrupt.
    minItems: 4
    maxItems: 10

  '#interrupt-cells':
    const: 2

  interrupt-controller: true

additionalProperties:
  oneOf:
    - type: object
      additionalProperties: false

      patternProperties:
        '^pins?-':
          type: object
          allOf:
            - $ref: /schemas/pinctrl/pincfg-node.yaml#
            - $ref: /schemas/pinctrl/pinmux-node.yaml#
          additionalProperties: false

          properties:
            pins: true
            function: true
            bias-disable: true
            bias-pull-up: true
            bias-pull-down: true
            output-high: true
            output-low: true

          required:
            - pins
            - function

    - type: object
      additionalProperties: false
      deprecated: true

      properties:
        brcm,pins:
          description:
            GPIO pin numbers for legacy configuration.
          $ref: /schemas/types.yaml#/definitions/uint32-array

        brcm,function:
          description:
            Legacy mux function for the pins (0=input, 1=output, 2–7=alt functions).
          $ref: /schemas/types.yaml#/definitions/uint32-array
          maximum: 7

        brcm,pull:
          description: >
            Legacy pull setting for the pins (0=none, 1=pull-down, 2=pull-up).
          $ref: /schemas/types.yaml#/definitions/uint32-array
          maximum: 2

      required:
        - brcm,pins

allOf:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - brcm,bcm2835-gpio
              - brcm,bcm2711-gpio
    then:
      properties:
        interrupts:
          maxItems: 5

examples:
  - |
    gpio@2200000 {
        compatible = "brcm,bcm2835-gpio";
        reg = <0x2200000 0xb4>;
        interrupts = <2 17>, <2 19>, <2 18>, <2 20>, <2 21>;
        #gpio-cells = <2>;
        gpio-controller;
        #interrupt-cells = <2>;
        interrupt-controller;
    };
