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

title: Axiado AX3005 SGPIO Controller

maintainers:
  - Petar Stepanovic <pstepanovic@axiado.com>
  - SriNavmani A <srinavmani@axiado.com>
  - Prasad Bolisetty <pbolisetty@axiado.com>

description: |
  The Axiado SGPIO controller provides a serial GPIO expansion interface
  that multiplexes multiple GPIO signals over a small set of physical lines.

  The controller serializes output values on a data output line (DOUT) and
  samples input values from a data input line (DIN) in synchronization with
  a shift clock (SCLK). A latch signal (LATCH) updates the output states
  after each transfer cycle.

  SGPIO positions are organized in banks of 32, with registers controlling
  output values, input sampling, and interrupt status. The number of SGPIO
  positions supported depends on the controller configuration.

  The controller detects changes on input GPIOs. Interrupt events are
  aggregated and signaled through a single interrupt line to the parent
  interrupt controller.

  Register access is performed over the APB bus. The SGPIO shift clock is
  derived from the APB clock using a programmable divider.

  Each SGPIO position provides one input and one output, and both are
  exposed as GPIO lines. Position N is described by two consecutive lines:
  line 2 * N is the input and line 2 * N + 1 is the output. Directions are
  fixed by the hardware, so even lines are always inputs and odd lines are
  always outputs.

  Only input lines can generate interrupts. Rising, falling, and both-edge
  interrupts are supported.

properties:
  compatible:
    const: axiado,ax3005-sgpio

  reg:
    maxItems: 1

  clocks:
    description: APB interface clock
    maxItems: 1

  bus-frequency:
    description: Desired SGPIO shift clock frequency in Hz
    minimum: 1

  gpio-controller: true

  '#gpio-cells':
    const: 2

  interrupt-controller: true

  '#interrupt-cells':
    const: 2

  interrupts:
    maxItems: 1

  ngpios:
    description: |
      Total number of GPIO lines provided by the controller. Each SGPIO
      position wired up on the board contributes one input and one output
      line, so this is twice the number of positions and must be even. It
      may be lower than the maximum supported by the hardware.
    minimum: 2
    maximum: 1024
    multipleOf: 2

required:
  - compatible
  - reg
  - clocks
  - bus-frequency
  - gpio-controller
  - '#gpio-cells'
  - interrupts
  - interrupt-controller
  - '#interrupt-cells'
  - ngpios

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/interrupt-controller/irq.h>

    gpio@33201c00 {
        compatible = "axiado,ax3005-sgpio";
        reg = <0x33201c00 0x400>;
        clocks = <&apb_clk>;
        bus-frequency = <1000000>;
        gpio-controller;
        #gpio-cells = <2>;
        interrupt-controller;
        #interrupt-cells = <2>;
        interrupt-parent = <&gic500>;
        interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
        ngpios = <256>;
    };