# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/pse-pd/ti,tps23881.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: TI TPS23881 Power Sourcing Equipment controller

maintainers:
  - Kory Maincent <kory.maincent@bootlin.com>

allOf:
  - $ref: pse-controller.yaml#

properties:
  compatible:
    enum:
      - ti,tps23881
      - ti,tps23881b

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  '#pse-cells':
    const: 1

  reset-gpios:
    maxItems: 1

  channels:
    description: |
      Defines the 8 physical delivery channels on the controller that can
      be referenced by PSE PIs through their "pairsets" property. The actual
      port matrix mapping is created when PSE PIs reference these channels in
      their pairsets. For 4-pair operation, two channels from the same group
      (0-3 or 4-7) must be referenced by a single PSE PI.
    type: object
    additionalProperties: false

    properties:
      "#address-cells":
        const: 1

      "#size-cells":
        const: 0

    patternProperties:
      '^channel@[0-7]$':
        type: object
        additionalProperties: false

        properties:
          reg:
            maxItems: 1

        required:
          - reg

    required:
      - "#address-cells"
      - "#size-cells"

unevaluatedProperties: false

required:
  - compatible
  - reg
  - interrupts

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

    i2c {
      #address-cells = <1>;
      #size-cells = <0>;

      ethernet-pse@20 {
        compatible = "ti,tps23881";
        reg = <0x20>;
        interrupts = <8 IRQ_TYPE_LEVEL_HIGH>;
        interrupt-parent = <&gpiog>;

        channels {
          #address-cells = <1>;
          #size-cells = <0>;

          phys0: channel@0 {
            reg = <0>;
          };

          phys1: channel@1 {
            reg = <1>;
          };

          phys2: channel@2 {
            reg = <2>;
          };
        };

        pse-pis {
          #address-cells = <1>;
          #size-cells = <0>;

          pse_pi0: pse-pi@0 {
            reg = <0>;
            #pse-cells = <0>;
            pairset-names = "alternative-a", "alternative-b";
            pairsets = <&phys0>, <&phys1>;
            polarity-supported = "MDI", "S";
            vpwr-supply = <&vpwr1>;
          };

          pse_pi1: pse-pi@1 {
            reg = <1>;
            #pse-cells = <0>;
            pairset-names = "alternative-a";
            pairsets = <&phys2>;
            polarity-supported = "MDI";
            vpwr-supply = <&vpwr2>;
          };
        };
      };
    };