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

title: Maxim MAX7360 GPIO controller

maintainers:
  - Kamel Bouhara <kamel.bouhara@bootlin.com>
  - Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>

description: |
  Maxim MAX7360 GPIO controller, in MAX7360 chipset
  https://www.analog.com/en/products/max7360.html

  The device provides two series of GPIOs, referred here as GPIOs and GPOs.

  PORT0 to PORT7 pins can be used as GPIOs, with support for interrupts and
  constant-current mode. These pins will also be used by the rotary encoder and
  PWM functionalities.

  COL2 to COL7 pins can be used as GPOs, there is no input capability. COL pins
  will be partitioned, with the first pins being affected to the keypad
  functionality and the last ones as GPOs.

properties:
  compatible:
    enum:
      - maxim,max7360-gpio
      - maxim,max7360-gpo

  gpio-controller: true

  "#gpio-cells":
    const: 2

  interrupt-controller: true

  "#interrupt-cells":
    const: 2

  maxim,constant-current-disable:
    $ref: /schemas/types.yaml#/definitions/uint32
    description:
      Bit field, each bit disables constant-current output of the associated
      GPIO, starting from the least significant bit for the first GPIO.
    maximum: 0xff

required:
  - compatible
  - gpio-controller

allOf:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - maxim,max7360-gpio
        ngpios: false
    then:
      required:
        - interrupt-controller
    else:
      properties:
        interrupt-controller: false
        maxim,constant-current-disable: false

additionalProperties: false

examples:
  - |
    gpio {
      compatible = "maxim,max7360-gpio";

      gpio-controller;
      #gpio-cells = <2>;
      maxim,constant-current-disable = <0x06>;

      interrupt-controller;
      #interrupt-cells = <2>;
    };
